@rxap/plugin-library 16.0.0-dev.4 → 16.0.0-dev.42

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 (82) hide show
  1. package/CHANGELOG.md +311 -0
  2. package/LICENSE.md +621 -0
  3. package/README.md +88 -4
  4. package/executors.json +5 -0
  5. package/generators.json +56 -4
  6. package/package.json +78 -38
  7. package/src/executors/check-version/executor.d.ts +5 -0
  8. package/src/executors/check-version/executor.js +37 -0
  9. package/src/executors/check-version/executor.js.map +1 -0
  10. package/src/executors/check-version/schema.d.ts +3 -0
  11. package/src/executors/check-version/schema.json +16 -0
  12. package/src/executors/readme/executor.js +129 -73
  13. package/src/executors/readme/executor.js.map +1 -1
  14. package/src/executors/run-generator/executor.d.ts +1 -1
  15. package/src/executors/run-generator/executor.js +69 -9
  16. package/src/executors/run-generator/executor.js.map +1 -1
  17. package/src/executors/run-generator/schema.d.ts +1 -0
  18. package/src/executors/run-generator/schema.json +4 -0
  19. package/src/generators/expose-as-schematic/generator.d.ts +4 -0
  20. package/src/generators/expose-as-schematic/generator.js +44 -0
  21. package/src/generators/expose-as-schematic/generator.js.map +1 -0
  22. package/src/generators/expose-as-schematic/index.d.ts +2 -0
  23. package/src/generators/expose-as-schematic/index.js +8 -0
  24. package/src/generators/expose-as-schematic/index.js.map +1 -0
  25. package/src/generators/expose-as-schematic/schema.d.ts +3 -0
  26. package/src/generators/expose-as-schematic/schema.json +16 -0
  27. package/src/generators/fix-dependencies/generator.d.ts +1 -1
  28. package/src/generators/fix-dependencies/generator.js +46 -104
  29. package/src/generators/fix-dependencies/generator.js.map +1 -1
  30. package/src/generators/fix-dependencies/index.d.ts +2 -0
  31. package/src/generators/fix-dependencies/index.js +8 -0
  32. package/src/generators/fix-dependencies/index.js.map +1 -0
  33. package/src/generators/index-export/generator.js +61 -32
  34. package/src/generators/index-export/generator.js.map +1 -1
  35. package/src/generators/index-export/index.d.ts +2 -0
  36. package/src/generators/index-export/index.js +8 -0
  37. package/src/generators/index-export/index.js.map +1 -0
  38. package/src/generators/index-export/schema.d.ts +1 -1
  39. package/src/generators/index-export/schema.json +7 -7
  40. package/src/generators/init/generator.js +65 -234
  41. package/src/generators/init/generator.js.map +1 -1
  42. package/src/generators/init/index.d.ts +2 -0
  43. package/src/generators/init/index.js +8 -0
  44. package/src/generators/init/index.js.map +1 -0
  45. package/src/generators/init/schema.d.ts +2 -0
  46. package/src/generators/init/schema.json +10 -0
  47. package/src/generators/init-buildable/generator.d.ts +4 -0
  48. package/src/generators/init-buildable/generator.js +45 -0
  49. package/src/generators/init-buildable/generator.js.map +1 -0
  50. package/src/generators/init-buildable/index.d.ts +2 -0
  51. package/src/generators/init-buildable/index.js +8 -0
  52. package/src/generators/init-buildable/index.js.map +1 -0
  53. package/src/generators/init-buildable/schema.d.ts +5 -0
  54. package/src/generators/init-buildable/schema.json +26 -0
  55. package/src/generators/init-plugin/generator.d.ts +4 -0
  56. package/src/generators/init-plugin/generator.js +58 -0
  57. package/src/generators/init-plugin/generator.js.map +1 -0
  58. package/src/generators/init-plugin/index.d.ts +2 -0
  59. package/src/generators/init-plugin/index.js +8 -0
  60. package/src/generators/init-plugin/index.js.map +1 -0
  61. package/src/generators/init-plugin/schema.d.ts +5 -0
  62. package/src/generators/init-plugin/schema.json +26 -0
  63. package/src/generators/{init → init-publishable}/files/README.md.handlebars +1 -1
  64. package/src/generators/init-publishable/generator.d.ts +4 -0
  65. package/src/generators/init-publishable/generator.js +111 -0
  66. package/src/generators/init-publishable/generator.js.map +1 -0
  67. package/src/generators/init-publishable/index.d.ts +2 -0
  68. package/src/generators/init-publishable/index.js +8 -0
  69. package/src/generators/init-publishable/index.js.map +1 -0
  70. package/src/generators/init-publishable/schema.d.ts +5 -0
  71. package/src/generators/init-publishable/schema.json +26 -0
  72. package/src/index.d.ts +2 -0
  73. package/src/index.js +7 -0
  74. package/src/index.js.map +1 -1
  75. package/src/generators/schematic/files/schematic/__fileName__/index.ts.template +0 -8
  76. package/src/generators/schematic/files/schematic/__fileName__/schema.d.ts.template +0 -3
  77. package/src/generators/schematic/files/schematic/__fileName__/schema.json.template +0 -18
  78. package/src/generators/schematic/generator.d.ts +0 -6
  79. package/src/generators/schematic/generator.js +0 -137
  80. package/src/generators/schematic/generator.js.map +0 -1
  81. package/src/generators/schematic/schema.d.ts +0 -6
  82. package/src/generators/schematic/schema.json +0 -43
