@schematics/angular 8.0.0-rc.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,8 @@
5
5
  # You can see what browsers were selected by your queries by running:
6
6
  # npx browserslist
7
7
 
8
- # Googlebot uses an older version of Chrome
9
- # For additional information see: https://developers.google.com/search/docs/guides/rendering
10
-
11
8
  > 0.5%
12
9
  last 2 versions
13
10
  Firefox ESR
14
- Chrome 41 # Support for Googlebot
15
11
  not dead
16
12
  not IE 9-11 # For IE 9-11 support, remove 'not'.
package/collection.json CHANGED
@@ -102,7 +102,7 @@
102
102
  "description": "Generate a library project for Angular."
103
103
  },
104
104
  "webWorker": {
105
- "aliases": ["web-worker", "worker"],
105
+ "aliases": ["web-worker"],
106
106
  "factory": "./web-worker",
107
107
  "schema": "./web-worker/schema.json",
108
108
  "description": "Create a Web Worker."
@@ -12,6 +12,7 @@
12
12
  ]
13
13
  },
14
14
  "angularCompilerOptions": {
15
+ "annotateForClosureCompiler": true,
15
16
  "skipTemplateCodegen": true,
16
17
  "strictMetadataEmit": true,
17
18
  "fullTemplateTypeCheck": true,
package/library/index.js CHANGED
@@ -72,6 +72,11 @@ function addDependenciesToPackageJson() {
72
72
  name: 'ng-packagr',
73
73
  version: '^5.1.0',
74
74
  },
75
+ {
76
+ type: dependencies_1.NodeDependencyType.Dev,
77
+ name: 'tsickle',
78
+ version: '^0.35.0',
79
+ },
75
80
  {
76
81
  type: dependencies_1.NodeDependencyType.Default,
77
82
  name: 'tslib',
@@ -176,7 +181,7 @@ function default_1(options) {
176
181
  commonModule: false,
177
182
  flat: true,
178
183
  path: sourceDir,
179
- project: options.name,
184
+ project: projectName,
180
185
  }),
181
186
  schematics_1.schematic('component', {
182
187
  name: options.name,
@@ -186,13 +191,13 @@ function default_1(options) {
186
191
  flat: true,
187
192
  path: sourceDir,
188
193
  export: true,
189
- project: options.name,
194
+ project: projectName,
190
195
  }),
191
196
  schematics_1.schematic('service', {
192
197
  name: options.name,
193
198
  flat: true,
194
199
  path: sourceDir,
195
- project: options.name,
200
+ project: projectName,
196
201
  }),
197
202
  options.lintFix ? lint_fix_1.applyLintFix(sourceDir) : schematics_1.noop(),
198
203
  (_tree, context) => {
@@ -7,4 +7,4 @@
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  export declare const updateTsLintConfig: () => Rule;
10
- export declare const updatePackageJson: () => (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree, context: import("../../../../angular_devkit/schematics/src/index").TypedSchematicContext<{}, {}>) => import("../../../../angular_devkit/schematics/src/tree/interface").Tree;
10
+ export declare const updatePackageJson: () => (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  const core_1 = require("@angular-devkit/core");
11
- const tasks_1 = require("@angular-devkit/schematics/tasks");
12
11
  const dependencies_1 = require("../../utility/dependencies");
13
12
  const json_utils_1 = require("../../utility/json-utils");
14
13
  const ruleMapping = {
@@ -61,7 +60,7 @@ exports.updateTsLintConfig = () => {
61
60
  };
62
61
  };
63
62
  exports.updatePackageJson = () => {
64
- return (host, context) => {
63
+ return (host) => {
65
64
  const dependency = {
66
65
  type: dependencies_1.NodeDependencyType.Dev,
67
66
  name: 'codelyzer',
@@ -69,7 +68,5 @@ exports.updatePackageJson = () => {
69
68
  overwrite: true,
70
69
  };
71
70
  dependencies_1.addPackageJsonDependency(host, dependency);
72
- context.addTask(new tasks_1.NodePackageInstallTask());
73
- return host;
74
71
  };
75
72
  };
@@ -17,56 +17,15 @@ const browserslistContent = `# This file is used by the build system to adjust C
17
17
  # You can see what browsers were selected by your queries by running:
18
18
  # npx browserslist
19
19
 
20
- # Googlebot uses an older version of Chrome
21
- # For additional information see: https://developers.google.com/search/docs/guides/rendering
22
-
23
20
  > 0.5%
24
21
  last 2 versions
25
22
  Firefox ESR
26
- Chrome 41 # Support for Googlebot
27
23
  not dead
28
24
  not IE 9-11 # For IE 9-11 support, remove 'not'.`;
29
25
  function updateES5Projects() {
30
- return (host) => {
31
- const tsConfigPath = '/tsconfig.json';
32
- const buffer = host.read(tsConfigPath);
33
- if (!buffer) {
34
- return host;
35
- }
36
- const tsCfgAst = core_1.parseJsonAst(buffer.toString(), core_1.JsonParseMode.Loose);
37
- if (tsCfgAst.kind !== 'object') {
38
- return host;
39
- }
40
- const compilerOptions = json_utils_1.findPropertyInAstObject(tsCfgAst, 'compilerOptions');
41
- if (!compilerOptions || compilerOptions.kind !== 'object') {
42
- return host;
43
- }
44
- const recorder = host.beginUpdate(tsConfigPath);
45
- const scriptTarget = json_utils_1.findPropertyInAstObject(compilerOptions, 'target');
46
- if (!scriptTarget) {
47
- json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'target', 'es2015', 4);
48
- }
49
- else if (scriptTarget.value !== 'es2015') {
50
- const { start, end } = scriptTarget;
51
- recorder.remove(start.offset, end.offset - start.offset);
52
- recorder.insertLeft(start.offset, '"es2015"');
53
- }
54
- const scriptModule = json_utils_1.findPropertyInAstObject(compilerOptions, 'module');
55
- if (!scriptModule) {
56
- json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'module', 'esnext', 4);
57
- }
58
- else if (scriptModule.value !== 'esnext') {
59
- const { start, end } = scriptModule;
60
- recorder.remove(start.offset, end.offset - start.offset);
61
- recorder.insertLeft(start.offset, '"esnext"');
62
- }
63
- host.commitUpdate(recorder);
64
- return updateBrowserlist;
65
- };
66
- }
67
- exports.updateES5Projects = updateES5Projects;
68
- function updateBrowserlist() {
69
26
  return (tree) => {
27
+ // update workspace tsconfig
28
+ updateTsConfig(tree, '/tsconfig.json');
70
29
  const angularConfigContent = tree.read('angular.json') || tree.read('.angular.json');
71
30
  if (!angularConfigContent) {
72
31
  return;
@@ -88,6 +47,24 @@ function updateBrowserlist() {
88
47
  // Skip existing separate E2E projects
89
48
  continue;
90
49
  }
50
+ // Older projects app and spec ts configs had script and module set in them.
51
+ const architect = project.architect;
52
+ if (!(core_1.isJsonObject(architect)
53
+ && core_1.isJsonObject(architect.build)
54
+ && architect.build.builder === '@angular-devkit/build-angular:browser')) {
55
+ // Skip projects who's build builder is not build-angular:browser
56
+ continue;
57
+ }
58
+ const buildOptionsConfig = architect.build.options;
59
+ if (core_1.isJsonObject(buildOptionsConfig) && typeof buildOptionsConfig.tsConfig === 'string') {
60
+ updateTsConfig(tree, buildOptionsConfig.tsConfig);
61
+ }
62
+ const testConfig = architect.test;
63
+ if (core_1.isJsonObject(testConfig)
64
+ && core_1.isJsonObject(testConfig.options)
65
+ && typeof testConfig.options.tsConfig === 'string') {
66
+ updateTsConfig(tree, testConfig.options.tsConfig);
67
+ }
91
68
  const browserslistPath = core_1.join(core_1.normalize(project.root), 'browserslist');
92
69
  if (typeof project.sourceRoot === 'string') {
93
70
  // Move the CLI 7 style browserlist to root if it's there.
@@ -107,16 +84,53 @@ function updateBrowserlist() {
107
84
  }
108
85
  }
109
86
  }
110
- const source = tree.read(browserslistPath);
111
- if (!source) {
87
+ if (!tree.exists(browserslistPath)) {
112
88
  tree.create(browserslistPath, browserslistContent);
113
89
  }
114
- else if (!source.toString().toLowerCase().includes('chrome 41')) {
115
- const recorder = tree.beginUpdate(browserslistPath);
116
- recorder.insertRight(source.length, '\nChrome 41 # Googlebot');
117
- tree.commitUpdate(recorder);
118
- }
119
90
  }
120
91
  return tree;
121
92
  };
122
93
  }
94
+ exports.updateES5Projects = updateES5Projects;
95
+ function updateTsConfig(tree, tsConfigPath) {
96
+ const buffer = tree.read(tsConfigPath);
97
+ if (!buffer) {
98
+ return;
99
+ }
100
+ const tsCfgAst = core_1.parseJsonAst(buffer.toString(), core_1.JsonParseMode.Loose);
101
+ if (tsCfgAst.kind !== 'object') {
102
+ return;
103
+ }
104
+ const configExtends = json_utils_1.findPropertyInAstObject(tsCfgAst, 'extends');
105
+ const isExtendedConfig = configExtends && configExtends.kind === 'string';
106
+ const compilerOptions = json_utils_1.findPropertyInAstObject(tsCfgAst, 'compilerOptions');
107
+ if (!compilerOptions || compilerOptions.kind !== 'object') {
108
+ return;
109
+ }
110
+ const recorder = tree.beginUpdate(tsConfigPath);
111
+ if (isExtendedConfig) {
112
+ json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'target');
113
+ json_utils_1.removePropertyInAstObject(recorder, compilerOptions, 'module');
114
+ }
115
+ else {
116
+ const scriptTarget = json_utils_1.findPropertyInAstObject(compilerOptions, 'target');
117
+ if (!scriptTarget) {
118
+ json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'target', 'es2015', 4);
119
+ }
120
+ else if (scriptTarget.value !== 'es2015') {
121
+ const { start, end } = scriptTarget;
122
+ recorder.remove(start.offset, end.offset - start.offset);
123
+ recorder.insertLeft(start.offset, '"es2015"');
124
+ }
125
+ const scriptModule = json_utils_1.findPropertyInAstObject(compilerOptions, 'module');
126
+ if (!scriptModule) {
127
+ json_utils_1.insertPropertyInAstObjectInOrder(recorder, compilerOptions, 'module', 'esnext', 4);
128
+ }
129
+ else if (scriptModule.value !== 'esnext') {
130
+ const { start, end } = scriptModule;
131
+ recorder.remove(start.offset, end.offset - start.offset);
132
+ recorder.insertLeft(start.offset, '"esnext"');
133
+ }
134
+ }
135
+ tree.commitUpdate(recorder);
136
+ }
@@ -64,11 +64,11 @@ function dropES2015PolyfillsFromFile(polyfillPath) {
64
64
  if (!source) {
65
65
  return;
66
66
  }
67
- // normalize line endings to increase hash match chances
68
- const content = source.toString().replace(/\r\n|\r/g, '\n');
67
+ const content = source.toString();
69
68
  // Check if file is unmodified, if so then replace and return
70
69
  const hash = crypto_1.createHash('md5');
71
- hash.update(content);
70
+ // normalize line endings to increase hash match chances
71
+ hash.update(content.replace(/\r\n|\r/g, '\n'));
72
72
  const digest = hash.digest('hex');
73
73
  if (knownPolyfillHashes.includes(digest)) {
74
74
  // Replace with new project polyfills file
@@ -8,11 +8,12 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  const schematics_1 = require("@angular-devkit/schematics");
11
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
11
12
  const codelyzer_5_1 = require("./codelyzer-5");
12
13
  const differential_loading_1 = require("./differential-loading");
13
14
  const drop_es6_polyfills_1 = require("./drop-es6-polyfills");
14
15
  const remove_angular_http_1 = require("./remove-angular-http");
15
- const update_builders_1 = require("./update-builders");
16
+ const update_dependencies_1 = require("./update-dependencies");
16
17
  var update_lazy_module_paths_1 = require("./update-lazy-module-paths");
17
18
  exports.updateLazyModulePaths = update_lazy_module_paths_1.updateLazyModulePaths;
18
19
  function default_1() {
@@ -22,8 +23,14 @@ function default_1() {
22
23
  codelyzer_5_1.updatePackageJson(),
23
24
  drop_es6_polyfills_1.dropES2015Polyfills(),
24
25
  differential_loading_1.updateES5Projects(),
25
- update_builders_1.updateBuilders(),
26
+ update_dependencies_1.updateDependencies(),
26
27
  remove_angular_http_1.removeAngularHttp(),
28
+ (tree, context) => {
29
+ const packageChanges = tree.actions.some(a => a.path.endsWith('/package.json'));
30
+ if (packageChanges) {
31
+ context.addTask(new tasks_1.NodePackageInstallTask());
32
+ }
33
+ },
27
34
  ]);
28
35
  };
29
36
  }
@@ -5,4 +5,4 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- export declare const removeAngularHttp: () => (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree, context: import("../../../../angular_devkit/schematics/src/index").TypedSchematicContext<{}, {}>) => import("../../../../angular_devkit/schematics/src/tree/interface").Tree;
8
+ export declare const removeAngularHttp: () => (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
@@ -7,12 +7,9 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const tasks_1 = require("@angular-devkit/schematics/tasks");
11
10
  const dependencies_1 = require("../../utility/dependencies");
12
11
  exports.removeAngularHttp = () => {
13
- return (host, context) => {
12
+ return (host) => {
14
13
  dependencies_1.removePackageJsonDependency(host, '@angular/http');
15
- context.addTask(new tasks_1.NodePackageInstallTask());
16
- return host;
17
14
  };
18
15
  };
@@ -0,0 +1 @@
1
+ export declare function updateDependencies(): (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree) => void;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tasks_1 = require("@angular-devkit/schematics/tasks");
4
3
  const dependencies_1 = require("../../utility/dependencies");
5
4
  const latest_versions_1 = require("../../utility/latest-versions");
6
- function updateBuilders() {
7
- return (host, context) => {
8
- let updates = false;
5
+ function updateDependencies() {
6
+ return (host) => {
9
7
  let current = dependencies_1.getPackageJsonDependency(host, '@angular-devkit/build-angular');
10
8
  if (current && current.version !== latest_versions_1.latestVersions.DevkitBuildAngular) {
11
- updates = true;
12
9
  dependencies_1.addPackageJsonDependency(host, {
13
10
  type: current.type,
14
11
  name: '@angular-devkit/build-angular',
@@ -18,7 +15,6 @@ function updateBuilders() {
18
15
  }
19
16
  current = dependencies_1.getPackageJsonDependency(host, '@angular-devkit/build-ng-packagr');
20
17
  if (current && current.version !== latest_versions_1.latestVersions.DevkitBuildNgPackagr) {
21
- updates = true;
22
18
  dependencies_1.addPackageJsonDependency(host, {
23
19
  type: current.type,
24
20
  name: '@angular-devkit/build-ng-packagr',
@@ -28,7 +24,6 @@ function updateBuilders() {
28
24
  }
29
25
  current = dependencies_1.getPackageJsonDependency(host, 'zone.js');
30
26
  if (current && current.version !== latest_versions_1.latestVersions.ZoneJs) {
31
- updates = true;
32
27
  dependencies_1.addPackageJsonDependency(host, {
33
28
  type: current.type,
34
29
  name: 'zone.js',
@@ -36,9 +31,17 @@ function updateBuilders() {
36
31
  overwrite: true,
37
32
  });
38
33
  }
39
- if (updates) {
40
- context.addTask(new tasks_1.NodePackageInstallTask());
34
+ // FIXME: change to ^2.3.2 as soon as it's released with the pr208 fix
35
+ const webAnimationsJsVersion = 'github:angular/web-animations-js#release_pr208';
36
+ current = dependencies_1.getPackageJsonDependency(host, 'web-animations-js');
37
+ if (current && current.version !== webAnimationsJsVersion) {
38
+ dependencies_1.addPackageJsonDependency(host, {
39
+ type: current.type,
40
+ name: 'web-animations-js',
41
+ version: webAnimationsJsVersion,
42
+ overwrite: true,
43
+ });
41
44
  }
42
45
  };
43
46
  }
44
- exports.updateBuilders = updateBuilders;
47
+ exports.updateDependencies = updateDependencies;
@@ -6,4 +6,4 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
- export declare const updateLazyModulePaths: () => Rule;
9
+ export declare function updateLazyModulePaths(): Rule;
@@ -1,17 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tasks_1 = require("@angular-devkit/schematics/tasks");
4
- const path = require("path");
5
- exports.updateLazyModulePaths = () => {
6
- return (_, context) => {
7
- context.addTask(new tasks_1.TslintFixTask({
8
- rulesDirectory: path.join(__dirname, 'rules'),
9
- rules: {
10
- 'no-lazy-module-paths': [true],
11
- },
12
- }, {
13
- includes: '**/*.ts',
14
- silent: false,
15
- }));
3
+ const ts = require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript");
4
+ function* visit(directory) {
5
+ for (const path of directory.subfiles) {
6
+ if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
7
+ const entry = directory.file(path);
8
+ if (entry) {
9
+ const content = entry.content;
10
+ if (content.includes('loadChildren')) {
11
+ const source = ts.createSourceFile(entry.path, content.toString(), ts.ScriptTarget.Latest, true);
12
+ yield source;
13
+ }
14
+ }
15
+ }
16
+ }
17
+ for (const path of directory.subdirs) {
18
+ if (path === 'node_modules') {
19
+ continue;
20
+ }
21
+ yield* visit(directory.dir(path));
22
+ }
23
+ }
24
+ function updateLazyModulePaths() {
25
+ return tree => {
26
+ for (const sourceFile of visit(tree.root)) {
27
+ let recorder;
28
+ ts.forEachChild(sourceFile, function analyze(node) {
29
+ if (ts.isPropertyAssignment(node) &&
30
+ (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
31
+ node.name.text === 'loadChildren' &&
32
+ ts.isStringLiteral(node.initializer)) {
33
+ const valueNode = node.initializer;
34
+ const parts = valueNode.text.split('#');
35
+ const path = parts[0];
36
+ const moduleName = parts[1] || 'default';
37
+ const fix = `() => import('${path}').then(m => m.${moduleName})`;
38
+ if (!recorder) {
39
+ recorder = tree.beginUpdate(sourceFile.fileName);
40
+ }
41
+ const index = valueNode.getStart();
42
+ const length = valueNode.getWidth();
43
+ recorder
44
+ .remove(index, length)
45
+ .insertLeft(index, fix);
46
+ }
47
+ ts.forEachChild(node, analyze);
48
+ });
49
+ if (recorder) {
50
+ tree.commitUpdate(recorder);
51
+ }
52
+ }
16
53
  };
17
- };
54
+ }
55
+ exports.updateLazyModulePaths = updateLazyModulePaths;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "8.0.0-rc.1",
3
+ "version": "8.0.0",
4
4
  "description": "Schematics specific to Angular",
5
5
  "keywords": [
6
6
  "angular",
@@ -14,8 +14,8 @@
14
14
  ],
15
15
  "schematics": "./collection.json",
16
16
  "dependencies": {
17
- "@angular-devkit/core": "8.0.0-rc.1",
18
- "@angular-devkit/schematics": "8.0.0-rc.1"
17
+ "@angular-devkit/core": "8.0.0",
18
+ "@angular-devkit/schematics": "8.0.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -7,7 +7,7 @@ export interface Schema {
7
7
  */
8
8
  flat?: boolean;
9
9
  /**
10
- * When true, applies lint fixes after generating the pipe.
10
+ * When true, applies lint fixes after generating the service.
11
11
  */
12
12
  lintFix?: boolean;
13
13
  /**
@@ -47,11 +47,9 @@
47
47
  "lintFix": {
48
48
  "type": "boolean",
49
49
  "default": false,
50
- "description": "When true, applies lint fixes after generating the pipe.",
50
+ "description": "When true, applies lint fixes after generating the service.",
51
51
  "x-user-analytics": 15
52
52
  }
53
53
  },
54
- "required": [
55
- "name"
56
- ]
54
+ "required": ["name"]
57
55
  }
@@ -155,7 +155,7 @@ function getTsConfigOutDir(host, tsConfigPath) {
155
155
  throw new schematics_1.SchematicsException(`Could not read ${tsConfigPath}`);
156
156
  }
157
157
  const tsConfigContent = tsConfigBuffer.toString();
158
- const tsConfig = core_1.parseJson(tsConfigContent);
158
+ const tsConfig = core_1.parseJson(tsConfigContent, core_1.JsonParseMode.Loose);
159
159
  if (tsConfig === null || typeof tsConfig !== 'object' || Array.isArray(tsConfig) ||
160
160
  tsConfig.compilerOptions === null || typeof tsConfig.compilerOptions !== 'object' ||
161
161
  Array.isArray(tsConfig.compilerOptions)) {
@@ -156,10 +156,7 @@ function nodesByPosition(first, second) {
156
156
  function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
157
157
  // sort() has a side effect, so make a copy so that we won't overwrite the parent's object.
158
158
  let lastItem = [...nodes].sort(nodesByPosition).pop();
159
- if (!lastItem) {
160
- throw new Error();
161
- }
162
- if (syntaxKind) {
159
+ if (syntaxKind && lastItem) {
163
160
  lastItem = findNodes(lastItem, syntaxKind).sort(nodesByPosition).pop();
164
161
  }
165
162
  if (!lastItem && fallbackPos == undefined) {
@@ -243,8 +240,7 @@ function getDecoratorMetadata(source, identifier, module) {
243
240
  .filter(expr => {
244
241
  if (expr.expression.kind == ts.SyntaxKind.Identifier) {
245
242
  const id = expr.expression;
246
- return id.getFullText(source) == identifier
247
- && angularImports[id.getFullText(source)] === module;
243
+ return id.text == identifier && angularImports[id.text] === module;
248
244
  }
249
245
  else if (expr.expression.kind == ts.SyntaxKind.PropertyAccessExpression) {
250
246
  // This covers foo.NgModule when importing * as foo.
@@ -254,7 +250,7 @@ function getDecoratorMetadata(source, identifier, module) {
254
250
  return false;
255
251
  }
256
252
  const id = paExpr.name.text;
257
- const moduleId = paExpr.expression.getText(source);
253
+ const moduleId = paExpr.expression.text;
258
254
  return id === identifier && (angularImports[moduleId + '.'] === module);
259
255
  }
260
256
  return false;
@@ -9,12 +9,12 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.latestVersions = {
11
11
  // These versions should be kept up to date with latest Angular peer dependencies.
12
- Angular: '~8.0.0-rc.1',
12
+ Angular: '~8.0.0',
13
13
  RxJs: '~6.4.0',
14
- ZoneJs: '~0.9.0',
14
+ ZoneJs: '~0.9.1',
15
15
  TypeScript: '~3.4.3',
16
16
  TsLib: '^1.9.0',
17
17
  // The versions below must be manually updated when making a new devkit release.
18
- DevkitBuildAngular: '~0.800.0-rc.1',
19
- DevkitBuildNgPackagr: '~0.800.0-rc.1',
18
+ DevkitBuildAngular: '~0.800.0',
19
+ DevkitBuildNgPackagr: '~0.800.0',
20
20
  };
@@ -49,9 +49,11 @@ function addSnippet(options) {
49
49
  if (options.path === undefined) {
50
50
  return;
51
51
  }
52
+ const fileRegExp = new RegExp(`^${options.name}.*\.ts`);
52
53
  const siblingModules = host.getDir(options.path).subfiles
53
- // Find all files that start with the same name, are ts files, and aren't spec files.
54
- .filter(f => f.startsWith(options.name) && f.endsWith('.ts') && !f.endsWith('spec.ts'))
54
+ // Find all files that start with the same name, are ts files,
55
+ // and aren't spec or module files.
56
+ .filter(f => fileRegExp.test(f) && !/(module|spec)\.ts$/.test(f))
55
57
  // Sort alphabetically for consistency.
56
58
  .sort();
57
59
  if (siblingModules.length === 0) {
@@ -1,12 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { RuleFailure, Rules } from 'tslint';
9
- import * as ts from '../../../third_party/github.com/Microsoft/TypeScript/lib/typescript';
10
- export declare class Rule extends Rules.AbstractRule {
11
- apply(ast: ts.SourceFile): Array<RuleFailure>;
12
- }
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @license
5
- * Copyright Google Inc. All Rights Reserved.
6
- *
7
- * Use of this source code is governed by an MIT-style license that can be
8
- * found in the LICENSE file at https://angular.io/license
9
- */
10
- const tslint_1 = require("tslint"); // tslint:disable-line:no-implicit-dependencies
11
- const ts = require("../../../third_party/github.com/Microsoft/TypeScript/lib/typescript");
12
- // Constants:
13
- const LOAD_CHILDREN_SPLIT = '#';
14
- const FAILURE_MESSAGE = 'Found magic `loadChildren` string. Use a function with `import` instead.';
15
- class Rule extends tslint_1.Rules.AbstractRule {
16
- apply(ast) {
17
- const ruleName = this.ruleName;
18
- const changes = [];
19
- // NOTE: This should ideally be excluded at a higher level to avoid parsing
20
- if (ast.isDeclarationFile || /[\\\/]node_modules[\\\/]/.test(ast.fileName)) {
21
- return [];
22
- }
23
- // Workaround mismatched tslint TS version and vendored TS version
24
- // The TS SyntaxKind enum numeric values change between versions
25
- const sourceFile = ts.createSourceFile(ast.fileName, ast.text, ast.languageVersion, true);
26
- ts.forEachChild(sourceFile, function analyze(node) {
27
- if (ts.isPropertyAssignment(node) &&
28
- (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
29
- node.name.text === 'loadChildren' &&
30
- ts.isStringLiteral(node.initializer)) {
31
- const valueNode = node.initializer;
32
- const parts = valueNode.text.split(LOAD_CHILDREN_SPLIT);
33
- const path = parts[0];
34
- const moduleName = parts[1] || 'default';
35
- let fix = `() => import('${path}').then(m => m.${moduleName})`;
36
- // Try to fix indentation in replacement:
37
- const { character } = ast.getLineAndCharacterOfPosition(node.getStart());
38
- fix = fix.replace(/\n/g, `\n${' '.repeat(character)}`);
39
- const replacement = new tslint_1.Replacement(valueNode.getStart(), valueNode.getWidth(), fix);
40
- const start = node.getStart();
41
- const end = node.getEnd();
42
- const change = new tslint_1.RuleFailure(ast, start, end, FAILURE_MESSAGE, ruleName, replacement);
43
- change.setRuleSeverity('warning');
44
- changes.push(change);
45
- }
46
- ts.forEachChild(node, analyze);
47
- });
48
- return changes;
49
- }
50
- }
51
- exports.Rule = Rule;
@@ -1 +0,0 @@
1
- export declare function updateBuilders(): (host: import("../../../../angular_devkit/schematics/src/tree/interface").Tree, context: import("../../../../angular_devkit/schematics/src/index").TypedSchematicContext<{}, {}>) => void;