From 762ec9d7fbbe02265bdb28fb4dc54707a244cdc6 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 17 Jun 2019 16:50:23 +0800 Subject: [PATCH 01/20] workflow: allow release to local registry for testing purpose --- scripts/release.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/release.js b/scripts/release.js index a7d575f297..03ffdea481 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -36,9 +36,18 @@ process.env.VUE_CLI_RELEASE = true const execa = require('execa') const semver = require('semver') const inquirer = require('inquirer') +const minimist = require('minimist') const { syncDeps } = require('./syncDeps') // const { buildEditorConfig } = require('./buildEditorConfig') +const cliOptions = minimist(process.argv) +if (cliOptions['local-registry']) { + inquirer.prompt = () => ({ + bump: 'minor', + yes: true + }) +} + const curVersion = require('../lerna.json').version const release = async () => { @@ -96,7 +105,7 @@ const release = async () => { const releaseType = semver.diff(curVersion, version) let distTag = 'latest' - if (releaseType.startsWith('pre')) { + if (releaseType.startsWith('pre') && !cliOptions['local-registry']) { distTag = 'next' } @@ -111,6 +120,10 @@ const release = async () => { lernaArgs.push('--force-publish') } + if (cliOptions['local-registry']) { + lernaArgs.push('--no-git-tag-version', '--no-commit-hooks', '--no-push') + } + await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' }) } From 6f0b8971eba7435c1994ef6fbbef51be8fe0edd4 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 24 Jun 2019 23:31:07 +0800 Subject: [PATCH 02/20] ci: add script for running a local registry with verdaccio --- scripts/local-registry.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/local-registry.sh diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh new file mode 100644 index 0000000000..4964a582e2 --- /dev/null +++ b/scripts/local-registry.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# adapted from https://github.com/facebook/create-react-app/blob/master/tasks/local-registry.sh + +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` +default_verdaccio_package=verdaccio@4 + +function startLocalRegistry { + # Start local registry + tmp_registry_log=`mktemp` + echo "Registry output file: $tmp_registry_log" + (cd && nohup npx $default_verdaccio_package -c $1 &>$tmp_registry_log &) + # Wait for Verdaccio to boot + grep -q 'http address' <(tail -f $tmp_registry_log) + + # Set registry to local registry + npm set registry "$custom_registry_url" + yarn config set registry "$custom_registry_url" + + # Login so we can publish packages + (cd && npx npm-auth-to-token@1 -u user -p password -e user@example.com -r "$custom_registry_url") +} + +function stopLocalRegistry { + # Restore the original NPM and Yarn registry URLs and stop Verdaccio + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" + + # Kill Verdaccio process + ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9 +} + +function publishToLocalRegistry { + git clean -df + yarn release --local-registry +} From 20199b3d6fece9dc1f74c56ee928daa90e5a9880 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 16:20:51 +0800 Subject: [PATCH 03/20] ci: run jest tests in an upper level directory --- .circleci/config.yml | 15 ++++++++++++++- .../__tests__/jestPlugin.spec.js | 7 ++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4edeeb5a59..0d955f33ba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,10 +59,19 @@ jobs: steps: - attach_workspace: at: ~/ - - run: yarn test -p unit-mocha,unit-jest,e2e-cypress + - run: yarn test -p unit-mocha,e2e-cypress # e2e-nightwatch was left out due to some unknown issues with selenium and the CI image - run: yarn test tsPluginE2e + tests-after-publish: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - run: ./scripts/local-registry.sh + - run: yarn release --local-registry + - run: yarn test -p unit-jest + cli-ui: <<: *defaults steps: @@ -96,6 +105,10 @@ workflows: <<: *filters requires: - install + - tests-after-publish: + <<: *filters + requires: + - install - cli-ui: <<: *filters requires: diff --git a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js index 33387a779b..fc11f99285 100644 --- a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js +++ b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js @@ -1,6 +1,11 @@ +const path = require('path') +const createTestProject = require('@vue/cli-test-utils/createTestProject') + jest.setTimeout(20000) -const create = require('@vue/cli-test-utils/createTestProject') +const create = (name, preset) => { + return createTestProject(name, preset, path.resolve(__dirname, '../../../../tests')) +} test('should work', async () => { const project = await create('unit-jest', { From f03615e5da7c1ad5780a8e3016992d171decdf8f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 16:32:29 +0800 Subject: [PATCH 04/20] ci: disable untouched jobs for testing purpose --- .circleci/config.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d955f33ba..d41d2ad8a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,27 +89,27 @@ workflows: jobs: - install: <<: *filters - - group-1: - <<: *filters - requires: - - install - - group-2: - <<: *filters - requires: - - install - - group-3: - <<: *filters - requires: - - install - - group-4: - <<: *filters - requires: - - install + # - group-1: + # <<: *filters + # requires: + # - install + # - group-2: + # <<: *filters + # requires: + # - install + # - group-3: + # <<: *filters + # requires: + # - install + # - group-4: + # <<: *filters + # requires: + # - install - tests-after-publish: <<: *filters requires: - install - - cli-ui: - <<: *filters - requires: - - install + # - cli-ui: + # <<: *filters + # requires: + # - install From 59b2b28f18c38873d3662a2dd56c5e5daa333f6a Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 16:33:03 +0800 Subject: [PATCH 05/20] chore: +x for the shell script --- scripts/local-registry.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/local-registry.sh diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh old mode 100644 new mode 100755 From 9a0be9982981e062f42993f4ae795785f1cce354 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 16:39:49 +0800 Subject: [PATCH 06/20] workflow: add --yes if publish to local registry --- scripts/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.js b/scripts/release.js index 03ffdea481..7ea30fd79f 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -121,7 +121,7 @@ const release = async () => { } if (cliOptions['local-registry']) { - lernaArgs.push('--no-git-tag-version', '--no-commit-hooks', '--no-push') + lernaArgs.push('--no-git-tag-version', '--no-commit-hooks', '--no-push', '--yes') } await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' }) From 0267eef3f93658fb1b3f6b79be07483a7c24f3e9 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 16:53:32 +0800 Subject: [PATCH 07/20] ci: fix git error --- .circleci/config.yml | 5 +++-- scripts/local-registry.sh | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d41d2ad8a5..8d0efa18aa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,8 +68,9 @@ jobs: steps: - attach_workspace: at: ~/ - - run: ./scripts/local-registry.sh - - run: yarn release --local-registry + - run: | + ./scripts/local-registry.sh + yarn release --local-registry - run: yarn test -p unit-jest cli-ui: diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index 4964a582e2..37c536c11e 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -19,6 +19,10 @@ function startLocalRegistry { npm set registry "$custom_registry_url" yarn config set registry "$custom_registry_url" + # set git user + git config --global user.email "user@example.com" + git config --global user.name "user" + # Login so we can publish packages (cd && npx npm-auth-to-token@1 -u user -p password -e user@example.com -r "$custom_registry_url") } From c37759c558c3078a069ae954052fffc191523e90 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 17:00:52 +0800 Subject: [PATCH 08/20] fix: exec startLocalRegistry --- scripts/local-registry.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index 37c536c11e..89ed3c3971 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -11,7 +11,7 @@ function startLocalRegistry { # Start local registry tmp_registry_log=`mktemp` echo "Registry output file: $tmp_registry_log" - (cd && nohup npx $default_verdaccio_package -c $1 &>$tmp_registry_log &) + (cd && nohup npx $default_verdaccio_package &>$tmp_registry_log &) # Wait for Verdaccio to boot grep -q 'http address' <(tail -f $tmp_registry_log) @@ -37,6 +37,7 @@ function stopLocalRegistry { } function publishToLocalRegistry { + startLocalRegistry git clean -df yarn release --local-registry } From cc1e6602cd1e18c4636930f995d74e8147c3bf00 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 17:07:14 +0800 Subject: [PATCH 09/20] chore: add log --- scripts/local-registry.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index 89ed3c3971..2d4658949d 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -19,12 +19,20 @@ function startLocalRegistry { npm set registry "$custom_registry_url" yarn config set registry "$custom_registry_url" + echo "set registry done" + # set git user git config --global user.email "user@example.com" git config --global user.name "user" + echo "git config done" + + git config --get user.email + # Login so we can publish packages (cd && npx npm-auth-to-token@1 -u user -p password -e user@example.com -r "$custom_registry_url") + + echo "npm user auth done" } function stopLocalRegistry { From 160e0b4e207b851413027a5b90f6e7d1b51f79fa Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 17:12:33 +0800 Subject: [PATCH 10/20] ci: fix publish command --- .circleci/config.yml | 4 +--- scripts/local-registry.sh | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8d0efa18aa..50f2ec243d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,9 +68,7 @@ jobs: steps: - attach_workspace: at: ~/ - - run: | - ./scripts/local-registry.sh - yarn release --local-registry + - run: ./scripts/local-registry.sh - run: yarn test -p unit-jest cli-ui: diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index 2d4658949d..eeb8bb3d28 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -45,7 +45,9 @@ function stopLocalRegistry { } function publishToLocalRegistry { - startLocalRegistry git clean -df yarn release --local-registry } + +startLocalRegistry +publishToLocalRegistry From 814013ce7cde860852131dda1581d63afe786d97 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 18:47:50 +0800 Subject: [PATCH 11/20] test: fix ENOENT --- .circleci/config.yml | 1 + packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 50f2ec243d..f678591eba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,6 +68,7 @@ jobs: steps: - attach_workspace: at: ~/ + - run: mkdir ../tests - run: ./scripts/local-registry.sh - run: yarn test -p unit-jest diff --git a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js index fc11f99285..1260508cc2 100644 --- a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js +++ b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js @@ -4,7 +4,7 @@ const createTestProject = require('@vue/cli-test-utils/createTestProject') jest.setTimeout(20000) const create = (name, preset) => { - return createTestProject(name, preset, path.resolve(__dirname, '../../../../tests')) + return createTestProject(name, preset, path.resolve(__dirname, '../../../../../tests')) } test('should work', async () => { From e930b33df9e09c7fda0786558fc31a6555b0ef0e Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 19:03:13 +0800 Subject: [PATCH 12/20] ci: delete VUE_CLI_TEST for tests-after-publish (for now) --- .../@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js index 1260508cc2..89e02d5842 100644 --- a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js +++ b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js @@ -7,6 +7,10 @@ const create = (name, preset) => { return createTestProject(name, preset, path.resolve(__dirname, '../../../../../tests')) } +beforeEach(() => { + process.env.VUE_CLI_TEST = false +}) + test('should work', async () => { const project = await create('unit-jest', { plugins: { From e0c9bb0bb9700cddfef4c55851869db48d467b0f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 21:43:37 +0800 Subject: [PATCH 13/20] test: run all tests with local registry --- .../__tests__/transpileDependencies.spec.js | 2 +- .../__tests__/tsPluginBabel.spec.js | 2 +- .../__tests__/tsPluginClassComponent.spec.js | 2 +- .../__tests__/tsPluginDefault.spec.js | 2 +- .../__tests__/tsPluginTSLint.spec.js | 2 +- .../__tests__/jestPlugin.spec.js | 13 ++----------- .../@vue/cli-service/__tests__/build.spec.js | 2 +- .../@vue/cli-service/__tests__/buildWc.spec.js | 2 +- .../@vue/cli-service/__tests__/cors.spec.js | 2 +- .../@vue/cli-service/__tests__/proxy.spec.js | 2 +- .../@vue/cli-test-utils/createTestProject.js | 7 ++++++- packages/@vue/cli/lib/Creator.js | 18 +++++++++--------- packages/@vue/cli/lib/invoke.js | 4 ++-- packages/@vue/cli/lib/util/installDeps.js | 8 ++++++++ 14 files changed, 36 insertions(+), 32 deletions(-) diff --git a/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js b/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js index fcd392038d..dad9ede07c 100644 --- a/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js +++ b/packages/@vue/cli-plugin-babel/__tests__/transpileDependencies.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const fs = require('fs-extra') const path = require('path') diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginBabel.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginBabel.spec.js index d590f839ff..b6f9456eac 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginBabel.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginBabel.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const Service = require('@vue/cli-service/lib/Service') const { assertServe, assertBuild } = require('./tsPlugin.helper') diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginClassComponent.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginClassComponent.spec.js index 1decff1098..25d6e2053f 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginClassComponent.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginClassComponent.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const { assertServe, assertBuild } = require('./tsPlugin.helper') diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginDefault.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginDefault.spec.js index e0f536678f..70dfb1b50f 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginDefault.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginDefault.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const { assertServe, assertBuild } = require('./tsPlugin.helper') diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js index a487e70241..9452e3f72b 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const create = require('@vue/cli-test-utils/createTestProject') diff --git a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js index 89e02d5842..62e6dfb594 100644 --- a/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js +++ b/packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js @@ -1,15 +1,6 @@ -const path = require('path') -const createTestProject = require('@vue/cli-test-utils/createTestProject') +jest.setTimeout(200000) -jest.setTimeout(20000) - -const create = (name, preset) => { - return createTestProject(name, preset, path.resolve(__dirname, '../../../../../tests')) -} - -beforeEach(() => { - process.env.VUE_CLI_TEST = false -}) +const create = require('@vue/cli-test-utils/createTestProject') test('should work', async () => { const project = await create('unit-jest', { diff --git a/packages/@vue/cli-service/__tests__/build.spec.js b/packages/@vue/cli-service/__tests__/build.spec.js index 070d29a559..b0ec5507dc 100644 --- a/packages/@vue/cli-service/__tests__/build.spec.js +++ b/packages/@vue/cli-service/__tests__/build.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const path = require('path') const portfinder = require('portfinder') diff --git a/packages/@vue/cli-service/__tests__/buildWc.spec.js b/packages/@vue/cli-service/__tests__/buildWc.spec.js index b59676d4e7..fd2ad9dc8f 100644 --- a/packages/@vue/cli-service/__tests__/buildWc.spec.js +++ b/packages/@vue/cli-service/__tests__/buildWc.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const path = require('path') const portfinder = require('portfinder') diff --git a/packages/@vue/cli-service/__tests__/cors.spec.js b/packages/@vue/cli-service/__tests__/cors.spec.js index 411cd2d2bd..3eeaade1d5 100644 --- a/packages/@vue/cli-service/__tests__/cors.spec.js +++ b/packages/@vue/cli-service/__tests__/cors.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const path = require('path') const portfinder = require('portfinder') diff --git a/packages/@vue/cli-service/__tests__/proxy.spec.js b/packages/@vue/cli-service/__tests__/proxy.spec.js index 725fcef8e1..03070b51ce 100644 --- a/packages/@vue/cli-service/__tests__/proxy.spec.js +++ b/packages/@vue/cli-service/__tests__/proxy.spec.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(300000) const request = require('request-promise-native') const { defaultPreset } = require('@vue/cli/lib/options') diff --git a/packages/@vue/cli-test-utils/createTestProject.js b/packages/@vue/cli-test-utils/createTestProject.js index eccca7317b..b23d36dba2 100644 --- a/packages/@vue/cli-test-utils/createTestProject.js +++ b/packages/@vue/cli-test-utils/createTestProject.js @@ -5,7 +5,12 @@ const execa = require('execa') module.exports = function createTestProject (name, preset, cwd, initGit) { delete process.env.VUE_CLI_SKIP_WRITE - cwd = cwd || path.resolve(__dirname, '../../test') + if (!cwd) { + cwd = path.resolve(__dirname, '../../../../test') + if (!fs.existsSync(cwd)) { + fs.mkdirSync(cwd) + } + } const projectRoot = path.resolve(cwd, name) diff --git a/packages/@vue/cli/lib/Creator.js b/packages/@vue/cli/lib/Creator.js index 250bfbd83c..5cbb5aafb1 100644 --- a/packages/@vue/cli/lib/Creator.js +++ b/packages/@vue/cli/lib/Creator.js @@ -155,12 +155,12 @@ module.exports = class Creator extends EventEmitter { log(`⚙ Installing CLI plugins. This might take a while...`) log() this.emit('creation', { event: 'plugins-install' }) - if (isTestOrDebug) { - // in development, avoid installation process - await require('./util/setupDevProject')(context) - } else { - await installDeps(context, packageManager, cliOptions.registry) - } + // if (isTestOrDebug) { + // // in development, avoid installation process + // await require('./util/setupDevProject')(context) + // } else { + await installDeps(context, packageManager, cliOptions.registry) + // } // run generator log(`🚀 Invoking generators...`) @@ -179,9 +179,9 @@ module.exports = class Creator extends EventEmitter { log(`📦 Installing additional dependencies...`) this.emit('creation', { event: 'deps-install' }) log() - if (!isTestOrDebug) { - await installDeps(context, packageManager, cliOptions.registry) - } + // if (!isTestOrDebug) { + await installDeps(context, packageManager, cliOptions.registry) + // } // run complete cbs if any (injected by generators) logWithSpinner('⚓', `Running completion hooks...`) diff --git a/packages/@vue/cli/lib/invoke.js b/packages/@vue/cli/lib/invoke.js index b822f08dd1..f493e56336 100644 --- a/packages/@vue/cli/lib/invoke.js +++ b/packages/@vue/cli/lib/invoke.js @@ -118,7 +118,7 @@ async function invoke (pluginName, options = {}, context = process.cwd()) { } async function runGenerator (context, plugin, pkg = getPkg(context)) { - const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG + // const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG const createCompleteCbs = [] const generator = new Generator(context, { pkg, @@ -141,7 +141,7 @@ async function runGenerator (context, plugin, pkg = getPkg(context)) { JSON.stringify(newDeps) !== JSON.stringify(pkg.dependencies) || JSON.stringify(newDevDeps) !== JSON.stringify(pkg.devDependencies) - if (!isTestOrDebug && depsChanged) { + if (depsChanged) { log(`📦 Installing additional dependencies...`) log() const packageManager = diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index 8c5613453c..41697acbb3 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -188,6 +188,10 @@ exports.installDeps = async function installDeps (targetDir, command, cliRegistr await addRegistryToArgs(command, args, cliRegistry) + if (process.env.VUE_CLI_TEST) { + args.push('--silent', '--prefer-offline') + } + debug(`command: `, command) debug(`args: `, args) @@ -211,6 +215,10 @@ exports.installPackage = async function (targetDir, command, cliRegistry, packag args.push(packageName) + if (process.env.VUE_CLI_TEST) { + args.push('--silent', '--prefer-offline') + } + debug(`command: `, command) debug(`args: `, args) From 9df1c4966043d7a2866671ea05abc497477d8db1 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 21:55:57 +0800 Subject: [PATCH 14/20] chore: ignore package manager output in test environments --- packages/@vue/cli/lib/util/installDeps.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index 41697acbb3..45fc04428f 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -99,9 +99,14 @@ function executeCommand (command, args, targetDir) { } } + const stdio = ['inherit', apiMode ? 'pipe' : 'inherit', !apiMode && command === 'yarn' ? 'pipe' : 'inherit'] + if (process.env.VUE_CLI_TEST) { + stdio[0] = stdio[1] = 'ignore' + } + const child = execa(command, args, { cwd: targetDir, - stdio: ['inherit', apiMode ? 'pipe' : 'inherit', !apiMode && command === 'yarn' ? 'pipe' : 'inherit'] + stdio }) if (apiMode) { From 5934108a86174d10ab4132d9a3c6f679c3c638e2 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 22:06:59 +0800 Subject: [PATCH 15/20] chore: remove prefer-offline --- packages/@vue/cli/lib/util/installDeps.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index 45fc04428f..ab929452e7 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -193,10 +193,6 @@ exports.installDeps = async function installDeps (targetDir, command, cliRegistr await addRegistryToArgs(command, args, cliRegistry) - if (process.env.VUE_CLI_TEST) { - args.push('--silent', '--prefer-offline') - } - debug(`command: `, command) debug(`args: `, args) @@ -220,10 +216,6 @@ exports.installPackage = async function (targetDir, command, cliRegistry, packag args.push(packageName) - if (process.env.VUE_CLI_TEST) { - args.push('--silent', '--prefer-offline') - } - debug(`command: `, command) debug(`args: `, args) From b7364d6c1ed001804cf0cdcf588d3cb6f3a176b0 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 22:50:07 +0800 Subject: [PATCH 16/20] test: test --- packages/@vue/cli/lib/Creator.js | 10 +++++----- packages/@vue/cli/lib/util/installDeps.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@vue/cli/lib/Creator.js b/packages/@vue/cli/lib/Creator.js index 5cbb5aafb1..f50c76d65c 100644 --- a/packages/@vue/cli/lib/Creator.js +++ b/packages/@vue/cli/lib/Creator.js @@ -63,7 +63,7 @@ module.exports = class Creator extends EventEmitter { } async create (cliOptions = {}, preset = null) { - const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG + // const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG const { run, name, context, createCompleteCbs } = this if (!preset) { @@ -209,10 +209,10 @@ module.exports = class Creator extends EventEmitter { let gitCommitFailed = false if (shouldInitGit) { await run('git add -A') - if (isTestOrDebug) { - await run('git', ['config', 'user.name', 'test']) - await run('git', ['config', 'user.email', 'test@test.com']) - } + // if (isTestOrDebug) { + await run('git', ['config', 'user.name', 'test']) + await run('git', ['config', 'user.email', 'test@test.com']) + // } const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init' try { await run('git', ['commit', '-m', msg]) diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index ab929452e7..221d02adef 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -100,9 +100,9 @@ function executeCommand (command, args, targetDir) { } const stdio = ['inherit', apiMode ? 'pipe' : 'inherit', !apiMode && command === 'yarn' ? 'pipe' : 'inherit'] - if (process.env.VUE_CLI_TEST) { - stdio[0] = stdio[1] = 'ignore' - } + // if (process.env.VUE_CLI_TEST) { + // stdio[0] = stdio[1] = 'ignore' + // } const child = execa(command, args, { cwd: targetDir, From 37c023fd8630501e674af33dc7e4031a7fdc5cd8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 23:36:52 +0800 Subject: [PATCH 17/20] revert: "test: test" This reverts commit b7364d6c1ed001804cf0cdcf588d3cb6f3a176b0. --- packages/@vue/cli/lib/Creator.js | 10 +++++----- packages/@vue/cli/lib/util/installDeps.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@vue/cli/lib/Creator.js b/packages/@vue/cli/lib/Creator.js index f50c76d65c..5cbb5aafb1 100644 --- a/packages/@vue/cli/lib/Creator.js +++ b/packages/@vue/cli/lib/Creator.js @@ -63,7 +63,7 @@ module.exports = class Creator extends EventEmitter { } async create (cliOptions = {}, preset = null) { - // const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG + const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG const { run, name, context, createCompleteCbs } = this if (!preset) { @@ -209,10 +209,10 @@ module.exports = class Creator extends EventEmitter { let gitCommitFailed = false if (shouldInitGit) { await run('git add -A') - // if (isTestOrDebug) { - await run('git', ['config', 'user.name', 'test']) - await run('git', ['config', 'user.email', 'test@test.com']) - // } + if (isTestOrDebug) { + await run('git', ['config', 'user.name', 'test']) + await run('git', ['config', 'user.email', 'test@test.com']) + } const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init' try { await run('git', ['commit', '-m', msg]) diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index 221d02adef..ab929452e7 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -100,9 +100,9 @@ function executeCommand (command, args, targetDir) { } const stdio = ['inherit', apiMode ? 'pipe' : 'inherit', !apiMode && command === 'yarn' ? 'pipe' : 'inherit'] - // if (process.env.VUE_CLI_TEST) { - // stdio[0] = stdio[1] = 'ignore' - // } + if (process.env.VUE_CLI_TEST) { + stdio[0] = stdio[1] = 'ignore' + } const child = execa(command, args, { cwd: targetDir, From 2f51296f03cf4860c97a81ac572363603892547c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 23:38:37 +0800 Subject: [PATCH 18/20] ci: add verdaccio config --- scripts/local-registry.sh | 2 +- scripts/verdaccio.yaml | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 scripts/verdaccio.yaml diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index eeb8bb3d28..782f66895d 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -11,7 +11,7 @@ function startLocalRegistry { # Start local registry tmp_registry_log=`mktemp` echo "Registry output file: $tmp_registry_log" - (cd && nohup npx $default_verdaccio_package &>$tmp_registry_log &) + (cd && nohup npx $default_verdaccio_package -c ./verdaccio.yaml &>$tmp_registry_log &) # Wait for Verdaccio to boot grep -q 'http address' <(tail -f $tmp_registry_log) diff --git a/scripts/verdaccio.yaml b/scripts/verdaccio.yaml new file mode 100644 index 0000000000..cbca71cae1 --- /dev/null +++ b/scripts/verdaccio.yaml @@ -0,0 +1,60 @@ +# +# This is based on verdaccio's default config file. It allows all users +# to do anything, so don't use it on production systems. +# +# Look here for more config file examples: +# https://github.com/verdaccio/verdaccio/tree/master/conf +# + +# path to a directory with all packages +storage: ./storage + +auth: + htpasswd: + file: ./htpasswd + # Maximum amount of users allowed to register, defaults to "+inf". + # You can set this to -1 to disable registration. + #max_users: 1000 + +# a list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ + max_fails: 40 + maxage: 30m + timeout: 60s + agent_options: + keepAlive: true + maxSockets: 40 + maxFreeSockets: 10 + +packages: + '@*/*': + # scoped packages + access: $all + publish: $all + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + # + # you can specify usernames/groupnames (depending on your auth plugin) + # and three keywords: "$all", "$anonymous", "$authenticated" + access: $all + + # allow all known users to publish packages + # (anyone can register by default, remember?) + publish: $all + + # if package is not available locally, proxy requests to 'npmjs' registry + proxy: npmjs + +# log settings +logs: + - {type: stdout, format: pretty, level: warn} + #- {type: file, path: verdaccio.log, level: info} + +# See https://github.com/verdaccio/verdaccio/issues/301 +server: + keepAliveTimeout: 0 From 51b5356b890214abb3ceee9885d795e37535796c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 23:47:57 +0800 Subject: [PATCH 19/20] ci: use verdaccio 3 --- scripts/local-registry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index 782f66895d..a733bfad3c 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -5,7 +5,7 @@ custom_registry_url=http://localhost:4873 original_npm_registry_url=`npm get registry` original_yarn_registry_url=`yarn config get registry` -default_verdaccio_package=verdaccio@4 +default_verdaccio_package=verdaccio@3 function startLocalRegistry { # Start local registry From 86c40c5932937baa94b48c11ebc786de4bd7918f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 27 Jun 2019 23:57:00 +0800 Subject: [PATCH 20/20] test: use absolute path --- scripts/local-registry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index a733bfad3c..e386e93356 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -11,7 +11,7 @@ function startLocalRegistry { # Start local registry tmp_registry_log=`mktemp` echo "Registry output file: $tmp_registry_log" - (cd && nohup npx $default_verdaccio_package -c ./verdaccio.yaml &>$tmp_registry_log &) + (cd && nohup npx $default_verdaccio_package -c ${CIRCLE_WORKING_DIRECTORY}/scripts/verdaccio.yaml &>$tmp_registry_log &) # Wait for Verdaccio to boot grep -q 'http address' <(tail -f $tmp_registry_log)