@schematics/angular 14.0.0-next.9 → 14.0.0-rc.2

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 (58) hide show
  1. package/app-shell/index.js +4 -8
  2. package/app-shell/schema.json +0 -3
  3. package/application/files/src/test.ts.template +1 -1
  4. package/application/index.js +3 -3
  5. package/class/schema.json +3 -0
  6. package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +1 -1
  7. package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +5 -2
  8. package/component/index.js +9 -14
  9. package/component/schema.d.ts +4 -0
  10. package/component/schema.json +9 -0
  11. package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template +2 -1
  12. package/directive/index.js +9 -18
  13. package/directive/schema.d.ts +4 -0
  14. package/directive/schema.json +9 -0
  15. package/e2e/index.js +5 -5
  16. package/enum/schema.json +3 -0
  17. package/guard/schema.json +3 -0
  18. package/interceptor/schema.json +3 -0
  19. package/interface/schema.json +3 -0
  20. package/library/files/src/test.ts.template +1 -1
  21. package/library/index.js +3 -4
  22. package/migrations/migration-collection.json +5 -0
  23. package/migrations/update-14/update-libraries-secondary-entrypoints.d.ts +10 -0
  24. package/migrations/update-14/update-libraries-secondary-entrypoints.js +51 -0
  25. package/module/index.js +8 -16
  26. package/module/schema.json +3 -0
  27. package/package.json +10 -3
  28. package/pipe/files/__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template +2 -1
  29. package/pipe/index.js +8 -17
  30. package/pipe/schema.d.ts +4 -0
  31. package/pipe/schema.json +9 -0
  32. package/resolver/schema.json +3 -0
  33. package/service/schema.json +3 -1
  34. package/service-worker/index.js +4 -8
  35. package/third_party/github.com/Microsoft/TypeScript/BUILD.bazel +4 -4
  36. package/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts +402 -295
  37. package/third_party/github.com/Microsoft/TypeScript/lib/typescript.js +23181 -20448
  38. package/universal/index.js +3 -7
  39. package/utility/dependency.d.ts +45 -0
  40. package/utility/dependency.js +97 -0
  41. package/utility/find-module.d.ts +1 -0
  42. package/utility/find-module.js +1 -2
  43. package/utility/generate-from-files.js +2 -3
  44. package/utility/index.d.ts +10 -0
  45. package/utility/index.js +21 -0
  46. package/utility/json-file.js +1 -7
  47. package/utility/latest-versions/package.json +4 -3
  48. package/utility/latest-versions.js +1 -1
  49. package/utility/ng-ast-utils.js +2 -10
  50. package/utility/parse-name.js +0 -1
  51. package/utility/validation.js +1 -3
  52. package/utility/workspace-models.d.ts +6 -0
  53. package/utility/workspace-models.js +6 -0
  54. package/utility/workspace.d.ts +36 -3
  55. package/utility/workspace.js +70 -34
  56. package/web-worker/index.js +2 -2
  57. package/web-worker/schema.json +3 -0
  58. package/workspace/index.js +1 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "14.0.0-next.9",
3
+ "version": "14.0.0-rc.2",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -13,10 +13,17 @@
13
13
  "code generation",
14
14
  "schematics"
15
15
  ],
16
+ "exports": {
17
+ "./package.json": "./package.json",
18
+ "./utility": "./utility/index.js",
19
+ "./utility/*": "./utility/*.js",
20
+ "./migrations/migration-collection.json": "./migrations/migration-collection.json",
21
+ "./*": "./*.js"
22
+ },
16
23
  "schematics": "./collection.json",
17
24
  "dependencies": {
18
- "@angular-devkit/core": "14.0.0-next.9",
19
- "@angular-devkit/schematics": "14.0.0-next.9",
25
+ "@angular-devkit/core": "14.0.0-rc.2",
26
+ "@angular-devkit/schematics": "14.0.0-rc.2",
20
27
  "jsonc-parser": "3.0.0"
21
28
  },
