Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: add convertToCached
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent e587135 commit 08edbb4
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 188 deletions.
31 changes: 19 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
- checkout
- restore_cache: &restore_cache
keys:
- 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
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- store_test_results:
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
Expand All @@ -28,16 +28,23 @@ jobs:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- store_test_results: *store_test_results
release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: ./.circleci/setup_git
- run: yarn --frozen-lockfile
- run: yarn exec nps ci.release
- save_cache: *save_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn exec nps release

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion .circleci/setup_git
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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"
git config --global user.name "$GIT_USERNAME"
fi

git submodule sync
Expand Down
22 changes: 22 additions & 0 deletions .circleci/yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

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

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
fi
greenkeeper-lockfile-update
fi

yarn install $CLI_ENGINE_UTIL_YARN_ARGS

if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then
greenkeeper-lockfile-upload
fi
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
- git config --global user.name "dxcli"
- yarn
test_script:
- .\node_modules\.bin\nps ci.test
- yarn test
after_test:
- ps: |
$env:PATH = 'C:\msys64\usr\bin;' + $env:PATH
Expand Down
114 changes: 33 additions & 81 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,44 @@
const {
setColors,
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',
]
const script = (script, description) => description ? {script, description} : {script}

module.exports = {
scripts: {
build: 'rm -rf lib && tsc',
lint: {
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.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'),
},
},
ci: {
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'),
)
),
},
typedoc: hidden('typedoc --out /tmp/docs src/index.ts --excludeNotExported --mode file'),
release: {
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',
)),
},
},
},
const linters = {
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'),
}

const scripts = {
...linters,
lint: concurrent(linters),
test: script(concurrent.nps(...Object.keys(linters), 'mocha'), 'lint and run all tests'),
mocha: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'),
}

if (process.env.CI) {
if (process.env.CIRCLECI) {
scripts.test.script = series(mkdirp('reports'), scripts.test.script)
// add mocha junit reporter
scripts.mocha.script = crossEnv(`MOCHA_FILE=reports/mocha.xml ${scripts.mocha.script} --reporter mocha-junit-reporter`)
// add eslint reporter
scripts.eslint.script = `${scripts.eslint.script} --format junit --output-file reports/eslint.xml`
// add tslint reporter
scripts.tslint.script = `${scripts.tslint.script} --format junit > reports/tslint.xml`
scripts.release = 'semantic-release -e @dxcli/dev-semantic-release'
}
// add code coverage reporting with nyc
const nyc = 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'
const nycReport = `${nyc} report --reporter text-lcov > coverage.lcov`
scripts.mocha.script = series(`${nyc} ${scripts.mocha.script}`, nycReport)
}

module.exports = {scripts}
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
"read-pkg": "^3.0.0"
},
"devDependencies": {
"@dxcli/dev": "^2.0.2",
"@dxcli/config": "^0.1.26",
"@dxcli/dev": "^2.0.5",
"@dxcli/engine": "^0.1.12",
"@heroku-cli/config-edit": "^1.0.4",
"@types/fs-extra": "^5.0.0",
"@types/load-json-file": "^2.0.7",
"fancy-test": "^0.5.4",
"chai": "^4.1.2",
"eslint": "^4.16.0",
"fancy-test": "^0.5.5",
"husky": "^0.14.3",
"mocha": "^5.0.0",
"nps": "^5.7.1",
"nps-utils": "^1.5.0",
"ts-node": "^4.1.0"
"ts-node": "^4.1.0",
"typescript": "^2.6.2"
},
"engines": {
"node": ">=8.0.0"
Expand All @@ -37,9 +43,9 @@
"repository": "dxcli/config",
"scripts": {
"commitmsg": "dxcli-dev-commitmsg",
"precommit": "nps lint",
"prepare": "nps build",
"test": "nps test"
"precommit": "nps lint -l warn",
"prepare": "rm -rf lib && tsc",
"test": "nps test -l warn"
},
"types": "lib/index.d.ts"
}
1 change: 1 addition & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ICachedCommand {

export interface ICommand extends ICachedCommand {
run(argv: string[], opts?: ICommandOptions): Promise<void>
convertToCached(): ICachedCommand
}

export interface ICommandOptions {
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig",
"include": [
"./**/*"
"./**/*",
"../src/**/*"
]
}
Loading

0 comments on commit 08edbb4

Please sign in to comment.