@stacksjs/actions 0.70.206 → 0.70.208

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,33 @@
1
+ /**
2
+ * Refresh the package-managed app scaffold from the installed
3
+ * `@stacksjs/defaults` package.
4
+ */
5
+ export declare function syncPackageProjectFiles(projectRoot: string, defaultsPackageRoot: string, options?: PackageProjectOptions): ProjectStructureChange[];
6
+ /**
7
+ * Remove assumptions that only hold when `storage/framework/core` is a
8
+ * workspace and point project scripts at the npm-backed launcher.
9
+ */
10
+ export declare function migratePackageProjectManifest(pkg: ProjectPackageJson): ProjectStructureChange[];
11
+ /**
12
+ * Preserve an app's TypeScript overrides while moving the legacy vendored-core
13
+ * base config to the package-compatible app config.
14
+ */
15
+ export declare function migratePackageProjectTsconfig(projectRoot: string, options?: PackageProjectOptions): ProjectStructureChange[];
16
+ /**
17
+ * Infer only providers a project already uses, plus Codex so the canonical
18
+ * AGENTS.md is always present after an update.
19
+ */
20
+ export declare function detectProjectAiProviders(projectRoot: string): DetectedAiProvider[];
21
+ export declare interface ProjectStructureChange {
22
+ path: string
23
+ action: 'add' | 'update' | 'remove'
24
+ }
25
+ declare interface PackageProjectOptions {
26
+ dryRun?: boolean
27
+ }
28
+ declare interface ProjectPackageJson {
29
+ scripts?: Record<string, string>
30
+ workspaces?: string[]
31
+ [key: string]: unknown
32
+ }
33
+ export type DetectedAiProvider = 'claude' | 'codex' | 'cursor' | 'copilot' | 'gemini';
@@ -0,0 +1,138 @@
1
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, relative } from "node:path";
3
+ const DEFAULTS_PACKAGE_IGNORES = new Set([
4
+ "README.md",
5
+ "build.ts",
6
+ "node_modules",
7
+ "package.json",
8
+ "project",
9
+ "tests"
10
+ ]), LOCAL_DEFAULT_IGNORES = new Set([
11
+ ".DS_Store",
12
+ ".discovered-models.json",
13
+ "dist",
14
+ "node_modules"
15
+ ]), SUPPORT_FILES = [
16
+ { source: "project/buddy", target: "buddy", executable: !0 },
17
+ { source: "project/bootstrap", target: "bootstrap", executable: !0 },
18
+ {
19
+ source: "project/storage/framework/tsconfig.app.json",
20
+ target: "storage/framework/tsconfig.app.json"
21
+ },
22
+ {
23
+ source: "project/storage/framework/tsconfig.base.json",
24
+ target: "storage/framework/tsconfig.base.json"
25
+ }
26
+ ];
27
+ function sameFile(left, right) {
28
+ if (!existsSync(left) || !existsSync(right))
29
+ return !1;
30
+ const leftStat = statSync(left), rightStat = statSync(right);
31
+ if (leftStat.size !== rightStat.size)
32
+ return !1;
33
+ return readFileSync(left).equals(readFileSync(right));
34
+ }
35
+ function copyFileIfChanged(source, target, projectRoot, changes, options, executable = !1) {
36
+ if (sameFile(source, target)) {
37
+ if (executable && !options.dryRun)
38
+ chmodSync(target, 493);
39
+ return;
40
+ }
41
+ changes.push({
42
+ path: relative(projectRoot, target),
43
+ action: existsSync(target) ? "update" : "add"
44
+ });
45
+ if (options.dryRun)
46
+ return;
47
+ mkdirSync(dirname(target), { recursive: !0 });
48
+ writeFileSync(target, readFileSync(source));
49
+ if (executable)
50
+ chmodSync(target, 493);
51
+ }
52
+ function syncDirectory(source, target, projectRoot, changes, options, isRoot = !1) {
53
+ if (!options.dryRun)
54
+ mkdirSync(target, { recursive: !0 });
55
+ const sourceEntries = new Set;
56
+ for (const entry of readdirSync(source)) {
57
+ if (isRoot && DEFAULTS_PACKAGE_IGNORES.has(entry))
58
+ continue;
59
+ sourceEntries.add(entry);
60
+ const sourcePath = join(source, entry), targetPath = join(target, entry);
61
+ if (lstatSync(sourcePath).isDirectory()) {
62
+ syncDirectory(sourcePath, targetPath, projectRoot, changes, options);
63
+ continue;
64
+ }
65
+ copyFileIfChanged(sourcePath, targetPath, projectRoot, changes, options);
66
+ }
67
+ if (!existsSync(target))
68
+ return;
69
+ for (const entry of readdirSync(target)) {
70
+ if (LOCAL_DEFAULT_IGNORES.has(entry) || sourceEntries.has(entry))
71
+ continue;
72
+ const targetPath = join(target, entry);
73
+ changes.push({ path: relative(projectRoot, targetPath), action: "remove" });
74
+ if (!options.dryRun)
75
+ rmSync(targetPath, { recursive: !0, force: !0 });
76
+ }
77
+ }
78
+ export function syncPackageProjectFiles(projectRoot, defaultsPackageRoot, options = {}) {
79
+ const changes = [], targetDefaults = join(projectRoot, "storage/framework/defaults");
80
+ syncDirectory(defaultsPackageRoot, targetDefaults, projectRoot, changes, options, !0);
81
+ for (const file of SUPPORT_FILES) {
82
+ const source = join(defaultsPackageRoot, file.source);
83
+ if (!existsSync(source))
84
+ continue;
85
+ copyFileIfChanged(source, join(projectRoot, file.target), projectRoot, changes, options, file.executable);
86
+ }
87
+ return changes;
88
+ }
89
+ export function migratePackageProjectManifest(pkg) {
90
+ const changes = [], scripts = pkg.scripts ?? {}, setScript = (name, value) => {
91
+ if (scripts[name] === value)
92
+ return;
93
+ scripts[name] = value;
94
+ changes.push({ path: `package.json#scripts.${name}`, action: "update" });
95
+ };
96
+ setScript("buddy", "./buddy");
97
+ setScript("typecheck", "bun x --bun tsc --noEmit -p tsconfig.json --pretty false");
98
+ setScript("typecheck:app", "bun x --bun tsc --noEmit -p tsconfig.json --pretty false");
99
+ setScript("types:check", "bun x --bun tsc --noEmit -p tsconfig.json --pretty false");
100
+ if (scripts["build:reset"]?.includes("storage/framework"))
101
+ setScript("build:reset", "rm -rf node_modules pantry.lock && bun install && ./buddy generate:types && ./buddy lint:fix");
102
+ if (scripts["build:framework-types"]) {
103
+ delete scripts["build:framework-types"];
104
+ changes.push({ path: "package.json#scripts.build:framework-types", action: "remove" });
105
+ }
106
+ pkg.scripts = scripts;
107
+ if (Array.isArray(pkg.workspaces)) {
108
+ const next = pkg.workspaces.filter((workspace) => workspace !== "storage/framework/core" && !workspace.startsWith("storage/framework/core/"));
109
+ if (next.length !== pkg.workspaces.length) {
110
+ pkg.workspaces = next;
111
+ changes.push({ path: "package.json#workspaces", action: "update" });
112
+ }
113
+ }
114
+ return changes;
115
+ }
116
+ export function migratePackageProjectTsconfig(projectRoot, options = {}) {
117
+ const path = join(projectRoot, "tsconfig.json");
118
+ if (!existsSync(path))
119
+ return [];
120
+ const raw = readFileSync(path, "utf8"), next = raw.replace(/"extends"\s*:\s*"\.\/storage\/framework\/core\/tsconfig\.json"/, '"extends": "./storage/framework/tsconfig.app.json"');
121
+ if (next === raw)
122
+ return [];
123
+ if (!options.dryRun)
124
+ writeFileSync(path, next);
125
+ return [{ path: "tsconfig.json", action: "update" }];
126
+ }
127
+ export function detectProjectAiProviders(projectRoot) {
128
+ const providers = new Set(["codex"]);
129
+ if (existsSync(join(projectRoot, "CLAUDE.md")) || existsSync(join(projectRoot, ".claude")))
130
+ providers.add("claude");
131
+ if (existsSync(join(projectRoot, ".cursor")))
132
+ providers.add("cursor");
133
+ if (existsSync(join(projectRoot, ".github/copilot-instructions.md")))
134
+ providers.add("copilot");
135
+ if (existsSync(join(projectRoot, "GEMINI.md")))
136
+ providers.add("gemini");
137
+ return [...providers];
138
+ }
@@ -40,7 +40,7 @@ export declare interface PackageUpgradeOptions {
40
40
  dryRun?: boolean
41
41
  noPostinstall?: boolean
42
42
  }