package/README.md CHANGED
@@ -19,7 +19,7 @@ yarn add @rxap/plugin-library
19
19
  ```
20
20
  **Install peer dependencies:**
21
21
  ```bash
22
- yarn add
22
+ yarn add @nx/devkit@^16.5.0 @rxap/generator-ts-morph@^1.0.1-dev.13 @rxap/generator-utilities@^1.1.0-dev.19 @rxap/node-utilities@^1.1.0-dev.15 @rxap/plugin-angular@^16.1.0-dev.58 @rxap/plugin-nestjs@^16.1.0-dev.45 @rxap/plugin-utilities@^16.1.0-dev.21 @rxap/ts-morph@^0.1.0-dev.18 @rxap/utilities@^16.0.0-dev.23 @rxap/workspace-utilities@^0.1.0-dev.24 handlebars@^4.7.7 nx@^16.5.0 semver@^7.5.3 ts-morph@^18.0.0 tslib@2.6.2
23
23
  ```
24
24
  **Execute the init generator:**
25
25
  ```bash
@@ -48,11 +48,81 @@ yarn nx g @rxap/plugin-library:fix-dependencies
48
48
  yarn nx g @rxap/plugin-library:index-export
49
49
  ```
50
50
 
51
- ## schematic
52
- > Create a Schematic for a project.
51
+ ## init-plugin
52
+ > init-plugin generator
53
53
 
54
54
  ```bash
55
- yarn nx g @rxap/plugin-library:schematic
55
+ yarn nx g @rxap/plugin-library:init-plugin
56
+ ```
57
+
58
+ ## init-buildable
59
+ > init-buildable generator
60
+
61
+ ```bash
62
+ yarn nx g @rxap/plugin-library:init-buildable
63
+ ```
64
+
65
+ ## init-publishable
66
+ > init-publishable generator
67
+
68
+ ```bash
69
+ yarn nx g @rxap/plugin-library:init-publishable
70
+ ```
71
+
72
+ ## expose-as-schematic
73
+ > expose-as-schematic generator
74
+
75
+ ```bash
76
+ yarn nx g @rxap/plugin-library:expose-as-schematic
77
+ ```
78
+
79
+ ## init
80
+ > Create and update configurations to use rxap package publish concept
81
+
82
+ ```bash
83
+ yarn nx g @rxap/plugin-library:init
84
+ ```
85
+
86
+ ## fix-dependencies
87
+ > Adds missing dependencies and removes redudant dependencies of a project
88
+
89
+ ```bash
90
+ yarn nx g @rxap/plugin-library:fix-dependencies
91
+ ```
92
+
93
+ ## index-export
94
+ > Generate index exports for each directory and in the src root
95
+
96
+ ```bash
97
+ yarn nx g @rxap/plugin-library:index-export
98
+ ```
99
+
100
+ ## init-plugin
101
+ > init-plugin generator
102
+
103
+ ```bash
104
+ yarn nx g @rxap/plugin-library:init-plugin
105
+ ```
106
+
107
+ ## init-buildable
108
+ > init-buildable generator
109
+
110
+ ```bash
111
+ yarn nx g @rxap/plugin-library:init-buildable
112
+ ```
113
+
114
+ ## init-publishable
115
+ > init-publishable generator
116
+
117
+ ```bash
118
+ yarn nx g @rxap/plugin-library:init-publishable
119
+ ```
120
+
121
+ ## expose-as-schematic
122
+ > expose-as-schematic generator
123
+
124
+ ```bash
125
+ yarn nx g @rxap/plugin-library:expose-as-schematic
56
126
  ```
57
127
  # Executors
58
128
 
@@ -112,3 +182,17 @@ yarn nx g @rxap/plugin-library:schematic
112
182
  }
113
183
  ```
