diff --git a/.circleci/config.yml b/.circleci/config.yml index 4edeeb5a59..f678591eba 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: mkdir ../tests + - run: ./scripts/local-registry.sh + - run: yarn test -p unit-jest + cli-ui: <<: *defaults steps: @@ -80,23 +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 - - cli-ui: + # - 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 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 33387a779b..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,4 +1,4 @@ -jest.setTimeout(20000) +jest.setTimeout(200000) const create = require('@vue/cli-test-utils/createTestProject') 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..ab929452e7 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) { diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh new file mode 100755 index 0000000000..e386e93356 --- /dev/null +++ b/scripts/local-registry.sh @@ -0,0 +1,53 @@ +#!/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@3 + +function startLocalRegistry { + # Start local registry + tmp_registry_log=`mktemp` + echo "Registry output file: $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) + + # Set registry to local registry + 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 { + # 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 +} + +startLocalRegistry +publishToLocalRegistry diff --git a/scripts/release.js b/scripts/release.js index a7d575f297..7ea30fd79f 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', '--yes') + } + await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' }) } 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