@smoothbricks/nx-plugin 0.4.7 → 0.4.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAKL,yBAAyB,EAW1B,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAmDrC,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAoGD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+KD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAKL,yBAAyB,EAW1B,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAmDrC,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAwHD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+KD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
package/dist/index.js CHANGED
@@ -116,7 +116,14 @@ const CARGO_INPUTS = [
116
116
  '{projectRoot}/scripts/*.sh',
117
117
  '!{projectRoot}/**/target/**',
118
118
  ];
119
- const CARGO_OUTPUT_INPUTS = [...CARGO_INPUTS, '{projectRoot}/package.json', '{workspaceRoot}/bun.lock'];
119
+ // A Cargo output is a function of Rust sources and the toolchain, not of the
120
+ // npm package that ships it. `{projectRoot}/package.json` and the lockfile
121
+ // used to be inputs here, and a release bumps exactly those two (the version
122
+ // step runs before the build), so every publish recompiled every native
123
+ // binary on every platform for a change to a version string. What the N-API
124
+ // build really reads is the package's `napi` block (binary name, targets) and
125
+ // the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
126
+ const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
120
127
  const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
121
128
  '{workspaceRoot}/**/*.rs',
122
129
  '{workspaceRoot}/**/Cargo.toml',
@@ -124,8 +131,6 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
124
131
  '{workspaceRoot}/**/.cargo/config.toml',
125
132
  '{workspaceRoot}/scripts/*.sh',
126
133
  '!{workspaceRoot}/**/target/**',
127
- '{projectRoot}/package.json',
128
- '{workspaceRoot}/bun.lock',
129
134
  ];
130
135
  const CARGO_ENVIRONMENT_INPUT = {
131
136
  runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
@@ -148,7 +153,22 @@ function targetCommandText(target) {
148
153
  ...(Array.isArray(commands) ? commands.filter((entry) => typeof entry === 'string') : []),
149
154
  ].join('\n');
150
155
  }
