Skip to content

Commit

Permalink
Add oclif
Browse files Browse the repository at this point in the history
  • Loading branch information
pepicrft committed Jan 11, 2022
1 parent 064ea2d commit 8cb811d
Show file tree
Hide file tree
Showing 14 changed files with 751 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "npm"
versioning-strategy: increase
directory: "/"
schedule:
interval: "monthly"
labels:
- "dependencies"
open-pull-requests-limit: 100
pull-request-branch-name:
separator: "-"
ignore:
- dependency-name: "fs-extra"
- dependency-name: "*"
update-types: ["version-update:semver-major"]
6 changes: 6 additions & 0 deletions packages/cli/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"oclif",
"oclif-typescript"
]
}
17 changes: 17 additions & 0 deletions packages/cli/bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

const oclif = require('@oclif/core')

const path = require('path')
const project = path.join(__dirname, '..', 'tsconfig.json')

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development'

require('ts-node').register({project})

// In dev mode, always show stack traces
oclif.settings.debug = true;

// Start the CLI
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
3 changes: 3 additions & 0 deletions packages/cli/bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
5 changes: 5 additions & 0 deletions packages/cli/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

const oclif = require('@oclif/core')

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
3 changes: 3 additions & 0 deletions packages/cli/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
Empty file modified packages/cli/bin/shopify.mjs
100644 → 100755
Empty file.
11 changes: 8 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
"shopify": "./bin/shopify.mjs"
},
"dependencies": {
"@oclif/core": "^1",
"@oclif/plugin-help": "^5",
"@oclif/plugin-plugins": "^2.0.1"
},
"devDependencies": {
"@oclif/test": "^2"
},
"devDependencies": {},
"peerDependencies": {},
"files": [
"dist",
"bin",
"*.d.ts",
"*.mjs"
"*.mjs",
"oclif.manifest.json"
]
}
23 changes: 23 additions & 0 deletions packages/cli/src/hello/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Command, Flags} from '@oclif/core'

export default class Hello extends Command {
static description = 'Say hello'

static examples = [
`$ oex hello friend --from oclif
hello friend from oclif! (./src/commands/hello/index.ts)
`,
]

static flags = {
from: Flags.string({char: 'f', description: 'Whom is saying hello', required: true}),
}

static args = [{name: 'person', description: 'Person to say hello to', required: true}]

async run(): Promise<void> {
const {args, flags} = await this.parse(Hello)

this.log(`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`)
}
}
19 changes: 19 additions & 0 deletions packages/cli/src/hello/world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Command} from '@oclif/core'

export default class World extends Command {
static description = 'Say hello world'

static examples = [
`$ oex hello world
hello world! (./src/commands/hello/world.ts)
`,
]

static flags = {}

static args = []

async run(): Promise<void> {
this.log('hello world! (./src/commands/hello/world.ts)')
}
}
1 change: 1 addition & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {run} from '@oclif/core'
Loading

0 comments on commit 8cb811d

Please sign in to comment.