From e7359f353f3a3f0a5bc478e4ca84355826226377 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Thu, 25 Jan 2018 02:14:09 -0800 Subject: [PATCH] fix: ran generator --- .circleci/config.yml | 17 +++-- .circleci/{test => greenkeeper} | 15 +--- .circleci/setup_git | 12 +++ appveyor.yml | 2 +- package-scripts.js | 130 ++++++++++++++++++-------------- package.json | 1 + src/config.ts | 9 ++- test/tsconfig.json | 8 +- tsconfig.json | 9 ++- yarn.lock | 90 +++++++++++++++++++++- 10 files changed, 197 insertions(+), 96 deletions(-) rename .circleci/{test => greenkeeper} (59%) create mode 100755 .circleci/setup_git diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e42c923..78a2343b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,14 +9,17 @@ jobs: - 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 + - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}} + - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}- + - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-master- + - run: ./.circleci/setup_git + - run: ./.circleci/greenkeeper + - run: yarn exec nps ci.test + - run: curl -s https://codecov.io/bash | bash - 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: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}} paths: - ~/cli/node_modules - /usr/local/share/.cache/yarn @@ -28,10 +31,12 @@ jobs: release: <<: *test steps: + - add_ssh_keys - checkout - restore_cache: *restore_cache + - run: ./.circleci/setup_git - run: yarn --frozen-lockfile - - run: ./node_modules/.bin/nps ci.release + - run: yarn exec nps ci.release - save_cache: *save_cache workflows: diff --git a/.circleci/test b/.circleci/greenkeeper similarity index 59% rename from .circleci/test rename to .circleci/greenkeeper index e0033458..6f89e965 100755 --- a/.circleci/test +++ b/.circleci/greenkeeper @@ -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 @@ -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 diff --git a/.circleci/setup_git b/.circleci/setup_git new file mode 100755 index 00000000..ea1283c8 --- /dev/null +++ b/.circleci/setup_git @@ -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 diff --git a/appveyor.yml b/appveyor.yml index 4d7c1c23..16352266 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ install: - git config --global user.name "dxcli" - yarn test_script: - - yarn test + - .\node_modules\.bin\nps ci.test after_test: - ps: | $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH diff --git a/package-scripts.js b/package-scripts.js index 97e42179..5c267d86 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -1,75 +1,91 @@ -const {concurrent, series} = require('nps-utils') +const { + concurrent, + crossEnv, + ifNotWindows, + ifWindows, + mkdirp, + series, + setColors, +} = require('nps-utils') +const pjson = require('./package.json') +const release = pjson.devDependencies.typedoc ? ['ci.release.semantic-release', 'ci.release.typedoc'] : ['ci.release.semantic-release'] +const script = (script, description) => description ? {script, description} : {script} +const hidden = script => ({script, hiddenFromHelp: true}) +const unixOrWindows = (unix, windows) => series(ifNotWindows(unix), ifWindows(windows)) + +setColors(['dim']) + +let ciTests = [ + 'ci.test.eslint', + 'ci.test.mocha', + 'ci.test.tslint', +] module.exports = { scripts: { build: 'rm -rf lib && tsc', lint: { default: concurrent.nps('lint.eslint', 'lint.commitlint', 'lint.tsc', 'lint.tslint'), - eslint: { - script: 'eslint .', - description: 'lint js files', - }, - commitlint: { - script: 'commitlint --from origin/master', - description: 'ensure that commits are in valid conventional-changelog format', - }, - tsc: { - script: 'tsc -p test --noEmit', - description: 'syntax check with tsc', - }, - tslint: { - script: 'tslint -p test', - description: 'lint ts files', - }, + 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.mocha'), - description: 'lint and run all tests', - }, + 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: { - script: 'mocha "test/**/*.test.ts"', - description: 'run all mocha tests', + 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'), }, }, ci: { - default: { - script: concurrent.nps( - 'ci.mocha', - 'ci.eslint', - 'ci.tslint', + test: { + default: hidden(series( + mkdirp('reports'), + unixOrWindows( + concurrent.nps(...ciTests), + series.nps(...ciTests), + ), + )), + mocha: hidden( + unixOrWindows( + series.nps('test.mocha.junit'), + series.nps('test.mocha.coverage'), + ) + ), + eslint: hidden( + unixOrWindows( + series.nps('lint.eslint --format junit --output-file reports/eslint.xml'), + series.nps('lint.eslint'), + ) + ), + tslint: hidden( + unixOrWindows( + series.nps('lint.tslint --format junit > reports/tslint.xml'), + series.nps('lint.tslint'), + ) ), - hiddenFromHelp: true, - }, - mocha: { - default: { - script: series.nps('ci.mocha.test', 'ci.mocha.report'), - hiddenFromHelp: true, - }, - test: { - script: 'MOCHA_FILE="reports/mocha.xml" nps "ci.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\""', - hiddenFromHelp: true, - }, - report: { - script: series.nps('ci.mocha.nyc report --reporter text-lcov > coverage.lcov'), - hiddenFromHelp: true, - }, - nyc: { - script: 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc', - hiddenFromHelp: true, - }, - }, - eslint: { - script: series.nps('lint.eslint --format junit --output-file reports/eslint.xml'), - hiddenFromHelp: true, - }, - tslint: { - script: series.nps('lint.tslint --format junit > reports/tslint.xml'), - hiddenFromHelp: true, }, + typedoc: hidden('typedoc --out /tmp/docs src/index.ts --excludeNotExported --mode file'), release: { - script: 'dxcli-dev-semantic-release', - hiddenFromHelp: true, + default: hidden(series.nps(...release)), + 'semantic-release': hidden('semantic-release -e @dxcli/dev-semantic-release'), + typedoc: hidden(series( + 'git clone -b gh-pages $CIRCLE_REPOSITORY_URL gh-pages', + 'nps ci.typedoc', + 'rm -rf ./gh-pages/*', + 'mv /tmp/docs/* ./gh-pages', + 'cd gh-pages && git add . && git commit -m "updates from $CIRCLE_SHA1 [skip ci]" && git push', + )), }, }, }, diff --git a/package.json b/package.json index 3dee43f1..40e0e2ca 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "nyc": "^11.4.1", "rxjs": "^5.5.6", "ts-node": "^4.1.0", + "typedoc": "^0.9.0", "typescript": "^2.6.2" }, "engines": { diff --git a/src/config.ts b/src/config.ts index 21b45359..a455ba79 100644 --- a/src/config.ts +++ b/src/config.ts @@ -221,9 +221,12 @@ export class Config { private _debug(): number { try { - let debug = require('debug')(this.bin).enabled || this.scopedEnvVarTrue('DEBUG') - return debug ? 1 : 0 - } catch { return 0 } + const {enabled} = require('debug')(this.bin) + if (enabled) return 1 + if (this.scopedEnvVarTrue('DEBUG')) return 1 + return 0 + // tslint:disable-next-line + } catch (err) { return 0 } } } diff --git a/test/tsconfig.json b/test/tsconfig.json index 7f2685a4..9b49559e 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,12 +1,6 @@ { "extends": "../tsconfig", - "compilerOptions": { - "rootDir": ".." - }, - "exclude": [ - "../plugins/**" - ], "include": [ - "../**/*" + "./**/*" ] } diff --git a/tsconfig.json b/tsconfig.json index 4fc58619..482dee82 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,20 @@ { "compilerOptions": { "declaration": true, - "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, "importHelpers": true, "module": "commonjs", "noUnusedLocals": true, "noUnusedParameters": true, "outDir": "./lib", - "rootDir": "./src", - "strict": true, + "rootDirs": [ + "./src" + ], "sourceMap": true, + "strict": true, "target": "es2017" }, "include": [ - "src/**/*" + "./src/**/*" ] } diff --git a/yarn.lock b/yarn.lock index 29328854..4a870b59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -364,20 +364,46 @@ version "4.1.2" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.2.tgz#f1af664769cfb50af805431c407425ed619daa21" +"@types/fs-extra@4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-4.0.0.tgz#1dd742ad5c9bce308f7a52d02ebc01421bc9102f" + dependencies: + "@types/node" "*" + "@types/fs-extra@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.0.tgz#d3e225b35eb5c6d3a5a782c28219df365c781413" dependencies: "@types/node" "*" +"@types/handlebars@4.0.31": + version "4.0.31" + resolved "https://registry.yarnpkg.com/@types/handlebars/-/handlebars-4.0.31.tgz#a7fba66fafe42713aee88eeca8db91192efe6e72" + +"@types/highlight.js@9.1.8": + version "9.1.8" + resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.1.8.tgz#d227f18bcb8f3f187e16965f2444859a04689758" + "@types/load-json-file@^2.0.7": version "2.0.7" resolved "https://registry.yarnpkg.com/@types/load-json-file/-/load-json-file-2.0.7.tgz#c887826f5230b7507d5230994d26315c6776be06" +"@types/lodash@4.14.74": + version "4.14.74" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.74.tgz#ac3bd8db988e7f7038e5d22bd76a7ba13f876168" + "@types/lodash@^4.14.96": version "4.14.96" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.96.tgz#49a402bb6984af7dd9a48cea3781744a3774bff1" +"@types/marked@0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@types/marked/-/marked-0.3.0.tgz#583c223dd33385a1dda01aaf77b0cd0411c4b524" + +"@types/minimatch@2.0.29": + version "2.0.29" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a" + "@types/mocha@^2.2.47": version "2.2.47" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.47.tgz#30bbd880834d4af0f609025f282a69b8d4458f06" @@ -402,6 +428,12 @@ dependencies: "@types/normalize-package-data" "*" +"@types/shelljs@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.7.0.tgz#229c157c6bc1e67d6b990e6c5e18dbd2ff58cff0" + dependencies: + "@types/node" "*" + "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" @@ -1985,6 +2017,14 @@ fs-extra@^1.0.0: jsonfile "^2.1.0" klaw "^1.0.0" +fs-extra@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-extra@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd" @@ -2194,7 +2234,7 @@ growl@1.10.3: version "1.10.3" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f" -handlebars@^4.0.2, handlebars@^4.0.3: +handlebars@^4.0.2, handlebars@^4.0.3, handlebars@^4.0.6: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" dependencies: @@ -2286,6 +2326,10 @@ heroku-client@3.0.6: is-retry-allowed "^1.0.0" tunnel-agent "^0.6.0" +highlight.js@^9.0.0: + version "9.12.0" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e" + hoek@4.x.x: version "4.2.0" resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" @@ -2974,7 +3018,7 @@ lodash@4.17.2: version "4.17.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42" -lodash@^4.0.0, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1: +lodash@^4.0.0, lodash@^4.13.1, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3038,7 +3082,7 @@ marked-terminal@^2.0.0: lodash.assign "^4.2.0" node-emoji "^1.4.1" -marked@^0.3.9: +marked@^0.3.5, marked@^0.3.9: version "0.3.12" resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.12.tgz#7cf25ff2252632f3fe2406bde258e94eee927519" @@ -3145,7 +3189,7 @@ mimic-fn@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" -"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.4: +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: @@ -4168,6 +4212,14 @@ shelljs@0.7.6: interpret "^1.0.0" rechoir "^0.6.2" +shelljs@^0.7.0: + version "0.7.8" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -4736,6 +4788,36 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" +typedoc-default-themes@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz#6dc2433e78ed8bea8e887a3acde2f31785bd6227" + +typedoc@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.9.0.tgz#159bff7c7784ce5b91d86f3e4cc8928e62040957" + dependencies: + "@types/fs-extra" "4.0.0" + "@types/handlebars" "4.0.31" + "@types/highlight.js" "9.1.8" + "@types/lodash" "4.14.74" + "@types/marked" "0.3.0" + "@types/minimatch" "2.0.29" + "@types/shelljs" "0.7.0" + fs-extra "^4.0.0" + handlebars "^4.0.6" + highlight.js "^9.0.0" + lodash "^4.13.1" + marked "^0.3.5" + minimatch "^3.0.0" + progress "^2.0.0" + shelljs "^0.7.0" + typedoc-default-themes "^0.5.0" + typescript "2.4.1" + +typescript@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc" + typescript@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"