refactor: move all CLI-specific exceptions to different options (#7981)

We made too many shortcuts for passing data in and custom schematics could not
work properly.

This is temporary as we will likely move some more logic into schematics tooling
to be able to pass only the raw args and the CLI config, but for now this is
enough to unblock AngularMix.
This commit is contained in:
Hans 2017-10-09 22:28:29 -07:00 committed by GitHub
parent eed13cf21d
commit ae47b46563
11 changed files with 855 additions and 73 deletions

822
package-lock.json generated
View File

@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"@angular-devkit/build-optimizer": {
"version": "0.0.23",
"resolved": "https://registry.npmjs.org/@angular-devkit/build-optimizer/-/build-optimizer-0.0.23.tgz",
"integrity": "sha512-X71T0kRjjGJDhcAxmQUulxyuM4tNtxVqt8OWLmeuxjdKPVv7A1WC+ZmPl1rNxsCFcc/8+oBsmMyYmlF9UN1AGQ==",
"version": "0.0.26",
"resolved": "https://registry.npmjs.org/@angular-devkit/build-optimizer/-/build-optimizer-0.0.26.tgz",
"integrity": "sha512-q2HZdEZeX21sTpP5yM2PeEUTGbr6+Q10/X7yDg3CFgZ2P5NKZv6TZ8Lt3apk/wB+SOgjSjNFdn+1RHpZsAY6xw==",
"requires": {
"loader-utils": "1.1.0",
"source-map": "0.5.7",
@ -16,22 +16,32 @@
}
},
"@angular-devkit/core": {
"version": "0.0.15",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-0.0.15.tgz",
"integrity": "sha512-B1neVy9IeljC1NdExJzuk2HUxaqcFDypmqwHFuQB0G4MtWp9yqAJneHcwGVaXd4CtqDnDd2D8LTme+upKtaeKQ==",
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-0.0.18.tgz",
"integrity": "sha512-KRrlTp0ravwuCDSjF97s1Lh8ec6wq9Q7I6MN9x5f/bycYcwnsbDe8a4CsJv+jTizqUqxgCOds2MRJgc7FoLMwg==",
"requires": {
"source-map": "0.5.7"
}
},
"@angular-devkit/schematics": {
"version": "0.0.25",
"resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-0.0.25.tgz",
"integrity": "sha512-bP5UKdXLfIzOFdYKi1kiUMIpze6+EnPuupU9l3AHHCBFInA/Sj4744opw4XH8p7qcjDDgX28XB290Jo9lz6mqg==",
"version": "0.0.31",
"resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-0.0.31.tgz",
"integrity": "sha512-ecGJFl7Fu1rPexkklaeft4hgyBR0pAI15FuBfhJvIuJGFHyqXHzqz28TucDHUrgYVt8TU0mpmqhFDX7HzDd93g==",
"requires": {
"@angular-devkit/core": "0.0.15",
"@angular-devkit/core": "0.0.18",
"@ngtools/json-schema": "1.1.0",
"minimist": "1.2.0",
"rxjs": "5.4.3"
},
"dependencies": {
"@angular-devkit/core": {
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-0.0.18.tgz",
"integrity": "sha512-KRrlTp0ravwuCDSjF97s1Lh8ec6wq9Q7I6MN9x5f/bycYcwnsbDe8a4CsJv+jTizqUqxgCOds2MRJgc7FoLMwg==",
"requires": {
"source-map": "0.5.7"
}
}
}
},
"@angular/compiler": {
@ -78,9 +88,9 @@
"integrity": "sha1-w6DFRNYjkqzCgTpCyKDcb1j4aSI="
},
"@schematics/angular": {
"version": "0.0.38",
"resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-0.0.38.tgz",
"integrity": "sha512-S2xKTcAIcZniVaFJnbcnVMJELw2HkYaRYiPPuL6/BKfjYnjHwUHOEVWu2IV9pHcyEcl1DpEqjnnqo48oPqUUcA=="
"version": "0.0.42",
"resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-0.0.42.tgz",
"integrity": "sha512-tvT9RHxsZdIQX/2iZ+Pt1WdcMfKfSbDr0mDbvuL0CR7iqRx0FDjAkMXOkQAucchdXa+u2ZXgIXz6cN60RWjWvQ=="
},
"@types/chalk": {
"version": "0.4.31",
@ -997,6 +1007,7 @@
"requires": {
"anymatch": "1.3.2",
"async-each": "1.0.1",
"fsevents": "1.1.2",
"glob-parent": "2.0.0",
"inherits": "2.0.3",
"is-binary-path": "1.0.1",
@ -2943,6 +2954,791 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz",
"integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==",
"optional": true,
"requires": {
"nan": "2.7.0",
"node-pre-gyp": "0.6.36"
},
"dependencies": {
"abbrev": {
"version": "1.1.0",
"bundled": true,
"optional": true
},
"ajv": {
"version": "4.11.8",
"bundled": true,
"optional": true,
"requires": {
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
}
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true
},
"aproba": {
"version": "1.1.1",
"bundled": true,
"optional": true
},
"are-we-there-yet": {
"version": "1.1.4",
"bundled": true,
"optional": true,
"requires": {
"delegates": "1.0.0",
"readable-stream": "2.2.9"
}
},
"asn1": {
"version": "0.2.3",
"bundled": true,
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"bundled": true,
"optional": true
},
"asynckit": {
"version": "0.4.0",
"bundled": true,
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"bundled": true,
"optional": true
},
"aws4": {
"version": "1.6.0",
"bundled": true,
"optional": true
},
"balanced-match": {
"version": "0.4.2",
"bundled": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"bundled": true,
"optional": true,
"requires": {
"tweetnacl": "0.14.5"
}
},
"block-stream": {
"version": "0.0.9",
"bundled": true,
"requires": {
"inherits": "2.0.3"
}
},
"boom": {
"version": "2.10.1",
"bundled": true,
"requires": {
"hoek": "2.16.3"
}
},
"brace-expansion": {
"version": "1.1.7",
"bundled": true,
"requires": {
"balanced-match": "0.4.2",
"concat-map": "0.0.1"
}
},
"buffer-shims": {
"version": "1.0.0",
"bundled": true
},
"caseless": {
"version": "0.12.0",
"bundled": true,
"optional": true
},
"co": {
"version": "4.6.0",
"bundled": true,
"optional": true
},
"code-point-at": {
"version": "1.1.0",
"bundled": true
},
"combined-stream": {
"version": "1.0.5",
"bundled": true,
"requires": {
"delayed-stream": "1.0.0"
}
},
"concat-map": {
"version": "0.0.1",
"bundled": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true
},
"cryptiles": {
"version": "2.0.5",
"bundled": true,
"optional": true,
"requires": {
"boom": "2.10.1"
}
},
"dashdash": {
"version": "1.14.1",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"debug": {
"version": "2.6.8",
"bundled": true,
"optional": true,
"requires": {
"ms": "2.0.0"
}
},
"deep-extend": {
"version": "0.4.2",
"bundled": true,
"optional": true
},
"delayed-stream": {
"version": "1.0.0",
"bundled": true
},
"delegates": {
"version": "1.0.0",
"bundled": true,
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"bundled": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"extend": {
"version": "3.0.1",
"bundled": true,
"optional": true
},
"extsprintf": {
"version": "1.0.2",
"bundled": true
},
"forever-agent": {
"version": "0.6.1",
"bundled": true,
"optional": true
},
"form-data": {
"version": "2.1.4",
"bundled": true,
"optional": true,
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.5",
"mime-types": "2.1.15"
}
},
"fs.realpath": {
"version": "1.0.0",
"bundled": true
},
"fstream": {
"version": "1.0.11",
"bundled": true,
"requires": {
"graceful-fs": "4.1.11",
"inherits": "2.0.3",
"mkdirp": "0.5.1",
"rimraf": "2.6.1"
}
},
"fstream-ignore": {
"version": "1.0.5",
"bundled": true,
"optional": true,
"requires": {
"fstream": "1.0.11",
"inherits": "2.0.3",
"minimatch": "3.0.4"
}
},
"gauge": {
"version": "2.7.4",
"bundled": true,
"optional": true,
"requires": {
"aproba": "1.1.1",
"console-control-strings": "1.1.0",
"has-unicode": "2.0.1",
"object-assign": "4.1.1",
"signal-exit": "3.0.2",
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wide-align": "1.1.2"
}
},
"getpass": {
"version": "0.1.7",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"glob": {
"version": "7.1.2",
"bundled": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"graceful-fs": {
"version": "4.1.11",
"bundled": true
},
"har-schema": {
"version": "1.0.5",
"bundled": true,
"optional": true
},
"har-validator": {
"version": "4.2.1",
"bundled": true,
"optional": true,
"requires": {
"ajv": "4.11.8",
"har-schema": "1.0.5"
}
},
"has-unicode": {
"version": "2.0.1",
"bundled": true,
"optional": true
},
"hawk": {
"version": "3.1.3",
"bundled": true,
"optional": true,
"requires": {
"boom": "2.10.1",
"cryptiles": "2.0.5",
"hoek": "2.16.3",
"sntp": "1.0.9"
}
},
"hoek": {
"version": "2.16.3",
"bundled": true
},
"http-signature": {
"version": "1.1.1",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "0.2.0",
"jsprim": "1.4.0",
"sshpk": "1.13.0"
}
},
"inflight": {
"version": "1.0.6",
"bundled": true,
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
}
},
"inherits": {
"version": "2.0.3",
"bundled": true
},
"ini": {
"version": "1.3.4",
"bundled": true,
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"requires": {
"number-is-nan": "1.0.1"
}
},
"is-typedarray": {
"version": "1.0.0",
"bundled": true,
"optional": true
},
"isarray": {
"version": "1.0.0",
"bundled": true
},
"isstream": {
"version": "0.1.2",
"bundled": true,
"optional": true
},
"jodid25519": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"jsbn": {
"version": "0.1.1",
"bundled": true,
"optional": true
},
"json-schema": {
"version": "0.2.3",
"bundled": true,
"optional": true
},
"json-stable-stringify": {
"version": "1.0.1",
"bundled": true,
"optional": true,
"requires": {
"jsonify": "0.0.0"
}
},
"json-stringify-safe": {
"version": "5.0.1",
"bundled": true,
"optional": true
},
"jsonify": {
"version": "0.0.0",
"bundled": true,
"optional": true
},
"jsprim": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.0.2",
"json-schema": "0.2.3",
"verror": "1.3.6"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"mime-db": {
"version": "1.27.0",
"bundled": true
},
"mime-types": {
"version": "2.1.15",
"bundled": true,
"requires": {
"mime-db": "1.27.0"
}
},
"minimatch": {
"version": "3.0.4",
"bundled": true,
"requires": {
"brace-expansion": "1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true
},
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"bundled": true,
"optional": true
},
"node-pre-gyp": {
"version": "0.6.36",
"bundled": true,
"optional": true,
"requires": {
"mkdirp": "0.5.1",
"nopt": "4.0.1",
"npmlog": "4.1.0",
"rc": "1.2.1",
"request": "2.81.0",
"rimraf": "2.6.1",
"semver": "5.3.0",
"tar": "2.2.1",
"tar-pack": "3.4.0"
}
},
"nopt": {
"version": "4.0.1",
"bundled": true,
"optional": true,
"requires": {
"abbrev": "1.1.0",
"osenv": "0.1.4"
}
},
"npmlog": {
"version": "4.1.0",
"bundled": true,
"optional": true,
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
"gauge": "2.7.4",
"set-blocking": "2.0.0"
}
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true
},
"oauth-sign": {
"version": "0.8.2",
"bundled": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
"bundled": true,
"optional": true
},
"once": {
"version": "1.4.0",
"bundled": true,
"requires": {
"wrappy": "1.0.2"
}
},
"os-homedir": {
"version": "1.0.2",
"bundled": true,
"optional": true
},
"os-tmpdir": {
"version": "1.0.2",
"bundled": true,
"optional": true
},
"osenv": {
"version": "0.1.4",
"bundled": true,
"optional": true,
"requires": {
"os-homedir": "1.0.2",
"os-tmpdir": "1.0.2"
}
},
"path-is-absolute": {
"version": "1.0.1",
"bundled": true
},
"performance-now": {
"version": "0.2.0",
"bundled": true,
"optional": true
},
"process-nextick-args": {
"version": "1.0.7",
"bundled": true
},
"punycode": {
"version": "1.4.1",
"bundled": true,
"optional": true
},
"qs": {
"version": "6.4.0",
"bundled": true,
"optional": true
},
"rc": {
"version": "1.2.1",
"bundled": true,
"optional": true,
"requires": {
"deep-extend": "0.4.2",
"ini": "1.3.4",
"minimist": "1.2.0",
"strip-json-comments": "2.0.1"
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"bundled": true,
"optional": true
}
}
},
"readable-stream": {
"version": "2.2.9",
"bundled": true,
"requires": {
"buffer-shims": "1.0.0",
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "1.0.7",
"string_decoder": "1.0.1",
"util-deprecate": "1.0.2"
}
},
"request": {
"version": "2.81.0",
"bundled": true,
"optional": true,
"requires": {
"aws-sign2": "0.6.0",
"aws4": "1.6.0",
"caseless": "0.12.0",
"combined-stream": "1.0.5",
"extend": "3.0.1",
"forever-agent": "0.6.1",
"form-data": "2.1.4",
"har-validator": "4.2.1",
"hawk": "3.1.3",
"http-signature": "1.1.1",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.15",
"oauth-sign": "0.8.2",
"performance-now": "0.2.0",
"qs": "6.4.0",
"safe-buffer": "5.0.1",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2",
"tunnel-agent": "0.6.0",
"uuid": "3.0.1"
}
},
"rimraf": {
"version": "2.6.1",
"bundled": true,
"requires": {
"glob": "7.1.2"
}
},
"safe-buffer": {
"version": "5.0.1",
"bundled": true
},
"semver": {
"version": "5.3.0",
"bundled": true,
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"bundled": true,
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"bundled": true,
"optional": true
},
"sntp": {
"version": "1.0.9",
"bundled": true,
"optional": true,
"requires": {
"hoek": "2.16.3"
}
},
"sshpk": {
"version": "1.13.0",
"bundled": true,
"optional": true,
"requires": {
"asn1": "0.2.3",
"assert-plus": "1.0.0",
"bcrypt-pbkdf": "1.0.1",
"dashdash": "1.14.1",
"ecc-jsbn": "0.1.1",
"getpass": "0.1.7",
"jodid25519": "1.0.2",
"jsbn": "0.1.1",
"tweetnacl": "0.14.5"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"string-width": {
"version": "1.0.2",
"bundled": true,
"requires": {
"code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0",
"strip-ansi": "3.0.1"
}
},
"string_decoder": {
"version": "1.0.1",
"bundled": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"stringstream": {
"version": "0.0.5",
"bundled": true,
"optional": true
},
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"requires": {
"ansi-regex": "2.1.1"
}
},
"strip-json-comments": {
"version": "2.0.1",
"bundled": true,
"optional": true
},
"tar": {
"version": "2.2.1",
"bundled": true,
"requires": {
"block-stream": "0.0.9",
"fstream": "1.0.11",
"inherits": "2.0.3"
}
},
"tar-pack": {
"version": "3.4.0",
"bundled": true,
"optional": true,
"requires": {
"debug": "2.6.8",
"fstream": "1.0.11",
"fstream-ignore": "1.0.5",
"once": "1.4.0",
"readable-stream": "2.2.9",
"rimraf": "2.6.1",
"tar": "2.2.1",
"uid-number": "0.0.6"
}
},
"tough-cookie": {
"version": "2.3.2",
"bundled": true,
"optional": true,
"requires": {
"punycode": "1.4.1"
}
},
"tunnel-agent": {
"version": "0.6.0",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"bundled": true,
"optional": true
},
"uid-number": {
"version": "0.0.6",
"bundled": true,
"optional": true
},
"util-deprecate": {
"version": "1.0.2",
"bundled": true
},
"uuid": {
"version": "3.0.1",
"bundled": true,
"optional": true
},
"verror": {
"version": "1.3.6",
"bundled": true,
"optional": true,
"requires": {
"extsprintf": "1.0.2"
}
},
"wide-align": {
"version": "1.1.2",
"bundled": true,
"optional": true,
"requires": {
"string-width": "1.0.2"
}
},
"wrappy": {
"version": "1.0.2",
"bundled": true
}
}
},
"fstream": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",

View File

@ -41,9 +41,10 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/build-optimizer": "~0.0.23",
"@angular-devkit/schematics": "~0.0.25",
"@schematics/angular": "~0.0.38",
"@angular-devkit/build-optimizer": "~0.0.26",
"@angular-devkit/core": "~0.0.18",
"@angular-devkit/schematics": "~0.0.31",
"@schematics/angular": "~0.0.42",
"autoprefixer": "^6.5.3",
"chalk": "^2.0.1",
"circular-dependency-plugin": "^3.0.0",

View File

@ -1,5 +1,4 @@
import { cyan, yellow } from 'chalk';
const stringUtils = require('ember-cli-string-utils');
import { oneLine } from 'common-tags';
import { CliConfig } from '../models/config';
@ -11,14 +10,11 @@ import {
} from '../utilities/schematics';
import { DynamicPathOptions, dynamicPathParser } from '../utilities/dynamic-path-parser';
import { getAppFromConfig } from '../utilities/app-utils';
import * as path from 'path';
import { SchematicAvailableOptions } from '../tasks/schematic-get-options';
const Command = require('../ember-cli/lib/models/command');
const SilentError = require('silent-error');
const separatorRegEx = /[\/\\]/g;
export default Command.extend({
name: 'generate',
@ -77,7 +73,7 @@ export default Command.extend({
beforeRun: function(rawArgs: string[]) {
const isHelp = ['--help', '-h'].includes(rawArgs[0]);
const isHelp = ['--help', '-h'].indexOf(rawArgs[0]) != -1;
if (isHelp) {
return;
}
@ -85,8 +81,7 @@ export default Command.extend({
const schematicName = rawArgs[0];
if (!schematicName) {
return Promise.reject(new SilentError(oneLine`
The "ng generate" command requires a
schematic name to be specified.
The "ng generate" command requires a schematic name to be specified.
For more details, use "ng help".
`));
}
@ -127,7 +122,6 @@ export default Command.extend({
}
const entityName = rawArgs[1];
commandOptions.name = stringUtils.dasherize(entityName.split(separatorRegEx).pop());
const appConfig = getAppFromConfig(commandOptions.app);
const dynamicPathOptions: DynamicPathOptions = {
@ -137,34 +131,16 @@ export default Command.extend({
dryRun: commandOptions.dryRun
};
const parsedPath = dynamicPathParser(dynamicPathOptions);
commandOptions.sourceDir = appConfig.root;
const root = appConfig.root + path.sep;
commandOptions.appRoot = parsedPath.appRoot === appConfig.root ? '' :
parsedPath.appRoot.startsWith(root)
? parsedPath.appRoot.substr(root.length)
: parsedPath.appRoot;
commandOptions.path = parsedPath.dir.replace(separatorRegEx, '/');
commandOptions.path = parsedPath.dir === appConfig.root ? '' :
parsedPath.dir.startsWith(root)
? commandOptions.path.substr(root.length)
: commandOptions.path;
// Do not pass the schematics name itself, that's not useful.
commandOptions._ = rawArgs.slice(1);
commandOptions._angularCliConfig = (CliConfig.fromProject() || CliConfig.fromGlobal()).config;
commandOptions._angularCliAppConfig = appConfig;
commandOptions._angularCliParsedPath = parsedPath;
const cwd = this.project.root;
const schematicName = rawArgs[0];
if (['component', 'c', 'directive', 'd'].indexOf(schematicName) !== -1) {
if (commandOptions.prefix === undefined) {
commandOptions.prefix = appConfig.prefix;
}
if (schematicName === 'component' || schematicName === 'c') {
if (commandOptions.styleext === undefined) {
commandOptions.styleext = CliConfig.getValue('defaults.styleExt');
}
}
}
const SchematicRunTask = require('../tasks/schematic-run').default;
const schematicRunTask = new SchematicRunTask({
ui: this.ui,
@ -173,10 +149,6 @@ export default Command.extend({
const collectionName = commandOptions.collection ||
CliConfig.getValue('defaults.schematics.collection');
if (collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs[2]) {
commandOptions.type = rawArgs[2];
}
return schematicRunTask.run({
taskOptions: commandOptions,
workingDir: cwd,

View File

@ -111,6 +111,9 @@ const NewCommand = Command.extend({
},
run: function (commandOptions: any, rawArgs: string[]) {
commandOptions._ = [...rawArgs];
commandOptions._angularCliConfig = (CliConfig.fromProject() || CliConfig.fromGlobal()).config;
const packageName = rawArgs.shift();
if (!packageName) {
@ -121,7 +124,7 @@ const NewCommand = Command.extend({
}
validateProjectName(packageName);
commandOptions.name = packageName;
if (commandOptions.dryRun) {
commandOptions.skipGit = true;
}

View File

@ -1,6 +1,7 @@
// Prevent the dependency validation from tripping because we don't import these. We need
// it as a peer dependency of @angular/core.
// require('zone.js')
// require('@angular-devkit/core')
import * as path from 'path';

View File

@ -27,11 +27,12 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/build-optimizer": "~0.0.18",
"@angular-devkit/schematics": "~0.0.25",
"@angular-devkit/build-optimizer": "~0.0.26",
"@angular-devkit/core": "~0.0.18",
"@angular-devkit/schematics": "~0.0.31",
"@ngtools/json-schema": "1.1.0",
"@ngtools/webpack": "1.8.0-beta.4",
"@schematics/angular": "~0.0.38",
"@schematics/angular": "~0.0.42",
"autoprefixer": "^6.5.3",
"chalk": "^2.0.1",
"circular-dependency-plugin": "^3.0.0",

View File

@ -1,12 +1,10 @@
import * as chalk from 'chalk';
import LinkCli from '../tasks/link-cli';
import NpmInstall from '../tasks/npm-install';
import { validateProjectName } from '../utilities/validate-project-name';
import {checkYarnOrCNPM} from '../utilities/check-package-manager';
import {CliConfig} from '../models/config';
const Task = require('../ember-cli/lib/models/task');
const SilentError = require('silent-error');
const GitInit = require('../tasks/git-init');
const packageJson = require('../package.json');
@ -48,23 +46,10 @@ export default Task.extend({
});
}
const project = this.project;
const packageName = commandOptions.name !== '.' && commandOptions.name || project.name();
if (commandOptions.style === undefined) {
commandOptions.style = CliConfig.fromGlobal().get('defaults.styleExt');
}
if (!packageName) {
const 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));
}
validateProjectName(packageName);
const SchematicRunTask = require('../tasks/schematic-run').default;
const schematicRunTask = new SchematicRunTask({
ui: this.ui,
@ -106,7 +91,7 @@ export default Task.extend({
})
.then(() => {
if (!commandOptions.dryRun) {
this.ui.writeLine(chalk.green(`Project '${packageName}' successfully created.`));
this.ui.writeLine(chalk.green(`Project '${commandOptions.name}' successfully created.`));
}
});
}

View File

@ -37,6 +37,8 @@ export default Task.extend({
case 'boolean':
type = Boolean;
break;
case undefined:
return null;
}
let aliases: string[] = [];
if (opt.alias) {
@ -52,7 +54,7 @@ export default Task.extend({
type,
default: undefined // do not carry over schematics defaults
};
});
}).filter(x => x);
return Promise.resolve(availableOptions);
}

View File

@ -168,6 +168,8 @@ export abstract class NonLeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
case 'enum': Klass = EnumSchemaTreeNode; break;
case 'oneOf': Klass = OneOfSchemaTreeNode; break;
case undefined: Klass = AnySchemaTreeNode; break;
default:
throw new InvalidSchema('Type ' + type + ' not understood by SchemaClassFactory.');
}
@ -452,6 +454,24 @@ export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
}
class AnySchemaTreeNode extends LeafSchemaTreeNode<any> {
serialize(serializer: Serializer) {
switch (typeof this.value) {
case 'string': serializer.outputString(this); break;
case 'number': serializer.outputNumber(this); break;
case 'boolean': serializer.outputBoolean(this); break;
default: serializer.outputValue(this);
}
}
isCompatible(_: any) { return true; }
convert(v: any) { return v; }
get type() { return 'any'; }
get tsType(): null { return null; }
}
/** Basic primitives for JSON Schema. */
class StringSchemaTreeNode extends LeafSchemaTreeNode<string> {
serialize(serializer: Serializer) { serializer.outputString(this); }

View File

@ -2,5 +2,5 @@ const s = require('@angular-devkit/schematics');
exports.default = function(options) {
return s.chain([s.mergeWith(s.apply(
s.url('./files'), [s.template({}), s.move(options.name)]))]);
s.url('./files'), [s.template({}), s.move(options.name || options._[0])]))]);
};

View File

@ -4,6 +4,7 @@
"title": "Angular Bazel Workspace Options Schema",
"type": "object",
"properties": {
"_": {},
"name": {
"type": "string"
}