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