diff --git a/package.json b/package.json index 6736e494ceea..59a0d4ee56c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "angular-cli", - "version": "1.0.0-beta.17", + "name": "angular-cli-with-use-yarn", + "version": "1.0.0-beta.17.2", "description": "CLI tool for Angular", "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "UA-8594346-19", @@ -44,6 +44,7 @@ "homepage": "https://github.com/angular/angular-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.0", + "@angular-cli/base-href-webpack": "^1.0.2", "@angular/common": "^2.0.0", "@angular/compiler": "^2.0.0", "@angular/compiler-cli": "^0.6.0", @@ -51,6 +52,7 @@ "@angular/platform-browser": "^2.0.0", "@angular/platform-server": "^2.0.0", "@angular/tsc-wrapped": "^0.3.0", + "@ngtools/webpack": "^1.1.0", "angular2-template-loader": "^0.5.0", "awesome-typescript-loader": "^2.2.3", "chalk": "^1.1.3", diff --git a/packages/angular-cli/commands/init.ts b/packages/angular-cli/commands/init.ts index 1b300e43b588..8ff31ee1100d 100644 --- a/packages/angular-cli/commands/init.ts +++ b/packages/angular-cli/commands/init.ts @@ -1,5 +1,6 @@ import LinkCli from '../tasks/link-cli'; import NpmInstall from '../tasks/npm-install'; +import Yarn from '../tasks/yarn'; const Command = require('ember-cli/lib/models/command'); const Promise = require('ember-cli/lib/ext/promise'); @@ -19,6 +20,7 @@ const InitCommand: any = Command.extend({ { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, + { name: 'use-yarn', type: Boolean, default: false, aliases: ['uy'] }, { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, { name: 'name', type: String, default: '', aliases: ['n'] }, @@ -56,8 +58,17 @@ const InitCommand: any = Command.extend({ } let npmInstall: any; - if (!commandOptions.skipNpm) { - npmInstall = new NpmInstall({ + let yarn: any; + if (!commandOptions.useYarn) { + if (!commandOptions.skipNpm) { + npmInstall = new NpmInstall({ + ui: this.ui, + analytics: this.analytics, + project: this.project + }); + } + } else { + yarn = new Yarn({ ui: this.ui, analytics: this.analytics, project: this.project @@ -122,8 +133,12 @@ const InitCommand: any = Command.extend({ } }.bind(this)) .then(function () { - if (!commandOptions.skipNpm) { - return npmInstall.run(); + if (!commandOptions.useYarn) { + if (!commandOptions.skipNpm) { + return npmInstall.run(); + } + } else { + return yarn.run(); } }) .then(function () { diff --git a/packages/angular-cli/commands/new.ts b/packages/angular-cli/commands/new.ts index 5737c0afaee8..7aae714e167a 100644 --- a/packages/angular-cli/commands/new.ts +++ b/packages/angular-cli/commands/new.ts @@ -16,6 +16,7 @@ const NewCommand = Command.extend({ { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, + { name: 'use-yarn', type: Boolean, default: false, aliases: ['uy'] }, { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, diff --git a/packages/angular-cli/tasks/yarn.ts b/packages/angular-cli/tasks/yarn.ts new file mode 100644 index 000000000000..b85ad5c207c6 --- /dev/null +++ b/packages/angular-cli/tasks/yarn.ts @@ -0,0 +1,26 @@ + +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 yarn.')); + exec('yarn', + (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 yarn.')); + resolve(); + } + }); + }); + } +});