diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a1f7f03..ed695433 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 bc585939..9c2d45b2 100644 --- a/package.json +++ b/package.json @@ -20,24 +20,24 @@ "devDependencies": { "@dxcli/dev-nyc-config": "^0.0.3", "@dxcli/dev-semantic-release": "^0.1.0", - "@dxcli/dev-tslint": "^0.0.15", + "@dxcli/dev-tslint": "^0.0.16", "@types/ansi-styles": "^2.0.30", "@types/chai": "^4.1.2", "@types/fs-extra": "^5.0.0", "@types/lodash": "^4.14.96", "@types/mocha": "^2.2.47", "@types/nock": "^9.1.2", - "@types/node": "^9.3.0", + "@types/node": "^9.4.0", "@types/semver": "^5.4.0", "@types/strip-ansi": "^3.0.0", "@types/supports-color": "^3.1.0", "chai": "^4.1.2", "eslint": "^4.16.0", "eslint-config-dxcli": "^1.1.4", - "fancy-mocha": "^0.3.2", + "fancy-mocha": "^0.3.3", "husky": "^0.14.3", "mocha": "^5.0.0", - "mocha-junit-reporter": "^1.16.0", + "mocha-junit-reporter": "^1.17.0", "nps": "^5.7.1", "nps-utils": "^1.5.0", "nyc": "^11.4.1", diff --git a/test/tsconfig.json b/test/tsconfig.json index 9dafb917..0503bd73 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,10 +1,7 @@ { "extends": "../tsconfig", - "compilerOptions": { - "rootDir": ".." - }, "include": [ - "../src/**/*", - "../test/**/*" + "./**/*", + "../src/**/*" ] } diff --git a/tsconfig.json b/tsconfig.json index 587bb841..482dee82 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,18 +1,20 @@ { "compilerOptions": { "declaration": true, + "forceConsistentCasingInFileNames": true, "importHelpers": true, "module": "commonjs", "noUnusedLocals": true, "noUnusedParameters": true, "outDir": "./lib", - "rootDir": "./src", - "strict": true, - "strictFunctionTypes": false, + "rootDirs": [ + "./src" + ], "sourceMap": true, + "strict": true, "target": "es2017" }, "include": [ - "src/**/*" + "./src/**/*" ] } diff --git a/yarn.lock b/yarn.lock index d5f7ce73..2f108ecb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -126,9 +126,9 @@ "@semantic-release/npm" "^2.6.4" semantic-release "^12.2.2" -"@dxcli/dev-tslint@^0.0.15": - version "0.0.15" - resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.15.tgz#54dbd49deccaaaf9dc590d83894415e3fab0b0ac" +"@dxcli/dev-tslint@^0.0.16": + version "0.0.16" + resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.16.tgz#84aa077d5f0c92f770b2b7eb091588c8553b4c9f" dependencies: tslint "^5.9.1" tslint-xo "^0.5.0" @@ -273,10 +273,14 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@^9.3.0": +"@types/node@*": version "9.3.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.3.0.tgz#3a129cda7c4e5df2409702626892cb4b96546dd5" +"@types/node@^9.4.0": + version "9.4.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1" + "@types/semver@^5.4.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.4.0.tgz#f3658535af7f1f502acd6da7daf405ffeb1f7ee4" @@ -1618,9 +1622,9 @@ extsprintf@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" -fancy-mocha@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/fancy-mocha/-/fancy-mocha-0.3.2.tgz#4bcc8dc4f323224ce0733bd1a093d8c485852406" +fancy-mocha@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/fancy-mocha/-/fancy-mocha-0.3.3.tgz#414359b859e84cb8d25a9183d02fc52c03d43403" dependencies: lodash "^4.17.4" stdout-stderr "^0.1.4" @@ -2947,13 +2951,14 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "0.0.8" -mocha-junit-reporter@^1.16.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.16.0.tgz#3d76af53e2f5e81f9b93406acee1e48b5dd6e6cc" +mocha-junit-reporter@^1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.17.0.tgz#2e5149ed40fc5d2e3ca71e42db5ab1fec9c6d85c" dependencies: debug "^2.2.0" md5 "^2.1.0" mkdirp "~0.5.1" + strip-ansi "^4.0.0" xml "^1.0.0" mocha@^5.0.0: