@schematics/angular 14.0.0-next.5 → 14.0.0-next.8

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.
Files changed (40) hide show
  1. package/app-shell/index.js +6 -2
  2. package/app-shell/schema.d.ts +3 -3
  3. package/app-shell/schema.json +3 -3
  4. package/application/index.js +1 -4
  5. package/application/schema.d.ts +1 -1
  6. package/application/schema.json +1 -1
  7. package/collection.json +1 -1
  8. package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +0 -2
  9. package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +3 -3
  10. package/component/index.js +5 -1
  11. package/directive/index.js +5 -1
  12. package/e2e/e2e-long.md +1 -1
  13. package/e2e/index.js +6 -0
  14. package/e2e/schema.d.ts +1 -1
  15. package/e2e/schema.json +1 -1
  16. package/library/index.js +1 -4
  17. package/migrations/migration-collection.json +10 -0
  18. package/migrations/update-14/remove-default-project-option.d.ts +10 -0
  19. package/migrations/update-14/remove-default-project-option.js +17 -0
  20. package/migrations/update-14/replace-default-collection-option.d.ts +10 -0
  21. package/migrations/update-14/replace-default-collection-option.js +32 -0
  22. package/module/index.js +5 -1
  23. package/ng-new/index.js +1 -1
  24. package/package.json +3 -3
  25. package/pipe/index.js +5 -1
  26. package/service-worker/index.js +7 -3
  27. package/third_party/github.com/Microsoft/TypeScript/BUILD.bazel +7 -2
  28. package/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts +29 -16
  29. package/third_party/github.com/Microsoft/TypeScript/lib/typescript.js +4866 -3030
  30. package/universal/index.js +11 -2
  31. package/universal/schema.d.ts +1 -1
  32. package/universal/schema.json +1 -1
  33. package/utility/ast-utils.js +31 -27
  34. package/utility/find-module.js +4 -8
  35. package/utility/latest-versions/package.json +3 -3
  36. package/utility/ng-ast-utils.js +6 -2
  37. package/utility/test/index.js +5 -1
  38. package/utility/workspace-models.d.ts +8 -6
  39. package/workspace/files/README.md.template +1 -1
  40. package/workspace/files/package.json.template +1 -2
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -33,6 +37,7 @@ const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/
33
37
  const ast_utils_1 = require("../utility/ast-utils");
34
38
  const change_1 = require("../utility/change");
35
39
  const dependencies_1 = require("../utility/dependencies");
40
+ const latest_versions_1 = require("../utility/latest-versions");
36
41
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
37
42
  const paths_1 = require("../utility/paths");
38
43
  const project_targets_1 = require("../utility/project-targets");
@@ -194,7 +199,11 @@ function addDependencies() {
194
199
  name: '@angular/platform-server',
195
200
  };
196
201
  (0, dependencies_1.addPackageJsonDependency)(host, platformServerDep);
197
- return host;
202
+ (0, dependencies_1.addPackageJsonDependency)(host, {
203
+ type: dependencies_1.NodeDependencyType.Dev,
204
+ name: '@types/node',
205
+ version: latest_versions_1.latestVersions['@types/node'],
206
+ });
198
207
  };
199
208
  }
