@builder.io/dev-tools 1.66.1-dev.202606161652.35dde6127 → 1.66.1-dev.202606171106.3ccc9ceba
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/cli/index.cjs +2153 -1379
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +1 -1
- package/core/index.mjs +1 -1
- package/node/index.cjs +1 -1
- package/node/index.mjs +1 -1
- package/package.json +1 -1
- package/server/index.cjs +62 -13
- package/server/index.mjs +62 -13
- package/types/cli/codegen.d.ts +1 -0
- package/types/cli/database-scaffold/cli.d.ts +3 -0
- package/types/cli/database-scaffold/provision.d.ts +68 -0
- package/types/cli/database-scaffold/provision.test.d.ts +1 -0
- package/types/cli/database-scaffold/scaffold.d.ts +12 -0
- package/types/cli/database-scaffold/scaffold.test.d.ts +1 -0
- package/types/cli/database-scaffold/template-files.d.ts +26 -0
- package/types/cli/database-scaffold/user-summary.d.ts +4 -0
- package/types/cli/database-scaffold/user-summary.test.d.ts +1 -0
- package/types/cli/launch/hosting/run-database-migration.d.ts +13 -0
- package/types/cli/launch/hosting/run-database-migration.test.d.ts +1 -0
- package/types/tsconfig.tsbuildinfo +1 -1
package/types/cli/codegen.d.ts
CHANGED
|
@@ -145,6 +145,7 @@ export declare class CodeGenSession {
|
|
|
145
145
|
queueSystemReminder(reminder: SystemReminderObj): {
|
|
146
146
|
operation: string;
|
|
147
147
|
};
|
|
148
|
+
notePendingDatabaseUserSummary(summaryLine: string): void;
|
|
148
149
|
setDefaultAutoPush(autoPush: AutoPushMode | undefined): void;
|
|
149
150
|
setPrivacyMode(privacyMode: PrivacyMode | undefined): Promise<void>;
|
|
150
151
|
/**
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { PushChangesArgs } from "#ai-utils";
|
|
2
|
+
import type { Credentials } from "../credentials";
|
|
3
|
+
export interface ProvisionDatabaseResult {
|
|
4
|
+
status: "ready" | "exists";
|
|
5
|
+
neonProjectId: string;
|
|
6
|
+
mainBranchId: string;
|
|
7
|
+
region: string;
|
|
8
|
+
branchNeonId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GitSession {
|
|
11
|
+
git(args: string[], opts?: string | {
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}): Promise<string | void>;
|
|
14
|
+
pushChanges(opts: PushChangesArgs): Promise<{
|
|
15
|
+
success?: boolean;
|
|
16
|
+
message?: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export declare function fetchFusionDatabaseStatus(args: {
|
|
20
|
+
credentials: Credentials;
|
|
21
|
+
projectId: string;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
ok: true;
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
error: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function resolveFusionBranchId(args: {
|
|
32
|
+
credentials: Credentials;
|
|
33
|
+
projectId: string;
|
|
34
|
+
branchName: string;
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
ok: true;
|
|
39
|
+
branchId: string;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: string;
|
|
43
|
+
}>;
|
|
44
|
+
export declare function provisionFusionDatabase(args: {
|
|
45
|
+
credentials: Credentials;
|
|
46
|
+
projectId: string;
|
|
47
|
+
branchId: string;
|
|
48
|
+
debug?: boolean;
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
ok: true;
|
|
52
|
+
result: ProvisionDatabaseResult;
|
|
53
|
+
} | {
|
|
54
|
+
ok: false;
|
|
55
|
+
error: string;
|
|
56
|
+
}>;
|
|
57
|
+
export declare function commitScaffoldFiles(args: {
|
|
58
|
+
session: GitSession;
|
|
59
|
+
gitRoot: string;
|
|
60
|
+
relativePaths: string[];
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
ok: true;
|
|
64
|
+
committed: boolean;
|
|
65
|
+
} | {
|
|
66
|
+
ok: false;
|
|
67
|
+
error: string;
|
|
68
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ScaffoldDrizzleDatabaseResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
rootDir: string;
|
|
4
|
+
written: string[];
|
|
5
|
+
skipped: string[];
|
|
6
|
+
packageJsonUpdated: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function isDrizzleScaffoldPresent(rootDir: string): boolean;
|
|
10
|
+
export declare function scaffoldDrizzleDatabase(args: {
|
|
11
|
+
rootDir: string;
|
|
12
|
+
}): ScaffoldDrizzleDatabaseResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const BUILDER_CONFIG_JSON = "{\n \"database\": {\n \"kind\": \"postgres\",\n \"migrations\": \"drizzle\",\n \"schemaDir\": \"drizzle\"\n }\n}\n";
|
|
2
|
+
export declare const DRIZZLE_CONFIG_TS = "import \"dotenv/config\";\nimport { defineConfig } from \"drizzle-kit\";\n\nexport default defineConfig({\n schema: \"./drizzle/schema.ts\",\n out: \"./drizzle/migrations\",\n dialect: \"postgresql\",\n dbCredentials: { url: process.env.DATABASE_URL_UNPOOLED! },\n});\n";
|
|
3
|
+
export declare const DRIZZLE_SCHEMA_TS = "import { pgTable } from \"drizzle-orm/pg-core\";\n\n// Add tables for this project below.\n";
|
|
4
|
+
export declare const SERVER_DB_TS = "import { neon } from \"@neondatabase/serverless\";\nimport { drizzle } from \"drizzle-orm/neon-http\";\nimport type { NeonHttpDatabase } from \"drizzle-orm/neon-http\";\nimport * as schema from \"../drizzle/schema\";\n\nlet dbInstance: NeonHttpDatabase<typeof schema> | undefined;\n\nexport function getDb(): NeonHttpDatabase<typeof schema> {\n if (dbInstance) {\n return dbInstance;\n }\n\n const databaseUrl = process.env.DATABASE_URL;\n if (!databaseUrl) {\n throw new Error(\"DATABASE_URL is required to initialize the database client\");\n }\n\n dbInstance = drizzle(neon(databaseUrl), { schema });\n return dbInstance;\n}\n\nexport { schema };\n";
|
|
5
|
+
export declare const MAYBE_MIGRATE_MJS = "import { spawnSync } from \"node:child_process\";\n\nconst branchKind = process.env.FUSION_BRANCH_KIND;\n\nif (branchKind !== \"feature\") {\n if (branchKind !== \"main\") {\n console.warn(\n `Skipping database migrations because FUSION_BRANCH_KIND is ${branchKind ?? \"unset\"}`,\n );\n }\n\n process.exit(0);\n}\n\nif (!process.env.DATABASE_URL_UNPOOLED) {\n console.warn(\n \"Skipping database migrations because DATABASE_URL_UNPOOLED is not set\",\n );\n process.exit(0);\n}\n\nconst isWindows = process.platform === \"win32\";\nconst npmCommand = isWindows ? \"npm.cmd\" : \"npm\";\nconst result = spawnSync(npmCommand, [\"run\", \"db:migrate\"], {\n env: process.env,\n shell: isWindows,\n stdio: \"inherit\",\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 1);\n";
|
|
6
|
+
export declare const GUARD_NO_DRIZZLE_PUSH_MJS = "import { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst bannedCommandPattern = /\\bdrizzle-kit\\b[^\\r\\n]*\\bpush\\b/;\nconst root = resolve(process.argv[2] ?? process.cwd());\nconst candidatePaths = [\n resolve(root, \"package.json\"),\n resolve(root, \"drizzle.config.ts\"),\n resolve(root, \"scripts\"),\n resolve(root, \"server\"),\n resolve(root, \"client\"),\n resolve(root, \"shared\"),\n resolve(root, \".github/workflows\"),\n];\nconst workflowExtensions = new Set([\".yml\", \".yaml\"]);\nconst sourceExtensions = new Set([\n \".cjs\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".sh\",\n \".ts\",\n \".tsx\",\n]);\nconst testFilePattern = /(?:^|[\\\\/])[^\\\\/]+\\.test\\.[cm]?[jt]sx?$/;\nconst guardFilePattern = /(?:^|[\\\\/])guard-no-drizzle-push\\.mjs$/;\n\nfunction getExtension(filePath) {\n const index = filePath.lastIndexOf(\".\");\n return index === -1 ? \"\" : filePath.slice(index);\n}\n\nfunction collectFiles(path) {\n try {\n const stats = statSync(path);\n\n if (stats.isFile()) {\n if (testFilePattern.test(path) || guardFilePattern.test(path)) {\n return [];\n }\n\n return path.endsWith(\"package.json\") ||\n workflowExtensions.has(getExtension(path)) ||\n sourceExtensions.has(getExtension(path))\n ? [path]\n : [];\n }\n\n if (!stats.isDirectory()) {\n return [];\n }\n\n return readdirSync(path).flatMap((entry) =>\n collectFiles(resolve(path, entry)),\n );\n } catch (error) {\n if (error?.code === \"ENOENT\") {\n return [];\n }\n\n throw error;\n }\n}\n\nconst scannedFiles = [...new Set(candidatePaths.flatMap(collectFiles))];\nconst offenders = scannedFiles.filter((filePath) =>\n bannedCommandPattern.test(readFileSync(filePath, \"utf8\")),\n);\n\nif (offenders.length > 0) {\n console.error(`Banned Drizzle command found in:\\n${offenders.join(\"\\n\")}`);\n process.exit(1);\n}\n";
|
|
7
|
+
export declare const SCAFFOLD_FILES: {
|
|
8
|
+
readonly "builder.config.json": "{\n \"database\": {\n \"kind\": \"postgres\",\n \"migrations\": \"drizzle\",\n \"schemaDir\": \"drizzle\"\n }\n}\n";
|
|
9
|
+
readonly "drizzle.config.ts": "import \"dotenv/config\";\nimport { defineConfig } from \"drizzle-kit\";\n\nexport default defineConfig({\n schema: \"./drizzle/schema.ts\",\n out: \"./drizzle/migrations\",\n dialect: \"postgresql\",\n dbCredentials: { url: process.env.DATABASE_URL_UNPOOLED! },\n});\n";
|
|
10
|
+
readonly "drizzle/schema.ts": "import { pgTable } from \"drizzle-orm/pg-core\";\n\n// Add tables for this project below.\n";
|
|
11
|
+
readonly "server/db.ts": "import { neon } from \"@neondatabase/serverless\";\nimport { drizzle } from \"drizzle-orm/neon-http\";\nimport type { NeonHttpDatabase } from \"drizzle-orm/neon-http\";\nimport * as schema from \"../drizzle/schema\";\n\nlet dbInstance: NeonHttpDatabase<typeof schema> | undefined;\n\nexport function getDb(): NeonHttpDatabase<typeof schema> {\n if (dbInstance) {\n return dbInstance;\n }\n\n const databaseUrl = process.env.DATABASE_URL;\n if (!databaseUrl) {\n throw new Error(\"DATABASE_URL is required to initialize the database client\");\n }\n\n dbInstance = drizzle(neon(databaseUrl), { schema });\n return dbInstance;\n}\n\nexport { schema };\n";
|
|
12
|
+
readonly "scripts/maybe-migrate.mjs": "import { spawnSync } from \"node:child_process\";\n\nconst branchKind = process.env.FUSION_BRANCH_KIND;\n\nif (branchKind !== \"feature\") {\n if (branchKind !== \"main\") {\n console.warn(\n `Skipping database migrations because FUSION_BRANCH_KIND is ${branchKind ?? \"unset\"}`,\n );\n }\n\n process.exit(0);\n}\n\nif (!process.env.DATABASE_URL_UNPOOLED) {\n console.warn(\n \"Skipping database migrations because DATABASE_URL_UNPOOLED is not set\",\n );\n process.exit(0);\n}\n\nconst isWindows = process.platform === \"win32\";\nconst npmCommand = isWindows ? \"npm.cmd\" : \"npm\";\nconst result = spawnSync(npmCommand, [\"run\", \"db:migrate\"], {\n env: process.env,\n shell: isWindows,\n stdio: \"inherit\",\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 1);\n";
|
|
13
|
+
readonly "scripts/guard-no-drizzle-push.mjs": "import { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst bannedCommandPattern = /\\bdrizzle-kit\\b[^\\r\\n]*\\bpush\\b/;\nconst root = resolve(process.argv[2] ?? process.cwd());\nconst candidatePaths = [\n resolve(root, \"package.json\"),\n resolve(root, \"drizzle.config.ts\"),\n resolve(root, \"scripts\"),\n resolve(root, \"server\"),\n resolve(root, \"client\"),\n resolve(root, \"shared\"),\n resolve(root, \".github/workflows\"),\n];\nconst workflowExtensions = new Set([\".yml\", \".yaml\"]);\nconst sourceExtensions = new Set([\n \".cjs\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".sh\",\n \".ts\",\n \".tsx\",\n]);\nconst testFilePattern = /(?:^|[\\\\/])[^\\\\/]+\\.test\\.[cm]?[jt]sx?$/;\nconst guardFilePattern = /(?:^|[\\\\/])guard-no-drizzle-push\\.mjs$/;\n\nfunction getExtension(filePath) {\n const index = filePath.lastIndexOf(\".\");\n return index === -1 ? \"\" : filePath.slice(index);\n}\n\nfunction collectFiles(path) {\n try {\n const stats = statSync(path);\n\n if (stats.isFile()) {\n if (testFilePattern.test(path) || guardFilePattern.test(path)) {\n return [];\n }\n\n return path.endsWith(\"package.json\") ||\n workflowExtensions.has(getExtension(path)) ||\n sourceExtensions.has(getExtension(path))\n ? [path]\n : [];\n }\n\n if (!stats.isDirectory()) {\n return [];\n }\n\n return readdirSync(path).flatMap((entry) =>\n collectFiles(resolve(path, entry)),\n );\n } catch (error) {\n if (error?.code === \"ENOENT\") {\n return [];\n }\n\n throw error;\n }\n}\n\nconst scannedFiles = [...new Set(candidatePaths.flatMap(collectFiles))];\nconst offenders = scannedFiles.filter((filePath) =>\n bannedCommandPattern.test(readFileSync(filePath, \"utf8\")),\n);\n\nif (offenders.length > 0) {\n console.error(`Banned Drizzle command found in:\\n${offenders.join(\"\\n\")}`);\n process.exit(1);\n}\n";
|
|
14
|
+
};
|
|
15
|
+
export declare const DRIZZLE_RUNTIME_DEPS: {
|
|
16
|
+
readonly "@neondatabase/serverless": "^1.0.2";
|
|
17
|
+
readonly "drizzle-orm": "0.45.2";
|
|
18
|
+
};
|
|
19
|
+
export declare const DRIZZLE_DEV_DEPS: {
|
|
20
|
+
readonly "drizzle-kit": "0.31.10";
|
|
21
|
+
};
|
|
22
|
+
export declare const DRIZZLE_SCRIPTS: {
|
|
23
|
+
readonly "db:generate": "drizzle-kit generate";
|
|
24
|
+
readonly "db:migrate": "drizzle-kit migrate";
|
|
25
|
+
readonly "ci:guard-no-drizzle-push": "node scripts/guard-no-drizzle-push.mjs";
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ActionItem } from "#ai-utils";
|
|
2
|
+
import { formatDatabaseEnabledUserSummary } from "#ai-utils";
|
|
3
|
+
export { formatDatabaseEnabledUserSummary };
|
|
4
|
+
export declare function appendDatabaseUserSummaryToActions(actions: ActionItem[] | undefined, summaryLine: string): ActionItem[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuildConfigOverrides } from "#ai-utils";
|
|
2
|
+
import type { DevServerOrchestrator } from "../dev-server-orchestrator";
|
|
3
|
+
export declare function shouldRunDeployDatabaseMigration(workingDirectory: string, buildConfigOverrides?: BuildConfigOverrides): boolean;
|
|
4
|
+
export declare function runDeployDatabaseMigration(args: {
|
|
5
|
+
devServer: DevServerOrchestrator;
|
|
6
|
+
buildConfigOverrides?: BuildConfigOverrides;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
ok: true;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
output: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|