@nrwl/angular 14.5.5 → 14.5.8

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/generators.d.ts +1 -0
  3. package/generators.js +1 -0
  4. package/generators.js.map +1 -1
  5. package/generators.json +10 -0
  6. package/migrations.json +9 -0
  7. package/package.json +9 -9
  8. package/src/executors/delegate-build/delegate-build.impl.js +1 -2
  9. package/src/executors/delegate-build/delegate-build.impl.js.map +1 -1
  10. package/src/executors/package/package.impl.js +1 -2
  11. package/src/executors/package/package.impl.js.map +1 -1
  12. package/src/generators/application/application.js +4 -0
  13. package/src/generators/application/application.js.map +1 -1
  14. package/src/generators/application/lib/convert-to-standalone-app.d.ts +3 -0
  15. package/src/generators/application/lib/convert-to-standalone-app.js +83 -0
  16. package/src/generators/application/lib/convert-to-standalone-app.js.map +1 -0
  17. package/src/generators/application/lib/index.d.ts +1 -0
  18. package/src/generators/application/lib/index.js +1 -0
  19. package/src/generators/application/lib/index.js.map +1 -1
  20. package/src/generators/application/schema.d.ts +1 -0
  21. package/src/generators/application/schema.json +5 -0
  22. package/src/generators/library/lib/add-children.js +7 -3
  23. package/src/generators/library/lib/add-children.js.map +1 -1
  24. package/src/generators/library/lib/add-load-children.js +3 -1
  25. package/src/generators/library/lib/add-load-children.js.map +1 -1
  26. package/src/generators/library/lib/add-standalone-component.d.ts +3 -0
  27. package/src/generators/library/lib/add-standalone-component.js +44 -0
  28. package/src/generators/library/lib/add-standalone-component.js.map +1 -0
  29. package/src/generators/library/lib/normalize-options.js +8 -9
  30. package/src/generators/library/lib/normalize-options.js.map +1 -1
  31. package/src/generators/library/lib/normalized-schema.d.ts +1 -0
  32. package/src/generators/library/lib/update-project.js +2 -2
  33. package/src/generators/library/lib/update-project.js.map +1 -1
  34. package/src/generators/library/library.d.ts +1 -1
  35. package/src/generators/library/library.js +25 -19
  36. package/src/generators/library/library.js.map +1 -1
  37. package/src/generators/library/schema.d.ts +1 -0
  38. package/src/generators/library/schema.json +5 -0
  39. package/src/generators/scam-to-standalone/compat.d.ts +2 -0
  40. package/src/generators/scam-to-standalone/compat.js +6 -0
  41. package/src/generators/scam-to-standalone/compat.js.map +1 -0
  42. package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.d.ts +3 -0
  43. package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.js +34 -0
  44. package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.js.map +1 -0
  45. package/src/generators/scam-to-standalone/lib/get-component-data-from-ast.d.ts +6 -0
  46. package/src/generators/scam-to-standalone/lib/get-component-data-from-ast.js +19 -0
  47. package/src/generators/scam-to-standalone/lib/get-component-data-from-ast.js.map +1 -0
  48. package/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.d.ts +9 -0
  49. package/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.js +65 -0
  50. package/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.js.map +1 -0
  51. package/src/generators/scam-to-standalone/lib/get-target-project.d.ts +2 -0
  52. package/src/generators/scam-to-standalone/lib/get-target-project.js +15 -0
  53. package/src/generators/scam-to-standalone/lib/get-target-project.js.map +1 -0
  54. package/src/generators/scam-to-standalone/lib/index.d.ts +8 -0
  55. package/src/generators/scam-to-standalone/lib/index.js +12 -0
  56. package/src/generators/scam-to-standalone/lib/index.js.map +1 -0
  57. package/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.d.ts +2 -0
  58. package/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.js +20 -0
  59. package/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.js.map +1 -0
  60. package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.d.ts +2 -0
  61. package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.js +9 -0
  62. package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.js.map +1 -0
  63. package/src/generators/scam-to-standalone/lib/verify-is-inline-scam.d.ts +2 -0
  64. package/src/generators/scam-to-standalone/lib/verify-is-inline-scam.js +12 -0
  65. package/src/generators/scam-to-standalone/lib/verify-is-inline-scam.js.map +1 -0
  66. package/src/generators/scam-to-standalone/lib/verify-module-is-scam.d.ts +1 -0
  67. package/src/generators/scam-to-standalone/lib/verify-module-is-scam.js +13 -0
  68. package/src/generators/scam-to-standalone/lib/verify-module-is-scam.js.map +1 -0
  69. package/src/generators/scam-to-standalone/scam-to-standalone.d.ts +4 -0
  70. package/src/generators/scam-to-standalone/scam-to-standalone.js +31 -0
  71. package/src/generators/scam-to-standalone/scam-to-standalone.js.map +1 -0
  72. package/src/generators/scam-to-standalone/schema.d.ts +5 -0
  73. package/src/generators/scam-to-standalone/schema.json +28 -0
  74. package/src/utils/mf/mf-webpack.js +23 -11
  75. package/src/utils/mf/mf-webpack.js.map +1 -1
  76. package/src/utils/versions.d.ts +1 -1
  77. package/src/utils/versions.js +1 -1
