@nstudio/angular 17.0.1 → 19.0.0-alpha.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/package.json +3 -3
- package/src/utils/ast.js +20 -20
- package/src/utils/testing.js +1 -1
- package/src/utils/versions.d.ts +6 -6
- package/src/utils/versions.js +7 -7
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nstudio/angular",
|
3
|
-
"version": "
|
3
|
+
"version": "19.0.0-alpha.0",
|
4
4
|
"description": "Angular Plugin for xplat",
|
5
5
|
"homepage": "https://nstudio.io/xplat",
|
6
6
|
"repository": {
|
@@ -29,9 +29,9 @@
|
|
29
29
|
"migrations": "./migrations.json"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@nx/angular": "^
|
32
|
+
"@nx/angular": "^19.0.0"
|
33
33
|
},
|
34
34
|
"peerDependencies": {
|
35
|
-
"@nstudio/xplat": "
|
35
|
+
"@nstudio/xplat": "19.0.0-alpha.0"
|
36
36
|
}
|
37
37
|
}
|
package/src/utils/ast.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getTsSourceFile = exports.getDecoratorPropertyValueNode = exports.readBootstrapInfo = exports.addEntryComponents = exports.addDeclarationToModule = exports.addProviderToComponent = exports.addProviderToModule = exports.addProviderToBootstrapApplication = exports.addRouteToNgModule = exports.getBootstrapComponent = exports.replaceIntoToTestBed = exports.addDeclarationsToTestBed = exports.addImportToTestBed = exports.addImportToModule = exports.addImportToPipe = exports.addImportToDirective = exports.addImportToComponent = exports.removeFromNgModule = exports._addSymbolToNgModuleMetadata = exports.getDecoratorMetadata = exports.isStandalone = exports.addToCollection = void 0;
|
4
4
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
5
|
-
const typescript_1 = require("nx/src/utils/typescript");
|
6
|
-
const ts = require("typescript");
|
7
5
|
const js_1 = require("@nx/js");
|
6
|
+
const ts = require("typescript");
|
7
|
+
const js_2 = require("@nx/js");
|
8
8
|
const path_1 = require("path");
|
9
9
|
const devkit_1 = require("@nx/devkit");
|
10
10
|
let tsModule;
|
@@ -16,15 +16,15 @@ function addToCollection(tree, source, barrelIndexPath, symbolName, insertSpaces
|
|
16
16
|
// return [new NoopChange()];
|
17
17
|
// console.log('collection.hasTrailingComma:', collection.hasTrailingComma);
|
18
18
|
if (collection.hasTrailingComma || collection.length === 0) {
|
19
|
-
return (0,
|
19
|
+
return (0, js_2.insertChange)(tree, source, barrelIndexPath, collection.end, symbolName);
|
20
20
|
}
|
21
21
|
else {
|
22
|
-
return (0,
|
22
|
+
return (0, js_2.insertChange)(tree, source, barrelIndexPath, collection.end, `,\n${insertSpaces}${symbolName}`);
|
23
23
|
}
|
24
24
|
}
|
25
25
|
exports.addToCollection = addToCollection;
|
26
26
|
function getCollection(source) {
|
27
|
-
const allCollections = (0,
|
27
|
+
const allCollections = (0, js_1.findNodes)(source, ts.SyntaxKind.ArrayLiteralExpression);
|
28
28
|
// console.log('allCollections:', allCollections);
|
29
29
|
// allCollections.forEach((i: ts.ArrayLiteralExpression) => {
|
30
30
|
// console.log('getText:',i.getText());
|
@@ -97,7 +97,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
97
97
|
if (!tsModule) {
|
98
98
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
99
99
|
}
|
100
|
-
const angularImports = (0,
|
100
|
+
const angularImports = (0, js_1.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration)
|
101
101
|
.map((node) => _angularImportsFromNode(node, source))
|
102
102
|
.reduce((acc, current) => {
|
103
103
|
for (const key of Object.keys(current)) {
|
@@ -105,7 +105,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
105
105
|
}
|
106
106
|
return acc;
|
107
107
|
}, {});
|
108
|
-
return (0,
|
108
|
+
return (0, js_2.getSourceNodes)(source)
|
109
109
|
.filter((node) => {
|
110
110
|
return (node.kind == tsModule.SyntaxKind.Decorator &&
|
111
111
|
node.expression.kind ==
|
@@ -186,7 +186,7 @@ function _addSymbolToDecoratorMetadata(host, source, filePath, metadataField, ex
|
|
186
186
|
toInsert = `, ${metadataField}: [${expression}]`;
|
187
187
|
}
|
188
188
|
}
|
189
|
-
return (0,
|
189
|
+
return (0, js_2.insertChange)(host, source, filePath, position, toInsert);
|
190
190
|
}
|
191
191
|
const assignment = matchingProperties[0];
|
192
192
|
// If it's not an array, nothing we can do really.
|
@@ -253,7 +253,7 @@ function _addSymbolToDecoratorMetadata(host, source, filePath, metadataField, ex
|
|
253
253
|
toInsert = `, ${expression}`;
|
254
254
|
}
|
255
255
|
}
|
256
|
-
return (0,
|
256
|
+
return (0, js_2.insertChange)(host, source, filePath, position, toInsert);
|
257
257
|
}
|
258
258
|
function _addSymbolToNgModuleMetadata(host, source, ngModulePath, metadataField, expression) {
|
259
259
|
return _addSymbolToDecoratorMetadata(host, source, ngModulePath, metadataField, expression, 'NgModule');
|
@@ -269,7 +269,7 @@ function removeFromNgModule(host, source, modulePath, property) {
|
|
269
269
|
// Get all the children property assignment of object literals.
|
270
270
|
const matchingProperty = getMatchingProperty(source, property, 'NgModule', '@angular/core');
|
271
271
|
if (matchingProperty) {
|
272
|
-
return (0,
|
272
|
+
return (0, js_2.removeChange)(host, source, modulePath, matchingProperty.getStart(source), matchingProperty.getFullText(source));
|
273
273
|
}
|
274
274
|
}
|
275
275
|
exports.removeFromNgModule = removeFromNgModule;
|
@@ -321,7 +321,7 @@ function addImportToTestBed(host, source, specPath, symbolName) {
|
|
321
321
|
if (!tsModule) {
|
322
322
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
323
323
|
}
|
324
|
-
const allCalls = ((0,
|
324
|
+
const allCalls = ((0, js_1.findNodes)(source, tsModule.SyntaxKind.CallExpression));
|
325
325
|
const configureTestingModuleObjectLiterals = allCalls
|
326
326
|
.filter((c) => c.expression.kind === tsModule.SyntaxKind.PropertyAccessExpression)
|
327
327
|
.filter((c) => c.expression.name.getText(source) === 'configureTestingModule')
|
@@ -332,7 +332,7 @@ function addImportToTestBed(host, source, specPath, symbolName) {
|
|
332
332
|
const startPosition = configureTestingModuleObjectLiterals[0]
|
333
333
|
.getFirstToken(source)
|
334
334
|
.getEnd();
|
335
|
-
return (0,
|
335
|
+
return (0, js_2.insertChange)(host, source, specPath, startPosition, `imports: [${symbolName}], `);
|
336
336
|
}
|
337
337
|
return source;
|
338
338
|
}
|
@@ -341,7 +341,7 @@ function addDeclarationsToTestBed(host, source, specPath, symbolName) {
|
|
341
341
|
if (!tsModule) {
|
342
342
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
343
343
|
}
|
344
|
-
const allCalls = ((0,
|
344
|
+
const allCalls = ((0, js_1.findNodes)(source, tsModule.SyntaxKind.CallExpression));
|
345
345
|
const configureTestingModuleObjectLiterals = allCalls
|
346
346
|
.filter((c) => c.expression.kind === tsModule.SyntaxKind.PropertyAccessExpression)
|
347
347
|
.filter((c) => c.expression.name.getText(source) === 'configureTestingModule')
|
@@ -352,7 +352,7 @@ function addDeclarationsToTestBed(host, source, specPath, symbolName) {
|
|
352
352
|
const startPosition = configureTestingModuleObjectLiterals[0]
|
353
353
|
.getFirstToken(source)
|
354
354
|
.getEnd();
|
355
|
-
return (0,
|
355
|
+
return (0, js_2.insertChange)(host, source, specPath, startPosition, `declarations: [${symbolName.join(',')}], `);
|
356
356
|
}
|
357
357
|
return source;
|
358
358
|
}
|
@@ -361,7 +361,7 @@ function replaceIntoToTestBed(host, source, specPath, newSymbol, previousSymbol)
|
|
361
361
|
if (!tsModule) {
|
362
362
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
363
363
|
}
|
364
|
-
const allCalls = ((0,
|
364
|
+
const allCalls = ((0, js_1.findNodes)(source, tsModule.SyntaxKind.CallExpression));
|
365
365
|
const configureTestingModuleObjectLiterals = allCalls
|
366
366
|
.filter((c) => c.expression.kind === tsModule.SyntaxKind.PropertyAccessExpression)
|
367
367
|
.filter((c) => c.expression.name.getText(source) === 'configureTestingModule')
|
@@ -372,7 +372,7 @@ function replaceIntoToTestBed(host, source, specPath, newSymbol, previousSymbol)
|
|
372
372
|
const startPosition = configureTestingModuleObjectLiterals[0]
|
373
373
|
.getFirstToken(source)
|
374
374
|
.getEnd();
|
375
|
-
return (0,
|
375
|
+
return (0, js_2.replaceChange)(host, source, specPath, startPosition, newSymbol, previousSymbol);
|
376
376
|
}
|
377
377
|
return source;
|
378
378
|
}
|
@@ -404,10 +404,10 @@ function addRouteToNgModule(host, ngModulePath, source, route) {
|
|
404
404
|
if (!routes)
|
405
405
|
return source;
|
406
406
|
if (routes.hasTrailingComma || routes.length === 0) {
|
407
|
-
return (0,
|
407
|
+
return (0, js_2.insertChange)(host, source, ngModulePath, routes.end, route);
|
408
408
|
}
|
409
409
|
else {
|
410
|
-
return (0,
|
410
|
+
return (0, js_2.insertChange)(host, source, ngModulePath, routes.end, `, ${route}`);
|
411
411
|
}
|
412
412
|
}
|
413
413
|
exports.addRouteToNgModule = addRouteToNgModule;
|
@@ -431,7 +431,7 @@ function getListOfRoutes(source) {
|
|
431
431
|
}
|
432
432
|
else if (routes.kind === tsModule.SyntaxKind.Identifier) {
|
433
433
|
// find the array expression
|
434
|
-
const variableDeclarations = (0,
|
434
|
+
const variableDeclarations = (0, js_1.findNodes)(source, tsModule.SyntaxKind.VariableDeclaration);
|
435
435
|
const routesDeclaration = variableDeclarations.find((x) => {
|
436
436
|
return x.name.getText() === routes.getText();
|
437
437
|
});
|
@@ -515,7 +515,7 @@ function readBootstrapInfo(host, app) {
|
|
515
515
|
}
|
516
516
|
const mainSource = host.read(mainPath).toString('utf-8');
|
517
517
|
const main = tsModule.createSourceFile(mainPath, mainSource, tsModule.ScriptTarget.Latest, true);
|
518
|
-
const moduleImports = (0,
|
518
|
+
const moduleImports = (0, js_2.getImport)(main, (s) => s.indexOf('.module') > -1);
|
519
519
|
if (moduleImports.length !== 1) {
|
520
520
|
throw new Error(`main.ts can only import a single module`);
|
521
521
|
}
|
package/src/utils/testing.js
CHANGED
@@ -7,7 +7,7 @@ const testing_1 = require("@angular-devkit/schematics/testing");
|
|
7
7
|
// import { names, toFileName } from '@nx/workspace';
|
8
8
|
const testRunner = new testing_1.SchematicTestRunner('@nstudio/angular', (0, path_1.join)(__dirname, '../../collection.json'));
|
9
9
|
function runSchematic(schematicName, options, tree) {
|
10
|
-
return testRunner.
|
10
|
+
return testRunner.runSchematic(schematicName, options, tree);
|
11
11
|
}
|
12
12
|
exports.runSchematic = runSchematic;
|
13
13
|
// export function runSchematicSync(
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
export declare const xplatVersion = "*";
|
2
|
-
export declare const nxVersion = "^
|
3
|
-
export declare const angularVersion = "^
|
4
|
-
export declare const angularDevkitVersion = "^
|
5
|
-
export declare const ngxTranslateVersion = "~
|
6
|
-
export declare const ngxTranslateHttpVersion = "~
|
2
|
+
export declare const nxVersion = "^19.0.0";
|
3
|
+
export declare const angularVersion = "^18.0.0";
|
4
|
+
export declare const angularDevkitVersion = "^18.0.0";
|
5
|
+
export declare const ngxTranslateVersion = "~15.0.0";
|
6
|
+
export declare const ngxTranslateHttpVersion = "~8.0.0";
|
7
7
|
export declare const rxjsVersion = "^7.8.0";
|
8
|
-
export declare const zonejsVersion = "~0.
|
8
|
+
export declare const zonejsVersion = "~0.14.0";
|
9
9
|
export declare const typesJest = "29.5.6";
|
package/src/utils/versions.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.typesJest = exports.zonejsVersion = exports.rxjsVersion = exports.ngxTranslateHttpVersion = exports.ngxTranslateVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = exports.xplatVersion = void 0;
|
4
|
-
exports.xplatVersion = '
|
5
|
-
exports.nxVersion = '^
|
6
|
-
exports.angularVersion = '^
|
7
|
-
exports.angularDevkitVersion = '^
|
8
|
-
exports.ngxTranslateVersion = '~
|
9
|
-
exports.ngxTranslateHttpVersion = '~
|
4
|
+
exports.xplatVersion = '19.0.0-alpha.0';
|
5
|
+
exports.nxVersion = '^19.0.0';
|
6
|
+
exports.angularVersion = '^18.0.0';
|
7
|
+
exports.angularDevkitVersion = '^18.0.0';
|
8
|
+
exports.ngxTranslateVersion = '~15.0.0';
|
9
|
+
exports.ngxTranslateHttpVersion = '~8.0.0';
|
10
10
|
exports.rxjsVersion = '^7.8.0';
|
11
|
-
exports.zonejsVersion = '~0.
|
11
|
+
exports.zonejsVersion = '~0.14.0';
|
12
12
|
exports.typesJest = '29.5.6';
|