mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 05:24:57 +08:00
fix(): initial commit message
This commit is contained in:
parent
e7e722cf9b
commit
6cad6c39df
@ -1,17 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var InitCommand = require('ember-cli/lib/commands/init');
|
||||
var Command = require('ember-cli/lib/models/command');
|
||||
var Promise = require('ember-cli/lib/ext/promise');
|
||||
var SilentError = require('silent-error');
|
||||
var validProjectName = require('ember-cli/lib/utilities/valid-project-name');
|
||||
var normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option');
|
||||
var GitInit = require('../tasks/git-init');
|
||||
|
||||
module.exports = Command.extend({
|
||||
name: 'init',
|
||||
description: 'Creates a new angular-cli project in the current folder.',
|
||||
aliases: ['i'],
|
||||
works: 'everywhere',
|
||||
|
||||
module.exports = InitCommand .extend({
|
||||
availableOptions: [
|
||||
{ name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
|
||||
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
|
||||
{ name: 'blueprint', type: String, aliases: ['b'] },
|
||||
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
|
||||
{ name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] },
|
||||
{ name: 'skip-bower', type: Boolean, default: false, aliases: ['sb'] },
|
||||
{ name: 'name', type: String, default: '', aliases: ['n'] }
|
||||
],
|
||||
|
||||
anonymousOptions: [
|
||||
'<glob-pattern>'
|
||||
],
|
||||
|
||||
_defaultBlueprint: function() {
|
||||
if (this.project.isEmberCLIAddon()) {
|
||||
return 'addon';
|
||||
@ -19,6 +33,91 @@ module.exports = InitCommand .extend({
|
||||
return 'ng2';
|
||||
}
|
||||
},
|
||||
|
||||
run: function(commandOptions, rawArgs) {
|
||||
if (commandOptions.dryRun) {
|
||||
commandOptions.skipNpm = true;
|
||||
commandOptions.skipBower = true;
|
||||
}
|
||||
|
||||
var installBlueprint = new this.tasks.InstallBlueprint({
|
||||
ui: this.ui,
|
||||
analytics: this.analytics,
|
||||
project: this.project
|
||||
});
|
||||
|
||||
// needs an explicit check in case it's just 'undefined'
|
||||
// due to passing of options from 'new' and 'addon'
|
||||
if (commandOptions.skipGit === false) {
|
||||
var gitInit = new GitInit({
|
||||
ui: this.ui,
|
||||
project: this.project
|
||||
});
|
||||
}
|
||||
|
||||
if (!commandOptions.skipNpm) {
|
||||
var npmInstall = new this.tasks.NpmInstall({
|
||||
ui: this.ui,
|
||||
analytics: this.analytics,
|
||||
project: this.project
|
||||
});
|
||||
}
|
||||
|
||||
if (!commandOptions.skipBower) {
|
||||
var bowerInstall = new this.tasks.BowerInstall({
|
||||
ui: this.ui,
|
||||
analytics: this.analytics,
|
||||
project: this.project
|
||||
});
|
||||
}
|
||||
|
||||
var project = this.project;
|
||||
var packageName = commandOptions.name !== '.' && commandOptions.name || project.name();
|
||||
|
||||
if (!packageName) {
|
||||
var message = 'The `ng ' + this.name + '` command requires a ' +
|
||||
'package.json in current folder with name attribute or a specified name via arguments. ' +
|
||||
'For more details, use `ng help`.';
|
||||
|
||||
return Promise.reject(new SilentError(message));
|
||||
}
|
||||
|
||||
var blueprintOpts = {
|
||||
dryRun: commandOptions.dryRun,
|
||||
blueprint: commandOptions.blueprint || this._defaultBlueprint(),
|
||||
rawName: packageName,
|
||||
targetFiles: rawArgs || '',
|
||||
rawArgs: rawArgs.toString()
|
||||
};
|
||||
|
||||
if (!validProjectName(packageName)) {
|
||||
return Promise.reject(new SilentError('We currently do not support a name of `' + packageName + '`.'));
|
||||
}
|
||||
|
||||
blueprintOpts.blueprint = normalizeBlueprint(blueprintOpts.blueprint);
|
||||
|
||||
return installBlueprint.run(blueprintOpts)
|
||||
.then(function() {
|
||||
if (commandOptions.skipGit === false) {
|
||||
return gitInit.run(commandOptions, rawArgs);
|
||||
}
|
||||
}.bind(this))
|
||||
.then(function() {
|
||||
if (!commandOptions.skipNpm) {
|
||||
return npmInstall.run({
|
||||
verbose: commandOptions.verbose,
|
||||
optional: false
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
if (!commandOptions.skipBower) {
|
||||
return bowerInstall.run({
|
||||
verbose: commandOptions.verbose
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.overrideCore = true;
|
||||
|
@ -8,10 +8,14 @@ var SilentError = require('silent-error');
|
||||
var validProjectName = require('ember-cli/lib/utilities/valid-project-name');
|
||||
var normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option');
|
||||
|
||||
var NewCommand = require('ember-cli/lib/commands/new');
|
||||
var GitInit = require('../tasks/git-init');
|
||||
var Command = require('ember-cli/lib/models/command');
|
||||
var InitCommand = require('./init');
|
||||
|
||||
module.exports = Command.extend({
|
||||
name: 'new',
|
||||
description: 'Creates a new directory and runs ' + chalk.green('ng init') + ' in it.',
|
||||
works: 'outsideProject',
|
||||
|
||||
module.exports = NewCommand.extend({
|
||||
availableOptions: [
|
||||
{ name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
|
||||
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
|
||||
@ -60,12 +64,6 @@ module.exports = NewCommand.extend({
|
||||
ui: this.ui,
|
||||
analytics: this.analytics
|
||||
});
|
||||
var InitCommand = this.commands.Init;
|
||||
|
||||
var gitInit = new GitInit({
|
||||
ui: this.ui,
|
||||
project: this.project
|
||||
});
|
||||
|
||||
var initCommand = new InitCommand({
|
||||
ui: this.ui,
|
||||
@ -79,8 +77,7 @@ module.exports = NewCommand.extend({
|
||||
directoryName: commandOptions.directory,
|
||||
dryRun: commandOptions.dryRun
|
||||
})
|
||||
.then(initCommand.run.bind(initCommand, commandOptions, rawArgs))
|
||||
.then(gitInit.run.bind(gitInit, commandOptions, rawArgs));
|
||||
.then(initCommand.run.bind(initCommand, commandOptions, rawArgs));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -6,6 +6,7 @@ var path = require('path');
|
||||
var pkg = require('../package.json');
|
||||
var fs = require('fs');
|
||||
var template = require('lodash/string/template');
|
||||
var Task = require('ember-cli/lib/models/task');
|
||||
|
||||
var gitEnvironmentVariables = {
|
||||
GIT_AUTHOR_NAME: 'angular-cli',
|
||||
@ -14,9 +15,7 @@ var gitEnvironmentVariables = {
|
||||
get GIT_COMMITTER_EMAIL(){ return this.GIT_AUTHOR_EMAIL; }
|
||||
};
|
||||
|
||||
var GitInit = require('ember-cli/lib/tasks/git-init');
|
||||
|
||||
module.exports = GitInit.extend({
|
||||
module.exports = Task.extend({
|
||||
run: function(commandOptions) {
|
||||
var chalk = require('chalk');
|
||||
var ui = this.ui;
|
||||
|
@ -1 +1,8 @@
|
||||
chore: initial commit from angular-cli v<%= version %>
|
||||
chore: initial commit from angular-cli
|
||||
_ _ _
|
||||
__ _ _ __ __ _ _ _| | __ _ _ __ ___| (_)
|
||||
/ _ | _ \ / _ | | | | |/ _ | __|____ / __| | |
|
||||
| (_| | | | | (_| | |_| | | (_| | | |_____| (__| | |
|
||||
\____|_| |_|\__ |\____|_|\____|_| \___|_|_|
|
||||
|___/
|
||||
|
Loading…
x
Reference in New Issue
Block a user