@abp/ng.schematics 9.2.0-rc.2 → 9.2.0-rc.4

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 (117) hide show
  1. package/commands/change-theme/index.d.ts +8 -3
  2. package/commands/change-theme/index.js +300 -71
  3. package/commands/change-theme/index.js.map +1 -1
  4. package/commands/change-theme/style-map.d.ts +2 -0
  5. package/commands/change-theme/style-map.js +96 -9
  6. package/commands/change-theme/style-map.js.map +1 -1
  7. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/.eslintrc.json.template +44 -0
  8. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/ng-package.json.template +7 -0
  9. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/src/enums/index.ts.template +1 -0
  10. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/src/enums/route-names.ts.template +3 -0
  11. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/src/providers/index.ts.template +1 -0
  12. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/src/providers/route.provider.ts.template +30 -0
  13. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/config/src/public-api.ts.template +2 -0
  14. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/karma.conf.js.template +44 -0
  15. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/ng-package.json.template +7 -0
  16. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/package.json.template +11 -0
  17. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/src/lib/__libraryName@kebab__.component.ts.template +11 -0
  18. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/src/lib/__libraryName@kebab__.routes.ts.template +9 -0
  19. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/src/lib/index.ts.template +1 -0
  20. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/src/public-api.ts.template +4 -0
  21. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/src/test.ts.template +26 -0
  22. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/tsconfig.lib.json.template +20 -0
  23. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/tsconfig.lib.prod.json.template +10 -0
  24. package/commands/create-lib/files-package-standalone/__libraryName@kebab__/tsconfig.spec.json.template +17 -0
  25. package/commands/create-lib/files-secondary-entrypoint-standalone/__libraryName@kebab__/ng-package.json.template +6 -0
  26. package/commands/create-lib/files-secondary-entrypoint-standalone/__libraryName@kebab__/src/lib/__target@kebab__-__libraryName@kebab__.ts.template +7 -0
  27. package/commands/create-lib/files-secondary-entrypoint-standalone/__libraryName@kebab__/src/lib/index.ts.template +1 -0
  28. package/commands/create-lib/files-secondary-entrypoint-standalone/__libraryName@kebab__/src/public-api.ts.template +1 -0
  29. package/commands/create-lib/index.d.ts +7 -3
  30. package/commands/create-lib/index.js +161 -58
  31. package/commands/create-lib/index.js.map +1 -1
  32. package/commands/create-lib/models/generate-lib-schema.d.ts +8 -1
  33. package/commands/create-lib/models/generate-lib-schema.js +6 -0
  34. package/commands/create-lib/models/generate-lib-schema.js.map +1 -1
  35. package/commands/create-lib/schema.json +13 -9
  36. package/package.json +1 -1
  37. package/utils/angular/add-declaration-to-ng-module.d.ts +2 -1
  38. package/utils/angular/add-declaration-to-ng-module.js +4 -4
  39. package/utils/angular/add-declaration-to-ng-module.js.map +1 -1
  40. package/utils/angular/ast-utils.d.ts +18 -8
  41. package/utils/angular/ast-utils.js +70 -41
  42. package/utils/angular/ast-utils.js.map +1 -1
  43. package/utils/angular/change.d.ts +1 -1
  44. package/utils/angular/change.js +4 -4
  45. package/utils/angular/change.js.map +1 -1
  46. package/utils/angular/dependencies.d.ts +1 -1
  47. package/utils/angular/dependencies.js +1 -1
  48. package/utils/angular/dependency.d.ts +1 -1
  49. package/utils/angular/dependency.js +2 -2
  50. package/utils/angular/dependency.js.map +1 -1
  51. package/utils/angular/eol.d.ts +8 -0
  52. package/utils/angular/eol.js +24 -0
  53. package/utils/angular/eol.js.map +1 -0
  54. package/utils/angular/find-module.d.ts +1 -1
  55. package/utils/angular/find-module.js +5 -5
  56. package/utils/angular/find-module.js.map +1 -1
  57. package/utils/angular/generate-from-files.d.ts +3 -1
  58. package/utils/angular/generate-from-files.js +15 -2
  59. package/utils/angular/generate-from-files.js.map +1 -1
  60. package/utils/angular/index.d.ts +1 -0
  61. package/utils/angular/index.js +1 -0
  62. package/utils/angular/index.js.map +1 -1
  63. package/utils/angular/json-file.d.ts +3 -2
  64. package/utils/angular/json-file.js +6 -3
  65. package/utils/angular/json-file.js.map +1 -1
  66. package/utils/angular/ng-ast-utils.d.ts +2 -2
  67. package/utils/angular/ng-ast-utils.js +19 -7
  68. package/utils/angular/ng-ast-utils.js.map +1 -1
  69. package/utils/angular/parse-name.d.ts +1 -1
  70. package/utils/angular/parse-name.js +1 -1
  71. package/utils/angular/paths.d.ts +1 -1
  72. package/utils/angular/paths.js +4 -7
  73. package/utils/angular/paths.js.map +1 -1
  74. package/utils/angular/project-targets.d.ts +3 -1
  75. package/utils/angular/project-targets.js +9 -2
  76. package/utils/angular/project-targets.js.map +1 -1
  77. package/utils/angular/standalone/app_component.d.ts +29 -0
  78. package/utils/angular/standalone/app_component.js +108 -0
  79. package/utils/angular/standalone/app_component.js.map +1 -0
  80. package/utils/angular/standalone/app_config.d.ts +23 -0
  81. package/utils/angular/standalone/app_config.js +90 -0
  82. package/utils/angular/standalone/app_config.js.map +1 -0
  83. package/utils/angular/standalone/code_block.d.ts +53 -0
  84. package/utils/angular/standalone/code_block.js +80 -0
  85. package/utils/angular/standalone/code_block.js.map +1 -0
  86. package/utils/angular/standalone/index.d.ts +9 -0
  87. package/utils/angular/standalone/index.js +14 -0
  88. package/utils/angular/standalone/index.js.map +1 -0
  89. package/utils/angular/standalone/rules.d.ts +45 -0
  90. package/utils/angular/standalone/rules.js +189 -0
  91. package/utils/angular/standalone/rules.js.map +1 -0
  92. package/utils/angular/standalone/util.d.ts +35 -0
  93. package/utils/angular/standalone/util.js +136 -0
  94. package/utils/angular/standalone/util.js.map +1 -0
  95. package/utils/angular/validation.d.ts +1 -1
  96. package/utils/angular/validation.js +2 -2
  97. package/utils/angular/validation.js.map +1 -1
  98. package/utils/angular/workspace-models.d.ts +12 -6
  99. package/utils/angular/workspace-models.js +11 -3
  100. package/utils/angular/workspace-models.js.map +1 -1
  101. package/utils/angular/workspace.d.ts +12 -1
  102. package/utils/angular/workspace.js +6 -6
  103. package/utils/angular/workspace.js.map +1 -1
  104. package/utils/ast.d.ts +1 -0
  105. package/utils/ast.js +6 -1
  106. package/utils/ast.js.map +1 -1
  107. package/utils/index.d.ts +2 -0
  108. package/utils/index.js +2 -0
  109. package/utils/index.js.map +1 -1
  110. package/utils/ng-module.d.ts +46 -0
  111. package/utils/ng-module.js +126 -0
  112. package/utils/ng-module.js.map +1 -0
  113. package/utils/standalone.d.ts +59 -0
  114. package/utils/standalone.js +146 -0
  115. package/utils/standalone.js.map +1 -0
  116. package/utils/workspace.js +1 -1
  117. package/utils/workspace.js.map +1 -1
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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.dev/license
7
+ */
8
+ export { addRootImport, addRootProvider } from './rules';
9
+ export type { PendingCode, CodeBlockCallback, CodeBlock } from './code_block';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.addRootProvider = exports.addRootImport = void 0;
11
+ var rules_1 = require("./rules");
12
+ Object.defineProperty(exports, "addRootImport", { enumerable: true, get: function () { return rules_1.addRootImport; } });
13
+ Object.defineProperty(exports, "addRootProvider", { enumerable: true, get: function () { return rules_1.addRootProvider; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/schematics/src/utils/angular/standalone/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAAyD;AAAhD,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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.dev/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ import { CodeBlockCallback } from './code_block';
10
+ /**
11
+ * Adds an import to the root of the project.
12
+ * @param project Name of the project to which to add the import.
13
+ * @param callback Function that generates the code block which should be inserted.
14
+ * @example
15
+ *
16
+ * ```ts
17
+ * import { Rule } from '@angular-devkit/schematics';
18
+ * import { addRootImport } from '@schematics/angular/utility';
19
+ *
20
+ * export default function(): Rule {
21
+ * return addRootImport('default', ({code, external}) => {
22
+ * return code`${external('MyModule', '@my/module')}.forRoot({})`;
23
+ * });
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function addRootImport(project: string, callback: CodeBlockCallback): Rule;
28
+ /**
29
+ * Adds a provider to the root of the project.
30
+ * @param project Name of the project to which to add the import.
31
+ * @param callback Function that generates the code block which should be inserted.
32
+ * @example
33
+ *
34
+ * ```ts
35
+ * import { Rule } from '@angular-devkit/schematics';
36
+ * import { addRootProvider } from '@schematics/angular/utility';
37
+ *
38
+ * export default function(): Rule {
39
+ * return addRootProvider('default', ({code, external}) => {
40
+ * return code`${external('provideLibrary', '@my/library')}({})`;
41
+ * });
42
+ * }
43
+ * ```
44
+ */
45
+ export declare function addRootProvider(project: string, callback: CodeBlockCallback): Rule;
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.addRootProvider = exports.addRootImport = void 0;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const schematics_1 = require("@angular-devkit/schematics");
13
+ const ast_utils_1 = require("../ast-utils");
14
+ const change_1 = require("../change");
15
+ const ng_ast_utils_1 = require("../ng-ast-utils");
16
+ const app_config_1 = require("./app_config");
17
+ const code_block_1 = require("./code_block");
18
+ const util_1 = require("./util");
19
+ /**
20
+ * Adds an import to the root of the project.
21
+ * @param project Name of the project to which to add the import.
22
+ * @param callback Function that generates the code block which should be inserted.
23
+ * @example
24
+ *
25
+ * ```ts
26
+ * import { Rule } from '@angular-devkit/schematics';
27
+ * import { addRootImport } from '@schematics/angular/utility';
28
+ *
29
+ * export default function(): Rule {
30
+ * return addRootImport('default', ({code, external}) => {
31
+ * return code`${external('MyModule', '@my/module')}.forRoot({})`;
32
+ * });
33
+ * }
34
+ * ```
35
+ */
36
+ function addRootImport(project, callback) {
37
+ return getRootInsertionRule(project, callback, 'imports', {
38
+ name: 'importProvidersFrom',
39
+ module: '@angular/core',
40
+ });
41
+ }
42
+ exports.addRootImport = addRootImport;
43
+ /**
44
+ * Adds a provider to the root of the project.
45
+ * @param project Name of the project to which to add the import.
46
+ * @param callback Function that generates the code block which should be inserted.
47
+ * @example
48
+ *
49
+ * ```ts
50
+ * import { Rule } from '@angular-devkit/schematics';
51
+ * import { addRootProvider } from '@schematics/angular/utility';
52
+ *
53
+ * export default function(): Rule {
54
+ * return addRootProvider('default', ({code, external}) => {
55
+ * return code`${external('provideLibrary', '@my/library')}({})`;
56
+ * });
57
+ * }
58
+ * ```
59
+ */
60
+ function addRootProvider(project, callback) {
61
+ return getRootInsertionRule(project, callback, 'providers');
62
+ }
63
+ exports.addRootProvider = addRootProvider;
64
+ /**
65
+ * Creates a rule that inserts code at the root of either a standalone or NgModule-based project.
66
+ * @param project Name of the project into which to inser tthe code.
67
+ * @param callback Function that generates the code block which should be inserted.
68
+ * @param ngModuleField Field of the root NgModule into which the code should be inserted, if the
69
+ * app is based on NgModule
70
+ * @param standaloneWrapperFunction Function with which to wrap the code if the app is standalone.
71
+ */
72
+ function getRootInsertionRule(project, callback, ngModuleField, standaloneWrapperFunction) {
73
+ return async (host) => {
74
+ const mainFilePath = await (0, util_1.getMainFilePath)(host, project);
75
+ const codeBlock = new code_block_1.CodeBlock();
76
+ if ((0, ng_ast_utils_1.isStandaloneApp)(host, mainFilePath)) {
77
+ return tree => addProviderToStandaloneBootstrap(tree, callback(codeBlock), mainFilePath, standaloneWrapperFunction);
78
+ }
79
+ const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainFilePath);
80
+ const pendingCode = code_block_1.CodeBlock.transformPendingCode(callback(codeBlock), modulePath);
81
+ return (0, schematics_1.chain)([
82
+ ...pendingCode.rules,
83
+ tree => {
84
+ const changes = (0, ast_utils_1.addSymbolToNgModuleMetadata)((0, util_1.getSourceFile)(tree, modulePath), modulePath, ngModuleField, pendingCode.code.expression,
85
+ // Explicitly set the import path to null since we deal with imports here separately.
86
+ null);
87
+ (0, util_1.applyChangesToFile)(tree, modulePath, changes);
88
+ },
89
+ ]);
90
+ };
91
+ }
92
+ /**
93
+ * Adds a provider to the root of a standalone project.
94
+ * @param host Tree of the root rule.
95
+ * @param pendingCode Code that should be inserted.
96
+ * @param mainFilePath Path to the project's main file.
97
+ * @param wrapperFunction Optional function with which to wrap the provider.
98
+ */
99
+ function addProviderToStandaloneBootstrap(host, pendingCode, mainFilePath, wrapperFunction) {
100
+ const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
101
+ const fileToEdit = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath)?.filePath || mainFilePath;
102
+ const { code, rules } = code_block_1.CodeBlock.transformPendingCode(pendingCode, fileToEdit);
103
+ return (0, schematics_1.chain)([
104
+ ...rules,
105
+ () => {
106
+ let wrapped;
107
+ let additionalRules;
108
+ if (wrapperFunction) {
109
+ const block = new code_block_1.CodeBlock();
110
+ const result = code_block_1.CodeBlock.transformPendingCode(block.code `${block.external(wrapperFunction.name, wrapperFunction.module)}(${code.expression})`, fileToEdit);
111
+ wrapped = result.code;
112
+ additionalRules = result.rules;
113
+ }
114
+ else {
115
+ wrapped = code;
116
+ additionalRules = [];
117
+ }
118
+ return (0, schematics_1.chain)([
119
+ ...additionalRules,
120
+ tree => insertStandaloneRootProvider(tree, mainFilePath, wrapped.expression),
121
+ ]);
122
+ },
123
+ ]);
124
+ }
125
+ /**
126
+ * Inserts a string expression into the root of a standalone project.
127
+ * @param tree File tree used to modify the project.
128
+ * @param mainFilePath Path to the main file of the project.
129
+ * @param expression Code expression to be inserted.
130
+ */
131
+ function insertStandaloneRootProvider(tree, mainFilePath, expression) {
132
+ const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(tree, mainFilePath);
133
+ const appConfig = (0, app_config_1.findAppConfig)(bootstrapCall, tree, mainFilePath);
134
+ if (bootstrapCall.arguments.length === 0) {
135
+ throw new schematics_1.SchematicsException(`Cannot add provider to invalid bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
136
+ }
137
+ if (appConfig) {
138
+ addProvidersExpressionToAppConfig(tree, appConfig, expression);
139
+ return;
140
+ }
141
+ const newAppConfig = `, {\n${core_1.tags.indentBy(2) `providers: [${expression}]`}\n}`;
142
+ let targetCall;
143
+ if (bootstrapCall.arguments.length === 1) {
144
+ targetCall = bootstrapCall;
145
+ }
146
+ else if ((0, util_1.isMergeAppConfigCall)(bootstrapCall.arguments[1])) {
147
+ targetCall = bootstrapCall.arguments[1];
148
+ }
149
+ else {
150
+ throw new schematics_1.SchematicsException(`Cannot statically analyze bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
151
+ }
152
+ (0, util_1.applyChangesToFile)(tree, mainFilePath, [
153
+ (0, ast_utils_1.insertAfterLastOccurrence)(targetCall.arguments, newAppConfig, mainFilePath, targetCall.getEnd() - 1),
154
+ ]);
155
+ }
156
+ /**
157
+ * Adds a string expression to an app config object.
158
+ * @param tree File tree used to modify the project.
159
+ * @param appConfig Resolved configuration object of the project.
160
+ * @param expression Code expression to be inserted.
161
+ */
162
+ function addProvidersExpressionToAppConfig(tree, appConfig, expression) {
163
+ const { node, filePath } = appConfig;
164
+ const configProps = node.properties;
165
+ const providersLiteral = (0, util_1.findProvidersLiteral)(node);
166
+ // If there's a `providers` property, we can add the provider
167
+ // to it, otherwise we need to declare it ourselves.
168
+ if (providersLiteral) {
169
+ (0, util_1.applyChangesToFile)(tree, filePath, [
170
+ (0, ast_utils_1.insertAfterLastOccurrence)(providersLiteral.elements, (providersLiteral.elements.length === 0 ? '' : ', ') + expression, filePath, providersLiteral.getStart() + 1),
171
+ ]);
172
+ }
173
+ else {
174
+ const prop = core_1.tags.indentBy(2) `providers: [${expression}]`;
175
+ let toInsert;
176
+ let insertPosition;
177
+ if (configProps.length === 0) {
178
+ toInsert = '\n' + prop + '\n';
179
+ insertPosition = node.getEnd() - 1;
180
+ }
181
+ else {
182
+ const hasTrailingComma = configProps.hasTrailingComma;
183
+ toInsert = (hasTrailingComma ? '' : ',') + '\n' + prop;
184
+ insertPosition = configProps[configProps.length - 1].getEnd() + (hasTrailingComma ? 1 : 0);
185
+ }
186
+ (0, util_1.applyChangesToFile)(tree, filePath, [new change_1.InsertChange(filePath, insertPosition, toInsert)]);
187
+ }
188
+ }
189
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../packages/schematics/src/utils/angular/standalone/rules.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAA4C;AAC5C,2DAAoF;AAEpF,4CAAsF;AACtF,sCAAyC;AACzC,kDAAoE;AACpE,6CAAgE;AAChE,6CAAyE;AACzE,iCAOgB;AAEhB;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,QAA2B;IACxE,OAAO,oBAAoB,CA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SAC5F;QAED,IAAA,yBAAkB,EAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,qBAAY,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;KAC5F;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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.dev/license
7
+ */
8
+ import { Tree } from '@angular-devkit/schematics';
9
+ import * as ts from 'typescript';
10
+ import { Change } from '../change';
11
+ /**
12
+ * Finds the main file of a project.
13
+ * @param tree File tree for the project.
14
+ * @param projectName Name of the project in which to search.
15
+ */
16
+ export declare function getMainFilePath(tree: Tree, projectName: string): Promise<string>;
17
+ /**
18
+ * Gets a TypeScript source file at a specific path.
19
+ * @param tree File tree of a project.
20
+ * @param path Path to the file.
21
+ */
22
+ export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile;
23
+ /** Finds the call to `bootstrapApplication` within a file. */
24
+ export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression;
25
+ /**
26
+ * Applies a set of changes to a file.
27
+ * @param tree File tree of the project.
28
+ * @param path Path to the file that is being changed.
29
+ * @param changes Changes that should be applied to the file.
30
+ */
31
+ export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void;
32
+ /** Checks whether a node is a call to `mergeApplicationConfig`. */
33
+ export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression;
34
+ /** Finds the `providers` array literal within an application config. */
35
+ export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.findProvidersLiteral = exports.isMergeAppConfigCall = exports.applyChangesToFile = exports.findBootstrapApplicationCall = exports.getSourceFile = exports.getMainFilePath = void 0;
11
+ const schematics_1 = require("@angular-devkit/schematics");
12
+ const ts = require("typescript");
13
+ const change_1 = require("../change");
14
+ const project_targets_1 = require("../project-targets");
15
+ const workspace_1 = require("../workspace");
16
+ const workspace_models_1 = require("../workspace-models");
17
+ /**
18
+ * Finds the main file of a project.
19
+ * @param tree File tree for the project.
20
+ * @param projectName Name of the project in which to search.
21
+ */
22
+ async function getMainFilePath(tree, projectName) {
23
+ const workspace = await (0, workspace_1.getWorkspace)(tree);
24
+ const project = workspace.projects.get(projectName);
25
+ const buildTarget = project?.targets.get('build');
26
+ if (!buildTarget) {
27
+ throw (0, project_targets_1.targetBuildNotFoundError)();
28
+ }
29
+ const options = buildTarget.options;
30
+ return buildTarget.builder === workspace_models_1.Builders.Application ||
31
+ buildTarget.builder === workspace_models_1.Builders.BuildApplication
32
+ ? options.browser
33
+ : options.main;
34
+ }
35
+ exports.getMainFilePath = getMainFilePath;
36
+ /**
37
+ * Gets a TypeScript source file at a specific path.
38
+ * @param tree File tree of a project.
39
+ * @param path Path to the file.
40
+ */
41
+ function getSourceFile(tree, path) {
42
+ const content = tree.readText(path);
43
+ const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
44
+ return source;
45
+ }
46
+ exports.getSourceFile = getSourceFile;
47
+ /** Finds the call to `bootstrapApplication` within a file. */
48
+ function findBootstrapApplicationCall(tree, mainFilePath) {
49
+ const sourceFile = getSourceFile(tree, mainFilePath);
50
+ const localName = findImportLocalName(sourceFile, 'bootstrapApplication', '@angular/platform-browser');
51
+ if (localName) {
52
+ let result = null;
53
+ sourceFile.forEachChild(function walk(node) {
54
+ if (ts.isCallExpression(node) &&
55
+ ts.isIdentifier(node.expression) &&
56
+ node.expression.text === localName) {
57
+ result = node;
58
+ }
59
+ if (!result) {
60
+ node.forEachChild(walk);
61
+ }
62
+ });
63
+ if (result) {
64
+ return result;
65
+ }
66
+ }
67
+ throw new schematics_1.SchematicsException(`Could not find bootstrapApplication call in ${mainFilePath}`);
68
+ }
69
+ exports.findBootstrapApplicationCall = findBootstrapApplicationCall;
70
+ /**
71
+ * Finds the local name of an imported symbol. Could be the symbol name itself or its alias.
72
+ * @param sourceFile File within which to search for the import.
73
+ * @param name Actual name of the import, not its local alias.
74
+ * @param moduleName Name of the module from which the symbol is imported.
75
+ */
76
+ function findImportLocalName(sourceFile, name, moduleName) {
77
+ for (const node of sourceFile.statements) {
78
+ // Only look for top-level imports.
79
+ if (!ts.isImportDeclaration(node) ||
80
+ !ts.isStringLiteral(node.moduleSpecifier) ||
81
+ node.moduleSpecifier.text !== moduleName) {
82
+ continue;
83
+ }
84
+ // Filter out imports that don't have the right shape.
85
+ if (!node.importClause ||
86
+ !node.importClause.namedBindings ||
87
+ !ts.isNamedImports(node.importClause.namedBindings)) {
88
+ continue;
89
+ }
90
+ // Look through the elements of the declaration for the specific import.
91
+ for (const element of node.importClause.namedBindings.elements) {
92
+ if ((element.propertyName || element.name).text === name) {
93
+ // The local name is always in `name`.
94
+ return element.name.text;
95
+ }
96
+ }
97
+ }
98
+ return null;
99
+ }
100
+ /**
101
+ * Applies a set of changes to a file.
102
+ * @param tree File tree of the project.
103
+ * @param path Path to the file that is being changed.
104
+ * @param changes Changes that should be applied to the file.
105
+ */
106
+ function applyChangesToFile(tree, path, changes) {
107
+ if (changes.length > 0) {
108
+ const recorder = tree.beginUpdate(path);
109
+ (0, change_1.applyToUpdateRecorder)(recorder, changes);
110
+ tree.commitUpdate(recorder);
111
+ }
112
+ }
113
+ exports.applyChangesToFile = applyChangesToFile;
114
+ /** Checks whether a node is a call to `mergeApplicationConfig`. */
115
+ function isMergeAppConfigCall(node) {
116
+ if (!ts.isCallExpression(node)) {
117
+ return false;
118
+ }
119
+ const localName = findImportLocalName(node.getSourceFile(), 'mergeApplicationConfig', '@angular/core');
120
+ return !!localName && ts.isIdentifier(node.expression) && node.expression.text === localName;
121
+ }
122
+ exports.isMergeAppConfigCall = isMergeAppConfigCall;
123
+ /** Finds the `providers` array literal within an application config. */
124
+ function findProvidersLiteral(config) {
125
+ for (const prop of config.properties) {
126
+ if (ts.isPropertyAssignment(prop) &&
127
+ ts.isIdentifier(prop.name) &&
128
+ prop.name.text === 'providers' &&
129
+ ts.isArrayLiteralExpression(prop.initializer)) {
130
+ return prop.initializer;
131
+ }
132
+ }
133
+ return null;
134
+ }
135
+ exports.findProvidersLiteral = findProvidersLiteral;
136
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../../../packages/schematics/src/utils/angular/standalone/util.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2DAAuE;AACvE,iCAAiC;AACjC,sCAA0D;AAC1D,wDAA8D;AAC9D,4CAA4C;AAC5C,0DAA+C;AAE/C;;;;GAIG;AACI,KAAK,UAAU,eAAe,CAAC,IAAU,EAAE,WAAmB;IACnE,MAAM,SAAS,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAElD,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAA,0CAAwB,GAAE,CAAC;KAClC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,OAAiC,CAAC;IAE9D,OAAO,WAAW,CAAC,OAAO,KAAK,2BAAQ,CAAC,WAAW;QACjD,WAAW,CAAC,OAAO,KAAK,2BAAQ,CAAC,gBAAgB;QACjD,CAAC,CAAC,OAAO,CAAC,OAAO;QACjB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AACnB,CAAC;AAfD,0CAeC;AAED;;;;GAIG;AACH,SAAgB,aAAa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S,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC;AAC/F,CAAC;AAZD,oDAYC;AAED,wEAAwE;AACxE,SAAgB,oBAAoB,CAClC,MAAkC;IAElC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,UAAU,EAAE;QACpC,IACE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAC7B,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;YAC9B,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,EAC7C;YACA,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAfD,oDAeC"}
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export declare const htmlSelectorRe: RegExp;
9
9
  export declare function validateHtmlSelector(selector: string): void;
@@ -4,14 +4,14 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.validateClassName = exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
11
11
  const schematics_1 = require("@angular-devkit/schematics");
12
12
  // Must start with a letter, and must contain only alphanumeric characters or dashes.
13
13
  // When adding a dash the segment after the dash must also start with a letter.
14
- exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
14
+ exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
15
15
  // See: https://github.com/tc39/proposal-regexp-unicode-property-escapes/blob/fe6d07fad74cd0192d154966baa1e95e7cda78a1/README.md#other-examples
16
16
  const ecmaIdentifierNameRegExp = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
17
17
  function validateHtmlSelector(selector) {
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/angular/validation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2DAAiE;AAEjE,qFAAqF;AACrF,+EAA+E;AAClE,QAAA,cAAc,GAAG,oDAAoD,CAAC;AAEnF,+IAA+I;AAC/I,MAAM,wBAAwB,GAAG,6DAA6D,CAAC;AAE/F,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,IAAI,QAAQ,IAAI,CAAC,sBAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC9C,MAAM,IAAI,gCAAmB,CAAC,aAAa,QAAQ,eAAe,CAAC,CAAC;KACrE;AACH,CAAC;AAJD,oDAIC;AAED,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,IAAI,gCAAmB,CAAC,eAAe,SAAS,eAAe,CAAC,CAAC;KACxE;AACH,CAAC;AAJD,8CAIC"}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/angular/validation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2DAAiE;AAEjE,qFAAqF;AACrF,+EAA+E;AAClE,QAAA,cAAc,GACzB,+EAA+E,CAAC;AAElF,+IAA+I;AAC/I,MAAM,wBAAwB,GAAG,6DAA6D,CAAC;AAE/F,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,IAAI,QAAQ,IAAI,CAAC,sBAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC9C,MAAM,IAAI,gCAAmB,CAAC,aAAa,QAAQ,eAAe,CAAC,CAAC;KACrE;AACH,CAAC;AAJD,oDAIC;AAED,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,IAAI,gCAAmB,CAAC,eAAe,SAAS,eAAe,CAAC,CAAC;KACxE;AACH,CAAC;AAJD,8CAIC"}
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export declare enum ProjectType {
9
9
  Application = "application",
@@ -16,16 +16,24 @@ export declare enum ProjectType {
16
16
  * `angular.json` workspace file.
17
17
  */
18
18
  export declare enum Builders {
19
+ Application = "@angular-devkit/build-angular:application",
19
20
  AppShell = "@angular-devkit/build-angular:app-shell",
20
21
  Server = "@angular-devkit/build-angular:server",
21
22
  Browser = "@angular-devkit/build-angular:browser",
23
+ SsrDevServer = "@angular-devkit/build-angular:ssr-dev-server",
24
+ Prerender = "@angular-devkit/build-angular:prerender",
25
+ BrowserEsbuild = "@angular-devkit/build-angular:browser-esbuild",
22
26
  Karma = "@angular-devkit/build-angular:karma",
27
+ BuildKarma = "@angular/build:karma",
23
28
  TsLint = "@angular-devkit/build-angular:tslint",
24
- DeprecatedNgPackagr = "@angular-devkit/build-ng-packagr:build",
25
29
  NgPackagr = "@angular-devkit/build-angular:ng-packagr",
30
+ BuildNgPackagr = "@angular/build:ng-packagr",
26
31
  DevServer = "@angular-devkit/build-angular:dev-server",
32
+ BuildDevServer = "@angular/build:dev-server",
27
33
  ExtractI18n = "@angular-devkit/build-angular:extract-i18n",
28
- Protractor = "@angular-devkit/build-angular:protractor"
34
+ BuildExtractI18n = "@angular/build:extract-i18n",
35
+ Protractor = "@angular-devkit/build-angular:private-protractor",
36
+ BuildApplication = "@angular/build:application"
29
37
  }
30
38
  export interface FileReplacements {
31
39
  replace: string;
@@ -63,7 +71,7 @@ export interface BrowserBuilderOptions extends BrowserBuilderBaseOptions {
63
71
  webWorkerTsConfig?: string;
64
72
  }
65
73
  export interface ServeBuilderOptions {
66
- browserTarget: string;
74
+ buildTarget: string;
67
75
  }
68
76
  export interface LibraryBuilderOptions {
69
77
  tsConfig: string;
@@ -119,11 +127,9 @@ export declare type E2EBuilderTarget = BuilderTarget<Builders.Protractor, E2EOpt
119
127
  interface WorkspaceCLISchema {
120
128
  warnings?: Record<string, boolean>;
121
129
  schematicCollections?: string[];
122
- defaultCollection?: string;
123
130
  }
124
131
  export interface WorkspaceSchema {
125
132
  version: 1;
126
- defaultProject?: string;
127
133
  cli?: WorkspaceCLISchema;
128
134
  projects: {
129
135
  [key: string]: WorkspaceProject<ProjectType.Application | ProjectType.Library>;
@@ -4,7 +4,7 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Builders = exports.ProjectType = void 0;
@@ -21,15 +21,23 @@ var ProjectType;
21
21
  */
22
22
  var Builders;
23
23
  (function (Builders) {
24
+ Builders["Application"] = "@angular-devkit/build-angular:application";
24
25
  Builders["AppShell"] = "@angular-devkit/build-angular:app-shell";
25
26
  Builders["Server"] = "@angular-devkit/build-angular:server";
26
27
  Builders["Browser"] = "@angular-devkit/build-angular:browser";
28
+ Builders["SsrDevServer"] = "@angular-devkit/build-angular:ssr-dev-server";
29
+ Builders["Prerender"] = "@angular-devkit/build-angular:prerender";
30
+ Builders["BrowserEsbuild"] = "@angular-devkit/build-angular:browser-esbuild";
27
31
  Builders["Karma"] = "@angular-devkit/build-angular:karma";
32
+ Builders["BuildKarma"] = "@angular/build:karma";
28
33
  Builders["TsLint"] = "@angular-devkit/build-angular:tslint";
29
- Builders["DeprecatedNgPackagr"] = "@angular-devkit/build-ng-packagr:build";
30
34
  Builders["NgPackagr"] = "@angular-devkit/build-angular:ng-packagr";
35
+ Builders["BuildNgPackagr"] = "@angular/build:ng-packagr";
31
36
  Builders["DevServer"] = "@angular-devkit/build-angular:dev-server";
37
+ Builders["BuildDevServer"] = "@angular/build:dev-server";
32
38
  Builders["ExtractI18n"] = "@angular-devkit/build-angular:extract-i18n";
33
- Builders["Protractor"] = "@angular-devkit/build-angular:protractor";
39
+ Builders["BuildExtractI18n"] = "@angular/build:extract-i18n";
40
+ Builders["Protractor"] = "@angular-devkit/build-angular:private-protractor";
41
+ Builders["BuildApplication"] = "@angular/build:application";
34
42
  })(Builders = exports.Builders || (exports.Builders = {}));
35
43
  //# sourceMappingURL=workspace-models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-models.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/angular/workspace-models.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,0CAA2B,CAAA;IAC3B,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAED;;;;;GAKG;AACH,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,gEAAoD,CAAA;IACpD,2DAA+C,CAAA;IAC/C,6DAAiD,CAAA;IACjD,yDAA6C,CAAA;IAC7C,2DAA+C,CAAA;IAC/C,0EAA8D,CAAA;IAC9D,kEAAsD,CAAA;IACtD,kEAAsD,CAAA;IACtD,sEAA0D,CAAA;IAC1D,mEAAuD,CAAA;AACzD,CAAC,EAXW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAWnB"}
1
+ {"version":3,"file":"workspace-models.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/utils/angular/workspace-models.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,0CAA2B,CAAA;IAC3B,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAED;;;;;GAKG;AACH,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IAClB,qEAAyD,CAAA;IACzD,gEAAoD,CAAA;IACpD,2DAA+C,CAAA;IAC/C,6DAAiD,CAAA;IACjD,yEAA6D,CAAA;IAC7D,iEAAqD,CAAA;IACrD,4EAAgE,CAAA;IAChE,yDAA6C,CAAA;IAC7C,+CAAmC,CAAA;IACnC,2DAA+C,CAAA;IAC/C,kEAAsD,CAAA;IACtD,wDAA4C,CAAA;IAC5C,kEAAsD,CAAA;IACtD,wDAA4C,CAAA;IAC5C,sEAA0D,CAAA;IAC1D,4DAAgD,CAAA;IAChD,2EAA+D,CAAA;IAC/D,2DAA+C,CAAA;AACjD,CAAC,EAnBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAmBnB"}
@@ -3,13 +3,24 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { json, workspaces } from '@angular-devkit/core';
9
9
  import { Rule, Tree } from '@angular-devkit/schematics';
10
10
  export declare type WorkspaceDefinition = workspaces.WorkspaceDefinition;
11
11
  export declare type ProjectDefinition = workspaces.ProjectDefinition;
12
12
  export declare type TargetDefinition = workspaces.TargetDefinition;
13
+ /**
14
+ * A {@link workspaces.WorkspaceHost} backed by a Schematics {@link Tree} instance.
15
+ */
16
+ export declare class TreeWorkspaceHost implements workspaces.WorkspaceHost {
17
+ private readonly tree;
18
+ constructor(tree: Tree);
19
+ readFile(path: string): Promise<string>;
20
+ writeFile(path: string, data: string): Promise<void>;
21
+ isDirectory(path: string): Promise<boolean>;
22
+ isFile(path: string): Promise<boolean>;
23
+ }
13
24
  /**
14
25
  * Updates the workspace file (`angular.json`) found within the root of the schematic's tree.
15
26
  * The workspace object model can be directly modified within the provided updater function
@@ -4,10 +4,10 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.allTargetOptions = exports.allWorkspaceTargets = exports.createDefaultPath = exports.buildDefaultPath = exports.writeWorkspace = exports.getWorkspace = exports.updateWorkspace = void 0;
10
+ exports.allTargetOptions = exports.allWorkspaceTargets = exports.createDefaultPath = exports.buildDefaultPath = exports.writeWorkspace = exports.getWorkspace = exports.updateWorkspace = exports.TreeWorkspaceHost = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const schematics_1 = require("@angular-devkit/schematics");
13
13
  const workspace_models_1 = require("./workspace-models");
@@ -38,6 +38,7 @@ class TreeWorkspaceHost {
38
38
  return this.tree.exists(path);
39
39
  }
40
40
  }
41
+ exports.TreeWorkspaceHost = TreeWorkspaceHost;
41
42
  /**
42
43
  * Updates the workspace file (`angular.json`) found within the root of the schematic's tree.
43
44
  * The workspace object model can be directly modified within the provided updater function
@@ -49,11 +50,10 @@ class TreeWorkspaceHost {
49
50
  * workspace. A {@link WorkspaceDefinition} is provided as the first argument to the function.
50
51
  */
51
52
  function updateWorkspace(updater) {
52
- return async (tree) => {
53
- const host = new TreeWorkspaceHost(tree);
54
- const { workspace } = await core_1.workspaces.readWorkspace(DEFAULT_WORKSPACE_PATH, host);
53
+ return async (host) => {
54
+ const workspace = await getWorkspace(host);
55
55
  const result = await updater(workspace);
56
- await core_1.workspaces.writeWorkspace(workspace, host);
56
+ await core_1.workspaces.writeWorkspace(workspace, new TreeWorkspaceHost(host));
57
57
  return result || schematics_1.noop;
58
58
  };
59
59
  }