43
- declare interface PkgJson {
43
+ export declare interface PkgJson {
44
44
  dependencies?: Record<string, string>
45
45
  devDependencies?: Record<string, string>
46
46
  [key: string]: unknown
@@ -2,6 +2,12 @@ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "
2
2
  import { join, relative } from "node:path";
3
3
  import process from "node:process";
4
4
  import { runCommand } from "@stacksjs/cli";
5
+ import {
6
+ detectProjectAiProviders,
7
+ migratePackageProjectManifest,
8
+ migratePackageProjectTsconfig,
9
+ syncPackageProjectFiles
10
+ } from "./package-project";
5
11
  export function hasStacksDependency(pkg) {
6
12
  return Boolean(pkg.dependencies?.stacks || pkg.devDependencies?.stacks);
7
13
  }
@@ -95,12 +101,7 @@ export async function upgradeStacksPackages(projectRoot, options) {
95
101
  if (current)
96
102
  console.log(` current \`stacks\` constraint: ${current}
97
103
  `);
98
- const lockstep = lockstepPackages(metaDeps, target), changes = applyBumps(pkg, target, lockstep), manifestChanges = reconcileVendoredManifests(projectRoot, target, { dryRun: options.dryRun });
99
- if (changes.length === 0 && manifestChanges.length === 0 && !options.force) {
100
- console.log(`\u2714 Already up to date \u2014 every framework dependency matches the target.
101
- `);
102
- process.exit(0);
103
- }
104
+ const lockstep = lockstepPackages(metaDeps, target), changes = applyBumps(pkg, target, lockstep), projectManifestChanges = migratePackageProjectManifest(pkg), manifestChanges = reconcileVendoredManifests(projectRoot, target, { dryRun: options.dryRun });
104
105
  if (changes.length > 0) {
105
106
  console.log(" The following dependencies will be updated:");
106
107
  const width = Math.max(...changes.map((c) => c.name.length));
@@ -115,12 +116,15 @@ export async function upgradeStacksPackages(projectRoot, options) {
115
116
  console.log(` ${c.name.padEnd(width)} ${c.from} \u2192 ${c.to} ${c.file}`);
116
117
  console.log("");
117
118
  }
119
+ if (projectManifestChanges.length > 0)
120
+ console.log(` Project manifest migrations: ${projectManifestChanges.length}
121
+ `);
118
122
  if (options.dryRun) {
119
123
  console.log(` --dry-run: no files were written and nothing was installed.
120
124
  `);
121
125
  process.exit(0);
122
126
  }
123
- if (changes.length > 0) {
127
+ if (changes.length > 0 || projectManifestChanges.length > 0) {
124
128
  const trailing = raw.endsWith(`
125
129
  `) ? `
126
130
  ` : "";
@@ -134,13 +138,32 @@ export async function upgradeStacksPackages(projectRoot, options) {
134
138
  `);
135
139
  process.exit(0);
136
140
  }
137
- console.log(` Installing\u2026
141
+ if (changes.length > 0 || manifestChanges.length > 0 || projectManifestChanges.length > 0 || options.force) {
142
+ console.log(` Installing\u2026
138
143
  `);
139
- if ((await runCommand(`bun update ${frameworkPkgs.join(" ")}`, { cwd: projectRoot })).isErr) {
140
- console.error("\n\u2717 The install step failed. Your package.json was updated \u2014 resolve the error and re-run `bun update`.\n");
141
- process.exit(1);
144
+ if ((await runCommand(`bun update ${frameworkPkgs.join(" ")}`, { cwd: projectRoot })).isErr) {
145
+ console.error("\n\u2717 The install step failed. Your package.json was updated \u2014 resolve the error and re-run `bun update`.\n");
146
+ process.exit(1);
147
+ }
142
148
  }
143
- console.log(`
149
+ const defaultsPackageRoot = join(projectRoot, "node_modules/@stacksjs/defaults"), structureChanges = existsSync(join(defaultsPackageRoot, "package.json")) ? syncPackageProjectFiles(projectRoot, defaultsPackageRoot) : [], tsconfigChanges = migratePackageProjectTsconfig(projectRoot);
150
+ if (structureChanges.length > 0 || tsconfigChanges.length > 0) {
151
+ const added = structureChanges.filter((change) => change.action === "add").length, updated = structureChanges.filter((change) => change.action === "update").length + tsconfigChanges.length, removed = structureChanges.filter((change) => change.action === "remove").length;
152
+ console.log(` Project structure: +${added} ~${updated} -${removed}`);
153
+ }
154
+ for (const provider of detectProjectAiProviders(projectRoot))
155
+ if ((await runCommand(`./buddy setup:ai ${provider} --force`, { cwd: projectRoot })).isErr) {
156
+ console.error(`
157
+ \u2717 AI setup refresh failed for ${provider}. Re-run \`buddy setup:ai ${provider} --force\`.
158
+ `);
159
+ process.exit(1);
160
+ }
161
+ if (!(changes.length > 0 || manifestChanges.length > 0 || projectManifestChanges.length > 0 || structureChanges.length > 0 || tsconfigChanges.length > 0) && !options.force)
162
+ console.log(`
163
+ \u2714 Already up to date \u2014 dependencies and managed project files match the target.
164
+ `);
165
+ else
166
+ console.log(`
144
167
  \u2714 Upgraded to stacks@${target}. Review the changelog: https://github.com/stacksjs/stacks/releases/tag/v${target}
145
168
  `);
146
169
  process.exit(0);
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.206",
5
+ "version": "0.70.208",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -62,31 +62,31 @@
62
62
  "prepublishOnly": "bun run build"
63
63
  },
64
64
  "dependencies": {
65
- "@stacksjs/config": "0.70.206",
65
+ "@stacksjs/config": "0.70.208",
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.206",
70
- "@stacksjs/ts-cloud": "^0.7.85",
69
+ "@stacksjs/registry": "0.70.208",
70
+ "@stacksjs/ts-cloud": "^0.7.86",
71
71
  "@stacksjs/ts-md": "^0.1.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@stacksjs/api": "0.70.206",
75
- "@stacksjs/cli": "0.70.206",
76
- "@stacksjs/database": "0.70.206",
74
+ "@stacksjs/api": "0.70.208",
75
+ "@stacksjs/cli": "0.70.208",
76
+ "@stacksjs/database": "0.70.208",
77
77
  "@stacksjs/tlsx": "^0.13.2",
78
78
  "better-dx": "^0.2.17",
79
- "@stacksjs/dns": "0.70.206",
80
- "@stacksjs/enums": "0.70.206",
81
- "@stacksjs/env": "0.70.206",
82
- "@stacksjs/error-handling": "0.70.206",
83
- "@stacksjs/logging": "0.70.206",
84
- "@stacksjs/path": "0.70.206",
85
- "@stacksjs/security": "0.70.206",
86
- "@stacksjs/storage": "0.70.206",
87
- "@stacksjs/strings": "0.70.206",
88
- "@stacksjs/utils": "0.70.206",
89
- "@stacksjs/validation": "0.70.206"
79
+ "@stacksjs/dns": "0.70.208",
80
+ "@stacksjs/enums": "0.70.208",
81
+ "@stacksjs/env": "0.70.208",
82
+ "@stacksjs/error-handling": "0.70.208",
83
+ "@stacksjs/logging": "0.70.208",
84
+ "@stacksjs/path": "0.70.208",
85
+ "@stacksjs/security": "0.70.208",
86
+ "@stacksjs/storage": "0.70.208",
87
+ "@stacksjs/strings": "0.70.208",
88
+ "@stacksjs/utils": "0.70.208",
89
+ "@stacksjs/validation": "0.70.208"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "pickier": "^0.1.35"