@powerlines/nx 0.1.0

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 (128) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +490 -0
  3. package/dist/chunk-23KFTIT2.mjs +1 -0
  4. package/dist/chunk-2IKNOV7W.mjs +305 -0
  5. package/dist/chunk-326QB2VK.mjs +14 -0
  6. package/dist/chunk-3QPPK4K2.js +18 -0
  7. package/dist/chunk-5K7DMFAV.mjs +15 -0
  8. package/dist/chunk-6UG6SXHV.js +4307 -0
  9. package/dist/chunk-6ZABD5GY.js +18 -0
  10. package/dist/chunk-AKX3TTDA.js +18 -0
  11. package/dist/chunk-CQP2LCFV.mjs +19 -0
  12. package/dist/chunk-CYWOTYVX.mjs +108 -0
  13. package/dist/chunk-E6VIOC6R.mjs +19 -0
  14. package/dist/chunk-ED7GH5H4.js +30 -0
  15. package/dist/chunk-ESI25Y6Y.mjs +15 -0
  16. package/dist/chunk-FK3VJFET.mjs +28 -0
  17. package/dist/chunk-FXCIWWXO.mjs +15 -0
  18. package/dist/chunk-HHPODCTP.js +126 -0
  19. package/dist/chunk-N2YKXZ5R.js +2 -0
  20. package/dist/chunk-O6BSKBJP.js +26 -0
  21. package/dist/chunk-O6YSETKJ.mjs +4 -0
  22. package/dist/chunk-OOERKIVS.js +312 -0
  23. package/dist/chunk-OZMYXUES.mjs +4276 -0
  24. package/dist/chunk-SHUYVCID.js +6 -0
  25. package/dist/chunk-TCSCYVA7.mjs +76 -0
  26. package/dist/chunk-UV4HQO3Y.mjs +1 -0
  27. package/dist/chunk-WKH7IEJU.js +26 -0
  28. package/dist/chunk-WUJKJGEW.js +17 -0
  29. package/dist/chunk-XO62WWX4.js +2 -0
  30. package/dist/chunk-XPEFTYN7.js +82 -0
  31. package/dist/executor-B2Y0F4JC.d.ts +83 -0
  32. package/dist/executor-BAcpDLQu.d.ts +83 -0
  33. package/dist/executor-BHIUeaip.d.ts +93 -0
  34. package/dist/executor-BYGMOBlU.d.mts +83 -0
  35. package/dist/executor-Ba95I3EK.d.mts +93 -0
  36. package/dist/executor-CIEyQL42.d.mts +83 -0
  37. package/dist/executor-CkqLFUNx.d.ts +83 -0
  38. package/dist/executor-D055lNr2.d.ts +83 -0
  39. package/dist/executor-D0PJOQkn.d.mts +83 -0
  40. package/dist/executor-DsRaA9mk.d.mts +83 -0
  41. package/dist/executors.d.mts +12 -0
  42. package/dist/executors.d.ts +12 -0
  43. package/dist/executors.js +34 -0
  44. package/dist/executors.mjs +9 -0
  45. package/dist/generators.d.mts +19 -0
  46. package/dist/generators.d.ts +19 -0
  47. package/dist/generators.js +16 -0
  48. package/dist/generators.mjs +3 -0
  49. package/dist/index.d.mts +16 -0
  50. package/dist/index.d.ts +16 -0
  51. package/dist/index.js +53 -0
  52. package/dist/index.mjs +12 -0
  53. package/dist/src/base/base-executor.d.mts +27 -0
  54. package/dist/src/base/base-executor.d.ts +27 -0
  55. package/dist/src/base/base-executor.js +12 -0
  56. package/dist/src/base/base-executor.mjs +3 -0
  57. package/dist/src/base/base-executor.schema.d.d.mts +75 -0
  58. package/dist/src/base/base-executor.schema.d.d.ts +75 -0
  59. package/dist/src/base/base-executor.schema.d.js +2 -0
  60. package/dist/src/base/base-executor.schema.d.mjs +1 -0
  61. package/dist/src/base/base-executor.schema.d.ts +75 -0
  62. package/dist/src/base/base-executor.schema.json +77 -0
  63. package/dist/src/base/base-executor.untyped.d.mts +5 -0
  64. package/dist/src/base/base-executor.untyped.d.ts +5 -0
  65. package/dist/src/base/base-executor.untyped.js +10 -0
  66. package/dist/src/base/base-executor.untyped.mjs +2 -0
  67. package/dist/src/executors/build/executor.d.mts +8 -0
  68. package/dist/src/executors/build/executor.d.ts +8 -0
  69. package/dist/src/executors/build/executor.js +19 -0
  70. package/dist/src/executors/build/executor.mjs +4 -0
  71. package/dist/src/executors/build/untyped.d.mts +5 -0
  72. package/dist/src/executors/build/untyped.d.ts +5 -0
  73. package/dist/src/executors/build/untyped.js +37 -0
  74. package/dist/src/executors/build/untyped.mjs +33 -0
  75. package/dist/src/executors/clean/executor.d.mts +8 -0
  76. package/dist/src/executors/clean/executor.d.ts +8 -0
  77. package/dist/src/executors/clean/executor.js +19 -0
  78. package/dist/src/executors/clean/executor.mjs +4 -0
  79. package/dist/src/executors/clean/untyped.d.mts +5 -0
  80. package/dist/src/executors/clean/untyped.d.ts +5 -0
  81. package/dist/src/executors/clean/untyped.js +19 -0
  82. package/dist/src/executors/clean/untyped.mjs +15 -0
  83. package/dist/src/executors/docs/executor.d.mts +8 -0
  84. package/dist/src/executors/docs/executor.d.ts +8 -0
  85. package/dist/src/executors/docs/executor.js +19 -0
  86. package/dist/src/executors/docs/executor.mjs +4 -0
  87. package/dist/src/executors/docs/untyped.d.mts +5 -0
  88. package/dist/src/executors/docs/untyped.d.ts +5 -0
  89. package/dist/src/executors/docs/untyped.js +20 -0
  90. package/dist/src/executors/docs/untyped.mjs +16 -0
  91. package/dist/src/executors/lint/executor.d.mts +8 -0
  92. package/dist/src/executors/lint/executor.d.ts +8 -0
  93. package/dist/src/executors/lint/executor.js +19 -0
  94. package/dist/src/executors/lint/executor.mjs +4 -0
  95. package/dist/src/executors/lint/untyped.d.mts +5 -0
  96. package/dist/src/executors/lint/untyped.d.ts +5 -0
  97. package/dist/src/executors/lint/untyped.js +20 -0
  98. package/dist/src/executors/lint/untyped.mjs +16 -0
  99. package/dist/src/executors/prepare/executor.d.mts +8 -0
  100. package/dist/src/executors/prepare/executor.d.ts +8 -0
  101. package/dist/src/executors/prepare/executor.js +19 -0
  102. package/dist/src/executors/prepare/executor.mjs +4 -0
  103. package/dist/src/executors/prepare/untyped.d.mts +5 -0
  104. package/dist/src/executors/prepare/untyped.d.ts +5 -0
  105. package/dist/src/executors/prepare/untyped.js +11 -0
  106. package/dist/src/executors/prepare/untyped.mjs +3 -0
  107. package/dist/src/generators/sync/generator.d.mts +6 -0
  108. package/dist/src/generators/sync/generator.d.ts +6 -0
  109. package/dist/src/generators/sync/generator.js +17 -0
  110. package/dist/src/generators/sync/generator.mjs +2 -0
  111. package/dist/src/generators/sync/untyped.d.mts +5 -0
  112. package/dist/src/generators/sync/untyped.d.ts +5 -0
  113. package/dist/src/generators/sync/untyped.js +25 -0
  114. package/dist/src/generators/sync/untyped.mjs +21 -0
  115. package/dist/src/plugin/index.d.mts +8 -0
  116. package/dist/src/plugin/index.d.ts +8 -0
  117. package/dist/src/plugin/index.js +16 -0
  118. package/dist/src/plugin/index.mjs +3 -0
  119. package/docs/api/base-executor.schema.md +72 -0
  120. package/docs/api/build/schema.md +82 -0
  121. package/docs/api/clean/schema.md +72 -0
  122. package/docs/api/docs/schema.md +72 -0
  123. package/docs/api/lint/schema.md +72 -0
  124. package/docs/api/prepare/schema.md +72 -0
  125. package/docs/api/sync/schema.md +16 -0
  126. package/executors.json +30 -0
  127. package/generators.json +14 -0
  128. package/package.json +172 -0
