@stacksjs/buddy 0.70.92 → 0.70.94

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.
@@ -18,6 +18,14 @@ export declare function migrationTable(filename: string): string | null;
18
18
  * always runs). Used by the migration runner's gating pass.
19
19
  */
20
20
  export declare function migrationFeature(filename: string): FeatureName | null;
21
+ /**
22
+ * True when an application-owned, top-level model explicitly declares a table.
23
+ * This lets apps intentionally use generic names such as `payments` without
24
+ * their migrations being mistaken for disabled framework-feature scaffolding.
25
+ * Root models listed in FEATURE_FILES remain feature-owned and do not override
26
+ * the gate.
27
+ */
28
+ export declare function appModelClaimsTable(table: string, root?: string): boolean;
21
29
  /**
22
30
  * Returns the subset of a feature's manifest paths that currently exist
23
31
  * on disk under `root` (defaults to `projectPath()`). Used by both the
@@ -1,4 +1,4 @@
1
- import { existsSync } from "node:fs";
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { cp, rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import process from "node:process";
@@ -149,6 +149,21 @@ export function migrationFeature(filename) {
149
149
  return f;
150
150
  return null;
151
151
  }
152
+ export function appModelClaimsTable(table, root = projectPath()) {
153
+ const modelsDir = join(root, "app/Models");
154
+ if (!existsSync(modelsDir))
155
+ return !1;
156
+ const featureModelFiles = new Set(FEATURE_NAMES.flatMap((feature) => FEATURE_FILES[feature]).filter((path) => path.startsWith("app/Models/") && !path.endsWith("/"))), escaped = table.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), declaration = new RegExp(`\\btable\\s*:\\s*['"]${escaped}['"]`);
157
+ for (const entry of readdirSync(modelsDir, { withFileTypes: !0 })) {
158
+ if (!entry.isFile() || !/\.[cm]?[jt]s$/.test(entry.name))
159
+ continue;
160
+ if (featureModelFiles.has(`app/Models/${entry.name}`))
161
+ continue;
162
+ if (declaration.test(readFileSync(join(modelsDir, entry.name), "utf8")))
163
+ return !0;
164
+ }
165
+ return !1;
166
+ }
152
167
  export function featurePathsPresent(feature, root = projectPath()) {
153
168
  return FEATURE_FILES[feature].filter((rel) => existsSync(`${root}/${rel}`));
154
169
  }
@@ -3,6 +3,7 @@ export declare function setup(buddy: CLI): void;
3
3
  export declare function ensurePantryInstalled(): Promise<void>;
4
4
  export declare function ensurePantryDependencies(cwd: string): Promise<void>;
5
5
  export declare function ensureAppKey(cwd: string): Promise<void>;
6
+ export declare function pantryDatabasePackage(connection: string): DatabasePackage | undefined;
6
7
  /**
7
8
  * Reads config/deps.ts dependencies and merges in environment-detected
8
9
  * dependencies (e.g. DB_CONNECTION), then writes deps.yaml so pantry install
@@ -10,3 +11,10 @@ export declare function ensureAppKey(cwd: string): Promise<void>;
10
11
  */
11
12
  export declare function optimizePantryDeps(): Promise<void>;
12
13
  export declare function ensureEnvIsSet(options: CliOptions): Promise<void>;
14
+ /**
15
+ * Maps DB_CONNECTION values to pantry package domains
16
+ */
17
+ declare interface DatabasePackage {
18
+ name: string
19
+ version: string
20
+ }
@@ -146,10 +146,13 @@ async function initializeProject(options) {
146
146
  log.info("Happy coding! \uD83D\uDC99");
147
147
  }
148
148
  const DB_CONNECTION_PACKAGES = {
149
- postgres: "postgresql.org",
150
- mysql: "mysql.com",
151
- sqlite: "sqlite.org"
149
+ postgres: { name: "postgresql.org", version: "^17.10" },
150
+ mysql: { name: "mysql.com", version: "*" },
151
+ sqlite: { name: "sqlite.org", version: "^3.47.2" }
152
152
  };
