diff --git a/.appveyor.yml b/.appveyor.yml index 2ffc56173f8c..d9cd073ebc96 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,6 +14,6 @@ test_script: - node --version - npm --version - npm test - - npm run test:e2e + - node tests\e2e_runner.js build: off diff --git a/.travis.yml b/.travis.yml index 3b7a15bc0fe2..cd2b7f8c4631 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,22 +13,22 @@ env: matrix: - SCRIPT=lint - SCRIPT=build - - SCRIPT=e2e - - SCRIPT=e2e:nightly - SCRIPT=test + - NODE_SCRIPT=tests/e2e_runner.js + - NODE_SCRIPT="tests/e2e_runner.js --nightly" # - TARGET=mobile SCRIPT=mobile_test matrix: fast_finish: true allow_failures: - os: osx - - env: SCRIPT=e2e:nightly + - env: NODE_SCRIPT="tests/e2e_runner.js --nightly" exclude: - node_js: "6" env: SCRIPT=lint - os: osx - env: SCRIPT=e2e:nightly + env: NODE_SCRIPT="tests/e2e_runner.js --nightly" - node_js: "6" - env: SCRIPT=e2e:nightly + env: NODE_SCRIPT="tests/e2e_runner.js --nightly" - os: osx node_js: "5" env: SCRIPT=lint @@ -57,4 +57,5 @@ install: - npm install --no-optional script: - - npm run-script $SCRIPT + - if [[ "$SCRIPT" ]]; then npm run-script $SCRIPT; fi + - if [[ "$NODE_SCRIPT" ]]; then node $NODE_SCRIPT; fi diff --git a/package.json b/package.json index ffb434f47e8e..a82ae2853cf3 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "less-loader": "^2.2.3", "lodash": "^4.11.1", "node-sass": "^3.7.0", - "npm": "3.10.2", "npm-run-all": "^3.0.0", "offline-plugin": "^3.4.1", "opn": "4.0.1", diff --git a/packages/angular-cli/commands/init.ts b/packages/angular-cli/commands/init.ts index e6378b3a1c63..f8f082214c76 100644 --- a/packages/angular-cli/commands/init.ts +++ b/packages/angular-cli/commands/init.ts @@ -1,4 +1,5 @@ import LinkCli from '../tasks/link-cli'; +import NpmInstall from '../tasks/npm-install'; const Command = require('ember-cli/lib/models/command'); const Promise = require('ember-cli/lib/ext/promise'); @@ -6,7 +7,6 @@ const SilentError = require('silent-error'); const validProjectName = require('ember-cli/lib/utilities/valid-project-name'); const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); const GitInit = require('../tasks/git-init'); -const NpmInstall = require('../tasks/npm-install'); const InitCommand: any = Command.extend({ @@ -57,18 +57,18 @@ const InitCommand: any = Command.extend({ }); } - let linkCli: any; - if (commandOptions.linkCli) { - linkCli = new LinkCli({ + let npmInstall: any; + if (!commandOptions.skipNpm) { + npmInstall = new NpmInstall({ ui: this.ui, analytics: this.analytics, project: this.project }); } - let npmInstall: any; - if (!commandOptions.skipNpm) { - npmInstall = new NpmInstall({ + let linkCli: any; + if (commandOptions.linkCli) { + linkCli = new LinkCli({ ui: this.ui, analytics: this.analytics, project: this.project @@ -121,19 +121,13 @@ const InitCommand: any = Command.extend({ } }.bind(this)) .then(function () { - if (commandOptions.linkCli) { - return linkCli.run({ - verbose: commandOptions.verbose, - optional: false - }); + if (!commandOptions.skipNpm) { + return npmInstall.run(); } }) .then(function () { - if (!commandOptions.skipNpm) { - return npmInstall.run({ - verbose: commandOptions.verbose, - optional: false - }); + if (commandOptions.linkCli) { + return linkCli.run(); } }) .then(function () { diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index ae57b7c0dc4e..6a338b993bfa 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -59,7 +59,6 @@ "less-loader": "^2.2.3", "lodash": "^4.11.1", "node-sass": "^3.7.0", - "npm": "3.10.2", "npm-run-all": "^3.0.0", "offline-plugin": "^3.4.1", "opn": "4.0.1", diff --git a/packages/angular-cli/tasks/npm-install.js b/packages/angular-cli/tasks/npm-install.js deleted file mode 100644 index 40fa58af9cbe..000000000000 --- a/packages/angular-cli/tasks/npm-install.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -// Runs `npm install` in cwd - -var NpmTask = require('./npm-task'); - -module.exports = NpmTask.extend({ - command: 'install', - startProgressMessage: 'Installing packages for tooling via npm', - completionMessage: 'Installed packages for tooling via npm.' -}); diff --git a/packages/angular-cli/tasks/npm-install.ts b/packages/angular-cli/tasks/npm-install.ts new file mode 100644 index 000000000000..abf491061847 --- /dev/null +++ b/packages/angular-cli/tasks/npm-install.ts @@ -0,0 +1,25 @@ +const Task = require('ember-cli/lib/models/task'); +import * as chalk from 'chalk'; +import {exec} from 'child_process'; + + +export default Task.extend({ + run: function() { + const ui = this.ui; + + return new Promise(function(resolve, reject) { + ui.writeLine(chalk.green('Installing packages for tooling via npm.')); + exec('npm install', + (err: NodeJS.ErrnoException, stdout: string, stderr: string) => { + if (err) { + ui.writeLine(stderr); + ui.writeLine(chalk.red('Package install failed, see above.')); + reject(); + } else { + ui.writeLine(chalk.green('Installed packages for tooling via npm.')); + resolve(); + } + }); + }); + } +}); diff --git a/packages/angular-cli/tasks/npm-task.js b/packages/angular-cli/tasks/npm-task.js deleted file mode 100644 index 4f720da73175..000000000000 --- a/packages/angular-cli/tasks/npm-task.js +++ /dev/null @@ -1,64 +0,0 @@ -/*eslint-disable no-console */ -'use strict'; - -// Runs `npm install` in cwd - -var chalk = require('chalk'); -var Task = require('ember-cli/lib/models/task'); -var npm = require('../utilities/npm'); - -module.exports = Task.extend({ - // The command to run: can be 'install' or 'uninstall' - command: '', - // Message to send to ui.startProgress - startProgressMessage: '', - // Message to send to ui.writeLine on completion - completionMessage: '', - - init: function() { - this.npm = this.npm || require('npm'); - }, - // Options: Boolean verbose - run: function(options) { - this.ui.startProgress(chalk.green(this.startProgressMessage), chalk.green('.')); - - var npmOptions = { - loglevel: options.verbose ? 'verbose' : 'error', - progress: false, - logstream: this.ui.outputStream, - color: 'always', - // by default, do install peoples optional deps - 'optional': 'optional' in options ? options.optional : true, - 'save-dev': !!options['save-dev'], - 'save-exact': !!options['save-exact'] - }; - - var packages = options.packages || []; - - // npm otherwise is otherwise noisy, already submitted PR for npm to fix - // misplaced console.log - this.disableLogger(); - - return npm(this.command, packages, npmOptions, this.npm). - finally(this.finally.bind(this)). - then(this.announceCompletion.bind(this)); - }, - - announceCompletion: function() { - this.ui.writeLine(chalk.green(this.completionMessage)); - }, - - finally: function() { - this.ui.stopProgress(); - this.restoreLogger(); - }, - - disableLogger: function() { - this.oldLog = console.log; - console.log = function() {}; - }, - - restoreLogger: function() { - console.log = this.oldLog; // Hack, see above - } -}); diff --git a/packages/angular-cli/utilities/npm.js b/packages/angular-cli/utilities/npm.js deleted file mode 100644 index fd88e14538d1..000000000000 --- a/packages/angular-cli/utilities/npm.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var Promise = require('ember-cli/lib/ext/promise'); - -// - -/** - Runs the npm command `command` with the supplied args and load options. - - Please note that the loaded module appears to retain some state, so do not - expect multiple invocations within the same process to work without quirks. - This problem is likely fixable. - - @method npm - @param {String} command The npm command to run. - @param {Array} npmArgs The arguments passed to the npm command. - @param {Array} options The options passed when loading npm. - @param {Module} [npm] A reference to the npm module. -*/ -module.exports = function npm(command, npmArgs, options/*, npm*/) { - var lib; - if (arguments.length === 4) { - lib = arguments[3]; - } else { - lib = require('npm'); - } - - var load = Promise.denodeify(lib.load); - - return load(options) - .then(function() { - // if install is denodeified outside load.then(), - // it throws "Call npm.load(config, cb) before using this command." - var operation = Promise.denodeify(lib.commands[command]); - - return operation(npmArgs || []); - }); -};