@rxap/plugin-utilities 16.1.0-dev.5 → 16.1.0-dev.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [16.1.0-dev.6](https://gitlab.com/rxap/packages/compare/@rxap/plugin-utilities@16.1.0-dev.5...@rxap/plugin-utilities@16.1.0-dev.6) (2023-08-06)
7
+
8
+ ### Bug Fixes
9
+
10
+ - ensure new line ([5562c46](https://gitlab.com/rxap/packages/commit/5562c46fbbb5705a4b383a9ea4ceb3945071b659))
11
+ - expose generators as schematics ([679ca36](https://gitlab.com/rxap/packages/commit/679ca36d3712a11e4dc838762bca2f7c471e1e04))
12
+
6
13
  # [16.1.0-dev.5](https://gitlab.com/rxap/packages/compare/@rxap/plugin-utilities@16.1.0-dev.4...@rxap/plugin-utilities@16.1.0-dev.5) (2023-08-05)
7
14
 
8
15
  ### Bug Fixes
package/README.md CHANGED
@@ -17,5 +17,5 @@ yarn add @rxap/plugin-utilities
17
17
  ```
18
18
  **Install peer dependencies:**
19
19
  ```bash
20
- yarn add @nx/devkit@^16.5.0 @rxap/node-utilities@^1.1.0-dev.1 @rxap/workspace-utilities@^0.1.0-dev.2
20
+ yarn add @nx/devkit@^16.5.0 @rxap/generator-utilities@* @rxap/node-utilities@^1.1.0-dev.1 @rxap/workspace-utilities@^0.1.0-dev.2
21
21
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxap/plugin-utilities",
3
- "version": "16.1.0-dev.5",
3
+ "version": "16.1.0-dev.6",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@nx/devkit": "^16.5.0",
32
+ "@rxap/generator-utilities": "*",
32
33
  "@rxap/node-utilities": "^1.1.0-dev.1",
33
34
  "@rxap/workspace-utilities": "^0.1.0-dev.2",
34
35
  "@rxap/utilities": "16.0.0-dev.6"
@@ -51,7 +52,7 @@
51
52
  }
52
53
  ]
53
54
  },
54
- "gitHead": "935f06ea33643b9821e0f49464a7ade7477972a5",
55
+ "gitHead": "8f010d8945a8bd56c8968c2af129b1e0b2f656cf",
55
56
  "main": "./src/index.js",
56
57
  "types": "./src/index.d.ts"
57
58
  }
package/src/index.d.ts CHANGED
@@ -8,3 +8,5 @@ export * from './lib/guess-output-path';
8
8
  export * from './lib/yarn-run';
9
9
  export * from './lib/project-target';
10
10
  export * from './lib/project-package-name-mapping';
11
+ export * from './lib/skip-non-generators-project';
12
+ export * from './lib/generators';
package/src/index.js CHANGED
@@ -11,4 +11,6 @@ tslib_1.__exportStar(require("./lib/guess-output-path"), exports);
11
11
  tslib_1.__exportStar(require("./lib/yarn-run"), exports);
12
12
  tslib_1.__exportStar(require("./lib/project-target"), exports);
13
13
  tslib_1.__exportStar(require("./lib/project-package-name-mapping"), exports);
14
+ tslib_1.__exportStar(require("./lib/skip-non-generators-project"), exports);
15
+ tslib_1.__exportStar(require("./lib/generators"), exports);
14
16
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/plugin/utilities/src/index.ts"],"names":[],"mappings":";;;AAAA,4FAAkE;AAClE,yFAA+D;AAC/D,qEAA2C;AAC3C,wDAA8B;AAC9B,mEAAyC;AACzC,mFAAyD;AACzD,kEAAwC;AACxC,yDAA+B;AAC/B,+DAAqC;AACrC,6EAAmD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/plugin/utilities/src/index.ts"],"names":[],"mappings":";;;AAAA,4FAAkE;AAClE,yFAA+D;AAC/D,qEAA2C;AAC3C,wDAA8B;AAC9B,mEAAyC;AACzC,mFAAyD;AACzD,kEAAwC;AACxC,yDAA+B;AAC/B,+DAAqC;AACrC,6EAAmD;AACnD,4EAAkD;AAClD,2DAAiC"}
@@ -0,0 +1,25 @@
1
+ import { ProjectConfiguration, Tree } from '@nx/devkit';
2
+ import { PackageJson } from '@rxap/workspace-utilities';
3
+ export interface PackageJsonWithGenerators extends PackageJson {
4
+ generators: string;
5
+ }
6
+ export declare function HasGeneratorProperty(packageJson: PackageJson): packageJson is PackageJsonWithGenerators;
7
+ export declare function GetGeneratorFilePath(projectRoot: string, packageJson: PackageJsonWithGenerators): string;
8
+ export declare function ExistsGeneratorFile(tree: Tree, projectRoot: string, packageJson: PackageJsonWithGenerators): boolean;
9
+ export interface GeneratorFile {
10
+ generators: Record<string, {
11
+ factory: string;
12
+ schema: string;
13
+ description: string;
14
+ }>;
15
+ schematics?: Record<string, {
16
+ factory: string;
17
+ schema: string;
18
+ description: string;
19
+ }>;
20
+ }
21
+ export declare function GetGeneratorFile(tree: Tree, projectRoot: string, packageJson: PackageJsonWithGenerators): GeneratorFile;
22
+ export declare function ProjectRootOrNameOrConfigurationToProjectRoot(tree: Tree, projectRootOrNameOrConfiguration: string | ProjectConfiguration): string;
23
+ export declare function GetGenerators(tree: Tree, projectRootOrNameOrConfiguration: string | ProjectConfiguration): GeneratorFile;
24
+ export declare function UpdateGenerators(tree: Tree, projectRootOrNameOrConfiguration: string | ProjectConfiguration, update: (generators: GeneratorFile) => GeneratorFile): void;
25
+ export declare function HasGenerators(tree: Tree, projectRootOrNameOrConfiguration: string | ProjectConfiguration): boolean;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasGenerators = exports.UpdateGenerators = exports.GetGenerators = exports.ProjectRootOrNameOrConfigurationToProjectRoot = exports.GetGeneratorFile = exports.ExistsGeneratorFile = exports.GetGeneratorFilePath = exports.HasGeneratorProperty = void 0;
4
+ const workspace_utilities_1 = require("@rxap/workspace-utilities");
5
+ const path_1 = require("path");
6
+ function HasGeneratorProperty(packageJson) {
7
+ return !!packageJson['generators'];
8
+ }
9
+ exports.HasGeneratorProperty = HasGeneratorProperty;
10
+ function GetGeneratorFilePath(projectRoot, packageJson) {
11
+ if (!packageJson['generators']) {
12
+ throw new Error(`The package.json of the project ${projectRoot} does not contains a generators property!`);
13
+ }
14
+ return (0, path_1.join)(projectRoot, packageJson['generators']);
15
+ }
16
+ exports.GetGeneratorFilePath = GetGeneratorFilePath;
17
+ function ExistsGeneratorFile(tree, projectRoot, packageJson) {
18
+ return tree.exists(GetGeneratorFilePath(projectRoot, packageJson));
19
+ }
20
+ exports.ExistsGeneratorFile = ExistsGeneratorFile;
21
+ function GetGeneratorFile(tree, projectRoot, packageJson) {
22
+ var _a;
23
+ const generatorFile = GetGeneratorFilePath(projectRoot, packageJson);
24
+ const content = (_a = tree.read(generatorFile)) === null || _a === void 0 ? void 0 : _a.toString('utf-8');
25
+ if (!content) {
26
+ throw new Error(`The generator file ${generatorFile} does not exists!`);
27
+ }
28
+ try {
29
+ return JSON.parse(content);
30
+ }
31
+ catch (e) {
32
+ throw new Error(`The generator file ${generatorFile} is not valid json!: ${e.message}`);
33
+ }
34
+ }
35
+ exports.GetGeneratorFile = GetGeneratorFile;
36
+ function ProjectRootOrNameOrConfigurationToProjectRoot(tree, projectRootOrNameOrConfiguration) {
37
+ if (typeof projectRootOrNameOrConfiguration === 'string') {
38
+ if (projectRootOrNameOrConfiguration.match(/^\/?([^/]+\/)+[^/]+/)) {
39
+ return projectRootOrNameOrConfiguration;
40
+ }
41
+ else {
42
+ const project = (0, workspace_utilities_1.GetProject)(tree, projectRootOrNameOrConfiguration);
43
+ if (project) {
44
+ return project.root;
45
+ }
46
+ else {
47
+ throw new Error(`The project ${projectRootOrNameOrConfiguration} does not exists!`);
48
+ }
49
+ }
50
+ }
51
+ else {
52
+ return projectRootOrNameOrConfiguration.root;
53
+ }
54
+ }
55
+ exports.ProjectRootOrNameOrConfigurationToProjectRoot = ProjectRootOrNameOrConfigurationToProjectRoot;
56
+ function GetGenerators(tree, projectRootOrNameOrConfiguration) {
57
+ const projectRoot = ProjectRootOrNameOrConfigurationToProjectRoot(tree, projectRootOrNameOrConfiguration);
58
+ const packageJson = (0, workspace_utilities_1.GetPackageJson)(tree, projectRoot);
59
+ if (!HasGeneratorProperty(packageJson)) {
60
+ throw new Error(`The project ${projectRoot} does not contains a generators property!`);
61
+ }
62
+ if (!ExistsGeneratorFile(tree, projectRoot, packageJson)) {
63
+ throw new Error(`The generator file ${GetGeneratorFilePath(projectRoot, packageJson)} does not exists!`);
64
+ }
65
+ return GetGeneratorFile(tree, projectRoot, packageJson);
66
+ }
67
+ exports.GetGenerators = GetGenerators;
68
+ function UpdateGenerators(tree, projectRootOrNameOrConfiguration, update) {
69
+ const projectRoot = ProjectRootOrNameOrConfigurationToProjectRoot(tree, projectRootOrNameOrConfiguration);
70
+ const packageJson = (0, workspace_utilities_1.GetPackageJson)(tree, projectRoot);
71
+ if (!HasGeneratorProperty(packageJson)) {
72
+ throw new Error(`The project ${projectRoot} does not contains a generators property!`);
73
+ }
74
+ if (!ExistsGeneratorFile(tree, projectRoot, packageJson)) {
75
+ throw new Error(`The generator file ${GetGeneratorFilePath(projectRoot, packageJson)} does not exists!`);
76
+ }
77
+ const generators = GetGeneratorFile(tree, projectRoot, packageJson);
78
+ tree.write(GetGeneratorFilePath(projectRoot, packageJson), JSON.stringify(update(generators), null, 2) + '\n');
79
+ }
80
+ exports.UpdateGenerators = UpdateGenerators;
81
+ function HasGenerators(tree, projectRootOrNameOrConfiguration) {
82
+ const projectRoot = ProjectRootOrNameOrConfigurationToProjectRoot(tree, projectRootOrNameOrConfiguration);
83
+ const packageJson = (0, workspace_utilities_1.GetPackageJson)(tree, projectRoot);
84
+ if (!HasGeneratorProperty(packageJson)) {
85
+ return false;
86
+ }
87
+ if (!ExistsGeneratorFile(tree, projectRoot, packageJson)) {
88
+ return false;
89
+ }
90
+ const generators = GetGeneratorFile(tree, projectRoot, packageJson);
91
+ if (!Object.keys(generators.generators).length) {
92
+ return false;
93
+ }
94
+ return true;
95
+ }
96
+ exports.HasGenerators = HasGenerators;
97
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../../../../packages/plugin/utilities/src/lib/generators.ts"],"names":[],"mappings":";;;AAIA,mEAImC;AACnC,+BAA4B;AAM5B,SAAgB,oBAAoB,CAAC,WAAwB;IAC3D,OAAO,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAFD,oDAEC;AAED,SAAgB,oBAAoB,CAAC,WAAmB,EAAE,WAAsC;IAE9F,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,mCAAoC,WAAY,2CAA2C,CAAC,CAAC;KAC9G;IAED,OAAO,IAAA,WAAI,EAAC,WAAW,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;AAEtD,CAAC;AARD,oDAQC;AAED,SAAgB,mBAAmB,CAAC,IAAU,EAAE,WAAmB,EAAE,WAAsC;IACzG,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,kDAEC;AAOD,SAAgB,gBAAgB,CAC9B,IAAU,EACV,WAAmB,EACnB,WAAsC;;IAEtC,MAAM,aAAa,GAAG,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAErE,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,sBAAuB,aAAc,mBAAmB,CAAC,CAAC;KAC3E;IACD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,OAAO,CAAM,EAAE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pE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;QAC9C,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAEd,CAAC;AAtBD,sCAsBC"}
@@ -0,0 +1,3 @@
1
+ import { ProjectConfiguration, Tree } from '@nx/devkit';
2
+ import { SkipProjectOptions } from '@rxap/generator-utilities';
3
+ export declare function SkipNonGeneratorsProject(tree: Tree, options: SkipProjectOptions, project: ProjectConfiguration, projectName: string): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SkipNonGeneratorsProject = void 0;
4
+ const generator_utilities_1 = require("@rxap/generator-utilities");
5
+ const generators_1 = require("./generators");
6
+ function SkipNonGeneratorsProject(tree, options, project, projectName) {
7
+ var _a;
8
+ if ((0, generator_utilities_1.SkipProject)(tree, options, project, projectName)) {
9
+ return true;
10
+ }
11
+ if (!((_a = project.tags) === null || _a === void 0 ? void 0 : _a.includes('plugin'))) {
12
+ return true;
13
+ }
14
+ if (!(0, generators_1.HasGenerators)(tree, project)) {
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ exports.SkipNonGeneratorsProject = SkipNonGeneratorsProject;
20
+ //# sourceMappingURL=skip-non-generators-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skip-non-generators-project.js","sourceRoot":"","sources":["../../../../../../packages/plugin/utilities/src/lib/skip-non-generators-project.ts"],"names":[],"mappings":";;;AAIA,mEAGmC;AACnC,6CAA6C;AAE7C,SAAgB,wBAAwB,CACtC,IAAU,EACV,OAA2B,EAC3B,OAA6B,EAC7B,WAAmB;;IAEnB,IAAI,IAAA,iCAAW,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE;QACpD,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,IAAA,0BAAa,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAjBD,4DAiBC"}