From 56f02d5a51c8f4347fa387da9a4d8c820ec490d6 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:27:27 +0530 Subject: [PATCH 01/12] [HASHES]: removed hello command --- src/commands/hello.ts | 31 ------------------------------- test/commands/hash.test.ts | 2 +- test/commands/hello.test.ts | 17 ----------------- 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 src/commands/hello.ts delete mode 100644 test/commands/hello.test.ts diff --git a/src/commands/hello.ts b/src/commands/hello.ts deleted file mode 100644 index 562bb81..0000000 --- a/src/commands/hello.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {Command, flags} from '@oclif/command' - -export default class Hello extends Command { - static description = 'describe the command here' - - static examples = [ - `$ cdt hello -hello world from ./src/hello.ts! -`, - ] - - static flags = { - help: flags.help({char: 'h'}), - // flag with a value (-n, --name=VALUE) - name: flags.string({char: 'n', description: 'name to print'}), - // flag with no value (-f, --force) - force: flags.boolean({char: 'f'}), - } - - static args = [{name: 'file'}] - - async run() { - const {args, flags} = this.parse(Hello) - - const name = flags.name || 'world' - this.log(`hello ${name} from ./src/commands/hello.ts`) - if (args.file && flags.force) { - this.log(`you input --force and --file: ${args.file}`) - } - } -} diff --git a/test/commands/hash.test.ts b/test/commands/hash.test.ts index 3758c16..29ba17a 100644 --- a/test/commands/hash.test.ts +++ b/test/commands/hash.test.ts @@ -11,7 +11,7 @@ describe('hash', () => { // passing sha1 as option test .stdout() - .command(['hash', 'ashish' ,'-t','sha1']) + .command(['hash', 'ashish' , '-t', 'sha1']) .it("cdt hash 'ashish' -t 'sha1'", ctx => { expect(ctx.stdout).to.contain('428b6da53085b8fd7b37e9fb259c0c609bd09984') }) diff --git a/test/commands/hello.test.ts b/test/commands/hello.test.ts deleted file mode 100644 index 651a421..0000000 --- a/test/commands/hello.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {expect, test} from '@oclif/test' - -describe('hello', () => { - test - .stdout() - .command(['hello']) - .it('runs hello', ctx => { - expect(ctx.stdout).to.contain('hello world') - }) - - test - .stdout() - .command(['hello', '--name', 'jeff']) - .it('runs hello --name jeff', ctx => { - expect(ctx.stdout).to.contain('hello jeff') - }) -}) From a97a788ad12537b93ef5d7bcfa932f40472d5594 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:35:53 +0530 Subject: [PATCH 02/12] [CIRCLE_CI]: added new config.yml --- .circleci/config.yml | 84 +++++++++++++++++----------------------- .circleci/config_tmp.yml | 64 ++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 48 deletions(-) create mode 100644 .circleci/config_tmp.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 8eb26be..c90b580 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,65 +1,53 @@ ---- version: 2 jobs: - node-latest: &test + build: + working_directory: ~/mern-starter + # The primary container is an instance of the first image listed. The job's commands run in this container. docker: - - image: node:latest - working_directory: ~/cli + - image: circleci/node:4.8.2-jessie + # The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost. + - image: mongo:3.4.4-jessie steps: - checkout - - restore_cache: &restore_cache - keys: - - v1-npm-{{checksum ".circleci/config.yml"}}-{{ checksum "package-lock.json"}} - - v1-npm-{{checksum ".circleci/config.yml"}} - run: - name: Install dependencies - command: .circleci/greenkeeper - - run: ./bin/run --version - - run: ./bin/run --help + name: Update npm + command: 'sudo npm install -g npm@latest' + - restore_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} - run: - name: Testing - command: npm test - - run: - name: Submitting code coverage to codecov - command: | - ./node_modules/.bin/nyc report --reporter text-lcov > coverage.lcov - curl -s https://codecov.io/bash | bash - node-8: - <<: *test + name: Install npm wee + command: npm install + - save_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + paths: + - node_modules + test: docker: - - image: node:8 - release: - <<: *test + - image: circleci/node:4.8.2-jessie + - image: mongo:3.4.4-jessie steps: - - add_ssh_keys - checkout - - restore_cache: *restore_cache - run: - name: Install dependencies - command: | - npm install -g @oclif/semantic-release@3 semantic-release@15 - npm install + name: Test + command: npm test - run: - name: Cutting release - command: | - semantic-release -e @oclif/semantic-release - - save_cache: - key: v1-npm-{{checksum ".circleci/config.yml"}}-{{checksum "package-lock.json"}} - paths: - - ~/cli/node_modules - - ~/.npm - - /usr/local/lib/node_modules + name: Generate code coverage + command: './node_modules/.bin/nyc report --reporter=text-lcov' + - store_artifacts: + path: test-results.xml + prefix: tests + - store_artifacts: + path: coverage + prefix: coverage workflows: version: 2 - "cdt": + build_and_test: jobs: - - node-latest - - node-8 - - release: - context: org-global - filters: - branches: {only: master} + - build + - test: requires: - - node-latest - - node-8 + - build + filters: + branches: + only: master diff --git a/.circleci/config_tmp.yml b/.circleci/config_tmp.yml new file mode 100644 index 0000000..266a5e6 --- /dev/null +++ b/.circleci/config_tmp.yml @@ -0,0 +1,64 @@ +version: 2 +jobs: + node-latest: &test + docker: + - image: node:latest + working_directory: ~/cli + steps: + - checkout + - restore_cache: &restore_cache + keys: + - v1-npm-{{checksum ".circleci/config_tmp.yml"}}-{{ checksum "package-lock.json"}} + - v1-npm-{{checksum ".circleci/config_tmp.yml"}} + - run: + name: Install dependencies + command: .circleci/greenkeeper + - run: ./bin/run --version + - run: ./bin/run --help + - run: + name: Testing + command: npm test + - run: + name: Submitting code coverage to codecov + command: | + ./node_modules/.bin/nyc report --reporter text-lcov > coverage.lcov + curl -s https://codecov.io/bash | bash + node-8: + <<: *test + docker: + - image: node:8 + release: + <<: *test + steps: + - add_ssh_keys + - checkout + - restore_cache: *restore_cache + - run: + name: Install dependencies + command: | + npm install -g @oclif/semantic-release@3 semantic-release@15 + npm install + - run: + name: Cutting release + command: | + semantic-release -e @oclif/semantic-release + - save_cache: + key: v1-npm-{{checksum ".circleci/config_tmp.yml"}}-{{checksum "package-lock.json"}} + paths: + - ~/cli/node_modules + - ~/.npm + - /usr/local/lib/node_modules + +workflows: + version: 2 + "cdt": + jobs: + - node-latest + - node-8 + - release: + context: org-global + filters: + branches: {only: master} + requires: + - node-latest + - node-8 From bdd8e769162d30e421b91a43fd06ba848751e1a3 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:40:29 +0530 Subject: [PATCH 03/12] [CIRCLE_CI]: added new version for node --- .circleci/config.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c90b580..a2609e4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,9 +4,8 @@ jobs: working_directory: ~/mern-starter # The primary container is an instance of the first image listed. The job's commands run in this container. docker: - - image: circleci/node:4.8.2-jessie + - image: circleci/node:latest # The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost. - - image: mongo:3.4.4-jessie steps: - checkout - run: @@ -23,8 +22,7 @@ jobs: - node_modules test: docker: - - image: circleci/node:4.8.2-jessie - - image: mongo:3.4.4-jessie + - image: circleci/node:latest steps: - checkout - run: From f4ba8aa7b9405e98215ec2382e1870e4c9467977 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:43:43 +0530 Subject: [PATCH 04/12] [CIRCLE_CI]: removing filters so tests run on all branches --- .circleci/config.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a2609e4..d3a7d56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ jobs: - restore_cache: key: dependency-cache-{{ checksum "package-lock.json" }} - run: - name: Install npm wee + name: Install npm dependencies command: npm install - save_cache: key: dependency-cache-{{ checksum "package-lock.json" }} @@ -46,6 +46,3 @@ workflows: - test: requires: - build - filters: - branches: - only: master From 6a8c414596ef48c138b6764d366c4c737ad4de03 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:48:19 +0530 Subject: [PATCH 05/12] [CIRCLE_CI]: npm test changed to include nyc from node_modules --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 199de0e..07644da 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "postpack": "rm -f oclif.manifest.json", "posttest": "tslint -p test -t stylish", "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", - "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", + "test": "node_modules/.bin/nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif-dev readme && git add README.md" }, "types": "lib/index.d.ts" From 2d2113800ebd8984176e43e091b7dc5d98ae46e1 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:51:35 +0530 Subject: [PATCH 06/12] [CIRCLE_CI]: nyc moved from devDependencies to dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 07644da..8e22462 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "@oclif/config": "^1.13.3", "@oclif/plugin-help": "^2.2.1", "jshashes": "^1.0.7", - "tslib": "^1.10.0" + "tslib": "^1.10.0", + "nyc": "^13.3.0" }, "devDependencies": { "@oclif/dev-cli": "^1.22.2", @@ -24,7 +25,6 @@ "chai": "^4.2.0", "globby": "^10.0.1", "mocha": "^5.2.0", - "nyc": "^13.3.0", "ts-node": "^8.4.1", "tslint": "^5.20.0", "typescript": "^3.6.4" @@ -56,7 +56,7 @@ "postpack": "rm -f oclif.manifest.json", "posttest": "tslint -p test -t stylish", "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", - "test": "node_modules/.bin/nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", + "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif-dev readme && git add README.md" }, "types": "lib/index.d.ts" From c780f5396c57da1fa35c30f2a7494625751d07ff Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 00:57:15 +0530 Subject: [PATCH 07/12] [CIRCLE_CI]: full path used --- package.json | 2 +- src/commands/hash.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8e22462..2b2fbdc 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "postpack": "rm -f oclif.manifest.json", "posttest": "tslint -p test -t stylish", "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", - "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", + "test": "./node_modules/.bin/nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif-dev readme && git add README.md" }, "types": "lib/index.d.ts" diff --git a/src/commands/hash.ts b/src/commands/hash.ts index 11e58b4..b411b5d 100644 --- a/src/commands/hash.ts +++ b/src/commands/hash.ts @@ -33,7 +33,6 @@ export default class Hash extends Command { } else str = args.string - this.log(str) this.calculateHash(type, str) } @@ -61,7 +60,7 @@ export default class Hash extends Command { if (hash) { let hashed: string = hash.hex(str) - this.log(`[HASH]: ${hashed}`) + this.log(`[${type.toUpperCase()}]: ${hashed}`) } else { this.log('[ERROR]: invalid hash type') } From b21a9d77e5eb08e96e34fd0bf9d730cc70d1271a Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 01:03:56 +0530 Subject: [PATCH 08/12] [CIRCLE_CI]: cache restore added --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d3a7d56..93f240c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,8 @@ jobs: - image: circleci/node:latest steps: - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} - run: name: Test command: npm test From bc43f13a6baf8915cd3282d6ec40238f99b15fc2 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 01:06:02 +0530 Subject: [PATCH 09/12] [CIRCLE_CI]: directly command used in config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 93f240c..6b20f4f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ jobs: key: dependency-cache-{{ checksum "package-lock.json" }} - run: name: Test - command: npm test + command: './node_modules/.bin/nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"' - run: name: Generate code coverage command: './node_modules/.bin/nyc report --reporter=text-lcov' From 7e3ab96000126c60c01273fcf595a8d5999c6dbb Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 01:14:09 +0530 Subject: [PATCH 10/12] [CIRCLE_CI]: npm install added for test also --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b20f4f..2377d00 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,11 +25,12 @@ jobs: - image: circleci/node:latest steps: - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} + - run: + name: Install npm dependencies + command: npm install - run: name: Test - command: './node_modules/.bin/nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"' + command: npm test - run: name: Generate code coverage command: './node_modules/.bin/nyc report --reporter=text-lcov' From d0fa2cad8f2bf2b8cb073a757a4b99c92d8f66c7 Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 01:20:41 +0530 Subject: [PATCH 11/12] [CIRCLE_CI]: added same thing in both jobs --- .circleci/config.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2377d00..dd2878a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,9 +25,19 @@ jobs: - image: circleci/node:latest steps: - checkout + # needed to add here also as both install and test are different docker instances and need to do same thing again in different instance + - run: + name: Update npm + command: 'sudo npm install -g npm@latest' + - restore_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} - run: name: Install npm dependencies command: npm install + - save_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + paths: + - node_modules - run: name: Test command: npm test From b14ab1f3dc2d6c35aa6e572f775e93c30ee9a4ee Mon Sep 17 00:00:00 2001 From: ashish Date: Wed, 23 Oct 2019 01:23:49 +0530 Subject: [PATCH 12/12] [CIRCLE_CI]: added config for single job --- .circleci/config.yml | 25 ++-------------- .circleci/config_2jobs.yml | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 .circleci/config_2jobs.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index dd2878a..b61b03f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2 jobs: - build: + build_and_test: working_directory: ~/mern-starter # The primary container is an instance of the first image listed. The job's commands run in this container. docker: @@ -20,24 +20,6 @@ jobs: key: dependency-cache-{{ checksum "package-lock.json" }} paths: - node_modules - test: - docker: - - image: circleci/node:latest - steps: - - checkout - # needed to add here also as both install and test are different docker instances and need to do same thing again in different instance - - run: - name: Update npm - command: 'sudo npm install -g npm@latest' - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install npm dependencies - command: npm install - - save_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - paths: - - node_modules - run: name: Test command: npm test @@ -55,7 +37,4 @@ workflows: version: 2 build_and_test: jobs: - - build - - test: - requires: - - build + - build_and_test diff --git a/.circleci/config_2jobs.yml b/.circleci/config_2jobs.yml new file mode 100644 index 0000000..dd2878a --- /dev/null +++ b/.circleci/config_2jobs.yml @@ -0,0 +1,61 @@ +version: 2 +jobs: + build: + working_directory: ~/mern-starter + # The primary container is an instance of the first image listed. The job's commands run in this container. + docker: + - image: circleci/node:latest + # The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost. + steps: + - checkout + - run: + name: Update npm + command: 'sudo npm install -g npm@latest' + - restore_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + - run: + name: Install npm dependencies + command: npm install + - save_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + paths: + - node_modules + test: + docker: + - image: circleci/node:latest + steps: + - checkout + # needed to add here also as both install and test are different docker instances and need to do same thing again in different instance + - run: + name: Update npm + command: 'sudo npm install -g npm@latest' + - restore_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + - run: + name: Install npm dependencies + command: npm install + - save_cache: + key: dependency-cache-{{ checksum "package-lock.json" }} + paths: + - node_modules + - run: + name: Test + command: npm test + - run: + name: Generate code coverage + command: './node_modules/.bin/nyc report --reporter=text-lcov' + - store_artifacts: + path: test-results.xml + prefix: tests + - store_artifacts: + path: coverage + prefix: coverage + +workflows: + version: 2 + build_and_test: + jobs: + - build + - test: + requires: + - build