@smoothbricks/nx-plugin 0.3.2 → 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/README.md +7 -12
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +1 -100
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -125
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +0 -30
- package/dist/version-actions.cjs +14 -36
- package/dist/version-actions.d.cts.map +1 -1
- package/generators.json +1 -1
- package/package.json +1 -1
- package/src/generators/create-package/generator.test.ts +0 -71
- package/src/generators/create-package/generator.ts +1 -121
- package/src/generators/create-package/schema.d.ts +1 -1
- package/src/generators/create-package/schema.json +1 -1
- package/src/index.test.ts +72 -81
- package/src/index.ts +25 -148
- package/src/package-target-policy.test.ts +0 -48
- package/src/package-target-policy.ts +0 -32
- package/src/version-actions.cts +14 -38
|
@@ -354,7 +354,6 @@ function isSafeNxScriptCommand(command: string): boolean {
|
|
|
354
354
|
/^tsdown(?:\s|$)/.test(trimmed) ||
|
|
355
355
|
/^vite\s+(?:build|dev|preview)(?:\s|$)/.test(trimmed) ||
|
|
356
356
|
/^astro\s+(?:build|dev|preview|check)(?:\s|$)/.test(trimmed) ||
|
|
357
|
-
/^zig\s+build(?:\s|$)/.test(trimmed) ||
|
|
358
357
|
/^bun\s+[./\w-]*build[\w.-]*\.ts(?:\s|$)/.test(trimmed) ||
|
|
359
358
|
/(?:^|\s)(?:bench|benchmark)(?:\s|$)/.test(trimmed) ||
|
|
360
359
|
/^wrangler\s+build(?:\s|$)/.test(trimmed)
|
|
@@ -418,10 +417,6 @@ function targetNameForCommand(command: string): string | null {
|
|
|
418
417
|
if (/^tsdown(?:\s|$)/.test(trimmed)) {
|
|
419
418
|
return 'tsdown-js';
|
|
420
419
|
}
|
|
421
|
-
const zigStep = /^zig\s+build\s+([A-Za-z0-9_-]+)(?:\s|$)/.exec(trimmed)?.[1];
|
|
422
|
-
if (zigStep) {
|
|
423
|
-
return `zig-${zigStep}`;
|
|
424
|
-
}
|
|
425
420
|
if (/^wrangler\s+build(?:\s|$)/.test(trimmed)) {
|
|
426
421
|
return 'build';
|
|
427
422
|
}
|
|
@@ -584,19 +579,6 @@ function directoryContainsTestFiles(path: string): boolean {
|
|
|
584
579
|
return false;
|
|
585
580
|
}
|
|
586
581
|
|
|
587
|
-
function validateBuildZigPolicy(root: string, packagePath: string): NxPolicyIssue[] {
|
|
588
|
-
const path = join(root, packagePath, 'build.zig');
|
|
589
|
-
if (!existsSync(path)) {
|
|
590
|
-
return [];
|
|
591
|
-
}
|
|
592
|
-
if (/\bb\.step\s*\(/.test(readFileSync(path, 'utf8'))) {
|
|
593
|
-
return [];
|
|
594
|
-
}
|
|
595
|
-
return [
|
|
596
|
-
{ path: join(root, packagePath), message: `${packagePath}/build.zig must define at least one b.step(...) target` },
|
|
597
|
-
];
|
|
598
|
-
}
|
|
599
|
-
|
|
600
582
|
function validateExplicitNxTargets(
|
|
601
583
|
pkg: Record<string, unknown>,
|
|
602
584
|
packagePath: string,
|
|
@@ -952,18 +934,6 @@ function directoryContainsTestFilesTree(tree: Tree, path: string): boolean {
|
|
|
952
934
|
return false;
|
|
953
935
|
}
|
|
954
936
|
|
|
955
|
-
function validateBuildZigPolicyTree(tree: Tree, packagePath: string): NxPolicyIssue[] {
|
|
956
|
-
const path = `${packagePath}/build.zig`;
|
|
957
|
-
if (!tree.exists(path)) {
|
|
958
|
-
return [];
|
|
959
|
-
}
|
|
960
|
-
const content = tree.read(path, 'utf-8');
|
|
961
|
-
if (content && /\bb\.step\s*\(/.test(content)) {
|
|
962
|
-
return [];
|
|
963
|
-
}
|
|
964
|
-
return [{ path: packagePath, message: `${packagePath}/build.zig must define at least one b.step(...) target` }];
|
|
965
|
-
}
|
|
966
|
-
|
|
967
937
|
function validateTestEntrypointPresenceTree(
|
|
968
938
|
tree: Tree,
|
|
969
939
|
packagePath: string,
|
|
@@ -998,7 +968,6 @@ export function checkPackageTargetPolicyTree(tree: Tree, options: PackageTargetP
|
|
|
998
968
|
|
|
999
969
|
issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject));
|
|
1000
970
|
issues.push(...validateTestEntrypointPresenceTree(tree, packagePath, pkg));
|
|
1001
|
-
issues.push(...validateBuildZigPolicyTree(tree, packagePath));
|
|
1002
971
|
issues.push(...validatePackageScriptPolicy(pkg, packagePath, workspaceNames, { resolvedTargets }));
|
|
1003
972
|
}
|
|
1004
973
|
|
|
@@ -1222,7 +1191,6 @@ export function checkPackageTargetPolicy(root: string, options: PackageTargetPol
|
|
|
1222
1191
|
|
|
1223
1192
|
issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject));
|
|
1224
1193
|
issues.push(...validateTestEntrypointPresence(root, packagePath, pkg));
|
|
1225
|
-
issues.push(...validateBuildZigPolicy(root, packagePath));
|
|
1226
1194
|
issues.push(...validatePackageScriptPolicy(pkg, packagePath, workspaceNames, { resolvedTargets: resolvedProject }));
|
|
1227
1195
|
}
|
|
1228
1196
|
|
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';
|
|
@@ -19,10 +18,16 @@ const afterAllProjectsVersioned: AfterAllProjectsVersioned = async (cwd, options
|
|
|
19
18
|
// - https://github.com/oven-sh/bun/issues/18906
|
|
20
19
|
// - https://github.com/oven-sh/bun/issues/20477
|
|
21
20
|
// - https://github.com/oven-sh/bun/issues/20829
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
|
|
21
|
+
//
|
|
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);
|
|
26
31
|
if (updated === 0) {
|
|
27
32
|
return result;
|
|
28
33
|
}
|
|
@@ -37,7 +42,7 @@ baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
|
|
|
37
42
|
|
|
38
43
|
export = baseVersionActions;
|
|
39
44
|
|
|
40
|
-
function
|
|
45
|
+
function syncBunLockfileVersionsToPackageJson(root: string): number {
|
|
41
46
|
const lockfilePath = join(root, 'bun.lock');
|
|
42
47
|
if (!existsSync(lockfilePath)) {
|
|
43
48
|
throw new Error('bun.lock not found');
|
|
@@ -46,13 +51,8 @@ function syncBunLockfileVersions(root: string): number {
|
|
|
46
51
|
let lockfile = readFileSync(lockfilePath, 'utf8');
|
|
47
52
|
let updated = 0;
|
|
48
53
|
for (const pkg of packages) {
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
// that `bun pm pack` writes an installable dependency range for consumers.
|
|
52
|
-
const targetVersion = pkg.version.includes('-')
|
|
53
|
-
? (latestStableTagVersion(root, pkg.projectName) ?? pkg.version)
|
|
54
|
-
: pkg.version;
|
|
55
|
-
|
|
54
|
+
// Install/CI invariant: lockfile version ≡ package.json version (including -next).
|
|
55
|
+
const targetVersion = pkg.version;
|
|
56
56
|
const relativePath = pkg.path.replaceAll('\\', '/');
|
|
57
57
|
const escaped = escapeRegex(relativePath);
|
|
58
58
|
const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
|
|
@@ -67,9 +67,7 @@ function syncBunLockfileVersions(root: string): number {
|
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
69
|
lockfile = lockfile.replace(pattern, `$1${targetVersion}$3`);
|
|
70
|
-
console.log(
|
|
71
|
-
`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}${targetVersion !== pkg.version ? ` (latest stable tag; package.json has ${pkg.version})` : ''}`,
|
|
72
|
-
);
|
|
70
|
+
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}`);
|
|
73
71
|
updated++;
|
|
74
72
|
}
|
|
75
73
|
if (updated > 0) {
|
|
@@ -117,25 +115,3 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
117
115
|
function escapeRegex(value: string): string {
|
|
118
116
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
119
117
|
}
|
|
120
|
-
|
|
121
|
-
function latestStableTagVersion(root: string, projectName: string): string | null {
|
|
122
|
-
try {
|
|
123
|
-
const output = execSync(`git tag --list '${projectName}@*' --sort=-v:refname`, {
|
|
124
|
-
cwd: root,
|
|
125
|
-
encoding: 'utf8',
|
|
126
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
127
|
-
});
|
|
128
|
-
const prefix = `${projectName}@`;
|
|
129
|
-
for (const line of output.split('\n')) {
|
|
130
|
-
const tag = line.trim();
|
|
131
|
-
if (!tag.startsWith(prefix)) continue;
|
|
132
|
-
const version = tag.slice(prefix.length);
|
|
133
|
-
if (version && !version.includes('-')) {
|
|
134
|
-
return version;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
} catch {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
}
|