angular-cli = function (options) {
// patch UI to not print Ember-CLI warnings (which don't apply to Angular-CLI)
UI.prototype.writeWarnLine = function () { }
// patch Watcher to always default to node, not checking for Watchman
Watcher.detectWatcher = function(ui, _options){
var options = _options || {};
options.watcher = 'node';
return Promise.resolve(options);
}
options.cli = {
name: 'ng',
root: path.join(__dirname, '..', '..'),
npmPackage: 'angular-cli'
};
// ensure the environemnt variable for dynamic paths
process.env.PWD = path.normalize(process.env.PWD || process.cwd());
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');
return cli(options);
}n/a
function DAG() {
this.names = [];
this.vertices = {};
}n/a
function Addon(parent, project) {
this.parent = parent;
this.project = project;
this.ui = project && project.ui;
this.addonPackages = {};
this.addons = [];
}n/a
function Blueprint(blueprintPath) {
this.path = blueprintPath;
this.name = path.basename(blueprintPath);
}n/a
function CLI(options) {
this.name = options.name;
this.ui = options.ui;
this.testing = options.testing;
this.disableDependencyChecker = options.disableDependencyChecker;
this.root = options.root;
this.npmPackage = options.npmPackage;
debug('testing %o', !!this.testing);
}n/a
function Command() {
CoreObject.apply(this, arguments);
this.isWithinProject = this.project.isEmberCLIProject();
this.name = this.name || path.basename(getCallerFile(), '.js');
debug('initialize: name: %s, name: %s', this.name);
this.aliases = this.aliases || [];
// Works Property
if (!allowedWorkOptions[this.works]) {
throw new Error('The "' + this.name + '" command\'s works field has to ' +
'be either "everywhere", "insideProject" or "outsideProject".');
}
// Options properties
this.availableOptions = this.availableOptions || [];
this.anonymousOptions = this.anonymousOptions || [];
this.registerOptions();
}n/a
function CoreObject(options) {
Object.assign(this, options);
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function EditFileDiff(options) {
this.info = options.info;
}n/a
function FileInfo(options) {
this.action = options.action;
this.outputPath = options.outputPath;
this.displayPath = options.displayPath;
this.inputPath = options.inputPath;
this.templateVariables = options.templateVariables;
this.ui = options.ui;
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function InstallationChecker(options) {
this.project = options.project;
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function openEditor(file) {
if (!openEditor.canEdit()) {
throw new Error('EDITOR environment variable is not set');
}
if (!file) {
throw new Error('No `file` option provided');
}
var editorArgs = openEditor._env().EDITOR.split(' ');
var editor = editorArgs.shift();
var editProcess = openEditor._spawn(editor, [file].concat(editorArgs), {stdio: 'inherit'});
return new Promise(function(resolve, reject) {
editProcess.on('close', function (code) {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
}n/a
function PlatformChecker(version) {
this.version = version;
this.isValid = this.checkIsValid();
this.isUntested = this.checkIsUntested();
this.isDeprecated = this.checkIsDeprecated();
debug('%o', {
version: this.version,
isValid: this.isValid,
isUntested: this.isUntested,
isDeprecated: this.isDeprecated
});
}n/a
function Project(root, pkg, ui, cli) {
debug('init root: %s', root);
this.root = root;
this.pkg = pkg;
this.ui = ui;
this.cli = cli;
this.addonPackages = {};
this.addons = [];
this.liveReloadFilterPatterns = [];
this.setupNodeModulesPath();
this._watchmanInfo = {
enabled: false,
version: null,
canNestRoots: false
};
}n/a
function PromiseExt(resolver, label) {
this._superConstructor(resolver, label);
}n/a
function Task() {
CoreObject.apply(this, arguments);
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function DAG() {
this.names = [];
this.vertices = {};
}n/a
add = function (name) {
if (!name) { return; }
if (this.vertices.hasOwnProperty(name)) {
return this.vertices[name];
}
var vertex = {
name: name,
incoming: {},
incomingNames: [],
hasOutgoing: false,
value: null
};
this.vertices[name] = vertex;
this.names.push(name);
return vertex;
}n/a
addEdge = function (fromName, toName) {
if (!fromName || !toName || fromName === toName) {
return;
}
var from = this.add(fromName), to = this.add(toName);
if (to.incoming.hasOwnProperty(fromName)) {
return;
}
function checkCycle(vertex, path) {
if (vertex.name === toName) {
throw new Error('cycle detected: ' + toName + ' <- ' + path.join(' <- '));
}
}
visit(from, checkCycle);
from.hasOutgoing = true;
to.incoming[fromName] = from;
to.incomingNames.push(fromName);
}n/a
addEdges = function (name, value, before, after) {
var i;
this.map(name, value);
if (before) {
if (typeof before === 'string') {
this.addEdge(name, before);
} else {
for (i = 0; i < before.length; i++) {
this.addEdge(name, before[i]);
}
}
}
if (after) {
if (typeof after === 'string') {
this.addEdge(after, name);
} else {
for (i = 0; i < after.length; i++) {
this.addEdge(after[i], name);
}
}
}
}n/a
map = function (name, value) {
this.add(name).value = value;
}...
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..'
;, 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
...topsort = function (fn) {
var visited = {},
vertices = this.vertices,
names = this.names,
len = names.length,
i, vertex;
for (i = 0; i < len; i++) {
vertex = vertices[names[i]];
if (!vertex.hasOutgoing) {
visit(vertex, fn, visited);
}
}
}n/a
function Addon(parent, project) {
this.parent = parent;
this.project = project;
this.ui = project && project.ui;
this.addonPackages = {};
this.addons = [];
}n/a
lookup = function (addon) {
var Constructor, addonModule, modulePath, moduleDir;
modulePath = Addon.resolvePath(addon);
moduleDir = path.dirname(modulePath);
if (existsSync(modulePath)) {
addonModule = require(modulePath);
if (typeof addonModule === 'function') {
Constructor = addonModule;
Constructor.prototype.root = Constructor.prototype.root || moduleDir;
Constructor.prototype.pkg = Constructor.prototype.pkg || addon.pkg;
} else {
Constructor = Addon.extend(assign({
root: moduleDir,
pkg: addon.pkg
}, addonModule));
}
}
if (!Constructor) {
throw new SilentError('The `' + addon.pkg.name + '` addon could not be found at `' + addon.path + '`.');
}
return Constructor;
}n/a
resolvePath = function (addon) {
var addonMain = addon.pkg['ember-addon-main'];
if (addonMain) {
this.ui && this.ui.writeDeprecateLine(addon.pkg.name + ' is using the deprecated ember-addon-main definition. It should be updated
to {\'ember-addon\': {\'main\': \'' + addon.pkg['ember-addon-main'] + '\'}}');
} else {
addonMain = (addon.pkg['ember-addon'] && addon.pkg['ember-addon'].main) || addon.pkg['main'] || 'index.js';
}
// Resolve will fail unless it has an extension
if (!path.extname(addonMain)) {
addonMain += '.js';
}
return path.resolve(addon.path, addonMain);
}n/a
blueprintsPath = function () {
return path.join(this.root, 'blueprints');
}n/a
config = function (env, baseConfig) {
var configPath = path.join(this.root, 'config', 'environment.js');
if (existsSync(configPath)) {
var configGenerator = require(configPath);
return configGenerator(env, baseConfig);
}
}n/a
dependencies = function () {
throw new Error()
var pkg = this.pkg || {};
return assign({}, pkg['devDependencies'], pkg['dependencies']);
}n/a
function eachAddonInvoke(methodName, args) {
this.initializeAddons();
var invokeArguments = args || [];
return this.addons.map(function(addon) {
if (addon[methodName]) {
return addon[methodName].apply(addon, invokeArguments);
}
}).filter(Boolean);
}n/a
included = function () {
if (!this._addonsInitialized) {
// someone called `this._super.included` without `apply` (because of older
// core-object issues that prevent a "real" super call from working properly)
return;
}
this.eachAddonInvoke('included', [this]);
}n/a
initializeAddons = function () {
if (this._addonsInitialized) {
return;
}
this._addonsInitialized = true;
this.addonPackages = {
'angular-cli': {
name: 'angular-cli',
path: path.join(__dirname, '../../../'),
pkg: cliPkg,
}
};
}n/a
function Blueprint(blueprintPath) {
this.path = blueprintPath;
this.name = path.basename(blueprintPath);
}n/a
defaultLookupPaths = function () {
return [
path.resolve(__dirname, '..', '..', 'blueprints')
];
}n/a
list = function (options) {
options = options || {};
var lookupPaths = generateLookupPaths(options.paths);
var seen = [];
return lookupPaths.map(function(lookupPath) {
var blueprints = dir(lookupPath);
var packagePath = path.join(lookupPath, '../package.json');
var source;
if (existsSync(packagePath)) {
source = require(packagePath).name;
} else {
source = path.basename(path.join(lookupPath, '..'));
}
blueprints = blueprints.map(function(blueprintPath) {
var blueprint = Blueprint.load(blueprintPath);
var name;
if (blueprint) {
name = blueprint.name;
blueprint.overridden = includes(seen, name);
seen.push(name);
return blueprint;
}
return;
});
return {
source: source,
blueprints: compact(blueprints)
};
});
}n/a
load = function (blueprintPath) {
var constructorPath = path.join(path.resolve(blueprintPath), 'index');
var blueprintModule;
var Constructor = Blueprint;
if (fs.lstatSync(blueprintPath).isDirectory()) {
blueprintModule = require(constructorPath);
if (blueprintModule) {
if (typeof blueprintModule === 'function') {
Constructor = blueprintModule;
} else if (typeof blueprintModule.default === 'function') {
Constructor = blueprintModule.default
} else {
Constructor = Blueprint.extend(blueprintModule);
}
}
return new Constructor(blueprintPath);
}
return;
}...
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..'
;, 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
...lookup = function (name, options) {
options = options || {};
var lookupPaths = generateLookupPaths(options.paths);
var lookupPath;
var blueprintPath;
for (var i = 0; (lookupPath = lookupPaths[i]); i++) {
blueprintPath = path.resolve(lookupPath, name);
if (existsSync(blueprintPath)) {
return Blueprint.load(blueprintPath);
}
}
if (!options.ignoreMissing) {
throw new SilentError('Unknown blueprint: ' + name);
}
}n/a
_checkForNoMatch = function (fileInfos, rawArgs) {
if (fileInfos.filter(isFilePath).length < 1 && rawArgs) {
this.ui.writeLine(chalk.yellow('The globPattern \"' + rawArgs +
'\" did not match any files, so no file updates will be made.'));
}
}n/a
_checkForPod = function (verbose) {
if (!this.hasPathToken && this.pod && verbose) {
this.ui.writeLine(chalk.yellow('You specified the pod flag, but this' +
' blueprint does not support pod structure. It will be generated with' +
' the default structure.'));
}
}n/a
_checkInRepoAddonExists = function (inRepoAddon) {
if (inRepoAddon) {
if (!inRepoAddonExists(inRepoAddon, this.project.root)) {
throw new SilentError('You specified the in-repo-addon flag, but the' +
' in-repo-addon \'' + inRepoAddon + '\' does not exist. Please' +
' check the name and try again.');
}
}
}n/a
_commit = function (result) {
var action = this._actions[result.action];
if (action) {
return action.call(this, result);
} else {
throw new Error('Tried to call action \"' + result.action + '\" but it does not exist');
}
}n/a
_fileMapTokens = function (options) {
var standardTokens = {
__name__: function(options) {
if (options.pod && options.hasPathToken) {
return options.blueprintName;
}
return options.dasherizedModuleName;
},
__path__: function(options) {
var blueprintName = options.blueprintName;
if (blueprintName.match(/-test/)) {
blueprintName = options.blueprintName.slice(0, options.blueprintName.indexOf('-test'));
}
if (options.pod && options.hasPathToken) {
return path.join(options.podPath, options.dasherizedModuleName);
}
return inflector.pluralize(blueprintName);
},
__root__: function(options) {
if (options.inRepoAddon) {
return path.join('lib',options.inRepoAddon, 'addon');
}
if (options.inDummy) {
return path.join('tests','dummy','app');
}
if (options.inAddon) {
return 'addon';
}
return 'app';
},
__test__: function(options) {
if (options.pod && options.hasPathToken) {
return options.blueprintName;
}
return options.dasherizedModuleName + '-test';
}
};
var customTokens = this.fileMapTokens(options) || options.fileMapTokens || {};
return merge(standardTokens, customTokens);
}n/a
_generateFileMapVariables = function (moduleName, locals, options) {
var originBlueprintName = options.originBlueprintName || this.name;
var podModulePrefix = this.project.config().podModulePrefix || '';
var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1);
var inAddon = this.project.isEmberCLIAddon() || !!options.inRepoAddon;
var inDummy = this.project.isEmberCLIAddon() ? options.dummy : false;
return {
pod: this.pod,
podPath: podPath,
hasPathToken: this.hasPathToken,
inAddon: inAddon,
inRepoAddon: options.inRepoAddon,
inDummy: inDummy,
blueprintName: this.name,
originBlueprintName: originBlueprintName,
dasherizedModuleName: stringUtils.dasherize(moduleName),
locals: locals
};
}n/a
_getFileInfos = function (files, intoDir, templateVariables) {
return files.map(this.buildFileInfo.bind(this, destPath.bind(null, intoDir), templateVariables));
}n/a
_getFilesForInstall = function (targetFiles) {
var files = this.files();
// if we've defined targetFiles, get file info on ones that match
return targetFiles && targetFiles.length > 0 && intersect(files, targetFiles) || files;
}n/a
_ignoreUpdateFiles = function () {
if (this.isUpdate()) {
Blueprint.ignoredFiles = Blueprint.ignoredFiles.concat(Blueprint.ignoredUpdateFiles);
}
}n/a
_locals = function (options) {
var packageName = options.project.name();
var moduleName = options.entity && options.entity.name || packageName;
var sanitizedModuleName = moduleName.replace(/\//g, '-');
return new Promise(function(resolve) {
resolve(this.locals(options));
}.bind(this)).then(function (customLocals) {
var fileMapVariables = this._generateFileMapVariables(moduleName, customLocals, options);
var fileMap = this.generateFileMap(fileMapVariables);
var standardLocals = {
dasherizedPackageName: stringUtils.dasherize(packageName),
classifiedPackageName: stringUtils.classify(packageName),
dasherizedModuleName: stringUtils.dasherize(moduleName),
classifiedModuleName: stringUtils.classify(sanitizedModuleName),
camelizedModuleName: stringUtils.camelize(sanitizedModuleName),
decamelizedModuleName: stringUtils.decamelize(sanitizedModuleName),
fileMap: fileMap,
hasPathToken: this.hasPathToken,
targetFiles: options.targetFiles,
rawArgs: options.rawArgs
};
return merge({}, standardLocals, customLocals);
}.bind(this));
}n/a
_normalizeEntityName = function (entity) {
if (entity) {
entity.name = this.normalizeEntityName(entity.name);
}
}n/a
_printCommand = function (initialMargin, shouldDescriptionBeGrey) {
initialMargin = initialMargin || '';
var output = '';
var options = this.anonymousOptions;
// <anonymous-option-1> ...
if (options.length) {
output += ' ' + chalk.yellow(options.map(function(option) {
// blueprints we insert brackets, commands already have them
if (option.indexOf('<') === 0) {
return option;
} else {
return '<' + option + '>';
}
}).join(' '));
}
options = this.availableOptions;
// <options...>
if (options.length) {
output += ' ' + chalk.cyan('<options...>');
}
// Description
var description = this.description;
if (description) {
if (shouldDescriptionBeGrey) {
description = chalk.grey(description);
}
output += EOL + initialMargin + ' ' + description;
}
// aliases: a b c
if (this.aliases && this.aliases.length) {
output += EOL + initialMargin + ' ' + chalk.grey('aliases: ' + this.aliases.filter(function(a) { return a; }).join(', '));
}
// --available-option (Required) (Default: value)
// ...
options.forEach(function(option) {
output += EOL + initialMargin + ' ' + chalk.cyan('--' + option.name);
if (option.values) {
output += chalk.cyan('=' + option.values.join('|'));
}
if (option.type) {
var types = Array.isArray(option.type) ?
option.type.map(formatType).join(', ') :
formatType(option.type);
output += ' ' + chalk.cyan('(' + types + ')');
}
if (option.required) {
output += ' ' + chalk.cyan('(Required)');
}
if (option.default !== undefined) {
output += ' ' + chalk.cyan('(Default: ' + option.default + ')');
}
if (option.description) {
output += ' ' + option.description;
}
if (option.aliases && option.aliases.length) {
output += EOL + initialMargin + ' ' + chalk.grey('aliases: ' + option.aliases.map(function(a) {
if (typeof a === 'string') {
return (a.length > 4 ? '--' : '-') + a + (option.type === Boolean ? '' : ' <value>');
} else {
var key = Object.keys(a)[0];
return (key.length > 4 ? '--' : '-') + key + ' (--' + option.name + '=' + a[key] + ')';
}
}).join(', '));
}
});
return output;
}n/a
_process = function (options, beforeHook, process, afterHook) {
var self = this;
var intoDir = options.target;
return this._locals(options).then(function (locals) {
return Promise.resolve()
.then(beforeHook.bind(self, options, locals))
.then(process.bind(self, intoDir, locals)).map(self._commit.bind(self))
.then(afterHook.bind(self, options));
});
}n/a
_writeFile = function (info) {
if (!this.dryRun) {
return writeFile(info.outputPath, info.render());
}
}n/a
_writeStatusToUI = function (chalkColor, keyword, message) {
if (this.ui) {
this.ui.writeLine(' ' + chalkColor(keyword) + ' ' + message);
}
}n/a
addPackageToProject = function (packageName, target) {
var packageObject = {name: packageName};
if (target) {
packageObject.target = target;
}
return this.addPackagesToProject([packageObject]);
}n/a
addPackagesToProject = function (packages) {
var task = this.taskFor('npm-install');
var installText = (packages.length > 1) ? 'install packages' : 'install package';
var packageNames = [];
var packageArray = [];
for (var i = 0; i < packages.length; i++) {
packageNames.push(packages[i].name);
var packageNameAndVersion = packages[i].name;
if (packages[i].target) {
packageNameAndVersion += '@' + packages[i].target;
}
packageArray.push(packageNameAndVersion);
}
this._writeStatusToUI(chalk.green, installText, packageNames.join(', '));
return task.run({
'save-dev': true,
verbose: false,
packages: packageArray
});
}n/a
afterInstall = function () {}n/a
afterUninstall = function () {}n/a
beforeInstall = function () {}n/a
beforeUninstall = function () {}n/a
buildFileInfo = function (destPath, templateVariables, file) {
var mappedPath = this.mapFile(file, templateVariables);
return new FileInfo({
action: 'write',
outputPath: destPath(mappedPath),
displayPath: path.normalize(mappedPath),
inputPath: this.srcPath(file),
templateVariables: templateVariables,
ui: this.ui
});
}n/a
fileMapTokens = function () {
}n/a
files = function () {
if (this._files) { return this._files; }
var filesPath = this.filesPath(this.options);
if (existsSync(filesPath)) {
this._files = walkSync(filesPath);
} else {
this._files = [];
}
return this._files;
}n/a
filesPath = function () {
return path.join(this.path, 'files');
}n/a
generateFileMap = function (fileMapVariables) {
var tokens = this._fileMapTokens(fileMapVariables);
var fileMapValues = values(tokens);
var tokenValues = fileMapValues.map(function(token) { return token(fileMapVariables); });
var tokenKeys = keys(tokens);
return zipObject(tokenKeys,tokenValues);
}n/a
getJson = function (verbose) {
var json = {};
printableProperties.forEachWithProperty(function(key) {
var value = this[key];
if (key === 'availableOptions') {
value = cloneDeep(value);
value.forEach(function(option) {
if (typeof option.type === 'function') {
option.type = option.type.name;
}
});
}
json[key] = value;
}, this);
if (verbose) {
var detailedHelp = this.printDetailedHelp(this.availableOptions);
if (detailedHelp) {
json.detailedHelp = detailedHelp;
}
}
return json;
}n/a
insertIntoFile = function (pathRelativeToProjectRoot, contentsToInsert, providedOptions) {
var fullPath = path.join(this.project.root, pathRelativeToProjectRoot);
var originalContents = '';
if (existsSync(fullPath)) {
originalContents = fs.readFileSync(fullPath, { encoding: 'utf8' });
}
var contentsToWrite = originalContents;
var options = providedOptions || {};
var alreadyPresent = originalContents.indexOf(contentsToInsert) > -1;
var insert = !alreadyPresent;
var insertBehavior = 'end';
if (options.before) { insertBehavior = 'before'; }
if (options.after) { insertBehavior = 'after'; }
if (options.force) { insert = true; }
if (insert) {
if (insertBehavior === 'end') {
contentsToWrite += contentsToInsert;
} else {
var contentMarker = options[insertBehavior];
var contentMarkerIndex = contentsToWrite.indexOf(contentMarker);
if (contentMarkerIndex !== -1) {
var insertIndex = contentMarkerIndex;
if (insertBehavior === 'after') { insertIndex += contentMarker.length; }
contentsToWrite = contentsToWrite.slice(0, insertIndex) +
contentsToInsert + EOL +
contentsToWrite.slice(insertIndex);
}
}
}
var returnValue = {
path: fullPath,
originalContents: originalContents,
contents: contentsToWrite,
inserted: false
};
if (contentsToWrite !== originalContents) {
returnValue.inserted = true;
return writeFile(fullPath, contentsToWrite)
.then(function() {
return returnValue;
});
} else {
return Promise.resolve(returnValue);
}
}n/a
install = function (options) {
var ui = this.ui = options.ui;
var dryRun = this.dryRun = options.dryRun;
this.project = options.project;
this.pod = options.pod;
this.options = options;
this.hasPathToken = hasPathToken(this.files());
podDeprecations(this.project.config(), ui);
ui.writeLine('installing ' + this.name);
if (dryRun) {
ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' +
' changes will be written.'));
}
this._normalizeEntityName(options.entity);
this._checkForPod(options.verbose);
this._checkInRepoAddonExists(options.inRepoAddon);
debug('START: processing blueprint: `%s`', this.name);
var start = new Date();
return this._process(
options,
this.beforeInstall,
this.processFiles,
this.afterInstall).finally(function() {
debug('END: processing blueprint: `%s` in (%dms)', this.name, new Date() - start);
}.bind(this));
}n/a
isUpdate = function () {
if (this.project && this.project.isEmberCLIProject) {
return this.project.isEmberCLIProject();
}
}n/a
locals = function () {}n/a
lookupBlueprint = function (dasherizedName) {
var projectPaths = this.project ? this.project.blueprintLookupPaths() : [];
return Blueprint.lookup(dasherizedName, {
paths: projectPaths
});
}n/a
mapFile = function (file, locals) {
var pattern, i;
var fileMap = locals.fileMap || { __name__: locals.dasherizedModuleName };
file = Blueprint.renamedFiles[file] || file;
for (i in fileMap) {
pattern = new RegExp(i, 'g');
file = file.replace(pattern, fileMap[i]);
}
return file;
}n/a
normalizeEntityName = function (entityName) {
return normalizeEntityName(entityName);
}n/a
printBasicHelp = function (verbose) {
var initialMargin = ' ';
var output = initialMargin;
if (this.overridden) {
output += chalk.grey('(overridden) ' + this.name);
} else {
output += this.name;
output += this._printCommand(initialMargin, true);
if (verbose) {
output += EOL + this.printDetailedHelp(this.availableOptions);
}
}
return output;
}...
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
};
return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
}
});
...printDetailedHelp = function () {
return '';
}n/a
processFiles = function (intoDir, templateVariables) {
var files = this._getFilesForInstall(templateVariables.targetFiles);
var fileInfos = this._getFileInfos(files, intoDir, templateVariables);
this._checkForNoMatch(fileInfos, templateVariables.rawArgs);
this._ignoreUpdateFiles();
return Promise.filter(fileInfos, isValidFile).
map(prepareConfirm).
then(finishProcessingForInstall);
}n/a
processFilesForUninstall = function (intoDir, templateVariables) {
var fileInfos = this._getFileInfos(this.files(), intoDir, templateVariables);
this._ignoreUpdateFiles();
return Promise.filter(fileInfos, isValidFile).
then(finishProcessingForUninstall);
}n/a
removePackageFromProject = function (packageName) {
var packageObject = {name: packageName};
return this.removePackagesFromProject([packageObject]);
}n/a
removePackagesFromProject = function (packages) {
var task = this.taskFor('npm-uninstall');
var installText = (packages.length > 1) ? 'uninstall packages' : 'uninstall package';
var packageNames = [];
var packageArray = [];
for (var i = 0; i < packages.length; i++) {
packageNames.push(packages[i].name);
var packageNameAndVersion = packages[i].name;
packageArray.push(packageNameAndVersion);
}
this._writeStatusToUI(chalk.green, installText, packageNames.join(', '));
return task.run({
'save-dev': true,
verbose: false,
packages: packageArray
});
}n/a
srcPath = function (file) {
return path.resolve(this.filesPath(this.options), file);
}n/a
supportsAddon = function () {
return this.files().join().match(/__root__/);
}n/a
taskFor = function (dasherizedName) {
var Task = require('../tasks/' + dasherizedName);
return new Task({
ui: this.ui,
project: this.project
});
}n/a
uninstall = function (options) {
var ui = this.ui = options.ui;
var dryRun = this.dryRun = options.dryRun;
this.project = options.project;
this.pod = options.pod;
this.options = options;
this.hasPathToken = hasPathToken(this.files());
podDeprecations(this.project.config(), ui);
ui.writeLine('uninstalling ' + this.name);
if (dryRun) {
ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' +
' files will be deleted.'));
}
this._normalizeEntityName(options.entity);
this._checkForPod(options.verbose);
return this._process(
options,
this.beforeUninstall,
this.processFilesForUninstall,
this.afterUninstall);
}n/a
function CLI(options) {
this.name = options.name;
this.ui = options.ui;
this.testing = options.testing;
this.disableDependencyChecker = options.disableDependencyChecker;
this.root = options.root;
this.npmPackage = options.npmPackage;
debug('testing %o', !!this.testing);
}n/a
callHelp = function (options) {
var environment = options.environment;
var commandName = options.commandName;
var commandArgs = options.commandArgs;
var helpIndex = commandArgs.indexOf('--help');
var hIndex = commandArgs.indexOf('-h');
var HelpCommand = lookupCommand(environment.commands, 'help', commandArgs, {
project: environment.project,
ui: this.ui
});
var help = new HelpCommand({
ui: this.ui,
commands: environment.commands,
tasks: environment.tasks,
project: environment.project,
settings: environment.settings,
testing: this.testing
});
if (helpIndex > -1) {
commandArgs.splice(helpIndex,1);
}
if (hIndex > -1) {
commandArgs.splice(hIndex,1);
}
commandArgs.unshift(commandName);
return help.validateAndRun(commandArgs);
}n/a
logError = function (error) {
if (this.testing && error) {
console.error(error.message);
if (error.stack) {
console.error(error.stack);
}
throw error;
}
this.ui.errorLog.push(error);
this.ui.writeError(error);
return 1;
}n/a
run = function (environment) {
return Promise.hash(environment).then(function(environment) {
var args = environment.cliArgs.slice();
if (args[0] === '--help') {
if (args.length === 1) {
args[0] = 'help';
} else {
args.shift();
args.push('--help');
}
}
var commandName = args.shift();
var commandArgs = args;
var helpOptions;
var update;
var CurrentCommand = lookupCommand(environment.commands, commandName, commandArgs, {
project: environment.project,
ui: this.ui
});
var command = new CurrentCommand({
ui: this.ui,
commands: environment.commands,
tasks: environment.tasks,
project: environment.project,
settings: environment.settings,
testing: this.testing,
cli: this
});
getOptionArgs('--verbose', commandArgs).forEach(function(arg) {
process.env['EMBER_VERBOSE_' + arg.toUpperCase()] = 'true';
});
var platform = new PlatformChecker(process.version);
if (!platform.isValid && !this.testing) {
if (platform.isDeprecated) {
this.ui.writeDeprecateLine('Node ' + process.version +
' is no longer supported by Angular CLI. Please update to a more recent version of Node');
}
if (platform.isUntested) {
this.ui.writeWarnLine('WARNING: Node ' + process.version +
' has currently not been tested against Angular CLI and may result in unexpected behaviour.');
}
}
debug('command: %s', commandName);
if (!this.testing) {
process.chdir(environment.project.root);
var skipInstallationCheck = commandArgs.indexOf('--skip-installation-check') !== -1;
if (environment.project.isEmberCLIProject() && !skipInstallationCheck) {
new InstallationChecker({ project: environment.project }).checkInstallations();
}
}
command.beforeRun(commandArgs);
return Promise.resolve(update).then(function() {
debugTesting('cli: command.validateAndRun');
return command.validateAndRun(commandArgs);
}).then(function(result) {
// if the help option was passed, call the help command
if (result === 'callHelp') {
helpOptions = {
environment: environment,
commandName: commandName,
commandArgs: commandArgs
};
return this.callHelp(helpOptions);
}
return result;
}.bind(this)).then(function(exitCode) {
debugTesting('cli: command run complete. exitCode: ' + exitCode);
// TODO: fix this
// Possibly this issue: https://github.com/joyent/node/issues/8329
// Wait to resolve promise when running on windows.
// This ensures that stdout is flushed so acceptance tests get full output
return new Promise(function(resolve) {
if (process.platform === 'win32') {
setTimeout(resolve, 250, exitCode);
} else {
resolve(exitCode);
}
});
}.bind(this));
}.bind(this)).catch(this.logError.bind(this));
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function Command() {
CoreObject.apply(this, arguments);
this.isWithinProject = this.project.isEmberCLIProject();
this.name = this.name || path.basename(getCallerFile(), '.js');
debug('initialize: name: %s, name: %s', this.name);
this.aliases = this.aliases || [];
// Works Property
if (!allowedWorkOptions[this.works]) {
throw new Error('The "' + this.name + '" command\'s works field has to ' +
'be either "everywhere", "insideProject" or "outsideProject".');
}
// Options properties
this.availableOptions = this.availableOptions || [];
this.anonymousOptions = this.anonymousOptions || [];
this.registerOptions();
}n/a
_printCommand = function (initialMargin, shouldDescriptionBeGrey) {
initialMargin = initialMargin || '';
var output = '';
var options = this.anonymousOptions;
// <anonymous-option-1> ...
if (options.length) {
output += ' ' + chalk.yellow(options.map(function(option) {
// blueprints we insert brackets, commands already have them
if (option.indexOf('<') === 0) {
return option;
} else {
return '<' + option + '>';
}
}).join(' '));
}
options = this.availableOptions;
// <options...>
if (options.length) {
output += ' ' + chalk.cyan('<options...>');
}
// Description
var description = this.description;
if (description) {
if (shouldDescriptionBeGrey) {
description = chalk.grey(description);
}
output += EOL + initialMargin + ' ' + description;
}
// aliases: a b c
if (this.aliases && this.aliases.length) {
output += EOL + initialMargin + ' ' + chalk.grey('aliases: ' + this.aliases.filter(function(a) { return a; }).join(', '));
}
// --available-option (Required) (Default: value)
// ...
options.forEach(function(option) {
output += EOL + initialMargin + ' ' + chalk.cyan('--' + option.name);
if (option.values) {
output += chalk.cyan('=' + option.values.join('|'));
}
if (option.type) {
var types = Array.isArray(option.type) ?
option.type.map(formatType).join(', ') :
formatType(option.type);
output += ' ' + chalk.cyan('(' + types + ')');
}
if (option.required) {
output += ' ' + chalk.cyan('(Required)');
}
if (option.default !== undefined) {
output += ' ' + chalk.cyan('(Default: ' + option.default + ')');
}
if (option.description) {
output += ' ' + option.description;
}
if (option.aliases && option.aliases.length) {
output += EOL + initialMargin + ' ' + chalk.grey('aliases: ' + option.aliases.map(function(a) {
if (typeof a === 'string') {
return (a.length > 4 ? '--' : '-') + a + (option.type === Boolean ? '' : ' <value>');
} else {
var key = Object.keys(a)[0];
return (key.length > 4 ? '--' : '-') + key + ' (--' + option.name + '=' + a[key] + ')';
}
}).join(', '));
}
});
return output;
}n/a
assignAlias = function (option, alias) {
var isValid = this.validateAlias(option, alias);
if (isValid) {
this.optionsAliases[alias.key] = alias.value;
}
return isValid;
}n/a
assignOption = function (option, parsedOptions, commandOptions) {
var isValid = isValidParsedOption(option, parsedOptions[option.name]);
if (isValid) {
if (parsedOptions[option.name] === undefined) {
if (option.default !== undefined) {
commandOptions[option.key] = option.default;
}
if (this.settings[option.name] !== undefined) {
commandOptions[option.key] = this.settings[option.name];
} else if (this.settings[option.key] !== undefined) {
commandOptions[option.key] = this.settings[option.key];
}
} else {
commandOptions[option.key] = parsedOptions[option.name];
delete parsedOptions[option.name];
}
} else {
this.ui.writeLine('The specified command ' + chalk.green(this.name) +
' requires the option ' + chalk.green(option.name) + '.');
}
return isValid;
}n/a
beforeRun = function () {
}n/a
getJson = function (options) {
var json = {};
printableProperties.forEachWithProperty(function(key) {
json[key] = this[key];
}, this);
if (this.addAdditionalJsonForHelp) {
this.addAdditionalJsonForHelp(json, options);
}
return json;
}n/a
mergeDuplicateOption = function (key) {
var duplicateOptions, mergedOption, mergedAliases;
// get duplicates to merge
duplicateOptions = filter(this.availableOptions, { 'name': key });
if (duplicateOptions.length > 1) {
// TODO: warn on duplicates and overwriting
mergedAliases = [];
map(duplicateOptions, 'aliases').map(function(alias) {
alias.map(function(a) {
mergedAliases.push(a);
});
});
// merge duplicate options
mergedOption = assign.apply(null,duplicateOptions);
// replace aliases with unique aliases
mergedOption.aliases = uniqBy(mergedAliases, function(alias) {
if (typeof alias === 'object') {
return alias[Object.keys(alias)[0]];
}
return alias;
});
// remove duplicates from options
this.availableOptions = reject(this.availableOptions, { 'name': key });
this.availableOptions.push(mergedOption);
}
return this.availableOptions;
}n/a
normalizeOption = function (option) {
option.key = camelize(option.name);
option.required = option.required || false;
return option;
}n/a
parseAlias = function (option, alias) {
var aliasType = typeof alias;
var key, value, aliasValue;
if (isValidAlias(alias, option.type)) {
if (aliasType === 'string') {
key = alias;
value = ['--' + option.name];
} else if (aliasType === 'object') {
key = Object.keys(alias)[0];
value = ['--' + option.name, alias[key]];
}
} else {
if (Array.isArray(alias)) {
aliasType = 'array';
aliasValue = alias.join(',');
} else {
aliasValue = alias;
try {
aliasValue = JSON.parse(alias);
} catch (e) {
var debug = require('debug')('angular-cli/ember-cli/models/command');
debug(e);
}
}
throw new Error('The "' + aliasValue + '" [type:' + aliasType +
'] alias is not an acceptable value. It must be a string or single key' +
' object with a string value (for example, "value" or { "key" : "value" }).');
}
return {
key: key,
value: value,
original: alias
};
}n/a
parseArgs = function (commandArgs) {
var knownOpts = {}; // Parse options
var commandOptions = {};
var parsedOptions;
var assembleAndValidateOption = function(option) {
return this.assignOption(option, parsedOptions, commandOptions);
};
var validateParsed = function(key) {
// ignore 'argv', 'h', and 'help'
if (!commandOptions.hasOwnProperty(key) && key !== 'argv' && key !== 'h' && key !== 'help') {
this.ui.writeLine(chalk.yellow('The option \'--' + key + '\' is not registered with the ' + this.name + ' command. ' +
'Run `ng ' + this.name + ' --help` for a list of supported options.'));
}
if (typeof parsedOptions[key] !== 'object') {
commandOptions[camelize(key)] = parsedOptions[key];
}
};
this.availableOptions.forEach(function(option) {
if (typeof option.type !== 'string') {
knownOpts[option.name] = option.type;
} else if (option.type === 'Path') {
knownOpts[option.name] = path;
} else {
knownOpts[option.name] = String;
}
});
parsedOptions = nopt(knownOpts, this.optionsAliases, commandArgs, 0);
if (!this.availableOptions.every(assembleAndValidateOption.bind(this))) {
return null;
}
keys(parsedOptions).map(validateParsed.bind(this));
return {
options: defaults(commandOptions, this.settings),
args: parsedOptions.argv.remain
};
}n/a
printBasicHelp = function () {
// ng command-name
var output;
if (this.isRoot) {
output = 'Usage: ' + this.name;
} else {
output = 'ng ' + this.name;
}
output += this._printCommand();
output += EOL;
return output;
}...
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
};
return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
}
});
...printDetailedHelp = function () {}n/a
registerOptions = function (options) {
var extendedAvailableOptions = options && options.availableOptions || [];
var extendedAnonymousOptions = options && options.anonymousOptions || [];
this.anonymousOptions = union(this.anonymousOptions.slice(0), extendedAnonymousOptions);
// merge any availableOptions
this.availableOptions = union(this.availableOptions.slice(0), extendedAvailableOptions);
var optionKeys = uniq(map(this.availableOptions, 'name'));
optionKeys.map(this.mergeDuplicateOption.bind(this));
this.optionsAliases = this.optionsAliases || {};
this.availableOptions.map(this.validateOption.bind(this));
}n/a
run = function (commandArgs) {
throw new Error('command must implement run' + commandArgs.toString());
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...validateAlias = function (option, alias) {
var key = alias.key;
var value = alias.value;
if (!this.optionsAliases[key]) {
return true;
} else {
if (value[0] !== this.optionsAliases[key][0]) {
throw new SilentError('The "' + key + '" alias is already in use by the "' + this.optionsAliases[key][0] +
'" option and cannot be used by the "' + value[0] + '" option. Please use a different alias.');
} else {
if (value[1] !== this.optionsAliases[key][1]) {
this.ui.writeLine(chalk.yellow('The "' + key + '" alias cannot be overridden. Please use a different alias.'));
// delete offending alias from options
var index = this.availableOptions.indexOf(option);
var aliasIndex = this.availableOptions[index].aliases.indexOf(alias.original);
if (this.availableOptions[index].aliases[aliasIndex]) {
delete this.availableOptions[index].aliases[aliasIndex];
}
}
}
return false;
}
}n/a
validateAndRun = function (args) {
var commandOptions = this.parseArgs(args);
// if the help option was passed, resolve with 'callHelp' to call help command
if (commandOptions && (commandOptions.options.help || commandOptions.options.h)) {
debug(this.name + ' called with help option');
return Promise.resolve('callHelp');
}
if (commandOptions === null) {
return Promise.resolve();
}
if (this.works === 'insideProject' && !this.isWithinProject) {
return Promise.reject(new SilentError(
'You have to be inside an angular-cli project in order to use ' +
'the ' + chalk.green(this.name) + ' command.'
));
}
if (this.works === 'outsideProject' && this.isWithinProject) {
return Promise.reject(new SilentError(
'You cannot use the ' + chalk.green(this.name) + ' command inside an angular-cli project.'
));
}
if (this.works === 'insideProject') {
if (!this.project.hasDependencies()) {
throw new SilentError('node_modules appears empty, you may need to run `npm install`');
}
}
return Watcher.detectWatcher(this.ui, commandOptions.options).then(function(options) {
if (options._watchmanInfo) {
this.project._watchmanInfo = options._watchmanInfo;
}
return this.run(options, commandOptions.args);
}.bind(this));
}n/a
validateOption = function (option) {
var parsedAliases;
if (!option.name || !option.type) {
throw new Error('The command "' + this.name + '" has an option ' +
'without the required type and name fields.');
}
if (option.name !== option.name.toLowerCase()) {
throw new Error('The "' + option.name + '" option\'s name of the "' +
this.name + '" command contains a capital letter.');
}
this.normalizeOption(option);
if (option.aliases) {
parsedAliases = option.aliases.map(this.parseAlias.bind(this, option));
return parsedAliases.map(this.assignAlias.bind(this, option)).indexOf(false) === -1;
}
return false;
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function getCommonConfig(wco) {
var projectRoot = wco.projectRoot, buildOptions = wco.buildOptions, appConfig = wco.appConfig;
var appRoot = path.resolve(projectRoot, appConfig.root);
var nodeModules = path.resolve(projectRoot, 'node_modules');
var extraPlugins = [];
var extraRules = [];
var entryPoints = {};
// figure out which are the lazy loaded entry points
var lazyChunks = utils_1.lazyChunksFilter(utils_1.extraEntryParser(appConfig.scripts, appRoot, 'scripts').concat(utils_1.extraEntryParser
(appConfig.styles, appRoot, 'styles')));
if (appConfig.main) {
entryPoints['main'] = [path.resolve(appRoot, appConfig.main)];
}
if (appConfig.polyfills) {
entryPoints['polyfills'] = [path.resolve(appRoot, appConfig.polyfills)];
}
// determine hashing format
var hashFormat = utils_1.getOutputHashFormat(buildOptions.outputHashing);
// process global scripts
if (appConfig.scripts.length > 0) {
var globalScripts = utils_1.extraEntryParser(appConfig.scripts, appRoot, 'scripts');
// add entry points and lazy chunks
globalScripts.forEach(function (script) {
var scriptPath = "script-loader!" + script.path;
if (script.lazy) {
lazyChunks.push(script.entry);
}
entryPoints[script.entry] = (entryPoints[script.entry] || []).concat(scriptPath);
});
}
if (buildOptions.vendorChunk) {
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['main'],
minChunks: function (module) { return module.resource && module.resource.startsWith(nodeModules); }
}));
}
// process environment file replacement
if (appConfig.environments) {
if (!('source' in appConfig.environments)) {
throw new SilentError("Environment configuration does not contain \"source\" entry.");
}
if (!(buildOptions.environment in appConfig.environments)) {
throw new SilentError("Environment \"" + buildOptions.environment + "\" does not exist.");
}
extraPlugins.push(new webpack.NormalModuleReplacementPlugin(
// This plugin is responsible for swapping the environment files.
// Since it takes a RegExp as first parameter, we need to escape the path.
// See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin
new RegExp(path.resolve(appRoot, appConfig.environments['source'])
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), path.resolve(appRoot, appConfig.environments[buildOptions.
environment])));
}
// process asset entries
if (appConfig.assets) {
extraPlugins.push(new glob_copy_webpack_plugin_1.GlobCopyWebpackPlugin({
patterns: appConfig.assets,
globOptions: { cwd: appRoot, dot: true, ignore: '**/.gitkeep' }
}));
}
if (buildOptions.progress) {
extraPlugins.push(new ProgressPlugin({ profile: buildOptions.verbose, colors: true }));
}
return {
devtool: buildOptions.sourcemap ? 'source-map' : false,
resolve: {
extensions: ['.ts', '.js'],
modules: [nodeModules],
},
resolveLoader: {
modules: [nodeModules]
},
context: projectRoot,
entry: entryPoints,
output: {
path: path.resolve(projectRoot, buildOptions.outputPath),
publicPath: buildOptions.deployUrl,
filename: "[name]" + hashFormat.chunk + ".bundle.js",
sourceMapFilename: "[name]" + hashFormat.chunk + ".bundle.map",
chunkFilename: "[id]" + hashFormat.chunk + ".chunk.js"
},
module: {
rules: [
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', exclude: [nodeModules] },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.(eot|svg)$/, loader: "file-loader?name ......
var projectRoot = path.dirname(configPath);
var appConfig = config_1.CliConfig.fromProject().config.apps[0];
appConfig = this.addAppConfigDefaults(appConfig);
buildOptions = this.addTargetDefaults(buildOptions);
buildOptions = this.mergeConfigs(buildOptions, appConfig);
var wco = { projectRoot: projectRoot, buildOptions: buildOptions, appConfig: appConfig };
var webpackConfigs = [
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getStylesConfig(wco),
this.getTargetConfig(wco)
];
if (appConfig.main || appConfig.polyfills) {
var typescriptConfigPartial = buildOptions.aot
? webpack_configs_1.getAotConfig(wco)
: webpack_configs_1.getNonAotConfig(wco);
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function CompressionPlugin(options) {
if (options === void 0) { options = {}; }
this.asset = '[path].gz[query]';
this.compressionOptions = {};
this.threshold = 0;
this.minRatio = 0.8;
if (options.hasOwnProperty('asset')) {
this.asset = options.asset;
}
var algorithm = options.hasOwnProperty('algorithm') ? options.algorithm : 'gzip';
var zlib = require('zlib');
this.compressionOptions = {};
this.algorithm = zlib[algorithm];
if (!this.algorithm) {
throw new Error("Algorithm not found in zlib: \"" + algorithm + "\".");
}
this.compressionOptions = {
level: options.level || 9,
flush: options.flush,
chunkSize: options.chunkSize,
windowBits: options.windowBits,
memLevel: options.memLevel,
strategy: options.strategy,
dictionary: options.dictionary
};
if (options.hasOwnProperty('test')) {
if (Array.isArray(options.test)) {
this.test = options.test;
}
else {
this.test = [options.test];
}
}
if (options.hasOwnProperty('threshold')) {
this.threshold = options.threshold;
}
if (options.hasOwnProperty('minRatio')) {
this.minRatio = options.minRatio;
}
}n/a
function CliConfig() {
_super.apply(this, arguments);
}n/a
function CoreObject(options) {
Object.assign(this, options);
}n/a
extend = function (options) {
var constructor = this;
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}
Class.__proto__ = CoreObject;
Class.prototype = Object.create(constructor.prototype);
Object.assign(Class.prototype, options);
Class.prototype.constructor = Class;
Class.prototype._super = constructor.prototype;
return Class;
}...
name: 'output-hashing',
type: String,
values: ['none', 'all', 'media', 'bundles'],
description: 'define the output filename cache-busting hashing mode',
aliases: ['oh']
},
];
var BuildCommand = Command.extend({
name: 'build',
description: 'Builds your app and places it into the output path (dist/ by default).',
aliases: ['b'],
availableOptions: exports.BaseBuildCommandOptions.concat([
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] }
]),
run: function (commandOptions) {
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
run = function (options) {
var directoryName = this.directoryName = options.directoryName;
if (options.dryRun) {
return new Promise(function(resolve, reject) {
if (existsSync(directoryName)) {
return reject(this.warnDirectoryAlreadyExists());
}
resolve();
}.bind(this));
}
return mkdir(directoryName)
.catch(function(err) {
if (err.code === 'EEXIST') {
throw this.warnDirectoryAlreadyExists();
} else {
throw err;
}
}.bind(this))
.then(function() {
var cwd = process.cwd();
process.chdir(directoryName);
return { initialDirectory: cwd };
});
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function warnDirectoryAlreadyExists() {
var message = 'Directory \'' + this.directoryName + '\' already exists.';
return new SilentError(message);
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
getDevConfig = function (wco) {
return {};
}...
}
// add style config
this.config = webpackMerge(webpackConfigs);
}
NgCliWebpackConfig.prototype.getTargetConfig = function (webpackConfigOptions) {
switch (webpackConfigOptions.buildOptions.target) {
case 'development':
return webpack_configs_1.getDevConfig(webpackConfigOptions);
case 'production':
return webpack_configs_1.getProdConfig(webpackConfigOptions);
}
};
// Validate build options
NgCliWebpackConfig.prototype.validateBuildOptions = function (buildOptions) {
if (buildOptions.target !== 'development' && buildOptions.target !== 'production') {
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function EditFileDiff(options) {
this.info = options.info;
}n/a
edit = function () {
return Promise.hash({
input: this.info.render(),
output: readFile(this.info.outputPath)
})
.then(invokeEditor.bind(this))
.then(applyPatch.bind(this))
.finally(cleanUp.bind(this));
}n/a
function NgToolkitError(message) {
_super.call(this);
if (message) {
this.message = message;
}
else {
this.message = this.constructor.name;
}
}n/a
function FileInfo(options) {
this.action = options.action;
this.outputPath = options.outputPath;
this.displayPath = options.displayPath;
this.inputPath = options.inputPath;
this.templateVariables = options.templateVariables;
this.ui = options.ui;
}n/a
checkForConflict = function () {
return new Promise(function (resolve, reject) {
fs.exists(this.outputPath, function (doesExist, error) {
if (error) {
reject(error);
return;
}
var result;
if (doesExist) {
result = Promise.hash({
input: this.render(),
output: readFile(this.outputPath)
}).then(function(result) {
var type;
if (result.input === result.output.toString()) {
type = 'identical';
} else {
type = 'confirm';
}
return type;
}.bind(this));
} else {
result = 'none';
}
resolve(result);
}.bind(this));
}.bind(this));
}n/a
confirmOverwrite = function (path) {
var promptOptions = {
type: 'expand',
name: 'answer',
default: false,
message: chalk.red('Overwrite') + ' ' + path + '?',
choices: [
{ key: 'y', name: 'Yes, overwrite', value: 'overwrite' },
{ key: 'n', name: 'No, skip', value: 'skip' },
{ key: 'd', name: 'Diff', value: 'diff' }
]
};
if (canEdit()) {
promptOptions.choices.push({ key: 'e', name: 'Edit', value: 'edit' });
}
return this.ui.prompt(promptOptions)
.then(function(response) {
return response.answer;
});
}n/a
confirmOverwriteTask = function () {
var info = this;
return function() {
return new Promise(function(resolve, reject) {
function doConfirm() {
info.confirmOverwrite(info.displayPath).then(function(action) {
if (action === 'diff') {
info.displayDiff().then(doConfirm, reject);
} else if (action === 'edit') {
var editFileDiff = new EditFileDiff({info: info});
editFileDiff.edit().then(function() {
info.action = action;
resolve(info);
}).catch(function() {
doConfirm()
.finally(function() {
resolve(info);
});
});
} else {
info.action = action;
resolve(info);
}
}, reject);
}
doConfirm();
});
}.bind(this);
}n/a
displayDiff = function () {
var info = this,
jsdiff = require('diff');
return Promise.hash({
input: this.render(),
output: readFile(info.outputPath)
}).then(function(result) {
var diff = jsdiff.createPatch(
info.outputPath, result.output.toString(), result.input
);
var lines = diff.split('\n');
for (var i = 0; i < lines.length; i++) {
info.ui.write(
diffHighlight(lines[i] + EOL)
);
}
});
}n/a
render = function () {
var path = this.inputPath,
context = this.templateVariables;
if (!this.rendered) {
this.rendered = readFile(path).then(function(content) {
return lstat(path).then(function(fileStat) {
if (isBinaryFile(content, fileStat.size)) {
return content;
} else {
try {
return processTemplate(content.toString(), context);
} catch (err) {
err.message += ' (Error in blueprint template: ' + path + ')';
throw err;
}
}
});
});
}
return this.rendered;
}n/a
function findParentModule(project, currentDir) {
var sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app');
// trim currentDir
currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, 'app'), '');
var pathToCheck = path.join(sourceRoot, currentDir);
while (pathToCheck.length >= sourceRoot.length) {
// TODO: refactor to not be based upon file name
var files = fs.readdirSync(pathToCheck)
.filter(function (fileName) { return !fileName.endsWith('routing.module.ts'); })
.filter(function (fileName) { return fileName.endsWith('.module.ts'); })
.filter(function (fileName) { return fs.statSync(path.join(pathToCheck, fileName)).isFile(); });
if (files.length === 1) {
return path.join(pathToCheck, files[0]);
}
else if (files.length > 1) {
throw new SilentError("Multiple module files found: " + pathToCheck.replace(sourceRoot, ''));
}
// move to parent directory
pathToCheck = path.dirname(pathToCheck);
}
throw new SilentError('No module files found');
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
lookupBlueprint = function (name, ignoreMissing) {
return Blueprint.lookup(name, {
paths: this.project.blueprintLookupPaths(),
ignoreMissing: ignoreMissing
});
}n/a
run = function (options) {
var self = this;
var name = options.args[0];
var noAddonBlueprint = ['mixin', 'blueprint-test'];
var mainBlueprint = this.lookupBlueprint(name, options.ignoreMissingMain);
var testBlueprint = this.lookupBlueprint(name + '-test', true);
// lookup custom addon blueprint
var addonBlueprint = this.lookupBlueprint(name + '-addon', true);
// otherwise, use default addon-import
if (noAddonBlueprint.indexOf(name) < 0 && !addonBlueprint && (mainBlueprint && mainBlueprint.supportsAddon()) && options.args[
1]) {
addonBlueprint = this.lookupBlueprint('addon-import', true);
}
if (options.ignoreMissingMain && !mainBlueprint) {
return Promise.resolve();
}
if (options.dummy) {
// don't install test or addon reexport for dummy
if (this.project.isEmberCLIAddon()) {
testBlueprint = null;
addonBlueprint = null;
}
}
var entity = {
name: options.args[1],
options: parseOptions(options.args.slice(2))
};
var blueprintOptions = {
target: this.project.root,
entity: entity,
ui: this.ui,
project: this.project,
settings: this.settings,
testing: this.testing,
taskOptions: options,
originBlueprintName: name
};
blueprintOptions = merge(blueprintOptions, options || {});
return mainBlueprint[this.blueprintFunction](blueprintOptions)
.then(function() {
if (!testBlueprint) { return; }
if (testBlueprint.locals === Blueprint.prototype.locals) {
testBlueprint.locals = function(options) {
return mainBlueprint.locals(options);
};
}
var testBlueprintOptions = merge({} , blueprintOptions, { installingTest: true });
return testBlueprint[self.blueprintFunction](testBlueprintOptions);
})
.then(function() {
if (!addonBlueprint || name.match(/-addon/)) { return; }
if (!this.project.isEmberCLIAddon() && blueprintOptions.inRepoAddon === null) { return; }
if (addonBlueprint.locals === Blueprint.prototype.locals) {
addonBlueprint.locals = function(options) {
return mainBlueprint.locals(options);
};
}
var addonBlueprintOptions = merge({}, blueprintOptions, { installingAddon: true });
return addonBlueprint[self.blueprintFunction](addonBlueprintOptions);
}.bind(this));
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function createTsSourceFile(fileName) {
return readFile(fileName, 'utf8')
.then(function (contents) {
return ts.createSourceFile(fileName, contents, ts.ScriptTarget.Latest, true);
});
}n/a
function getAllAssociatedFiles(fileName) {
var fileDirName = path.dirname(fileName);
var componentName = path.basename(fileName, '.ts');
return globSearch(path.join(fileDirName, componentName + ".*"), { nodir: true })
.then(function (files) {
return files.filter(function (file) {
return (path.basename(file) !== 'index.ts');
});
});
}n/a
function getDependentFiles(fileName, rootPath) {
return globSearch(path.join(rootPath, '**/*.ts'), { nodir: true })
.then(function (files) { return Promise.all(files.map(function (file) { return createTsSourceFile(file); }))
.then(function (tsFiles) { return tsFiles.map(function (file) { return getImportClauses(file); }); })
.then(function (moduleSpecifiers) {
var allFiles = {};
files.forEach(function (file, index) {
var sourcePath = path.normalize(file);
allFiles[sourcePath] = moduleSpecifiers[index];
});
return allFiles;
})
.then(function (allFiles) {
var relevantFiles = {};
Object.keys(allFiles).forEach(function (filePath) {
var tempModuleSpecifiers = allFiles[filePath]
.filter(function (importClause) {
// Filter only relative imports
var singleSlash = importClause.specifierText.charAt(0) === '/';
var currentDirSyntax = importClause.specifierText.slice(0, 2) === './';
var parentDirSyntax = importClause.specifierText.slice(0, 3) === '../';
return singleSlash || currentDirSyntax || parentDirSyntax;
})
.filter(function (importClause) {
var modulePath = path.resolve(path.dirname(filePath), importClause.specifierText);
var resolvedFileName = path.resolve(fileName);
var fileBaseName = path.basename(resolvedFileName, '.ts');
var parsedFilePath = path.join(path.dirname(resolvedFileName), fileBaseName);
return (parsedFilePath === modulePath) || (resolvedFileName === modulePath);
});
if (tempModuleSpecifiers.length > 0) {
relevantFiles[filePath] = tempModuleSpecifiers;
}
;
});
return relevantFiles;
}); });
}n/a
function getImportClauses(node) {
return node.statements
.filter(function (node) { return node.kind === ts.SyntaxKind.ImportDeclaration; }) // Only Imports.
.map(function (node) {
var moduleSpecifier = node.moduleSpecifier;
return {
specifierText: moduleSpecifier.getText().slice(1, -1),
pos: moduleSpecifier.pos,
end: moduleSpecifier.end
};
});
}n/a
function hasIndexFile(dirPath) {
return globSearch(path.join(dirPath, 'index.ts'), { nodir: true })
.then(function (indexFile) {
return indexFile.length > 0;
});
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function githubPagesDeployRun(options, rawArgs) {
var ui = this.ui;
var root = this.project.root;
var execOptions = {
cwd: root
};
if (options.environment === '') {
if (options.target === 'development') {
options.environment = 'dev';
}
if (options.target === 'production') {
options.environment = 'prod';
}
}
var projectName = this.project.pkg.name;
var outDir = config_1.CliConfig.fromProject().config.apps[0].outDir;
var indexFilename = config_1.CliConfig.fromProject().config.apps[0].index;
var ghPagesBranch = 'gh-pages';
var destinationBranch = options.userPage ? 'master' : ghPagesBranch;
var initialBranch;
var branchErrMsg = ' You might also need to return to the initial branch manually.';
// declared here so that tests can stub exec
var execPromise = denodeify(child_process_1.exec);
var buildTask = new build_1.default({
ui: this.ui,
cliProject: this.project,
target: options.target,
environment: options.environment,
outputPath: outDir
});
/**
* BaseHref tag setting logic:
* First, no value if --custom-domain is provided.
* Second, use --base-href flag value if provided.
* Else if --user-page is true, then keep baseHref default as declared in index.html.
* Otherwise auto-replace with `/${projectName}/`.
*/
var baseHref = null;
if (!options.customDomain) {
baseHref = options.baseHref || (options.userPage ? null : "/" + projectName + "/");
}
var buildOptions = {
target: options.target,
environment: options.environment,
outputPath: outDir,
baseHref: baseHref,
aot: options.aot,
vendorChunk: options.vendorChunk,
};
var createGithubRepoTask = new create_github_repo_1.default({
ui: this.ui,
project: this.project
});
var createGithubRepoOptions = {
projectName: projectName,
ghUsername: options.ghUsername,
ghToken: options.ghToken
};
return checkForPendingChanges()
.then(build)
.then(saveStartingBranchName)
.then(createGitHubRepoIfNeeded)
.then(checkoutGhPages)
.then(cleanGhPagesBranch)
.then(copyFiles)
.then(createNotFoundPage)
.then(createCustomDomainFile)
.then(addAndCommit)
.then(returnStartingBranch)
.then(pushToGitRepo)
.then(printProjectUrl)
.catch(failGracefully);
function checkForPendingChanges() {
return execPromise('git status --porcelain')
.then(function (stdout) {
if (/\w+/m.test(stdout)) {
var msg = 'Uncommitted file changes found! Please commit all changes before deploying.';
return Promise.reject(new SilentError(msg));
}
});
}
function build() {
if (options.skipBuild) {
return Promise.resolve();
}
return buildTask.run(buildOptions);
}
function saveStartingBranchName() {
return execPromise('git rev-parse --abbrev-ref HEAD')
.then(function (stdout) { return initialBranch = stdout.replace(/\s/g, ''); });
}
function createGitHubRepoIfNeeded() {
return execPromise('git remote -v')
.then(function (stdout) {
if (!/origin\s+(https:\/\/|git@)github\.com/m.test(stdout)) {
return createGithubRepoTask.run(createGithubRepoOptions)
.then(function () { return generateRemoteUrl(); })
.then(function (upstream) {
// only push starting branch if it's not the destinationBranch
// this happens commonly when using github user pages, since
// they require the destination branch to be 'master'
if (destinationBranch !== initialBranch) {
execPromise("git push -u " + upstream + " " + initialBranch);
}
}); ......
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function GlobCopyWebpackPlugin(options) {
this.options = options;
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...blueprintsPath = function () {
return path.join(__dirname, '../blueprints');
}n/a
config = function () {
this.project.ngConfigObj = this.project.ngConfigObj || config.CliConfig.fromProject();
this.project.ngConfig = this.project.ngConfig || (
this.project.ngConfigObj && this.project.ngConfigObj.config);
}n/a
includedCommands = function () {
return {
'build': require('../commands/build').default,
'serve': require('../commands/serve').default,
'new': require('../commands/new').default,
'generate': require('../commands/generate').default,
'destroy': require('../commands/destroy').default,
'init': require('../commands/init').default,
'test': require('../commands/test').default,
'e2e': require('../commands/e2e').default,
'help': require('../commands/help').default,
'lint': require('../commands/lint').default,
'version': require('../commands/version').default,
'completion': require('../commands/completion').default,
'doc': require('../commands/doc').default,
'github-pages-deploy': require('../commands/github-pages-deploy').default,
// Easter eggs.
'make-this-awesome': require('../commands/easter-egg').default,
// Configuration.
'set': require('../commands/set').default,
'get': require('../commands/get').default
};
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function initRun(commandOptions, rawArgs) {
var _this = this;
if (commandOptions.dryRun) {
commandOptions.skipNpm = true;
}
var installBlueprint = new this.tasks.InstallBlueprint({
ui: this.ui,
project: this.project
});
// needs an explicit check in case it's just 'undefined'
// due to passing of options from 'new' and 'addon'
var gitInit;
if (commandOptions.skipGit === false) {
gitInit = new GitInit({
ui: this.ui,
project: this.project
});
}
var npmInstall;
if (!commandOptions.skipNpm) {
npmInstall = new npm_install_1.default({
ui: this.ui,
project: this.project
});
}
var linkCli;
if (commandOptions.linkCli) {
linkCli = new link_cli_1.default({
ui: this.ui,
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: 'ng2',
rawName: packageName,
targetFiles: rawArgs || '',
rawArgs: rawArgs.toString(),
sourceDir: commandOptions.sourceDir,
style: commandOptions.style,
prefix: commandOptions.prefix,
routing: commandOptions.routing,
inlineStyle: commandOptions.inlineStyle,
inlineTemplate: commandOptions.inlineTemplate,
ignoredUpdateFiles: ['favicon.ico'],
skipGit: commandOptions.skipGit,
skipTests: commandOptions.skipTests
};
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);
}
})
.then(function () {
if (!commandOptions.skipNpm) {
return npmInstall.run();
}
})
.then(function () {
if (commandOptions.linkCli) {
return linkCli.run();
}
})
.then(function () {
_this.ui.writeLine(chalk.green("Project '" + packageName + "' successfully created."));
});
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
run = function (options) {
var cwd = process.cwd();
var name = options.rawName;
var blueprintOption = options.blueprint;
// If we're in a dry run, pretend we changed directories.
// Pretending we cd'd avoids prompts in the actual current directory.
var fakeCwd = path.join(cwd, name);
var target = options.dryRun ? fakeCwd : cwd;
var installOptions = {
target: target,
entity: { name: name },
ui: this.ui,
project: this.project,
dryRun: options.dryRun,
targetFiles: options.targetFiles,
rawArgs: options.rawArgs
};
installOptions = merge(installOptions, options || {});
var blueprintName = blueprintOption || 'app';
var blueprint = Blueprint.lookup(blueprintName, {
paths: this.project.blueprintLookupPaths()
});
return blueprint.install(installOptions);
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function InstallationChecker(options) {
this.project = options.project;
}n/a
checkInstallations = function () {
var commands = [];
if (this.usingNpm() && this.npmDependenciesNotPresent()) {
debug('npm dependencies not installed');
commands.push('`npm install`');
}
if (commands.length) {
var commandText = commands.join(' and ');
throw new SilentError('No dependencies installed. Run ' + commandText + ' to install missing dependencies.');
}
}n/a
hasNpmDeps = function () {
return hasDependencies(readJSON(path.join(this.project.root, 'package.json')));
}n/a
npmDependenciesNotPresent = function () {
return !existsSync(this.project.nodeModulesPath);
}n/a
usingNpm = function () {
return existsSync(path.join(this.project.root, 'package.json')) && this.hasNpmDeps();
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
announceCompletion = function () {
this.ui.writeLine(chalk.green(this.completionMessage));
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
disableLogger = function () {
this.oldLog = console.log;
console.log = function() {};
}n/a
finally = function () {
this.ui.stopProgress();
this.restoreLogger();
}n/a
init = function () {
}n/a
restoreLogger = function () {
console.log = this.oldLog; // Hack, see above
}n/a
run = function (options) {
this.ui.startProgress(chalk.green(this.startProgressMessage), chalk.green('.'));
var npmOptions = {
loglevel: options.verbose ? 'verbose' : 'error',
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 spawn('npm', [this.command].concat(packages, npmOptions)).
// return npm(this.command, packages, npmOptions, this.npm).
finally(this.finally.bind(this)).
then(this.announceCompletion.bind(this));
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function openEditor(file) {
if (!openEditor.canEdit()) {
throw new Error('EDITOR environment variable is not set');
}
if (!file) {
throw new Error('No `file` option provided');
}
var editorArgs = openEditor._env().EDITOR.split(' ');
var editor = editorArgs.shift();
var editProcess = openEditor._spawn(editor, [file].concat(editorArgs), {stdio: 'inherit'});
return new Promise(function(resolve, reject) {
editProcess.on('close', function (code) {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
}n/a
_env = function () {
return process.env;
}n/a
_spawn = function () {
return spawn.apply(this, arguments);
}n/a
canEdit = function () {
return openEditor._env().EDITOR !== undefined;
}n/a
function packageChunkSort(appConfig) {
var entryPoints = ['inline', 'polyfills'];
var pushExtraEntries = function (extraEntry) {
if (entryPoints.indexOf(extraEntry.entry) === -1) {
entryPoints.push(extraEntry.entry);
}
};
if (appConfig.scripts) {
utils_1.extraEntryParser(appConfig.scripts, './', 'scripts').forEach(pushExtraEntries);
}
if (appConfig.styles) {
utils_1.extraEntryParser(appConfig.styles, './', 'styles').forEach(pushExtraEntries);
}
entryPoints.push.apply(entryPoints, ['vendor', 'main']);
return function sort(left, right) {
var leftIndex = entryPoints.indexOf(left.names[0]);
var rightindex = entryPoints.indexOf(right.names[0]);
if (leftIndex > rightindex) {
return 1;
}
else if (leftIndex < rightindex) {
return -1;
}
else {
return 0;
}
};
}n/a
function getRelativeParentPath(path, offset, slash) {
var offsetValue = offset || 0;
var trailingSlash = typeof slash === 'undefined' ? true : slash;
var outputPath = new Array(path.split('/').length + 1 - offsetValue).join('../');
return trailingSlash ? outputPath : outputPath.substr(0, outputPath.length - 1);
}n/a
function getRelativePath(path, offset) {
var offsetValue = offset || 0;
var relativePath = new Array(path.split('/').length - offsetValue).join('../');
return relativePath || './';
}n/a
function PlatformChecker(version) {
this.version = version;
this.isValid = this.checkIsValid();
this.isUntested = this.checkIsUntested();
this.isDeprecated = this.checkIsDeprecated();
debug('%o', {
version: this.version,
isValid: this.isValid,
isUntested: this.isUntested,
isDeprecated: this.isDeprecated
});
}n/a
checkIsDeprecated = function () {
return semver.satisfies(this.version, '<' + LOWER_RANGE);
}n/a
checkIsUntested = function () {
return semver.satisfies(this.version, '>=' + UPPER_RANGE);
}n/a
checkIsValid = function () {
return semver.satisfies(this.version, '>=' + LOWER_RANGE + ' <' + UPPER_RANGE);
}n/a
function PrerenderWebpackPlugin(options) {
this.options = options;
// maintain your platform instance
this.bootloader = require(this.options.configPath).getBootloader();
}n/a
getProdConfig = function (wco) {
var projectRoot = wco.projectRoot, buildOptions = wco.buildOptions, appConfig = wco.appConfig;
var appRoot = path.resolve(projectRoot, appConfig.root);
return {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
mangle: { screw_ie8: true },
compress: { screw_ie8: true, warnings: buildOptions.verbose },
sourceMap: buildOptions.sourcemap
}),
new compression_plugin_1.CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.html$|\.css$/,
threshold: 10240
})
]
};
}...
this.config = webpackMerge(webpackConfigs);
}
NgCliWebpackConfig.prototype.getTargetConfig = function (webpackConfigOptions) {
switch (webpackConfigOptions.buildOptions.target) {
case 'development':
return webpack_configs_1.getDevConfig(webpackConfigOptions);
case 'production':
return webpack_configs_1.getProdConfig(webpackConfigOptions);
}
};
// Validate build options
NgCliWebpackConfig.prototype.validateBuildOptions = function (buildOptions) {
if (buildOptions.target !== 'development' && buildOptions.target !== 'production') {
throw new Error("Invalid build target. Only 'development' and 'production' are available.");
}
...function Project(root, pkg, ui, cli) {
debug('init root: %s', root);
this.root = root;
this.pkg = pkg;
this.ui = ui;
this.cli = cli;
this.addonPackages = {};
this.addons = [];
this.liveReloadFilterPatterns = [];
this.setupNodeModulesPath();
this._watchmanInfo = {
enabled: false,
version: null,
canNestRoots: false
};
}n/a
function NotFoundError(message) {
this.name = 'NotFoundError';
this.message = message;
this.stack = (new Error()).stack;
}n/a
closest = function (pathName, _ui, _cli) {
var ui = ensureUI(_ui);
return closestPackageJSON(pathName)
.then(function(result) {
debug('closest %s -> %s', pathName, result);
if (result.pkg && result.pkg.name === 'ember-cli') {
return Project.nullProject(_ui, _cli);
}
return new Project(result.directory, result.pkg, ui, _cli);
})
.catch(function(reason) {
handleFindupError(pathName, reason);
});
}n/a
closestSync = function (pathName, _ui, _cli) {
var ui = ensureUI(_ui);
var directory, pkg;
if (_cli && _cli.testing) {
directory = existsSync(path.join(pathName, 'package.json')) && process.cwd();
if (!directory) {
if (pathName.indexOf(path.sep + 'app') > -1) {
directory = findupPath(pathName);
} else {
pkg = {name: 'ember-cli'};
}
}
} else {
directory = findupPath(pathName);
}
if (!pkg) {
pkg = JSON.parse(fs.readFileSync(path.join(directory, 'package.json')));
}
debug('dir' + directory);
debug('pkg: %s', pkg);
if (pkg && pkg.name === 'ember-cli') {
return Project.nullProject(_ui, _cli);
}
debug('closestSync %s -> %s', pathName, directory);
return new Project(directory, pkg, ui, _cli);
}n/a
getProjectRoot = function () {
try {
var directory = findup.sync(process.cwd(), 'package.json');
var pkg = require(path.join(directory, 'package.json'));
if (pkg && pkg.name === 'ember-cli') {
debug('getProjectRoot: named \'ember-cli\'. Will use cwd: %s', process.cwd());
return process.cwd();
}
debug('getProjectRoot %s -> %s', process.cwd(), directory);
return directory;
} catch (reason) {
if (isFindupError(reason)) {
debug('getProjectRoot: not found. Will use cwd: %s', process.cwd());
return process.cwd();
} else {
throw reason;
}
}
}n/a
nullProject = function (ui, cli) {
if (NULL_PROJECT) { return NULL_PROJECT; }
NULL_PROJECT = new Project(processCwd, {}, ui, cli);
NULL_PROJECT.isEmberCLIProject = function() {
return false;
};
NULL_PROJECT.isEmberCLIAddon = function() {
return false;
};
NULL_PROJECT.name = function() {
return path.basename(process.cwd());
};
NULL_PROJECT.initializeAddons();
return NULL_PROJECT;
}...
if (!commandOptions.directory) {
commandOptions.directory = packageName;
}
var createAndStepIntoDirectory = new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui });
var initCommand = new init_1.default({
ui: this.ui,
tasks: this.tasks,
project: Project.nullProject(this.ui, this.cli)
});
return createAndStepIntoDirectory
.run({
directoryName: commandOptions.directory,
dryRun: commandOptions.dryRun
})
.then(initCommand.run.bind(initCommand, commandOptions, rawArgs));
...projectOrnullProject = function (_ui, _cli) {
try {
return Project.closestSync(process.cwd(), _ui, _cli);
} catch (reason) {
if (reason instanceof Project.NotFoundError) {
return Project.nullProject(_ui, _cli);
} else {
throw reason;
}
}
}n/a
addonBlueprintLookupPaths = function () {
var addonPaths = this.addons.map(function(addon) {
if (addon.blueprintsPath) {
return addon.blueprintsPath();
}
}, this);
return addonPaths.filter(Boolean).reverse();
}n/a
addonCommands = function () {
var commands = {};
this.addons.forEach(function(addon) {
var includedCommands = (addon.includedCommands && addon.includedCommands()) || {};
var addonCommands = {};
for (var key in includedCommands) {
if (typeof includedCommands[key] === 'function') {
addonCommands[key] = includedCommands[key];
} else {
addonCommands[key] = Command.extend(includedCommands[key]);
}
}
if (Object.keys(addonCommands).length) {
commands[addon.name] = addonCommands;
}
});
return commands;
}n/a
blueprintLookupPaths = function () {
if (this.isEmberCLIProject()) {
var lookupPaths = [this.localBlueprintLookupPath()];
var addonLookupPaths = this.addonBlueprintLookupPaths();
return lookupPaths.concat(addonLookupPaths);
} else {
return this.addonBlueprintLookupPaths();
}
}n/a
config = function (env) {
var configPath = this.configPath();
if (existsSync(path.join(this.root, configPath + '.js'))) {
var appConfig = this.require('./' + configPath)(env);
var addonsConfig = this.getAddonsConfig(env, appConfig);
return merge(addonsConfig, appConfig);
} else {
return this.getAddonsConfig(env, {});
}
}n/a
configPath = function () {
var configPath = 'config';
if (this.pkg['ember-addon'] && this.pkg['ember-addon']['configPath']) {
configPath = this.pkg['ember-addon']['configPath'];
}
return path.join(configPath, 'environment');
}n/a
dependencies = function (pkg, excludeDevDeps) {
pkg = pkg || this.pkg || {};
var devDependencies = pkg['devDependencies'];
if (excludeDevDeps) {
devDependencies = {};
}
return assign({}, devDependencies, pkg['dependencies']);
}n/a
eachAddonCommand = function (callback) {
if (this.initializeAddons && this.addonCommands) {
this.initializeAddons();
var addonCommands = this.addonCommands();
forOwn(addonCommands, function(commands, addonName) {
return callback(addonName, commands);
});
}
}n/a
findAddonByName = function (name) {
this.initializeAddons();
var exactMatch = find(this.addons, function(addon) {
return name === addon.name || (addon.pkg && name === addon.pkg.name);
});
if (exactMatch) {
return exactMatch;
}
return find(this.addons, function(addon) {
return name.indexOf(addon.name) > -1 || (addon.pkg && name.indexOf(addon.pkg.name) > -1);
});
}n/a
generateTestFile = function () {
var message = 'Please install an Ember.js test framework addon or update your dependencies.';
if (this.ui) {
this.ui.writeDeprecateLine(message)
} else {
console.warn(message);
}
return '';
}n/a
getAddonsConfig = function (env, appConfig) {
this.initializeAddons();
var initialConfig = merge({}, appConfig);
return this.addons.reduce(function(config, addon) {
if (addon.config) {
merge(config, addon.config(env, config));
}
return config;
}, initialConfig);
}n/a
has = function (file) {
return existsSync(path.join(this.root, file)) || existsSync(path.join(this.root, file + '.js'));
}n/a
hasDependencies = function () {
return !!this.nodeModulesPath;
}n/a
initializeAddons = function () {
if (this._addonsInitialized) {
return;
}
this._addonsInitialized = true;
debug('initializeAddons for: %s', this.name());
const cliPkg = require(path.resolve(__dirname, '../../../package.json'));
const Addon = require('../models/addon');
const Constructor = Addon.lookup({
name: 'angular-cli',
path: path.join(__dirname, '../../../'),
pkg: cliPkg,
});
const addon = new Constructor(this.addonParent, this);
this.addons = [addon];
}n/a
isEmberCLIAddon = function () {
return !!this.pkg.keywords && this.pkg.keywords.indexOf('ember-addon') > -1;
}n/a
isEmberCLIProject = function () {
return (this.cli ? this.cli.npmPackage : 'ember-cli') in this.dependencies();
}n/a
localBlueprintLookupPath = function () {
return path.join(this.root, 'blueprints');
}n/a
name = function () {
return getPackageBaseName(this.pkg.name);
}...
if (commandOptions.linkCli) {
linkCli = new link_cli_1.default({
ui: this.ui,
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 = {
...reloadAddons = function () {
this.reloadPkg();
this._addonsInitialized = false;
return this.initializeAddons();
}n/a
reloadPkg = function () {
var pkgPath = path.join(this.root, 'package.json');
// We use readFileSync instead of require to avoid the require cache.
this.pkg = JSON.parse(fs.readFileSync(pkgPath, { encoding: 'utf-8' }));
return this.pkg;
}n/a
require = function (file) {
if (/^\.\//.test(file)) { // Starts with ./
return require(path.join(this.root, file));
} else {
return require(path.join(this.nodeModulesPath, file));
}
}n/a
resolve = function (file) {
return resolve(file, {
basedir: this.root
});
}...
let profiler = null;
if (process.env['NG_CLI_PROFILING']) {
profiler = require('v8-profiler');
profiler.startProfiling();
function exitHandler(options, err) {
if (options.cleanup) {
const cpuProfile = profiler.stopProfiling();
fs.writeFileSync(path.resolve(process.cwd(), process.env.NG_CLI_PROFILING) + '
;.cpuprofile',
JSON.stringify(cpuProfile));
}
if (options.exit) {
process.exit();
}
}
...resolveSync = function (file) {
return resolve.sync(file, {
basedir: this.root
});
}n/a
setupNodeModulesPath = function () {
this.nodeModulesPath = nodeModulesPath(this.root);
debug('nodeModulesPath: %s', this.nodeModulesPath);
}n/a
supportedInternalAddonPaths = function () {
if (!this.root) { return []; }
var internalMiddlewarePath = path.join(__dirname, '../tasks/server/middleware');
return [
path.join(internalMiddlewarePath, 'tests-server'),
path.join(internalMiddlewarePath, 'history-support'),
path.join(internalMiddlewarePath, 'serve-files'),
path.join(internalMiddlewarePath, 'proxy-server')
];
}n/a
function PromiseExt(resolver, label) {
this._superConstructor(resolver, label);
}n/a
denodeify = function () {
var fn = RSVP.denodeify.apply(null, arguments);
var Constructor = this;
var newFn = function() {
return Constructor.resolve(fn.apply(null, arguments));
};
newFn.__proto__ = arguments[0];
return newFn;
}n/a
filter = function () {
return this.resolve(RSVP.filter.apply(null, arguments));
}...
if (!rawArgs[1]) {
SilentError.debugOrThrow('angular-cli/commands/generate', "The `ng generate " + rawArgs[0] + "` command
requires a name to be specified.");
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
...hash = function () {
return this.resolve(RSVP.hash.apply(null, arguments));
}n/a
map = function () {
return this.resolve(RSVP.map.apply(null, arguments));
}...
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..'
;, 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
...function Promise$1(resolver, label) {
this._id = counter++;
this._label = label;
this._state = undefined;
this._result = undefined;
this._subscribers = [];
config.instrument && instrument$1('created', this);
if (noop !== resolver) {
typeof resolver !== 'function' && needsResolver();
this instanceof Promise$1 ? initializePromise(this, resolver) : needsNew();
}
}n/a
function PromiseExt(resolver, label) {
this._superConstructor(resolver, label);
}n/a
filter = function (filterFn) {
return constructorMethod(this, 'filter', filterFn);
}...
if (!rawArgs[1]) {
SilentError.debugOrThrow('angular-cli/commands/generate', "The `ng generate " + rawArgs[0] + "` command
requires a name to be specified.");
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
...invoke = function (method) {
var args = Array.prototype.slice(arguments, 1);
return this.then(function(value) {
return value[method].apply(value, args);
}, undefined, 'invoke: ' + method + ' with: ' + args);
}n/a
map = function (mapFn) {
return constructorMethod(this, 'map', mapFn);
}...
}
// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function () {
var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..'
;, 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
...returns = function (value) {
return this.then(function() {
return value;
});
}n/a
function requireDependency(root, moduleName) {
var packageJson = require(path.join(root, 'node_modules', moduleName, 'package.json'));
var main = path.normalize(packageJson.main);
return require(path.join(root, 'node_modules', moduleName, main));
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function serveRun(commandOptions) {
var _this = this;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;
return checkExpressPort(commandOptions)
.then(function () { return autoFindLiveReloadPort(commandOptions); })
.then(function (opts) {
var serve = new serve_1.default({
ui: _this.ui,
project: _this.project,
});
return serve.run(opts);
});
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function getStylesConfig(wco) {
var projectRoot = wco.projectRoot, buildOptions = wco.buildOptions, appConfig = wco.appConfig;
var appRoot = path.resolve(projectRoot, appConfig.root);
var entryPoints = {};
var globalStylePaths = [];
var extraPlugins = [];
// style-loader does not support sourcemaps without absolute publicPath, so it's
// better to disable them when not extracting css
// https://github.com/webpack-contrib/style-loader#recommended-configuration
var cssSourceMap = buildOptions.extractCss && buildOptions.sourcemap;
// minify/optimize css in production
// autoprefixer is always run separately so disable here
var extraPostCssPlugins = buildOptions.target === 'production'
? [cssnano({ safe: true, autoprefixer: false })]
: [];
// determine hashing format
var hashFormat = utils_1.getOutputHashFormat(buildOptions.outputHashing);
// use includePaths from appConfig
var includePaths = [];
if (appConfig.stylePreprocessorOptions
&& appConfig.stylePreprocessorOptions.includePaths
&& appConfig.stylePreprocessorOptions.includePaths.length > 0) {
appConfig.stylePreprocessorOptions.includePaths.forEach(function (includePath) {
return includePaths.push(path.resolve(appRoot, includePath));
});
}
// process global styles
if (appConfig.styles.length > 0) {
var globalStyles = utils_1.extraEntryParser(appConfig.styles, appRoot, 'styles');
// add style entry points
globalStyles.forEach(function (style) {
return entryPoints[style.entry]
? entryPoints[style.entry].push(style.path)
: entryPoints[style.entry] = [style.path];
});
// add global css paths
globalStylePaths.push.apply(globalStylePaths, globalStyles.map(function (style) { return style.path; }));
}
// set base rules to derive final rules from
var baseRules = [
{ test: /\.css$/, loaders: [] },
{ test: /\.scss$|\.sass$/, loaders: ['sass-loader'] },
{ test: /\.less$/, loaders: ['less-loader'] },
// stylus-loader doesn't support webpack.LoaderOptionsPlugin properly,
// so we need to add options in its query
{
test: /\.styl$/, loaders: [("stylus-loader?" + JSON.stringify({
sourceMap: cssSourceMap,
paths: includePaths
}))]
}
];
var commonLoaders = ['postcss-loader'];
// load component css as raw strings
var rules = baseRules.map(function (_a) {
var test = _a.test, loaders = _a.loaders;
return ({
exclude: globalStylePaths, test: test, loaders: ['raw-loader'].concat(commonLoaders, loaders)
});
});
// load global css as css files
if (globalStylePaths.length > 0) {
rules.push.apply(rules, baseRules.map(function (_a) {
var test = _a.test, loaders = _a.loaders;
return ({
include: globalStylePaths, test: test, loaders: ExtractTextPlugin.extract({
loader: [
// css-loader doesn't support webpack.LoaderOptionsPlugin properly,
// so we need to add options in its query
("css-loader?" + JSON.stringify({ sourceMap: cssSourceMap }))
].concat(commonLoaders, loaders),
fallbackLoader: 'style-loader',
// publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
publicPath: ''
})
});
}));
}
// supress empty .js files in css only entry points
if (buildOptions.extractCss) {
extraPlugins.push(new suppress_entry_chunks_webpack_plugin_1.SuppressExtractedTextChunksWebpackPlugin());
}
return {
entry: entryPoints,
module: { rules: rules },
plugins: [
// extract global css from js files into own css file
new ExtractTextPlugin({ ......
var appConfig = config_1.CliConfig.fromProject().config.apps[0];
appConfig = this.addAppConfigDefaults(appConfig);
buildOptions = this.addTargetDefaults(buildOptions);
buildOptions = this.mergeConfigs(buildOptions, appConfig);
var wco = { projectRoot: projectRoot, buildOptions: buildOptions, appConfig: appConfig };
var webpackConfigs = [
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getStylesConfig(wco),
this.getTargetConfig(wco)
];
if (appConfig.main || appConfig.polyfills) {
var typescriptConfigPartial = buildOptions.aot
? webpack_configs_1.getAotConfig(wco)
: webpack_configs_1.getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial);
...function SuppressExtractedTextChunksWebpackPlugin() {
}n/a
function Task() {
CoreObject.apply(this, arguments);
}n/a
run = function () {
throw new Error('Task needs to have run() defined.');
}...
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
//# sourceMappingURL=/Users/hans/Sources/angular-cli/packages/angular-cli/commands/build.run.js.map
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
}
if (!validProjectName(packageName)) {
return Promise.reject(new SilentError("We currently do not support a name of \"" + packageName + "\"
;."));
}
if (!commandOptions.directory) {
commandOptions.directory = packageName;
}
var createAndStepIntoDirectory = new this.tasks.CreateAndStepIntoDirectory({ ui: this
.ui });
var initCommand = new init_1.default({
ui: this.ui,
tasks: this.tasks,
project: Project.nullProject(this.ui, this.cli)
});
return createAndStepIntoDirectory
.run({
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
var normalizeBlueprint = require('../ember-cli/lib/utilities/normalize-blueprint-option');
var GitInit = require('../tasks/git-init');
function initRun(commandOptions, rawArgs) {
var _this = this;
if (commandOptions.dryRun) {
commandOptions.skipNpm = true;
}
var installBlueprint = new this.tasks.InstallBlueprint({
ui: this.ui,
project: this.project
});
// needs an explicit check in case it's just 'undefined'
// due to passing of options from 'new' and 'addon'
var gitInit;
if (commandOptions.skipGit === false) {
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
getAotConfig = function (wco) {
var projectRoot = wco.projectRoot, buildOptions = wco.buildOptions, appConfig = wco.appConfig;
var exclude = ['**/*.spec.ts'];
if (appConfig.test) {
exclude.push(path.join(projectRoot, appConfig.root, appConfig.test));
}
;
return {
module: {
rules: [
{
test: /\.ts$/,
loader: webpackLoader,
exclude: [/\.(spec|e2e)\.ts$/]
}
]
},
plugins: [
new webpack_1.AotPlugin({
tsConfigPath: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig),
mainPath: path.join(projectRoot, appConfig.root, appConfig.main),
i18nFile: buildOptions.i18nFile,
i18nFormat: buildOptions.i18nFormat,
locale: buildOptions.locale,
exclude: exclude
})
]
};
}...
var webpackConfigs = [
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getStylesConfig(wco),
this.getTargetConfig(wco)
];
if (appConfig.main || appConfig.polyfills) {
var typescriptConfigPartial = buildOptions.aot
? webpack_configs_1.getAotConfig(wco)
: webpack_configs_1.getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial);
}
// add style config
this.config = webpackMerge(webpackConfigs);
}
NgCliWebpackConfig.prototype.getTargetConfig = function (webpackConfigOptions) {
...getNonAotConfig = function (wco) {
var projectRoot = wco.projectRoot, appConfig = wco.appConfig;
var exclude = ['**/*.spec.ts'];
if (appConfig.test) {
exclude.push(path.join(projectRoot, appConfig.root, appConfig.test));
}
;
return {
module: {
rules: [
{
test: /\.ts$/,
loader: webpackLoader,
exclude: [/\.(spec|e2e)\.ts$/]
}
]
},
plugins: [
new webpack_1.AotPlugin({
tsConfigPath: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig),
mainPath: path.join(projectRoot, appConfig.root, appConfig.main),
exclude: exclude,
skipCodeGeneration: true
}),
]
};
}...
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getStylesConfig(wco),
this.getTargetConfig(wco)
];
if (appConfig.main || appConfig.polyfills) {
var typescriptConfigPartial = buildOptions.aot
? webpack_configs_1.getAotConfig(wco)
: webpack_configs_1.getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial);
}
// add style config
this.config = webpackMerge(webpackConfigs);
}
NgCliWebpackConfig.prototype.getTargetConfig = function (webpackConfigOptions) {
switch (webpackConfigOptions.buildOptions.target) {
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
printBasicHelp = function () {
return chalk.red('No help entry for \'' + this.name + '\'');
}...
var blueprints = blueprintList
.filter(function (bp) { return bp.indexOf('-test') === -1; })
.filter(function (bp) { return bp !== 'ng2'; })
.map(function (bp) { return Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)); });
var output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
};
return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
}
});
...validateAndRun = function () {
throw new SilentError('The specified command ' + this.name +
' is invalid. For available options, see' +
' `ng help`.');
}n/a
function extraEntryParser(extraEntries, appRoot, defaultEntry) {
return extraEntries
.map(function (extraEntry) {
return typeof extraEntry === 'string' ? { input: extraEntry } : extraEntry;
})
.map(function (extraEntry) {
extraEntry.path = path.resolve(appRoot, extraEntry.input);
if (extraEntry.output) {
extraEntry.entry = extraEntry.output.replace(/\.(js|css)$/i, '');
}
else if (extraEntry.lazy) {
extraEntry.entry = extraEntry.input.replace(/\.(js|css|scss|sass|less|styl)$/i, '');
}
else {
extraEntry.entry = defaultEntry;
}
return extraEntry;
});
}n/a
function getOutputHashFormat(option, length) {
if (length === void 0) { length = 20; }
/* tslint:disable:max-line-length */
var hashFormats = {
none: { chunk: '', extract: '', file: '' },
media: { chunk: '', extract: '', file: ".[hash:" + length + "]" },
bundles: { chunk: ".[chunkhash:" + length + "]", extract: ".[contenthash:" + length + "]", file: '' },
all: { chunk: ".[chunkhash:" + length + "]", extract: ".[contenthash:" + length + "]", file: ".[hash:" + length + "]" },
};
/* tslint:enable:max-line-length */
return hashFormats[option] || hashFormats['none'];
}n/a
function getWebpackStatsConfig(verbose) {
if (verbose === void 0) { verbose = false; }
return verbose
? Object.assign(webpackOutputOptions, verboseWebpackOutputOptions)
: webpackOutputOptions;
}...
run: function (runTaskOptions) {
var _this = this;
var project = this.cliProject;
var outputPath = runTaskOptions.outputPath || config_1.CliConfig.fromProject().config.apps[0].outDir;
rimraf.sync(path.resolve(project.root, outputPath));
var webpackConfig = new webpack_config_1.NgCliWebpackConfig(runTaskOptions).config;
var webpackCompiler = webpack(webpackConfig);
var statsConfig = utils_1.getWebpackStatsConfig(runTaskOptions.verbose);
return new Promise(function (resolve, reject) {
var callback = function (err, stats) {
if (err) {
return reject(err);
}
_this.ui.writeLine(stats.toString(statsConfig));
if (runTaskOptions.watch) {
...function lazyChunksFilter(extraEntries) {
return extraEntries
.filter(function (extraEntry) { return extraEntry.lazy; })
.map(function (extraEntry) { return extraEntry.entry; });
}n/a
ngAppResolve = function (resolvePath) {
return path.resolve(process.cwd(), resolvePath);
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}...
"use strict";
var version_1 = require('../upgrade/version');
var build_1 = require('../tasks/build');
function buildRun(commandOptions) {
var project = this.project;
// Check angular version.
version_1.Version.assertAngularVersionIs2_3_1OrHigher(project.root);
var buildTask = new build_1.default({
cliProject: project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = buildRun;
...function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
detectWatcher = function (ui, _options) {
var options = _options || {};
var watchmanInfo = 'Visit http://ember-cli.com/user-guide/#watchman for more info.';
if (options.watcher === 'polling') {
debug('skip detecting watchman, poll instead');
return Promise.resolve(options);
} else if (options.watcher === 'node') {
debug('skip detecting watchman, node instead');
return Promise.resolve(options);
} else if (isWin) {
debug('watchman isn\'t supported on windows, node instead');
options.watcher = 'node';
return Promise.resolve(options);
} else {
debug('detecting watchman');
return exec('watchman version').then(function(output) {
var version;
try {
version = JSON.parse(output).version;
} catch (e) {
options.watcher = 'node';
ui.writeLine('Looks like you have a different program called watchman, falling back to NodeWatcher.');
ui.writeLine(watchmanInfo);
return options;
}
debug('detected watchman: %s', version);
var semver = require('semver');
if (semver.satisfies(version, '>= 3.0.0')) {
debug('watchman %s does satisfy: %s', version, '>= 3.0.0');
options.watcher = 'watchman';
options._watchmanInfo = {
enabled: true,
version: version,
canNestRoots: semver.satisfies(version, '>= 3.7.0')
};
} else {
debug('watchman %s does NOT satisfy: %s', version, '>= 3.0.0');
ui.writeLine('Invalid watchman found, version: [' + version + '] did not satisfy [>= 3.0.0], falling back to NodeWatcher
.');
ui.writeLine(watchmanInfo);
options.watcher = 'node';
}
return options;
}, function(reason) {
debug('detecting watchman failed %o', reason);
ui.writeLine('Could not start watchman; falling back to NodeWatcher for file system events.');
ui.writeLine(watchmanInfo);
options.watcher = 'node';
return options;
});
}
}n/a
buildOptions = function () {
var watcher = this.options && this.options.watcher;
if (watcher && ['polling', 'watchman', 'node', 'events'].indexOf(watcher) === -1) {
throw new Error('Unknown watcher type --watcher=[polling|watchman|node] but was: ' + watcher);
}
return {
verbose: this.verbose,
poll: watcher === 'polling',
watchman: watcher === 'watchman' || watcher === 'events',
node: watcher === 'node'
};
}n/a
function Class() {
constructor.apply(this, arguments);
if (this.init) {
this.init(options);
}
}n/a
didChange = function (results) {
debug('didChange %o', results);
var totalTime = results.totalTime / 1e6;
this.ui.writeLine('');
this.ui.writeLine(chalk.green('Build successful - ' + Math.round(totalTime) + 'ms.'));
}n/a
didError = function (error) {
debug('didError %o', error);
this.ui.writeError(error);
}n/a
init = function () {
var options = this.buildOptions();
debug('initialize %o', options);
}n/a
off = function () {
// this.watcher.off.apply(this.watcher, arguments);
}n/a
on = function () {
// this.watcher.on.apply(this.watcher, arguments);
}...
}
if (options.exit) {
process.exit();
}
}
process.on('exit', exitHandler.bind(null, { cleanup: true }));
process.on('SIGINT', exitHandler.bind(null, { exit: true }));
process.on('uncaughtException', exitHandler.bind(null, { exit: true }));
}
// Show the warnings due to package and version deprecation.
const version = new SemVer(process.version);
...then = function () {
// return this.watcher.then.apply(this.watcher, arguments);
}...
cli = cli['default'];
}
cli({
cliArgs: process.argv.slice(2),
inputStream: process.stdin,
outputStream: process.stdout
}).then(function (result) {
process.exit(typeof result === 'object' ? result.exitCode : result);
});
});
...function NgCliWebpackConfig(buildOptions) {
this.validateBuildOptions(buildOptions);
var configPath = config_1.CliConfig.configFilePath();
var projectRoot = path.dirname(configPath);
var appConfig = config_1.CliConfig.fromProject().config.apps[0];
appConfig = this.addAppConfigDefaults(appConfig);
buildOptions = this.addTargetDefaults(buildOptions);
buildOptions = this.mergeConfigs(buildOptions, appConfig);
var wco = { projectRoot: projectRoot, buildOptions: buildOptions, appConfig: appConfig };
var webpackConfigs = [
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getStylesConfig(wco),
this.getTargetConfig(wco)
];
if (appConfig.main || appConfig.polyfills) {
var typescriptConfigPartial = buildOptions.aot
? webpack_configs_1.getAotConfig(wco)
: webpack_configs_1.getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial);
}
// add style config
this.config = webpackMerge(webpackConfigs);
}...
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Task.extend({
run: function (runTaskOptions) {
var _this = this;
var project = this.cliProject;
var outputPath = runTaskOptions.outputPath || config_1.CliConfig.fromProject().config.apps[0].outDir;
rimraf.sync(path.resolve(project.root, outputPath));
var webpackConfig = new webpack_config_1.NgCliWebpackConfig(runTaskOptions).config
;
var webpackCompiler = webpack(webpackConfig);
var statsConfig = utils_1.getWebpackStatsConfig(runTaskOptions.verbose);
return new Promise(function (resolve, reject) {
var callback = function (err, stats) {
if (err) {
return reject(err);
}
...