@smoothbricks/nx-plugin 0.3.3 → 0.3.4
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/version-actions.cjs +13 -39
- package/dist/version-actions.d.cts.map +1 -1
- package/package.json +1 -1
- package/src/version-actions.cts +13 -39
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"}
|
package/package.json
CHANGED
package/src/version-actions.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
1
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
2
|
import { join } from 'node:path';
|
|
4
3
|
import type { AfterAllProjectsVersioned, VersionActions } from 'nx/release';
|
|
@@ -20,11 +19,15 @@ const afterAllProjectsVersioned: AfterAllProjectsVersioned = async (cwd, options
|
|
|
20
19
|
// - https://github.com/oven-sh/bun/issues/20477
|
|
21
20
|
// - https://github.com/oven-sh/bun/issues/20829
|
|
22
21
|
//
|
|
23
|
-
// After version
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
22
|
+
// After ANY version bump (release or prepare-next), bun.lock workspace versions
|
|
23
|
+
// must match package.json exactly — including unpublished -next. Day-to-day CI
|
|
24
|
+
// and frozen installs require that invariant.
|
|
25
|
+
//
|
|
26
|
+
// Publish-time pack rewrites (-next → last stable tag) happen only in
|
|
27
|
+
// `smoo release publish` around `bun pm pack`, never here. Doing publish-mode
|
|
28
|
+
// rewrite on prepare-next is what left lock at 0.x.y while package.json said
|
|
29
|
+
// 0.x.y-next.0 and blew up monorepo validate / packed-package-manifest.
|
|
30
|
+
const updated = syncBunLockfileVersionsToPackageJson(cwd);
|
|
28
31
|
if (updated === 0) {
|
|
29
32
|
return result;
|
|
30
33
|
}
|
|
@@ -39,7 +42,7 @@ baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
|
|
|
39
42
|
|
|
40
43
|
export = baseVersionActions;
|
|
41
44
|
|
|
42
|
-
function
|
|
45
|
+
function syncBunLockfileVersionsToPackageJson(root: string): number {
|
|
43
46
|
const lockfilePath = join(root, 'bun.lock');
|
|
44
47
|
if (!existsSync(lockfilePath)) {
|
|
45
48
|
throw new Error('bun.lock not found');
|
|
@@ -48,7 +51,8 @@ function syncBunLockfileVersionsForPublish(root: string): number {
|
|
|
48
51
|
let lockfile = readFileSync(lockfilePath, 'utf8');
|
|
49
52
|
let updated = 0;
|
|
50
53
|
for (const pkg of packages) {
|
|
51
|
-
|
|
54
|
+
// Install/CI invariant: lockfile version ≡ package.json version (including -next).
|
|
55
|
+
const targetVersion = pkg.version;
|
|
52
56
|
const relativePath = pkg.path.replaceAll('\\', '/');
|
|
53
57
|
const escaped = escapeRegex(relativePath);
|
|
54
58
|
const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
|
|
@@ -63,8 +67,7 @@ function syncBunLockfileVersionsForPublish(root: string): number {
|
|
|
63
67
|
continue;
|
|
64
68
|
}
|
|
65
69
|
lockfile = lockfile.replace(pattern, `$1${targetVersion}$3`);
|
|
66
|
-
|
|
67
|
-
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}${suffix}`);
|
|
70
|
+
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}`);
|
|
68
71
|
updated++;
|
|
69
72
|
}
|
|
70
73
|
if (updated > 0) {
|
|
@@ -76,35 +79,6 @@ function syncBunLockfileVersionsForPublish(root: string): number {
|
|
|
76
79
|
return updated;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
function publishLockfileVersion(root: string, projectName: string, packageVersion: string): string {
|
|
80
|
-
if (!packageVersion.includes('-')) {
|
|
81
|
-
return packageVersion;
|
|
82
|
-
}
|
|
83
|
-
return latestStableTagVersion(root, projectName) ?? packageVersion;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function latestStableTagVersion(root: string, projectName: string): string | null {
|
|
87
|
-
try {
|
|
88
|
-
const output = execSync(`git tag --list '${projectName}@*' --sort=-v:refname`, {
|
|
89
|
-
cwd: root,
|
|
90
|
-
encoding: 'utf8',
|
|
91
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
92
|
-
});
|
|
93
|
-
const prefix = `${projectName}@`;
|
|
94
|
-
for (const line of output.split('\n')) {
|
|
95
|
-
const tag = line.trim();
|
|
96
|
-
if (!tag.startsWith(prefix)) continue;
|
|
97
|
-
const version = tag.slice(prefix.length);
|
|
98
|
-
if (version && !version.includes('-')) {
|
|
99
|
-
return version;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
} catch {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
82
|
interface WorkspacePackage {
|
|
109
83
|
path: string;
|
|
110
84
|
name: string;
|