200
209
  function default_1(options) {
@@ -7,7 +7,7 @@ export interface Schema {
7
7
  */
8
8
  appDir?: string;
9
9
  /**
10
- * The app identifier to use for transition.
10
+ * The application identifier to use for transition.
11
11
  */
12
12
  appId?: string;
13
13
  /**
@@ -16,7 +16,7 @@
16
16
  "appId": {
17
17
  "type": "string",
18
18
  "format": "html-selector",
19
- "description": "The app identifier to use for transition.",
19
+ "description": "The application identifier to use for transition.",
20
20
  "default": "serverApp"
21
21
  },
22
22
  "main": {
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -140,7 +144,6 @@ function getSourceNodes(sourceFile) {
140
144
  exports.getSourceNodes = getSourceNodes;
141
145
  function findNode(node, kind, text) {
142
146
  if (node.kind === kind && node.getText() === text) {
143
- // throw new Error(node.getText());
144
147
  return node;
145
148
  }
146
149
  let foundNode = null;
@@ -280,27 +283,26 @@ function getMetadataField(node, metadataField) {
280
283
  exports.getMetadataField = getMetadataField;
281
284
  function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbolName, importPath = null) {
282
285
  const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core');
283
- let node = nodes[0]; // eslint-disable-line @typescript-eslint/no-explicit-any
286
+ const node = nodes[0];
284
287
  // Find the decorator declaration.
285
- if (!node) {
288
+ if (!node || !ts.isObjectLiteralExpression(node)) {
286
289
  return [];
287
290
  }
288
291
  // Get all the children property assignment of object literals.
289
292
  const matchingProperties = getMetadataField(node, metadataField);
290
293
  if (matchingProperties.length == 0) {
291
294
  // We haven't found the field in the metadata declaration. Insert a new field.
292
- const expr = node;
293
295
  let position;
294
296
  let toInsert;
295
- if (expr.properties.length == 0) {
296
- position = expr.getEnd() - 1;
297
+ if (node.properties.length == 0) {
298
+ position = node.getEnd() - 1;
297
299
  toInsert = `\n ${metadataField}: [\n${core_1.tags.indentBy(4) `${symbolName}`}\n ]\n`;
298
300
  }
299
301
  else {
300
- node = expr.properties[expr.properties.length - 1];
301
- position = node.getEnd();
302
+ const childNode = node.properties[node.properties.length - 1];
303
+ position = childNode.getEnd();
302
304
  // Get the indentation of the last element, if any.
303
- const text = node.getFullText(source);
305
+ const text = childNode.getFullText(source);
304
306
  const matches = text.match(/^(\r?\n)(\s*)/);
305
307
  if (matches) {
306
308
  toInsert =
@@ -323,35 +325,33 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
323
325
  }
324
326
  const assignment = matchingProperties[0];
325
327
  // If it's not an array, nothing we can do really.
326
- if (assignment.initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
328
+ if (!ts.isPropertyAssignment(assignment) ||
329
+ !ts.isArrayLiteralExpression(assignment.initializer)) {
327
330
  return [];
328
331
  }
329
- const arrLiteral = assignment.initializer;
330
- if (arrLiteral.elements.length == 0) {
331
- // Forward the property.
332
- node = arrLiteral;
333
- }
334
- else {
335
- node = arrLiteral.elements;
336
- }
337
- if (Array.isArray(node)) {
338
- const nodeArray = node;
339
- const symbolsArray = nodeArray.map((node) => core_1.tags.oneLine `${node.getText()}`);
332
+ let expresssion;
333
+ const assignmentInit = assignment.initializer;
334
+ const elements = assignmentInit.elements;
335
+ if (elements.length) {
336
+ const symbolsArray = elements.map((node) => core_1.tags.oneLine `${node.getText()}`);
340
337
  if (symbolsArray.includes(core_1.tags.oneLine `${symbolName}`)) {
341
338
  return [];
342
339
  }
343
- node = node[node.length - 1];
340
+ expresssion = elements[elements.length - 1];
341
+ }
342
+ else {
343
+ expresssion = assignmentInit;
344
344
  }
345
345
  let toInsert;
346
- let position = node.getEnd();
347
- if (node.kind == ts.SyntaxKind.ArrayLiteralExpression) {
346
+ let position = expresssion.getEnd();
347
+ if (ts.isArrayLiteralExpression(expresssion)) {
348
348
  // We found the field but it's empty. Insert it just before the `]`.
349
349
  position--;
350
350
  toInsert = `\n${core_1.tags.indentBy(4) `${symbolName}`}\n `;
351
351
  }
352
352
  else {
353
353
  // Get the indentation of the last element, if any.
354
- const text = node.getFullText(source);
354
+ const text = expresssion.getFullText(source);
355
355
  const matches = text.match(/^(\r?\n)(\s*)/);
356
356
  if (matches) {
357
357
  toInsert = `,${matches[1]}${core_1.tags.indentBy(matches[2].length) `${symbolName}`}`;
@@ -466,6 +466,9 @@ exports.getEnvironmentExportName = getEnvironmentExportName;
466
466
  function getRouterModuleDeclaration(source) {
467
467
  const result = getDecoratorMetadata(source, 'NgModule', '@angular/core');
468
468
  const node = result[0];
469
+ if (!node || !ts.isObjectLiteralExpression(node)) {
470
+ return undefined;
471
+ }
469
472
  const matchingProperties = getMetadataField(node, 'imports');
470
473
  if (!matchingProperties) {
471
474
  return;
@@ -486,7 +489,8 @@ exports.getRouterModuleDeclaration = getRouterModuleDeclaration;
486
489
  function addRouteDeclarationToModule(source, fileToAdd, routeLiteral) {
487
490
  const routerModuleExpr = getRouterModuleDeclaration(source);
488
491
  if (!routerModuleExpr) {
489
- throw new Error(`Couldn't find a route declaration in ${fileToAdd}.`);
492
+ throw new Error(`Couldn't find a route declaration in ${fileToAdd}.\n` +
493
+ `Use the '--module' option to specify a different routing module.`);
490
494
  }
491
495
  const scopeConfigMethodArgs = routerModuleExpr.arguments;
492
496
  if (!scopeConfigMethodArgs.length) {
@@ -38,11 +38,7 @@ function findModuleFromOptions(host, options) {
38
38
  }
39
39
  const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
40
40
  for (const c of candidatesDirs) {
41
- const candidateFiles = [
42
- '',
43
- `${moduleBaseName}.ts`,
44
- `${moduleBaseName}${moduleExt}`,
45
- ].map((x) => (0, core_1.join)(c, x));
41
+ const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map((x) => (0, core_1.join)(c, x));
46
42
  for (const sc of candidateFiles) {
47
43
  if (host.exists(sc)) {
48
44
  return (0, core_1.normalize)(sc);
@@ -68,7 +64,7 @@ function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingMo
68
64
  return (0, core_1.join)(dir.path, filteredMatches[0]);
69
65
  }
70
66
  else if (filteredMatches.length > 1) {
71
- throw new Error('More than one module matches. Use the skip-import option to skip importing ' +
67
+ throw new Error(`More than one module matches. Use the '--skip-import' option to skip importing ` +
72
68
  'the component into the closest module or use the module option to specify a module.');
73
69
  }
74
70
  dir = dir.parent;
@@ -76,8 +72,8 @@ function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingMo
76
72
  const errorMsg = foundRoutingModule
77
73
  ? 'Could not find a non Routing NgModule.' +
78
74
  `\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
79
- '\nUse the skip-import option to skip importing in NgModule.'
80
- : 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
75
+ `\nUse the '--skip-import' option to skip importing in NgModule.`
76
+ : `Could not find an NgModule. Use the '--skip-import' option to skip importing in NgModule.`;
81
77
  throw new Error(errorMsg);
82
78
  }
83
79
  exports.findModule = findModule;
@@ -3,7 +3,7 @@
3
3
  "comment": "This file is needed so that depedencies are synced by Renovate.",
4
4
  "private": true,
5
5
  "dependencies": {
6
- "@types/jasmine": "~3.10.0",
6
+ "@types/jasmine": "~4.0.0",
7
7
  "@types/node": "^14.15.0",
8
8
  "jasmine-core": "~4.0.0",
9
9
  "karma-chrome-launcher": "~3.1.0",
@@ -11,10 +11,10 @@
11
11
  "karma-jasmine-html-reporter": "~1.7.0",
12
12
  "karma-jasmine": "~4.0.0",
13
13
  "karma": "~6.3.0",
14
- "ng-packagr": "^13.0.0",
14
+ "ng-packagr": "^14.0.0-next.2",
15
15
  "rxjs": "~7.5.0",
16
16
  "tslib": "^2.3.0",
17
- "typescript": "~4.5.2",
17
+ "typescript": "~4.6.2",
18
18
  "zone.js": "~0.11.4"
19
19
  }
20
20
  }
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -68,7 +72,7 @@ function findBootstrapModulePath(host, mainPath) {
68
72
  const bootstrapModule = bootstrapCall.arguments[0];
69
73
  const mainBuffer = host.read(mainPath);
70
74
  if (!mainBuffer) {
71
- throw new schematics_1.SchematicsException(`Client app main file (${mainPath}) not found`);
75
+ throw new schematics_1.SchematicsException(`Client application main file (${mainPath}) not found`);
72
76
  }
73
77
  const mainText = mainBuffer.toString('utf-8');
74
78
  const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -110,12 +110,15 @@ export declare type TestBuilderTarget = BuilderTarget<Builders.Karma, TestBuilde
110
110
  export declare type ServeBuilderTarget = BuilderTarget<Builders.DevServer, ServeBuilderOptions>;
111
111
  export declare type ExtractI18nBuilderTarget = BuilderTarget<Builders.ExtractI18n, ExtractI18nOptions>;
112
112
  export declare type E2EBuilderTarget = BuilderTarget<Builders.Protractor, E2EOptions>;
113
+ interface WorkspaceCLISchema {
114
+ warnings?: Record<string, boolean>;
115
+ schematicCollections?: string[];
116
+ defaultCollection?: string;
117
+ }
113
118
  export interface WorkspaceSchema {
114
119
  version: 1;
115
120
  defaultProject?: string;
116
- cli?: {
117
- warnings?: Record<string, boolean>;
118
- };
121
+ cli?: WorkspaceCLISchema;
119
122
  projects: {
120
123
  [key: string]: WorkspaceProject<ProjectType.Application | ProjectType.Library>;
121
124
  };
@@ -128,9 +131,7 @@ export interface WorkspaceProject<TProjectType extends ProjectType = ProjectType
128
131
  root: string;
129
132
  sourceRoot: string;
130
133
  prefix: string;
131
- cli?: {
132
- warnings?: Record<string, boolean>;
133
- };
134
+ cli?: WorkspaceCLISchema;
134
135
  /**
135
136
  * Tool options.
136
137
  */
@@ -150,3 +151,4 @@ export interface WorkspaceTargets<TProjectType extends ProjectType = ProjectType
150
151
  'extract-i18n'?: ExtractI18nBuilderTarget;
151
152
  [key: string]: any;
152
153
  }
154
+ export {};
@@ -4,7 +4,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular
4
4
 
5
5
  ## Development server
6
6
 
7
- Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
7
+ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
8
8
 
9
9
  ## Code scaffolding
10
10
 
@@ -25,8 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@angular/cli": "<%= '~' + version %>",
27
27
  "@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %>
28
- "@types/jasmine": "<%= latestVersions['@types/jasmine'] %>",<% } %>
29
- "@types/node": "<%= latestVersions['@types/node'] %>",<% if (!minimal) { %>
28
+ "@types/jasmine": "<%= latestVersions['@types/jasmine'] %>",
30
29
  "jasmine-core": "<%= latestVersions['jasmine-core'] %>",
31
30
  "karma": "<%= latestVersions['karma'] %>",
32
31
  "karma-chrome-launcher": "<%= latestVersions['karma-chrome-launcher'] %>",