@beignet/cli 0.0.3 → 0.0.5
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/CHANGELOG.md +219 -0
- package/README.md +379 -61
- package/dist/ansi.d.ts +10 -0
- package/dist/ansi.d.ts.map +1 -0
- package/dist/ansi.js +20 -0
- package/dist/ansi.js.map +1 -0
- package/dist/choices.d.ts +49 -0
- package/dist/choices.d.ts.map +1 -0
- package/dist/choices.js +53 -0
- package/dist/choices.js.map +1 -0
- package/dist/completion.d.ts +47 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +123 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/create-prompts.d.ts +41 -0
- package/dist/create-prompts.d.ts.map +1 -0
- package/dist/create-prompts.js +78 -0
- package/dist/create-prompts.js.map +1 -0
- package/dist/create.d.ts +10 -5
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +28 -47
- package/dist/create.js.map +1 -1
- package/dist/db.d.ts +1 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +37 -2
- package/dist/db.js.map +1 -1
- package/dist/github-annotations.d.ts +18 -0
- package/dist/github-annotations.d.ts.map +1 -0
- package/dist/github-annotations.js +22 -0
- package/dist/github-annotations.js.map +1 -0
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +665 -603
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +21 -2
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +1938 -131
- package/dist/inspect.js.map +1 -1
- package/dist/lib.d.ts +20 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +17 -0
- package/dist/lib.js.map +1 -0
- package/dist/lint.d.ts +10 -1
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +340 -33
- package/dist/lint.js.map +1 -1
- package/dist/make.d.ts +20 -3
- package/dist/make.d.ts.map +1 -1
- package/dist/make.js +1896 -382
- package/dist/make.js.map +1 -1
- package/dist/outbox.d.ts +24 -0
- package/dist/outbox.d.ts.map +1 -0
- package/dist/outbox.js +138 -0
- package/dist/outbox.js.map +1 -0
- package/dist/schedule.d.ts +36 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/schedule.js +155 -0
- package/dist/schedule.js.map +1 -0
- package/dist/task.d.ts +26 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +106 -0
- package/dist/task.js.map +1 -0
- package/dist/templates/base.d.ts +13 -0
- package/dist/templates/base.d.ts.map +1 -0
- package/dist/templates/base.js +300 -0
- package/dist/templates/base.js.map +1 -0
- package/dist/templates/db.d.ts +14 -0
- package/dist/templates/db.d.ts.map +1 -0
- package/dist/templates/db.js +962 -0
- package/dist/templates/db.js.map +1 -0
- package/dist/templates/index.d.ts +14 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +123 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/server.d.ts +26 -0
- package/dist/templates/server.d.ts.map +1 -0
- package/dist/templates/server.js +520 -0
- package/dist/templates/server.js.map +1 -0
- package/dist/templates/shadcn.d.ts +5 -0
- package/dist/templates/shadcn.d.ts.map +1 -0
- package/dist/templates/shadcn.js +555 -0
- package/dist/templates/shadcn.js.map +1 -0
- package/dist/templates/shared.d.ts +49 -0
- package/dist/templates/shared.d.ts.map +1 -0
- package/dist/templates/shared.js +57 -0
- package/dist/templates/shared.js.map +1 -0
- package/dist/templates/shell.d.ts +5 -0
- package/dist/templates/shell.d.ts.map +1 -0
- package/dist/templates/shell.js +1190 -0
- package/dist/templates/shell.js.map +1 -0
- package/dist/templates/todos.d.ts +17 -0
- package/dist/templates/todos.d.ts.map +1 -0
- package/dist/templates/todos.js +607 -0
- package/dist/templates/todos.js.map +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +9 -8
- package/src/ansi.ts +30 -0
- package/src/choices.ts +83 -0
- package/src/completion.ts +169 -0
- package/src/config.ts +16 -0
- package/src/create-prompts.ts +114 -0
- package/src/create.ts +40 -64
- package/src/db.ts +60 -4
- package/src/github-annotations.ts +37 -0
- package/src/index.ts +1075 -817
- package/src/inspect.ts +2859 -115
- package/src/lib.ts +45 -0
- package/src/lint.ts +493 -39
- package/src/make.ts +2389 -406
- package/src/outbox.ts +249 -0
- package/src/schedule.ts +272 -0
- package/src/task.ts +169 -0
- package/src/templates/base.ts +377 -0
- package/src/templates/db.ts +963 -0
- package/src/templates/index.ts +148 -0
- package/src/templates/server.ts +528 -0
- package/src/templates/shadcn.ts +570 -0
- package/src/templates/shared.ts +90 -0
- package/src/templates/shell.ts +1219 -0
- package/src/templates/todos.ts +607 -0
- package/src/version.ts +20 -0
- package/dist/create-bin.d.ts +0 -3
- package/dist/create-bin.d.ts.map +0 -1
- package/dist/create-bin.js +0 -9
- package/dist/create-bin.js.map +0 -1
- package/dist/templates.d.ts +0 -55
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -3520
- package/dist/templates.js.map +0 -1
- package/src/create-bin.ts +0 -11
- package/src/templates.ts +0 -3774
package/src/db.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type RunDatabaseCommandOptions = {
|
|
|
21
21
|
* Result returned by a database lifecycle command.
|
|
22
22
|
*/
|
|
23
23
|
export type RunDatabaseCommandResult = {
|
|
24
|
+
schemaVersion: 1;
|
|
24
25
|
command: DatabaseCommand;
|
|
25
26
|
cwd: string;
|
|
26
27
|
script: string;
|
|
@@ -56,18 +57,20 @@ export async function runDatabaseCommand(
|
|
|
56
57
|
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
57
58
|
const script = databaseScripts[options.command];
|
|
58
59
|
const packageJson = await readPackageJson(cwd);
|
|
60
|
+
const scriptCommand = packageJson.scripts?.[script];
|
|
59
61
|
|
|
60
|
-
if (!
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Missing package.json script "${script}". Add it to this Beignet app before running beignet db ${options.command}.`,
|
|
63
|
-
);
|
|
62
|
+
if (!scriptCommand) {
|
|
63
|
+
throw new Error(missingDatabaseScriptMessage(options.command, script));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
await assertDatabaseCommandPreflight(cwd, options.command, scriptCommand);
|
|
67
|
+
|
|
66
68
|
const runner = await detectPackageManager(cwd);
|
|
67
69
|
const args = ["run", script];
|
|
68
70
|
|
|
69
71
|
if (options.dryRun) {
|
|
70
72
|
return {
|
|
73
|
+
schemaVersion: 1,
|
|
71
74
|
command: options.command,
|
|
72
75
|
cwd,
|
|
73
76
|
script,
|
|
@@ -83,6 +86,7 @@ export async function runDatabaseCommand(
|
|
|
83
86
|
});
|
|
84
87
|
|
|
85
88
|
return {
|
|
89
|
+
schemaVersion: 1,
|
|
86
90
|
command: options.command,
|
|
87
91
|
cwd,
|
|
88
92
|
script,
|
|
@@ -96,6 +100,58 @@ export async function runDatabaseCommand(
|
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
async function assertDatabaseCommandPreflight(
|
|
104
|
+
cwd: string,
|
|
105
|
+
command: DatabaseCommand,
|
|
106
|
+
scriptCommand: string,
|
|
107
|
+
): Promise<void> {
|
|
108
|
+
if (
|
|
109
|
+
(command === "generate" || command === "migrate") &&
|
|
110
|
+
/\bdrizzle-kit\b/.test(scriptCommand) &&
|
|
111
|
+
!hasExplicitDrizzleConfigFlag(scriptCommand) &&
|
|
112
|
+
!(await exists(path.join(cwd, "drizzle.config.ts"))) &&
|
|
113
|
+
!(await exists(path.join(cwd, "drizzle.config.mts"))) &&
|
|
114
|
+
!(await exists(path.join(cwd, "drizzle.config.js"))) &&
|
|
115
|
+
!(await exists(path.join(cwd, "drizzle.config.mjs")))
|
|
116
|
+
) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Missing Drizzle config. beignet db ${command} runs "${scriptCommand}", but no drizzle.config.ts, drizzle.config.mts, drizzle.config.js, or drizzle.config.mjs exists in the app root.`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const standardEntrypoints: Partial<Record<DatabaseCommand, string>> = {
|
|
123
|
+
seed: "infra/db/seed.ts",
|
|
124
|
+
reset: "infra/db/reset.ts",
|
|
125
|
+
};
|
|
126
|
+
const standardEntrypoint = standardEntrypoints[command];
|
|
127
|
+
if (
|
|
128
|
+
standardEntrypoint &&
|
|
129
|
+
scriptCommand.includes(standardEntrypoint) &&
|
|
130
|
+
!(await exists(path.join(cwd, standardEntrypoint)))
|
|
131
|
+
) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Missing database ${command} entrypoint ${standardEntrypoint}. beignet db ${command} runs "${scriptCommand}", so restore ${standardEntrypoint} or update package.json script "${databaseScripts[command]}".`,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function hasExplicitDrizzleConfigFlag(scriptCommand: string): boolean {
|
|
139
|
+
return /(?:^|\s)--config(?:=|\s)/.test(scriptCommand);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function missingDatabaseScriptMessage(
|
|
143
|
+
command: DatabaseCommand,
|
|
144
|
+
script: string,
|
|
145
|
+
): string {
|
|
146
|
+
if (command === "generate" || command === "migrate") {
|
|
147
|
+
return `Missing package.json script "${script}". Standard Drizzle apps use "${script}": "drizzle-kit ${command}" with drizzle.config.ts at the app root.`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const entrypoint =
|
|
151
|
+
command === "seed" ? "infra/db/seed.ts" : "infra/db/reset.ts";
|
|
152
|
+
return `Missing package.json script "${script}". Standard Drizzle apps use "${script}": "bun ${entrypoint}" so beignet db ${command} can run the app-owned ${command} entrypoint.`;
|
|
153
|
+
}
|
|
154
|
+
|
|
99
155
|
async function readPackageJson(cwd: string): Promise<PackageJson> {
|
|
100
156
|
try {
|
|
101
157
|
return JSON.parse(
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels understood by GitHub Actions workflow commands.
|
|
3
|
+
*/
|
|
4
|
+
export type GithubAnnotationSeverity = "error" | "warning" | "notice";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Format one GitHub Actions annotation workflow command.
|
|
8
|
+
*
|
|
9
|
+
* Absent properties are omitted and the message is percent-encoded so
|
|
10
|
+
* multiline messages survive the single-line command format.
|
|
11
|
+
*/
|
|
12
|
+
export function formatGithubAnnotation(annotation: {
|
|
13
|
+
severity: GithubAnnotationSeverity;
|
|
14
|
+
message: string;
|
|
15
|
+
file?: string;
|
|
16
|
+
line?: number;
|
|
17
|
+
col?: number;
|
|
18
|
+
}): string {
|
|
19
|
+
const properties = [
|
|
20
|
+
annotation.file === undefined ? undefined : `file=${annotation.file}`,
|
|
21
|
+
annotation.line === undefined ? undefined : `line=${annotation.line}`,
|
|
22
|
+
annotation.col === undefined ? undefined : `col=${annotation.col}`,
|
|
23
|
+
].filter((property): property is string => property !== undefined);
|
|
24
|
+
const propertySection =
|
|
25
|
+
properties.length > 0 ? ` ${properties.join(",")}` : "";
|
|
26
|
+
|
|
27
|
+
return `::${annotation.severity}${propertySection}::${encodeGithubAnnotationMessage(
|
|
28
|
+
annotation.message,
|
|
29
|
+
)}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function encodeGithubAnnotationMessage(message: string): string {
|
|
33
|
+
return message
|
|
34
|
+
.replaceAll("%", "%25")
|
|
35
|
+
.replaceAll("\r", "%0D")
|
|
36
|
+
.replaceAll("\n", "%0A");
|
|
37
|
+
}
|