@@ -0,0 +1,312 @@
1
+ 'use strict';
2
+
3
+ var chunkHHPODCTP_js = require('./chunk-HHPODCTP.js');
4
+ var devkit = require('@nx/devkit');
5
+ var nxJson = require('@storm-software/workspace-tools/utils/nx-json');
6
+ var pluginHelpers = require('@storm-software/workspace-tools/utils/plugin-helpers');
7
+ var projectTags = require('@storm-software/workspace-tools/utils/project-tags');
8
+ var getEnvPaths = require('@stryke/env/get-env-paths');
9
+ var exists = require('@stryke/fs/exists');
10
+ var json = require('@stryke/fs/json');
11
+ var murmurhash = require('@stryke/hash/murmurhash');
12
+ var joinPaths = require('@stryke/path/join-paths');
13
+ var kebabCase = require('@stryke/string-format/kebab-case');
14
+ var isError = require('@stryke/type-checks/is-error');
15
+ var defu = require('defu');
16
+ var jiti = require('jiti');
17
+ var path = require('path');
18
+ var nxJson_js = require('nx/src/config/nx-json.js');
19
+ var packageJson_js = require('nx/src/utils/package-json.js');
20
+
21
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
+
23
+ var defu__default = /*#__PURE__*/_interopDefault(defu);
24
+
25
+ // src/helpers/constants.ts
26
+ var CONFIG_INPUTS = [
27
+ "{projectRoot}/.storm",
28
+ "{projectRoot}/storm.json",
29
+ "{projectRoot}/storm.*.json",
30
+ "{projectRoot}/storm.jsonc",
31
+ "{projectRoot}/storm.*.jsonc",
32
+ "{projectRoot}/storm.json5",
33
+ "{projectRoot}/storm.*.json5",
34
+ "{projectRoot}/storm.yaml",
35
+ "{projectRoot}/storm.*.yaml",
36
+ "{projectRoot}/storm.yml",
37
+ "{projectRoot}/storm.*.yml",
38
+ "{projectRoot}/storm.toml",
39
+ "{projectRoot}/storm.*.toml",
40
+ "{projectRoot}/storm.js",
41
+ "{projectRoot}/storm.*.js",
42
+ "{projectRoot}/storm.cjs",
43
+ "{projectRoot}/storm.*.cjs",
44
+ "{projectRoot}/storm.mjs",
45
+ "{projectRoot}/storm.*.mjs",
46
+ "{projectRoot}/storm.ts",
47
+ "{projectRoot}/storm.*.ts",
48
+ "{projectRoot}/storm.cts",
49
+ "{projectRoot}/storm.*.cts",
50
+ "{projectRoot}/storm.mts",
51
+ "{projectRoot}/storm.*.mts"
52
+ ];
53
+
54
+ // src/plugin/index.ts
55
+ var name = "powerlines/nx/plugin";
56
+ var stormConfigGlob = "**/{package.json,storm.json,storm.*.json,storm.jsonc,storm.*.jsonc,storm.json5,storm.*.json5,storm.yaml,storm.*.yaml,storm.yml,storm.*.yml,storm.toml,storm.*.toml,storm.js,storm.*.js,storm.ts,storm.*.ts,storm.mjs,storm.*.mjs,storm.cjs,storm.*.cjs,storm.mts,storm.*.mts,storm.cts,storm.*.cts}";
57
+ var createNodesV2 = [
58
+ stormConfigGlob,
59
+ async (configFiles, optionsV2, contextV2) => {
60
+ const envPaths = getEnvPaths.getEnvPaths({
61
+ orgId: "storm-software",
62
+ appId: "powerlines",
63
+ workspaceRoot: contextV2.workspaceRoot
64
+ });
65
+ if (!envPaths.cache) {
66
+ throw new Error("The cache directory could not be determined.");
67
+ }
68
+ const nxJson$1 = nxJson_js.readNxJson(contextV2.workspaceRoot);
69
+ return devkit.createNodesFromFiles(async (configFile, options, context) => {
70
+ try {
71
+ const projectRoot = pluginHelpers.getProjectRoot(configFile, contextV2.workspaceRoot);
72
+ if (!projectRoot) {
73
+ console.error(`[${name}]: package.json and Powerlines configuration files (i.e. powerlines.config.ts) must be located in the project root directory: ${configFile}`);
74
+ return {};
75
+ }
76
+ const root = pluginHelpers.getRoot(projectRoot, context);
77
+ const cacheDir = joinPaths.joinPaths(envPaths.cache, "projects", murmurhash.murmurhash(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot), {
78
+ maxLength: chunkHHPODCTP_js.PROJECT_ROOT_HASH_LENGTH
79
+ }));
80
+ const jiti$1 = jiti.createJiti(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot), {
81
+ interopDefault: true,
82
+ fsCache: joinPaths.joinPaths(cacheDir, "jiti"),
83
+ moduleCache: true
84
+ });
85
+ const userConfig = await chunkHHPODCTP_js.loadUserConfigFile(projectRoot, jiti$1);
86
+ const packageJson = json.readJsonFileSync(joinPaths.joinPaths(projectRoot, "package.json"));
87
+ if (!userConfig.configFile && !packageJson.storm) {
88
+ console.debug(`[${name}]: Skipping ${projectRoot} - no Powerlines configuration found for project in root directory.`);
89
+ return {};
90
+ }
91
+ const projectConfig = pluginHelpers.getProjectConfigFromProjectRoot(projectRoot, packageJson);
92
+ if (!projectConfig) {
93
+ console.warn(`[${name}]: No project configuration found for project in root directory ${projectRoot}`);
94
+ return {};
95
+ }
96
+ const tsconfig = userConfig?.tsconfig || (exists.existsSync(joinPaths.joinPaths(projectRoot, "tsconfig.json")) ? joinPaths.joinPaths(projectRoot, "tsconfig.json") : void 0);
97
+ const targets = packageJson_js.readTargetsFromPackageJson(packageJson, nxJson$1, projectRoot, context.workspaceRoot);
98
+ targets.clean = {
99
+ dependsOn: [
100
+ "^clean"
101
+ ],
102
+ executor: "@powerlines/nx:clean",
103
+ defaultConfiguration: "production",
104
+ options: {
105
+ outputPath: userConfig.output?.outputPath || "dist/{projectRoot}",
106
+ projectType: projectConfig.projectType || userConfig.type,
107
+ skipInstalls: userConfig.skipInstalls
108
+ },
109
+ configurations: {
110
+ production: {
111
+ mode: "production"
112
+ },
113
+ test: {
114
+ mode: "test"
115
+ },
116
+ development: {
117
+ mode: "development",
118
+ skipCache: true
119
+ }
120
+ }
121
+ };
122
+ targets.prepare = {
123
+ cache: true,
124
+ inputs: nxJson.withNamedInputs(CONFIG_INPUTS, [
125
+ "typescript"
126
+ ]),
127
+ outputs: [
128
+ "{projectRoot}/.storm"
129
+ ],
130
+ dependsOn: [
131
+ "clean",
132
+ "^prepare"
133
+ ],
134
+ executor: "@powerlines/nx:prepare",
135
+ defaultConfiguration: "production",
136
+ options: {
137
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
138
+ projectType: projectConfig.projectType || userConfig.type,
139
+ tsconfig,
140
+ skipInstalls: userConfig.skipInstalls,
141
+ skipCache: userConfig.skipCache
142
+ },
143
+ configurations: {
144
+ production: {
145
+ mode: "production"
146
+ },
147
+ test: {
148
+ mode: "test"
149
+ },
150
+ development: {
151
+ mode: "development",
152
+ skipCache: true
153
+ }
154
+ }
155
+ };
156
+ targets["type-check"] ??= {
157
+ cache: true,
158
+ inputs: [
159
+ "typescript",
160
+ "^production"
161
+ ],
162
+ outputs: [
163
+ "{workspaceRoot}/dist/{projectRoot}"
164
+ ],
165
+ executor: "nx:run-commands",
166
+ dependsOn: [
167
+ "^type-check",
168
+ "^build"
169
+ ],
170
+ options: {
171
+ command: `pnpm exec tsc --noEmit --pretty --project ${userConfig.tsconfig || path.join(projectConfig.root, "tsconfig.json")}`
172
+ }
173
+ };
174
+ targets.build = {
175
+ cache: true,
176
+ inputs: nxJson.withNamedInputs(CONFIG_INPUTS, [
177
+ "typescript"
178
+ ]),
179
+ outputs: [
180
+ "{options.outputPath}"
181
+ ],
182
+ dependsOn: [
183
+ "prepare",
184
+ "^build"
185
+ ],
186
+ executor: "@powerlines/nx:build",
187
+ defaultConfiguration: "production",
188
+ options: {
189
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
190
+ outputPath: userConfig.output?.outputPath || "dist/{projectRoot}",
191
+ projectType: projectConfig.projectType || userConfig.type,
192
+ tsconfig,
193
+ skipInstalls: userConfig.skipInstalls,
194
+ skipCache: userConfig.skipCache
195
+ },
196
+ configurations: {
197
+ production: {
198
+ mode: "production"
199
+ },
200
+ test: {
201
+ mode: "test"
202
+ },
203
+ development: {
204
+ mode: "development",
205
+ skipCache: true
206
+ }
207
+ }
208
+ };
209
+ targets.lint = {
210
+ cache: true,
211
+ inputs: nxJson.withNamedInputs([
212
+ ...CONFIG_INPUTS,
213
+ "{projectRoot}/.storm"
214
+ ], [
215
+ "linting",
216
+ "typescript"
217
+ ]),
218
+ outputs: nxJson.withNamedInputs([
219
+ "{projectRoot}/.storm"
220
+ ], [
221
+ "typescript"
222
+ ]),
223
+ dependsOn: [
224
+ "prepare",
225
+ "^lint"
226
+ ],
227
+ executor: "@powerlines/nx:lint",
228
+ defaultConfiguration: "production",
229
+ options: {
230
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
231
+ projectType: projectConfig.projectType || userConfig.type,
232
+ tsconfig,
233
+ skipInstalls: userConfig.skipInstalls,
234
+ skipCache: userConfig.skipCache
235
+ },
236
+ configurations: {
237
+ production: {
238
+ mode: "production"
239
+ },
240
+ test: {
241
+ mode: "test"
242
+ },
243
+ development: {
244
+ mode: "development",
245
+ skipCache: true
246
+ }
247
+ }
248
+ };
249
+ targets.docs = {
250
+ cache: true,
251
+ inputs: nxJson.withNamedInputs([
252
+ ...CONFIG_INPUTS,
253
+ "{projectRoot}/.storm"
254
+ ], [
255
+ "documentation",
256
+ "typescript"
257
+ ]),
258
+ outputs: [
259
+ "{projectRoot}/docs/generated"
260
+ ],
261
+ dependsOn: [
262
+ "prepare",
263
+ "build",
264
+ "^docs"
265
+ ],
266
+ executor: "@powerlines/nx:docs",
267
+ defaultConfiguration: "production",
268
+ options: {
269
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
270
+ projectType: projectConfig.projectType || userConfig.type,
271
+ tsconfig,
272
+ skipInstalls: userConfig.skipInstalls,
273
+ skipCache: userConfig.skipCache
274
+ },
275
+ configurations: {
276
+ production: {
277
+ mode: "production"
278
+ },
279
+ test: {
280
+ mode: "test"
281
+ },
282
+ development: {
283
+ mode: "development",
284
+ skipCache: true
285
+ }
286
+ }
287
+ };
288
+ projectTags.setDefaultProjectTags(projectConfig, name);
289
+ projectTags.addProjectTag(projectConfig, "powerlines", projectConfig.projectType || userConfig.type || "library", {
290
+ overwrite: true
291
+ });
292
+ return {
293
+ projects: {
294
+ [root]: defu__default.default(projectConfig, {
295
+ name: kebabCase.kebabCase(userConfig.name),
296
+ projectType: userConfig.type || "library",
297
+ root,
298
+ sourceRoot: joinPaths.joinPaths(root, "src"),
299
+ targets
300
+ })
301
+ }
302
+ };
303
+ } catch (error) {
304
+ console.error(`[${name}]: ${isError.isError(error) ? error.message : "Unknown fatal error"}`);
305
+ return {};
306
+ }
307
+ }, configFiles, optionsV2, contextV2);
308
+ }
309
+ ];
310
+
311
+ exports.createNodesV2 = createNodesV2;
312
+ exports.name = name;