@smoothbricks/nx-plugin 0.4.8 → 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.
- package/dist/index.js +4 -1
- package/dist/release-config-policy.d.ts +8 -0
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +31 -4
- package/package.json +2 -2
- package/src/index.test.ts +1 -4
- package/src/index.ts +4 -1
- package/src/release-config-policy.test.ts +18 -1
- package/src/release-config-policy.ts +33 -4
package/dist/index.js
CHANGED
|
@@ -1091,7 +1091,10 @@ function inferTypescriptOutputs(tsconfigPath, packageJsonPath) {
|
|
|
1091
1091
|
const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
|
|
1092
1092
|
const outDir = compilerOptions?.outDir;
|
|
1093
1093
|
if (typeof outDir !== 'string' || outDir.length === 0) {
|
|
1094
|
-
|
|
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}'];
|
|
1095
1098
|
}
|
|
1096
1099
|
const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
|
|
1097
1100
|
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":"
|
|
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')
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
@@ -1302,7 +1302,10 @@ function inferTypescriptOutputs(tsconfigPath: string, packageJsonPath: string):
|
|
|
1302
1302
|
const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
|
|
1303
1303
|
const outDir = compilerOptions?.outDir;
|
|
1304
1304
|
if (typeof outDir !== 'string' || outDir.length === 0) {
|
|
1305
|
-
|
|
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}'];
|
|
1306
1309
|
}
|
|
1307
1310
|
|
|
1308
1311
|
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(
|
|
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')
|
|
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
|
-
|
|
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;
|