Skip to content

Commit

Permalink
fix: move generator into this package
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 27, 2018
1 parent c88a57e commit d379e63
Show file tree
Hide file tree
Showing 75 changed files with 2,155 additions and 271 deletions.
135 changes: 121 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,156 @@
---
version: 2
jobs:
node-latest: &test
node-latest-base: &test
docker:
- image: node:latest
working_directory: ~/cli
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-master-
- run: ./.circleci/test
- store_test_results:
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/greenkeeper
- run: .circleci/setup_git
- run: ./scripts/circleci
- run: yarn exec mocha test/commands/base/*.test.ts
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
key: v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
node-8:
node-latest-single:
<<: *test
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/single/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-latest-plugin:
<<: *test
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/plugin/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-latest-multi:
<<: *test
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/multi/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-base:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/base/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-single:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/single/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-plugin:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/plugin/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-multi:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: yarn exec mocha test/commands/multi/*.test.ts
- store_test_results: *store_test_results
- save_cache: *save_cache

lint:
<<: *test
docker:
- image: node:latest
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: nps lint
- store_test_results: *store_test_results
- save_cache: *save_cache

release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: yarn --frozen-lockfile
- run: ./node_modules/.bin/nps ci.release
- run: ./scripts/greenkeeper
- run: ./scripts/setup_git
- run: ./node_modules/.bin/nps release
- save_cache: *save_cache

workflows:
version: 2
"create-dxcli":
jobs:
- node-latest
- node-8
- lint
- node-latest-base
- node-latest-single
- node-latest-plugin
- node-latest-multi
- node-8-base
- node-8-single
- node-8-plugin
- node-8-multi
- release:
context: org-global
filters:
branches: {only: master}
requires:
- node-latest
- node-8
- lint
- node-latest-base
- node-latest-single
- node-latest-plugin
- node-latest-multi
- node-8-base
- node-8-single
- node-8-plugin
- node-8-multi
15 changes: 1 addition & 14 deletions .circleci/test → .circleci/greenkeeper
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/usr/bin/env bash

set -ex
set -e

PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH

if [[ ! -z "$GIT_EMAIL" ]] & [[ ! -z "$GIT_USERNAME" ]]; then
git config --global push.default simple
git config --global user.email "$GIT_EMAIL"
git config --global user.user "$GIT_USERNAME"
fi

git submodule sync
git submodule update --init --recursive

CLI_ENGINE_UTIL_YARN_ARGS="--frozen-lockfile"

if [[ "$CIRCLE_BRANCH" == greenkeeper/* ]]; then
Expand All @@ -29,7 +20,3 @@ yarn install $CLI_ENGINE_UTIL_YARN_ARGS
if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then
greenkeeper-lockfile-upload
fi

mkdir -p reports
./node_modules/.bin/nps ci
curl -s https://codecov.io/bash | bash
12 changes: 12 additions & 0 deletions .circleci/setup_git
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

if [[ ! -z "$GIT_EMAIL" ]] & [[ ! -z "$GIT_USERNAME" ]]; then
git config --global push.default simple
git config --global user.email "$GIT_EMAIL"
git config --global user.user "$GIT_USERNAME"
fi

git submodule sync
git submodule update --init --recursive
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/lib
/tmp
/templates
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* text=auto
*.js text eol=lf
*.ts text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*-debug.log
*-error.log
/.nyc_output
/coverage
/coverage.lcov
/lib
Expand Down
12 changes: 11 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
environment:
nodejs_version: "9"
matrix:
- TEST_TYPE: base
- TEST_TYPE: single
- TEST_TYPE: plugin
- TEST_TYPE: multi
cache:
- '%LOCALAPPDATA%\Yarn -> appveyor.yml'
- node_modules -> yarn.lock
Expand All @@ -12,7 +17,12 @@ install:
- git config --global user.name "dxcli"
- yarn
test_script:
- yarn test
- npx nps lint
- npx nps test.%TEST_TYPE%.everything
- npx nps test.%TEST_TYPE%.mocha
- npx nps test.%TEST_TYPE%.plain
- npx nps test.%TEST_TYPE%.semantic-release
- npx nps test.%TEST_TYPE%.typescript
after_test:
- ps: |
$env:PATH = 'C:\msys64\usr\bin;' + $env:PATH
Expand Down
12 changes: 11 additions & 1 deletion bin/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/usr/bin/env node

require('generator-dxcli/generators/run')
/* eslint-disable no-unpublished-require */

