@nrwl/angular 13.5.0-beta.9 → 13.5.2

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 CHANGED
@@ -21,4 +21,64 @@ Nx is a next generation build system with first class monorepo support and power
21
21
 
22
22
  This package is an [Angular plugin for Nx](https://nx.dev/angular/overview).
23
23
 
24
- {{content}
24
+ ## Getting Started
25
+
26
+ ### Creating an Nx Workspace
27
+
28
+ **Using `npx`**
29
+
30
+ ```bash
31
+ npx create-nx-workspace
32
+ ```
33
+
34
+ **Using `npm init`**
35
+
36
+ ```bash
37
+ npm init nx-workspace
38
+ ```
39
+
40
+ **Using `yarn create`**
41
+
42
+ ```bash
43
+ yarn create nx-workspace
44
+ ```
45
+
46
+ The `create-nx-workspace` command will ask you to select a preset, which will configure some plugins and create your applications to help you get started.
47
+
48
+ ```
49
+ ? What to create in the new workspace (Use arrow keys)
50
+ ❯ apps [an empty workspace with no plugins with a layout that works best for building apps]
51
+ core [an empty workspace with no plugins set up to publish npm packages (similar to yarn workspaces)]
52
+ ts [an empty workspace with the JS/TS plugin preinstalled]
53
+ react [a workspace with a single React application]
54
+ angular [a workspace with a single Angular application]
55
+ next.js [a workspace with a single Next.js application]
56
+ nest [a workspace with a single Nest application]
57
+ express [a workspace with a single Express application]
58
+ web components [a workspace with a single app built using web components]
59
+ react-native [a workspace with a single React Native application]
60
+ react-express [a workspace with a full stack application (React + Express)]
61
+ ```
62
+
63
+ Select the preset that works best for you
64
+
65
+ ### Adding Nx to an Existing Monorepo
66
+
67
+ Run:
68
+
69
+ ```bash
70
+ npx add-nx-to-monorepo@latest
71
+ ```
72
+
73
+ ## Documentation & Resources
74
+
75
+ A few links to help you get started:
76
+
77
+ - [Nx.Dev: Documentation, Guides, Interactive Tutorials](https://nx.dev)
78
+ - [Tutorial: Adding Nx to an Existing Monorepo](https://nx.dev/migration/adding-to-monorepo)
79
+ - [Official Nx YouTube Channel](https://www.youtube.com/c/Nrwl_io)
80
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
81
+
82
+ <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
83
+ width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
84
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/angular",
3
- "version": "13.5.0-beta.9",
3
+ "version": "13.5.2",
4
4
  "description": "Angular Plugin for Nx",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,11 +56,11 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@angular-devkit/schematics": "~13.1.0",
59
- "@nrwl/cypress": "13.5.0-beta.9",
60
- "@nrwl/devkit": "13.5.0-beta.9",
61
- "@nrwl/jest": "13.5.0-beta.9",
62
- "@nrwl/linter": "13.5.0-beta.9",
63
- "@nrwl/storybook": "13.5.0-beta.9",
59
+ "@nrwl/cypress": "13.5.2",
60
+ "@nrwl/devkit": "13.5.2",
61
+ "@nrwl/jest": "13.5.2",
62
+ "@nrwl/linter": "13.5.2",
63
+ "@nrwl/storybook": "13.5.2",
64
64
  "@schematics/angular": "~13.1.0",
65
65
  "@phenomnomnominal/tsquery": "4.1.1",
66
66
  "ignore": "^5.0.4",
@@ -747,9 +747,9 @@ nx g @nrwl/angular:component button --project ui</pre>
747
747
  d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
748
748
  />
749
749
  </svg>
750
- View interactive dependency graph
750
+ View interactive project graph
751
751
  </summary>
752
- <pre>nx dep-graph</pre>
752
+ <pre>nx graph</pre>
753
753
  </details>
754
754
  <details>
755
755
  <summary>
@@ -769,7 +769,7 @@ nx g @nrwl/angular:component button --project ui</pre>
769
769
  Run affected commands
770
770
  </summary>
771
771
  <pre><span># see what&apos;s been affected by changes</span>
772
- nx affected:dep-graph
772
+ nx affected:graph
773
773
 
774
774
  <span># run tests for current changes</span>
775
775
  nx affected:test
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nrwl/devkit';
1
+ import { Tree } from '@nrwl/devkit';
2
2
  import type { Schema } from '../schema';
3
3
  export declare function createScam(tree: Tree, schema: Schema): void;
@@ -2,24 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createScam = void 0;
4
4
  const devkit_1 = require("@nrwl/devkit");
5
+ const devkit_2 = require("@nrwl/devkit");
5
6
  const ast_utils_1 = require("@nrwl/workspace/src/utilities/ast-utils");
6
7
  const typescript_1 = require("typescript");
7
8
  function createScam(tree, schema) {
8
9
  var _a, _b, _c;
9
- const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_1.readWorkspaceConfiguration)(tree).defaultProject;
10
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
11
- const componentNames = (0, devkit_1.names)(schema.name);
12
- const typeNames = (0, devkit_1.names)((_b = schema.type) !== null && _b !== void 0 ? _b : 'component');
10
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
11
+ const projectConfig = (0, devkit_2.readProjectConfiguration)(tree, project);
12
+ const componentNames = (0, devkit_2.names)(schema.name);
13
+ const typeNames = (0, devkit_2.names)((_b = schema.type) !== null && _b !== void 0 ? _b : 'component');
13
14
  const componentFileName = `${componentNames.fileName}.${(_c = schema.type) !== null && _c !== void 0 ? _c : 'component'}`;
14
15
  let componentDirectory = schema.flat
15
- ? (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
16
- : (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', componentNames.fileName);
16
+ ? (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
17
+ : (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', componentNames.fileName);
17
18
  if (schema.path) {
18
19
  componentDirectory = schema.flat
19
- ? (0, devkit_1.normalizePath)(schema.path)
20
- : (0, devkit_1.joinPathFragments)(schema.path, componentNames.fileName);
20
+ ? (0, devkit_2.normalizePath)(schema.path)
21
+ : (0, devkit_2.joinPathFragments)(schema.path, componentNames.fileName);
21
22
  }
22
- const componentFilePath = (0, devkit_1.joinPathFragments)(componentDirectory, `${componentFileName}.ts`);
23
+ const componentFilePath = (0, devkit_2.joinPathFragments)(componentDirectory, `${componentFileName}.ts`);
23
24
  if (!tree.exists(componentFilePath)) {
24
25
  throw new Error(`Couldn't find component at path ${componentFilePath} to add SCAM setup.`);
25
26
  }
@@ -31,11 +32,46 @@ function createScam(tree, schema) {
31
32
  let updatedComponentSource = source.getText();
32
33
  updatedComponentSource = `${updatedComponentSource}${createAngularComponentModule(`${componentNames.className}${typeNames.className}`)}`;
33
34
  tree.write(componentFilePath, updatedComponentSource);
35
+ exportScam(tree, schema, componentFilePath);
34
36
  return;
35
37
  }
36
- tree.write((0, devkit_1.joinPathFragments)(componentDirectory, `${componentNames.fileName}.module.ts`), createSeparateAngularComponentModuleFile(`${componentNames.className}${typeNames.className}`, componentFileName));
38
+ const scamFilePath = (0, devkit_2.joinPathFragments)(componentDirectory, `${componentNames.fileName}.module.ts`);
39
+ tree.write(scamFilePath, createSeparateAngularComponentModuleFile(`${componentNames.className}${typeNames.className}`, componentFileName));
40
+ exportScam(tree, schema, scamFilePath);
37
41
  }
38
42
  exports.createScam = createScam;
43
+ function exportScam(tree, schema, scamFilePath) {
44
+ var _a, _b;
45
+ if (!schema.export) {
46
+ return;
47
+ }
48
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
49
+ const { root, sourceRoot, projectType } = (0, devkit_2.readProjectConfiguration)(tree, project);
50
+ if (projectType === 'application') {
51
+ devkit_1.logger.warn('--export=true was ignored as the project the SCAM is being generated in is not a library.');
52
+ return;
53
+ }
54
+ const ngPackageJsonPath = (0, devkit_2.joinPathFragments)(root, 'ng-package.json');
55
+ const ngPackageEntryPoint = tree.exists(ngPackageJsonPath)
56
+ ? (_b = (0, devkit_1.readJson)(tree, ngPackageJsonPath).lib) === null || _b === void 0 ? void 0 : _b.entryFile
57
+ : undefined;
58
+ const projectEntryPoint = ngPackageEntryPoint
59
+ ? (0, devkit_2.joinPathFragments)(root, ngPackageEntryPoint)
60
+ : (0, devkit_2.joinPathFragments)(sourceRoot, `index.ts`);
61
+ if (!tree.exists(projectEntryPoint)) {
62
+ // Let's not error, simply warn the user
63
+ // It's not too much effort to manually do this
64
+ // It would be more frustrating to have to find the correct path and re-run the command
65
+ devkit_1.logger.warn(`Could not export SCAM. Unable to determine project's entry point. Path ${projectEntryPoint} does not exist. SCAM has still been created.`);
66
+ return;
67
+ }
68
+ const relativePathFromEntryPoint = `.${scamFilePath
69
+ .split(sourceRoot)[1]
70
+ .replace('.ts', '')}`;
71
+ const updateEntryPointContent = `${tree.read(projectEntryPoint)}
72
+ export * from "${relativePathFromEntryPoint}";`;
73
+ tree.write(projectEntryPoint, updateEntryPointContent);
74
+ }
39
75
  function createAngularComponentModule(name) {
40
76
  return `
41
77
  @NgModule({
@@ -1 +1 @@
1
- {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam/lib/create-module.ts"],"names":[],"mappings":";;;AAGA,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,UAAU,CAAC,IAAU,EAAE,MAAc;;IACnD,MAAM,OAAO,GACX,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mCAA0B,EAAC,IAAI,CAAC,CAAC,cAAc,CAAC;IACpE,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,cAAc,GAAG,IAAA,cAAK,EA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,iBAAiB,EACjB,wBAAwB,EACxB,yBAAY,CAAC,MAAM,EACnB,IAAI,CACL,CAAC;QAEF,MAAM,GAAG,IAAA,wBAAY,EACnB,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,eAAe,CAChB,CAAC;QAEF,MAAM,GAAG,IAAA,wBAAY,EACnB,IAAI,EACJ,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,iBAAiB,CAClB,CAAC;QAEF,IAAI,sBAAsB,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAE9C,sBAAsB,GAAG,GAAG,sBAAsB,GAAG,4BAA4B,CAC/E,GAAG,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,CACpD,EAAE,CAAC;QAEJ,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;QACtD,OAAO;KACR;IAED,IAAI,CAAC,KAAK,CACR,IAAA,0BAAiB,EACf,kBAAkB,EAClB,GAAG,cAAc,CAAC,QAAQ,YAAY,CACvC,EACD,wCAAwC,CACtC,GAAG,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,EACnD,iBAAiB,CAClB,CACF,CAAC;AACJ,CAAC;AArFD,gCAqFC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,wCAAwC,CAC/C,IAAY,EACZ,iBAAyB;IAEzB,OAAO;;WAEE,IAAI,cAAc,iBAAiB;EAC5C,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;AACvC,CAAC"}
1
+ {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam/lib/create-module.ts"],"names":[],"mappings":";;;AAAA,yCAAsD;AAGtD,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,UAAU,CAAC,IAAU,EAAE,MAA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,CAAC;IAEhD,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,wCAAwC,CAC/C,IAAY,EACZ,iBAAyB;IAEzB,OAAO;;WAEE,IAAI,cAAc,iBAAiB;EAC5C,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;AACvC,CAAC"}
@@ -15,4 +15,5 @@ export interface Schema {
15
15
  prefix?: string;
16
16
  selector?: string;
17
17
  skipSelector?: boolean;
18
+ export?: boolean;
18
19
  }
@@ -109,6 +109,11 @@
109
109
  "format": "html-selector"
110
110
  }
111
111
  ]
112
+ },
113
+ "export": {
114
+ "type": "boolean",
115
+ "description": "Specifies if the SCAM should be exported from the project's entry point (normally `index.ts`). It only applies to libraries.",
116
+ "default": false
112
117
  }
113
118
  },
114
119
  "required": ["name"]
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nrwl/devkit';
1
+ import { Tree } from '@nrwl/devkit';
2
2
  import type { Schema } from '../schema';
3
3
  export declare function createScamDirective(tree: Tree, schema: Schema): void;
@@ -2,24 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createScamDirective = void 0;
4
4
  const devkit_1 = require("@nrwl/devkit");
5
+ const devkit_2 = require("@nrwl/devkit");
5
6
  const ast_utils_1 = require("@nrwl/workspace/src/utilities/ast-utils");
6
7
  const typescript_1 = require("typescript");
7
8
  function createScamDirective(tree, schema) {
8
9
  var _a;
9
- const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_1.readWorkspaceConfiguration)(tree).defaultProject;
10
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
11
- const directiveNames = (0, devkit_1.names)(schema.name);
12
- const typeNames = (0, devkit_1.names)('directive');
10
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
11
+ const projectConfig = (0, devkit_2.readProjectConfiguration)(tree, project);
12
+ const directiveNames = (0, devkit_2.names)(schema.name);
13
+ const typeNames = (0, devkit_2.names)('directive');
13
14
  const directiveFileName = `${directiveNames.fileName}.directive`;
14
15
  let directiveDirectory = schema.flat
15
- ? (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
16
- : (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', directiveNames.fileName);
16
+ ? (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
17
+ : (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', directiveNames.fileName);
17
18
  if (schema.path) {
18
19
  directiveDirectory = schema.flat
19
- ? (0, devkit_1.normalizePath)(schema.path)
20
- : (0, devkit_1.joinPathFragments)(schema.path, directiveNames.fileName);
20
+ ? (0, devkit_2.normalizePath)(schema.path)
21
+ : (0, devkit_2.joinPathFragments)(schema.path, directiveNames.fileName);
21
22
  }
22
- const directiveFilePath = (0, devkit_1.joinPathFragments)(directiveDirectory, `${directiveFileName}.ts`);
23
+ const directiveFilePath = (0, devkit_2.joinPathFragments)(directiveDirectory, `${directiveFileName}.ts`);
23
24
  if (!tree.exists(directiveFilePath)) {
24
25
  throw new Error(`Couldn't find directive at path ${directiveFilePath} to add SCAM setup.`);
25
26
  }
@@ -31,11 +32,46 @@ function createScamDirective(tree, schema) {
31
32
  let updatedDirectiveSource = source.getText();
32
33
  updatedDirectiveSource = `${updatedDirectiveSource}${createAngularDirectiveModule(`${directiveNames.className}${typeNames.className}`)}`;
33
34
  tree.write(directiveFilePath, updatedDirectiveSource);
35
+ exportScam(tree, schema, directiveFilePath);
34
36
  return;
35
37
  }
36
- tree.write((0, devkit_1.joinPathFragments)(directiveDirectory, `${directiveNames.fileName}.module.ts`), createSeparateAngularDirectiveModuleFile(`${directiveNames.className}${typeNames.className}`, directiveFileName));
38
+ const scamFilePath = (0, devkit_2.joinPathFragments)(directiveDirectory, `${directiveNames.fileName}.module.ts`);
39
+ tree.write(scamFilePath, createSeparateAngularDirectiveModuleFile(`${directiveNames.className}${typeNames.className}`, directiveFileName));
40
+ exportScam(tree, schema, scamFilePath);
37
41
  }
38
42
  exports.createScamDirective = createScamDirective;
43
+ function exportScam(tree, schema, scamFilePath) {
44
+ var _a, _b;
45
+ if (!schema.export) {
46
+ return;
47
+ }
48
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
49
+ const { root, sourceRoot, projectType } = (0, devkit_2.readProjectConfiguration)(tree, project);
50
+ if (projectType === 'application') {
51
+ devkit_1.logger.warn('--export=true was ignored as the project the SCAM is being generated in is not a library.');
52
+ return;
53
+ }
54
+ const ngPackageJsonPath = (0, devkit_2.joinPathFragments)(root, 'ng-package.json');
55
+ const ngPackageEntryPoint = tree.exists(ngPackageJsonPath)
56
+ ? (_b = (0, devkit_1.readJson)(tree, ngPackageJsonPath).lib) === null || _b === void 0 ? void 0 : _b.entryFile
57
+ : undefined;
58
+ const projectEntryPoint = ngPackageEntryPoint
59
+ ? (0, devkit_2.joinPathFragments)(root, ngPackageEntryPoint)
60
+ : (0, devkit_2.joinPathFragments)(sourceRoot, `index.ts`);
61
+ if (!tree.exists(projectEntryPoint)) {
62
+ // Let's not error, simply warn the user
63
+ // It's not too much effort to manually do this
64
+ // It would be more frustrating to have to find the correct path and re-run the command
65
+ devkit_1.logger.warn(`Could not export SCAM. Unable to determine project's entry point. Path ${projectEntryPoint} does not exist. SCAM has still been created.`);
66
+ return;
67
+ }
68
+ const relativePathFromEntryPoint = `.${scamFilePath
69
+ .split(sourceRoot)[1]
70
+ .replace('.ts', '')}`;
71
+ const updateEntryPointContent = `${tree.read(projectEntryPoint)}
72
+ export * from "${relativePathFromEntryPoint}";`;
73
+ tree.write(projectEntryPoint, updateEntryPointContent);
74
+ }
39
75
  function createAngularDirectiveModule(name) {
40
76
  return `
41
77
  @NgModule({
@@ -1 +1 @@
1
- {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-directive/lib/create-module.ts"],"names":[],"mappings":";;;AAGA,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,mBAAmB,CAAC,IAAU,EAAE,MAAc;;IAC5D,MAAM,OAAO,GACX,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mCAA0B,EAAC,IAAI,CAAC,CAAC,cAAc,CAAC;IACpE,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,cAAc,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,WAAW,CAAC,CAAC;IAErC,MAAM,iBAAiB,GAAG,GAAG,cAAc,CAAC,QAAQ,YAAY,CAAC;IAEjE,IAAI,kBAAkB,GAAG,MAAM,CAAC,IAAI;QAClC,CAAC,CAAC,IAAA,0BAAiB,EACf,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAC5D;QACH,CAAC,CAAC,IAAA,0BAAiB,EACf,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAC3D,cAAc,CAAC,QAAQ,CACxB,CAAC;IAEN,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,kBAAkB,GAAG,MAAM,CAAC,IAAI;YAC9B,CAAC,CAAC,IAAA,sBAAa,EAAC,MAAM,CAAC,IAAI,CAAC;YAC5B,CAAC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AC;AACJ,CAAC;AAnFD,kDAmFC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,wCAAwC,CAC/C,IAAY,EACZ,iBAAyB;IAEzB,OAAO;;WAEE,IAAI,cAAc,iBAAiB;EAC5C,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;AACvC,CAAC"}
1
+ {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-directive/lib/create-module.ts"],"names":[],"mappings":";;;AAAA,yCAAsD;AAGtD,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,mBAAmB,CAAC,IAAU,EAAE,MAAc;;IAC5D,MAAM,OAAO,GACX,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mCAA0B,EAAC,IAAI,CAAC,CAAC,cAAc,CAAC;IACpE,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,cAAc,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,WAAW,CAAC,CAAC;IAErC,MAAM,iBAAiB,GAAG,GAAG,cAAc,CAAC,QAAQ,YAAY,CAAC;IAEjE,IAAI,kBAAkB,GAAG,MAAM,CAAC,IAAI;QAClC,CAAC,CAAC,IAAA,0BAAiB,EACf,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAC5D;QACH,CAAC,CAAC,IAAA,0BAAiB,EACf,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAC3D,cAAc,CAAC,QAAQ,CACx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AI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QACnC,wCAAwC;QACxC,+CAA+C;QAC/C,uFAAuF;QACvF,eAAM,CAAC,IAAI,CACT,0EAA0E,iBAAiB,+CAA+C,CAC3I,CAAC;QAEF,OAAO;KACR;IAED,MAAM,0BAA0B,GAAG,IAAI,YAAY;SAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IAExB,MAAM,uBAAuB,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;mBAC9C,0BAA0B,IAAI,CAAC;IAEhD,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,wCAAwC,CAC/C,IAAY,EACZ,iBAAyB;IAEzB,OAAO;;WAEE,IAAI,cAAc,iBAAiB;EAC5C,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;AACvC,CAAC"}
@@ -7,4 +7,5 @@ export interface Schema {
7
7
  flat?: boolean;
8
8
  prefix?: string;
9
9
  selector?: string;
10
+ export?: boolean;
10
11
  }
@@ -62,6 +62,11 @@
62
62
  "format": "html-selector"
63
63
  }
64
64
  ]
65
+ },
66
+ "export": {
67
+ "type": "boolean",
68
+ "description": "Specifies if the SCAM should be exported from the project's entry point (normally `index.ts`). It only applies to libraries.",
69
+ "default": false
65
70
  }
66
71
  },
67
72
  "required": ["name"]
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nrwl/devkit';
1
+ import { Tree } from '@nrwl/devkit';
2
2
  import type { Schema } from '../schema';
3
3
  export declare function createScamPipe(tree: Tree, schema: Schema): void;
@@ -2,24 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createScamPipe = void 0;
4
4
  const devkit_1 = require("@nrwl/devkit");
5
+ const devkit_2 = require("@nrwl/devkit");
5
6
  const ast_utils_1 = require("@nrwl/workspace/src/utilities/ast-utils");
6
7
  const typescript_1 = require("typescript");
7
8
  function createScamPipe(tree, schema) {
8
9
  var _a;
9
- const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_1.readWorkspaceConfiguration)(tree).defaultProject;
10
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
11
- const pipeNames = (0, devkit_1.names)(schema.name);
12
- const typeNames = (0, devkit_1.names)('pipe');
10
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
11
+ const projectConfig = (0, devkit_2.readProjectConfiguration)(tree, project);
12
+ const pipeNames = (0, devkit_2.names)(schema.name);
13
+ const typeNames = (0, devkit_2.names)('pipe');
13
14
  const pipeFileName = `${pipeNames.fileName}.pipe`;
14
15
  let pipeDirectory = schema.flat
15
- ? (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
16
- : (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', pipeNames.fileName);
16
+ ? (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib')
17
+ : (0, devkit_2.joinPathFragments)(projectConfig.sourceRoot, projectConfig.projectType === 'application' ? 'app' : 'lib', pipeNames.fileName);
17
18
  if (schema.path) {
18
19
  pipeDirectory = schema.flat
19
- ? (0, devkit_1.normalizePath)(schema.path)
20
- : (0, devkit_1.joinPathFragments)(schema.path, pipeNames.fileName);
20
+ ? (0, devkit_2.normalizePath)(schema.path)
21
+ : (0, devkit_2.joinPathFragments)(schema.path, pipeNames.fileName);
21
22
  }
22
- const pipeFilePath = (0, devkit_1.joinPathFragments)(pipeDirectory, `${pipeFileName}.ts`);
23
+ const pipeFilePath = (0, devkit_2.joinPathFragments)(pipeDirectory, `${pipeFileName}.ts`);
23
24
  if (!tree.exists(pipeFilePath)) {
24
25
  throw new Error(`Couldn't find pipe at path ${pipeFilePath} to add SCAM setup.`);
25
26
  }
@@ -31,11 +32,46 @@ function createScamPipe(tree, schema) {
31
32
  let updatedPipeSource = source.getText();
32
33
  updatedPipeSource = `${updatedPipeSource}${createAngularPipeModule(`${pipeNames.className}${typeNames.className}`)}`;
33
34
  tree.write(pipeFilePath, updatedPipeSource);
35
+ exportScam(tree, schema, pipeFilePath);
34
36
  return;
35
37
  }
36
- tree.write((0, devkit_1.joinPathFragments)(pipeDirectory, `${pipeNames.fileName}.module.ts`), createSeparateAngularPipeModuleFile(`${pipeNames.className}${typeNames.className}`, pipeFileName));
38
+ const scamFilePath = (0, devkit_2.joinPathFragments)(pipeDirectory, `${pipeNames.fileName}.module.ts`);
39
+ tree.write(scamFilePath, createSeparateAngularPipeModuleFile(`${pipeNames.className}${typeNames.className}`, pipeFileName));
40
+ exportScam(tree, schema, scamFilePath);
37
41
  }
38
42
  exports.createScamPipe = createScamPipe;
43
+ function exportScam(tree, schema, scamFilePath) {
44
+ var _a, _b;
45
+ if (!schema.export) {
46
+ return;
47
+ }
48
+ const project = (_a = schema.project) !== null && _a !== void 0 ? _a : (0, devkit_2.readWorkspaceConfiguration)(tree).defaultProject;
49
+ const { root, sourceRoot, projectType } = (0, devkit_2.readProjectConfiguration)(tree, project);
50
+ if (projectType === 'application') {
51
+ devkit_1.logger.warn('--export=true was ignored as the project the SCAM is being generated in is not a library.');
52
+ return;
53
+ }
54
+ const ngPackageJsonPath = (0, devkit_2.joinPathFragments)(root, 'ng-package.json');
55
+ const ngPackageEntryPoint = tree.exists(ngPackageJsonPath)
56
+ ? (_b = (0, devkit_1.readJson)(tree, ngPackageJsonPath).lib) === null || _b === void 0 ? void 0 : _b.entryFile
57
+ : undefined;
58
+ const projectEntryPoint = ngPackageEntryPoint
59
+ ? (0, devkit_2.joinPathFragments)(root, ngPackageEntryPoint)
60
+ : (0, devkit_2.joinPathFragments)(sourceRoot, `index.ts`);
61
+ if (!tree.exists(projectEntryPoint)) {
62
+ // Let's not error, simply warn the user
63
+ // It's not too much effort to manually do this
64
+ // It would be more frustrating to have to find the correct path and re-run the command
65
+ devkit_1.logger.warn(`Could not export SCAM. Unable to determine project's entry point. Path ${projectEntryPoint} does not exist. SCAM has still been created.`);
66
+ return;
67
+ }
68
+ const relativePathFromEntryPoint = `.${scamFilePath
69
+ .split(sourceRoot)[1]
70
+ .replace('.ts', '')}`;
71
+ const updateEntryPointContent = `${tree.read(projectEntryPoint)}
72
+ export * from "${relativePathFromEntryPoint}";`;
73
+ tree.write(projectEntryPoint, updateEntryPointContent);
74
+ }
39
75
  function createAngularPipeModule(name) {
40
76
  return `
41
77
  @NgModule({
@@ -1 +1 @@
1
- {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-pipe/lib/create-module.ts"],"names":[],"mappings":";;;AAGA,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,cAAc,CAAC,IAAU,EAAE,MAAc;;IACvD,MAAM,OAAO,GACX,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mCAA0B,EAAC,IAAI,CAAC,CAAC,cAAc,CAAC;IACpE,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,YAAY,GAAG,GAAG,SAAS,CAAC,QAAQ,OAAO,CAAC;IAElD,IAAI,aAAa,GAAG,MAAM,CAAC,IAAI;QAC7B,CAAC,CAAC,IAAA,0BAAiB,EACf,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,WAAW,KA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B,CAChE,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,CAC/C,EAAE,CAAC;QAEJ,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;QAC5C,OAAO;KACR;IAED,IAAI,CAAC,KAAK,CACR,IAAA,0BAAiB,EAAC,aAAa,EAAE,GAAG,SAAS,CAAC,QAAQ,YAAY,CAAC,EACnE,mCAAmC,CACjC,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,EAC9C,YAAY,CACb,CACF,CAAC;AACJ,CAAC;AA7ED,wCA6EC;AAED,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,mCAAmC,CAC1C,IAAY,EACZ,YAAoB;IAEpB,OAAO;;WAEE,IAAI,cAAc,YAAY;EACvC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"create-module.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-pipe/lib/create-module.ts"],"names":[],"mappings":";;;AAAA,yCAAsD;AAGtD,yCAMsB;AACtB,uEAAuE;AACvE,2CAA4D;AAE5D,SAAgB,cAAc,CAAC,IAAU,EAAE,MAAc;;IACvD,MAAM,OAAO,GACX,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,mCAA0B,EAAC,IAAI,CAAC,CAAC,cAAc,CAAC;IACpE,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,YAAY,GAAG,GAAG,SAAS,CAAC,QAAQ,OAAO,CAAC;IAElD,IA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CAAC;QACxD,CAAC,CAAC,MAAA,IAAA,iBAAQ,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,GAAG,0CAAE,SAAS;QAClD,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,iBAAiB,GAAG,mBAAmB;QAC3C,CAAC,CAAC,IAAA,0BAAiB,EAAC,IAAI,EAAE,mBAAmB,CAAC;QAC9C,CAAC,CAAC,IAAA,0BAAiB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE9C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QACnC,wCAAwC;QACxC,+CAA+C;QAC/C,uFAAuF;QACvF,eAAM,CAAC,IAAI,CACT,0EAA0E,iBAAiB,+CAA+C,CAC3I,CAAC;QAEF,OAAO;KACR;IAED,MAAM,0BAA0B,GAAG,IAAI,YAAY;SAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IAExB,MAAM,uBAAuB,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;mBAC9C,0BAA0B,IAAI,CAAC;IAEhD,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO;;;mBAGU,IAAI;cACT,IAAI;;eAEH,IAAI,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,mCAAmC,CAC1C,IAAY,EACZ,YAAoB;IAEpB,OAAO;;WAEE,IAAI,cAAc,YAAY;EACvC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC"}
@@ -5,4 +5,5 @@ export interface Schema {
5
5
  skipTests?: boolean;
6
6
  inlineScam?: boolean;
7
7
  flat?: boolean;
8
+ export?: boolean;
8
9
  }
@@ -43,6 +43,11 @@
43
43
  "type": "boolean",
44
44
  "description": "Create the new files at the top level of the current project.",
45
45
  "default": true
46
+ },
47
+ "export": {
48
+ "type": "boolean",
49
+ "description": "Specifies if the SCAM should be exported from the project's entry point (normally `index.ts`). It only applies to libraries.",
50
+ "default": false
46
51
  }
47
52
  },
48
53
  "required": ["name"]
@@ -4,7 +4,7 @@ const { join } = require('path');
4
4
  module.exports = {
5
5
  mode: 'jit',
6
6
  purge: [
7
- join(__dirname, '<%= relativeSourceRoot %>/**/*.{html,ts}'),
7
+ join(__dirname, '<%= relativeSourceRoot %>/**/!(*.stories|*.spec).{ts,html}'),
8
8
  ...createGlobPatternsForDependencies(__dirname),
9
9
  ],
10
10
  darkMode: false, // or 'media' or 'class'
@@ -3,7 +3,7 @@ const { join } = require('path');
3
3
 
4
4
  module.exports = {
5
5
  content: [
6
- join(__dirname, '<%= relativeSourceRoot %>/**/*.{html,ts}'),
6
+ join(__dirname, '<%= relativeSourceRoot %>/**/!(*.stories|*.spec).{ts,html}'),
7
7
  ...createGlobPatternsForDependencies(__dirname),
8
8
  ],
9
9
  theme: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.autoprefixerVersion = exports.postcssVersion = exports.tailwindVersion = exports.angularArchitectsModuleFederationPluginVersion = exports.angularEslintVersion = exports.jestPresetAngularVersion = exports.rxjsVersion = exports.ngrxVersion = exports.angularJsVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
- exports.nxVersion = '13.5.0-beta.9';
4
+ exports.nxVersion = '13.5.2';
5
5
  exports.angularVersion = '~13.1.0';
6
6
  exports.angularDevkitVersion = '~13.1.0';
7
7
  exports.angularJsVersion = '1.7.9';