Skip to content

Use yarn #2652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes to this file.

Package name should not change, and the version will be updated via the release process.

The two extra dependencies added are subpackages of this one, and are already added in the appropriate package.json.

"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",
Expand Down Expand Up @@ -44,13 +44,15 @@
"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",
"@angular/core": "^2.0.0",
"@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",
Expand Down
23 changes: 19 additions & 4 deletions packages/angular-cli/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import LinkCli from '../tasks/link-cli';
import NpmInstall from '../tasks/npm-install';
import Yarn from '../tasks/yarn';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name task YarnInstall and file yarn-install


const Command = require('ember-cli/lib/models/command');
const Promise = require('ember-cli/lib/ext/promise');
Expand All @@ -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'] },
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down
1 change: 1 addition & 0 deletions packages/angular-cli/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] },
Expand Down
26 changes: 26 additions & 0 deletions packages/angular-cli/tasks/yarn.ts
Original file line number Diff line number Diff line change
@@ -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();
}
});
});
}
});