@nstudio/angular 12.7.0 → 13.4.1
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 +5 -5
- package/package.json +3 -3
- package/src/schematics/application/index.js +33 -23
- package/src/schematics/application/index.spec.js +8 -33
- package/src/schematics/application/schema.json +1 -28
- package/src/schematics/component/index.js +16 -16
- package/src/schematics/component/index.spec.js +22 -22
- package/src/schematics/directive/index.js +1 -1
- package/src/schematics/directive/index.spec.js +23 -23
- package/src/schematics/elements/index.js +18 -18
- package/src/schematics/elements/index.spec.js +21 -21
- package/src/schematics/feature/index.js +10 -10
- package/src/schematics/feature/index.spec.js +37 -37
- package/src/schematics/helpers/applitools/index.js +8 -8
- package/src/schematics/helpers/index.js +4 -4
- package/src/schematics/helpers/index.spec.js +15 -15
- package/src/schematics/ng-add/index.js +4 -4
- package/src/schematics/ngrx/index.js +1 -1
- package/src/schematics/ngrx/index.spec.js +16 -16
- package/src/schematics/pipe/index.js +1 -1
- package/src/schematics/pipe/index.spec.js +20 -20
- package/src/schematics/service/index.js +1 -1
- package/src/schematics/service/index.spec.js +20 -20
- package/src/schematics/xplat/index.js +7 -7
- package/src/schematics/xplat/index.spec.js +13 -13
- package/src/utils/ast.js +8 -8
- package/src/utils/generator.js +48 -48
- package/src/utils/testing.js +1 -1
- package/src/utils/versions.d.ts +9 -11
- package/src/utils/versions.js +11 -13
- package/src/utils/xplat.js +24 -23
package/src/utils/generator.js
CHANGED
@@ -9,14 +9,14 @@ const ast_1 = require("./ast");
|
|
9
9
|
const ts = require("typescript");
|
10
10
|
function generate(type, options) {
|
11
11
|
if (!options.name) {
|
12
|
-
throw new Error(xplat_1.generateOptionError(type));
|
12
|
+
throw new Error((0, xplat_1.generateOptionError)(type));
|
13
13
|
}
|
14
14
|
let featureName = getFeatureName(options);
|
15
15
|
let platforms = [];
|
16
16
|
const externalChains = [];
|
17
17
|
if (options.projects) {
|
18
18
|
// building in projects
|
19
|
-
const projects = xplat_utils_1.sanitizeCommaDelimitedArg(options.projects);
|
19
|
+
const projects = (0, xplat_utils_1.sanitizeCommaDelimitedArg)(options.projects);
|
20
20
|
for (const name of projects) {
|
21
21
|
const nameParts = name.split('-');
|
22
22
|
const platPrefix = nameParts[0];
|
@@ -35,12 +35,12 @@ function generate(type, options) {
|
|
35
35
|
}
|
36
36
|
else if (options.platforms) {
|
37
37
|
// building in shared code only
|
38
|
-
platforms = xplat_utils_1.sanitizeCommaDelimitedArg(options.platforms);
|
38
|
+
platforms = (0, xplat_utils_1.sanitizeCommaDelimitedArg)(options.platforms);
|
39
39
|
}
|
40
40
|
const projectChains = [];
|
41
41
|
if (options.projects) {
|
42
42
|
for (const fullProjectPath of options.projects.split(',')) {
|
43
|
-
const projectName = xplat_utils_1.parseProjectNameFromPath(fullProjectPath);
|
43
|
+
const projectName = (0, xplat_utils_1.parseProjectNameFromPath)(fullProjectPath);
|
44
44
|
const projectParts = projectName.split('-');
|
45
45
|
const platform = xplat_utils_1.supportedPlatforms.includes(projectParts[0])
|
46
46
|
? projectParts[0]
|
@@ -70,7 +70,7 @@ function generate(type, options) {
|
|
70
70
|
// console.log('featureModulePath:', featureModulePath);
|
71
71
|
// console.log('projectName:', projectName);
|
72
72
|
if (!tree.exists(featureModulePath)) {
|
73
|
-
throw new Error(xplat_1.needFeatureModuleError(featureModulePath, featureName, projectName, true));
|
73
|
+
throw new Error((0, xplat_1.needFeatureModuleError)(featureModulePath, featureName, projectName, true));
|
74
74
|
}
|
75
75
|
return addToFeature(platform, type, options, prefixPath, tree)(tree, context);
|
76
76
|
});
|
@@ -86,7 +86,7 @@ function generate(type, options) {
|
|
86
86
|
return adjustFeatureModuleForState(options, featureModulePath)(tree, context);
|
87
87
|
});
|
88
88
|
projectChains.push((tree, context) => {
|
89
|
-
return xplat_1.updatePackageForNgrx(tree, `apps/${fullProjectPath}/package.json`);
|
89
|
+
return (0, xplat_1.updatePackageForNgrx)(tree, `apps/${fullProjectPath}/package.json`);
|
90
90
|
});
|
91
91
|
}
|
92
92
|
else {
|
@@ -103,7 +103,7 @@ function generate(type, options) {
|
|
103
103
|
}
|
104
104
|
}
|
105
105
|
else {
|
106
|
-
projectChains.push(schematics_1.noop());
|
106
|
+
projectChains.push((0, schematics_1.noop)());
|
107
107
|
for (const platform of platforms) {
|
108
108
|
if (xplat_utils_1.supportedPlatforms.includes(platform)) {
|
109
109
|
// externalChains.push(externalSchematic(`@nstudio/${platform}-angular`, type, options, {
|
@@ -123,7 +123,7 @@ function generate(type, options) {
|
|
123
123
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
124
124
|
return options.needsIndex
|
125
125
|
? addToFeature(xplatFolderName, type, options, `libs/xplat/${xplatFolderName}`, tree, '_index')(tree, context)
|
126
|
-
: schematics_1.noop()(tree, context);
|
126
|
+
: (0, schematics_1.noop)()(tree, context);
|
127
127
|
});
|
128
128
|
// adjust feature module metadata if needed
|
129
129
|
externalChains.push((tree, context) => {
|
@@ -132,39 +132,39 @@ function generate(type, options) {
|
|
132
132
|
});
|
133
133
|
}
|
134
134
|
else {
|
135
|
-
throw new Error(xplat_1.unsupportedPlatformError(platform));
|
135
|
+
throw new Error((0, xplat_1.unsupportedPlatformError)(platform));
|
136
136
|
}
|
137
137
|
}
|
138
138
|
}
|
139
|
-
return schematics_1.chain([
|
140
|
-
xplat_utils_1.prerun(),
|
139
|
+
return (0, schematics_1.chain)([
|
140
|
+
(0, xplat_utils_1.prerun)(),
|
141
141
|
(tree, context) =>
|
142
142
|
// for entire workspace usage
|
143
143
|
// no projects and no specific platforms specified
|
144
144
|
!options.projects && platforms.length === 0
|
145
145
|
? addToFeature('', type, options, 'libs/xplat', tree)(tree, context)
|
146
|
-
: schematics_1.noop()(tree, context),
|
146
|
+
: (0, schematics_1.noop)()(tree, context),
|
147
147
|
// adjust libs barrel
|
148
148
|
(tree, context) => !options.projects && platforms.length === 0
|
149
149
|
? adjustBarrel(type, options, 'libs/xplat')(tree, context)
|
150
|
-
: schematics_1.noop()(tree, context),
|
150
|
+
: (0, schematics_1.noop)()(tree, context),
|
151
151
|
// add index barrel if needed
|
152
152
|
(tree, context) => options.needsIndex
|
153
153
|
? addToFeature('', type, options, 'libs/xplat', tree, '_index')(tree, context)
|
154
|
-
: schematics_1.noop()(tree, context),
|
154
|
+
: (0, schematics_1.noop)()(tree, context),
|
155
155
|
// adjust feature module metadata if needed
|
156
156
|
(tree, context) => !options.projects && platforms.length === 0
|
157
157
|
? adjustModule(tree, type, options, 'libs/xplat')(tree, context)
|
158
|
-
: schematics_1.noop()(tree, context),
|
158
|
+
: (0, schematics_1.noop)()(tree, context),
|
159
159
|
// project handling
|
160
|
-
(tree, context) => schematics_1.chain(projectChains),
|
161
|
-
(tree, context) => schematics_1.chain(externalChains),
|
160
|
+
(tree, context) => (0, schematics_1.chain)(projectChains),
|
161
|
+
(tree, context) => (0, schematics_1.chain)(externalChains),
|
162
162
|
// dependency updates
|
163
163
|
(tree, context) => !options.projects && type === 'state'
|
164
164
|
? // ensure ngrx dependencies are added to root package
|
165
|
-
xplat_1.updatePackageForNgrx(tree)
|
166
|
-
: schematics_1.noop()(tree, context),
|
167
|
-
workspace_1.formatFiles({ skipFormat: options.skipFormat }),
|
165
|
+
(0, xplat_1.updatePackageForNgrx)(tree)
|
166
|
+
: (0, schematics_1.noop)()(tree, context),
|
167
|
+
(0, workspace_1.formatFiles)({ skipFormat: options.skipFormat }),
|
168
168
|
]);
|
169
169
|
}
|
170
170
|
exports.generate = generate;
|
@@ -198,7 +198,7 @@ function getFeatureName(options) {
|
|
198
198
|
}
|
199
199
|
exports.getFeatureName = getFeatureName;
|
200
200
|
function getNxFeaturePath(tree, featureName) {
|
201
|
-
const tsConfig = workspace_1.readJsonInTree(tree, 'tsconfig.base.json');
|
201
|
+
const tsConfig = (0, workspace_1.readJsonInTree)(tree, 'tsconfig.base.json');
|
202
202
|
if (tsConfig) {
|
203
203
|
if (tsConfig.compilerOptions &&
|
204
204
|
tsConfig.compilerOptions.paths &&
|
@@ -264,7 +264,7 @@ function addToFeature(xplatFolderName, type, options, prefixPath, tree, extra =
|
|
264
264
|
optionName = parts[2];
|
265
265
|
}
|
266
266
|
}
|
267
|
-
throw new Error(xplat_1.needFeatureModuleError(featureModulePath, featureName, optionName));
|
267
|
+
throw new Error((0, xplat_1.needFeatureModuleError)(featureModulePath, featureName, optionName));
|
268
268
|
}
|
269
269
|
}
|
270
270
|
if (forSubFolder && options.subFolder) {
|
@@ -275,15 +275,15 @@ function addToFeature(xplatFolderName, type, options, prefixPath, tree, extra =
|
|
275
275
|
if ((extra === '_index' || extra === '_base_index') &&
|
276
276
|
tree.exists(indexPath)) {
|
277
277
|
// already has an index barrel
|
278
|
-
return schematics_1.noop();
|
278
|
+
return (0, schematics_1.noop)();
|
279
279
|
}
|
280
280
|
else {
|
281
|
-
return schematics_1.branchAndMerge(schematics_1.mergeWith(schematics_1.apply(schematics_1.url(`./${extra}_files`), [
|
282
|
-
schematics_1.template(Object.assign(Object.assign(Object.assign({}, options), xplat_1.getDefaultTemplateOptions()), { name: options.name.toLowerCase(), relativeDirectory,
|
281
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./${extra}_files`), [
|
282
|
+
(0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, options), (0, xplat_1.getDefaultTemplateOptions)()), { name: options.name.toLowerCase(), relativeDirectory,
|
283
283
|
xplatFolderName,
|
284
284
|
// feature: featureName,
|
285
285
|
forSubFolder })),
|
286
|
-
schematics_1.move(moveTo),
|
286
|
+
(0, schematics_1.move)(moveTo),
|
287
287
|
])));
|
288
288
|
}
|
289
289
|
}
|
@@ -346,24 +346,24 @@ function adjustBarrelIndex(type, options, indexFilePath, inSubFolder, isBase, im
|
|
346
346
|
const symbolName = `${xplat_1.stringUtils
|
347
347
|
.sanitize(options.subFolder)
|
348
348
|
.toUpperCase()}_${type.toUpperCase()}S`;
|
349
|
-
changes.push(...xplat_1.addGlobal(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${options.subFolder}';`), ...ast_1.addToCollection(indexSourceFile, indexFilePath, `...${symbolName}`, ' '));
|
349
|
+
changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${options.subFolder}';`), ...(0, ast_1.addToCollection)(indexSourceFile, indexFilePath, `...${symbolName}`, ' '));
|
350
350
|
}
|
351
351
|
else {
|
352
352
|
const symbolName = `${xplat_1.stringUtils.classify(name)}${xplat_1.stringUtils.capitalize(type)}`;
|
353
|
-
changes.push(...xplat_1.addGlobal(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${inSubFolder ? `${name}/` : ''}${name}.${type}';`), ...ast_1.addToCollection(indexSourceFile, indexFilePath, symbolName, ' '));
|
353
|
+
changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `import { ${symbolName} } from './${inSubFolder ? `${name}/` : ''}${name}.${type}';`), ...(0, ast_1.addToCollection)(indexSourceFile, indexFilePath, symbolName, ' '));
|
354
354
|
}
|
355
355
|
}
|
356
356
|
if (type === 'component' || type === 'service' || type === 'pipe') {
|
357
357
|
// export symbol from barrel
|
358
358
|
if ((isBase || importIfSubFolder) && options.subFolder) {
|
359
|
-
changes.push(...xplat_1.addGlobal(indexSourceFile, indexFilePath, `export * from './${options.subFolder}';`, true));
|
359
|
+
changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${options.subFolder}';`, true));
|
360
360
|
}
|
361
361
|
else {
|
362
362
|
const subFolder = inSubFolder ? `${name}/` : '';
|
363
|
-
changes.push(...xplat_1.addGlobal(indexSourceFile, indexFilePath, `export * from './${subFolder}${name}.${isBase ? 'base-' : ''}${type}';`, true));
|
363
|
+
changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${subFolder}${name}.${isBase ? 'base-' : ''}${type}';`, true));
|
364
364
|
}
|
365
365
|
}
|
366
|
-
xplat_1.insert(host, indexFilePath, changes);
|
366
|
+
(0, xplat_1.insert)(host, indexFilePath, changes);
|
367
367
|
}
|
368
368
|
else {
|
369
369
|
options.needsIndex = true;
|
@@ -378,8 +378,8 @@ function adjustBarrelIndexForType(type, options, indexFilePath) {
|
|
378
378
|
const indexSource = host.read(indexFilePath).toString('utf-8');
|
379
379
|
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
380
380
|
const changes = [];
|
381
|
-
changes.push(...xplat_1.addGlobal(indexSourceFile, indexFilePath, `export * from './${type}';`, true));
|
382
|
-
xplat_1.insert(host, indexFilePath, changes);
|
381
|
+
changes.push(...(0, xplat_1.addGlobal)(indexSourceFile, indexFilePath, `export * from './${type}';`, true));
|
382
|
+
(0, xplat_1.insert)(host, indexFilePath, changes);
|
383
383
|
}
|
384
384
|
else {
|
385
385
|
options.needsIndex = true;
|
@@ -463,10 +463,10 @@ function adjustFeatureModule(type, options, modulePath) {
|
|
463
463
|
else {
|
464
464
|
if (type !== 'service') {
|
465
465
|
// add to module
|
466
|
-
changes.push(...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { ${collectionName} } from './${type}s';`));
|
467
|
-
changes.push(...ast_1.addDeclarationToModule(moduleSourceFile, modulePath, `...${collectionName}`), ...ast_1.addSymbolToNgModuleMetadata(moduleSourceFile, modulePath, 'exports', `...${collectionName}`));
|
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}`));
|
468
468
|
}
|
469
|
-
xplat_1.insert(host, modulePath, changes);
|
469
|
+
(0, xplat_1.insert)(host, modulePath, changes);
|
470
470
|
}
|
471
471
|
}
|
472
472
|
return host;
|
@@ -484,31 +484,31 @@ function adjustFeatureModuleForState(options, modulePath) {
|
|
484
484
|
const name = options.name.toLowerCase();
|
485
485
|
const changes = [];
|
486
486
|
if (moduleSource.indexOf('StoreModule') === -1) {
|
487
|
-
changes.push(...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { StoreModule } from '@ngrx/store';`));
|
487
|
+
changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { StoreModule } from '@ngrx/store';`));
|
488
488
|
}
|
489
489
|
if (moduleSource.indexOf('EffectsModule') === -1) {
|
490
|
-
changes.push(...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { EffectsModule } from '@ngrx/effects';`));
|
490
|
+
changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { EffectsModule } from '@ngrx/effects';`));
|
491
491
|
}
|
492
|
-
changes.push(...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}Effects } from './state/${name}.effects';`), ...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.camelize(name)}Reducer } from './state/${name}.reducer';`), ...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { ${xplat_1.stringUtils.classify(name)}State } from './state/${name}.state';`));
|
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';`));
|
493
493
|
if (options.root) {
|
494
494
|
if (moduleSource.indexOf('environments/environment') === -1) {
|
495
495
|
const envFrom = isInLibs
|
496
496
|
? './environments/environment'
|
497
|
-
: `@${xplat_utils_1.getNpmScope()}/xplat/core`;
|
498
|
-
changes.push(...xplat_1.addGlobal(moduleSourceFile, modulePath, `import { environment } from '${envFrom}';`));
|
497
|
+
: `@${(0, xplat_utils_1.getNpmScope)()}/xplat/core`;
|
498
|
+
changes.push(...(0, xplat_1.addGlobal)(moduleSourceFile, modulePath, `import { environment } from '${envFrom}';`));
|
499
499
|
}
|
500
|
-
changes.push(...ast_1.addImportToModule(moduleSourceFile, modulePath, `StoreModule.forRoot(
|
500
|
+
changes.push(...(0, ast_1.addImportToModule)(moduleSourceFile, modulePath, `StoreModule.forRoot(
|
501
501
|
{ ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.camelize(name)}Reducer },
|
502
502
|
{
|
503
503
|
initialState: { ${xplat_1.stringUtils.camelize(name)}: ${xplat_1.stringUtils.classify(name)}State.initialState }
|
504
504
|
}
|
505
|
-
), EffectsModule.forRoot([${xplat_1.stringUtils.classify(name)}Effects])`), ...ast_1.addProviderToModule(moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`));
|
505
|
+
), EffectsModule.forRoot([${xplat_1.stringUtils.classify(name)}Effects])`), ...(0, ast_1.addProviderToModule)(moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`));
|
506
506
|
}
|
507
507
|
else {
|
508
508
|
// feature state
|
509
|
-
changes.push(...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])`), ...ast_1.addProviderToModule(moduleSourceFile, modulePath, `${xplat_1.stringUtils.classify(name)}Effects`));
|
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`));
|
510
510
|
}
|
511
|
-
xplat_1.insert(host, modulePath, changes);
|
511
|
+
(0, xplat_1.insert)(host, modulePath, changes);
|
512
512
|
}
|
513
513
|
return host;
|
514
514
|
};
|
@@ -533,11 +533,11 @@ function adjustRouting(options, routingModulePaths, platform) {
|
|
533
533
|
const routingSourceFile = ts.createSourceFile(routingModulePath, routingSource, ts.ScriptTarget.Latest, true);
|
534
534
|
const changes = [];
|
535
535
|
// add component to route config
|
536
|
-
changes.push(...ast_1.addToCollection(routingSourceFile, routingModulePath, `{
|
536
|
+
changes.push(...(0, ast_1.addToCollection)(routingSourceFile, routingModulePath, `{
|
537
537
|
path: '${featureName}',
|
538
538
|
loadChildren: () => import('./features/${options.directory ? options.directory + '/' : ''}${featureName}/${featureName}.module').then(m => m.${xplat_1.stringUtils.classify(featureName)}Module)
|
539
539
|
}`));
|
540
|
-
xplat_1.insert(host, routingModulePath, changes);
|
540
|
+
(0, xplat_1.insert)(host, routingModulePath, changes);
|
541
541
|
}
|
542
542
|
return host;
|
543
543
|
};
|
@@ -589,7 +589,7 @@ function adjustSandbox(options, platform, appDirectory) {
|
|
589
589
|
homeTemplate.slice(buttonEndIndex + 9);
|
590
590
|
break;
|
591
591
|
}
|
592
|
-
workspace_1.createOrUpdate(tree, homeCmpPath, homeTemplate);
|
592
|
+
(0, workspace_1.createOrUpdate)(tree, homeCmpPath, homeTemplate);
|
593
593
|
}
|
594
594
|
else {
|
595
595
|
throw new schematics_1.SchematicsException(`The --adjustSandbox option is only supported on the following at the moment: ${xplat_1.supportedSandboxPlatforms}`);
|
package/src/utils/testing.js
CHANGED
@@ -5,7 +5,7 @@ const path_1 = require("path");
|
|
5
5
|
const testing_1 = require("@angular-devkit/schematics/testing");
|
6
6
|
// import { createApp, createLib } from '@nrwl/angular/testing';
|
7
7
|
// import { names, toFileName } from '@nrwl/workspace';
|
8
|
-
const testRunner = new testing_1.SchematicTestRunner('@nstudio/angular', path_1.join(__dirname, '../../collection.json'));
|
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();
|
11
11
|
}
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,13 +1,11 @@
|
|
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 = "^13.0.0";
|
3
|
+
export declare const angularVersion = "^13.0.0";
|
4
|
+
export declare const angularDevkitVersion = "~13.0.0";
|
5
|
+
export declare const ngxTranslateVersion = "~14.0.0";
|
6
|
+
export declare const ngxTranslateHttpVersion = "~7.0.0";
|
7
7
|
export declare const coreJsVersion = "^3.6.5";
|
8
|
-
export declare const rxjsVersion = "^
|
9
|
-
export declare const zonejsVersion = "~0.11.
|
10
|
-
export declare const
|
11
|
-
export declare const
|
12
|
-
export declare const jestPresetAngular = "8.4.0";
|
13
|
-
export declare const typesJest = "26.0.8";
|
8
|
+
export declare const rxjsVersion = "^7.4.0";
|
9
|
+
export declare const zonejsVersion = "~0.11.4";
|
10
|
+
export declare const jestPresetAngular = "11.0.0";
|
11
|
+
export declare const typesJest = "27.0.2";
|
package/src/utils/versions.js
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.typesJest = exports.jestPresetAngular = exports.
|
4
|
-
exports.xplatVersion = '
|
5
|
-
exports.nxVersion = '^
|
6
|
-
exports.angularVersion = '^
|
7
|
-
exports.angularDevkitVersion = '
|
8
|
-
exports.ngxTranslateVersion = '~
|
9
|
-
exports.ngxTranslateHttpVersion = '~
|
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 = '13.4.1';
|
5
|
+
exports.nxVersion = '^13.0.0';
|
6
|
+
exports.angularVersion = '^13.0.0';
|
7
|
+
exports.angularDevkitVersion = '~13.0.0';
|
8
|
+
exports.ngxTranslateVersion = '~14.0.0';
|
9
|
+
exports.ngxTranslateHttpVersion = '~7.0.0';
|
10
10
|
exports.coreJsVersion = '^3.6.5';
|
11
|
-
exports.rxjsVersion = '^
|
12
|
-
exports.zonejsVersion = '~0.11.
|
13
|
-
exports.
|
14
|
-
exports.
|
15
|
-
exports.jestPresetAngular = '8.4.0';
|
16
|
-
exports.typesJest = '26.0.8';
|
11
|
+
exports.rxjsVersion = '^7.4.0';
|
12
|
+
exports.zonejsVersion = '~0.11.4';
|
13
|
+
exports.jestPresetAngular = '11.0.0';
|
14
|
+
exports.typesJest = '27.0.2';
|
package/src/utils/xplat.js
CHANGED
@@ -9,11 +9,11 @@ const versions_1 = require("./versions");
|
|
9
9
|
var ComponentHelpers;
|
10
10
|
(function (ComponentHelpers) {
|
11
11
|
function platformGenerator(options, platform) {
|
12
|
-
const chains = [xplat_utils_1.prerun()];
|
12
|
+
const chains = [(0, xplat_utils_1.prerun)()];
|
13
13
|
const componentSettings = xplat_1.XplatComponentHelpers.prepare(options);
|
14
14
|
if (options.onlyProject) {
|
15
15
|
for (const fullProjectPath of componentSettings.projectNames) {
|
16
|
-
const projectName = xplat_utils_1.parseProjectNameFromPath(fullProjectPath);
|
16
|
+
const projectName = (0, xplat_utils_1.parseProjectNameFromPath)(fullProjectPath);
|
17
17
|
const projectParts = projectName.split('-');
|
18
18
|
const platPrefix = projectParts[0];
|
19
19
|
const platSuffix = projectParts.pop();
|
@@ -26,15 +26,15 @@ var ComponentHelpers;
|
|
26
26
|
// console.log('will adjustProject:', projectName);
|
27
27
|
chains.push((tree, context) => {
|
28
28
|
if (!tree.exists(featureModulePath)) {
|
29
|
-
throw new Error(xplat_1.needFeatureModuleError(featureModulePath, componentSettings.featureName, fullProjectPath, true));
|
29
|
+
throw new Error((0, xplat_1.needFeatureModuleError)(featureModulePath, componentSettings.featureName, fullProjectPath, true));
|
30
30
|
}
|
31
|
-
return generator_1.addToFeature('', 'component', options, prefixPath, tree)(tree, context);
|
31
|
+
return (0, generator_1.addToFeature)('', 'component', options, prefixPath, tree)(tree, context);
|
32
32
|
});
|
33
33
|
chains.push((tree, context) => {
|
34
|
-
return generator_1.adjustBarrelIndex('component', options, barrelIndex, true)(tree, context);
|
34
|
+
return (0, generator_1.adjustBarrelIndex)('component', options, barrelIndex, true)(tree, context);
|
35
35
|
});
|
36
36
|
chains.push((tree, context) => {
|
37
|
-
return generator_1.addToFeature('', 'component', options, prefixPath, tree, '_index')(tree, context);
|
37
|
+
return (0, generator_1.addToFeature)('', 'component', options, prefixPath, tree, '_index')(tree, context);
|
38
38
|
});
|
39
39
|
}
|
40
40
|
}
|
@@ -43,31 +43,33 @@ var ComponentHelpers;
|
|
43
43
|
// add component
|
44
44
|
chains.push((tree, context) => {
|
45
45
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
46
|
-
return generator_1.addToFeature(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, ``, true)(tree, context);
|
46
|
+
return (0, generator_1.addToFeature)(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, ``, true)(tree, context);
|
47
47
|
});
|
48
48
|
if (options.subFolder) {
|
49
49
|
// adjust components barrel for subFolder
|
50
50
|
chains.push((tree, context) => {
|
51
51
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
52
|
-
return generator_1.adjustBarrelIndex('component', options, `libs/xplat/${xplatFolderName}/features/src/lib/${componentSettings.directory
|
52
|
+
return (0, generator_1.adjustBarrelIndex)('component', options, `libs/xplat/${xplatFolderName}/features/src/lib/${componentSettings.directory
|
53
|
+
? componentSettings.directory + '/'
|
54
|
+
: ''}${componentSettings.featureName}/components/${options.subFolder}/index.ts`, true)(tree, context);
|
53
55
|
});
|
54
56
|
chains.push((tree, context) => {
|
55
57
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
56
58
|
return options.needsIndex
|
57
|
-
? generator_1.addToFeature(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, '_index', true)(tree, context)
|
58
|
-
: schematics_1.noop()(tree, context);
|
59
|
+
? (0, generator_1.addToFeature)(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, '_index', true)(tree, context)
|
60
|
+
: (0, schematics_1.noop)()(tree, context);
|
59
61
|
});
|
60
62
|
}
|
61
63
|
// adjust overall components barrel
|
62
64
|
chains.push((tree, context) => {
|
63
65
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
64
|
-
return generator_1.adjustBarrelIndex('component', options, `libs/xplat/${xplatFolderName}/features/src/lib/${componentSettings.directory ? componentSettings.directory + '/' : ''}${componentSettings.featureName}/components/index.ts`, true, false, true)(tree, context);
|
66
|
+
return (0, generator_1.adjustBarrelIndex)('component', options, `libs/xplat/${xplatFolderName}/features/src/lib/${componentSettings.directory ? componentSettings.directory + '/' : ''}${componentSettings.featureName}/components/index.ts`, true, false, true)(tree, context);
|
65
67
|
});
|
66
68
|
chains.push((tree, context) => {
|
67
69
|
const xplatFolderName = xplat_1.XplatHelpers.getXplatFoldername(platform, 'angular');
|
68
70
|
return options.needsIndex
|
69
|
-
? generator_1.addToFeature(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, '_index')(tree, context)
|
70
|
-
: schematics_1.noop()(tree, context);
|
71
|
+
? (0, generator_1.addToFeature)(xplatFolderName, 'component', options, `libs/xplat/${xplatFolderName}`, tree, '_index')(tree, context)
|
72
|
+
: (0, schematics_1.noop)()(tree, context);
|
71
73
|
});
|
72
74
|
}
|
73
75
|
return chains;
|
@@ -80,7 +82,7 @@ var XplatAngularHelpers;
|
|
80
82
|
return (tree, context) => {
|
81
83
|
const dependencies = {};
|
82
84
|
const devDependencies = {};
|
83
|
-
const packageJson = xplat_utils_1.getJsonFromFile(tree, 'package.json');
|
85
|
+
const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, 'package.json');
|
84
86
|
const hasAngularDeps = packageJson.dependencies['@angular/core'];
|
85
87
|
if (!hasAngularDeps) {
|
86
88
|
dependencies[`@angular/animations`] = versions_1.angularVersion;
|
@@ -97,7 +99,6 @@ var XplatAngularHelpers;
|
|
97
99
|
devDependencies[`@angular/compiler-cli`] = versions_1.angularVersion;
|
98
100
|
devDependencies[`@angular/language-service`] = versions_1.angularVersion;
|
99
101
|
devDependencies[`@angular-devkit/build-angular`] = versions_1.angularDevkitVersion;
|
100
|
-
devDependencies[`codelyzer`] = versions_1.codelyzerVersion;
|
101
102
|
}
|
102
103
|
if (!packageJson.devDependencies['@nrwl/angular']) {
|
103
104
|
packageJson.devDependencies['@nrwl/angular'] = versions_1.nxVersion;
|
@@ -108,10 +109,10 @@ var XplatAngularHelpers;
|
|
108
109
|
if (!packageJson.devDependencies['@nstudio/web']) {
|
109
110
|
packageJson.devDependencies['@nstudio/web'] = versions_1.xplatVersion;
|
110
111
|
}
|
111
|
-
dependencies[`@${xplat_utils_1.getNpmScope()}/xplat-scss`] = 'file:libs/xplat/scss/src';
|
112
|
+
dependencies[`@${(0, xplat_utils_1.getNpmScope)()}/xplat-scss`] = 'file:libs/xplat/scss/src';
|
112
113
|
return xplat_1.XplatHelpers.updatePackageForXplat(options, {
|
113
114
|
dependencies: Object.assign(Object.assign({}, dependencies), { '@ngx-translate/core': versions_1.ngxTranslateVersion, '@ngx-translate/http-loader': versions_1.ngxTranslateHttpVersion }),
|
114
|
-
devDependencies: Object.assign(Object.assign({}, devDependencies), { '@types/jest': versions_1.typesJest, 'jest-
|
115
|
+
devDependencies: Object.assign(Object.assign({}, devDependencies), { '@types/jest': versions_1.typesJest, 'jest-preset-angular': versions_1.jestPresetAngular }),
|
115
116
|
})(tree, context);
|
116
117
|
};
|
117
118
|
}
|
@@ -121,7 +122,7 @@ var XplatAngularHelpers;
|
|
121
122
|
const chains = [];
|
122
123
|
for (const platform of platforms) {
|
123
124
|
// console.log('angular externalChains:', `@nstudio/${platform}-angular`)
|
124
|
-
chains.push(schematics_1.externalSchematic(`@nstudio/${platform}-angular`, 'xplat', options, {
|
125
|
+
chains.push((0, schematics_1.externalSchematic)(`@nstudio/${platform}-angular`, 'xplat', options, {
|
125
126
|
interactive: false,
|
126
127
|
}));
|
127
128
|
}
|
@@ -132,15 +133,15 @@ var XplatAngularHelpers;
|
|
132
133
|
return (tree, context) => {
|
133
134
|
if (libName === 'scss' &&
|
134
135
|
tree.exists(`libs/xplat/${libName}/src/package.json`)) {
|
135
|
-
return schematics_1.noop()(tree, context);
|
136
|
+
return (0, schematics_1.noop)()(tree, context);
|
136
137
|
}
|
137
138
|
else if (tree.exists(`libs/xplat/${libName}/src/lib/index.ts`)) {
|
138
|
-
return schematics_1.noop()(tree, context);
|
139
|
+
return (0, schematics_1.noop)()(tree, context);
|
139
140
|
}
|
140
141
|
const libSrcFolder = `/${libName}/src${libName === 'scss' ? '' : '/lib'}`;
|
141
|
-
return schematics_1.branchAndMerge(schematics_1.mergeWith(schematics_1.apply(schematics_1.url(`${relativeTo}_files_${libName}`), [
|
142
|
-
schematics_1.template(Object.assign(Object.assign({}, options), xplat_1.getDefaultTemplateOptions())),
|
143
|
-
schematics_1.move(`libs/xplat/${libSrcFolder}`),
|
142
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`${relativeTo}_files_${libName}`), [
|
143
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, options), (0, xplat_1.getDefaultTemplateOptions)())),
|
144
|
+
(0, schematics_1.move)(`libs/xplat/${libSrcFolder}`),
|
144
145
|
])))(tree, context);
|
145
146
|
};
|
146
147
|
}
|