@stacksjs/actions 0.70.153 → 0.70.155
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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the migration hook after a vendored framework upgrade.
|
|
3
|
+
*
|
|
4
|
+
* The upgrade command is already an explicit request to install and activate
|
|
5
|
+
* the new framework. Its nested migration must therefore never open a second
|
|
6
|
+
* confirmation prompt. Ignoring stdin makes that contract structural, while
|
|
7
|
+
* `--force` bypasses both migration confirmation gates. A nonzero exit is a
|
|
8
|
+
* real upgrade failure so callers cannot report success with an unapplied
|
|
9
|
+
* schema.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runPostSyncMigration(options: PostSyncMigrationOptions): Promise<void>;
|
|
12
|
+
declare interface PostSyncSpawnOptions {
|
|
13
|
+
cmd: string[]
|
|
14
|
+
cwd: string
|
|
15
|
+
stdin: 'ignore'
|
|
16
|
+
stdout: 'inherit'
|
|
17
|
+
stderr: 'inherit'
|
|
18
|
+
}
|
|
19
|
+
declare interface PostSyncMigrationOptions {
|
|
20
|
+
bunExecutable: string
|
|
21
|
+
migrateScript: string
|
|
22
|
+
projectRoot: string
|
|
23
|
+
spawn: PostSyncSpawn
|
|
24
|
+
}
|
|
25
|
+
declare type PostSyncSpawn = (options: PostSyncSpawnOptions) => { exited: Promise<number> }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export async function runPostSyncMigration(options) {
|
|
2
|
+
const code = await options.spawn({
|
|
3
|
+
cmd: [options.bunExecutable, options.migrateScript, "migrate", "--force"],
|
|
4
|
+
cwd: options.projectRoot,
|
|
5
|
+
stdin: "ignore",
|
|
6
|
+
stdout: "inherit",
|
|
7
|
+
stderr: "inherit"
|
|
8
|
+
}).exited;
|
|
9
|
+
if (code !== 0)
|
|
10
|
+
throw Error(`Post-upgrade migration exited with code ${code}.`);
|
|
11
|
+
}
|
|
@@ -43,6 +43,14 @@ export declare function readSyncedVersion(versionFilePath: string): SyncedVersio
|
|
|
43
43
|
* Persist the last-synced channel + sha to `.stacks-version`.
|
|
44
44
|
*/
|
|
45
45
|
export declare function writeSyncedVersion(versionFilePath: string, ch: 'stable' | 'canary', sha: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Decide whether the upgrade must protect framework-managed paths from local
|
|
48
|
+
* edits. The initial process always owns this preflight unless the user passed
|
|
49
|
+
* `--force`. An internal restart runs only after that validated parent has
|
|
50
|
+
* intentionally replaced those paths, so checking again would reject the
|
|
51
|
+
* upgrade's own writes as if they belonged to the user.
|
|
52
|
+
*/
|
|
53
|
+
export declare function shouldCheckDirtyManagedPaths(args: { force: boolean, alreadyRestarted: boolean }): boolean;
|
|
46
54
|
/**
|
|
47
55
|
* Pure decision for the "already up to date" short-circuit. Returns true only
|
|
48
56
|
* when a sync can be safely skipped: no override flags, not a pinned version,
|
|
@@ -53,6 +53,9 @@ export function writeSyncedVersion(versionFilePath, ch, sha) {
|
|
|
53
53
|
writeFileSync(versionFilePath, `${ch} ${sha}`, "utf-8");
|
|
54
54
|
} catch {}
|
|
55
55
|
}
|
|
56
|
+
export function shouldCheckDirtyManagedPaths(args) {
|
|
57
|
+
return !args.force && !args.alreadyRestarted;
|
|
58
|
+
}
|
|
56
59
|
export function shouldShortCircuit(args) {
|
|
57
60
|
const { force, targetVersion, remoteSha, synced, channel } = args;
|
|
58
61
|
if (force || targetVersion)
|
|
@@ -19,11 +19,13 @@ import {
|
|
|
19
19
|
resolveUpgradeContext,
|
|
20
20
|
resolveUpgradeMessage,
|
|
21
21
|
shouldAutoDetectLocalStacks,
|
|
22
|
+
shouldCheckDirtyManagedPaths,
|
|
22
23
|
shouldShortCircuit,
|
|
23
24
|
snapshotTree,
|
|
24
25
|
writeChannel,
|
|
25
26
|
writeSyncedVersion
|
|
26
27
|
} from "./framework-utils";
|
|
28
|
+
import { runPostSyncMigration } from "./framework-hooks";
|
|
27
29
|
const options = parseOptions(), projectRoot = p.projectPath();
|
|
28
30
|
if (!existsSync(p.projectPath("storage/framework/core"))) {
|
|
29
31
|
const { upgradeStacksPackages } = await import("./packages");
|
|
@@ -43,7 +45,8 @@ if (options.dryRun) {
|
|
|
43
45
|
await runDryRunPreview();
|
|
44
46
|
process.exit(ExitCode.Success);
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
const alreadyRestarted = process.argv.includes("--__restarted");
|
|
49
|
+
if (shouldCheckDirtyManagedPaths({ force: !!options.force, alreadyRestarted })) {
|
|
47
50
|
const dirty = await detectDirtyManagedPaths(projectRoot);
|
|
48
51
|
if (dirty.length > 0) {
|
|
49
52
|
console.warn(`
|
|
@@ -90,7 +93,7 @@ try {
|
|
|
90
93
|
console.error("\u2718 Failed to upgrade Stacks framework:", err?.message || err);
|
|
91
94
|
process.exit(ExitCode.FatalError);
|
|
92
95
|
}
|
|
93
|
-
const newVersion = readVersion(corePkgPath), ownHashAfter = await hashFileOrZero(ownPath)
|
|
96
|
+
const newVersion = readVersion(corePkgPath), ownHashAfter = await hashFileOrZero(ownPath);
|
|
94
97
|
if (ownHashBefore !== 0n && ownHashAfter !== 0n && ownHashBefore !== ownHashAfter && !alreadyRestarted) {
|
|
95
98
|
console.log(`Upgrade pulled a newer version of the upgrade action \u2014 re-running once to pick up new sync paths and hooks.
|
|
96
99
|
`);
|
|
@@ -121,7 +124,12 @@ for (const { managed, summary } of perPath)
|
|
|
121
124
|
console.log(` ${managed.label.padEnd(10)} +${summary.added} ~${summary.changed} -${summary.removed} (${summary.unchanged} unchanged)`);
|
|
122
125
|
const runHooks = !options.noPostinstall && options.postinstall !== !1;
|
|
123
126
|
if (runHooks)
|
|
124
|
-
|
|
127
|
+
try {
|
|
128
|
+
await runPostSyncHooks({ aggregate, perPath, projectRoot });
|
|
129
|
+
} catch (err) {
|
|
130
|
+
console.error(`Post-sync hooks failed: ${err?.message || err}`);
|
|
131
|
+
process.exit(ExitCode.FatalError);
|
|
132
|
+
}
|
|
125
133
|
if (ctx.channel === "canary" && !ctx.targetVersion)
|
|
126
134
|
console.warn("\u26A0 Canary builds may contain bugs or breaking changes. Not recommended for production.");
|
|
127
135
|
process.exit(ExitCode.Success);
|
|
@@ -426,18 +434,13 @@ async function runPostSyncHooks(args) {
|
|
|
426
434
|
const migrationsDir = join(projectRoot, "database", "migrations");
|
|
427
435
|
if (existsSync(migrationsDir)) {
|
|
428
436
|
console.log("Running pending migrations...");
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (code !== 0)
|
|
437
|
-
console.warn(` migrate exited with code ${code} (non-fatal \u2014 DB may not be set up yet)`);
|
|
438
|
-
} catch (err) {
|
|
439
|
-
console.warn(` migrate failed (non-fatal): ${err?.message || err}`);
|
|
440
|
-
}
|
|
437
|
+
const migrateScript = p.frameworkPath("core/buddy/src/cli.ts");
|
|
438
|
+
await runPostSyncMigration({
|
|
439
|
+
bunExecutable: process.argv[0] || "bun",
|
|
440
|
+
migrateScript,
|
|
441
|
+
projectRoot,
|
|
442
|
+
spawn: (spawnOptions) => Bun.spawn(spawnOptions)
|
|
443
|
+
});
|
|
441
444
|
}
|
|
442
445
|
}
|
|
443
446
|
function pkgJsonInTree(dir) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.155",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"prepublishOnly": "bun run build"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@stacksjs/config": "0.70.
|
|
65
|
+
"@stacksjs/config": "0.70.155",
|
|
66
66
|
"@stacksjs/bumpx": "^0.2.6",
|
|
67
67
|
"@stacksjs/bunpress": "^0.1.12",
|
|
68
68
|
"@stacksjs/logsmith": "^0.2.3",
|
|
@@ -70,23 +70,23 @@
|
|
|
70
70
|
"@stacksjs/ts-md": "^0.1.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@stacksjs/api": "0.70.
|
|
74
|
-
"@stacksjs/cli": "0.70.
|
|
75
|
-
"@stacksjs/config": "0.70.
|
|
76
|
-
"@stacksjs/database": "0.70.
|
|
73
|
+
"@stacksjs/api": "0.70.155",
|
|
74
|
+
"@stacksjs/cli": "0.70.155",
|
|
75
|
+
"@stacksjs/config": "0.70.155",
|
|
76
|
+
"@stacksjs/database": "0.70.155",
|
|
77
77
|
"@stacksjs/tlsx": "^0.13.2",
|
|
78
78
|
"better-dx": "^0.2.17",
|
|
79
|
-
"@stacksjs/dns": "0.70.
|
|
80
|
-
"@stacksjs/enums": "0.70.
|
|
81
|
-
"@stacksjs/env": "0.70.
|
|
82
|
-
"@stacksjs/error-handling": "0.70.
|
|
83
|
-
"@stacksjs/logging": "0.70.
|
|
84
|
-
"@stacksjs/path": "0.70.
|
|
85
|
-
"@stacksjs/security": "0.70.
|
|
86
|
-
"@stacksjs/storage": "0.70.
|
|
87
|
-
"@stacksjs/strings": "0.70.
|
|
88
|
-
"@stacksjs/utils": "0.70.
|
|
89
|
-
"@stacksjs/validation": "0.70.
|
|
79
|
+
"@stacksjs/dns": "0.70.155",
|
|
80
|
+
"@stacksjs/enums": "0.70.155",
|
|
81
|
+
"@stacksjs/env": "0.70.155",
|
|
82
|
+
"@stacksjs/error-handling": "0.70.155",
|
|
83
|
+
"@stacksjs/logging": "0.70.155",
|
|
84
|
+
"@stacksjs/path": "0.70.155",
|
|
85
|
+
"@stacksjs/security": "0.70.155",
|
|
86
|
+
"@stacksjs/storage": "0.70.155",
|
|
87
|
+
"@stacksjs/strings": "0.70.155",
|
|
88
|
+
"@stacksjs/utils": "0.70.155",
|
|
89
|
+
"@stacksjs/validation": "0.70.155"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"pickier": "^0.1.35"
|