@nstudio/angular 15.0.4-rc.1 → 16.2.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.
@@ -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("@nrwl/workspace");
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
- const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
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
- changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${options.subFolder}';`), ...(0, ast_1.addToCollection)(indexSourceFile, indexFilePath, `...${symbolName}`, ' '));
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
- changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${inSubFolder ? `${name}/` : ''}${name}.${type}';`), ...(0, ast_1.addToCollection)(indexSourceFile, indexFilePath, symbolName, ' '));
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
- changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${options.subFolder}';`, true));
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
- changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${subFolder}${name}.${isBase ? 'base-' : ''}${type}';`, true));
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
- (0, xplat_1.insert)(host, indexFilePath, changes);
373
+ // insert(devKitTree.tree, indexFilePath, changes);
367
374
  }
368
375
  else {
369
376
  options.needsIndex = true;
370
377
  }
371
- return host;
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(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${type}';`, true));
382
- (0, xplat_1.insert)(host, indexFilePath, changes);
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 host;
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 = ts.createSourceFile(modulePath, moduleSource, ts.ScriptTarget.Latest, true);
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(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { ${collectionName} } from './${type}s';`));
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
- (0, xplat_1.insert)(host, modulePath, changes);
477
+ // insert(devKitTree.tree, modulePath, changes);
470
478
  }
471
479
  }
472
- return host;
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
- const moduleSourceFile = ts.createSourceFile(modulePath, moduleSource, ts.ScriptTarget.Latest, true);
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
- changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { StoreModule } from '@ngrx/store';`));
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
- changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { EffectsModule } from '@ngrx/effects';`));
500
+ moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { EffectsModule } from '@ngrx/effects';`);
501
+ changes.push(moduleSourceFile);
491
502
  }
492
- changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}Effects } from './state/${name}.effects';`), ...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.camelize(name)}Reducer } from './state/${name}.reducer';`), ...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}State } from './state/${name}.state';`));
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
- changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { environment } from '${envFrom}';`));
512
+ moduleSourceFile = (0, xplat_1.addGlobal)(devKitTree, moduleSourceFile, modulePath, `import { environment } from '${envFrom}';`);
513
+ changes.push(moduleSourceFile);
499
514
  }
500
- changes.push(...(0, ast_1.addImportToModule)(moduleSourceFile, modulePath, `StoreModule.forRoot(
501
- { ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.camelize(name)}Reducer },
502
- {
503
- initialState: { ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.classify(name)}State.initialState }
504
- }
505
- ), EffectsModule.forRoot([${xplat_1.stringUtils.classify(name)}Effects])`), ...(0, ast_1.addProviderToModule)(moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`));
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(...(0, ast_1.addImportToModule)(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])`), ...(0, ast_1.addProviderToModule)(moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`));
528
+ changes.push(moduleSourceFile);
510
529
  }
511
- (0, xplat_1.insert)(host, modulePath, changes);
530
+ // insert(devKitTree.tree, modulePath, changes);
512
531
  }
513
- return host;
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(...(0, ast_1.addToCollection)(routingSourceFile, routingModulePath, `{
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
- (0, xplat_1.insert)(host, routingModulePath, changes);
560
+ // insert(devKitTree.tree, routingModulePath, changes);
541
561
  }
542
- return host;
562
+ return devKitTree.tree;
543
563
  };
544
564
  }
545
565
  exports.adjustRouting = adjustRouting;
@@ -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 '@nrwl/angular/testing';
7
- // import { names, toFileName } from '@nrwl/workspace';
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();
@@ -1,11 +1,10 @@
1
1
  export declare const xplatVersion = "*";
2
- export declare const nxVersion = "^15.0.0";
3
- export declare const angularVersion = "^15.0.0";
4
- export declare const angularDevkitVersion = "^15.0.0";
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
- export declare const rxjsVersion = "^7.8.0";
7
+ export declare const rxjsVersion = "^7.5.0";
9
8
  export declare const zonejsVersion = "~0.13.0";
10
- export declare const jestPresetAngular = "11.0.0";
9
+ export declare const jestPresetAngular = "~13.0.0";
11
10
  export declare const typesJest = "29.4.0";
@@ -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.coreJsVersion = exports.ngxTranslateHttpVersion = exports.ngxTranslateVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = exports.xplatVersion = void 0;
4
- exports.xplatVersion = '15.0.4-rc.1';
5
- exports.nxVersion = '^15.0.0';
6
- exports.angularVersion = '^15.0.0';
7
- exports.angularDevkitVersion = '^15.0.0';
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.2.0-beta.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
- exports.rxjsVersion = '^7.8.0';
10
+ exports.rxjsVersion = '^7.5.0';
12
11
  exports.zonejsVersion = '~0.13.0';
13
- exports.jestPresetAngular = '11.0.0';
12
+ exports.jestPresetAngular = '~13.0.0';
14
13
  exports.typesJest = '29.4.0';
@@ -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[`core-js`] = versions_1.coreJsVersion;
104
- dependencies[`rxjs`] = versions_1.rxjsVersion;
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['@nrwl/angular']) {
110
- packageJson.devDependencies['@nrwl/angular'] = versions_1.nxVersion;
110
+ if (!packageJson.devDependencies['@nx/angular']) {
111
+ packageJson.devDependencies['@nx/angular'] = versions_1.nxVersion;
111
112
  }
112
- if (!packageJson.devDependencies['@nrwl/jest']) {
113
- packageJson.devDependencies['@nrwl/jest'] = versions_1.nxVersion;
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;