@skyux/packages 15.0.0-alpha.8 → 15.0.0-beta.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.
- package/migrations.json +19 -9
- package/package.json +61 -61
- package/src/schematics/migrations/update-15/add-compat-stylesheets/add-compat-stylesheet.schematic.js +103 -15
- package/src/schematics/migrations/update-15/add-compat-stylesheets/add-compat-stylesheet.schematic.js.map +1 -1
- package/src/schematics/migrations/update-15/fluid-grid-inset/fluid-grid-inset.schematic.d.ts +8 -0
- package/src/schematics/migrations/update-15/fluid-grid-inset/fluid-grid-inset.schematic.js +173 -0
- package/src/schematics/migrations/update-15/fluid-grid-inset/fluid-grid-inset.schematic.js.map +1 -0
- package/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.d.ts +13 -2
- package/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.js +426 -4
- package/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.js.map +1 -1
- package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.d.ts +7 -0
- package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.js +98 -0
- package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.js.map +1 -0
- package/src/schematics/ng-generate/add-skyux-to-project/add-skyux-to-project.schematic.js +4 -15
- package/src/schematics/ng-generate/add-skyux-to-project/add-skyux-to-project.schematic.js.map +1 -1
- package/src/schematics/ng-generate/migrate-karma-to-vitest/migrate-karma-to-vitest.schematic.js +8 -0
- package/src/schematics/ng-generate/migrate-karma-to-vitest/migrate-karma-to-vitest.schematic.js.map +1 -1
- package/src/schematics/rules/add-ag-grid-styles-config.js +2 -11
- package/src/schematics/rules/add-ag-grid-styles-config.js.map +1 -1
- package/src/schematics/rules/convert-grid-to-data-grid/convert-grid-to-data-grid.js +5 -4
- package/src/schematics/rules/convert-grid-to-data-grid/convert-grid-to-data-grid.js.map +1 -1
- package/src/schematics/rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header.js +1 -1
- package/src/schematics/rules/convert-progress-indicator-wizard-to-tab-wizard/convert-progress-indicator-wizard-to-tab-wizard.js +1 -1
- package/src/schematics/rules/workspace-check/workspace-check.js +2 -7
- package/src/schematics/rules/workspace-check/workspace-check.js.map +1 -1
- package/src/schematics/utility/builders.d.ts +7 -0
- package/src/schematics/utility/builders.js +28 -0
- package/src/schematics/utility/builders.js.map +1 -0
- package/src/schematics/utility/typescript/ng-ast.d.ts +8 -0
- package/src/schematics/utility/typescript/ng-ast.js +41 -20
- package/src/schematics/utility/typescript/ng-ast.js.map +1 -1
- package/src/schematics/utility/typescript/remove-class-reference.d.ts +7 -6
- package/src/schematics/utility/typescript/remove-class-reference.js +39 -14
- package/src/schematics/utility/typescript/remove-class-reference.js.map +1 -1
- package/src/schematics/utility/typescript/swap-imported-class.d.ts +7 -0
- package/src/schematics/utility/typescript/swap-imported-class.js +24 -8
- package/src/schematics/utility/typescript/swap-imported-class.js.map +1 -1
- package/src/version.js +1 -1
package/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
6
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
7
|
+
const eol_1 = require("@schematics/angular/utility/eol");
|
|
5
8
|
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
9
|
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
7
10
|
const ng_ast_1 = require("../../../utility/typescript/ng-ast");
|
|
@@ -12,6 +15,27 @@ const CLASS_NAMES = {
|
|
|
12
15
|
SkyAppResourcesService: 'SkyAppResourcesLegacyService',
|
|
13
16
|
SkyLibResourcesService: 'SkyLibResourcesLegacyService',
|
|
14
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* The declarations that can shadow a service class name in a file, and so rule
|
|
20
|
+
* that name out for an inserted provider.
|
|
21
|
+
*/
|
|
22
|
+
const DECLARATION_KINDS = new Set([
|
|
23
|
+
typescript_1.default.SyntaxKind.ImportClause,
|
|
24
|
+
typescript_1.default.SyntaxKind.NamespaceImport,
|
|
25
|
+
typescript_1.default.SyntaxKind.ImportEqualsDeclaration,
|
|
26
|
+
typescript_1.default.SyntaxKind.ClassDeclaration,
|
|
27
|
+
typescript_1.default.SyntaxKind.ClassExpression,
|
|
28
|
+
typescript_1.default.SyntaxKind.InterfaceDeclaration,
|
|
29
|
+
typescript_1.default.SyntaxKind.TypeAliasDeclaration,
|
|
30
|
+
typescript_1.default.SyntaxKind.TypeParameter,
|
|
31
|
+
typescript_1.default.SyntaxKind.EnumDeclaration,
|
|
32
|
+
typescript_1.default.SyntaxKind.ModuleDeclaration,
|
|
33
|
+
typescript_1.default.SyntaxKind.FunctionDeclaration,
|
|
34
|
+
typescript_1.default.SyntaxKind.FunctionExpression,
|
|
35
|
+
typescript_1.default.SyntaxKind.VariableDeclaration,
|
|
36
|
+
typescript_1.default.SyntaxKind.Parameter,
|
|
37
|
+
typescript_1.default.SyntaxKind.BindingElement,
|
|
38
|
+
]);
|
|
15
39
|
/**
|
|
16
40
|
* Whether the reference is the `SkyLibResourcesService.addResources()` static
|
|
17
41
|
* call. Only the observables returned by the instance methods changed, so
|
|
@@ -23,6 +47,372 @@ function isStaticAddResourcesReference(node) {
|
|
|
23
47
|
parent.expression === node &&
|
|
24
48
|
parent.name.text === 'addResources');
|
|
25
49
|
}
|
|
50
|
+
function isWrappedExpression(node) {
|
|
51
|
+
return (typescript_1.default.isParenthesizedExpression(node) ||
|
|
52
|
+
typescript_1.default.isAssertionExpression(node) ||
|
|
53
|
+
typescript_1.default.isSatisfiesExpression(node) ||
|
|
54
|
+
typescript_1.default.isNonNullExpression(node));
|
|
55
|
+
}
|
|
56
|
+
function getOuterExpression(node) {
|
|
57
|
+
while (isWrappedExpression(node.parent)) {
|
|
58
|
+
node = node.parent;
|
|
59
|
+
}
|
|
60
|
+
return node;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The provider object literal in which `node` is the value of `propertyName`,
|
|
64
|
+
* e.g. `{ provide: SkyAppResourcesService, ... }` for `provide`, or
|
|
65
|
+
* `undefined` when `node` sits anywhere else.
|
|
66
|
+
*/
|
|
67
|
+
function getProviderObjectLiteral(node, propertyName) {
|
|
68
|
+
const expression = getOuterExpression(node);
|
|
69
|
+
const propertyAssignment = expression.parent;
|
|
70
|
+
if (!typescript_1.default.isPropertyAssignment(propertyAssignment) ||
|
|
71
|
+
propertyAssignment.initializer !== expression ||
|
|
72
|
+
propertyAssignment.name.getText() !== propertyName) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
return propertyAssignment.parent;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The array elements through which `objectLiteral` reaches a
|
|
79
|
+
* `providers: [...]` list -- the object literal itself when it's written
|
|
80
|
+
* inline, or every reference to the variable it was assigned to, e.g.
|
|
81
|
+
* `const resourcesProvider = { provide: SkyAppResourcesService, ... };` used
|
|
82
|
+
* as `providers: [resourcesProvider]`. Empty when the object never reaches an
|
|
83
|
+
* array.
|
|
84
|
+
*/
|
|
85
|
+
function getProviderArrayElements(objectLiteral, sourceFile, checker) {
|
|
86
|
+
const expression = getOuterExpression(objectLiteral);
|
|
87
|
+
if (typescript_1.default.isArrayLiteralExpression(expression.parent)) {
|
|
88
|
+
return [expression];
|
|
89
|
+
}
|
|
90
|
+
const variable = expression.parent;
|
|
91
|
+
if (!typescript_1.default.isVariableDeclaration(variable) || !typescript_1.default.isIdentifier(variable.name)) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const variableName = variable.name.text;
|
|
95
|
+
return (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.Identifier)
|
|
96
|
+
.filter((reference) => typescript_1.default.isIdentifier(reference) &&
|
|
97
|
+
reference.text === variableName &&
|
|
98
|
+
reference !== variable.name &&
|
|
99
|
+
checker.getSymbolAtLocation(reference) ===
|
|
100
|
+
checker.getSymbolAtLocation(variable.name))
|
|
101
|
+
.map(getOuterExpression)
|
|
102
|
+
.filter((element) => typescript_1.default.isArrayLiteralExpression(element.parent));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The array elements after which `token`'s legacy twin provider belongs, or
|
|
106
|
+
* an empty array when `token` isn't the `provide:` token of a provider that
|
|
107
|
+
* reaches a `providers: [...]` list.
|
|
108
|
+
*/
|
|
109
|
+
function getTwinInsertionPoints(token, sourceFile, checker) {
|
|
110
|
+
const objectLiteral = getProviderObjectLiteral(token, 'provide');
|
|
111
|
+
return objectLiteral
|
|
112
|
+
? getProviderArrayElements(objectLiteral, sourceFile, checker)
|
|
113
|
+
: [];
|
|
114
|
+
}
|
|
115
|
+
function isImportedService(node, className, checker) {
|
|
116
|
+
const symbol = typescript_1.default.isShorthandPropertyAssignment(node.parent)
|
|
117
|
+
? checker.getShorthandAssignmentValueSymbol(node.parent)
|
|
118
|
+
: typescript_1.default.isExportSpecifier(node.parent)
|
|
119
|
+
? checker.getExportSpecifierLocalTargetSymbol(node.parent)
|
|
120
|
+
: checker.getSymbolAtLocation(node);
|
|
121
|
+
return (symbol?.declarations?.some((declaration) => typescript_1.default.isImportSpecifier(declaration) &&
|
|
122
|
+
(declaration.propertyName ?? declaration.name).text === className &&
|
|
123
|
+
typescript_1.default.isStringLiteral(declaration.parent.parent.parent.moduleSpecifier) &&
|
|
124
|
+
declaration.parent.parent.parent.moduleSpecifier.text === MODULE_NAME) ?? false);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Whether `objectLiteral` is a provider whose `provide` token is
|
|
128
|
+
* the imported legacy service, including an existing aliased import.
|
|
129
|
+
*/
|
|
130
|
+
function isLegacyProvider(objectLiteral, legacyClassName, checker) {
|
|
131
|
+
return objectLiteral.properties.some((property) => {
|
|
132
|
+
if (!typescript_1.default.isPropertyAssignment(property) ||
|
|
133
|
+
property.name.getText() !== 'provide') {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
let token = property.initializer;
|
|
137
|
+
while (isWrappedExpression(token)) {
|
|
138
|
+
token = token.expression;
|
|
139
|
+
}
|
|
140
|
+
return (typescript_1.default.isIdentifier(token) &&
|
|
141
|
+
isImportedService(token, legacyClassName, checker));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Whether the reference is a provider token that must not be renamed: either
|
|
146
|
+
* the `provide:` token of a provider registered in a `providers: [...]` list,
|
|
147
|
+
* or the `useExisting:` token of a legacy provider alias.
|
|
148
|
+
* The `provide:` token is duplicated rather than renamed -- see
|
|
149
|
+
* `duplicateProviderTokens` -- since test doubles registered under the
|
|
150
|
+
* original token would otherwise stop matching the pipe and matchers that
|
|
151
|
+
* still inject it, and the twin's `useExisting:` token has to keep pointing at
|
|
152
|
+
* it. An existing legacy provider alias must likewise keep that target to
|
|
153
|
+
* avoid aliasing the legacy service to itself. Any other `useExisting:` token
|
|
154
|
+
* is a consumer's own alias, and its injectors expect the legacy behavior,
|
|
155
|
+
* so it is renamed like a normal
|
|
156
|
+
* reference.
|
|
157
|
+
*/
|
|
158
|
+
function isProviderToken(node, sourceFile, checker) {
|
|
159
|
+
const useExistingLiteral = getProviderObjectLiteral(node, 'useExisting');
|
|
160
|
+
const objectLiteral = getProviderObjectLiteral(node, 'provide') ??
|
|
161
|
+
(useExistingLiteral &&
|
|
162
|
+
isLegacyProvider(useExistingLiteral, CLASS_NAMES[node.text], checker)
|
|
163
|
+
? useExistingLiteral
|
|
164
|
+
: undefined);
|
|
165
|
+
return (!!objectLiteral &&
|
|
166
|
+
getProviderArrayElements(objectLiteral, sourceFile, checker).length > 0);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The whitespace between the start of `node`'s line and `node` itself, used
|
|
170
|
+
* to indent an inserted sibling the same as the node it follows. Returns
|
|
171
|
+
* `undefined` when `node` isn't the first thing on its line (e.g. a
|
|
172
|
+
* single-line `providers: [{ provide: X, ... }]`) -- the text preceding it
|
|
173
|
+
* on the line is code, not indentation, and repeating it would corrupt the
|
|
174
|
+
* file.
|
|
175
|
+
*/
|
|
176
|
+
function getLineIndent(node, sourceFile) {
|
|
177
|
+
const text = sourceFile.text;
|
|
178
|
+
const lineStart = text.lastIndexOf('\n', node.getStart() - 1) + 1;
|
|
179
|
+
const prefix = text.slice(lineStart, node.getStart());
|
|
180
|
+
return /^\s*$/.test(prefix) ? prefix : undefined;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The provider object literal `element` stands for: the element itself when
|
|
184
|
+
* the provider is written inline, or the object literal the variable was
|
|
185
|
+
* initialized with, e.g. `const legacyProvider = { ... };` listed as
|
|
186
|
+
* `providers: [legacyProvider]`.
|
|
187
|
+
*/
|
|
188
|
+
function getProviderFromArrayElement(element, checker) {
|
|
189
|
+
while (isWrappedExpression(element)) {
|
|
190
|
+
element = element.expression;
|
|
191
|
+
}
|
|
192
|
+
if (typescript_1.default.isObjectLiteralExpression(element)) {
|
|
193
|
+
return element;
|
|
194
|
+
}
|
|
195
|
+
if (!typescript_1.default.isIdentifier(element)) {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
const declaration = checker.getSymbolAtLocation(element)?.valueDeclaration;
|
|
199
|
+
let initializer = declaration && typescript_1.default.isVariableDeclaration(declaration)
|
|
200
|
+
? declaration.initializer
|
|
201
|
+
: undefined;
|
|
202
|
+
while (initializer && isWrappedExpression(initializer)) {
|
|
203
|
+
initializer = initializer.expression;
|
|
204
|
+
}
|
|
205
|
+
return initializer && typescript_1.default.isObjectLiteralExpression(initializer)
|
|
206
|
+
? initializer
|
|
207
|
+
: undefined;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Whether `array` already lists a provider whose `provide` token is
|
|
211
|
+
* the legacy service, either inline or through a variable. Keeps the migration
|
|
212
|
+
* idempotent: re-running it, or running it against a file someone already
|
|
213
|
+
* hand-fixed, doesn't add a second twin. It also keeps an explicit legacy
|
|
214
|
+
* provider's precedence -- the last provider for a token wins, so a twin
|
|
215
|
+
* inserted after it would override it.
|
|
216
|
+
*/
|
|
217
|
+
function arrayHasLegacyProvider(array, legacyClassName, checker) {
|
|
218
|
+
return array.elements.some((element) => {
|
|
219
|
+
const provider = getProviderFromArrayElement(element, checker);
|
|
220
|
+
return !!provider && isLegacyProvider(provider, legacyClassName, checker);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Whether `specifier` imports `className` from `MODULE_NAME`.
|
|
225
|
+
* Such a binding can be reused; an import of a different service cannot.
|
|
226
|
+
*/
|
|
227
|
+
function isServiceImportSpecifier(specifier, className) {
|
|
228
|
+
const moduleSpecifier = specifier.parent.parent.parent.moduleSpecifier;
|
|
229
|
+
return (typescript_1.default.isStringLiteral(moduleSpecifier) &&
|
|
230
|
+
moduleSpecifier.text === MODULE_NAME &&
|
|
231
|
+
(specifier.propertyName ?? specifier.name).text === className);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The name `node` binds, when it's a declaration that binds one. Covers the
|
|
235
|
+
* declarations that could shadow a service class name; import specifiers are
|
|
236
|
+
* handled separately, since the migration's own are exempt.
|
|
237
|
+
*/
|
|
238
|
+
function getDeclaredName(node) {
|
|
239
|
+
if (!DECLARATION_KINDS.has(node.kind)) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const name = node.name;
|
|
243
|
+
// A destructured variable declares a binding pattern rather than a name.
|
|
244
|
+
return name?.kind === typescript_1.default.SyntaxKind.Identifier
|
|
245
|
+
? name.text
|
|
246
|
+
: undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Every name `sourceFile` binds, apart from `className` imports
|
|
250
|
+
* from `MODULE_NAME`. An inserted provider can't reference a service class
|
|
251
|
+
* under a name in this set -- the file already means something else by it.
|
|
252
|
+
*/
|
|
253
|
+
function getBoundNames(sourceFile, className) {
|
|
254
|
+
const names = new Set();
|
|
255
|
+
const visit = (node) => {
|
|
256
|
+
if (typescript_1.default.isImportSpecifier(node)) {
|
|
257
|
+
if (!isServiceImportSpecifier(node, className)) {
|
|
258
|
+
names.add(node.name.text);
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const declaredName = getDeclaredName(node);
|
|
263
|
+
if (declaredName) {
|
|
264
|
+
names.add(declaredName);
|
|
265
|
+
}
|
|
266
|
+
typescript_1.default.forEachChild(node, visit);
|
|
267
|
+
};
|
|
268
|
+
typescript_1.default.forEachChild(sourceFile, visit);
|
|
269
|
+
return names;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The name to reference each service class by in `sourceFile`, keyed by its
|
|
273
|
+
* exported name. Normally the class name itself, but a suffixed
|
|
274
|
+
* alias when the file already binds that name to something of its own -- the
|
|
275
|
+
* inserted provider and its import would otherwise redeclare it.
|
|
276
|
+
*/
|
|
277
|
+
function getServiceLocalNames(sourceFile) {
|
|
278
|
+
const localNames = {};
|
|
279
|
+
Object.entries(CLASS_NAMES)
|
|
280
|
+
.flat()
|
|
281
|
+
.forEach((className) => {
|
|
282
|
+
const boundNames = getBoundNames(sourceFile, className);
|
|
283
|
+
let localName = className;
|
|
284
|
+
let suffix = 0;
|
|
285
|
+
while (boundNames.has(localName)) {
|
|
286
|
+
suffix += 1;
|
|
287
|
+
localName = `${className}_${suffix}`;
|
|
288
|
+
}
|
|
289
|
+
localNames[className] = localName;
|
|
290
|
+
});
|
|
291
|
+
return localNames;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* For every `provide:` token referencing a renamed class, inserts a twin
|
|
295
|
+
* provider aliasing the legacy class to it, e.g.
|
|
296
|
+
* `{ provide: SkyAppResourcesService, useClass: SkyAppResourcesTestService }`
|
|
297
|
+
* gets a
|
|
298
|
+
* `{ provide: SkyAppResourcesLegacyService, useExisting: SkyAppResourcesService }`
|
|
299
|
+
* sibling. `useExisting` rather than a copy of the original provider's
|
|
300
|
+
* configuration: both tokens must resolve to the same instance, which copying
|
|
301
|
+
* a `useClass` or `useFactory` provider would not do. Returns the imports the
|
|
302
|
+
* twins require, including an alias for an original token when its name is
|
|
303
|
+
* shadowed at a provider variable's use site.
|
|
304
|
+
*/
|
|
305
|
+
function duplicateProviderTokens(recorder, sourceFile, eol, localNames, checker) {
|
|
306
|
+
const requiredImports = new Map();
|
|
307
|
+
Object.entries(CLASS_NAMES).forEach(([oldClassName, legacyClassName]) => {
|
|
308
|
+
const legacyLocalName = localNames[legacyClassName];
|
|
309
|
+
const originalLocalName = localNames[oldClassName];
|
|
310
|
+
const tokens = (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.Identifier).filter((node) => typescript_1.default.isIdentifier(node) &&
|
|
311
|
+
node.text === oldClassName &&
|
|
312
|
+
isImportedService(node, oldClassName, checker));
|
|
313
|
+
tokens.forEach((token) => {
|
|
314
|
+
getTwinInsertionPoints(token, sourceFile, checker).forEach((element) => {
|
|
315
|
+
const array = element.parent;
|
|
316
|
+
if (arrayHasLegacyProvider(array, legacyClassName, checker)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const indent = getLineIndent(element, sourceFile);
|
|
320
|
+
const separator = indent === undefined ? ' ' : `${eol}${indent}`;
|
|
321
|
+
recorder.insertRight(element.getEnd(), `,${separator}{ provide: ${legacyLocalName}, useExisting: ${originalLocalName} }`);
|
|
322
|
+
requiredImports.set(legacyClassName, legacyLocalName);
|
|
323
|
+
if (originalLocalName !== oldClassName) {
|
|
324
|
+
requiredImports.set(oldClassName, originalLocalName);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
return requiredImports;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The named import binding `className` from `MODULE_NAME` as
|
|
333
|
+
* `localName`, if the file has one. The specifier may be type-only, which
|
|
334
|
+
* doesn't satisfy the inserted provider -- see `ensureServiceImport`.
|
|
335
|
+
*/
|
|
336
|
+
function findServiceImportSpecifier(sourceFile, className, localName) {
|
|
337
|
+
for (const node of (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.ImportDeclaration)) {
|
|
338
|
+
if (!typescript_1.default.isImportDeclaration(node) ||
|
|
339
|
+
!typescript_1.default.isStringLiteral(node.moduleSpecifier) ||
|
|
340
|
+
node.moduleSpecifier.text !== MODULE_NAME) {
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
344
|
+
if (!namedBindings || !typescript_1.default.isNamedImports(namedBindings)) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const specifier = namedBindings.elements.find((element) => (element.propertyName ?? element.name).text === className &&
|
|
348
|
+
element.name.text === localName);
|
|
349
|
+
if (specifier) {
|
|
350
|
+
return specifier;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Whether `specifier` only brings in a type, either through
|
|
357
|
+
* `import type { X }` or `import { type X }`.
|
|
358
|
+
*/
|
|
359
|
+
function isTypeOnlyImport(specifier) {
|
|
360
|
+
return specifier.isTypeOnly || specifier.parent.parent.isTypeOnly;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Turns a type-only import of `specifier` into a value import by dropping its
|
|
364
|
+
* `type` keyword. Adding a second declaration for a name the file already
|
|
365
|
+
* binds would be a duplicate identifier.
|
|
366
|
+
*/
|
|
367
|
+
function removeTypeKeyword(recorder, specifier) {
|
|
368
|
+
const [typeKeywordStart, bindingStart] = specifier.isTypeOnly
|
|
369
|
+
? [
|
|
370
|
+
specifier.getStart(),
|
|
371
|
+
(specifier.propertyName ?? specifier.name).getStart(),
|
|
372
|
+
]
|
|
373
|
+
: [specifier.parent.parent.getStart(), specifier.parent.getStart()];
|
|
374
|
+
recorder.remove(typeKeywordStart, bindingStart - typeKeywordStart);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Adds an import declaration of its own after the file's last import, for the
|
|
378
|
+
* cases `insertImport` can't merge into an existing one.
|
|
379
|
+
*/
|
|
380
|
+
function insertImportDeclaration(recorder, sourceFile, className, localName) {
|
|
381
|
+
const endOfImports = (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.ImportDeclaration).reduce((max, node) => Math.max(max, node.getEnd()), 0);
|
|
382
|
+
const binding = localName === className ? className : `${className} as ${localName}`;
|
|
383
|
+
recorder.insertRight(endOfImports, `${(0, eol_1.getEOL)(sourceFile.text)}import { ${binding} } from '${MODULE_NAME}';`);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Binds `className` as a value from `MODULE_NAME` under `localName` so
|
|
387
|
+
* the twin providers `duplicateProviderTokens` inserted resolve.
|
|
388
|
+
* `swapImportedClass` adds the legacy import itself whenever it renames a
|
|
389
|
+
* non-provider reference. Original tokens can also need an unshadowed alias,
|
|
390
|
+
* and an existing type-only import must become a value import.
|
|
391
|
+
*/
|
|
392
|
+
function ensureServiceImport(tree, filePath, className, localName) {
|
|
393
|
+
const sourceFile = (0, ng_ast_1.parseSourceFile)(tree, filePath);
|
|
394
|
+
const specifier = findServiceImportSpecifier(sourceFile, className, localName);
|
|
395
|
+
if (specifier && !isTypeOnlyImport(specifier)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const recorder = tree.beginUpdate(filePath);
|
|
399
|
+
if (specifier) {
|
|
400
|
+
removeTypeKeyword(recorder, specifier);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
// `insertImport` no-ops when the module is already bound under another
|
|
404
|
+
// name -- an alias, or a namespace import -- so a declaration of our own
|
|
405
|
+
// is the fallback.
|
|
406
|
+
const change = (0, ast_utils_1.insertImport)(sourceFile, filePath, className, MODULE_NAME, false, localName === className ? undefined : localName);
|
|
407
|
+
if (change instanceof change_1.NoopChange) {
|
|
408
|
+
insertImportDeclaration(recorder, sourceFile, className, localName);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
(0, change_1.applyToUpdateRecorder)(recorder, [change]);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
tree.commitUpdate(recorder);
|
|
415
|
+
}
|
|
26
416
|
async function updateSourceFiles(tree) {
|
|
27
417
|
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
28
418
|
workspace.projects.forEach((project) => {
|
|
@@ -34,22 +424,54 @@ async function updateSourceFiles(tree) {
|
|
|
34
424
|
if (!Object.keys(CLASS_NAMES).some((name) => content.includes(name))) {
|
|
35
425
|
return;
|
|
36
426
|
}
|
|
427
|
+
const sourceFile = (0, ng_ast_1.parseSourceFile)(tree, filePath);
|
|
428
|
+
// Only local bindings are needed; do not load dependencies or lib files.
|
|
429
|
+
const options = {
|
|
430
|
+
noLib: true,
|
|
431
|
+
noResolve: true,
|
|
432
|
+
types: [],
|
|
433
|
+
};
|
|
434
|
+
const checker = typescript_1.default
|
|
435
|
+
.createProgram([sourceFile.fileName], options, {
|
|
436
|
+
...typescript_1.default.createCompilerHost(options),
|
|
437
|
+
getSourceFile: () => sourceFile,
|
|
438
|
+
})
|
|
439
|
+
.getTypeChecker();
|
|
440
|
+
const localNames = getServiceLocalNames(sourceFile);
|
|
37
441
|
const recorder = tree.beginUpdate(filePath);
|
|
38
|
-
(0, swap_imported_class_1.swapImportedClass)(recorder, filePath,
|
|
442
|
+
(0, swap_imported_class_1.swapImportedClass)(recorder, filePath, sourceFile, [
|
|
39
443
|
{
|
|
40
444
|
classNames: CLASS_NAMES,
|
|
41
445
|
moduleName: MODULE_NAME,
|
|
42
|
-
|
|
446
|
+
localNames,
|
|
447
|
+
filter: (node) => isImportedService(node, node.text, checker) &&
|
|
448
|
+
!isStaticAddResourcesReference(node) &&
|
|
449
|
+
!isProviderToken(node, sourceFile, checker),
|
|
43
450
|
},
|
|
44
451
|
]);
|
|
452
|
+
const requiredImports = duplicateProviderTokens(recorder, sourceFile, (0, eol_1.getEOL)(sourceFile.text), localNames, checker);
|
|
45
453
|
tree.commitUpdate(recorder);
|
|
454
|
+
requiredImports.forEach((localName, className) => {
|
|
455
|
+
ensureServiceImport(tree, filePath, className, localName);
|
|
456
|
+
});
|
|
46
457
|
});
|
|
47
458
|
});
|
|
48
459
|
}
|
|
49
460
|
/**
|
|
50
461
|
* Replaces the resources services with their "legacy" equivalents, which emit
|
|
51
|
-
* once and complete. The original services now emit again whenever the
|
|
52
|
-
* changes.
|
|
462
|
+
* once and complete. The original services now emit again whenever the
|
|
463
|
+
* locale changes.
|
|
464
|
+
*
|
|
465
|
+
* A `provide:` token inside a `providers: [...]` array (e.g. a test's
|
|
466
|
+
* `TestBed.configureTestingModule`) is duplicated instead of renamed: the
|
|
467
|
+
* original provider stays, and a `useExisting` twin for the legacy token is
|
|
468
|
+
* added right after it unless that array already provides the legacy service.
|
|
469
|
+
* Provider variables are resolved within their lexical scope, including
|
|
470
|
+
* parenthesized expressions, type assertions, and `satisfies` expressions.
|
|
471
|
+
* The `skyAppResources` pipe and the `toHaveResourceText`/`toEqualResourceText`
|
|
472
|
+
* matchers still inject the
|
|
473
|
+
* original service, so renaming the provider outright would leave them
|
|
474
|
+
* resolving against the real, un-mocked service.
|
|
53
475
|
*/
|
|
54
476
|
function default_1() {
|
|
55
477
|
return async (tree) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-i18n-services.schematic.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/packages/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.ts"],"names":[],"mappings":";;AAkEA,4BAIC;;AArED,qEAAqE;AAErE,oEAA4B;AAE5B,+DAAqE;AACrE,yFAAoF;AACpF,8EAAyE;AAEzE,MAAM,WA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WAAW;oBACvB,MAAM,EAAE,CAAC,IAAI,EAAW,EAAE,CAAC,CAAC,6BAA6B,CAAC,IAAI,CAAC;iBAChE;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH;IACE,OAAO,KAAK,EAAE,IAAU,EAAiB,EAAE;QACzC,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"legacy-i18n-services.schematic.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/packages/src/schematics/migrations/update-15/legacy-i18n-services/legacy-i18n-services.schematic.ts"],"names":[],"mappings":";;AAqrBA,4BAIC;;AAxrBD,qEAAgF;AAChF,+DAG4C;AAC5C,yDAAyD;AACzD,qEAAqE;AAErE,oEAA4B;AAE5B,+DAAqE;AACrE,yFAAoF;AACpF,8EAAyE;AAEzE,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,MAAM,WAAW,GAA2B;IAC1C,sBAAsB,EAAE,8BAA8B;IACtD,sBAAsB,EAAE,8BAA8B;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAgB;IAC/C,oBAAE,CAAC,UAAU,CAAC,YAAY;IAC1B,oBAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,oBAAE,CAAC,UAAU,CAAC,uBAAuB;IACrC,oBAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,oBAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,oBAAE,CAAC,UAAU,CAAC,oBAAoB;IAClC,oBAAE,CAAC,UAAU,CAAC,oBAAoB;IAClC,oBAAE,CAAC,UAAU,CAAC,aAAa;IAC3B,oBAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,oBAAE,CAAC,UAAU,CAAC,iBAAiB;IAC/B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OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBAC/C,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH;IACE,OAAO,KAAK,EAAE,IAAU,EAAiB,EAAE;QACzC,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
/**
|
|
3
|
+
* Removes the `SkySelectFieldModule` import from projects that no longer
|
|
4
|
+
* reference `<sky-select-field>` in any template, and drops the
|
|
5
|
+
* `@skyux/select-field` dependency once nothing in the workspace imports it.
|
|
6
|
+
*/
|
|
7
|
+
export default function (): Rule;
|
package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
5
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
+
const dependencies_2 = require("../../../utility/dependencies");
|
|
7
|
+
const log_once_1 = require("../../../utility/log-once");
|
|
8
|
+
const template_1 = require("../../../utility/template");
|
|
9
|
+
const ng_ast_1 = require("../../../utility/typescript/ng-ast");
|
|
10
|
+
const remove_class_reference_1 = require("../../../utility/typescript/remove-class-reference");
|
|
11
|
+
const visit_project_files_1 = require("../../../utility/visit-project-files");
|
|
12
|
+
const workspace_2 = require("../../../utility/workspace");
|
|
13
|
+
const SELECTOR = 'sky-select-field';
|
|
14
|
+
const CLASS_NAME = 'SkySelectFieldModule';
|
|
15
|
+
const PACKAGE_NAME = '@skyux/select-field';
|
|
16
|
+
function contentHasSelector(content) {
|
|
17
|
+
return (0, template_1.getElementsByTagName)(SELECTOR, (0, template_1.parseTemplate)(content)).length > 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* True if any `.html` template or inline `@Component({ template })` anywhere
|
|
21
|
+
* in the project contains a `<sky-select-field>` element.
|
|
22
|
+
*/
|
|
23
|
+
function projectUsesSelectField(tree, sourceRoot) {
|
|
24
|
+
let used = false;
|
|
25
|
+
(0, visit_project_files_1.visitProjectFiles)(tree, sourceRoot, (filePath) => {
|
|
26
|
+
if (used) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (filePath.endsWith('.html')) {
|
|
30
|
+
const content = tree.readText(filePath);
|
|
31
|
+
if (content.includes(`<${SELECTOR}`) && contentHasSelector(content)) {
|
|
32
|
+
used = true;
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (filePath.endsWith('.ts') && !filePath.endsWith('.d.ts')) {
|
|
37
|
+
const content = tree.readText(filePath);
|
|
38
|
+
if (!content.includes(`<${SELECTOR}`)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const source = (0, ng_ast_1.parseSourceFile)(tree, filePath);
|
|
42
|
+
used = (0, ng_ast_1.getInlineTemplates)(source).some((template) => contentHasSelector(content.slice(template.start, template.end)));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return used;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Removes `SkySelectFieldModule` from every decorator `imports` and
|
|
49
|
+
* `exports` array and every `TestBed.configureTestingModule` `imports`
|
|
50
|
+
* array (and the now-unused import statement) throughout the project.
|
|
51
|
+
*/
|
|
52
|
+
function removeModuleReferences(tree, sourceRoot, context) {
|
|
53
|
+
(0, visit_project_files_1.visitProjectFiles)(tree, sourceRoot, (filePath) => {
|
|
54
|
+
if (!filePath.endsWith('.ts') || filePath.endsWith('.d.ts')) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const content = tree.readText(filePath);
|
|
58
|
+
if (!content.includes(CLASS_NAME)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const source = (0, ng_ast_1.parseSourceFile)(tree, filePath);
|
|
62
|
+
// `SkySelectFieldModule` may be imported under an alias (`SkySelectFieldModule
|
|
63
|
+
// as Foo`); `removeClassReference`/`removeImport` match on the local
|
|
64
|
+
// identifier, so resolve it (and confirm the import exists) up front.
|
|
65
|
+
const localName = (0, ng_ast_1.getLocalImportName)(source, CLASS_NAME, PACKAGE_NAME);
|
|
66
|
+
if (!localName) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const recorder = tree.beginUpdate(filePath);
|
|
70
|
+
const removed = (0, remove_class_reference_1.removeClassReference)(recorder, source, localName, PACKAGE_NAME, ['imports', 'exports']);
|
|
71
|
+
if (removed) {
|
|
72
|
+
tree.commitUpdate(recorder);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
(0, log_once_1.logOnce)(context, 'warn', `The "${CLASS_NAME}" import in "${filePath}" was kept because it is referenced outside a decorator "imports"/"exports" array or a "TestBed.configureTestingModule" "imports" array. Remove the import manually if it is no longer needed.`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the `SkySelectFieldModule` import from projects that no longer
|
|
81
|
+
* reference `<sky-select-field>` in any template, and drops the
|
|
82
|
+
* `@skyux/select-field` dependency once nothing in the workspace imports it.
|
|
83
|
+
*/
|
|
84
|
+
function default_1() {
|
|
85
|
+
return async (tree, context) => {
|
|
86
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
87
|
+
for (const project of workspace.projects.values()) {
|
|
88
|
+
const sourceRoot = (0, workspace_2.getSourceRoot)(project);
|
|
89
|
+
if (!projectUsesSelectField(tree, sourceRoot)) {
|
|
90
|
+
removeModuleReferences(tree, sourceRoot, context);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!(await (0, dependencies_2.isPackageUsed)(tree, PACKAGE_NAME))) {
|
|
94
|
+
(0, dependencies_1.removePackageJsonDependency)(tree, PACKAGE_NAME);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=remove-select-field.schematic.js.map
|
package/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-select-field.schematic.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/packages/src/schematics/migrations/update-15/remove-select-field/remove-select-field.schematic.ts"],"names":[],"mappings":";;AAmHA,4BAeC;AAjID,2EAAuF;AACvF,qEAAqE;AAErE,gEAA8D;AAC9D,wDAAoD;AACpD,wDAAgF;AAChF,+DAI4C;AAC5C,+FAA0F;AAC1F,8EAAyE;AACzE,0DAA2D;AAE3D,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C,SAAS,kBAAkB,CAAC,OAAe;IACzC,OAAO,IAAA,+BAAoB,EAAC,QAAQ,EAAE,IAAA,wBAAa,EAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAAC,IAAU,EAAE,UAAkB;IAC5D,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,IAAA,uCAAiB,EAAC,IAAI,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC/C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM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AED,IAAI,CAAC,CAAC,MAAM,IAAA,4BAAa,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC;YAC/C,IAAA,0CAA2B,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = addSkyuxToProject;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const utility_1 = require("@schematics/angular/utility");
|
|
6
|
-
const
|
|
7
|
-
'@angular/build:application',
|
|
8
|
-
'@angular-devkit/build-angular:application',
|
|
9
|
-
'@angular-devkit/build-angular:browser',
|
|
10
|
-
'@blackbaud-internal/skyux-angular-builders:browser',
|
|
11
|
-
'@blackbaud-internal/skyux-build:application',
|
|
12
|
-
];
|
|
13
|
-
const SUPPORTED_TEST_BUILDERS = [
|
|
14
|
-
'@angular/build:karma',
|
|
15
|
-
'@angular-devkit/build-angular:karma',
|
|
16
|
-
'@blackbaud-internal/skyux-angular-builders:karma',
|
|
17
|
-
];
|
|
6
|
+
const builders_1 = require("../../utility/builders");
|
|
18
7
|
function addSkyuxToProject(options) {
|
|
19
8
|
const { project: projectName } = options;
|
|
20
9
|
return () => {
|
|
@@ -30,7 +19,8 @@ function modifyWorkspaceConfig(projectName) {
|
|
|
30
19
|
}
|
|
31
20
|
function configureAllowedCommonJsDependencies(project) {
|
|
32
21
|
const target = project.targets.get('build');
|
|
33
|
-
if (target &&
|
|
22
|
+
if (target &&
|
|
23
|
+
builders_1.WEBPACK_BUILDERS.concat(builders_1.ESBUILD_BUILDERS).includes(target.builder)) {
|
|
34
24
|
target.options ??= {};
|
|
35
25
|
target.options['allowedCommonJsDependencies'] ??= [];
|
|
36
26
|
const allowedCommonJsDependencies = target.options['allowedCommonJsDependencies'];
|
|
@@ -45,10 +35,9 @@ function configureStyles(project) {
|
|
|
45
35
|
'@skyux/theme/css/sky.css',
|
|
46
36
|
'@skyux/theme/css/themes/modern/styles.css',
|
|
47
37
|
];
|
|
48
|
-
const supportedBuilders = SUPPORTED_BUILD_BUILDERS.concat(SUPPORTED_TEST_BUILDERS);
|
|
49
38
|
for (const target of ['build', 'test']) {
|
|
50
39
|
const def = project.targets.get(target);
|
|
51
|
-
if (def &&
|
|
40
|
+
if (def && (0, builders_1.builderHasStylesOption)(def.builder)) {
|
|
52
41
|
def.options ??= {};
|
|
53
42
|
def.options['styles'] ??= [];
|
|
54
43
|
const stylesheets = def.options['styles'];
|