@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/src/index.test.ts
CHANGED
|
@@ -58,7 +58,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it('
|
|
61
|
+
it('splits transformed JavaScript emit from native declarations and typechecking', async () => {
|
|
62
62
|
const workspace = await createWorkspace();
|
|
63
63
|
try {
|
|
64
64
|
await workspace.write(
|
|
@@ -70,8 +70,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
70
70
|
|
|
71
71
|
const targets = await inferProjectTargets(workspace, 'packages/example/package.json');
|
|
72
72
|
|
|
73
|
-
expect(targets['tsc-js']?.
|
|
74
|
-
|
|
73
|
+
expect(targets['tsc-js']?.executor).toBe('@smoothbricks/nx-plugin:typescript-emit');
|
|
74
|
+
expect(targets['tsc-js']?.options).toEqual({
|
|
75
|
+
tsConfig: 'tsconfig.lib.json',
|
|
75
76
|
cwd: 'packages/example',
|
|
76
77
|
});
|
|
77
78
|
const toolchainInputs = [
|
|
@@ -86,9 +87,12 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
86
87
|
...toolchainInputs,
|
|
87
88
|
'{projectRoot}/tsconfig.lib.json',
|
|
88
89
|
]);
|
|
89
|
-
expect(targets['tsc-js']?.outputs).toEqual([
|
|
90
|
+
expect(targets['tsc-js']?.outputs).toEqual([
|
|
91
|
+
'{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}',
|
|
92
|
+
'{projectRoot}/dist/**/*.tsbuildinfo',
|
|
93
|
+
]);
|
|
90
94
|
expect(targets.typecheck?.options).toMatchObject({
|
|
91
|
-
command: '
|
|
95
|
+
command: 'tsc -p tsconfig.lib.json --noEmit',
|
|
92
96
|
cwd: 'packages/example',
|
|
93
97
|
});
|
|
94
98
|
expect(targets.typecheck?.inputs).toEqual([
|
|
@@ -105,9 +109,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
105
109
|
|
|
106
110
|
expect(targets['typecheck-tests']?.executor).toBe('nx:run-commands');
|
|
107
111
|
expect(targets['typecheck-tests']?.cache).toBe(true);
|
|
108
|
-
expect(targets['typecheck-tests']?.dependsOn).toEqual(['typecheck']);
|
|
112
|
+
expect(targets['typecheck-tests']?.dependsOn).toEqual(['tsc-js', 'typecheck']);
|
|
109
113
|
expect(targets['typecheck-tests']?.options).toMatchObject({
|
|
110
|
-
command: '
|
|
114
|
+
command: 'tsc -p tsconfig.test.json --noEmit',
|
|
111
115
|
cwd: 'packages/example',
|
|
112
116
|
});
|
|
113
117
|
expect(targets['typecheck-tests']?.inputs).toEqual([
|
|
@@ -120,7 +124,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
120
124
|
expect(targets['typecheck-tests:watch']?.executor).toBe('nx:run-commands');
|
|
121
125
|
expect(targets['typecheck-tests:watch']?.continuous).toBe(true);
|
|
122
126
|
expect(targets['typecheck-tests:watch']?.options).toMatchObject({
|
|
123
|
-
command: '
|
|
127
|
+
command: 'tsc -p tsconfig.test.json --noEmit --watch',
|
|
124
128
|
cwd: 'packages/example',
|
|
125
129
|
});
|
|
126
130
|
|
|
@@ -140,6 +144,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
140
144
|
}
|
|
141
145
|
});
|
|
142
146
|
|
|
147
|
+
it('rebuilds current library declarations before test typechecking after clean', async () => {
|
|
148
|
+
const workspace = await createWorkspace();
|
|
149
|
+
try {
|
|
150
|
+
await workspace.write('packages/example/package.json', '{"name":"example"}\n');
|
|
151
|
+
await workspace.write('packages/example/tsconfig.lib.json', '{}\n');
|
|
152
|
+
await workspace.write('packages/example/tsconfig.test.json', '{}\n');
|
|
153
|
+
|
|
154
|
+
const targets = await inferProjectTargets(workspace, 'packages/example/package.json');
|
|
155
|
+
|
|
156
|
+
expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
157
|
+
expect(targets['typecheck-tests']?.dependsOn).toEqual(['tsc-js', 'typecheck']);
|
|
158
|
+
} finally {
|
|
159
|
+
await workspace.cleanup();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
143
163
|
it('infers vitest watch targets from explicit test commands', async () => {
|
|
144
164
|
const workspace = await createWorkspace();
|
|
145
165
|
try {
|
|
@@ -238,9 +258,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
238
258
|
expect(targets['cargo-test']?.inputs).toEqual([
|
|
239
259
|
'{projectRoot}/**/*.rs',
|
|
240
260
|
'{projectRoot}/**/Cargo.toml',
|
|
241
|
-
'{projectRoot}
|
|
242
|
-
'{projectRoot}
|
|
243
|
-
'!{projectRoot}
|
|
261
|
+
'{projectRoot}/**/Cargo.lock',
|
|
262
|
+
'{projectRoot}/**/.cargo/config.toml',
|
|
263
|
+
'!{projectRoot}/**/target/**',
|
|
244
264
|
]);
|
|
245
265
|
expect(targets['cargo-lint']?.options).toMatchObject({
|
|
246
266
|
commands: ['cargo fmt --all --check', 'cargo clippy --workspace --all-targets -- -D warnings'],
|
|
@@ -259,22 +279,142 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
259
279
|
}
|
|
260
280
|
});
|
|
261
281
|
|
|
262
|
-
it('
|
|
282
|
+
it('infers a cached Cargo Wasm build directly from crate metadata', async () => {
|
|
283
|
+
const workspace = await createWorkspace();
|
|
284
|
+
try {
|
|
285
|
+
await workspace.write('packages/git-do/package.json', '{"name":"git-do"}\n');
|
|
286
|
+
await workspace.write(
|
|
287
|
+
'packages/git-do/crates/git-do/Cargo.toml',
|
|
288
|
+
[
|
|
289
|
+
'[package]',
|
|
290
|
+
'name = "git-do"',
|
|
291
|
+
'',
|
|
292
|
+
'[lib]',
|
|
293
|
+
'name = "gitoxide_engine"',
|
|
294
|
+
'crate-type = ["cdylib", "rlib"]',
|
|
295
|
+
'',
|
|
296
|
+
'[package.metadata.smoothbricks.wasm-bindgen]',
|
|
297
|
+
'targets = ["nodejs", "web"]',
|
|
298
|
+
'out-dir = "generated/wasm"',
|
|
299
|
+
'',
|
|
300
|
+
].join('\n'),
|
|
301
|
+
);
|
|
302
|
+
await workspace.write('packages/git-do/tsconfig.lib.json', '{"compilerOptions":{"outDir":"dist"}}\n');
|
|
303
|
+
|
|
304
|
+
const targets = await inferProjectTargets(workspace, 'packages/git-do/package.json');
|
|
305
|
+
|
|
306
|
+
expect(targets['cargo-wasm']).toMatchObject({
|
|
307
|
+
executor: 'nx:run-commands',
|
|
308
|
+
cache: true,
|
|
309
|
+
dependsOn: ['^build'],
|
|
310
|
+
inputs: [
|
|
311
|
+
'{projectRoot}/**/*.rs',
|
|
312
|
+
'{projectRoot}/**/Cargo.toml',
|
|
313
|
+
'{projectRoot}/**/Cargo.lock',
|
|
314
|
+
'{projectRoot}/**/.cargo/config.toml',
|
|
315
|
+
'!{projectRoot}/**/target/**',
|
|
316
|
+
'{projectRoot}/package.json',
|
|
317
|
+
'{workspaceRoot}/bun.lock',
|
|
318
|
+
],
|
|
319
|
+
outputs: ['{projectRoot}/generated/wasm'],
|
|
320
|
+
options: {
|
|
321
|
+
commands: [
|
|
322
|
+
'cargo build --release --target wasm32-unknown-unknown --target-dir crates/git-do/target/cargo-wasm --manifest-path crates/git-do/Cargo.toml',
|
|
323
|
+
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/cargo-wasm/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
324
|
+
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/cargo-wasm/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
325
|
+
],
|
|
326
|
+
cwd: 'packages/git-do',
|
|
327
|
+
parallel: false,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
expect(targets['tsc-js']?.dependsOn).toEqual(['^*-js', 'cargo-wasm']);
|
|
331
|
+
expect(targets.typecheck?.dependsOn).toEqual(['^*-js', 'cargo-wasm']);
|
|
332
|
+
expect(targets.build?.dependsOn).toEqual(buildOutputDependencies);
|
|
333
|
+
expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
334
|
+
// A nested crate manifest is enough for output inference, but not for
|
|
335
|
+
// workspace-wide cargo-test/lint policy.
|
|
336
|
+
expect(targets['cargo-test']).toBeUndefined();
|
|
337
|
+
expect(targets['cargo-lint']).toBeUndefined();
|
|
338
|
+
} finally {
|
|
339
|
+
await workspace.cleanup();
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('infers disjoint host and release targets from canonical N-API metadata', async () => {
|
|
263
344
|
const workspace = await createWorkspace();
|
|
264
345
|
try {
|
|
265
|
-
await workspace.write(
|
|
346
|
+
await workspace.write(
|
|
347
|
+
'packages/cowshed/package.json',
|
|
348
|
+
JSON.stringify({
|
|
349
|
+
name: 'cowshed',
|
|
350
|
+
scripts: { test: 'nx run cowshed:test --outputStyle=stream' },
|
|
351
|
+
napi: {
|
|
352
|
+
binaryName: 'cowshed',
|
|
353
|
+
targets: [
|
|
354
|
+
'aarch64-apple-darwin',
|
|
355
|
+
'x86_64-apple-darwin',
|
|
356
|
+
'aarch64-unknown-linux-gnu',
|
|
357
|
+
'x86_64-unknown-linux-gnu',
|
|
358
|
+
],
|
|
359
|
+
},
|
|
360
|
+
}),
|
|
361
|
+
);
|
|
266
362
|
await workspace.write('packages/cowshed/Cargo.toml', '[workspace]\nmembers = ["crates/cowshed-napi"]\n');
|
|
267
363
|
await workspace.write(
|
|
268
364
|
'packages/cowshed/crates/cowshed-napi/Cargo.toml',
|
|
269
365
|
'[package]\nname = "cowshed-napi"\n\n[lib]\ncrate-type = ["cdylib"]\n',
|
|
270
366
|
);
|
|
367
|
+
await workspace.write(
|
|
368
|
+
'packages/cowshed/tsconfig.lib.json',
|
|
369
|
+
'{"compilerOptions":{"outDir":"dist/ts","tsBuildInfoFile":"dist/ts/tsconfig.lib.tsbuildinfo"}}\n',
|
|
370
|
+
);
|
|
371
|
+
await workspace.write('packages/cowshed/src/native.test.ts', 'export {};\n');
|
|
271
372
|
|
|
272
373
|
const targets = await inferProjectTargets(workspace, 'packages/cowshed/package.json');
|
|
273
374
|
|
|
274
375
|
expect(targets['cargo-wasm']).toBeUndefined();
|
|
275
|
-
expect(targets
|
|
276
|
-
expect(targets
|
|
277
|
-
|
|
376
|
+
expect(targets['tsc-js']?.outputs).toEqual(['{projectRoot}/dist/ts']);
|
|
377
|
+
expect(targets['cargo-napi']).toMatchObject({
|
|
378
|
+
executor: 'nx:run-commands',
|
|
379
|
+
cache: true,
|
|
380
|
+
dependsOn: ['^build'],
|
|
381
|
+
outputs: ['{projectRoot}/dist/native/host'],
|
|
382
|
+
options: {
|
|
383
|
+
cwd: 'packages/cowshed',
|
|
384
|
+
command:
|
|
385
|
+
'napi build --release --platform --no-js --dts cowshed.napi.d.ts --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --output-dir dist/native/host',
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
expect(targets['napi-arm64-macos']?.outputs).toEqual(['{projectRoot}/dist/native/darwin-arm64']);
|
|
389
|
+
expect(targets['napi-arm64-macos']?.options).toMatchObject({
|
|
390
|
+
command:
|
|
391
|
+
'napi build --release --platform --no-js --dts cowshed.darwin-arm64.d.ts --target aarch64-apple-darwin --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --output-dir dist/native/darwin-arm64',
|
|
392
|
+
});
|
|
393
|
+
expect(targets['napi-arm64-macos']?.options?.env).toBeUndefined();
|
|
394
|
+
expect(targets['napi-x64-linux']?.outputs).toEqual(['{projectRoot}/dist/native/linux-x64-gnu']);
|
|
395
|
+
expect(targets['napi-x64-linux']?.options).toMatchObject({
|
|
396
|
+
command:
|
|
397
|
+
'napi build --release --platform --no-js --dts cowshed.linux-x64-gnu.d.ts --target x86_64-unknown-linux-gnu --use-napi-cross --manifest-path crates/cowshed-napi/Cargo.toml --package cowshed-napi --output-dir dist/native/linux-x64-gnu',
|
|
398
|
+
env: { TARGET_CC: 'clang', TARGET_CXX: 'clang++' },
|
|
399
|
+
});
|
|
400
|
+
expect(targets.build?.dependsOn).toEqual(buildOutputDependencies);
|
|
401
|
+
expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
402
|
+
expect(targets['napi-test']).toMatchObject({
|
|
403
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
404
|
+
cache: true,
|
|
405
|
+
dependsOn: ['cargo-test', 'cargo-napi', 'tsc-js', '^build', 'build'],
|
|
406
|
+
options: {
|
|
407
|
+
command: 'bun test --timeout=30000 src/native.test.ts',
|
|
408
|
+
cwd: 'packages/cowshed',
|
|
409
|
+
timeoutMs: 120000,
|
|
410
|
+
killAfterMs: 10000,
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
await workspace.write('packages/cowshed/bunfig.napi-test.toml', '[test]\n');
|
|
414
|
+
const targetsWithDedicatedBunfig = await inferProjectTargets(workspace, 'packages/cowshed/package.json');
|
|
415
|
+
expect(targetsWithDedicatedBunfig['napi-test']?.options?.command).toBe(
|
|
416
|
+
'bun --config=bunfig.napi-test.toml test --timeout=30000 src/native.test.ts',
|
|
417
|
+
);
|
|
278
418
|
} finally {
|
|
279
419
|
await workspace.cleanup();
|
|
280
420
|
}
|
|
@@ -300,7 +440,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
300
440
|
);
|
|
301
441
|
await workspace.write(
|
|
302
442
|
'packages/columine/crates/columine-wasm/Cargo.toml',
|
|
303
|
-
'[package]\nname = "columine-wasm"\n\n[lib]\ncrate-type = ["cdylib", "rlib"]\n',
|
|
443
|
+
'[package]\nname = "columine-wasm"\n\n[lib]\ncrate-type = ["cdylib", "rlib"]\n\n[package.metadata.smoothbricks.wasm-bindgen]\ntargets = ["web"]\n',
|
|
304
444
|
);
|
|
305
445
|
|
|
306
446
|
const targets = await inferProjectTargets(workspace, 'packages/columine/package.json');
|