Skip to content

Commit

Permalink
fix: updates from config/command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 5, 2018
1 parent b98138f commit b2d0733
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 235 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- checkout
- restore_cache: &restore_cache
keys:
- v002-{{checksum ".circleci/config.yml"}}-{{ checksum "yarn.lock"}}
- v002-{{checksum ".circleci/config.yml"}}
- v002
- v1-{{checksum ".circleci/config.yml"}}-{{ checksum "yarn.lock"}}
- v1-{{checksum ".circleci/config.yml"}}
- v1
- run: .circleci/greenkeeper
- run: yarn add -D nyc@11 @anycli/nyc-config@0 mocha-junit-reporter@1 @commitlint/cli@6 @commitlint/config-conventional@6
- run: yarn exec commitlint -- -x @commitlint/config-conventional --from origin/master
Expand Down Expand Up @@ -94,12 +94,12 @@ jobs:
- checkout
- restore_cache:
keys:
- v002-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
- v1-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
- run: yarn global add greenkeeper-lockfile@1
- run: yarn add -D nyc@11 @anycli/nyc-config@0 mocha-junit-reporter@1 @commitlint/cli@6 @commitlint/config-conventional@6
- run: yarn exec nps test.command
- save_cache:
key: v002-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
key: v1-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
paths:
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
},
"bugs": "https://github.com/anycli/cli/issues",
"dependencies": {
"@anycli/command": "^1.2.4",
"@anycli/config": "^1.1.2",
"@anycli/dev-cli": "^0.1.5",
"@anycli/plugin-help": "^0.6.0",
"@anycli/plugin-not-found": "^0.1.15",
"cli-ux": "^3.3.13",
"@anycli/command": "^1.2.7",
"@anycli/config": "^1.2.3",
"@anycli/plugin-help": "^0.6.3",
"@anycli/plugin-not-found": "^0.1.16",
"debug": "^3.1.0",
"fixpack": "^2.3.1",
"lodash": "^4.17.4",
"lodash": "^4.17.5",
"sort-pjson": "^1.0.2",
"yeoman-environment": "^2.0.5",
"yeoman-generator": "^2.0.2",
"yosay": "^2.0.1"
},
"devDependencies": {
"@anycli/dev-cli": "^0.1.6",
"@anycli/tslint": "^0.2.5",
"@types/lodash": "^4.14.100",
"@types/read-pkg": "^3.0.0",
Expand All @@ -41,8 +40,9 @@
"eslint": "^4.17.0",
"eslint-config-anycli": "^1.3.2",
"execa": "^0.9.0",
"fancy-test": "^0.6.10",
"fancy-test": "^1.0.1",
"fs-extra": "^5.0.0",
"globby": "^7.1.1",
"mocha": "^5.0.0",
"npm-run-path": "^2.0.2",
"nps": "^5.7.1",
Expand Down
10 changes: 5 additions & 5 deletions src/commands/command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {flags, parse} from '@anycli/command'
import {flags} from '@anycli/command'

import Base from '../command_base'

Expand All @@ -16,13 +16,13 @@ export default abstract class AppCommand extends Base {
static args = [
{name: 'name', description: 'name of command', required: true}
]
options = parse(this.argv, AppCommand)

async run() {
const {flags, args} = this.parse(AppCommand)
await super.generate('command', {
name: this.options.args.name,
defaults: this.options.flags.defaults,
force: this.options.flags.force
name: args.name,
defaults: flags.defaults,
force: flags.force
})
}
}
29 changes: 12 additions & 17 deletions src/generators/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ class App extends Generator {
this.pjson.scripts.posttest = 'yarn run lint'
// this.pjson.scripts.precommit = 'yarn run lint'
if (this.ts && this.mocha) {
this.pjson.scripts.lint = 'concurrently -p command "eslint ." "tsc -p test --noEmit" "tslint -p test -t stylish"'
this.pjson.scripts.lint = 'concurrently -p command "tsc -p test --noEmit" "tslint -p test -t stylish"'
} else if (this.ts) {
this.pjson.scripts.lint = 'concurrently -p command "eslint ." "tsc -p . --noEmit" "tslint -p . -t stylish"'
this.pjson.scripts.lint = 'concurrently -p command "tsc -p . --noEmit" "tslint -p . -t stylish"'
} else {
this.pjson.scripts.lint = 'eslint .'
}
Expand Down Expand Up @@ -289,11 +289,10 @@ class App extends Generator {
if (this.type === 'multi' && !this.pjson.anycli.plugins) {
this.pjson.anycli.plugins = [
'@anycli/plugin-help',
'@anycli/plugin-not-found',
]
}

if (this.pjson.anycli && _.isArray(this.pjson.anycli.plugins)) {
if (this.pjson.anycli && Array.isArray(this.pjson.anycli.plugins)) {
this.pjson.anycli.plugins.sort()
}

Expand Down Expand Up @@ -354,24 +353,19 @@ class App extends Generator {

install() {
const dependencies: string[] = []
const devDependencies = [
'eslint',
'eslint-config-anycli',
]
const devDependencies: string[] = []
switch (this.type) {
case 'base': break
case 'single':
dependencies.push(
'@anycli/config',
'@anycli/command',
'@anycli/plugin-help',
'cli-ux',
)
break
case 'plugin':
dependencies.push(
'@anycli/command',
'cli-ux',
)
devDependencies.push(
'@anycli/dev-cli',
Expand All @@ -381,12 +375,12 @@ class App extends Generator {
break
case 'multi':
dependencies.push(
'@anycli/dev-cli',
'@anycli/config',
'@anycli/command',
'@anycli/plugin-not-found',
'@anycli/plugin-help',
'cli-ux',
)
devDependencies.push(
'@anycli/dev-cli',
)
}
if (this.mocha) {
Expand All @@ -402,19 +396,20 @@ class App extends Generator {
devDependencies.push(
// '@types/ansi-styles',
'@types/chai',
'@types/lodash',
'@types/mocha',
'@types/nock',
'@types/node',
'@types/node-notifier',
'@types/read-pkg',
// '@types/strip-ansi',
// '@types/supports-color',
'typescript',
'ts-node',
'@anycli/tslint',
'concurrently',
)
} else {
devDependencies.push(
'eslint',
'eslint-config-anycli',
)
}
let yarnOpts = {} as any
if (process.env.YARN_MUTEX) yarnOpts.mutex = process.env.YARN_MUTEX
Expand Down
5 changes: 0 additions & 5 deletions templates/plugin/src/hooks/init.js

This file was deleted.

8 changes: 0 additions & 8 deletions templates/plugin/src/hooks/init.ts

This file was deleted.

3 changes: 1 addition & 2 deletions templates/src/command.js.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const {Command, flags} = require('@anycli/command')
const {cli} = require('cli-ux')
<%_ const klass = _.upperFirst(_.camelCase(name.split(':').slice(-1).join(':') + ':command')) _%>

class <%- klass %> extends Command {
async run() {
const {flags} = this.parse(<%- klass %>)
const name = flags.name || 'world'
cli.log(`hello ${name} from <%- name %>!`)
this.log(`hello ${name} from <%- name %>!`)
}
}

Expand Down
5 changes: 2 additions & 3 deletions templates/src/command.ts.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Command, flags} from '@anycli/command'
import cli from 'cli-ux'
<%_ const klass = _.upperFirst(_.camelCase(name)) _%>

<%_ if (type === 'single') { _%>
Expand Down Expand Up @@ -95,9 +94,9 @@ hello myname from <%- name %>!
const {args, flags} = this.parse(<%- klass %>)
const name = flags.name || 'world'
cli.log(`hello ${name} from <%- name %>!`)
this.log(`hello ${name} from <%- name %>!`)
if (args.file && flags.force) {
cli.log(`you input ${args.file}`)
this.log(`you input ${args.file}`)
}
}
}
Expand Down

0 comments on commit b2d0733

Please sign in to comment.