@stacksjs/actions 0.70.165 → 0.70.166
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/upgrade/framework.js +2 -22
- package/package.json +17 -18
- package/dist/upgrade/catalog.d.ts +0 -60
- package/dist/upgrade/catalog.js +0 -113
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
writeChannel,
|
|
27
27
|
writeSyncedVersion
|
|
28
28
|
} from "./framework-utils";
|
|
29
|
-
import { reconcileWorkspaceCatalog } from "./catalog";
|
|
30
29
|
import {
|
|
31
30
|
detectDependencyInstaller,
|
|
32
31
|
resolveDependencyRefreshCommand,
|
|
@@ -139,7 +138,7 @@ for (const { managed, summary } of perPath)
|
|
|
139
138
|
const runHooks = !options.noPostinstall && options.postinstall !== !1;
|
|
140
139
|
if (runHooks)
|
|
141
140
|
try {
|
|
142
|
-
await runPostSyncHooks({ aggregate, perPath, projectRoot, alreadyRestarted
|
|
141
|
+
await runPostSyncHooks({ aggregate, perPath, projectRoot, alreadyRestarted });
|
|
143
142
|
} catch (err) {
|
|
144
143
|
console.error(`Post-sync hooks failed: ${err?.message || err}`);
|
|
145
144
|
process.exit(ExitCode.FatalError);
|
|
@@ -417,7 +416,7 @@ async function syncRootFilesFromGitHub(ref) {
|
|
|
417
416
|
}
|
|
418
417
|
}
|
|
419
418
|
async function runPostSyncHooks(args) {
|
|
420
|
-
const { aggregate, perPath, projectRoot, alreadyRestarted
|
|
419
|
+
const { aggregate, perPath, projectRoot, alreadyRestarted } = args, changeCount = aggregate.added + aggregate.changed + aggregate.removed;
|
|
421
420
|
if (!shouldRunPostSyncHooks(changeCount, alreadyRestarted)) {
|
|
422
421
|
console.log("Nothing changed \u2014 skipping post-sync hooks.");
|
|
423
422
|
return;
|
|
@@ -429,25 +428,6 @@ async function runPostSyncHooks(args) {
|
|
|
429
428
|
} catch (err) {
|
|
430
429
|
console.warn(` auto-imports failed (non-fatal): ${err?.message || err}`);
|
|
431
430
|
}
|
|
432
|
-
console.log("Reconciling workspace dependency catalog...");
|
|
433
|
-
try {
|
|
434
|
-
const result = await reconcileWorkspaceCatalog({
|
|
435
|
-
projectRoot,
|
|
436
|
-
frameworkRoot: join(projectRoot, "storage", "framework"),
|
|
437
|
-
localStacksRoot,
|
|
438
|
-
ref
|
|
439
|
-
});
|
|
440
|
-
if (!result)
|
|
441
|
-
console.log(" catalog: nothing to reconcile");
|
|
442
|
-
else if (result.added.length || result.updated.length)
|
|
443
|
-
console.log(` catalog: +${result.added.length} added, ~${result.updated.length} updated`);
|
|
444
|
-
else
|
|
445
|
-
console.log(" catalog: up to date");
|
|
446
|
-
if (result?.missing.length)
|
|
447
|
-
console.warn(` catalog: no upstream version for ${result.missing.join(", ")}`);
|
|
448
|
-
} catch (err) {
|
|
449
|
-
console.warn(` catalog reconcile failed (non-fatal): ${err?.message || err}`);
|
|
450
|
-
}
|
|
451
431
|
if (shouldRefreshPostSyncDependencies(perPath.some((entry) => {
|
|
452
432
|
const { managed, summary } = entry;
|
|
453
433
|
if (managed.isFile)
|
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.166",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -62,32 +62,31 @@
|
|
|
62
62
|
"prepublishOnly": "bun run build"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@stacksjs/config": "0.70.
|
|
65
|
+
"@stacksjs/config": "0.70.166",
|
|
66
66
|
"@stacksjs/bumpx": "^0.2.6",
|
|
67
67
|
"@stacksjs/bunpress": "^0.1.18",
|
|
68
68
|
"@stacksjs/logsmith": "^0.2.3",
|
|
69
|
-
"@stacksjs/registry": "0.70.
|
|
69
|
+
"@stacksjs/registry": "0.70.166",
|
|
70
70
|
"@stacksjs/ts-cloud": "^0.7.60",
|
|
71
71
|
"@stacksjs/ts-md": "^0.1.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@stacksjs/api": "0.70.
|
|
75
|
-
"@stacksjs/cli": "0.70.
|
|
76
|
-
"@stacksjs/
|
|
77
|
-
"@stacksjs/database": "0.70.165",
|
|
74
|
+
"@stacksjs/api": "0.70.166",
|
|
75
|
+
"@stacksjs/cli": "0.70.166",
|
|
76
|
+
"@stacksjs/database": "0.70.166",
|
|
78
77
|
"@stacksjs/tlsx": "^0.13.2",
|
|
79
78
|
"better-dx": "^0.2.17",
|
|
80
|
-
"@stacksjs/dns": "0.70.
|
|
81
|
-
"@stacksjs/enums": "0.70.
|
|
82
|
-
"@stacksjs/env": "0.70.
|
|
83
|
-
"@stacksjs/error-handling": "0.70.
|
|
84
|
-
"@stacksjs/logging": "0.70.
|
|
85
|
-
"@stacksjs/path": "0.70.
|
|
86
|
-
"@stacksjs/security": "0.70.
|
|
87
|
-
"@stacksjs/storage": "0.70.
|
|
88
|
-
"@stacksjs/strings": "0.70.
|
|
89
|
-
"@stacksjs/utils": "0.70.
|
|
90
|
-
"@stacksjs/validation": "0.70.
|
|
79
|
+
"@stacksjs/dns": "0.70.166",
|
|
80
|
+
"@stacksjs/enums": "0.70.166",
|
|
81
|
+
"@stacksjs/env": "0.70.166",
|
|
82
|
+
"@stacksjs/error-handling": "0.70.166",
|
|
83
|
+
"@stacksjs/logging": "0.70.166",
|
|
84
|
+
"@stacksjs/path": "0.70.166",
|
|
85
|
+
"@stacksjs/security": "0.70.166",
|
|
86
|
+
"@stacksjs/storage": "0.70.166",
|
|
87
|
+
"@stacksjs/strings": "0.70.166",
|
|
88
|
+
"@stacksjs/utils": "0.70.166",
|
|
89
|
+
"@stacksjs/validation": "0.70.166"
|
|
91
90
|
},
|
|
92
91
|
"peerDependencies": {
|
|
93
92
|
"pickier": "^0.1.35"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every dependency name a manifest pins to `catalog:`.
|
|
3
|
-
*
|
|
4
|
-
* Bun also accepts the named form (`catalog:react19`); those resolve from a
|
|
5
|
-
* separate `catalogs` map rather than the default catalog, so we deliberately
|
|
6
|
-
* match only the bare default protocol here.
|
|
7
|
-
*/
|
|
8
|
-
export declare function collectCatalogReferences(manifests: PackageManifest[]): string[];
|
|
9
|
-
/**
|
|
10
|
-
* Read a catalog off a manifest, accepting either shape Bun supports: a
|
|
11
|
-
* top-level `catalog` field, or `workspaces.catalog` on the object form.
|
|
12
|
-
*/
|
|
13
|
-
export declare function readCatalogField(manifest: PackageManifest | null | undefined): Record<string, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Merge the upstream catalog into the app's own, restricted to what the
|
|
16
|
-
* vendored tree references.
|
|
17
|
-
*
|
|
18
|
-
* User-authored entries survive untouched: we only write keys that appear in
|
|
19
|
-
* `referenced`, so a catalog entry the app added for its own packages is never
|
|
20
|
-
* clobbered by an upgrade.
|
|
21
|
-
*/
|
|
22
|
-
export declare function mergeCatalog(current: Record<string, string>, upstream: Record<string, string>, referenced: string[]): CatalogMergeResult;
|
|
23
|
-
/** Parse a `package.json`, returning null rather than throwing on bad input. */
|
|
24
|
-
export declare function readManifest(path: string): PackageManifest | null;
|
|
25
|
-
/**
|
|
26
|
-
* Walk a synced tree for workspace manifests. Depth is bounded because the
|
|
27
|
-
* framework nests packages at most a few levels deep, and an unbounded walk
|
|
28
|
-
* over a vendored tree is needlessly expensive on every upgrade.
|
|
29
|
-
*/
|
|
30
|
-
export declare function findWorkspaceManifests(root: string, maxDepth?: number): string[];
|
|
31
|
-
/**
|
|
32
|
-
* Fetch the upstream catalog for a GitHub-sourced upgrade.
|
|
33
|
-
*
|
|
34
|
-
* We hit the raw root manifest directly rather than re-downloading a tarball
|
|
35
|
-
* we've already extracted the interesting parts of. Failure is non-fatal: the
|
|
36
|
-
* caller falls back to leaving the existing catalog alone.
|
|
37
|
-
*/
|
|
38
|
-
export declare function fetchUpstreamCatalog(ref: string): Promise<Record<string, string>>;
|
|
39
|
-
/**
|
|
40
|
-
* Mirror the upstream catalog into the app's root manifest so the vendored
|
|
41
|
-
* workspace members resolve. Returns null when there is nothing to do.
|
|
42
|
-
*/
|
|
43
|
-
export declare function reconcileWorkspaceCatalog(options: ReconcileCatalogOptions): Promise<CatalogMergeResult | null>;
|
|
44
|
-
export declare interface PackageManifest {
|
|
45
|
-
catalog?: Record<string, string>
|
|
46
|
-
workspaces?: string[] | { catalog?: Record<string, string> }
|
|
47
|
-
[field: string]: unknown
|
|
48
|
-
}
|
|
49
|
-
export declare interface CatalogMergeResult {
|
|
50
|
-
catalog: Record<string, string>
|
|
51
|
-
added: string[]
|
|
52
|
-
updated: string[]
|
|
53
|
-
missing: string[]
|
|
54
|
-
}
|
|
55
|
-
export declare interface ReconcileCatalogOptions {
|
|
56
|
-
projectRoot: string
|
|
57
|
-
frameworkRoot: string
|
|
58
|
-
localStacksRoot?: string | null
|
|
59
|
-
ref?: string
|
|
60
|
-
}
|
package/dist/upgrade/catalog.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
const CATALOG_PROTOCOL = "catalog:", DEPENDENCY_FIELDS = [
|
|
4
|
-
"dependencies",
|
|
5
|
-
"devDependencies",
|
|
6
|
-
"peerDependencies",
|
|
7
|
-
"optionalDependencies"
|
|
8
|
-
], MANIFEST_SCAN_SKIP = new Set(["node_modules", "dist", ".git", ".cache", "cache"]);
|
|
9
|
-
export function collectCatalogReferences(manifests) {
|
|
10
|
-
const names = new Set;
|
|
11
|
-
for (const manifest of manifests)
|
|
12
|
-
for (const field of DEPENDENCY_FIELDS) {
|
|
13
|
-
const deps = manifest[field];
|
|
14
|
-
if (!deps || typeof deps !== "object")
|
|
15
|
-
continue;
|
|
16
|
-
for (const [name, range] of Object.entries(deps))
|
|
17
|
-
if (range === CATALOG_PROTOCOL)
|
|
18
|
-
names.add(name);
|
|
19
|
-
}
|
|
20
|
-
return [...names].sort();
|
|
21
|
-
}
|
|
22
|
-
export function readCatalogField(manifest) {
|
|
23
|
-
if (!manifest)
|
|
24
|
-
return {};
|
|
25
|
-
if (manifest.catalog && typeof manifest.catalog === "object")
|
|
26
|
-
return { ...manifest.catalog };
|
|
27
|
-
const workspaces = manifest.workspaces;
|
|
28
|
-
if (workspaces && !Array.isArray(workspaces) && workspaces.catalog)
|
|
29
|
-
return { ...workspaces.catalog };
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
export function mergeCatalog(current, upstream, referenced) {
|
|
33
|
-
const catalog = { ...current }, added = [], updated = [], missing = [];
|
|
34
|
-
for (const name of referenced) {
|
|
35
|
-
const version = upstream[name];
|
|
36
|
-
if (!version) {
|
|
37
|
-
if (!(name in catalog))
|
|
38
|
-
missing.push(name);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (!(name in catalog)) {
|
|
42
|
-
catalog[name] = version;
|
|
43
|
-
added.push(name);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (catalog[name] !== version) {
|
|
47
|
-
catalog[name] = version;
|
|
48
|
-
updated.push(name);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return { catalog: sortKeys(catalog), added, updated, missing };
|
|
52
|
-
}
|
|
53
|
-
function sortKeys(record) {
|
|
54
|
-
return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)));
|
|
55
|
-
}
|
|
56
|
-
export function readManifest(path) {
|
|
57
|
-
try {
|
|
58
|
-
if (!existsSync(path))
|
|
59
|
-
return null;
|
|
60
|
-
return JSON.parse(readFileSync(path, "utf-8"));
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export function findWorkspaceManifests(root, maxDepth = 4) {
|
|
66
|
-
const found = [], walk = (dir, depth) => {
|
|
67
|
-
if (depth > maxDepth || !existsSync(dir))
|
|
68
|
-
return;
|
|
69
|
-
const manifest = join(dir, "package.json");
|
|
70
|
-
if (existsSync(manifest))
|
|
71
|
-
found.push(manifest);
|
|
72
|
-
let entries;
|
|
73
|
-
try {
|
|
74
|
-
entries = readdirSync(dir, { withFileTypes: !0 });
|
|
75
|
-
} catch {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
if (!entry.isDirectory())
|
|
80
|
-
continue;
|
|
81
|
-
if (entry.name.startsWith(".") || MANIFEST_SCAN_SKIP.has(entry.name))
|
|
82
|
-
continue;
|
|
83
|
-
walk(join(dir, entry.name), depth + 1);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
walk(root, 0);
|
|
87
|
-
return found;
|
|
88
|
-
}
|
|
89
|
-
export async function fetchUpstreamCatalog(ref) {
|
|
90
|
-
try {
|
|
91
|
-
const response = await fetch(`https://raw.githubusercontent.com/stacksjs/stacks/${ref}/package.json`);
|
|
92
|
-
if (!response.ok)
|
|
93
|
-
return {};
|
|
94
|
-
return readCatalogField(await response.json());
|
|
95
|
-
} catch {
|
|
96
|
-
return {};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export async function reconcileWorkspaceCatalog(options) {
|
|
100
|
-
const rootManifestPath = join(options.projectRoot, "package.json"), rootManifest = readManifest(rootManifestPath);
|
|
101
|
-
if (!rootManifest)
|
|
102
|
-
return null;
|
|
103
|
-
const manifests = findWorkspaceManifests(options.frameworkRoot).map(readManifest).filter((manifest) => manifest !== null), referenced = collectCatalogReferences(manifests);
|
|
104
|
-
if (referenced.length === 0)
|
|
105
|
-
return null;
|
|
106
|
-
const upstream = options.localStacksRoot ? readCatalogField(readManifest(join(options.localStacksRoot, "package.json"))) : await fetchUpstreamCatalog(options.ref || "main"), result = mergeCatalog(readCatalogField(rootManifest), upstream, referenced);
|
|
107
|
-
if (result.added.length === 0 && result.updated.length === 0)
|
|
108
|
-
return result;
|
|
109
|
-
rootManifest.catalog = result.catalog;
|
|
110
|
-
await Bun.write(rootManifestPath, `${JSON.stringify(rootManifest, null, 2)}
|
|
111
|
-
`);
|
|
112
|
-
return result;
|
|
113
|
-
}
|