@smoothbricks/nx-plugin 0.4.8 → 0.4.10

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;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"}
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;AA8HD,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
@@ -132,8 +132,14 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
132
132
  '{workspaceRoot}/scripts/*.sh',
133
133
  '!{workspaceRoot}/**/target/**',
134
134
  ];
135
+ // The environment half of a cargo task's identity. Beyond cargo/rustc's own
136
+ // variables, every build script that compiles C/C++ reads the Apple SDK
137
+ // (SDKROOT, DEVELOPER_DIR, the deployment targets), bindgen reads its libclang
138
+ // and extra clang args, cmake-rs forwards CMAKE_*, and zig-based cross links
139
+ // read ZIG*. An output linked against one sysroot must never hash equal to
140
+ // the same sources linked against another.
135
141
  const CARGO_ENVIRONMENT_INPUT = {
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; })}));'`,
142
+ 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_|SDKROOT$|DEVELOPER_DIR$|MACOSX_DEPLOYMENT_TARGET$|IPHONEOS_DEPLOYMENT_TARGET$|LIBCLANG_PATH$|BINDGEN_EXTRA_CLANG_ARGS|CMAKE_|ZIG)/.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; })}));'`,
137
143
  };
138
144
  function cargoRuntimeInput(projectRoot, command) {
139
145
  const quotedRoot = `'${projectRoot.replaceAll("'", "'\"'\"'")}'`;
@@ -1091,7 +1097,10 @@ function inferTypescriptOutputs(tsconfigPath, packageJsonPath) {
1091
1097
  const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
1092
1098
  const outDir = compilerOptions?.outDir;
1093
1099
  if (typeof outDir !== 'string' || outDir.length === 0) {
1094
- return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}', '{projectRoot}/dist/**/*.tsbuildinfo'];
1100
+ // No .tsbuildinfo here: the emit executor overlays incremental: false, so
1101
+ // tsc-js never writes one and a declared-but-absent output fails the
1102
+ // release-candidate output inspection.
1103
+ return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
1095
1104
  }
1096
1105
  const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
1097
1106
  if (normalized === '.' || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('/')) {
@@ -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;
@@ -1 +1 @@
1
- {"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAYjB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAoDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAO7F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAyDhE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAiEtE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAyD9D"}
1
+ {"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAYjB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAsDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAO7F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAyDhE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAiEtE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAyD9D"}
@@ -1,6 +1,5 @@
1
1
  import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
- import { isDeepStrictEqual } from 'node:util';
4
3
  import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
5
4
  const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
6
5
  /**
@@ -130,11 +129,15 @@ export function applyTypecheckTestDefaults(tsconfigTest, options) {
130
129
  const extendsValue = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
131
130
  let changed = setMissingStringProperty(tsconfigTest, 'extends', extendsValue);
132
131
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
133
- // Copy relevant compiler options from lib tsconfig
132
+ // Fill from the lib tsconfig only what the test program has NOT declared. A
133
+ // test program that names its own `lib` is stating a fact the lib program
134
+ // cannot know: it runs on one runtime (Bun's JSC understands
135
+ // change-array-by-copy) while the library's output has to run on the shipping
136
+ // floor. Overwriting it turned `toSorted` into a type error in a suite that
137
+ // calls it every day, and it came back on every `smoo monorepo update`.
134
138
  if (options.libCompilerOptions) {
135
139
  for (const key of ['baseUrl', 'module', 'moduleResolution', 'jsx', 'lib']) {
136
- if (Object.hasOwn(options.libCompilerOptions, key) &&
137
- !isDeepStrictEqual(compilerOptions[key], options.libCompilerOptions[key])) {
140
+ if (Object.hasOwn(options.libCompilerOptions, key) && !Object.hasOwn(compilerOptions, key)) {
138
141
  compilerOptions[key] = options.libCompilerOptions[key];
139
142
  changed = true;
140
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
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',
package/src/index.ts CHANGED
@@ -179,8 +179,14 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
179
179
  '{workspaceRoot}/scripts/*.sh',
180
180
  '!{workspaceRoot}/**/target/**',
181
181
  ];
182
+ // The environment half of a cargo task's identity. Beyond cargo/rustc's own
183
+ // variables, every build script that compiles C/C++ reads the Apple SDK
184
+ // (SDKROOT, DEVELOPER_DIR, the deployment targets), bindgen reads its libclang
185
+ // and extra clang args, cmake-rs forwards CMAKE_*, and zig-based cross links
186
+ // read ZIG*. An output linked against one sysroot must never hash equal to
187
+ // the same sources linked against another.
182
188
  const CARGO_ENVIRONMENT_INPUT = {
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; })}));'`,
189
+ 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_|SDKROOT$|DEVELOPER_DIR$|MACOSX_DEPLOYMENT_TARGET$|IPHONEOS_DEPLOYMENT_TARGET$|LIBCLANG_PATH$|BINDGEN_EXTRA_CLANG_ARGS|CMAKE_|ZIG)/.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; })}));'`,
184
190
  };
185
191
 
186
192
  function cargoRuntimeInput(projectRoot: string, command: string): { runtime: string } {
@@ -1302,7 +1308,10 @@ function inferTypescriptOutputs(tsconfigPath: string, packageJsonPath: string):
1302
1308
  const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
1303
1309
  const outDir = compilerOptions?.outDir;
1304
1310
  if (typeof outDir !== 'string' || outDir.length === 0) {
1305
- return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}', '{projectRoot}/dist/**/*.tsbuildinfo'];
1311
+ // No .tsbuildinfo here: the emit executor overlays incremental: false, so
1312
+ // tsc-js never writes one and a declared-but-absent output fails the
1313
+ // release-candidate output inspection.
1314
+ return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
1306
1315
  }
1307
1316
 
1308
1317
  const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
@@ -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;
@@ -199,6 +199,33 @@ describe('applyTypecheckTestDefaults', () => {
199
199
  expect(references).toContainEqual({ path: './tsconfig.lib.json' });
200
200
  });
201
201
 
202
+ it('fills compiler options the test program left out and keeps the ones it declared', () => {
203
+ // A Bun-only test program declaring es2023 says something the library cannot
204
+ // know: its runtime has change-array-by-copy while the library's output ships
205
+ // to node, workerd and browsers. Overwriting it made `toSorted` a type error
206
+ // in a suite that calls it, and every `smoo monorepo update` reintroduced it.
207
+ const declared: Record<string, unknown> = {
208
+ compilerOptions: { lib: ['es2023'], types: ['bun'], noEmit: true },
209
+ };
210
+ applyTypecheckTestDefaults(declared, {
211
+ testRunners: new Set(['bun'] as const),
212
+ referencePaths: [],
213
+ libCompilerOptions: { lib: ['es2022'], module: 'preserve' },
214
+ });
215
+
216
+ const declaredOptions = expectRecord(declared.compilerOptions);
217
+ expect(declaredOptions.lib).toEqual(['es2023']);
218
+ expect(declaredOptions.module).toBe('preserve');
219
+
220
+ const silent: Record<string, unknown> = { compilerOptions: {} };
221
+ applyTypecheckTestDefaults(silent, {
222
+ testRunners: new Set(['bun'] as const),
223
+ referencePaths: [],
224
+ libCompilerOptions: { lib: ['es2022'] },
225
+ });
226
+ expect(expectRecord(silent.compilerOptions).lib).toEqual(['es2022']);
227
+ });
228
+
202
229
  it('uses custom extends from lib tsconfig', () => {
203
230
  const tsconfigTest: Record<string, unknown> = {};
204
231
  applyTypecheckTestDefaults(tsconfigTest, {
@@ -1,6 +1,5 @@
1
1
  import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
- import { isDeepStrictEqual } from 'node:util';
4
3
  import type { Tree } from 'nx/src/devkit-exports.js';
5
4
  import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
6
5
 
@@ -167,13 +166,15 @@ export function applyTypecheckTestDefaults(
167
166
 
168
167
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
169
168
 
170
- // Copy relevant compiler options from lib tsconfig
169
+ // Fill from the lib tsconfig only what the test program has NOT declared. A
170
+ // test program that names its own `lib` is stating a fact the lib program
171
+ // cannot know: it runs on one runtime (Bun's JSC understands
172
+ // change-array-by-copy) while the library's output has to run on the shipping
173
+ // floor. Overwriting it turned `toSorted` into a type error in a suite that
174
+ // calls it every day, and it came back on every `smoo monorepo update`.
171
175
  if (options.libCompilerOptions) {
172
176
  for (const key of ['baseUrl', 'module', 'moduleResolution', 'jsx', 'lib']) {
173
- if (
174
- Object.hasOwn(options.libCompilerOptions, key) &&
175
- !isDeepStrictEqual(compilerOptions[key], options.libCompilerOptions[key])
176
- ) {
177
+ if (Object.hasOwn(options.libCompilerOptions, key) && !Object.hasOwn(compilerOptions, key)) {
177
178
  compilerOptions[key] = options.libCompilerOptions[key];
178
179
  changed = true;
179
180
  }