151
- const NAPI_INPUTS = CARGO_OUTPUT_INPUTS;
156
+ /**
157
+ * The N-API build's inputs beyond the Cargo sources: the package's `napi`
158
+ * block, which names the binary and the targets, and the napi CLI's resolved
159
+ * version from the lockfile. Neither the package version nor any other
160
+ * lockfile entry is part of the artifact.
161
+ */
162
+ function napiInputs(projectRoot, repoRooted) {
163
+ // Runtime inputs execute from the workspace root, so the manifest is named
164
+ // by its path from there whichever way the Cargo invocation is rooted.
165
+ const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
166
+ return [
167
+ ...(repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : CARGO_OUTPUT_INPUTS),
168
+ { runtime: `bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'` },
169
+ { externalDependencies: ['@napi-rs/cli'] },
170
+ ];
171
+ }
152
172
  const NAPI_TARGET_CONVENTIONS = {
153
173
  'aarch64-apple-darwin': {
154
174
  architecture: 'arm64',
@@ -1071,7 +1091,10 @@ function inferTypescriptOutputs(tsconfigPath, packageJsonPath) {
1071
1091
  const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
1072
1092
  const outDir = compilerOptions?.outDir;
1073
1093
  if (typeof outDir !== 'string' || outDir.length === 0) {
1074
- return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}', '{projectRoot}/dist/**/*.tsbuildinfo'];
1094
+ // No .tsbuildinfo here: the emit executor overlays incremental: false, so
1095
+ // tsc-js never writes one and a declared-but-absent output fails the
1096
+ // release-candidate output inspection.
1097
+ return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
1075
1098
  }
1076
1099
  const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
1077
1100
  if (normalized === '.' || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('/')) {
@@ -1121,7 +1144,7 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
1121
1144
  // that stale local artifacts can mask for months.
1122
1145
  const packageJsonPath = repoRooted ? posix.join(projectRoot, 'package.json') : 'package.json';
1123
1146
  const commonCommand = `--manifest-path ${config.manifestPath} --package ${config.cargoPackage} --package-json-path ${packageJsonPath}`;
1124
- const cargoInputs = repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : NAPI_INPUTS;
1147
+ const cargoInputs = napiInputs(projectRoot, repoRooted);
1125
1148
  const cargoCwd = repoRooted ? '.' : projectRoot;
1126
1149
  // A repository-root Cargo invocation runs outside the owning npm package, so
1127
1150
  // Nx's root-only PATH cannot resolve that package's napi CLI.
@@ -1,6 +1,14 @@
1
1
  import type { Tree } from 'nx/src/devkit-exports.js';
2
2
  import type { NxPolicyIssue } from './workspace-config-policy.js';
3
3
  export declare const SMOO_NX_VERSION_ACTIONS = "@smoothbricks/nx-plugin/version-actions";
4
+ /**
5
+ * The same module as a workspace path. Nx resolves `versionActions` with
6
+ * `require.resolve` from its own location and falls back to workspaceRoot +
7
+ * path; under bun's global virtual store Nx lives outside the workspace, so
8
+ * only the path form resolves there. Derived from this package's own
9
+ * `./version-actions` export, never retyped.
10
+ */
11
+ export declare const SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH: string;
4
12
  export declare const SMOO_NX_RELEASE_TAG_PATTERN = "{projectName}@{version}";
5
13
  /**
6
14
  * Check release config policy on an in-memory nx.json object.
@@ -1 +1 @@
1
- {"version":3,"file":"release-config-policy.d.ts","sourceRoot":"","sources":["../src/release-config-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AACjF,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAErE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAuFnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAuC3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAKlE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAYtE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAW9D"}
1
+ {"version":3,"file":"release-config-policy.d.ts","sourceRoot":"","sources":["../src/release-config-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AACjF;;;;;;GAMG;AACH,eAAO,MAAM,sCAAsC,QAAgC,CAAC;AACpF,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAoBrE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAuFnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAyC3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAKlE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAYtE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAW9D"}
@@ -1,8 +1,33 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { readJson, updateJson } from 'nx/src/devkit-exports.js';
4
5
  export const SMOO_NX_VERSION_ACTIONS = '@smoothbricks/nx-plugin/version-actions';
6
+ /**
7
+ * The same module as a workspace path. Nx resolves `versionActions` with
8
+ * `require.resolve` from its own location and falls back to workspaceRoot +
9
+ * path; under bun's global virtual store Nx lives outside the workspace, so
10
+ * only the path form resolves there. Derived from this package's own
11
+ * `./version-actions` export, never retyped.
12
+ */
13
+ export const SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH = versionActionsWorkspacePath();
5
14
  export const SMOO_NX_RELEASE_TAG_PATTERN = '{projectName}@{version}';
15
+ function versionActionsWorkspacePath() {
16
+ // src/ and dist/ both sit one level below the package root.
17
+ const packageJson = readJsonObject(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'));
18
+ const name = packageJson && stringProperty(packageJson, 'name');
19
+ const exports = packageJson && recordProperty(packageJson, 'exports');
20
+ const entry = exports && recordProperty(exports, './version-actions');
21
+ const target = entry && stringProperty(entry, 'require');
22
+ if (!name || !target) {
23
+ // invariant throw: this package's own manifest is malformed
24
+ throw new Error('@smoothbricks/nx-plugin: package.json lacks the ./version-actions require export');
25
+ }
26
+ return `node_modules/${name}/${target.replace(/^\.\//, '')}`;
27
+ }
28
+ function isVersionActions(value) {
29
+ return value === SMOO_NX_VERSION_ACTIONS || value === SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH;
30
+ }
6
31
  /**
7
32
  * Check release config policy on an in-memory nx.json object.
8
33
  */
@@ -29,10 +54,10 @@ export function checkReleaseConfig(nxJson) {
29
54
  if (version && stringProperty(version, 'fallbackCurrentVersionResolver') !== 'disk') {
30
55
  issues.push({ path: 'nx.json', message: 'release.version.fallbackCurrentVersionResolver must be disk' });
31
56
  }
32
- if (version && stringProperty(version, 'versionActions') !== SMOO_NX_VERSION_ACTIONS) {
57
+ if (version && !isVersionActions(stringProperty(version, 'versionActions'))) {
33
58
  issues.push({
34
59
  path: 'nx.json',
35
- message: `release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS}`,
60
+ message: `release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS} or ${SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH}`,
36
61
  });
37
62
  }
38
63
  if (version && stringProperty(version, 'preVersionCommand')) {
@@ -98,7 +123,9 @@ export function applyReleaseConfig(nxJson) {
98
123
  changed = setStringProperty(version, 'specifierSource', 'conventional-commits') || changed;
99
124
  changed = setStringProperty(version, 'currentVersionResolver', 'git-tag') || changed;
100
125
  changed = setStringProperty(version, 'fallbackCurrentVersionResolver', 'disk') || changed;
101
- changed = setStringProperty(version, 'versionActions', SMOO_NX_VERSION_ACTIONS) || changed;
126
+ if (!isVersionActions(stringProperty(version, 'versionActions'))) {
127
+ changed = setStringProperty(version, 'versionActions', SMOO_NX_VERSION_ACTIONS) || changed;
128
+ }
102
129
  if ('preVersionCommand' in version) {
103
130
  delete version.preVersionCommand;
104
131
  changed = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -108,7 +108,7 @@
108
108
  "typia": "14.0.2"
109
109
  },
110
110
  "devDependencies": {
111
- "@smoothbricks/lmao": "0.3.10",
111
+ "@smoothbricks/lmao": "0.3.11",
112
112
  "@smoothbricks/validation": "0.1.8"
113
113
  }
114
114
  }
package/src/index.test.ts CHANGED
@@ -198,10 +198,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
198
198
  ...toolchainInputs,
199
199
  '{projectRoot}/tsconfig.lib.json',
200
200
  ]);
201
- expect(targets['tsc-js']?.outputs).toEqual([
202
- '{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}',
203
- '{projectRoot}/dist/**/*.tsbuildinfo',
204
- ]);
201
+ expect(targets['tsc-js']?.outputs).toEqual(['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}']);
205
202
  expect(targets.typecheck?.options).toMatchObject({
206
203
  command: 'tsc -p tsconfig.lib.json --noEmit',
207
204
  cwd: 'packages/example',
@@ -692,6 +689,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
692
689
  // its tests load the artifact `napi-debug` writes into `target/debug`.
693
690
  expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, rootArchive, 'napi-debug']);
694
691
  expect(native['napi-debug']?.dependsOn).toContainEqual(rootCompile);
692
+ // The addon depends on the package's napi block and the napi CLI's version,
693
+ // never on the package version or the whole lockfile: a release bumps both
694
+ // before it builds, and that must not recompile the native code.
695
+ const napiInputs = native['napi-debug']?.inputs ?? [];
696
+ expect(napiInputs).toContainEqual({ externalDependencies: ['@napi-rs/cli'] });
697
+ expect(
698
+ napiInputs.some((input) => typeof input === 'object' && 'runtime' in input && input.runtime.includes('.napi')),
699
+ ).toBe(true);
700
+ expect(napiInputs).not.toContain('{workspaceRoot}/bun.lock');
701
+ expect(napiInputs.some((input) => typeof input === 'string' && input.endsWith('/package.json'))).toBe(false);
695
702
  expect(native['napi-debug']?.options).toMatchObject({
696
703
  cwd: '.',
697
704
  command:
@@ -891,16 +898,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
891
898
 
892
899
  const targets = await inferProjectTargets(workspace, 'packages/git-do/package.json');
893
900
 
901
+ // A release bumps package.json and the lockfile before it builds; neither
902
+ // is part of a wasm artifact, so neither may be an input.
903
+ expect(targets['cargo-wasm']?.inputs).not.toContain('{projectRoot}/package.json');
904
+ expect(targets['cargo-wasm']?.inputs).not.toContain('{workspaceRoot}/bun.lock');
894
905
  expect(targets['cargo-wasm']).toMatchObject({
895
906
  executor: 'nx:run-commands',
896
907
  cache: true,
897
908
  dependsOn: ['cargo-fetch', '^build'],
898
- inputs: expect.arrayContaining([
899
- '{projectRoot}/**/*.rs',
900
- '{projectRoot}/**/Cargo.toml',
901
- '{projectRoot}/package.json',
902
- '{workspaceRoot}/bun.lock',
903
- ]),
909
+ inputs: expect.arrayContaining(['{projectRoot}/**/*.rs', '{projectRoot}/**/Cargo.toml']),
904
910
  outputs: ['{projectRoot}/generated/wasm'],
905
911
  options: {
906
912
  commands: [
package/src/index.ts CHANGED
@@ -163,7 +163,14 @@ const CARGO_INPUTS = [
163
163
  '{projectRoot}/scripts/*.sh',
164
164
  '!{projectRoot}/**/target/**',
165
165
  ];
166
- const CARGO_OUTPUT_INPUTS = [...CARGO_INPUTS, '{projectRoot}/package.json', '{workspaceRoot}/bun.lock'];
166
+ // A Cargo output is a function of Rust sources and the toolchain, not of the
167
+ // npm package that ships it. `{projectRoot}/package.json` and the lockfile
168
+ // used to be inputs here, and a release bumps exactly those two (the version
169
+ // step runs before the build), so every publish recompiled every native
170
+ // binary on every platform for a change to a version string. What the N-API
171
+ // build really reads is the package's `napi` block (binary name, targets) and
172
+ // the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
173
+ const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
167
174
  const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
168
175
  '{workspaceRoot}/**/*.rs',
169
176
  '{workspaceRoot}/**/Cargo.toml',
@@ -171,8 +178,6 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
171
178
  '{workspaceRoot}/**/.cargo/config.toml',
172
179
  '{workspaceRoot}/scripts/*.sh',
173
180
  '!{workspaceRoot}/**/target/**',
174
- '{projectRoot}/package.json',
175
- '{workspaceRoot}/bun.lock',
176
181
  ];
177
182
  const CARGO_ENVIRONMENT_INPUT = {
178
183
  runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
@@ -197,7 +202,22 @@ function targetCommandText(target: TargetConfiguration): string {
197
202
  ...(Array.isArray(commands) ? commands.filter((entry) => typeof entry === 'string') : []),
198
203
  ].join('\n');
199
204
  }
200
- const NAPI_INPUTS = CARGO_OUTPUT_INPUTS;
205
+ /**
206
+ * The N-API build's inputs beyond the Cargo sources: the package's `napi`
207
+ * block, which names the binary and the targets, and the napi CLI's resolved
208
+ * version from the lockfile. Neither the package version nor any other
209
+ * lockfile entry is part of the artifact.
210
+ */
211
+ function napiInputs(projectRoot: string, repoRooted: boolean): TargetConfiguration['inputs'] {
212
+ // Runtime inputs execute from the workspace root, so the manifest is named
213
+ // by its path from there whichever way the Cargo invocation is rooted.
214
+ const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
215
+ return [
216
+ ...(repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : CARGO_OUTPUT_INPUTS),
217
+ { runtime: `bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'` },
218
+ { externalDependencies: ['@napi-rs/cli'] },
219
+ ];
220
+ }
201
221
 
202
222
  interface NapiTargetConvention extends NapiPlatform {
203
223
  outputName: string;
@@ -1282,7 +1302,10 @@ function inferTypescriptOutputs(tsconfigPath: string, packageJsonPath: string):
1282
1302
  const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
1283
1303
  const outDir = compilerOptions?.outDir;
1284
1304
  if (typeof outDir !== 'string' || outDir.length === 0) {
1285
- return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}', '{projectRoot}/dist/**/*.tsbuildinfo'];
1305
+ // No .tsbuildinfo here: the emit executor overlays incremental: false, so
1306
+ // tsc-js never writes one and a declared-but-absent output fails the
1307
+ // release-candidate output inspection.
1308
+ return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
1286
1309
  }
1287
1310
 
1288
1311
  const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
@@ -1350,7 +1373,7 @@ function createNapiTargets(
1350
1373
  // that stale local artifacts can mask for months.
1351
1374
  const packageJsonPath = repoRooted ? posix.join(projectRoot, 'package.json') : 'package.json';
1352
1375
  const commonCommand = `--manifest-path ${config.manifestPath} --package ${config.cargoPackage} --package-json-path ${packageJsonPath}`;
1353
- const cargoInputs = repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : NAPI_INPUTS;
1376
+ const cargoInputs = napiInputs(projectRoot, repoRooted);
1354
1377
  const cargoCwd = repoRooted ? '.' : projectRoot;
1355
1378
  // A repository-root Cargo invocation runs outside the owning npm package, so
1356
1379
  // Nx's root-only PATH cannot resolve that package's napi CLI.
@@ -15,6 +15,7 @@ import {
15
15
  checkReleaseConfigTree,
16
16
  SMOO_NX_RELEASE_TAG_PATTERN,
17
17
  SMOO_NX_VERSION_ACTIONS,
18
+ SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH,
18
19
  } from './release-config-policy.js';
19
20
 
20
21
  // ---------------------------------------------------------------------------
@@ -100,7 +101,9 @@ describe('pure core: checkReleaseConfig', () => {
100
101
  expect(messages).toContainEqual('release.version.specifierSource must be conventional-commits');
101
102
  expect(messages).toContainEqual('release.version.currentVersionResolver must be git-tag');
102
103
  expect(messages).toContainEqual('release.version.fallbackCurrentVersionResolver must be disk');
103
- expect(messages).toContainEqual(`release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS}`);
104
+ expect(messages).toContainEqual(
105
+ `release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS} or ${SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH}`,
106
+ );
104
107
  expect(messages).toContainEqual(
105
108
  'release.version.preVersionCommand must not be defined; smoo builds npm-missing packages before publish',
106
109
  );
@@ -110,6 +113,20 @@ describe('pure core: checkReleaseConfig', () => {
110
113
  expect(messages).toContainEqual('release.changelog.projectChangelogs.createRelease must be false');
111
114
  expect(messages).toContainEqual('release.changelog.projectChangelogs.file must be false');
112
115
  });
116
+
117
+ it('accepts the workspace path to the same version-actions module and leaves it alone', () => {
118
+ // Under bun's global virtual store Nx resolves versionActions only as
119
+ // workspaceRoot + path; the path is the plugin's own export target.
120
+ expect(SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH).toBe(
121
+ 'node_modules/@smoothbricks/nx-plugin/dist/version-actions.cjs',
122
+ );
123
+ const nxJson = validReleaseNxJson();
124
+ const version = expectRecord(expectRecord(nxJson.release).version);
125
+ version.versionActions = SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH;
126
+ expect(checkReleaseConfig(nxJson)).toEqual([]);
127
+ expect(applyReleaseConfig(nxJson)).toBe(false);
128
+ expect(version.versionActions).toBe(SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH);
129
+ });
113
130
  });
114
131
 
115
132
  describe('pure core: applyReleaseConfig', () => {
@@ -1,13 +1,40 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import type { Tree } from 'nx/src/devkit-exports.js';
4
5
  import { readJson, updateJson } from 'nx/src/devkit-exports.js';
5
6
 
6
7
  import type { NxPolicyIssue } from './workspace-config-policy.js';
7
8
 
8
9
  export const SMOO_NX_VERSION_ACTIONS = '@smoothbricks/nx-plugin/version-actions';
10
+ /**
11
+ * The same module as a workspace path. Nx resolves `versionActions` with
12
+ * `require.resolve` from its own location and falls back to workspaceRoot +
13
+ * path; under bun's global virtual store Nx lives outside the workspace, so
14
+ * only the path form resolves there. Derived from this package's own
15
+ * `./version-actions` export, never retyped.
16
+ */
17
+ export const SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH = versionActionsWorkspacePath();
9
18
  export const SMOO_NX_RELEASE_TAG_PATTERN = '{projectName}@{version}';
10
19
 
20
+ function versionActionsWorkspacePath(): string {
21
+ // src/ and dist/ both sit one level below the package root.
22
+ const packageJson = readJsonObject(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'));
23
+ const name = packageJson && stringProperty(packageJson, 'name');
24
+ const exports = packageJson && recordProperty(packageJson, 'exports');
25
+ const entry = exports && recordProperty(exports, './version-actions');
26
+ const target = entry && stringProperty(entry, 'require');
27
+ if (!name || !target) {
28
+ // invariant throw: this package's own manifest is malformed
29
+ throw new Error('@smoothbricks/nx-plugin: package.json lacks the ./version-actions require export');
30
+ }
31
+ return `node_modules/${name}/${target.replace(/^\.\//, '')}`;
32
+ }
33
+
34
+ function isVersionActions(value: string | null): boolean {
35
+ return value === SMOO_NX_VERSION_ACTIONS || value === SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH;
36
+ }
37
+
11
38
  /**
12
39
  * Check release config policy on an in-memory nx.json object.
13
40
  */
@@ -37,10 +64,10 @@ export function checkReleaseConfig(nxJson: Record<string, unknown>): NxPolicyIss
37
64
  if (version && stringProperty(version, 'fallbackCurrentVersionResolver') !== 'disk') {
38
65
  issues.push({ path: 'nx.json', message: 'release.version.fallbackCurrentVersionResolver must be disk' });
39
66
  }
40
- if (version && stringProperty(version, 'versionActions') !== SMOO_NX_VERSION_ACTIONS) {
67
+ if (version && !isVersionActions(stringProperty(version, 'versionActions'))) {
41
68
  issues.push({
42
69
  path: 'nx.json',
43
- message: `release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS}`,
70
+ message: `release.version.versionActions must be ${SMOO_NX_VERSION_ACTIONS} or ${SMOO_NX_VERSION_ACTIONS_WORKSPACE_PATH}`,
44
71
  });
45
72
  }
46
73
  if (version && stringProperty(version, 'preVersionCommand')) {
@@ -114,7 +141,9 @@ export function applyReleaseConfig(nxJson: Record<string, unknown>): boolean {
114
141
  changed = setStringProperty(version, 'specifierSource', 'conventional-commits') || changed;
115
142
  changed = setStringProperty(version, 'currentVersionResolver', 'git-tag') || changed;
116
143
  changed = setStringProperty(version, 'fallbackCurrentVersionResolver', 'disk') || changed;
117
- changed = setStringProperty(version, 'versionActions', SMOO_NX_VERSION_ACTIONS) || changed;
144
+ if (!isVersionActions(stringProperty(version, 'versionActions'))) {
145
+ changed = setStringProperty(version, 'versionActions', SMOO_NX_VERSION_ACTIONS) || changed;
146
+ }
118
147
 
119
148
  if ('preVersionCommand' in version) {
120
149
  delete version.preVersionCommand;