22
29
  "repository": {
@@ -1,7 +1,8 @@
1
1
  import { Pipe, PipeTransform } from '@angular/core';
2
2
 
3
3
  @Pipe({
4
- name: '<%= camelize(name) %>'
4
+ name: '<%= camelize(name) %>'<% if(standalone) {%>,
5
+ standalone: true<%}%>
5
6
  })
6
7
  export class <%= classify(name) %>Pipe implements PipeTransform {
7
8
 
package/pipe/index.js CHANGED
@@ -30,7 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- const core_1 = require("@angular-devkit/core");
34
33
  const schematics_1 = require("@angular-devkit/schematics");
35
34
  const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
36
35
  const ast_utils_1 = require("../utility/ast-utils");
@@ -40,22 +39,18 @@ const parse_name_1 = require("../utility/parse-name");
40
39
  const workspace_1 = require("../utility/workspace");
41
40
  function addDeclarationToNgModule(options) {
42
41
  return (host) => {
43
- if (options.skipImport || !options.module) {
42
+ if (options.skipImport || options.standalone || !options.module) {
44
43
  return host;
45
44
  }
46
45
  const modulePath = options.module;
47
- const text = host.read(modulePath);
48
- if (text === null) {
49
- throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
50
- }
51
- const sourceText = text.toString('utf-8');
46
+ const sourceText = host.readText(modulePath);
52
47
  const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
53
48
  const pipePath = `/${options.path}/` +
54
- (options.flat ? '' : core_1.strings.dasherize(options.name) + '/') +
55
- core_1.strings.dasherize(options.name) +
49
+ (options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
50
+ schematics_1.strings.dasherize(options.name) +
56
51
  '.pipe';
57
52
  const relativePath = (0, find_module_1.buildRelativePath)(modulePath, pipePath);
58
- const changes = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, core_1.strings.classify(`${options.name}Pipe`), relativePath);
53
+ const changes = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Pipe`), relativePath);
59
54
  const recorder = host.beginUpdate(modulePath);
60
55
  for (const change of changes) {
61
56
  if (change instanceof change_1.InsertChange) {
@@ -64,14 +59,10 @@ function addDeclarationToNgModule(options) {
64
59
  }
65
60
  host.commitUpdate(recorder);
66
61
  if (options.export) {
67
- const text = host.read(modulePath);
68
- if (text === null) {
69
- throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
70
- }
71
- const sourceText = text.toString('utf-8');
62
+ const sourceText = host.readText(modulePath);
72
63
  const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
73
64
  const exportRecorder = host.beginUpdate(modulePath);
74
- const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Pipe`), relativePath);
65
+ const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, schematics_1.strings.classify(`${options.name}Pipe`), relativePath);
75
66
  for (const change of exportChanges) {
76
67
  if (change instanceof change_1.InsertChange) {
77
68
  exportRecorder.insertLeft(change.pos, change.toAdd);
@@ -94,7 +85,7 @@ function default_1(options) {
94
85
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
95
86
  options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
96
87
  (0, schematics_1.applyTemplates)({
97
- ...core_1.strings,
88
+ ...schematics_1.strings,
98
89
  'if-flat': (s) => (options.flat ? '' : s),
99
90
  ...options,
100
91
  }),
package/pipe/schema.d.ts CHANGED
@@ -34,4 +34,8 @@ export interface Schema {
34
34
  * Do not create "spec.ts" test files for the new pipe.
35
35
  */
36
36
  skipTests?: boolean;
37
+ /**
38
+ * Whether the generated pipe is standalone.
39
+ */
40
+ standalone?: boolean;
37
41
  }
package/pipe/schema.json CHANGED
@@ -18,6 +18,9 @@
18
18
  "path": {
19
19
  "type": "string",
20
20
  "format": "path",
21
+ "$default": {
22
+ "$source": "workingDirectory"
23
+ },
21
24
  "description": "The path at which to create the pipe, relative to the workspace root.",
22
25
  "visible": false
23
26
  },
@@ -45,6 +48,12 @@
45
48
  "description": "Do not import this pipe into the owning NgModule.",
46
49
  "x-user-analytics": 18
47
50
  },
51
+ "standalone": {
52
+ "description": "Whether the generated pipe is standalone.",
53
+ "type": "boolean",
54
+ "default": false,
55
+ "x-user-analytics": 15
56
+ },
48
57
  "module": {
49
58
  "type": "string",
50
59
  "description": "The declaring NgModule.",
@@ -29,6 +29,9 @@
29
29
  "path": {
30
30
  "type": "string",
31
31
  "format": "path",
32
+ "$default": {
33
+ "$source": "workingDirectory"
34
+ },
32
35
  "description": "The path at which to create the interface that defines the resolver, relative to the current workspace.",
33
36
  "visible": false
34
37
  },
@@ -17,7 +17,9 @@
17
17
  },
18
18
  "path": {
19
19
  "type": "string",
20
- "format": "path",
20
+ "$default": {
21
+ "$source": "workingDirectory"
22
+ },
21
23
  "description": "The path at which to create the service, relative to the workspace root.",
22
24
  "visible": false
23
25
  },
@@ -34,13 +34,13 @@ const core_1 = require("@angular-devkit/core");
34
34
  const schematics_1 = require("@angular-devkit/schematics");
35
35
  const tasks_1 = require("@angular-devkit/schematics/tasks");
36
36
  const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
37
+ const utility_1 = require("../utility");
37
38
  const ast_utils_1 = require("../utility/ast-utils");
38
39
  const change_1 = require("../utility/change");
39
40
  const dependencies_1 = require("../utility/dependencies");
40
41
  const ng_ast_utils_1 = require("../utility/ng-ast-utils");
41
42
  const paths_1 = require("../utility/paths");
42
43
  const project_targets_1 = require("../utility/project-targets");
43
- const workspace_1 = require("../utility/workspace");
44
44
  function addDependencies() {
45
45
  return (host, context) => {
46
46
  const packageName = '@angular/service-worker';
@@ -113,17 +113,13 @@ function updateAppModule(mainPath) {
113
113
  };
114
114
  }
115
115
  function getTsSourceFile(host, path) {
116
- const buffer = host.read(path);
117
- if (!buffer) {
118
- throw new schematics_1.SchematicsException(`Could not read file (${path}).`);
119
- }
120
- const content = buffer.toString();
116
+ const content = host.readText(path);
121
117
  const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
122
118
  return source;
123
119
  }
124
120
  function default_1(options) {
125
121
  return async (host, context) => {
126
- const workspace = await (0, workspace_1.getWorkspace)(host);
122
+ const workspace = await (0, utility_1.readWorkspace)(host);
127
123
  const project = workspace.projects.get(options.project);
128
124
  if (!project) {
129
125
  throw new schematics_1.SchematicsException(`Invalid project name (${options.project})`);
@@ -152,9 +148,9 @@ function default_1(options) {
152
148
  (0, schematics_1.move)(project.root),
153
149
  ]);
154
150
  context.addTask(new tasks_1.NodePackageInstallTask());
151
+ await (0, utility_1.writeWorkspace)(host, workspace);
155
152
  return (0, schematics_1.chain)([
156
153
  (0, schematics_1.mergeWith)(templateSource),
157
- (0, workspace_1.updateWorkspace)(workspace),
158
154
  addDependencies(),
159
155
  updateAppModule(buildOptions.main),
160
156
  ]);
@@ -1,11 +1,11 @@
1
1
  load("//tools:defaults.bzl", "ts_library")
2
2
 
3
- # files fetched on 2022-03-10 from
4
- # https://github.com/microsoft/TypeScript/releases/tag/v4.6.2
3
+ # files fetched on 2022-05-25 from
4
+ # https://github.com/microsoft/TypeScript/releases/tag/v4.7.2
5
5
 
6
6
  # Commands to download:
7
- # curl https://raw.githubusercontent.com/microsoft/TypeScript/v4.6.2/lib/typescript.d.ts -o packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts
8
- # curl https://raw.githubusercontent.com/microsoft/TypeScript/v4.6.2/lib/typescript.js -o packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js
7
+ # curl https://raw.githubusercontent.com/microsoft/TypeScript/v4.7.2/lib/typescript.d.ts -o packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts
8
+ # curl https://raw.githubusercontent.com/microsoft/TypeScript/v4.7.2/lib/typescript.js -o packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js
9
9
 
10
10
  licenses(["notice"]) # Apache 2.0
11
11