@nstudio/angular 15.0.4-rc.1 → 16.5.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/README.md +21 -17
- package/collection.json +6 -1
- package/package.json +3 -3
- package/src/schematics/application/index.js +2 -2
- package/src/schematics/component/index.js +1 -1
- package/src/schematics/elements/index.js +10 -12
- package/src/schematics/feature/index.js +2 -2
- package/src/schematics/feature/index.spec.js +1 -1
- package/src/schematics/helpers/applitools/index.d.ts +2 -0
- package/src/schematics/helpers/applitools/index.js +115 -0
- package/src/schematics/helpers/applitools/index.js.map +1 -0
- package/src/schematics/helpers/index.d.ts +2 -0
- package/src/schematics/helpers/index.js +27 -0
- package/src/schematics/helpers/index.spec.d.ts +1 -0
- package/src/schematics/helpers/index.spec.js +95 -0
- package/src/schematics/helpers/schema.json +22 -0
- package/src/schematics/ngrx/_files/__name__.effects.spec.ts__tmpl__ +1 -1
- package/src/schematics/xplat/index.js +1 -1
- package/src/utils/ast.d.ts +75 -10
- package/src/utils/ast.js +261 -87
- package/src/utils/generator.js +58 -38
- package/src/utils/testing.js +2 -2
- package/src/utils/versions.d.ts +4 -5
- package/src/utils/versions.js +6 -7
- package/src/utils/xplat.js +7 -6
package/src/utils/generator.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.adjustSandbox = exports.adjustRouting = exports.adjustFeatureModuleForState = exports.adjustFeatureModule = exports.adjustModule = exports.adjustBarrelIndexForType = exports.adjustBarrelIndex = exports.adjustBarrel = exports.shouldTargetCoreBarrel = exports.isFeatureInGeneralBarrel = exports.addToFeature = exports.getNxFeaturePath = exports.getFeatureName = exports.generate = void 0;
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
5
|
-
const workspace_1 = require("@
|
5
|
+
const workspace_1 = require("@nx/workspace");
|
6
6
|
const xplat_1 = require("@nstudio/xplat");
|
7
7
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
8
8
|
const ast_1 = require("./ast");
|
@@ -331,12 +331,13 @@ function adjustBarrel(type, options, prefix) {
|
|
331
331
|
}
|
332
332
|
exports.adjustBarrel = adjustBarrel;
|
333
333
|
function adjustBarrelIndex(type, options, indexFilePath, inSubFolder, isBase, importIfSubFolder) {
|
334
|
-
return (host) => {
|
334
|
+
return (host, context) => {
|
335
|
+
const devKitTree = (0, xplat_1.convertNgTreeToDevKit)(host, context);
|
335
336
|
// console.log('adjustBarrelIndex:', indexFilePath);
|
336
337
|
// console.log('host.exists(indexFilePath):', host.exists(indexFilePath));
|
337
338
|
if (host.exists(indexFilePath)) {
|
338
339
|
const indexSource = host.read(indexFilePath).toString('utf-8');
|
339
|
-
|
340
|
+
let indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
340
341
|
const changes = [];
|
341
342
|
const name = options.name.toLowerCase();
|
342
343
|
if (!isBase && type !== 'service') {
|
@@ -346,45 +347,52 @@ function adjustBarrelIndex(type, options, indexFilePath, inSubFolder, isBase, im
|
|
346
347
|
const symbolName = `${xplat_1.stringUtils
|
347
348
|
.sanitize(options.subFolder)
|
348
349
|
.toUpperCase()}_${type.toUpperCase()}S`;
|
349
|
-
|
350
|
+
indexSourceFile = (0, xplat_1.addGlobal)(devKitTree, indexSourceFile, indexFilePath, `import { ${symbolName} } from './${options.subFolder}';`, false);
|
351
|
+
indexSourceFile = (0, ast_1.addToCollection)(devKitTree, indexSourceFile, indexFilePath, `...${symbolName}`, ' ');
|
352
|
+
changes.push(indexSourceFile);
|
350
353
|
}
|
351
354
|
else {
|
352
355
|
const symbolName = `${xplat_1.stringUtils.classify(name)}${xplat_1.stringUtils.capitalize(type)}`;
|
353
|
-
|
356
|
+
indexSourceFile = (0, xplat_1.addGlobal)(devKitTree, indexSourceFile, indexFilePath, `import { ${symbolName} } from './${inSubFolder ? `${name}/` : ''}${name}.${type}';`);
|
357
|
+
indexSourceFile = (0, ast_1.addToCollection)(devKitTree, indexSourceFile, indexFilePath, symbolName, ' ');
|
358
|
+
changes.push(indexSourceFile);
|
354
359
|
}
|
355
360
|
}
|
356
361
|
if (type === 'component' || type === 'service' || type === 'pipe') {
|
357
362
|
// export symbol from barrel
|
358
363
|
if ((isBase || importIfSubFolder) && options.subFolder) {
|
359
|
-
|
364
|
+
indexSourceFile = (0, xplat_1.addGlobal)(devKitTree, indexSourceFile, indexFilePath, `export * from './${options.subFolder}';`, true);
|
365
|
+
changes.push(indexSourceFile);
|
360
366
|
}
|
361
367
|
else {
|
362
368
|
const subFolder = inSubFolder ? `${name}/` : '';
|
363
|
-
|
369
|
+
indexSourceFile = (0, xplat_1.addGlobal)(devKitTree, indexSourceFile, indexFilePath, `export * from './${subFolder}${name}.${isBase ? 'base-' : ''}${type}';`, true);
|
370
|
+
changes.push(indexSourceFile);
|
364
371
|
}
|
365
372
|
}
|
366
|
-
|
373
|
+
// insert(devKitTree.tree, indexFilePath, changes);
|
367
374
|
}
|
368
375
|
else {
|
369
376
|
options.needsIndex = true;
|
370
377
|
}
|
371
|
-
return
|
378
|
+
return devKitTree.tree;
|
372
379
|
};
|
373
380
|
}
|
374
381
|
exports.adjustBarrelIndex = adjustBarrelIndex;
|
375
382
|
function adjustBarrelIndexForType(type, options, indexFilePath) {
|
376
|
-
return (host) => {
|
383
|
+
return (host, context) => {
|
384
|
+
const devKitTree = (0, xplat_1.convertNgTreeToDevKit)(host, context);
|
377
385
|
if (host.exists(indexFilePath)) {
|
378
386
|
const indexSource = host.read(indexFilePath).toString('utf-8');
|
379
387
|
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
380
388
|
const changes = [];
|
381
|
-
changes.push(
|
382
|
-
|
389
|
+
changes.push((0, xplat_1.addGlobal)(devKitTree, indexSourceFile, indexFilePath, `export * from './${type}';`, true));
|
390
|
+
// insert(devKitTree.tree, indexFilePath, changes);
|
383
391
|
}
|
384
392
|
else {
|
385
393
|
options.needsIndex = true;
|
386
394
|
}
|
387
|
-
return
|
395
|
+
return devKitTree.tree;
|
388
396
|
};
|
389
397
|
}
|
390
398
|
exports.adjustBarrelIndexForType = adjustBarrelIndexForType;
|
@@ -413,11 +421,12 @@ function adjustModule(tree, type, options, prefixPath) {
|
|
413
421
|
}
|
414
422
|
exports.adjustModule = adjustModule;
|
415
423
|
function adjustFeatureModule(type, options, modulePath) {
|
416
|
-
return (host) => {
|
424
|
+
return (host, context) => {
|
425
|
+
const devKitTree = (0, xplat_1.convertNgTreeToDevKit)(host, context);
|
417
426
|
// console.log('adjustFeatureModule:', modulePath);
|
418
427
|
if (host.exists(modulePath)) {
|
419
428
|
const moduleSource = host.read(modulePath).toString('utf-8');
|
420
|
-
const moduleSourceFile =
|
429
|
+
const moduleSourceFile = (0, ast_1.getTsSourceFile)(devKitTree, modulePath);
|
421
430
|
const changes = [];
|
422
431
|
let featureName;
|
423
432
|
if (options.feature) {
|
@@ -463,59 +472,70 @@ function adjustFeatureModule(type, options, modulePath) {
|
|
463
472
|
else {
|
464
473
|
if (type !== 'service') {
|
465
474
|
// add to module
|
466
|
-
changes.push(
|
467
|
-
changes.push(...(0, ast_1.addDeclarationToModule)(moduleSourceFile, modulePath, `...${collectionName}`), ...(0, ast_1.addSymbolToNgModuleMetadata)(moduleSourceFile, modulePath, 'exports', `...${collectionName}`));
|
475
|
+
changes.push((0, ast_1._addSymbolToNgModuleMetadata)(devKitTree, (0, ast_1.addDeclarationToModule)(devKitTree, (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { ${collectionName} } from './${type}s';`), modulePath, `...${collectionName}`), modulePath, 'exports', `...${collectionName}`));
|
468
476
|
}
|
469
|
-
|
477
|
+
// insert(devKitTree.tree, modulePath, changes);
|
470
478
|
}
|
471
479
|
}
|
472
|
-
return
|
480
|
+
return devKitTree.tree;
|
473
481
|
};
|
474
482
|
}
|
475
483
|
exports.adjustFeatureModule = adjustFeatureModule;
|
476
484
|
function adjustFeatureModuleForState(options, modulePath) {
|
477
|
-
return (host) => {
|
485
|
+
return (host, context) => {
|
486
|
+
const devKitTree = (0, xplat_1.convertNgTreeToDevKit)(host, context);
|
478
487
|
// console.log('adjustFeatureModuleForState:', modulePath);
|
479
488
|
if (host.exists(modulePath)) {
|
480
489
|
const moduleSource = host.read(modulePath).toString('utf-8');
|
481
|
-
|
490
|
+
let moduleSourceFile = ts.createSourceFile(modulePath, moduleSource, ts.ScriptTarget.Latest, true);
|
482
491
|
// console.log('moduleSource:', moduleSource);
|
483
492
|
const isInLibs = modulePath.indexOf('libs/xplat/core') === 0;
|
484
493
|
const name = options.name.toLowerCase();
|
485
494
|
const changes = [];
|
486
495
|
if (moduleSource.indexOf('StoreModule') === -1) {
|
487
|
-
|
496
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { StoreModule } from '@ngrx/store';`);
|
497
|
+
changes.push(moduleSourceFile);
|
488
498
|
}
|
489
499
|
if (moduleSource.indexOf('EffectsModule') === -1) {
|
490
|
-
|
500
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { EffectsModule } from '@ngrx/effects';`);
|
501
|
+
changes.push(moduleSourceFile);
|
491
502
|
}
|
492
|
-
|
503
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}Effects } from './state/${name}.effects';`);
|
504
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.camelize(name)}Reducer } from './state/${name}.reducer';`);
|
505
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}State } from './state/${name}.state';`);
|
506
|
+
changes.push(moduleSourceFile);
|
493
507
|
if (options.root) {
|
494
508
|
if (moduleSource.indexOf('environments/environment') === -1) {
|
495
509
|
const envFrom = isInLibs
|
496
510
|
? './environments/environment'
|
497
511
|
: `@${(0, xplat_utils_1.getNpmScope)()}/xplat/core`;
|
498
|
-
|
512
|
+
moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { environment } from '${envFrom}';`);
|
513
|
+
changes.push(moduleSourceFile);
|
499
514
|
}
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
515
|
+
moduleSourceFile = (0, ast_1.addImportToModule)(devKitTree, moduleSourceFile, modulePath, `StoreModule.forRoot(
|
516
|
+
{ ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.camelize(name)}Reducer },
|
517
|
+
{
|
518
|
+
initialState: { ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.classify(name)}State.initialState }
|
519
|
+
}
|
520
|
+
), EffectsModule.forRoot([${xplat_1.stringUtils.classify(name)}Effects])`);
|
521
|
+
moduleSourceFile = (0, ast_1.addProviderToModule)(devKitTree, moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`);
|
522
|
+
changes.push(moduleSourceFile);
|
506
523
|
}
|
507
524
|
else {
|
525
|
+
moduleSourceFile = (0, ast_1.addImportToModule)(devKitTree, moduleSourceFile, modulePath, `StoreModule.forFeature('${xplat_1.stringUtils.camelize(name)}', ${xplat_1.stringUtils.camelize(name)}Reducer, { initialState: ${xplat_1.stringUtils.classify(name)}State.initialState }), EffectsModule.forFeature([${xplat_1.stringUtils.classify(name)}Effects])`);
|
526
|
+
moduleSourceFile = (0, ast_1.addProviderToModule)(devKitTree, moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`);
|
508
527
|
// feature state
|
509
|
-
changes.push(
|
528
|
+
changes.push(moduleSourceFile);
|
510
529
|
}
|
511
|
-
|
530
|
+
// insert(devKitTree.tree, modulePath, changes);
|
512
531
|
}
|
513
|
-
return
|
532
|
+
return devKitTree.tree;
|
514
533
|
};
|
515
534
|
}
|
516
535
|
exports.adjustFeatureModuleForState = adjustFeatureModuleForState;
|
517
536
|
function adjustRouting(options, routingModulePaths, platform) {
|
518
|
-
return (host) => {
|
537
|
+
return (host, context) => {
|
538
|
+
const devKitTree = (0, xplat_1.convertNgTreeToDevKit)(host, context);
|
519
539
|
const featureName = options.name.toLowerCase();
|
520
540
|
let routingModulePath;
|
521
541
|
// check which routing naming convention might be in use
|
@@ -533,13 +553,13 @@ function adjustRouting(options, routingModulePaths, platform) {
|
|
533
553
|
const routingSourceFile = ts.createSourceFile(routingModulePath, routingSource, ts.ScriptTarget.Latest, true);
|
534
554
|
const changes = [];
|
535
555
|
// add component to route config
|
536
|
-
changes.push(
|
556
|
+
changes.push((0, ast_1.addToCollection)(devKitTree, routingSourceFile, routingModulePath, `{
|
537
557
|
path: '${featureName}',
|
538
558
|
loadChildren: () => import('./features/${options.directory ? options.directory + '/' : ''}${featureName}/${featureName}.module').then(m => m.${xplat_1.stringUtils.classify(featureName)}Module)
|
539
559
|
}`));
|
540
|
-
|
560
|
+
// insert(devKitTree.tree, routingModulePath, changes);
|
541
561
|
}
|
542
|
-
return
|
562
|
+
return devKitTree.tree;
|
543
563
|
};
|
544
564
|
}
|
545
565
|
exports.adjustRouting = adjustRouting;
|
package/src/utils/testing.js
CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLibConfig = exports.getAppConfig = exports.callRule = exports.runSchematic = void 0;
|
4
4
|
const path_1 = require("path");
|
5
5
|
const testing_1 = require("@angular-devkit/schematics/testing");
|
6
|
-
// import { createApp, createLib } from '@
|
7
|
-
// import { names, toFileName } from '@
|
6
|
+
// import { createApp, createLib } from '@nx/angular/testing';
|
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
10
|
return testRunner.runSchematicAsync(schematicName, options, tree).toPromise();
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
export declare const xplatVersion = "*";
|
2
|
-
export declare const nxVersion = "^
|
3
|
-
export declare const angularVersion = "^
|
4
|
-
export declare const angularDevkitVersion = "^
|
2
|
+
export declare const nxVersion = "^16.2.0";
|
3
|
+
export declare const angularVersion = "^16.0.0";
|
4
|
+
export declare const angularDevkitVersion = "^16.0.0";
|
5
5
|
export declare const ngxTranslateVersion = "~14.0.0";
|
6
6
|
export declare const ngxTranslateHttpVersion = "~7.0.0";
|
7
|
-
export declare const coreJsVersion = "^3.6.5";
|
8
7
|
export declare const rxjsVersion = "^7.8.0";
|
9
8
|
export declare const zonejsVersion = "~0.13.0";
|
10
|
-
export declare const jestPresetAngular = "
|
9
|
+
export declare const jestPresetAngular = "^13.0.0";
|
11
10
|
export declare const typesJest = "29.4.0";
|
package/src/utils/versions.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.typesJest = exports.jestPresetAngular = exports.zonejsVersion = exports.rxjsVersion = exports.
|
4
|
-
exports.xplatVersion = '
|
5
|
-
exports.nxVersion = '^
|
6
|
-
exports.angularVersion = '^
|
7
|
-
exports.angularDevkitVersion = '^
|
3
|
+
exports.typesJest = exports.jestPresetAngular = exports.zonejsVersion = exports.rxjsVersion = exports.ngxTranslateHttpVersion = exports.ngxTranslateVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = exports.xplatVersion = void 0;
|
4
|
+
exports.xplatVersion = '16.5.0';
|
5
|
+
exports.nxVersion = '^16.2.0';
|
6
|
+
exports.angularVersion = '^16.0.0';
|
7
|
+
exports.angularDevkitVersion = '^16.0.0';
|
8
8
|
exports.ngxTranslateVersion = '~14.0.0';
|
9
9
|
exports.ngxTranslateHttpVersion = '~7.0.0';
|
10
|
-
exports.coreJsVersion = '^3.6.5';
|
11
10
|
exports.rxjsVersion = '^7.8.0';
|
12
11
|
exports.zonejsVersion = '~0.13.0';
|
13
|
-
exports.jestPresetAngular = '
|
12
|
+
exports.jestPresetAngular = '^13.0.0';
|
14
13
|
exports.typesJest = '29.4.0';
|
package/src/utils/xplat.js
CHANGED
@@ -100,17 +100,18 @@ var XplatAngularHelpers;
|
|
100
100
|
dependencies[`@angular/platform-browser`] = ngVersion;
|
101
101
|
dependencies[`@angular/platform-browser-dynamic`] = ngVersion;
|
102
102
|
dependencies[`@angular/router`] = ngVersion;
|
103
|
-
dependencies[`
|
104
|
-
|
103
|
+
if (!dependencies[`rxjs`]) {
|
104
|
+
dependencies[`rxjs`] = versions_1.rxjsVersion;
|
105
|
+
}
|
105
106
|
dependencies[`zone.js`] = versions_1.zonejsVersion;
|
106
107
|
devDependencies[`@angular/compiler-cli`] = ngVersion;
|
107
108
|
devDependencies[`@angular/language-service`] = ngVersion;
|
108
109
|
}
|
109
|
-
if (!packageJson.devDependencies['@
|
110
|
-
packageJson.devDependencies['@
|
110
|
+
if (!packageJson.devDependencies['@nx/angular']) {
|
111
|
+
packageJson.devDependencies['@nx/angular'] = versions_1.nxVersion;
|
111
112
|
}
|
112
|
-
if (!packageJson.devDependencies['@
|
113
|
-
packageJson.devDependencies['@
|
113
|
+
if (!packageJson.devDependencies['@nx/jest']) {
|
114
|
+
packageJson.devDependencies['@nx/jest'] = versions_1.nxVersion;
|
114
115
|
}
|
115
116
|
if (!packageJson.devDependencies['@nstudio/web']) {
|
116
117
|
packageJson.devDependencies['@nstudio/web'] = versions_1.xplatVersion;
|