@@ -19,7 +19,8 @@ const normalize_options_1 = require("./lib/normalize-options");
19
19
  const update_lib_package_npm_scope_1 = require("./lib/update-lib-package-npm-scope");
20
20
  const update_project_1 = require("./lib/update-project");
21
21
  const update_tsconfig_1 = require("./lib/update-tsconfig");
22
- function libraryGenerator(host, schema) {
22
+ const add_standalone_component_1 = require("./lib/add-standalone-component");
23
+ function libraryGenerator(tree, schema) {
23
24
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
25
  // Do some validation checks
25
26
  if (!schema.routing && schema.lazy) {
@@ -31,10 +32,10 @@ function libraryGenerator(host, schema) {
31
32
  if (schema.addTailwind && !schema.buildable && !schema.publishable) {
32
33
  throw new Error(`To use "--addTailwind" option, you have to set either "--buildable" or "--publishable".`);
33
34
  }
34
- const options = (0, normalize_options_1.normalizeOptions)(host, schema);
35
- yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true, e2eTestRunner: "none" /* E2eTestRunner.None */ }));
35
+ const options = (0, normalize_options_1.normalizeOptions)(tree, schema);
36
+ yield (0, init_1.default)(tree, Object.assign(Object.assign({}, options), { skipFormat: true, e2eTestRunner: "none" /* E2eTestRunner.None */ }));
36
37
  const runAngularLibrarySchematic = (0, ngcli_adapter_1.wrapAngularDevkitSchematic)('@schematics/angular', 'library');
37
- yield runAngularLibrarySchematic(host, {
38
+ yield runAngularLibrarySchematic(tree, {
38
39
  name: options.name,
39
40
  prefix: options.prefix,
40
41
  entryFile: 'index',
@@ -42,40 +43,45 @@ function libraryGenerator(host, schema) {
42
43
  skipTsConfig: true,
43
44
  });
44
45
  if (options.ngCliSchematicLibRoot !== options.projectRoot) {
45
- (0, devkit_1.moveFilesToNewDirectory)(host, options.ngCliSchematicLibRoot, options.projectRoot);
46
+ (0, devkit_1.moveFilesToNewDirectory)(tree, options.ngCliSchematicLibRoot, options.projectRoot);
46
47
  }
47
- yield (0, update_project_1.updateProject)(host, options);
48
- (0, update_tsconfig_1.updateTsConfig)(host, options);
49
- yield addUnitTestRunner(host, options);
50
- updateNpmScopeIfBuildableOrPublishable(host, options);
51
- (0, add_module_1.addModule)(host, options);
52
- setStrictMode(host, options);
53
- yield addLinting(host, options);
48
+ yield (0, update_project_1.updateProject)(tree, options);
49
+ (0, update_tsconfig_1.updateTsConfig)(tree, options);
50
+ yield addUnitTestRunner(tree, options);
51
+ updateNpmScopeIfBuildableOrPublishable(tree, options);
52
+ if (!options.standalone) {
53
+ (0, add_module_1.addModule)(tree, options);
54
+ }
55
+ else {
56
+ yield (0, add_standalone_component_1.addStandaloneComponent)(tree, options);
57
+ }
58
+ setStrictMode(tree, options);
59
+ yield addLinting(tree, options);
54
60
  if (options.addTailwind) {
55
- yield (0, setup_tailwind_1.default)(host, {
61
+ yield (0, setup_tailwind_1.default)(tree, {
56
62
  project: options.name,
57
63
  skipFormat: true,
58
64
  });
59
65
  }
60
66
  if (options.buildable || options.publishable) {
61
- (0, devkit_1.removeDependenciesFromPackageJson)(host, [], ['ng-packagr']);
62
- (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
67
+ (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['ng-packagr']);
68
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
63
69
  'ng-packagr': versions_1.ngPackagrVersion,
64
70
  });
65
- (0, dependencies_1.addBuildableLibrariesPostCssDependencies)(host);
71
+ (0, dependencies_1.addBuildableLibrariesPostCssDependencies)(tree);
66
72
  }
67
73
  if (options.standaloneConfig) {
68
- yield (0, generators_1.convertToNxProjectGenerator)(host, {
74
+ yield (0, generators_1.convertToNxProjectGenerator)(tree, {
69
75
  project: options.name,
70
76
  all: false,
71
77
  skipFormat: true,
72
78
  });
73
79
  }
74
80
  if (!options.skipFormat) {
75
- yield (0, devkit_1.formatFiles)(host);
81
+ yield (0, devkit_1.formatFiles)(tree);
76
82
  }
77
83
  return () => {
78
- (0, devkit_1.installPackagesTask)(host);
84
+ (0, devkit_1.installPackagesTask)(tree);
79
85
  };
80
86
  });
81
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/library/library.ts"],"names":[],"mappings":";;;;AAAA,yCAOsB;AACtB,8DAAwE;AACxE,qCAAkD;AAClD,yCAAsC;AACtC,2DAAyE;AACzE,qDAA8C;AAE9C,mDAAwD;AACxD,4DAA6D;AAC7D,kEAAmE;AACnE,qEAAsE;AACtE,wDAAiF;AACjF,iDAA6C;AAC7C,mFAG2C;AAC3C,+DAA2D;AAE3D,qFAA8E;AAC9E,yDAAqD;AACrD,2DAAuD;AAGvD,SAAsB,gBAAgB,CAAC,IAAU,EAAE,MAAuB;;QACxE,4BAA4B;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;SAC1E;QAED,IAAI,MAAM,CAAC,WAAW,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACrD,MAAM,IAAI,KAAK,CACb,oJAAoJ,C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M,IAAA,uBAAqB,EAAC,IAAI,EAAE;gBAChC,OAAO,EAAE,OAAO,CAAC,IAAI;gBACrB,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;SACJ;IACH,CAAC;CAAA;AAED,SAAS,sCAAsC,CAC7C,IAAU,EACV,OAAyB;IAEzB,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE;QAC5C,IAAA,uDAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACzC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,IAAU,EAAE,OAAyB;IAC1D,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,IAAA,sDAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACzC;SAAM;QACL,IAAA,qDAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;KAC/C;AACH,CAAC;AAED,SAAe,UAAU,CAAC,IAAU,EAAE,OAAyB;;QAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,eAAM,CAAC,IAAI,EAAE;YAClC,OAAO;SACR;QACD,MAAM,IAAA,qBAAmB,EAAC,IAAI,EAAE;YAC9B,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;YACxD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/library/library.ts"],"names":[],"mappings":";;;;AAAA,yCAOsB;AACtB,8DAAwE;AACxE,qCAAkD;AAClD,yCAAsC;AACtC,2DAAyE;AACzE,qDAA8C;AAE9C,mDAAwD;AACxD,4DAA6D;AAC7D,kEAAmE;AACnE,qEAAsE;AACtE,wDAAiF;AACjF,iDAA6C;AAC7C,mFAG2C;A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W,EAAE,OAAO,CAAC,IAAI;YACzB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;YACxD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;CAAA;AAED,kBAAe,gBAAgB,CAAC"}
@@ -31,4 +31,5 @@ export interface Schema {
31
31
  skipModule?: boolean;
32
32
  skipPackageJson?: boolean;
33
33
  skipPostInstall?: boolean;
34
+ standalone?: boolean;
34
35
  }
@@ -128,6 +128,11 @@
128
128
  "type": "boolean",
129
129
  "description": "Whether to skip the creation of a default module when generating the library.",
130
130
  "default": false
131
+ },
132
+ "standalone": {
133
+ "type": "boolean",
134
+ "description": "Generate a library that uses a standalone component instead of a module as the entry point.",
135
+ "default": false
131
136
  }
132
137
  },
133
138
  "additionalProperties": false,
@@ -0,0 +1,2 @@
1
+ declare const _default: (generatorOptions: import("./schema").Schema) => (tree: any, context: any) => Promise<any>;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nrwl/devkit");
4
+ const scam_to_standalone_1 = require("./scam-to-standalone");
5
+ exports.default = (0, devkit_1.convertNxGenerator)(scam_to_standalone_1.scamToStandalone);
6
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/scam-to-standalone/compat.ts"],"names":[],"mappings":";;AAAA,yCAAkD;AAClD,6DAAwD;AAExD,kBAAe,IAAA,2BAAkB,EAAC,qCAAgB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Node, SourceFile } from 'typescript';
2
+ import { Tree } from 'nx/src/generators/tree';
3
+ export declare function convertScamToStandalone(componentAST: SourceFile, componentFileContents: string, importsArray: string[], providersArray: string[], moduleNodes: Array<Node>, tree: Tree, normalizedComponentPath: string, componentName: string): void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertScamToStandalone = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ const path_1 = require("path");
6
+ const path_2 = require("nx/src/utils/path");
7
+ function convertScamToStandalone(componentAST, componentFileContents, importsArray, providersArray, moduleNodes, tree, normalizedComponentPath, componentName) {
8
+ let newComponentContents = '';
9
+ const COMPONENT_PROPERTY_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression';
10
+ const componentDecoratorMetadataNode = (0, tsquery_1.tsquery)(componentAST, COMPONENT_PROPERTY_SELECTOR, { visitAllChildren: true })[0];
11
+ newComponentContents = `${componentFileContents.slice(0, componentDecoratorMetadataNode.getStart() - 1)}({
12
+ standalone: true,
13
+ imports: [${importsArray.join(',')}],${providersArray.length > 0 ? `providers: [${providersArray.join(',')}],` : ''}${componentFileContents.slice(componentDecoratorMetadataNode.getStart() + 1, moduleNodes[0].getStart() - 1)}`;
14
+ tree.write(normalizedComponentPath, newComponentContents);
15
+ const componentPathParts = (0, path_1.parse)(normalizedComponentPath);
16
+ const pathToComponentSpec = (0, path_2.joinPathFragments)(componentPathParts.dir, '/', `${componentPathParts.name}.spec.ts`);
17
+ if (tree.exists(pathToComponentSpec)) {
18
+ const componentSpecContents = tree.read(pathToComponentSpec, 'utf-8');
19
+ // Only support testbed based tests
20
+ if (componentSpecContents.includes('TestBed')) {
21
+ let newComponentSpecContents = componentSpecContents;
22
+ if (componentSpecContents.includes('imports: [')) {
23
+ newComponentSpecContents = newComponentSpecContents.replace('imports: [', `imports: [${componentName}, `);
24
+ newComponentSpecContents.replace(/declarations: \[.+/, '');
25
+ }
26
+ else {
27
+ newComponentSpecContents = newComponentSpecContents.replace('declarations: [', 'imports: [');
28
+ }
29
+ tree.write(pathToComponentSpec, newComponentSpecContents);
30
+ }
31
+ }
32
+ }
33
+ exports.convertScamToStandalone = convertScamToStandalone;
34
+ //# sourceMappingURL=convert-scam-to-standalone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-scam-to-standalone.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AACpD,+BAA6B;AAC7B,4CAAsD;AAEtD,SAAgB,uBAAuB,CACrC,YAAwB,EACxB,qBAA6B,EAC7B,YAAsB,EACtB,cAAwB,EACxB,WAAwB,EACxB,IAAU,EACV,uBAA+B,EAC/B,aAAqB;IAErB,IAAI,oBAAoB,GAAG,EAAE,CAAC;IAC9B,MAAM,2BAA2B,GAC/B,uGAAuG,CAAC;IAC1G,MAAM,8BAA8B,GAAG,IAAA,iBAAO,EAC5C,YAAY,EACZ,2BAA2B,EAC3B,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC,CAAC,CAAC,CAAC;IAEL,oBAAoB,GAAG,GAAG,qBAAqB,CAAC,KAAK,CACnD,CAAC,EACD,8BAA8B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAC9C;;gBAEa,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAClC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAC5E,GAAG,qBAAqB,CAAC,KAAK,CAC5B,8BAA8B,CAAC,QAAQ,EAAE,GAAG,CAAC,EAC7C,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAC9B,EAAE,CAAC;IAEJ,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;IAE1D,MAAM,kBAAkB,GAAG,IAAA,YAAK,EAAC,uBAAuB,CAAC,CAAC;IAC1D,MAAM,mBAAmB,GAAG,IAAA,wBAAiB,EAC3C,kBAAkB,CAAC,GAAG,EACtB,GAAG,EACH,GAAG,kBAAkB,CAAC,IAAI,UAAU,CACrC,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QACpC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAEtE,mCAAmC;QACnC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC7C,IAAI,wBAAwB,GAAG,qBAAqB,CAAC;YAErD,IAAI,qBAAqB,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;gBAChD,wBAAwB,GAAG,wBAAwB,CAAC,OAAO,CACzD,YAAY,EACZ,aAAa,aAAa,IAAI,CAC/B,CAAC;gBACF,wBAAwB,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;aAC5D;iBAAM;gBACL,wBAAwB,GAAG,wBAAwB,CAAC,OAAO,CACzD,iBAAiB,EACjB,YAAY,CACb,CAAC;aACH;YAED,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;SAC3D;KACF;AACH,CAAC;AA/DD,0DA+DC"}
@@ -0,0 +1,6 @@
1
+ import { Tree } from 'nx/src/generators/tree';
2
+ export declare function getComponentDataFromAST(tree: Tree, normalizedComponentPath: string): {
3
+ componentFileContents: string;
4
+ componentAST: import("typescript").SourceFile;
5
+ componentName: string;
6
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComponentDataFromAST = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ function getComponentDataFromAST(tree, normalizedComponentPath) {
6
+ const COMPONENT_CONTENT_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component]))';
7
+ const COMPONENT_NAME_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component])) > Identifier';
8
+ const componentFileContents = tree.read(normalizedComponentPath, 'utf-8');
9
+ const componentAST = tsquery_1.tsquery.ast(componentFileContents);
10
+ const componentNode = (0, tsquery_1.tsquery)(componentAST, COMPONENT_CONTENT_SELECTOR, {
11
+ visitAllChildren: true,
12
+ })[0];
13
+ const componentContents = componentFileContents.slice(componentNode.getStart(), componentNode.getEnd());
14
+ const componentNameNode = (0, tsquery_1.tsquery)(tsquery_1.tsquery.ast(componentContents), COMPONENT_NAME_SELECTOR, { visitAllChildren: true })[0];
15
+ const componentName = componentNameNode.getText();
16
+ return { componentFileContents, componentAST, componentName };
17
+ }
18
+ exports.getComponentDataFromAST = getComponentDataFromAST;
19
+ //# sourceMappingURL=get-component-data-from-ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-component-data-from-ast.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-component-data-from-ast.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,SAAgB,uBAAuB,CACrC,IAAU,EACV,uBAA+B;IAE/B,MAAM,0BAA0B,GAC9B,kFAAkF,CAAC;IACrF,MAAM,uBAAuB,GAC3B,+FAA+F,CAAC;IAElG,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,YAAY,GAAG,iBAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAExD,MAAM,aAAa,GAAG,IAAA,iBAAO,EAAC,YAAY,EAAE,0BAA0B,EAAE;QACtE,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,KAAK,CACnD,aAAa,CAAC,QAAQ,EAAE,EACxB,aAAa,CAAC,MAAM,EAAE,CACvB,CAAC;IAEF,MAAM,iBAAiB,GAAG,IAAA,iBAAO,EAC/B,iBAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAC9B,uBAAuB,EACvB,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC,CAAC,CAAC,CAAC;IACL,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAClD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChE,CAAC;AA3BD,0DA2BC"}
@@ -0,0 +1,9 @@
1
+ import { SourceFile } from 'typescript';
2
+ export declare function getModuleMetadataFromAST(componentAST: SourceFile, componentFileContents: string): {
3
+ moduleNodes: import("typescript").Node[];
4
+ exportsArray: string[];
5
+ importsArray: string[];
6
+ declarationsArray: string[];
7
+ providersArray: string[];
8
+ moduleName: string;
9
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getModuleMetadataFromAST = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ function getModuleMetadataFromAST(componentAST, componentFileContents) {
6
+ const NGMODULE_CONTENT_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=NgModule]))';
7
+ const moduleNodes = (0, tsquery_1.tsquery)(componentAST, NGMODULE_CONTENT_SELECTOR, {
8
+ visitAllChildren: true,
9
+ });
10
+ const moduleContents = componentFileContents.slice(moduleNodes[0].getStart(), moduleNodes[0].getEnd());
11
+ // verify module is a scam
12
+ const NGMODULE_EXPORTS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=exports]) ArrayLiteralExpression';
13
+ const NGMODULE_DECLARATIONS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=declarations]) ArrayLiteralExpression';
14
+ const NGMODULE_IMPORTS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=imports]) ArrayLiteralExpression';
15
+ const NGMODULE_PROVIDERS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=providers]) ArrayLiteralExpression';
16
+ const NGMODULE_NAME_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=NgModule])) > Identifier';
17
+ const moduleAST = tsquery_1.tsquery.ast(moduleContents);
18
+ const importsNode = (0, tsquery_1.tsquery)(moduleAST, NGMODULE_IMPORTS_SELECTOR, {
19
+ visitAllChildren: true,
20
+ })[0];
21
+ const exportsNode = (0, tsquery_1.tsquery)(moduleAST, NGMODULE_EXPORTS_SELECTOR, {
22
+ visitAllChildren: true,
23
+ })[0];
24
+ const declarationsNode = (0, tsquery_1.tsquery)(moduleAST, NGMODULE_DECLARATIONS_SELECTOR, {
25
+ visitAllChildren: true,
26
+ })[0];
27
+ const providersNodes = (0, tsquery_1.tsquery)(moduleAST, NGMODULE_PROVIDERS_SELECTOR, {
28
+ visitAllChildren: true,
29
+ });
30
+ const exportsArray = moduleContents
31
+ .slice(exportsNode.getStart(), exportsNode.getEnd())
32
+ .replace('[', '')
33
+ .replace(']', '')
34
+ .split(',');
35
+ const importsArray = moduleContents
36
+ .slice(importsNode.getStart(), importsNode.getEnd())
37
+ .replace('[', '')
38
+ .replace(']', '')
39
+ .split(',');
40
+ const declarationsArray = moduleContents
41
+ .slice(declarationsNode.getStart(), declarationsNode.getEnd())
42
+ .replace('[', '')
43
+ .replace(']', '')
44
+ .split(',');
45
+ const providersArray = providersNodes.length > 0
46
+ ? moduleContents
47
+ .slice(providersNodes[0].getStart(), providersNodes[0].getEnd())
48
+ .replace('[', '')
49
+ .replace(']', '')
50
+ .split(',')
51
+ : [];
52
+ const moduleName = (0, tsquery_1.tsquery)(moduleAST, NGMODULE_NAME_SELECTOR, {
53
+ visitAllChildren: true,
54
+ })[0].getText();
55
+ return {
56
+ moduleNodes,
57
+ exportsArray,
58
+ importsArray,
59
+ declarationsArray,
60
+ providersArray,
61
+ moduleName,
62
+ };
63
+ }
64
+ exports.getModuleMetadataFromAST = getModuleMetadataFromAST;
65
+ //# sourceMappingURL=get-module-metadata-from-ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-module-metadata-from-ast.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,SAAgB,wBAAwB,CACtC,YAAwB,EACxB,qBAA6B;IAE7B,MAAM,yBAAyB,GAC7B,iFAAiF,CAAC;IACpF,MAAM,WAAW,GAAG,IAAA,iBAAO,EAAC,YAAY,EAAE,yBAAyB,EAAE;QACnE,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,qBAAqB,CAAC,KAAK,CAChD,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EACzB,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CACxB,CAAC;IAEF,0BAA0B;IAC1B,MAAM,yBAAyB,GAC7B,gLAAgL,CAAC;IACnL,MAAM,8BAA8B,GAClC,qLAAqL,CAAC;IACxL,MAAM,yBAAyB,GAC7B,gLAAgL,CAAC;IACnL,MAAM,2BAA2B,GAC/B,kLAAkL,CAAC;IACrL,MAAM,sBAAsB,GAC1B,8FAA8F,CAAC;IAEjG,MAAM,SAAS,GAAG,iBAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAA,iBAAO,EAAC,SAAS,EAAE,yBAAyB,EAAE;QAChE,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,WAAW,GAAG,IAAA,iBAAO,EAAC,SAAS,EAAE,yBAAyB,EAAE;QAChE,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,gBAAgB,GAAG,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AC,CAAC,EAAE,CAAC;IACT,MAAM,UAAU,GAAG,IAAA,iBAAO,EAAC,SAAS,EAAE,sBAAsB,EAAE;QAC5D,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChB,OAAO;QACL,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,iBAAiB;QACjB,cAAc;QACd,UAAU;KACX,CAAC;AACJ,CAAC;AA1ED,4DA0EC"}
@@ -0,0 +1,2 @@
1
+ import { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
2
+ export declare function getTargetProject(projectName: string, projects: Map<string, ProjectConfiguration>): ProjectConfiguration;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTargetProject = void 0;
4
+ function getTargetProject(projectName, projects) {
5
+ let project;
6
+ if (projectName && !projects.has(projectName)) {
7
+ throw new Error(`Project (${projectName}) does not exist in the workspace! Please provide a valid project name.`);
8
+ }
9
+ else if (projectName && projects.has(projectName)) {
10
+ project = projects.get(projectName);
11
+ }
12
+ return project;
13
+ }
14
+ exports.getTargetProject = getTargetProject;
15
+ //# sourceMappingURL=get-target-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-target-project.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-target-project.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAC9B,WAAmB,EACnB,QAA2C;IAE3C,IAAI,OAA6B,CAAC;IAClC,IAAI,WAAW,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CACb,YAAY,WAAW,yEAAyE,CACjG,CAAC;KACH;SAAM,IAAI,WAAW,IAAI,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;QACnD,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KACrC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,4CAaC"}
@@ -0,0 +1,8 @@
1
+ export * from './convert-scam-to-standalone';
2
+ export * from './get-component-data-from-ast';
3
+ export * from './get-module-metadata-from-ast';
4
+ export * from './get-target-project';
5
+ export * from './replace-module-usages-with-component';
6
+ export * from './selector-exists-in-ast';
7
+ export * from './verify-is-inline-scam';
8
+ export * from './verify-module-is-scam';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./convert-scam-to-standalone"), exports);
5
+ tslib_1.__exportStar(require("./get-component-data-from-ast"), exports);
6
+ tslib_1.__exportStar(require("./get-module-metadata-from-ast"), exports);
7
+ tslib_1.__exportStar(require("./get-target-project"), exports);
8
+ tslib_1.__exportStar(require("./replace-module-usages-with-component"), exports);
9
+ tslib_1.__exportStar(require("./selector-exists-in-ast"), exports);
10
+ tslib_1.__exportStar(require("./verify-is-inline-scam"), exports);
11
+ tslib_1.__exportStar(require("./verify-module-is-scam"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,wEAA8C;AAC9C,yEAA+C;AAC/C,+DAAqC;AACrC,iFAAuD;AACvD,mEAAyC;AACzC,kEAAwC;AACxC,kEAAwC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from 'nx/src/generators/tree';
2
+ export declare function replaceModuleUsagesWithComponent(tree: Tree, moduleName: string, componentName: string): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceModuleUsagesWithComponent = void 0;
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const path_1 = require("path");
6
+ function replaceModuleUsagesWithComponent(tree, moduleName, componentName) {
7
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
8
+ if ((0, path_1.extname)(path) !== '.ts') {
9
+ return;
10
+ }
11
+ const fileContents = tree.read(path, 'utf-8');
12
+ if (fileContents.includes(moduleName)) {
13
+ const moduleNameRegex = new RegExp(moduleName, 'g');
14
+ const newFileContents = fileContents.replace(moduleNameRegex, componentName);
15
+ tree.write(path, newFileContents);
16
+ }
17
+ });
18
+ }
19
+ exports.replaceModuleUsagesWithComponent = replaceModuleUsagesWithComponent;
20
+ //# sourceMappingURL=replace-module-usages-with-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-module-usages-with-component.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/replace-module-usages-with-component.ts"],"names":[],"mappings":";;;AACA,yCAAoD;AACpD,+BAA+B;AAE/B,SAAgB,gCAAgC,CAC9C,IAAU,EACV,UAAkB,EAClB,aAAqB;IAErB,IAAA,6BAAoB,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACvC,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,KAAK,KAAK,EAAE;YAC3B,OAAO;SACR;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACrC,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;YACpD,MAAM,eAAe,GAAG,YAAY,CAAC,OAAO,CAC1C,eAAe,EACf,aAAa,CACd,CAAC;YACF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;SACnC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,4EAmBC"}
@@ -0,0 +1,2 @@
1
+ import { SourceFile } from 'typescript';
2
+ export declare function selectorExistsInAST(selector: string, ast: SourceFile): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectorExistsInAST = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ function selectorExistsInAST(selector, ast) {
6
+ return (0, tsquery_1.tsquery)(ast, selector, { visitAllChildren: true }).length > 0;
7
+ }
8
+ exports.selectorExistsInAST = selectorExistsInAST;
9
+ //# sourceMappingURL=selector-exists-in-ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector-exists-in-ast.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/selector-exists-in-ast.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,SAAgB,mBAAmB,CAAC,QAAgB,EAAE,GAAe;IACnE,OAAO,IAAA,iBAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACvE,CAAC;AAFD,kDAEC"}
@@ -0,0 +1,2 @@
1
+ import { SourceFile } from 'typescript';
2
+ export declare function verifyIsInlineScam(componentAST: SourceFile): boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyIsInlineScam = void 0;
4
+ const selector_exists_in_ast_1 = require("./selector-exists-in-ast");
5
+ function verifyIsInlineScam(componentAST) {
6
+ const NGMODULE_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule])';
7
+ const COMPONENT_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=Component])';
8
+ return ((0, selector_exists_in_ast_1.selectorExistsInAST)(COMPONENT_DECORATOR_SELECTOR, componentAST) &&
9
+ (0, selector_exists_in_ast_1.selectorExistsInAST)(NGMODULE_DECORATOR_SELECTOR, componentAST));
10
+ }
11
+ exports.verifyIsInlineScam = verifyIsInlineScam;
12
+ //# sourceMappingURL=verify-is-inline-scam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-is-inline-scam.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/verify-is-inline-scam.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAG/D,SAAgB,kBAAkB,CAAC,YAAwB;IACzD,MAAM,2BAA2B,GAC/B,8EAA8E,CAAC;IACjF,MAAM,4BAA4B,GAChC,+EAA+E,CAAC;IAElF,OAAO,CACL,IAAA,4CAAmB,EAAC,4BAA4B,EAAE,YAAY,CAAC;QAC/D,IAAA,4CAAmB,EAAC,2BAA2B,EAAE,YAAY,CAAC,CAC/D,CAAC;AACJ,CAAC;AAVD,gDAUC"}
@@ -0,0 +1 @@
1
+ export declare function verifyModuleIsScam(exportsArray: string[], componentName: string, declarationsArray: string[]): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyModuleIsScam = void 0;
4
+ function verifyModuleIsScam(exportsArray, componentName, declarationsArray) {
5
+ // Check exports has 1 export and check export exists in declaration and is the same as the component name
6
+ if (exportsArray.length !== 1 &&
7
+ !(exportsArray.includes(componentName) &&
8
+ declarationsArray.includes(componentName))) {
9
+ throw new Error(`The NgModule is not a SCAM. Please ensure the NgModule only contains one export and that the component is both declared and exported from the NgModule.`);
10
+ }
11
+ }
12
+ exports.verifyModuleIsScam = verifyModuleIsScam;
13
+ //# sourceMappingURL=verify-module-is-scam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-module-is-scam.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/verify-module-is-scam.ts"],"names":[],"mappings":";;;AAAA,SAAgB,kBAAkB,CAChC,YAAsB,EACtB,aAAqB,EACrB,iBAA2B;IAE3B,0GAA0G;IAC1G,IACE,YAAY,CAAC,MAAM,KAAK,CAAC;QACzB,CAAC,CACC,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC;YACpC,iBAAiB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAC1C,EACD;QACA,MAAM,IAAI,KAAK,CACb,yJAAyJ,CAC1J,CAAC;KACH;AACH,CAAC;AAjBD,gDAiBC"}
@@ -0,0 +1,4 @@
1
+ import type { Tree } from '@nrwl/devkit';
2
+ import type { Schema } from './schema';
3
+ export declare function scamToStandalone(tree: Tree, { component, project: projectName, skipFormat }: Schema): Promise<void>;
4
+ export default scamToStandalone;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scamToStandalone = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nrwl/devkit");
6
+ const lib_1 = require("./lib");
7
+ function scamToStandalone(tree, { component, project: projectName, skipFormat }) {
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ let project = (0, lib_1.getTargetProject)(projectName, projects);
11
+ const normalizedComponentPath = (0, devkit_1.joinPathFragments)(project.root, component);
12
+ if (!tree.exists(normalizedComponentPath)) {
13
+ throw new Error(`The path provided to the component (${normalizedComponentPath}) does not exist. Please ensure the correct path has been provided.`);
14
+ }
15
+ const { componentFileContents, componentAST, componentName } = (0, lib_1.getComponentDataFromAST)(tree, normalizedComponentPath);
16
+ const isInlineScam = (0, lib_1.verifyIsInlineScam)(componentAST);
17
+ if (!isInlineScam) {
18
+ throw new Error('This generator currently only supports inline SCAMs. We could not find an accompanying NgModule within the component file, please ensure the SCAM provided is an inline scam.');
19
+ }
20
+ const { moduleNodes, exportsArray, importsArray, declarationsArray, providersArray, moduleName, } = (0, lib_1.getModuleMetadataFromAST)(componentAST, componentFileContents);
21
+ (0, lib_1.verifyModuleIsScam)(exportsArray, componentName, declarationsArray);
22
+ (0, lib_1.convertScamToStandalone)(componentAST, componentFileContents, importsArray, providersArray, moduleNodes, tree, normalizedComponentPath, componentName);
23
+ (0, lib_1.replaceModuleUsagesWithComponent)(tree, moduleName, componentName);
24
+ if (!skipFormat) {
25
+ yield (0, devkit_1.formatFiles)(tree);
26
+ }
27
+ });
28
+ }
29
+ exports.scamToStandalone = scamToStandalone;
30
+ exports.default = scamToStandalone;
31
+ //# sourceMappingURL=scam-to-standalone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scam-to-standalone.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/scam-to-standalone/scam-to-standalone.ts"],"names":[],"mappings":";;;;AACA,yCAA2E;AAE3E,+BAQe;AAEf,SAAsB,gBAAgB,CACpC,IAAU,EACV,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAU;;QAEvD,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QACnC,IAAI,OAAO,GAAG,IAAA,sBAAgB,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAEtD,MAAM,uBAAuB,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE;YACzC,MAAM,IAAI,KAAK,CACb,uCAAuC,uBAAuB,qEAAqE,CACpI,CAAC;SACH;QAED,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,GAC1D,IAAA,6BAAuB,EAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;QAEzD,MAAM,YAAY,GAAG,IAAA,wBAAkB,EAAC,YAAY,CAAC,CAAC;QAEtD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,KAAK,CACb,+KAA+K,CAChL,CAAC;SACH;QAED,MAAM,EACJ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,GACX,GAAG,IAAA,8BAAwB,EAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;QAElE,IAAA,wBAAkB,EAAC,YAAY,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;QAEnE,IAAA,6BAAuB,EACrB,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,IAAI,EACJ,uBAAuB,EACvB,aAAa,CACd,CAAC;QAEF,IAAA,sCAAgC,EAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QAElE,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AApDD,4CAoDC;AAED,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface Schema {
2
+ component: string;
3
+ project: string;
4
+ skipFormat?: boolean;
5
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "GeneratorAngularScamToStandalone",
4
+ "cli": "nx",
5
+ "title": "Convert an Inline SCAM to Standalone Component",
6
+ "description": "Convert an Inline SCAM to a Standalone Component.",
7
+ "type": "object",
8
+ "properties": {
9
+ "component": {
10
+ "type": "string",
11
+ "description": "The path to the SCAM component file, relative to the root of the project containing the SCAM.",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ }
16
+ },
17
+ "project": {
18
+ "type": "string",
19
+ "description": "The project containing the SCAM.",
20
+ "x-prompt": "What project contains the SCAM?",
21
+ "x-dropdown": "projects"
22
+ },
23
+ "skipFormat": {
24
+ "type": "boolean",
25
+ "description": "Skip formatting the workspace after the generator completes."
26
+ }
27
+ }
28
+ }
@@ -9,18 +9,30 @@ const path_1 = require("path");
9
9
  const webpack_1 = require("webpack");