114
184
 
185
+ ## check-version
186
+ > check-version executor
187
+
188
+ **project.json**
189
+ ```json
190
+ {
191
+ "targets": {
192
+ "check-version": {
193
+ "executor": "@rxap/plugin-library:check-version"
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
package/executors.json CHANGED
@@ -19,6 +19,11 @@
19
19
  "implementation": "./src/executors/run-generator/executor",
20
20
  "schema": "./src/executors/run-generator/schema.json",
21
21
  "description": "Executes a generator for the project"
22
+ },
23
+ "check-version": {
24
+ "implementation": "./src/executors/check-version/executor",
25
+ "schema": "./src/executors/check-version/schema.json",
26
+ "description": "check-version executor"
22
27
  }
23
28
  }
24
29
  }
package/generators.json CHANGED
@@ -15,10 +15,62 @@
15
15
  "schema": "./src/generators/index-export/schema.json",
16
16
  "description": "Generate index exports for each directory and in the src root"
17
17
  },
18
- "schematic": {
19
- "factory": "./src/generators/schematic/generator",
20
- "schema": "./src/generators/schematic/schema.json",
21
- "description": "Create a Schematic for a project."
18
+ "init-plugin": {
19
+ "factory": "./src/generators/init-plugin/generator",
20
+ "schema": "./src/generators/init-plugin/schema.json",
21
+ "description": "init-plugin generator"
22
+ },
23
+ "init-buildable": {
24
+ "factory": "./src/generators/init-buildable/generator",
25
+ "schema": "./src/generators/init-buildable/schema.json",
26
+ "description": "init-buildable generator"
27
+ },
28
+ "init-publishable": {
29
+ "factory": "./src/generators/init-publishable/generator",
30
+ "schema": "./src/generators/init-publishable/schema.json",
31
+ "description": "init-publishable generator"
32
+ },
33
+ "expose-as-schematic": {
34
+ "factory": "./src/generators/expose-as-schematic/generator",
35
+ "schema": "./src/generators/expose-as-schematic/schema.json",
36
+ "description": "expose-as-schematic generator"
37
+ }
38
+ },
39
+ "schematics": {
40
+ "init": {
41
+ "factory": "./src/generators/init/index",
42
+ "schema": "./src/generators/init/schema.json",
43
+ "description": "Create and update configurations to use rxap package publish concept"
44
+ },
45
+ "fix-dependencies": {
46
+ "factory": "./src/generators/fix-dependencies/index",
47
+ "schema": "./src/generators/fix-dependencies/schema.json",
48
+ "description": "Adds missing dependencies and removes redudant dependencies of a project"
49
+ },
50
+ "index-export": {
51
+ "factory": "./src/generators/index-export/index",
52
+ "schema": "./src/generators/index-export/schema.json",
53
+ "description": "Generate index exports for each directory and in the src root"
54
+ },
55
+ "init-plugin": {
56
+ "factory": "./src/generators/init-plugin/index",
57
+ "schema": "./src/generators/init-plugin/schema.json",
58
+ "description": "init-plugin generator"
59
+ },
60
+ "init-buildable": {
61
+ "factory": "./src/generators/init-buildable/index",
62
+ "schema": "./src/generators/init-buildable/schema.json",
63
+ "description": "init-buildable generator"
64
+ },
65
+ "init-publishable": {
66
+ "factory": "./src/generators/init-publishable/index",
67
+ "schema": "./src/generators/init-publishable/schema.json",
68
+ "description": "init-publishable generator"
69
+ },
70
+ "expose-as-schematic": {
71
+ "factory": "./src/generators/expose-as-schematic/index",
72
+ "schema": "./src/generators/expose-as-schematic/schema.json",
73
+ "description": "expose-as-schematic generator"
22
74
  }
23
75
  }
24
76
  }
package/package.json CHANGED
@@ -1,67 +1,107 @@
1
1
  {
2
+ "version": "16.0.0-dev.42",
2
3
  "name": "@rxap/plugin-library",
3
- "version": "16.0.0-dev.4",
4
- "type": "commonjs",
4
+ "license": "GPL-3.0-or-later",
5
+ "dependencies": {
6
+ "@apidevtools/json-schema-ref-parser": "9.0.9",
7
+ "ignore": "5.2.4",
8
+ "process": "0.11.10",
9
+ "tslib": "2.6.2",
10
+ "yaml": "2.3.1"
11
+ },
12
+ "peerDependencies": {
13
+ "@nx/devkit": "^16.5.0",
14
+ "@rxap/generator-ts-morph": "^1.0.1-dev.13",
15
+ "@rxap/generator-utilities": "^1.1.0-dev.19",
16
+ "@rxap/node-utilities": "^1.1.0-dev.15",
17
+ "@rxap/plugin-angular": "^16.1.0-dev.58",
18
+ "@rxap/plugin-nestjs": "^16.1.0-dev.45",
19
+ "@rxap/plugin-utilities": "^16.1.0-dev.21",
20
+ "@rxap/ts-morph": "^0.1.0-dev.18",
21
+ "@rxap/utilities": "^16.0.0-dev.23",
22
+ "@rxap/workspace-utilities": "^0.1.0-dev.24",
23
+ "handlebars": "^4.7.7",
24
+ "nx": "^16.5.0",
25
+ "semver": "^7.5.3",
26
+ "ts-morph": "^18.0.0",
27
+ "tslib": "2.6.2",
28
+ "@rxap/plugin-localazy": "16.1.0-dev.18",
29
+ "@rxap/workspace-ts-morph": "0.1.0-dev.12"
30
+ },
31
+ "author": {
32
+ "name": "Merzough Münker",
33
+ "email": "mmuenker@digitaix.com"
34
+ },
35
+ "bugs": {
36
+ "url": "https://gitlab.com/rxap/packages/-/issues",
37
+ "email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
38
+ },
5
39
  "executors": "./executors.json",
6
40
  "generators": "./generators.json",
7
- "publishConfig": {
8
- "access": "public",
9
- "directory": "../../../dist/packages/plugin/library"
10
- },
41
+ "homepage": "https:/gitlab.com/rxap/packages/packages/plugin/library",
42
+ "keywords": [
43
+ "library",
44
+ "packages",
45
+ "plugin",
46
+ "plugin-library",
47
+ "rxap"
48
+ ],
11
49
  "nx-migrations": {
12
50
  "packageGroup": [
13
51
  {
14
52
  "package": "@rxap/generator-ts-morph",
15
- "version": "1.0.1-dev.0"
53
+ "version": "1.0.1-dev.13"
16
54
  },
17
55
  {
18
56
  "package": "@rxap/generator-utilities",
19
- "version": "1.0.1-dev.0"
57
+ "version": "1.1.0-dev.19"
58
+ },
59
+ {
60
+ "package": "@rxap/node-utilities",
61
+ "version": "1.1.0-dev.15"
62
+ },
63
+ {
64
+ "package": "@rxap/plugin-angular",
65
+ "version": "16.1.0-dev.58"
66
+ },
67
+ {
68
+ "package": "@rxap/plugin-nestjs",
69
+ "version": "16.1.0-dev.45"
20
70
  },
21
71
  {
22
72
  "package": "@rxap/plugin-utilities",
23
- "version": "1.0.1-dev.0"
73
+ "version": "16.1.0-dev.21"
24
74
  },
25
75
  {
26
76
  "package": "@rxap/schematics-utilities",
27
- "version": "16.0.0-dev.3"
77
+ "version": "16.0.0-dev.4"
78
+ },
79
+ {
80
+ "package": "@rxap/ts-morph",
81
+ "version": "0.1.0-dev.18"
82
+ },
83
+ {
84
+ "package": "@rxap/utilities",
85
+ "version": "16.0.0-dev.23"
86
+ },
87
+ {
88
+ "package": "@rxap/workspace-utilities",
89
+ "version": "0.1.0-dev.24"
28
90
  }
29
91
  ]
30
92
  },
31
- "keywords": [
32
- "rxap"
33
- ],
34
- "homepage": "https:/gitlab.com/rxap/packages/packages/plugin/library",
35
- "bugs": {
36
- "url": "https://gitlab.com/rxap/packages/-/issues",
37
- "email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
93
+ "publishConfig": {
94
+ "access": "public",
95
+ "directory": "../../../dist/packages/plugin/library"
38
96
  },
39
- "license": "GPL-3.0-or-later",
40
97
  "repository": {
41
98
  "type": "git",
42
99
  "url": "https://gitlab.com/rxap/packages.git",
43
100
  "directory": "packages/plugin/library"
44
101
  },
45
- "author": {
46
- "name": "Merzough Münker",
47
- "email": "mmuenker@digitaix.com"
48
- },
49
- "dependencies": {
50
- "handlebars": "4.7.7",
51
- "semver": "7.5.3",
52
- "tslib": "2.5.3"
53
- },
54
- "peerDependencies": {
55
- "@nx/angular": "^16.3.2",
56
- "@nx/devkit": "^16.3.2",
57
- "@rxap/generator-ts-morph": "^1.0.1-dev.0",
58
- "@rxap/generator-utilities": "^1.0.1-dev.0",
59
- "@rxap/plugin-utilities": "^1.0.1-dev.0",
60
- "@rxap/schematics-utilities": "^16.0.0-dev.3",
61
- "nx": "^16.3.0",
62
- "ts-morph": "^18.0.0",
63
- "@rxap/node-utilities": "1.0.1-dev.0"
64
- },
102
+ "schematics": "./generators.json",
103
+ "type": "commonjs",
104
+ "gitHead": "e693226c20a89161107a08ef8e5da07abd0ebd7d",
65
105
  "main": "./src/index.js",
66
106
  "types": "./src/index.d.ts"
67
107
  }
@@ -0,0 +1,5 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { CheckVersionExecutorSchema } from './schema';
3
+ export default function runExecutor(options: CheckVersionExecutorSchema, context: ExecutorContext): Promise<{
4
+ success: boolean;
5
+ }>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const plugin_utilities_1 = require("@rxap/plugin-utilities");
5
+ const semver_1 = require("semver");
6
+ function runExecutor(options, context) {
7
+ var _a;
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ console.log('Executor ran for CheckVersion', options);
10
+ const projectJson = (0, plugin_utilities_1.readPackageJsonForProject)(context);
11
+ const rootPackageJson = (0, plugin_utilities_1.readPackageJsonForProject)(context, 'workspace');
12
+ let targetVersion = (_a = rootPackageJson.devDependencies[options.packageName]) !== null && _a !== void 0 ? _a : rootPackageJson.dependencies[options.packageName];
13
+ if (!targetVersion) {
14
+ console.error(`The package ${options.packageName} is not installed in the root package.json`);
15
+ return {
16
+ success: false,
17
+ };
18
+ }
19
+ targetVersion = targetVersion.replace(/^[~^]/, '');
20
+ console.log(`Current '${options.packageName}' version: ${targetVersion}`);
21
+ console.log(`Project version: ${projectJson.version}`);
22
+ const version = (0, semver_1.parse)(targetVersion);
23
+ const versionRange = `>=${version.major}`;
24
+ const normalizedVersion = projectJson.version.replace(/-.*$/, '');
25
+ if (!(0, semver_1.satisfies)(normalizedVersion, versionRange)) {
26
+ console.error(`The project version '${projectJson.version}' normalized '${normalizedVersion}' is not compatible with the '${options.packageName}' version '${targetVersion}' with the range '${versionRange}'`);
27
+ return {
28
+ success: false,
29
+ };
30
+ }
31
+ return {
32
+ success: true,
33
+ };
34
+ });
35
+ }
36
+ exports.default = runExecutor;
37
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/library/src/executors/check-version/executor.ts"],"names":[],"mappings":";;;AACA,6DAAmE;AACnE,mCAGgB;AAGhB,SAA8B,WAAW,CACvC,OAAmC,EACnC,OAAwB;;;QAExB,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;QAEtD,MAAM,WAAW,GAAG,IAAA,4CAAyB,EAAC,OAAO,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,IAAA,4CAAyB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAExE,IAAI,aAAa,GAAG,MAAA,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,mCACtE,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEpD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,eAAgB,OAAO,CAAC,WAAY,4CAA4C,CAAC,CAAC;YAChG,OAAO;gBACL,OAAO,EAAE,KAAK;aACf,CAAC;SACH;QAED,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAEnD,OAAO,CAAC,GAAG,CAAC,YAAa,OAAO,CAAC,WAAY,cAAe,aAAc,EAAE,CAAC,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC,oBAAqB,WAAW,CAAC,OAAQ,EAAE,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,IAAA,cAAK,EAAC,aAAa,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,KAAM,OAAO,CAAC,KAAM,EAAE,CAAC;QAE5C,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,IAAA,kBAAS,EAAC,iBAAiB,EAAE,YAAY,CAAC,EAAE;YAC/C,OAAO,CAAC,KAAK,CAAC,wBAAyB,WAAW,CAAC,OAAQ,iBAAkB,iBAAkB,iCAAkC,OAAO,CAAC,WAAY,cAAe,aAAc,qBAAsB,YAAa,GAAG,CAAC,CAAC;YAC1N,OAAO;gBACL,OAAO,EAAE,KAAK;aACf,CAAC;SACH;QAED,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;;CACH;AAxCD,8BAwCC"}
@@ -0,0 +1,3 @@
1
+ export interface CheckVersionExecutorSchema {
2
+ packageName: string;
3
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "CheckVersion executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {
8
+ "packageName": {
9
+ "type": "string",
10
+ "description": "The name of the package used as minimum version reference"
11
+ }
12
+ },
13
+ "required": [
14
+ "packageName"
15
+ ]
16
+ }
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const Handlebars = tslib_1.__importStar(require("handlebars"));
4
+ const json_schema_ref_parser_1 = tslib_1.__importDefault(require("@apidevtools/json-schema-ref-parser"));
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const plugin_utilities_1 = require("@rxap/plugin-utilities");
7
+ const utilities_1 = require("@rxap/utilities");
8
+ const Handlebars = tslib_1.__importStar(require("handlebars"));
7
9
  const path_1 = require("path");
8
10
  function readGetStartedFile(context) {
9
11
  // TODO : support GET_STARTED.md but with an fallback to GETSTARTED.md
@@ -16,91 +18,135 @@ function getTemplate(context) {
16
18
  const readmeTemplateFile = (0, plugin_utilities_1.readFileFromProjectRoot)(context, 'README.md.handlebars', true);
17
19
  return Handlebars.compile(readmeTemplateFile);
18
20
  }
21
+ function normalizeSchema(context, schema, basePath) {
22
+ var _a, _b, _c;
23
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ schema = yield json_schema_ref_parser_1.default.bundle(schema, {
25
+ resolve: {
26
+ external: true,
27
+ file: {
28
+ canRead: /schema\.json$/,
29
+ read(file) {
30
+ // fix the file url. The url is already resolved relative the current cwd.
31
+ // this results in an incorrect path. Eg. $ref: ../init-application/schema.json
32
+ // will be resolved to file.url = /<project-root>/../init-application/schema.json
33
+ // A workaround is need to fix the url to be resolved relative to the schema.json
34
+ // file in the schematic/generator/executor/builder folder
35
+ const restoredRef = (0, path_1.relative)(context.root, file.url);
36
+ const schemaFilePath = (0, path_1.join)(basePath, restoredRef);
37
+ return (0, plugin_utilities_1.readFileFromProjectRoot)(context, schemaFilePath, true);
38
+ },
39
+ },
40
+ },
41
+ });
42
+ if (schema.allOf) {
43
+ schema.properties = {};
44
+ schema.required = [];
45
+ for (const item of schema.allOf) {
46
+ if (typeof item === 'object') {
47
+ schema.properties = (0, utilities_1.deepMerge)(schema.properties, (_a = item.properties) !== null && _a !== void 0 ? _a : {});
48
+ schema.required = [
49
+ ...schema.required, ...(typeof item.required !== 'boolean' ? (_b = item.required) !== null && _b !== void 0 ? _b : [] : []),
50
+ ].filter((0, utilities_1.unique)());
51
+ }
52
+ }
53
+ }
54
+ // ensure the property 'properties' is defined
55
+ (_c = schema.properties) !== null && _c !== void 0 ? _c : (schema.properties = {});
56
+ return schema;
57
+ });
58
+ }
19
59
  function getSchematics(context) {
20
60
  var _a;
21
- const { schematics } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
22
- if (!schematics) {
23
- return [];
24
- }
25
- const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
26
- const collectionJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, schematics));
27
- const schematicList = [];
28
- for (const [schematic, config] of Object.entries((_a = collectionJson.schematics) !== null && _a !== void 0 ? _a : {})) {
29
- schematicList.push({
30
- name: schematic,
31
- description: config.description,
32
- schema: (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, config.schema)),
33
- });
34
- }
35
- return schematicList;
61
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
62
+ const { schematics } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
63
+ if (!schematics) {
64
+ return [];
65
+ }
66
+ const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
67
+ const collectionJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, schematics));
68
+ const schematicList = [];
69
+ for (const [schematic, config] of Object.entries((_a = collectionJson.schematics) !== null && _a !== void 0 ? _a : {})) {
70
+ schematicList.push({
71
+ name: schematic,
72
+ description: config.description,
73
+ schema: yield normalizeSchema(context, (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, config.schema)), (0, path_1.dirname)(config.schema)),
74
+ });
75
+ }
76
+ return schematicList;
77
+ });
36
78
  }
37
79
  function getGenerators(context) {
38
80
  var _a;
39
- const { generators } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
40
- if (!generators) {
41
- return [];
42
- }
43
- const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
44
- const collectionJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, generators));
45
- const generatorList = [];
46
- for (const [generator, config] of Object.entries((_a = collectionJson.generators) !== null && _a !== void 0 ? _a : {})) {
47
- generatorList.push({
48
- name: generator,
49
- description: config.description,
50
- schema: (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, config.schema)),
51
- });
52
- }
53
- const schematicList = getSchematics(context);
54
- return [...generatorList, ...schematicList];
81
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
82
+ const { generators } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
83
+ if (!generators) {
84
+ return [];
85
+ }
86
+ const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
87
+ const collectionJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, generators));
88
+ const generatorList = [];
89
+ for (const [generator, config] of Object.entries((_a = collectionJson.generators) !== null && _a !== void 0 ? _a : {})) {
90
+ generatorList.push({
91
+ name: generator,
92
+ description: config.description,
93
+ schema: yield normalizeSchema(context, (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, config.schema)), (0, path_1.dirname)(config.schema)),
94
+ });
95
+ }
96
+ const schematicList = yield getSchematics(context);
97
+ return [...generatorList, ...schematicList];
98
+ });
55
99
  }
56
100
  function getBuilders(context) {
57
101
  var _a;
58
- const { builders } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
59
- if (!builders) {
60
- return [];
61
- }
62
- const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
63
- const buildersJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, builders));
64
- const builderList = [];
65
- for (const [builder, config] of Object.entries((_a = buildersJson.builders) !== null && _a !== void 0 ? _a : {})) {
66
- builderList.push({
67
- name: builder,
68
- description: config.description,
69
- schema: (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, config.schema)),
70
- });
71
- }
72
- return builderList;
102
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
103
+ const { builders } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
104
+ if (!builders) {
105
+ return [];
106
+ }
107
+ const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
108
+ const buildersJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, builders));
109
+ const builderList = [];
110
+ for (const [builder, config] of Object.entries((_a = buildersJson.builders) !== null && _a !== void 0 ? _a : {})) {
111
+ builderList.push({
112
+ name: builder,
113
+ description: config.description,
114
+ schema: yield normalizeSchema(context, (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, config.schema)), (0, path_1.dirname)(config.schema)),
115
+ });
116
+ }
117
+ return builderList;
118
+ });
73
119
  }
74
120
  function getExecutors(context) {
75
121
  var _a;
76
- const { executors } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
77
- if (!executors) {
78
- return [];
79
- }
80
- const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
81
- const executorsJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, executors));
82
- const executorList = [];
83
- for (const [executor, config] of Object.entries((_a = executorsJson.executors) !== null && _a !== void 0 ? _a : {})) {
84
- executorList.push({
85
- name: executor,
86
- description: config.description,
87
- schema: (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, config.schema)),
88
- });
89
- }
90
- const builderList = getBuilders(context);
91
- return [...executorList, ...builderList];
122
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
123
+ const { executors } = (0, plugin_utilities_1.readPackageJsonForProject)(context);
124
+ if (!executors) {
125
+ return [];
126
+ }
127
+ const projectRoot = (0, plugin_utilities_1.GetProjectRoot)(context);
128
+ const executorsJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, executors));
129
+ const executorList = [];
130
+ for (const [executor, config] of Object.entries((_a = executorsJson.executors) !== null && _a !== void 0 ? _a : {})) {
131
+ executorList.push({
132
+ name: executor,
133
+ description: config.description,
134
+ schema: yield normalizeSchema(context, (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, projectRoot, config.schema)), (0, path_1.dirname)(config.schema)),
135
+ });
136
+ }
137
+ const builderList = yield getBuilders(context);
138
+ return [...executorList, ...builderList];
139
+ });
92
140
  }
93
141
  function getPeerDependencyList(context) {
94
142
  var _a;
95
143
  const packageJson = (0, plugin_utilities_1.readPackageJsonForProject)(context);
96
144
  const peerDependencyList = [];
97
145
  for (const [packageName, version] of Object.entries((_a = packageJson.peerDependencies) !== null && _a !== void 0 ? _a : {})) {
98
- if (packageName.match(/^@rxap\//)) {
99
- peerDependencyList.push({
100
- name: packageName,
101
- version,
102
- });
103
- }
146
+ peerDependencyList.push({
147
+ name: packageName,
148
+ version,
149
+ });
104
150
  }
105
151
  return peerDependencyList;
106
152
  }
@@ -115,11 +161,12 @@ function runExecutor(options, context) {
115
161
  const guidesContent = readGetGuidsFile(context);
116
162
  const packageJson = (0, plugin_utilities_1.readPackageJsonForProject)(context);
117
163
  const template = getTemplate(context);
118
- const generatorList = getGenerators(context);
119
- const executorsList = getExecutors(context);
164
+ const generatorList = yield getGenerators(context);
165
+ const executorsList = yield getExecutors(context);
120
166
  const peerDependencyList = getPeerDependencyList(context);
121
167
  console.log('Input for README.md template ready');
122
- const readme = template({
168
+ let readme;
169
+ const templateContext = {
123
170
  packageJson,
124
171
  getStartedContent,
125
172
  guidesContent,
@@ -131,7 +178,16 @@ function runExecutor(options, context) {
131
178
  hasExecutors: executorsList.length > 0,
132
179
  hasInitGenerator: generatorList.find((generator) => generator.name === 'init') !== undefined,
133
180
  hasConfigGenerator: generatorList.find((generator) => generator.name === 'config') !== undefined,
134
- });
181
+ };
182
+ try {
183
+ readme = template(templateContext);
184
+ }
185
+ catch (e) {
186
+ console.error(`Error while generating README.md: ${e.message}`, templateContext);
187
+ return {
188
+ success: false,
189
+ };
190
+ }
135
191
  console.log('README.md generated');
136
192
  (0, plugin_utilities_1.writeFileToProjectRoot)(context, 'README.md', readme);
137
193
  return {