@smoothbricks/cli 0.10.3 → 0.10.5
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 +9 -13
- package/dist/bun/preload.d.ts +13 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +12 -0
- package/dist/cli.js +13 -5
- package/dist/generate/index.d.ts.map +1 -1
- package/dist/generate/index.js +0 -6
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +52 -16
- package/dist/github-ci/outputs.d.ts.map +1 -1
- package/dist/github-ci/outputs.js +1 -2
- package/dist/lib/cli-package.js +2 -2
- package/dist/lib/json.d.ts +120 -11
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/json.js +319 -29
- package/dist/lib/workspace.d.ts +7 -14
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/lib/workspace.js +76 -82
- package/dist/monorepo/ci-workflow.d.ts +2 -0
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +27 -1
- package/dist/monorepo/git-config.js +2 -2
- package/dist/monorepo/index.d.ts +4 -2
- package/dist/monorepo/index.d.ts.map +1 -1
- package/dist/monorepo/index.js +19 -3
- package/dist/monorepo/lockfile.d.ts +14 -1
- package/dist/monorepo/lockfile.d.ts.map +1 -1
- package/dist/monorepo/lockfile.js +33 -21
- package/dist/monorepo/managed-files.d.ts +11 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +57 -32
- package/dist/monorepo/package-policy.d.ts.map +1 -1
- package/dist/monorepo/package-policy.js +52 -45
- package/dist/monorepo/packed-manifest.d.ts +5 -2
- package/dist/monorepo/packed-manifest.d.ts.map +1 -1
- package/dist/monorepo/packed-manifest.js +16 -47
- package/dist/monorepo/packed-package.d.ts.map +1 -1
- package/dist/monorepo/packed-package.js +28 -16
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +14 -5
- package/dist/monorepo/publish-workflow.js +3 -1
- package/dist/monorepo/runtime.d.ts +15 -0
- package/dist/monorepo/runtime.d.ts.map +1 -1
- package/dist/monorepo/runtime.js +66 -12
- package/dist/monorepo/tool-validation.d.ts +2 -2
- package/dist/monorepo/tool-validation.d.ts.map +1 -1
- package/dist/monorepo/tool-validation.js +141 -38
- package/dist/monorepo/wrangler.d.ts.map +1 -1
- package/dist/monorepo/wrangler.js +13 -13
- package/dist/nx/index.d.ts +9 -7
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +48 -31
- package/dist/pr/index.d.ts.map +1 -1
- package/dist/pr/index.js +28 -32
- package/dist/release/candidates.d.ts +3 -2
- package/dist/release/candidates.d.ts.map +1 -1
- package/dist/release/candidates.js +4 -5
- package/dist/release/index.d.ts +1 -0
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +88 -59
- package/dist/wrangler/prepare-env.d.ts +0 -1
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +100 -51
- package/dist/wrangler/scaffold.d.ts.map +1 -1
- package/dist/wrangler/scaffold.js +12 -12
- package/managed/raw/envrc +5 -3
- package/managed/raw/git-format-staged.yml +19 -1
- package/managed/raw/patches/ttsc@0.19.3.patch +67 -0
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +2 -1
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +3 -3
- package/managed/raw/tooling/direnv/setup-environment.ts +170 -19
- package/managed/raw/tooling/git-hooks/pre-commit.sh +0 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +5 -2
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +5 -0
- package/managed/templates/github/workflows/managed-files.yml +80 -0
- package/package.json +15 -4
- package/src/bun/preload.ts +12 -0
- package/src/cli.ts +20 -8
- package/src/generate/index.ts +0 -6
- package/src/github-ci/index.ts +49 -18
- package/src/github-ci/outputs.ts +1 -2
- package/src/lib/cli-package.ts +2 -2
- package/src/lib/json.ts +293 -32
- package/src/lib/workspace.ts +88 -100
- package/src/monorepo/__tests__/ci-workflow.test.ts +3 -3
- package/src/monorepo/ci-workflow.ts +27 -1
- package/src/monorepo/git-config.ts +2 -2
- package/src/monorepo/index.ts +19 -3
- package/src/monorepo/lockfile.test.ts +35 -36
- package/src/monorepo/lockfile.ts +49 -24
- package/src/monorepo/managed-files.test.ts +1 -0
- package/src/monorepo/managed-files.ts +62 -38
- package/src/monorepo/package-policy.test.ts +20 -50
- package/src/monorepo/package-policy.ts +76 -59
- package/src/monorepo/packed-manifest.ts +18 -52
- package/src/monorepo/packed-package.ts +43 -22
- package/src/monorepo/packs/index.ts +14 -5
- package/src/monorepo/publish-workflow.ts +3 -1
- package/src/monorepo/runtime.test.ts +42 -3
- package/src/monorepo/runtime.ts +90 -12
- package/src/monorepo/tool-validation.test.ts +38 -16
- package/src/monorepo/tool-validation.ts +149 -41
- package/src/monorepo/wrangler.test.ts +11 -15
- package/src/monorepo/wrangler.ts +15 -15
- package/src/nx/index.test.ts +9 -5
- package/src/nx/index.ts +69 -42
- package/src/pr/index.ts +42 -36
- package/src/release/__tests__/candidates.test.ts +5 -4
- package/src/release/__tests__/trust-publisher.test.ts +7 -0
- package/src/release/candidates.ts +10 -17
- package/src/release/index.ts +110 -73
- package/src/wrangler/prepare-env.ts +75 -54
- package/src/wrangler/scaffold.test.ts +9 -12
- package/src/wrangler/scaffold.ts +13 -13
package/src/monorepo/lockfile.ts
CHANGED
|
@@ -5,27 +5,37 @@ import { escapeRegex, getWorkspacePackages } from '../lib/workspace.js';
|
|
|
5
5
|
|
|
6
6
|
export interface SyncBunLockfileVersionsOptions {
|
|
7
7
|
log?: boolean;
|
|
8
|
-
/** `git add` bun.lock
|
|
8
|
+
/** `git add` bun.lock when versions were resynced. */
|
|
9
9
|
stage?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* `install` (default): lockfile must match package.json (including -next).
|
|
12
|
+
* `publish`: rewrite unpublished prerelease package.json versions to the last
|
|
13
|
+
* stable git tag so `bun pm pack` embeds installable dependency versions.
|
|
14
|
+
* Only use publish mode around pack; never leave the tree in publish mode.
|
|
15
|
+
*/
|
|
16
|
+
mode?: 'install' | 'publish';
|
|
10
17
|
}
|
|
11
18
|
|
|
12
|
-
// Temporary Bun workaround. Delete
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// versions stale in bun.lock after manifest bumps. Until then, `bun pm pack`
|
|
16
|
-
// rewrites `workspace:*` dependencies using those stale lockfile versions instead
|
|
17
|
-
// of the current package.json versions. Track removal against:
|
|
19
|
+
// Temporary Bun workaround. Delete once supported Bun versions stop leaving
|
|
20
|
+
// workspace package versions stale in bun.lock after manifest bumps, and stop
|
|
21
|
+
// resolving `workspace:*` from the lockfile during `bun pm pack`:
|
|
18
22
|
// - https://github.com/oven-sh/bun/issues/18906
|
|
19
23
|
// - https://github.com/oven-sh/bun/issues/20477
|
|
20
24
|
// - https://github.com/oven-sh/bun/issues/20829
|
|
21
25
|
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
26
|
+
// Two modes, because one lockfile serves two jobs:
|
|
27
|
+
//
|
|
28
|
+
// 1) install / frozen CI → lockfile ≡ package.json (including -next)
|
|
29
|
+
// 2) pre-publish pack → for package.json prereleases that were never published
|
|
30
|
+
// (post-release "prepare next"), lockfile entry := last
|
|
31
|
+
// stable tag so a releasing package does not embed an
|
|
32
|
+
// unpublished -next dependency version.
|
|
33
|
+
//
|
|
34
|
+
// Do not run publish-mode rewrite in day-to-day validate or pre-commit: bun install
|
|
35
|
+
// rewrites lockfile back to package.json and frozen CI then fails.
|
|
27
36
|
export function syncBunLockfileVersions(root: string, options: SyncBunLockfileVersionsOptions = {}): number {
|
|
28
37
|
const log = options.log ?? true;
|
|
38
|
+
const mode = options.mode ?? 'install';
|
|
29
39
|
const lockfilePath = join(root, 'bun.lock');
|
|
30
40
|
if (!existsSync(lockfilePath)) {
|
|
31
41
|
throw new Error('bun.lock not found');
|
|
@@ -34,13 +44,7 @@ export function syncBunLockfileVersions(root: string, options: SyncBunLockfileVe
|
|
|
34
44
|
let lockfile = readFileSync(lockfilePath, 'utf8');
|
|
35
45
|
let updated = 0;
|
|
36
46
|
for (const pkg of packages) {
|
|
37
|
-
|
|
38
|
-
// never have been published. Use the latest stable git tag version so
|
|
39
|
-
// that `bun pm pack` writes an installable dependency range for consumers.
|
|
40
|
-
const targetVersion = pkg.version.includes('-')
|
|
41
|
-
? (latestStableTagVersion(root, pkg.projectName) ?? pkg.version)
|
|
42
|
-
: pkg.version;
|
|
43
|
-
|
|
47
|
+
const targetVersion = lockfileTargetVersion(root, pkg.projectName, pkg.version, mode);
|
|
44
48
|
const relativePath = pkg.path.replaceAll('\\', '/');
|
|
45
49
|
const escaped = escapeRegex(relativePath);
|
|
46
50
|
const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
|
|
@@ -60,7 +64,10 @@ export function syncBunLockfileVersions(root: string, options: SyncBunLockfileVe
|
|
|
60
64
|
}
|
|
61
65
|
lockfile = lockfile.replace(pattern, `$1${targetVersion}$3`);
|
|
62
66
|
if (log) {
|
|
63
|
-
const suffix =
|
|
67
|
+
const suffix =
|
|
68
|
+
mode === 'publish' && targetVersion !== pkg.version
|
|
69
|
+
? ` (latest stable tag; package.json has ${pkg.version})`
|
|
70
|
+
: '';
|
|
64
71
|
console.log(`fix: ${relativePath}: ${lockVersion} -> ${targetVersion}${suffix}`);
|
|
65
72
|
}
|
|
66
73
|
updated++;
|
|
@@ -81,6 +88,7 @@ export function syncBunLockfileVersions(root: string, options: SyncBunLockfileVe
|
|
|
81
88
|
return updated;
|
|
82
89
|
}
|
|
83
90
|
|
|
91
|
+
/** Install/CI invariant: bun.lock workspace versions match package.json. */
|
|
84
92
|
export function validateBunLockfileVersions(root: string): number {
|
|
85
93
|
const lockfilePath = join(root, 'bun.lock');
|
|
86
94
|
if (!existsSync(lockfilePath)) {
|
|
@@ -91,10 +99,7 @@ export function validateBunLockfileVersions(root: string): number {
|
|
|
91
99
|
const lockfile = readFileSync(lockfilePath, 'utf8');
|
|
92
100
|
let failures = 0;
|
|
93
101
|
for (const pkg of packages) {
|
|
94
|
-
const targetVersion = pkg.version
|
|
95
|
-
? (latestStableTagVersion(root, pkg.projectName) ?? pkg.version)
|
|
96
|
-
: pkg.version;
|
|
97
|
-
|
|
102
|
+
const targetVersion = pkg.version;
|
|
98
103
|
const relativePath = pkg.path.replaceAll('\\', '/');
|
|
99
104
|
const escaped = escapeRegex(relativePath);
|
|
100
105
|
const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
|
|
@@ -116,6 +121,26 @@ export function validateBunLockfileVersions(root: string): number {
|
|
|
116
121
|
return failures;
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Version Bun should embed for a workspace dependency when packing for publish.
|
|
126
|
+
* Unpublished package.json prereleases (prepare-next) map to the last stable tag.
|
|
127
|
+
*/
|
|
128
|
+
export function publishPackDependencyVersion(root: string, projectName: string, packageVersion: string): string {
|
|
129
|
+
return lockfileTargetVersion(root, projectName, packageVersion, 'publish');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function lockfileTargetVersion(
|
|
133
|
+
root: string,
|
|
134
|
+
projectName: string,
|
|
135
|
+
packageVersion: string,
|
|
136
|
+
mode: 'install' | 'publish',
|
|
137
|
+
): string {
|
|
138
|
+
if (mode === 'install' || !packageVersion.includes('-')) {
|
|
139
|
+
return packageVersion;
|
|
140
|
+
}
|
|
141
|
+
return latestStableTagVersion(root, projectName) ?? packageVersion;
|
|
142
|
+
}
|
|
143
|
+
|
|
119
144
|
function latestStableTagVersion(root: string, projectName: string): string | null {
|
|
120
145
|
try {
|
|
121
146
|
const output = execSync(`git tag --list '${projectName}@*' --sort=-v:refname`, {
|
|
@@ -22,6 +22,7 @@ const NODE_MODULES_CACHE_KEY = "${{ hashFiles('bun.lock', 'package.json', 'packa
|
|
|
22
22
|
const CACHE_ACTIONS = [
|
|
23
23
|
{ name: 'cache-nix-devenv', osKeyLines: 6 },
|
|
24
24
|
{ name: 'cache-node-modules', osKeyLines: 2 },
|
|
25
|
+
{ name: 'cache-ttsc-plugins', osKeyLines: 2 },
|
|
25
26
|
{ name: 'cache-nx', osKeyLines: 2 },
|
|
26
27
|
] as const;
|
|
27
28
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { PLATFORM_TARGET_GLOBS } from '@smoothbricks/nx-plugin/workspace-config-policy';
|
|
6
|
+
import { type PackageJson, parseNxProjectJsonText, parseStringArrayText } from '../lib/json.js';
|
|
6
7
|
import { listReleasePackages, readPackageJson } from '../lib/workspace.js';
|
|
7
8
|
import { renderCiWorkflowYaml } from './ci-workflow.js';
|
|
8
9
|
import { renderPublishWorkflowYaml } from './publish-workflow.js';
|
|
@@ -198,6 +199,11 @@ const managedFiles: ManagedFile[] = [
|
|
|
198
199
|
target: 'tooling/direnv/merge-newer-pins.sh',
|
|
199
200
|
executable: true,
|
|
200
201
|
},
|
|
202
|
+
{
|
|
203
|
+
kind: 'raw',
|
|
204
|
+
source: 'patches/ttsc@0.19.3.patch',
|
|
205
|
+
target: 'patches/ttsc@0.19.3.patch',
|
|
206
|
+
},
|
|
201
207
|
{
|
|
202
208
|
kind: 'generated',
|
|
203
209
|
source: 'ci-workflow',
|
|
@@ -209,6 +215,11 @@ const managedFiles: ManagedFile[] = [
|
|
|
209
215
|
target: '.github/workflows/publish.yml',
|
|
210
216
|
releasePackagesOnly: true,
|
|
211
217
|
},
|
|
218
|
+
{
|
|
219
|
+
kind: 'template',
|
|
220
|
+
source: 'github/workflows/managed-files.yml',
|
|
221
|
+
target: '.github/workflows/managed-files.yml',
|
|
222
|
+
},
|
|
212
223
|
{
|
|
213
224
|
kind: 'template',
|
|
214
225
|
source: 'github/actions/cache-nix-devenv/action.yml',
|
|
@@ -229,6 +240,11 @@ const managedFiles: ManagedFile[] = [
|
|
|
229
240
|
source: 'github/actions/cache-node-modules/action.yml',
|
|
230
241
|
target: '.github/actions/cache-node-modules/action.yml',
|
|
231
242
|
},
|
|
243
|
+
{
|
|
244
|
+
kind: 'template',
|
|
245
|
+
source: 'github/actions/cache-ttsc-plugins/action.yml',
|
|
246
|
+
target: '.github/actions/cache-ttsc-plugins/action.yml',
|
|
247
|
+
},
|
|
232
248
|
{
|
|
233
249
|
kind: 'template',
|
|
234
250
|
source: 'github/actions/cache-nx/action.yml',
|
|
@@ -348,8 +364,8 @@ function readResolvedNxTargetNames(root: string): string[] {
|
|
|
348
364
|
encoding: 'utf8',
|
|
349
365
|
stdio: ['ignore', 'pipe', 'inherit'],
|
|
350
366
|
});
|
|
351
|
-
const projects
|
|
352
|
-
if (!
|
|
367
|
+
const projects = parseStringArrayText(output);
|
|
368
|
+
if (!projects) {
|
|
353
369
|
return [];
|
|
354
370
|
}
|
|
355
371
|
const targetNames = new Set<string>();
|
|
@@ -359,8 +375,8 @@ function readResolvedNxTargetNames(root: string): string[] {
|
|
|
359
375
|
encoding: 'utf8',
|
|
360
376
|
stdio: ['ignore', 'pipe', 'inherit'],
|
|
361
377
|
});
|
|
362
|
-
const projectJson
|
|
363
|
-
const targets =
|
|
378
|
+
const projectJson = parseNxProjectJsonText(projectOutput);
|
|
379
|
+
const targets = projectJson?.targets;
|
|
364
380
|
if (targets) {
|
|
365
381
|
for (const targetName of Object.keys(targets)) {
|
|
366
382
|
targetNames.add(targetName);
|
|
@@ -383,8 +399,8 @@ function getDeployTargetInfo(root: string, configuration: string): DeployTargetI
|
|
|
383
399
|
encoding: 'utf8',
|
|
384
400
|
stdio: ['ignore', 'pipe', 'inherit'],
|
|
385
401
|
});
|
|
386
|
-
const projects
|
|
387
|
-
if (!
|
|
402
|
+
const projects = parseStringArrayText(output);
|
|
403
|
+
if (!projects) {
|
|
388
404
|
return { exists: false };
|
|
389
405
|
}
|
|
390
406
|
let exists = false;
|
|
@@ -406,47 +422,25 @@ function nxDeployTarget(root: string, project: string, configuration: string): D
|
|
|
406
422
|
encoding: 'utf8',
|
|
407
423
|
stdio: ['ignore', 'pipe', 'inherit'],
|
|
408
424
|
});
|
|
409
|
-
const
|
|
410
|
-
const
|
|
411
|
-
const
|
|
412
|
-
const deploy = recordValue(targets?.deploy);
|
|
413
|
-
const configurations = recordValue(deploy?.configurations);
|
|
414
|
-
const config = recordValue(configurations?.[configuration]);
|
|
425
|
+
const projectJson = parseNxProjectJsonText(output);
|
|
426
|
+
const deploy = projectJson?.targets?.deploy;
|
|
427
|
+
const config = deploy?.configurations?.[configuration];
|
|
415
428
|
if (!config) {
|
|
416
429
|
return { exists: false };
|
|
417
430
|
}
|
|
418
|
-
const
|
|
431
|
+
const commandValue = config.command ?? config.options?.command ?? deploy?.options?.command;
|
|
432
|
+
const command = typeof commandValue === 'string' ? commandValue : '';
|
|
419
433
|
return { exists: true, provider: command.includes('wrangler ') ? 'cloudflare' : undefined };
|
|
420
434
|
}
|
|
421
435
|
|
|
422
|
-
function
|
|
423
|
-
const command = stringValue(config.command) ?? stringValue(recordValue(config.options)?.command);
|
|
424
|
-
return command ?? stringValue(recordValue(deploy?.options)?.command) ?? '';
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
function stringValue(value: unknown): string | undefined {
|
|
428
|
-
return typeof value === 'string' ? value : undefined;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function getCiPushBranches(packageJson: unknown): string[] {
|
|
436
|
+
function getCiPushBranches(packageJson: PackageJson | null | undefined): string[] {
|
|
432
437
|
const configured = readCiPushBranches(packageJson);
|
|
433
438
|
return configured.length > 0 ? configured : ['main'];
|
|
434
439
|
}
|
|
435
440
|
|
|
436
|
-
function readCiPushBranches(packageJson:
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
const github = recordValue(smoo?.github);
|
|
440
|
-
const branches = Array.isArray(github?.pushBranches) ? github.pushBranches : [];
|
|
441
|
-
return branches.filter((branch): branch is string => typeof branch === 'string' && branch.length > 0);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function recordValue(value: unknown): Record<string, unknown> | undefined {
|
|
445
|
-
return isRecord(value) ? value : undefined;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
449
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
441
|
+
function readCiPushBranches(packageJson: PackageJson | null | undefined): string[] {
|
|
442
|
+
const branches = packageJson?.smoo?.github?.pushBranches ?? [];
|
|
443
|
+
return branches.filter((branch) => branch.length > 0);
|
|
450
444
|
}
|
|
451
445
|
|
|
452
446
|
function renderYamlFlowList(values: string[]): string {
|
|
@@ -473,3 +467,33 @@ export function validateManagedFiles(root: string): number {
|
|
|
473
467
|
}
|
|
474
468
|
return failures;
|
|
475
469
|
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Non-blocking drift report: prints the per-file table and surfaces drift as
|
|
473
|
+
* GitHub Actions warning annotations (plain stderr elsewhere) without failing
|
|
474
|
+
* the run. Managed-file drift is derived state with its own remediation flow
|
|
475
|
+
* (the persistent managed-files PR); only `monorepo check` without --warn and
|
|
476
|
+
* PR-scoped gates treat it as an error.
|
|
477
|
+
*
|
|
478
|
+
* Under GitHub Actions the drifted-file count is published as the step output
|
|
479
|
+
* `drifted`, so downstream steps gate declaratively instead of parsing logs.
|
|
480
|
+
*/
|
|
481
|
+
export function warnOnManagedFileDrift(root: string): void {
|
|
482
|
+
const results = applyManagedFiles(root, 'check');
|
|
483
|
+
printResults(results);
|
|
484
|
+
const drifted = results.filter((result) => result.action === 'drifted');
|
|
485
|
+
if (process.env.GITHUB_OUTPUT) {
|
|
486
|
+
appendFileSync(process.env.GITHUB_OUTPUT, `drifted=${drifted.length}\n`);
|
|
487
|
+
}
|
|
488
|
+
if (drifted.length === 0) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (process.env.GITHUB_ACTIONS === 'true') {
|
|
492
|
+
for (const result of drifted) {
|
|
493
|
+
console.log(
|
|
494
|
+
`::warning title=Managed file drift::${result.target} drifted from the @smoothbricks/cli template; run 'smoo monorepo update'`,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
console.error(`${drifted.length} managed monorepo file(s) drifted (non-blocking). Run: smoo monorepo update`);
|
|
499
|
+
}
|
|
@@ -262,7 +262,7 @@ describe('workspace package script policy', () => {
|
|
|
262
262
|
try {
|
|
263
263
|
expect(validateWorkspaceDependencies(root)).toBe(2);
|
|
264
264
|
|
|
265
|
-
const resolvedTargetsByProject = new Map([['native', new Set(['build', 'tsc-js', '
|
|
265
|
+
const resolvedTargetsByProject = new Map([['native', new Set(['build', 'tsc-js', 'tsdown-js'])]]);
|
|
266
266
|
applyWorkspaceDependencyDefaults(root, { resolvedTargetsByProject });
|
|
267
267
|
|
|
268
268
|
const native = await readJson(join(root, 'packages/native/package.json'));
|
|
@@ -284,17 +284,17 @@ describe('workspace package script policy', () => {
|
|
|
284
284
|
dependencies: { '@smoothbricks/lib': 'workspace:*' },
|
|
285
285
|
scripts: {
|
|
286
286
|
'build:custom': 'nx run native:build:custom',
|
|
287
|
-
'build:
|
|
287
|
+
'build:bundle': 'nx run native:build:bundle',
|
|
288
288
|
'build:ts': 'nx run native:build:ts',
|
|
289
289
|
},
|
|
290
290
|
nx: {
|
|
291
291
|
name: 'native',
|
|
292
292
|
targets: {
|
|
293
|
-
build: { dependsOn: ['^build', 'build:ts', 'build:
|
|
293
|
+
build: { dependsOn: ['^build', 'build:ts', 'build:bundle', 'build:custom'] },
|
|
294
294
|
'build:custom': {},
|
|
295
|
-
'build:
|
|
295
|
+
'build:bundle': {
|
|
296
296
|
executor: 'nx:run-commands',
|
|
297
|
-
options: { command: '
|
|
297
|
+
options: { command: 'tsdown', cwd: '{projectRoot}' },
|
|
298
298
|
},
|
|
299
299
|
'build:ts': {
|
|
300
300
|
executor: 'nx:run-commands',
|
|
@@ -307,25 +307,21 @@ describe('workspace package script policy', () => {
|
|
|
307
307
|
});
|
|
308
308
|
try {
|
|
309
309
|
await writeJson(join(root, 'packages/native/tsconfig.lib.json'), {});
|
|
310
|
-
await writeFile(
|
|
311
|
-
join(root, 'packages/native/build.zig'),
|
|
312
|
-
'pub fn build(b: *std.Build) void { _ = b.step("wasm", "Build wasm"); }\n',
|
|
313
|
-
);
|
|
314
310
|
expect(validateWorkspaceDependencies(root)).toBe(6);
|
|
315
311
|
|
|
316
|
-
const resolvedTargetsByProject = new Map([['native', new Set(['build', 'custom', 'tsc-js', '
|
|
312
|
+
const resolvedTargetsByProject = new Map([['native', new Set(['build', 'custom', 'tsc-js', 'tsdown-js'])]]);
|
|
317
313
|
applyWorkspaceDependencyDefaults(root, { resolvedTargetsByProject });
|
|
318
314
|
|
|
319
315
|
const native = await readJson(join(root, 'packages/native/package.json'));
|
|
320
316
|
expect(native.scripts).toEqual({
|
|
321
317
|
'build:custom': 'nx run native:custom',
|
|
322
|
-
'build:
|
|
318
|
+
'build:bundle': 'nx run native:tsdown-js',
|
|
323
319
|
'build:ts': 'nx run native:tsc-js',
|
|
324
320
|
});
|
|
325
321
|
expect(native.nx).toEqual({
|
|
326
322
|
name: 'native',
|
|
327
323
|
targets: {
|
|
328
|
-
build: { dependsOn: ['^build', 'tsc-js', '
|
|
324
|
+
build: { dependsOn: ['^build', 'tsc-js', 'tsdown-js', 'custom'] },
|
|
329
325
|
},
|
|
330
326
|
});
|
|
331
327
|
expect(validateWorkspaceDependencies(root, { resolvedTargetsByProject })).toBe(0);
|
|
@@ -344,7 +340,7 @@ describe('workspace package script policy', () => {
|
|
|
344
340
|
nx: {
|
|
345
341
|
name: 'native',
|
|
346
342
|
targets: {
|
|
347
|
-
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', '
|
|
343
|
+
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', 'tsdown-js', 'custom'] },
|
|
348
344
|
},
|
|
349
345
|
},
|
|
350
346
|
},
|
|
@@ -352,14 +348,10 @@ describe('workspace package script policy', () => {
|
|
|
352
348
|
});
|
|
353
349
|
try {
|
|
354
350
|
await writeJson(join(root, 'packages/native/tsconfig.lib.json'), {});
|
|
355
|
-
await writeFile(
|
|
356
|
-
join(root, 'packages/native/build.zig'),
|
|
357
|
-
'pub fn build(b: *std.Build) void { _ = b.step("wasm", "Build wasm"); }\n',
|
|
358
|
-
);
|
|
359
351
|
const resolvedTargetsByProject = new Map([
|
|
360
352
|
[
|
|
361
353
|
'native',
|
|
362
|
-
{ targets: new Set(['build', 'tsc-js', '
|
|
354
|
+
{ targets: new Set(['build', 'tsc-js', 'tsdown-js']), buildDependsOn: ['^build', 'tsc-js', 'tsdown-js'] },
|
|
363
355
|
],
|
|
364
356
|
]);
|
|
365
357
|
|
|
@@ -369,7 +361,7 @@ describe('workspace package script policy', () => {
|
|
|
369
361
|
expect(native.nx).toEqual({
|
|
370
362
|
name: 'native',
|
|
371
363
|
targets: {
|
|
372
|
-
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', '
|
|
364
|
+
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', 'tsdown-js', 'custom'] },
|
|
373
365
|
},
|
|
374
366
|
});
|
|
375
367
|
} finally {
|
|
@@ -389,8 +381,8 @@ describe('workspace package script policy', () => {
|
|
|
389
381
|
targets: {
|
|
390
382
|
build: {
|
|
391
383
|
executor: 'nx:run-commands',
|
|
392
|
-
options: { command: '
|
|
393
|
-
dependsOn: ['^build', '
|
|
384
|
+
options: { command: 'tsdown', cwd: '{projectRoot}' },
|
|
385
|
+
dependsOn: ['^build', 'tsdown-js'],
|
|
394
386
|
},
|
|
395
387
|
},
|
|
396
388
|
},
|
|
@@ -398,12 +390,8 @@ describe('workspace package script policy', () => {
|
|
|
398
390
|
],
|
|
399
391
|
});
|
|
400
392
|
try {
|
|
401
|
-
await writeFile(
|
|
402
|
-
join(root, 'packages/native/build.zig'),
|
|
403
|
-
'pub fn build(b: *std.Build) void { _ = b.step("wasm", "Build wasm"); }\n',
|
|
404
|
-
);
|
|
405
393
|
const resolvedTargetsByProject = new Map([
|
|
406
|
-
['native', { targets: new Set(['build', '
|
|
394
|
+
['native', { targets: new Set(['build', 'tsdown-js']), buildDependsOn: ['^build', 'tsdown-js'] }],
|
|
407
395
|
]);
|
|
408
396
|
|
|
409
397
|
applyWorkspaceDependencyDefaults(root, { resolvedTargetsByProject });
|
|
@@ -414,8 +402,8 @@ describe('workspace package script policy', () => {
|
|
|
414
402
|
targets: {
|
|
415
403
|
build: {
|
|
416
404
|
executor: 'nx:run-commands',
|
|
417
|
-
options: { command: '
|
|
418
|
-
dependsOn: ['^build', '
|
|
405
|
+
options: { command: 'tsdown', cwd: '{projectRoot}' },
|
|
406
|
+
dependsOn: ['^build', 'tsdown-js'],
|
|
419
407
|
},
|
|
420
408
|
},
|
|
421
409
|
});
|
|
@@ -434,7 +422,7 @@ describe('workspace package script policy', () => {
|
|
|
434
422
|
nx: {
|
|
435
423
|
name: 'native',
|
|
436
424
|
targets: {
|
|
437
|
-
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', '
|
|
425
|
+
build: { executor: 'nx:noop', dependsOn: ['^build', 'tsc-js', 'tsdown-js'] },
|
|
438
426
|
},
|
|
439
427
|
},
|
|
440
428
|
},
|
|
@@ -444,7 +432,7 @@ describe('workspace package script policy', () => {
|
|
|
444
432
|
const resolvedTargetsByProject = new Map([
|
|
445
433
|
[
|
|
446
434
|
'native',
|
|
447
|
-
{ targets: new Set(['build', 'tsc-js', '
|
|
435
|
+
{ targets: new Set(['build', 'tsc-js', 'tsdown-js']), buildDependsOn: ['^build', 'tsc-js', 'tsdown-js'] },
|
|
448
436
|
],
|
|
449
437
|
]);
|
|
450
438
|
|
|
@@ -498,7 +486,7 @@ describe('workspace package script policy', () => {
|
|
|
498
486
|
});
|
|
499
487
|
try {
|
|
500
488
|
const resolvedTargetsByProject = new Map([
|
|
501
|
-
['native', { targets: new Set(['build', 'tsc-js', '
|
|
489
|
+
['native', { targets: new Set(['build', 'tsc-js', 'tsdown-js']), buildDependsOn: buildOutputDependencies }],
|
|
502
490
|
]);
|
|
503
491
|
|
|
504
492
|
applyWorkspaceDependencyDefaults(root, { resolvedTargetsByProject });
|
|
@@ -558,20 +546,6 @@ describe('workspace package script policy', () => {
|
|
|
558
546
|
}
|
|
559
547
|
});
|
|
560
548
|
|
|
561
|
-
it('rejects build.zig without steps', async () => {
|
|
562
|
-
const root = await createWorkspace({
|
|
563
|
-
rootName: '@smoothbricks/codebase',
|
|
564
|
-
packages: [{ dir: 'native', name: '@smoothbricks/native', nx: { name: 'native' } }],
|
|
565
|
-
});
|
|
566
|
-
try {
|
|
567
|
-
await writeFile(join(root, 'packages/native/build.zig'), 'pub fn build(b: *std.Build) void { _ = b; }\n');
|
|
568
|
-
|
|
569
|
-
expect(validateWorkspaceDependencies(root)).toBe(1);
|
|
570
|
-
} finally {
|
|
571
|
-
await rm(root, { recursive: true, force: true });
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
|
|
575
549
|
it('rejects old test tsconfig output for packages with test runners', async () => {
|
|
576
550
|
const root = await createWorkspace({
|
|
577
551
|
rootName: '@smoothbricks/codebase',
|
|
@@ -728,17 +702,13 @@ describe('workspace package script policy', () => {
|
|
|
728
702
|
}
|
|
729
703
|
});
|
|
730
704
|
|
|
731
|
-
it('accepts noEmit test tsconfig
|
|
705
|
+
it('accepts a noEmit test tsconfig', async () => {
|
|
732
706
|
const root = await createWorkspace({
|
|
733
707
|
rootName: '@smoothbricks/codebase',
|
|
734
708
|
packages: [{ dir: 'native', name: '@smoothbricks/native', nx: { name: 'native', targets: { lint: {} } } }],
|
|
735
709
|
});
|
|
736
710
|
try {
|
|
737
711
|
await writeJson(join(root, 'packages/native/tsconfig.test.json'), { compilerOptions: { noEmit: true } });
|
|
738
|
-
await writeFile(
|
|
739
|
-
join(root, 'packages/native/build.zig'),
|
|
740
|
-
'pub fn build(b: *std.Build) void { _ = b.step("build", "Build native artifact"); }\n',
|
|
741
|
-
);
|
|
742
712
|
|
|
743
713
|
expect(validateWorkspaceDependencies(root)).toBe(0);
|
|
744
714
|
} finally {
|