10
10
  const typescript_2 = require("./typescript");
11
11
  const utils_1 = require("./utils");
12
- function collectWorkspaceLibrarySecondaryEntryPoints(library, libraryRoot, tsconfigPathAliases) {
13
- const aliasesUnderLibrary = Object.keys(tsconfigPathAliases).filter((libName) => libName.startsWith(library) && libName !== library);
12
+ function collectWorkspaceLibrarySecondaryEntryPoints(library, tsconfigPathAliases) {
13
+ const libraryRoot = (0, path_1.join)(devkit_1.workspaceRoot, library.root);
14
+ const needsSecondaryEntryPointsCollected = (0, fs_1.existsSync)((0, path_1.join)(libraryRoot, 'ng-package.json'));
14
15
  const secondaryEntryPoints = [];
15
- for (const alias of aliasesUnderLibrary) {
16
- const pathToLib = (0, path_1.dirname)((0, path_1.join)(devkit_1.workspaceRoot, tsconfigPathAliases[alias][0]));
17
- let searchDir = pathToLib;
18
- while (searchDir !== libraryRoot) {
19
- if ((0, fs_1.existsSync)((0, path_1.join)(searchDir, 'ng-package.json'))) {
20
- secondaryEntryPoints.push({ name: alias, path: pathToLib });
21
- break;
16
+ if (needsSecondaryEntryPointsCollected) {
17
+ const tsConfigAliasesForLibWithSecondaryEntryPoints = Object.entries(tsconfigPathAliases).reduce((acc, [tsKey, tsPaths]) => {
18
+ if (!tsKey.startsWith(library.importKey)) {
19
+ return Object.assign({}, acc);
20
+ }
21
+ if (tsPaths.some((path) => path.startsWith(`${library.root}/`))) {
22
+ acc = Object.assign(Object.assign({}, acc), { [tsKey]: tsPaths });
23
+ }
24
+ return acc;
25
+ }, {});
26
+ for (const [alias] of Object.entries(tsConfigAliasesForLibWithSecondaryEntryPoints)) {
27
+ const pathToLib = (0, path_1.dirname)((0, path_1.join)(devkit_1.workspaceRoot, tsconfigPathAliases[alias][0]));
28
+ let searchDir = pathToLib;
29
+ while (searchDir !== libraryRoot) {
30
+ if ((0, fs_1.existsSync)((0, path_1.join)(searchDir, 'ng-package.json'))) {
31
+ secondaryEntryPoints.push({ name: alias, path: pathToLib });
32
+ break;
33
+ }
34
+ searchDir = (0, path_1.dirname)(searchDir);
22
35
  }
23
- searchDir = (0, path_1.dirname)(searchDir);
24
36
  }
25
37
  }
26
38
  return secondaryEntryPoints;
@@ -41,7 +53,7 @@ function shareWorkspaceLibraries(libraries, tsConfigPath) {
41
53
  if (!library) {
42
54
  continue;
43
55
  }
44
- collectWorkspaceLibrarySecondaryEntryPoints(key, (0, path_1.join)(devkit_1.workspaceRoot, library.root), tsconfigPathAliases).forEach(({ name, path }) => pathMappings.push({
56
+ collectWorkspaceLibrarySecondaryEntryPoints(library, tsconfigPathAliases).forEach(({ name, path }) => pathMappings.push({
45
57
  name,
46
58
  path,
47
59
  }));