diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e93be8..ef76b61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}} - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}- - v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-master- - - run: ./scripts/circleci + - run: ./scripts/circleci test - store_test_results: path: ~/cli/reports - save_cache: &save_cache @@ -30,8 +30,7 @@ jobs: steps: - checkout - restore_cache: *restore_cache - - run: yarn - - run: ./node_modules/.bin/dxcli-dev-semantic-release + - run: ./scripts/circleci release - save_cache: *save_cache workflows: diff --git a/.gitattributes b/.gitattributes index 176a458..3beda43 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ * text=auto +*.js text eol=lf +*.ts text eol=lf diff --git a/.gitignore b/.gitignore index d2c07ab..7bc5cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ *-debug.log *-error.log +/.nyc_output /coverage +/coverage.lcov +/lib /node_modules /tmp -/lib -/.nyc_output diff --git a/appveyor.yml b/appveyor.yml index a5177d6..b3d6d2a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,10 +2,12 @@ environment: nodejs_version: "9" cache: - '%LOCALAPPDATA%\Yarn -> appveyor.yml' - - node_modules -> package.json + - node_modules -> yarn.lock install: - ps: Install-Product node $env:nodejs_version x64 + - git config --global user.email "dxcli@example.com" + - git config --global user.name "dxcli" - yarn test_script: - yarn test diff --git a/package.json b/package.json index bddfa3a..2b01fee 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "lodash": "^4.17.4" }, "devDependencies": { - "@dxcli/dev": "^1.1.2", + "@dxcli/dev": "^1.1.3", "@dxcli/dev-semantic-release": "^0.0.3", - "@dxcli/dev-test": "^0.0.1", - "@dxcli/dev-tslint": "^0.0.8", + "@dxcli/dev-test": "^0.1.1", + "@dxcli/dev-tslint": "^0.0.9", "@heroku/linewrap": "^1.0.0", "@types/chalk": "^2.2.0", "@types/node": "^9.3.0", @@ -28,18 +28,16 @@ "workflows": { "test": [ "eslint .", - "tsc", - "tslint -p .", - "commitlint --from master", "tsc -p test --noEmit", + "tslint -p test", + "commitlint --from origin/master", "mocha \"test/**/*.ts\"" ], "lint": [ "eslint .", - "tsc", - "tslint -p .", - "commitlint --from master", - "tsc -p test --noEmit" + "tsc -p test --noEmit", + "tslint -p test", + "commitlint --from origin/master" ] } }, diff --git a/scripts/circleci b/scripts/circleci index c135e0c..2b92881 100755 --- a/scripts/circleci +++ b/scripts/circleci @@ -2,33 +2,61 @@ set -ex +duration() { + set +x + start=$(date +%s) + "$@" + end=$(date +%s) + python -c "print 'Ran $1 in %u:%02u' % ((${end} - ${start})/60, (${end} - ${start})%60)" + set -x +} + PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH -CLI_ENGINE_UTIL_YARN_ARGS="--frozen-lockfile" +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 + +_test() { + CLI_ENGINE_UTIL_YARN_ARGS="--frozen-lockfile" -if [[ "$CIRCLE_BRANCH" == greenkeeper/* ]]; then - CLI_ENGINE_GREENKEEPER_BRANCH=1 - CLI_ENGINE_UTIL_YARN_ARGS="" - if [[ ! -x "$(command -v greenkeeper-lockfile-update)" ]]; then - yarn global add greenkeeper-lockfile@1 + if [[ "$CIRCLE_BRANCH" == greenkeeper/* ]]; then + CLI_ENGINE_GREENKEEPER_BRANCH=1 + CLI_ENGINE_UTIL_YARN_ARGS="" + if [[ ! -x "$(command -v greenkeeper-lockfile-update)" ]]; then + duration yarn global add greenkeeper-lockfile@1 + fi + duration greenkeeper-lockfile-update fi - greenkeeper-lockfile-update -fi -yarn install $CLI_ENGINE_UTIL_YARN_ARGS + duration yarn install $CLI_ENGINE_UTIL_YARN_ARGS -if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then - greenkeeper-lockfile-upload -fi + if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then + duration greenkeeper-lockfile-upload + fi -CWD=$(pwd) -NYC="./node_modules/.bin/nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc" -mkdir -p reports -MOCHA_FILE="$CWD/reports/mocha.xml" \ - DXCLI_MOCHA_OPTS="--reporter mocha-junit-reporter" \ - DXCLI_ESLINT_OPTS="--format junit --output-file $CWD/reports/eslint.xml" \ - DXCLI_TSLINT_OPTS="--format junit > $CWD/reports/tslint.xml" \ - $NYC yarn test -$NYC report --reporter=text-lcov > coverage.lcov - -curl -s https://codecov.io/bash | bash + CWD=$(pwd) + NYC=(./node_modules/.bin/nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc) + mkdir -p reports + MOCHA_FILE="$CWD/reports/mocha.xml" \ + DXCLI_MOCHA_OPTS="--reporter mocha-junit-reporter" \ + DXCLI_ESLINT_OPTS="--format junit --output-file $CWD/reports/eslint.xml" \ + DXCLI_TSLINT_OPTS="--format junit > $CWD/reports/tslint.xml" \ + duration "${NYC[@]}" yarn test + + duration "${NYC[@]}" report --reporter=text-lcov > coverage.lcov + + duration curl -s https://codecov.io/bash | bash +} + +_release() { + yarn --frozen-lockfile + ./node_modules/.bin/dxcli-dev-semantic-release +} + +case "$1" in + release) _release;; + *) _test;; +esac diff --git a/test/parse.test.ts b/test/parse.test.ts index 91718bd..c898d2f 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -214,7 +214,7 @@ See more help with --help`) foo: flags.string(), }, }) - expect(out.flags.foo!.toUpperCase()).to.equal('C') + expect(out.flags.foo.toUpperCase()).to.equal('C') expect(out.flags.bar.join('|')).to.equal('a|b') }) }) diff --git a/yarn.lock b/yarn.lock index 2463af9..39b9312 100644 --- a/yarn.lock +++ b/yarn.lock @@ -130,9 +130,9 @@ "@semantic-release/npm" "^2.6.1" semantic-release "^12.2.0" -"@dxcli/dev-test@^0.0.1": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@dxcli/dev-test/-/dev-test-0.0.1.tgz#8440c7fec40ccf7ad5dc21d5224be09ca42a4cb4" +"@dxcli/dev-test@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@dxcli/dev-test/-/dev-test-0.1.1.tgz#6a03471c700412e3b04724501e083310777beda1" dependencies: "@dxcli/dev-nyc-config" "^0.0.3" "@types/ansi-styles" "^2.0.30" @@ -147,16 +147,16 @@ strip-ansi "^4.0.0" ts-node "^4.1.0" -"@dxcli/dev-tslint@^0.0.8": - version "0.0.8" - resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.8.tgz#f07750d0152b26764b43fd99110076db87b4a22e" +"@dxcli/dev-tslint@^0.0.9": + version "0.0.9" + resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.9.tgz#552b62b769ede24b30fdc3b8c04e10b1a60f027f" dependencies: tslint "^5.9.1" tslint-xo "^0.5.0" -"@dxcli/dev@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@dxcli/dev/-/dev-1.1.2.tgz#66acd0b6d5cc9cf8a94a00692c67d40c94ebf81b" +"@dxcli/dev@^1.1.3": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@dxcli/dev/-/dev-1.1.3.tgz#da1b929372cae0af15f78849483494a74c3c075e" dependencies: cli-ux "^2.0.21" concurrently "^3.5.1"