153
+ export function pantryDatabasePackage(connection) {
154
+ return DB_CONNECTION_PACKAGES[connection];
155
+ }
153
156
  function detectDbPackage(cwd) {
154
157
  const envPath = join(cwd, ".env"), envExamplePath = join(cwd, ".env.example"), filePath = existsSync(envPath) ? envPath : existsSync(envExamplePath) ? envExamplePath : void 0;
155
158
  if (!filePath)
@@ -158,7 +161,7 @@ function detectDbPackage(cwd) {
158
161
  if (!match)
159
162
  return;
160
163
  const value = match[1].trim().replace(/['"]/g, "");
161
- return DB_CONNECTION_PACKAGES[value];
164
+ return pantryDatabasePackage(value);
162
165
  }
163
166
  export async function optimizePantryDeps() {
164
167
  const cwd = p.projectPath(), depsConfigPath = join(cwd, "config", "deps.ts");
@@ -177,9 +180,9 @@ export async function optimizePantryDeps() {
177
180
  }
178
181
  const dbPackage = detectDbPackage(cwd);
179
182
  if (dbPackage) {
180
- if (!Object.keys(configDeps).some((key) => key === dbPackage || key.startsWith(`${dbPackage}/`))) {
181
- log.info(`Detected DB_CONNECTION requires ${dbPackage}, adding to dependencies`);
182
- configDeps[dbPackage] = "*";
183
+ if (!Object.keys(configDeps).some((key) => key === dbPackage.name || key.startsWith(`${dbPackage.name}/`))) {
184
+ log.info(`Detected DB_CONNECTION requires ${dbPackage.name}, adding to dependencies`);
185
+ configDeps[dbPackage.name] = dbPackage.version;
183
186
  }
184
187
  }
185
188
  const lines = [
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.92",
5
+ "version": "0.70.94",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -75,13 +75,13 @@
75
75
  "scripts": {
76
76
  "buddy": "bunx --bun ./src/cli.ts",
77
77
  "build": "bun build.ts",
78
- "compile": "bun build ./src/cli.ts --compile --minify --sourcemap --external=localtunnels/cloud --external=bun-queue --outfile dist/buddy",
78
+ "compile": "bun build ./src/cli.ts --compile --minify --sourcemap --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile dist/buddy",
79
79
  "compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
80
- "compile:linux-x64": "bun build ./src/cli.ts --compile --minify --target=bun-linux-x64 --external=localtunnels/cloud --external=bun-queue --outfile bin/buddy-linux-x64",
81
- "compile:linux-arm64": "bun build ./src/cli.ts --compile --minify --target=bun-linux-arm64 --external=localtunnels/cloud --external=bun-queue --outfile bin/buddy-linux-arm64",
82
- "compile:windows-x64": "bun build ./src/cli.ts --compile --minify --target=bun-windows-x64 --external=localtunnels/cloud --external=bun-queue --outfile bin/buddy-windows-x64.exe",
83
- "compile:darwin-x64": "bun build ./src/cli.ts --compile --minify --target=bun-darwin-x64 --external=localtunnels/cloud --external=bun-queue --outfile bin/buddy-darwin-x64",
84
- "compile:darwin-arm64": "bun build ./src/cli.ts --compile --minify --target=bun-darwin-arm64 --external=localtunnels/cloud --external=bun-queue --outfile bin/buddy-darwin-arm64",
80
+ "compile:linux-x64": "bun build ./src/cli.ts --compile --minify --target=bun-linux-x64 --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile bin/buddy-linux-x64",
81
+ "compile:linux-arm64": "bun build ./src/cli.ts --compile --minify --target=bun-linux-arm64 --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile bin/buddy-linux-arm64",
82
+ "compile:windows-x64": "bun build ./src/cli.ts --compile --minify --target=bun-windows-x64 --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile bin/buddy-windows-x64.exe",
83
+ "compile:darwin-x64": "bun build ./src/cli.ts --compile --minify --target=bun-darwin-x64 --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile bin/buddy-darwin-x64",
84
+ "compile:darwin-arm64": "bun build ./src/cli.ts --compile --minify --target=bun-darwin-arm64 --external=localtunnels/cloud --external=bun-queue --external=@stacksjs/bun-queue --outfile bin/buddy-darwin-arm64",
85
85
  "typecheck": "bun tsc --noEmit",
86
86
  "zip:all": "bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:windows-x64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64",
87
87
  "zip:linux-x64": "zip -j bin/buddy-linux-x64.zip bin/buddy-linux-x64",