@lssm/app.cli-databases 1.11.0 → 1.11.1
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/cli.mjs +59 -2
- package/dist/index.mjs +3 -1
- package/dist/profile.d.mts +1 -2
- package/dist/profile.mjs +13 -2
- package/package.json +2 -2
- package/dist/cli.mjs.map +0 -1
- package/dist/profile.d.mts.map +0 -1
- package/dist/profile.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{loadProfile
|
|
3
|
-
|
|
2
|
+
import { loadProfile } from "./profile.mjs";
|
|
3
|
+
import mri from "minimist";
|
|
4
|
+
import { execa } from "execa";
|
|
5
|
+
|
|
6
|
+
//#region src/cli.ts
|
|
7
|
+
async function main() {
|
|
8
|
+
const argv = mri(process.argv.slice(2));
|
|
9
|
+
const [cmd] = argv._;
|
|
10
|
+
const profile = await loadProfile(argv.profile || "default");
|
|
11
|
+
async function runForEachDb(args) {
|
|
12
|
+
for (const db of profile.databases) await execa("prisma", args, {
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
cwd: db.cwd
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
switch (cmd) {
|
|
18
|
+
case "import":
|
|
19
|
+
for (const db of profile.databases) await execa("database", [
|
|
20
|
+
"import",
|
|
21
|
+
"--modules",
|
|
22
|
+
db.modules.join(","),
|
|
23
|
+
"--target",
|
|
24
|
+
db.cwd
|
|
25
|
+
], { stdio: "inherit" });
|
|
26
|
+
break;
|
|
27
|
+
case "check":
|
|
28
|
+
for (const db of profile.databases) await execa("database", [
|
|
29
|
+
"check",
|
|
30
|
+
"--target",
|
|
31
|
+
db.cwd
|
|
32
|
+
], { stdio: "inherit" });
|
|
33
|
+
break;
|
|
34
|
+
case "generate":
|
|
35
|
+
await runForEachDb(["generate"]);
|
|
36
|
+
break;
|
|
37
|
+
case "migrate:dev":
|
|
38
|
+
await runForEachDb(["migrate", "dev"]);
|
|
39
|
+
break;
|
|
40
|
+
case "migrate:deploy":
|
|
41
|
+
await runForEachDb(["migrate", "deploy"]);
|
|
42
|
+
break;
|
|
43
|
+
case "migrate:status":
|
|
44
|
+
await runForEachDb(["migrate", "status"]);
|
|
45
|
+
break;
|
|
46
|
+
case "seed":
|
|
47
|
+
await runForEachDb(["db", "seed"]);
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
console.error("Usage: databases <import|check|generate|migrate:dev|migrate:deploy|migrate:status|seed> --profile <name>");
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
main().catch((err) => {
|
|
55
|
+
console.error(err);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { };
|
package/dist/index.mjs
CHANGED
package/dist/profile.d.mts
CHANGED
|
@@ -11,5 +11,4 @@ interface DatabasesProfile {
|
|
|
11
11
|
}
|
|
12
12
|
declare function loadProfile(name: string): Promise<DatabasesProfile>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { DatabasesProfile, DbConfig, loadProfile };
|
|
15
|
-
//# sourceMappingURL=profile.d.mts.map
|
|
14
|
+
export { DatabasesProfile, DbConfig, loadProfile };
|
package/dist/profile.mjs
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/profile.ts
|
|
5
|
+
async function loadProfile(name) {
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
const file = path.join(root, `databases.profile.${name}.json`);
|
|
8
|
+
if (!fs.existsSync(file)) throw new Error(`Profile not found: ${file}`);
|
|
9
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { loadProfile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.cli-databases",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"databases": "dist/cli.js"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"execa": "^9.5.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@lssm/tool.tsdown": "0.12.
|
|
19
|
+
"@lssm/tool.tsdown": "0.12.1",
|
|
20
20
|
"tsdown": "^0.16.6"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/index.mjs",
|
package/dist/cli.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport mri from 'minimist';\nimport { execa } from 'execa';\nimport { loadProfile } from './profile.js';\n\nasync function main() {\n const argv = mri(process.argv.slice(2));\n const [cmd] = argv._ as string[];\n const profileName = (argv.profile as string) || 'default';\n const profile = await loadProfile(profileName);\n\n async function runForEachDb(args: string[]) {\n for (const db of profile.databases) {\n await execa('prisma', args, { stdio: 'inherit', cwd: db.cwd });\n }\n }\n\n switch (cmd) {\n case 'import':\n for (const db of profile.databases) {\n await execa('database', ['import', '--modules', db.modules.join(','), '--target', db.cwd], { stdio: 'inherit' });\n }\n break;\n case 'check':\n for (const db of profile.databases) {\n await execa('database', ['check', '--target', db.cwd], { stdio: 'inherit' });\n }\n break;\n case 'generate':\n await runForEachDb(['generate']);\n break;\n case 'migrate:dev':\n await runForEachDb(['migrate', 'dev']);\n break;\n case 'migrate:deploy':\n await runForEachDb(['migrate', 'deploy']);\n break;\n case 'migrate:status':\n await runForEachDb(['migrate', 'status']);\n break;\n case 'seed':\n await runForEachDb(['db', 'seed']);\n break;\n default:\n console.error('Usage: databases <import|check|generate|migrate:dev|migrate:deploy|migrate:status|seed> --profile <name>');\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n\n\n"],"mappings":";kGAKA,eAAe,GAAO,CACpB,IAAM,EAAO,EAAI,QAAQ,KAAK,MAAM,EAAE,CAAC,CACjC,CAAC,GAAO,EAAK,EAEb,EAAU,MAAM,EADD,EAAK,SAAsB,UACF,CAE9C,eAAe,EAAa,EAAgB,CAC1C,IAAK,IAAM,KAAM,EAAQ,UACvB,MAAM,EAAM,SAAU,EAAM,CAAE,MAAO,UAAW,IAAK,EAAG,IAAK,CAAC,CAIlE,OAAQ,EAAR,CACE,IAAK,SACH,IAAK,IAAM,KAAM,EAAQ,UACvB,MAAM,EAAM,WAAY,CAAC,SAAU,YAAa,EAAG,QAAQ,KAAK,IAAI,CAAE,WAAY,EAAG,IAAI,CAAE,CAAE,MAAO,UAAW,CAAC,CAElH,MACF,IAAK,QACH,IAAK,IAAM,KAAM,EAAQ,UACvB,MAAM,EAAM,WAAY,CAAC,QAAS,WAAY,EAAG,IAAI,CAAE,CAAE,MAAO,UAAW,CAAC,CAE9E,MACF,IAAK,WACH,MAAM,EAAa,CAAC,WAAW,CAAC,CAChC,MACF,IAAK,cACH,MAAM,EAAa,CAAC,UAAW,MAAM,CAAC,CACtC,MACF,IAAK,iBACH,MAAM,EAAa,CAAC,UAAW,SAAS,CAAC,CACzC,MACF,IAAK,iBACH,MAAM,EAAa,CAAC,UAAW,SAAS,CAAC,CACzC,MACF,IAAK,OACH,MAAM,EAAa,CAAC,KAAM,OAAO,CAAC,CAClC,MACF,QACE,QAAQ,MAAM,2GAA2G,CACzH,QAAQ,KAAK,EAAE,EAIrB,GAAM,CAAC,MAAO,GAAQ,CACpB,QAAQ,MAAM,EAAI,CAClB,QAAQ,KAAK,EAAE,EACf"}
|
package/dist/profile.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.mts","names":[],"sources":["../src/profile.ts"],"sourcesContent":[],"mappings":";UAGiB,QAAA;EAAA,IAAA,EAAA,MAAQ;EAOR,GAAA,EAAA,MAAA;EAKK,OAAA,EAAA,MAAW,EAAA;;;UALhB,gBAAA;;aAEJ;;iBAGS,WAAA,gBAA2B,QAAQ"}
|
package/dist/profile.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile.mjs","names":[],"sources":["../src/profile.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nexport interface DbConfig {\n dbId: string;\n cwd: string; // path to the DB package root where prisma/ lives\n modules: string[]; // @lssm/app.cli-database-* modules to import\n configFile?: string; // override prisma config location (defaults to prisma.config.ts)\n}\n\nexport interface DatabasesProfile {\n name: string;\n databases: DbConfig[];\n}\n\nexport async function loadProfile(name: string): Promise<DatabasesProfile> {\n // Convention: look for databases.profile.<name>.json at repo root\n const root = process.cwd();\n const file = path.join(root, `databases.profile.${name}.json`);\n if (!fs.existsSync(file)) {\n throw new Error(`Profile not found: ${file}`);\n }\n const json = JSON.parse(fs.readFileSync(file, 'utf8')) as DatabasesProfile;\n return json;\n}\n"],"mappings":"gDAeA,eAAsB,EAAY,EAAyC,CAEzE,IAAM,EAAO,QAAQ,KAAK,CACpB,EAAO,EAAK,KAAK,EAAM,qBAAqB,EAAK,OAAO,CAC9D,GAAI,CAAC,EAAG,WAAW,EAAK,CACtB,MAAU,MAAM,sBAAsB,IAAO,CAG/C,OADa,KAAK,MAAM,EAAG,aAAa,EAAM,OAAO,CAAC"}
|