@smoothbricks/nx-plugin 0.3.3 → 0.3.5
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/README.md +40 -8
- package/dist/bounded-test-policy.d.ts +4 -2
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +93 -15
- package/dist/executors/typescript-emit/executor.d.ts +17 -0
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -0
- package/dist/executors/typescript-emit/executor.js +61 -0
- package/dist/executors/typescript-emit/schema.d.ts +5 -0
- package/dist/executors/typescript-emit/schema.d.ts.map +1 -0
- package/dist/executors/typescript-emit/schema.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +278 -28
- package/dist/package-target-policy.d.ts +2 -0
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +5 -1
- package/dist/version-actions.cjs +13 -39
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +11 -3
- package/executors.json +5 -0
- package/package.json +4 -3
- package/src/bounded-test-policy.test.ts +102 -2
- package/src/bounded-test-policy.ts +110 -17
- package/src/executors/typescript-emit/executor.test.ts +98 -0
- package/src/executors/typescript-emit/executor.ts +94 -0
- package/src/executors/typescript-emit/schema.json +19 -0
- package/src/executors/typescript-emit/schema.ts +4 -0
- package/src/index.test.ts +157 -17
- package/src/index.ts +356 -30
- package/src/package-target-policy.test.ts +17 -0
- package/src/package-target-policy.ts +5 -1
- package/src/version-actions.cts +13 -39
- package/src/workspace-config-policy.test.ts +41 -1
- package/src/workspace-config-policy.ts +12 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join, posix } from 'node:path';
|
|
4
|
+
import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
4
5
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
6
|
+
import { parse as parseToml } from 'smol-toml';
|
|
5
7
|
import { BUILD_OUTPUT_DEPENDENCIES, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
6
8
|
const BUILD_OUTPUT_TARGET_PATTERN = /-(?:js|web|html|css|android|native|napi|bun|wasm)$/;
|
|
7
9
|
const TYPESCRIPT_TOOLCHAIN_INPUTS = [
|
|
@@ -13,21 +15,65 @@ const TYPESCRIPT_TOOLCHAIN_INPUTS = [
|
|
|
13
15
|
//#region smoo!n/rust-output-target-inference
|
|
14
16
|
// Cargo workspace inference: a package.json sitting next to a Cargo.toml that
|
|
15
17
|
// declares [workspace] gets direct cargo-test/test targets, cargo-lint feeding
|
|
16
|
-
// the lint aggregate, mutation (cargo-mutants), and bench.
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// declare output targets in package.json nx.targets, and those *-wasm/*-napi/
|
|
20
|
-
// *-native output-family names feed the aggregate build and clean targets.
|
|
21
|
-
// Explicit nx.targets entries always win over inference.
|
|
18
|
+
// the lint aggregate, mutation (cargo-mutants), and bench. Cargo output families
|
|
19
|
+
// use tool-native metadata: N-API comes from package.json napi metadata; Wasm
|
|
20
|
+
// comes from [package.metadata.smoothbricks.wasm-bindgen] in a crate manifest.
|
|
22
21
|
const CARGO_WORKSPACE_PATTERN = /^\s*\[workspace\]/m;
|
|
23
22
|
//#endregion
|
|
24
23
|
const CARGO_INPUTS = [
|
|
25
24
|
'{projectRoot}/**/*.rs',
|
|
26
25
|
'{projectRoot}/**/Cargo.toml',
|
|
27
|
-
'{projectRoot}
|
|
28
|
-
'{projectRoot}
|
|
29
|
-
'!{projectRoot}
|
|
26
|
+
'{projectRoot}/**/Cargo.lock',
|
|
27
|
+
'{projectRoot}/**/.cargo/config.toml',
|
|
28
|
+
'!{projectRoot}/**/target/**',
|
|
30
29
|
];
|
|
30
|
+
const CARGO_OUTPUT_INPUTS = [...CARGO_INPUTS, '{projectRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
|
31
|
+
const NAPI_INPUTS = CARGO_OUTPUT_INPUTS;
|
|
32
|
+
const NAPI_TARGET_CONVENTIONS = {
|
|
33
|
+
'aarch64-apple-darwin': {
|
|
34
|
+
architecture: 'arm64',
|
|
35
|
+
outputName: 'darwin-arm64',
|
|
36
|
+
targetFamily: 'macos',
|
|
37
|
+
useNapiCross: false,
|
|
38
|
+
},
|
|
39
|
+
'x86_64-apple-darwin': {
|
|
40
|
+
architecture: 'x64',
|
|
41
|
+
outputName: 'darwin-x64',
|
|
42
|
+
targetFamily: 'macos',
|
|
43
|
+
useNapiCross: false,
|
|
44
|
+
},
|
|
45
|
+
'aarch64-unknown-linux-gnu': {
|
|
46
|
+
architecture: 'arm64',
|
|
47
|
+
outputName: 'linux-arm64-gnu',
|
|
48
|
+
targetFamily: 'linux',
|
|
49
|
+
useNapiCross: true,
|
|
50
|
+
},
|
|
51
|
+
'x86_64-unknown-linux-gnu': {
|
|
52
|
+
architecture: 'x64',
|
|
53
|
+
outputName: 'linux-x64-gnu',
|
|
54
|
+
targetFamily: 'linux',
|
|
55
|
+
useNapiCross: true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
function createCargoWasmTarget(projectRoot, config) {
|
|
59
|
+
const cargoTargetDirectory = posix.join(posix.dirname(config.manifestPath), 'target/cargo-wasm');
|
|
60
|
+
const wasmInput = `${cargoTargetDirectory}/wasm32-unknown-unknown/release/${config.libraryName}.wasm`;
|
|
61
|
+
return {
|
|
62
|
+
executor: 'nx:run-commands',
|
|
63
|
+
cache: true,
|
|
64
|
+
dependsOn: ['^build'],
|
|
65
|
+
inputs: CARGO_OUTPUT_INPUTS,
|
|
66
|
+
outputs: [`{projectRoot}/${config.outputDirectory}`],
|
|
67
|
+
options: {
|
|
68
|
+
commands: [
|
|
69
|
+
`cargo build --release --target wasm32-unknown-unknown --target-dir ${cargoTargetDirectory} --manifest-path ${config.manifestPath}`,
|
|
70
|
+
...config.targets.map(({ bindgenTarget, outputName }) => `wasm-bindgen --target ${bindgenTarget} --out-dir ${config.outputDirectory}/${outputName} ${wasmInput}`),
|
|
71
|
+
],
|
|
72
|
+
cwd: projectRoot,
|
|
73
|
+
parallel: false,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
31
77
|
function createCargoTestTarget(projectRoot) {
|
|
32
78
|
return {
|
|
33
79
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
@@ -80,21 +126,34 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
80
126
|
const packageJson = await readPackageJson(join(workspaceRoot, packageJsonPath));
|
|
81
127
|
const targets = {};
|
|
82
128
|
const validationTargets = [];
|
|
83
|
-
const
|
|
129
|
+
const libTsconfigPath = join(absoluteProjectRoot, 'tsconfig.lib.json');
|
|
130
|
+
const hasLibTsconfig = existsSync(libTsconfigPath);
|
|
131
|
+
const cargoTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
|
|
132
|
+
const isCargoWorkspace = existsSync(cargoTomlPath) && CARGO_WORKSPACE_PATTERN.test(await readFile(cargoTomlPath, 'utf-8'));
|
|
133
|
+
const napiConfig = resolveNapiConfig(packageJson, packageJsonPath, absoluteProjectRoot, isCargoWorkspace);
|
|
134
|
+
const declaredTargets = packageJson.nx?.targets ?? {};
|
|
135
|
+
const cargoWasmConfig = await resolveCargoWasmConfig(absoluteProjectRoot, packageJsonPath);
|
|
136
|
+
const inferCargoWasm = cargoWasmConfig !== null && !('cargo-wasm' in declaredTargets);
|
|
84
137
|
const packageLocalBuildOutputs = classifyPackageLocalBuildOutputs(packageJson);
|
|
85
|
-
const hasOrdinaryBuildOutputTarget = hasLibTsconfig || packageLocalBuildOutputs.ordinary;
|
|
138
|
+
const hasOrdinaryBuildOutputTarget = hasLibTsconfig || napiConfig !== null || cargoWasmConfig !== null || packageLocalBuildOutputs.ordinary;
|
|
86
139
|
const hasAnyBuildOutputTarget = hasOrdinaryBuildOutputTarget || packageLocalBuildOutputs.platform;
|
|
87
140
|
if (hasLibTsconfig) {
|
|
88
|
-
//
|
|
89
|
-
//
|
|
141
|
+
// Dependency packages may publish bundled entries that raw tsc does not produce.
|
|
142
|
+
// Build every JavaScript output lane before resolving package exports, without pulling
|
|
143
|
+
// unrelated Wasm, N-API, native, or web outputs onto the compiler critical path.
|
|
144
|
+
//
|
|
145
|
+
// ttsc transforms the source program before declaration emit, so typia's
|
|
146
|
+
// generated implementation identifiers are not valid declaration inputs.
|
|
147
|
+
// The executor gives ttsc a JS-only overlay and emits declarations from the
|
|
148
|
+
// original project with native tsc.
|
|
90
149
|
targets['tsc-js'] = {
|
|
91
|
-
executor: 'nx:
|
|
150
|
+
executor: '@smoothbricks/nx-plugin:typescript-emit',
|
|
92
151
|
cache: true,
|
|
93
152
|
inputs: ['production', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.lib.json'],
|
|
94
|
-
outputs:
|
|
95
|
-
dependsOn: ['
|
|
153
|
+
outputs: inferTypescriptOutputs(libTsconfigPath, packageJsonPath),
|
|
154
|
+
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
96
155
|
options: {
|
|
97
|
-
|
|
156
|
+
tsConfig: 'tsconfig.lib.json',
|
|
98
157
|
cwd: projectRoot,
|
|
99
158
|
},
|
|
100
159
|
};
|
|
@@ -103,9 +162,9 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
103
162
|
cache: true,
|
|
104
163
|
inputs: ['production', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.lib.json'],
|
|
105
164
|
outputs: [],
|
|
106
|
-
dependsOn: ['
|
|
165
|
+
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
107
166
|
options: {
|
|
108
|
-
command: '
|
|
167
|
+
command: 'tsc -p tsconfig.lib.json --noEmit',
|
|
109
168
|
cwd: projectRoot,
|
|
110
169
|
},
|
|
111
170
|
};
|
|
@@ -118,7 +177,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
118
177
|
inputs: ['default', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.test.json'],
|
|
119
178
|
dependsOn: ['typecheck'],
|
|
120
179
|
options: {
|
|
121
|
-
command: '
|
|
180
|
+
command: 'tsc -p tsconfig.test.json --noEmit',
|
|
122
181
|
cwd: projectRoot,
|
|
123
182
|
},
|
|
124
183
|
};
|
|
@@ -126,7 +185,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
126
185
|
executor: 'nx:run-commands',
|
|
127
186
|
continuous: true,
|
|
128
187
|
options: {
|
|
129
|
-
command: '
|
|
188
|
+
command: 'tsc -p tsconfig.test.json --noEmit --watch',
|
|
130
189
|
cwd: projectRoot,
|
|
131
190
|
},
|
|
132
191
|
};
|
|
@@ -147,11 +206,20 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
147
206
|
else if (hasLibTsconfig) {
|
|
148
207
|
validationTargets.push('typecheck');
|
|
149
208
|
}
|
|
209
|
+
if (inferCargoWasm && cargoWasmConfig) {
|
|
210
|
+
targets['cargo-wasm'] = createCargoWasmTarget(projectRoot, cargoWasmConfig);
|
|
211
|
+
}
|
|
212
|
+
if (napiConfig) {
|
|
213
|
+
Object.assign(targets, createNapiTargets(projectRoot, napiConfig));
|
|
214
|
+
if (!('napi-test' in (packageJson.nx?.targets ?? {})) &&
|
|
215
|
+
existsSync(join(absoluteProjectRoot, 'src/native.test.ts'))) {
|
|
216
|
+
targets['napi-test'] = createNapiTestTarget(projectRoot, existsSync(join(absoluteProjectRoot, 'bunfig.napi-test.toml')));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
150
219
|
// Member crates get their targets from the workspace-root package.json,
|
|
151
220
|
// never per-crate — one Nx project per Cargo workspace.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const declared = packageJson.nx?.targets ?? {};
|
|
221
|
+
if (isCargoWorkspace) {
|
|
222
|
+
const declared = declaredTargets;
|
|
155
223
|
if (!('cargo-test' in declared)) {
|
|
156
224
|
targets['cargo-test'] = createCargoTestTarget(projectRoot);
|
|
157
225
|
}
|
|
@@ -168,7 +236,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
168
236
|
};
|
|
169
237
|
}
|
|
170
238
|
validationTargets.push('cargo-lint');
|
|
171
|
-
if (!('test' in declared) && typeof packageJson.scripts?.test !== 'string') {
|
|
239
|
+
if (!targets.test && !('test' in declared) && typeof packageJson.scripts?.test !== 'string') {
|
|
172
240
|
// Execute Cargo directly: workspace targetDefaults may replace test.dependsOn.
|
|
173
241
|
targets.test = createCargoTestTarget(projectRoot);
|
|
174
242
|
}
|
|
@@ -204,7 +272,10 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
204
272
|
}
|
|
205
273
|
if (targets['typecheck-tests']) {
|
|
206
274
|
if (hasLibTsconfig) {
|
|
207
|
-
|
|
275
|
+
// Test configs may resolve the package's own `./index.js` through dist.
|
|
276
|
+
// Rebuild that current-project declaration output after clean, not only
|
|
277
|
+
// dependency-project outputs reached through typecheck.
|
|
278
|
+
targets['typecheck-tests'].dependsOn = ['tsc-js', 'typecheck'];
|
|
208
279
|
}
|
|
209
280
|
else if (targets.build) {
|
|
210
281
|
targets['typecheck-tests'].dependsOn = ['build'];
|
|
@@ -226,6 +297,184 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
226
297
|
},
|
|
227
298
|
};
|
|
228
299
|
}
|
|
300
|
+
const WASM_BINDGEN_OUTPUT_NAMES = {
|
|
301
|
+
bundler: 'bundler',
|
|
302
|
+
deno: 'deno',
|
|
303
|
+
module: 'module',
|
|
304
|
+
'no-modules': 'no-modules',
|
|
305
|
+
nodejs: 'node',
|
|
306
|
+
web: 'web',
|
|
307
|
+
};
|
|
308
|
+
async function resolveCargoWasmConfig(absoluteProjectRoot, packageJsonPath) {
|
|
309
|
+
const manifestPaths = ['Cargo.toml'];
|
|
310
|
+
const cratesDirectory = join(absoluteProjectRoot, 'crates');
|
|
311
|
+
if (existsSync(cratesDirectory)) {
|
|
312
|
+
const crateEntries = await readdir(cratesDirectory, { withFileTypes: true });
|
|
313
|
+
for (const entry of crateEntries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
314
|
+
if (entry.isDirectory()) {
|
|
315
|
+
const manifestPath = posix.join('crates', entry.name, 'Cargo.toml');
|
|
316
|
+
if (existsSync(join(absoluteProjectRoot, manifestPath))) {
|
|
317
|
+
manifestPaths.push(manifestPath);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const resolved = [];
|
|
323
|
+
for (const manifestPath of manifestPaths) {
|
|
324
|
+
const absoluteManifestPath = join(absoluteProjectRoot, manifestPath);
|
|
325
|
+
if (!existsSync(absoluteManifestPath)) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const manifest = parseToml(await readFile(absoluteManifestPath, 'utf-8'));
|
|
329
|
+
const cargoPackage = isRecord(manifest) && isRecord(manifest.package) ? manifest.package : null;
|
|
330
|
+
const metadata = cargoPackage && isRecord(cargoPackage.metadata) ? cargoPackage.metadata : null;
|
|
331
|
+
const smoothbricks = metadata && isRecord(metadata.smoothbricks) ? metadata.smoothbricks : null;
|
|
332
|
+
const rawConfig = smoothbricks && isRecord(smoothbricks['wasm-bindgen']) ? smoothbricks['wasm-bindgen'] : null;
|
|
333
|
+
if (!rawConfig) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
const packageName = cargoPackage?.name;
|
|
337
|
+
if (typeof packageName !== 'string' || !/^[A-Za-z0-9_-]+$/.test(packageName)) {
|
|
338
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} must declare a valid package.name for Wasm inference`);
|
|
339
|
+
}
|
|
340
|
+
const lib = isRecord(manifest) && isRecord(manifest.lib) ? manifest.lib : null;
|
|
341
|
+
const crateTypes = lib?.['crate-type'];
|
|
342
|
+
if (!Array.isArray(crateTypes) || !crateTypes.includes('cdylib')) {
|
|
343
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} Wasm inference requires lib.crate-type to include cdylib`);
|
|
344
|
+
}
|
|
345
|
+
const rawLibraryName = lib?.name ?? packageName.replaceAll('-', '_');
|
|
346
|
+
if (typeof rawLibraryName !== 'string' || !/^[A-Za-z0-9_]+$/.test(rawLibraryName)) {
|
|
347
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} must declare a valid Rust library name`);
|
|
348
|
+
}
|
|
349
|
+
const rawTargets = rawConfig.targets;
|
|
350
|
+
if (!Array.isArray(rawTargets) ||
|
|
351
|
+
rawTargets.length === 0 ||
|
|
352
|
+
!rawTargets.every((target) => typeof target === 'string')) {
|
|
353
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} smoothbricks.wasm-bindgen.targets must be a non-empty string array`);
|
|
354
|
+
}
|
|
355
|
+
const bindgenTargets = [...new Set(rawTargets)];
|
|
356
|
+
const targets = bindgenTargets.map((bindgenTarget) => {
|
|
357
|
+
const outputName = WASM_BINDGEN_OUTPUT_NAMES[bindgenTarget];
|
|
358
|
+
if (!outputName) {
|
|
359
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} has unsupported wasm-bindgen target ${bindgenTarget}`);
|
|
360
|
+
}
|
|
361
|
+
return { bindgenTarget, outputName };
|
|
362
|
+
});
|
|
363
|
+
const rawOutputDirectory = rawConfig['out-dir'] ?? 'dist-wasm';
|
|
364
|
+
if (typeof rawOutputDirectory !== 'string' || !/^[A-Za-z0-9._/-]+$/.test(rawOutputDirectory)) {
|
|
365
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} smoothbricks.wasm-bindgen.out-dir must be a safe relative path`);
|
|
366
|
+
}
|
|
367
|
+
const outputDirectory = posix.normalize(rawOutputDirectory);
|
|
368
|
+
if (outputDirectory === '.' ||
|
|
369
|
+
outputDirectory === '..' ||
|
|
370
|
+
outputDirectory.startsWith('../') ||
|
|
371
|
+
outputDirectory.startsWith('/')) {
|
|
372
|
+
throw new Error(`${packageJsonPath}: ${manifestPath} smoothbricks.wasm-bindgen.out-dir must stay inside the project`);
|
|
373
|
+
}
|
|
374
|
+
resolved.push({ libraryName: rawLibraryName, manifestPath, outputDirectory, targets });
|
|
375
|
+
}
|
|
376
|
+
if (resolved.length > 1) {
|
|
377
|
+
throw new Error(`${packageJsonPath}: only one Cargo crate may declare smoothbricks.wasm-bindgen metadata`);
|
|
378
|
+
}
|
|
379
|
+
return resolved[0] ?? null;
|
|
380
|
+
}
|
|
381
|
+
function inferTypescriptOutputs(tsconfigPath, packageJsonPath) {
|
|
382
|
+
const tsconfig = readJsonFile(tsconfigPath);
|
|
383
|
+
const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
|
|
384
|
+
const outDir = compilerOptions?.outDir;
|
|
385
|
+
if (typeof outDir !== 'string' || outDir.length === 0) {
|
|
386
|
+
return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}', '{projectRoot}/dist/**/*.tsbuildinfo'];
|
|
387
|
+
}
|
|
388
|
+
const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
|
|
389
|
+
if (normalized === '.' || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('/')) {
|
|
390
|
+
throw new Error(`${packageJsonPath}: tsconfig.lib.json compilerOptions.outDir must stay inside the project`);
|
|
391
|
+
}
|
|
392
|
+
return [`{projectRoot}/${normalized}`];
|
|
393
|
+
}
|
|
394
|
+
function resolveNapiConfig(packageJson, packageJsonPath, absoluteProjectRoot, isCargoWorkspace) {
|
|
395
|
+
if (!packageJson.napi) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
if (!isCargoWorkspace) {
|
|
399
|
+
throw new Error(`${packageJsonPath}: napi target inference requires a Cargo workspace beside package.json`);
|
|
400
|
+
}
|
|
401
|
+
const binaryName = packageJson.napi.binaryName;
|
|
402
|
+
if (typeof binaryName !== 'string' || !/^[A-Za-z0-9_-]+$/.test(binaryName)) {
|
|
403
|
+
throw new Error(`${packageJsonPath}: napi.binaryName must contain only letters, numbers, hyphens, or underscores`);
|
|
404
|
+
}
|
|
405
|
+
const rawTargets = packageJson.napi.targets;
|
|
406
|
+
if (!Array.isArray(rawTargets) ||
|
|
407
|
+
rawTargets.length === 0 ||
|
|
408
|
+
!rawTargets.every((target) => typeof target === 'string')) {
|
|
409
|
+
throw new Error(`${packageJsonPath}: napi.targets must be a non-empty array of target triples`);
|
|
410
|
+
}
|
|
411
|
+
const targets = [...new Set(rawTargets)];
|
|
412
|
+
for (const target of targets) {
|
|
413
|
+
if (!NAPI_TARGET_CONVENTIONS[target]) {
|
|
414
|
+
throw new Error(`${packageJsonPath}: unsupported inferred napi target ${target}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
const cargoPackage = `${binaryName}-napi`;
|
|
418
|
+
const manifestPath = `crates/${cargoPackage}/Cargo.toml`;
|
|
419
|
+
if (!existsSync(join(absoluteProjectRoot, manifestPath))) {
|
|
420
|
+
throw new Error(`${packageJsonPath}: inferred N-API crate is missing at ${manifestPath}`);
|
|
421
|
+
}
|
|
422
|
+
return { binaryName, cargoPackage, manifestPath, targets };
|
|
423
|
+
}
|
|
424
|
+
function createNapiTargets(projectRoot, config) {
|
|
425
|
+
const commonCommand = `--manifest-path ${config.manifestPath} --package ${config.cargoPackage}`;
|
|
426
|
+
const targets = {
|
|
427
|
+
'cargo-napi': {
|
|
428
|
+
executor: 'nx:run-commands',
|
|
429
|
+
cache: true,
|
|
430
|
+
dependsOn: ['^build'],
|
|
431
|
+
inputs: NAPI_INPUTS,
|
|
432
|
+
outputs: ['{projectRoot}/dist/native/host'],
|
|
433
|
+
options: {
|
|
434
|
+
cwd: projectRoot,
|
|
435
|
+
command: `napi build --release --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir dist/native/host`,
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
for (const triple of config.targets) {
|
|
440
|
+
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
441
|
+
if (!convention) {
|
|
442
|
+
throw new Error(`Missing N-API target convention for ${triple}`);
|
|
443
|
+
}
|
|
444
|
+
const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
|
|
445
|
+
const outputDirectory = `dist/native/${convention.outputName}`;
|
|
446
|
+
const crossFlag = convention.useNapiCross ? ' --use-napi-cross' : '';
|
|
447
|
+
targets[targetName] = {
|
|
448
|
+
executor: 'nx:run-commands',
|
|
449
|
+
cache: true,
|
|
450
|
+
inputs: NAPI_INPUTS,
|
|
451
|
+
outputs: [`{projectRoot}/${outputDirectory}`],
|
|
452
|
+
options: {
|
|
453
|
+
cwd: projectRoot,
|
|
454
|
+
command: `napi build --release --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple}${crossFlag} ${commonCommand} --output-dir ${outputDirectory}`,
|
|
455
|
+
// @napi-rs recognizes Clang and supplies its downloaded GNU sysroot
|
|
456
|
+
// and toolchain flags. This keeps sccache enabled while avoiding the
|
|
457
|
+
// old bundled GCC, which rejects sccache's diagnostics-color flag.
|
|
458
|
+
...(convention.useNapiCross ? { env: { TARGET_CC: 'clang', TARGET_CXX: 'clang++' } } : {}),
|
|
459
|
+
},
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
return targets;
|
|
463
|
+
}
|
|
464
|
+
function createNapiTestTarget(projectRoot, hasDedicatedBunfig) {
|
|
465
|
+
const configFlag = hasDedicatedBunfig ? ' --config=bunfig.napi-test.toml' : '';
|
|
466
|
+
return {
|
|
467
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
468
|
+
cache: true,
|
|
469
|
+
dependsOn: ['cargo-test', 'cargo-napi', 'tsc-js', '^build', 'build'],
|
|
470
|
+
options: {
|
|
471
|
+
command: `bun${configFlag} test --timeout=30000 src/native.test.ts`,
|
|
472
|
+
cwd: projectRoot,
|
|
473
|
+
timeoutMs: 120000,
|
|
474
|
+
killAfterMs: 10000,
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
}
|
|
229
478
|
async function readPackageJson(packageJsonPath) {
|
|
230
479
|
const parsed = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
|
|
231
480
|
if (!isRecord(parsed)) {
|
|
@@ -234,6 +483,7 @@ async function readPackageJson(packageJsonPath) {
|
|
|
234
483
|
const rawNx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
235
484
|
return {
|
|
236
485
|
...(typeof parsed.name === 'string' ? { name: parsed.name } : {}),
|
|
486
|
+
...(isRecord(parsed.napi) ? { napi: parsed.napi } : {}),
|
|
237
487
|
...(isRecord(parsed.scripts) ? { scripts: parsed.scripts } : {}),
|
|
238
488
|
...(rawNx
|
|
239
489
|
? {
|
|
@@ -3,10 +3,12 @@ import { type NxPolicyIssue } from './workspace-config-policy.js';
|
|
|
3
3
|
export { BUILD_OUTPUT_DEPENDENCIES, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
4
4
|
export type { NxPolicyIssue };
|
|
5
5
|
export interface ResolvedProjectTargets {
|
|
6
|
+
root?: string;
|
|
6
7
|
targets: ReadonlySet<string>;
|
|
7
8
|
buildDependsOn?: readonly string[];
|
|
8
9
|
targetDependencies?: ReadonlyMap<string, readonly string[]>;
|
|
9
10
|
targetExecutors?: ReadonlyMap<string, string>;
|
|
11
|
+
targetOptions?: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
10
12
|
targetScripts?: ReadonlyMap<string, string>;
|
|
11
13
|
}
|
|
12
14
|
export interface PackageTargetPolicyOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAChG,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAC,CAAC;CAC9F;AA0HD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAGhF;
|
|
1
|
+
{"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAChG,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACvE,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAC,CAAC;CAC9F;AA0HD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAGhF;AA6JD,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,MAAM,CAMR;AAynBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAoBlH;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA4B1G;AAoJD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACpC,aAAa,EAAE,CAEjB;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAO,GACtD,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAmBhH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA6BxG"}
|
|
@@ -147,7 +147,11 @@ function isBuildOutputDependencyPattern(dependency) {
|
|
|
147
147
|
return BUILD_OUTPUT_DEPENDENCIES.some((pattern) => pattern === dependency);
|
|
148
148
|
}
|
|
149
149
|
function expectedTargetDependencies(targetName) {
|
|
150
|
-
|
|
150
|
+
if (targetName === 'preview')
|
|
151
|
+
return ['build'];
|
|
152
|
+
if (targetName.endsWith('-js'))
|
|
153
|
+
return ['^*-js'];
|
|
154
|
+
return ['^build'];
|
|
151
155
|
}
|
|
152
156
|
function applyTargetDependencyPolicy(target, targetName) {
|
|
153
157
|
return setStringArrayProperty(target, 'dependsOn', expectedTargetDependencies(targetName));
|
package/dist/version-actions.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const node_child_process_1 = require("node:child_process");
|
|
3
2
|
const node_fs_1 = require("node:fs");
|
|
4
3
|
const node_path_1 = require("node:path");
|
|
5
4
|
const nxJsVersionActions = require('@nx/js/src/release/version-actions');
|
|
@@ -12,11 +11,15 @@ const afterAllProjectsVersioned = async (cwd, options) => {
|
|
|
12
11
|
// - https://github.com/oven-sh/bun/issues/20477
|
|
13
12
|
// - https://github.com/oven-sh/bun/issues/20829
|
|
14
13
|
//
|
|
15
|
-
// After version
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
14
|
+
// After ANY version bump (release or prepare-next), bun.lock workspace versions
|
|
15
|
+
// must match package.json exactly — including unpublished -next. Day-to-day CI
|
|
16
|
+
// and frozen installs require that invariant.
|
|
17
|
+
//
|
|
18
|
+
// Publish-time pack rewrites (-next → last stable tag) happen only in
|
|
19
|
+
// `smoo release publish` around `bun pm pack`, never here. Doing publish-mode
|
|
20
|
+
// rewrite on prepare-next is what left lock at 0.x.y while package.json said
|
|
21
|
+
// 0.x.y-next.0 and blew up monorepo validate / packed-package-manifest.
|
|
22
|
+
const updated = syncBunLockfileVersionsToPackageJson(cwd);
|
|
20
23
|
if (updated === 0) {
|
|
21
24
|
return result;
|
|
22
25
|
}
|
|
@@ -26,7 +29,7 @@ const afterAllProjectsVersioned = async (cwd, options) => {
|
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
|
|
29
|
-
function
|
|
32
|
+
function syncBunLockfileVersionsToPackageJson(root) {
|
|
30
33
|
const lockfilePath = (0, node_path_1.join)(root, 'bun.lock');
|
|
31
34
|
if (!(0, node_fs_1.existsSync)(lockfilePath)) {
|
|
32
35
|
throw new Error('bun.lock not found');
|
|
@@ -35,7 +38,8 @@ function syncBunLockfileVersionsForPublish(root) {
|
|
|
35
38
|
let lockfile = (0, node_fs_1.readFileSync)(lockfilePath, 'utf8');
|
|
36
39
|
let updated = 0;
|
|
37
40
|
for (const pkg of packages) {
|
|
38
|
-
|
|
41
|
+
// Install/CI invariant: lockfile version ≡ package.json version (including -next).
|
|
42
|
+
const targetVersion = pkg.version;
|
|
39
43
|
const relativePath = pkg.path.replaceAll('\\', '/');
|
|
40
44
|
const escaped = escapeRegex(relativePath);
|
|
41
45
|
const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
|
|
@@ -50,8 +54,7 @@ function syncBunLockfileVersionsForPublish(root) {
|
|
|
50
54
|
continue;
|
|
51
55
|
}
|
|
52
56
|
lockfile = lockfile.replace(pattern, `$1${targetVersion}$3`);
|
|
53
|
-
|
|
54
|
-
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}${suffix}`);
|
|
57
|
+
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}`);
|
|
55
58
|
updated++;
|
|
56
59
|
}
|
|
57
60
|
if (updated > 0) {
|
|
@@ -60,35 +63,6 @@ function syncBunLockfileVersionsForPublish(root) {
|
|
|
60
63
|
console.log(updated > 0 ? `Updated ${updated} workspace version(s) in bun.lock` : 'All workspace versions already in sync.');
|
|
61
64
|
return updated;
|
|
62
65
|
}
|
|
63
|
-
function publishLockfileVersion(root, projectName, packageVersion) {
|
|
64
|
-
if (!packageVersion.includes('-')) {
|
|
65
|
-
return packageVersion;
|
|
66
|
-
}
|
|
67
|
-
return latestStableTagVersion(root, projectName) ?? packageVersion;
|
|
68
|
-
}
|
|
69
|
-
function latestStableTagVersion(root, projectName) {
|
|
70
|
-
try {
|
|
71
|
-
const output = (0, node_child_process_1.execSync)(`git tag --list '${projectName}@*' --sort=-v:refname`, {
|
|
72
|
-
cwd: root,
|
|
73
|
-
encoding: 'utf8',
|
|
74
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
75
|
-
});
|
|
76
|
-
const prefix = `${projectName}@`;
|
|
77
|
-
for (const line of output.split('\n')) {
|
|
78
|
-
const tag = line.trim();
|
|
79
|
-
if (!tag.startsWith(prefix))
|
|
80
|
-
continue;
|
|
81
|
-
const version = tag.slice(prefix.length);
|
|
82
|
-
if (version && !version.includes('-')) {
|
|
83
|
-
return version;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
66
|
function workspacePackages(root) {
|
|
93
67
|
const packagesRoot = (0, node_path_1.join)(root, 'packages');
|
|
94
68
|
return (0, node_fs_1.readdirSync)(packagesRoot, { withFileTypes: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5E,QAAA,MAAM,kBAAkB;+BALyC,yBAAyB;CAKf,CAAC;SAgCnE,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-config-policy.d.ts","sourceRoot":"","sources":["../src/workspace-config-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,yBAAyB,YACpC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,eAAO,MAAM,2BAA2B,YAAI,SAAS,EAAE,OAAO,CAAU,CAAC;AACzE,eAAO,MAAM,2BAA2B,YAAI,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,qBAAqB,0CAA4E,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace-config-policy.d.ts","sourceRoot":"","sources":["../src/workspace-config-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,yBAAyB,YACpC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,eAAO,MAAM,2BAA2B,YAAI,SAAS,EAAE,OAAO,CAAU,CAAC;AACzE,eAAO,MAAM,2BAA2B,YAAI,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,qBAAqB,0CAA4E,CAAC;AAgB/G;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAuDrF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAa7E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAKpE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAYxE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWhE"}
|
|
@@ -19,6 +19,7 @@ const nxJsTypescriptPlugin = '@nx/js/typescript';
|
|
|
19
19
|
const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
|
|
20
20
|
const cleanOutputsExecutor = '@smoothbricks/nx-plugin:clean-outputs';
|
|
21
21
|
const expectedSharedGlobalsNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
|
|
22
|
+
const inferredTestTypecheckTarget = 'typecheck-tests';
|
|
22
23
|
const defaultProductionNamedInput = [
|
|
23
24
|
'{projectRoot}/src/**/*',
|
|
24
25
|
'{projectRoot}/package.json',
|
|
@@ -43,6 +44,13 @@ export function checkWorkspaceConfig(nxJson) {
|
|
|
43
44
|
'Nx CLI syntax already uses project:target:configuration, so smoo Nx target names must be unambiguous tool-output names.',
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
if (targetName === inferredTestTypecheckTarget) {
|
|
48
|
+
issues.push({
|
|
49
|
+
path: 'nx.json',
|
|
50
|
+
message: `targetDefaults.${inferredTestTypecheckTarget} must not be configured. ` +
|
|
51
|
+
'Per-project inference selects current library or build outputs before test typechecking.',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
// Build target default
|
|
@@ -74,7 +82,7 @@ export function checkWorkspaceConfig(nxJson) {
|
|
|
74
82
|
* Mutates in place, returns whether anything changed.
|
|
75
83
|
*/
|
|
76
84
|
export function applyWorkspaceConfig(nxJson) {
|
|
77
|
-
let changed =
|
|
85
|
+
let changed = removeDisallowedTargetDefaults(nxJson);
|
|
78
86
|
changed = applyBuildTargetDefault(nxJson) || changed;
|
|
79
87
|
changed = applyCleanTargetDefault(nxJson) || changed;
|
|
80
88
|
changed = applyNamedInputDefaults(nxJson) || changed;
|
|
@@ -228,14 +236,14 @@ function applyNamedInputDefaults(nxJson) {
|
|
|
228
236
|
}
|
|
229
237
|
return changed;
|
|
230
238
|
}
|
|
231
|
-
function
|
|
239
|
+
function removeDisallowedTargetDefaults(nxJson) {
|
|
232
240
|
const targetDefaults = recordProperty(nxJson, 'targetDefaults');
|
|
233
241
|
if (!targetDefaults) {
|
|
234
242
|
return false;
|
|
235
243
|
}
|
|
236
244
|
let changed = false;
|
|
237
245
|
for (const targetName of Object.keys(targetDefaults)) {
|
|
238
|
-
if (targetName.includes(':')) {
|
|
246
|
+
if (targetName.includes(':') || targetName === inferredTestTypecheckTarget) {
|
|
239
247
|
delete targetDefaults[targetName];
|
|
240
248
|
changed = true;
|
|
241
249
|
}
|
package/executors.json
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
"schema": "./src/executors/bounded-exec/schema.json",
|
|
6
6
|
"description": "Run a command with bounded timeout and force-kill behavior"
|
|
7
7
|
},
|
|
8
|
+
"typescript-emit": {
|
|
9
|
+
"implementation": "./dist/executors/typescript-emit/executor.js",
|
|
10
|
+
"schema": "./src/executors/typescript-emit/schema.json",
|
|
11
|
+
"description": "Emit transformed JavaScript with ttsc and declarations with native tsc"
|
|
12
|
+
},
|
|
8
13
|
"clean-outputs": {
|
|
9
14
|
"implementation": "./dist/executors/clean-outputs/executor.js",
|
|
10
15
|
"schema": "./src/executors/clean-outputs/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -92,8 +92,9 @@
|
|
|
92
92
|
"directory": "packages/nx-plugin"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@nx/js": "23.1.
|
|
96
|
-
"nx": "23.1.
|
|
95
|
+
"@nx/js": "23.1.1",
|
|
96
|
+
"nx": "23.1.1",
|
|
97
|
+
"smol-toml": "^1.6.1",
|
|
97
98
|
"tslib": "^2.8.1"
|
|
98
99
|
}
|
|
99
100
|
}
|