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