const undefault = m => m.__esModule === true ? m.default : m

const fs = require('fs')
const path = require('path')
const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))

if (dev) require('ts-node/register')

undefault(require(`../${dev ? 'src' : 'lib'}`))()
63 changes: 29 additions & 34 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
/* eslint-disable node/no-extraneous-require */
const {
concurrent,
crossEnv,
series,
setColors,
} = require('nps-utils')
const script = (script, description) => description ? {script, description} : {script}
const hidden = script => ({script, hiddenFromHelp: true})

const {concurrent} = require('nps-utils')
setColors(['dim'])

module.exports = {
scripts: {
build: 'rm -rf lib && tsc',
lint: {
default: concurrent.nps('lint.eslint', 'lint.commitlint'),
eslint: {
script: 'eslint .',
description: 'lint js files',
},
commitlint: {
script: 'commitlint --from origin/master',
description: 'ensure that commits are in valid conventional-changelog format',
},
default: concurrent.nps('lint.eslint', 'lint.commitlint', 'lint.tsc', 'lint.tslint'),
eslint: script('eslint .', 'lint js files'),
commitlint: script('commitlint --from origin/master', 'ensure that commits are in valid conventional-changelog format'),
tsc: script('tsc -p test --noEmit', 'syntax check with tsc'),
tslint: script('tslint -p test', 'lint ts files'),
},
test: {
default: {
script: concurrent.nps('lint', 'test.single'),
description: 'lint and test',
},
single: {
script: 'node ./scripts/test single',
description: 'test single CLI generator',
},
},
ci: {
default: {
script: concurrent.nps(
'ci.eslint',
),
hiddenFromHelp: true,
},
eslint: {
script: concurrent.nps('lint.eslint --format junit --output-file reports/eslint.xml'),
hiddenFromHelp: true,
},
release: {
script: 'dxcli-dev-semantic-release',
hiddenFromHelp: true,
default: script(concurrent.nps('lint', 'test.mocha'), 'lint and run all tests'),
series: script(series.nps('lint', 'test.mocha'), 'lint and run all tests in series'),
mocha: {
default: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'),
coverage: {
default: hidden(series.nps('test.mocha.nyc nps test.mocha', 'test.mocha.coverage.report')),
report: hidden(series('nps "test.mocha.nyc report --reporter text-lcov" > coverage.lcov')),
},
junit: hidden(series(
crossEnv('MOCHA_FILE="reports/mocha.xml" ') + series.nps('test.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\"'),
series.nps('test.mocha.coverage.report'),
)),
nyc: hidden('nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'),
},
},
release: hidden('semantic-release -e @dxcli/dev-semantic-release'),
},
}
32 changes: 23 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,29 @@
"bin": "bin/run",
"bugs": "https://github.com/dxcli/create-dxcli/issues",
"dependencies": {
"generator-dxcli": "1.15.3"
"@dxcli/engine": "^0.1.11",
"@dxcli/version": "^0.1.5",
"cli-ux": "^3.2.1",
"sort-pjson": "^1.0.2",
"yeoman-environment": "^2.0.5",
"yeoman-generator": "^2.0.2",
"yosay": "^2.0.1"
},
"devDependencies": {
"@dxcli/command": "^0.1.1",
"@dxcli/dev-semantic-release": "^0.0.3",
"eslint": "^4.16.0",
"eslint-config-dxcli": "^1.1.4",
"@dxcli/dev": "^2.0.1",
"@dxcli/dev-test": "^0.9.11",
"@types/shelljs": "^0.7.7",
"@types/yeoman-generator": "^2.0.1",
"@types/yosay": "^0.0.29",
"husky": "^0.14.3",
"nps": "^5.7.1",
"nps-utils": "^1.5.0",
"nyc": "^11.4.1",
"shelljs": "^0.8.0"
"shelljs": "^0.8.1"
},
"dxcli": {
"commands": "./lib/commands",
"plugins": [
"@dxcli/version"
]
},
"engines": {
"node": ">=8.0.0"
Expand All @@ -30,10 +41,13 @@
"dxcli"
],
"license": "MIT",
"main": "lib/index.js",
"repository": "dxcli/create-dxcli",
"scripts": {
"commitmsg": "dxcli-dev-commitmsg",
"precommit": "nps lint",
"prepare": "nps build",
"test": "nps test"
}
},
"types": "lib/index.d.ts"
}

0 comments on commit d379e63

Please sign in to comment.