@lssm/app.cli-databases 0.0.0-canary-20251221144710 → 0.0.0-canary-20251221153314
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.d.mts +1 -0
- package/dist/cli.mjs +61 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -0
- package/dist/profile.d.mts +15 -0
- package/dist/profile.d.mts.map +1 -0
- package/dist/profile.mjs +14 -0
- package/dist/profile.mjs.map +1 -0
- package/package.json +3 -3
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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 { };
|
|
61
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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(\n 'database',\n ['import', '--modules', db.modules.join(','), '--target', db.cwd],\n { stdio: 'inherit' }\n );\n }\n break;\n case 'check':\n for (const db of profile.databases) {\n await execa('database', ['check', '--target', db.cwd], {\n stdio: 'inherit',\n });\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(\n 'Usage: databases <import|check|generate|migrate:dev|migrate:deploy|migrate:status|seed> --profile <name>'\n );\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAKA,eAAe,OAAO;CACpB,MAAM,OAAO,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;CACvC,MAAM,CAAC,OAAO,KAAK;CAEnB,MAAM,UAAU,MAAM,YADD,KAAK,WAAsB,UACF;CAE9C,eAAe,aAAa,MAAgB;AAC1C,OAAK,MAAM,MAAM,QAAQ,UACvB,OAAM,MAAM,UAAU,MAAM;GAAE,OAAO;GAAW,KAAK,GAAG;GAAK,CAAC;;AAIlE,SAAQ,KAAR;EACE,KAAK;AACH,QAAK,MAAM,MAAM,QAAQ,UACvB,OAAM,MACJ,YACA;IAAC;IAAU;IAAa,GAAG,QAAQ,KAAK,IAAI;IAAE;IAAY,GAAG;IAAI,EACjE,EAAE,OAAO,WAAW,CACrB;AAEH;EACF,KAAK;AACH,QAAK,MAAM,MAAM,QAAQ,UACvB,OAAM,MAAM,YAAY;IAAC;IAAS;IAAY,GAAG;IAAI,EAAE,EACrD,OAAO,WACR,CAAC;AAEJ;EACF,KAAK;AACH,SAAM,aAAa,CAAC,WAAW,CAAC;AAChC;EACF,KAAK;AACH,SAAM,aAAa,CAAC,WAAW,MAAM,CAAC;AACtC;EACF,KAAK;AACH,SAAM,aAAa,CAAC,WAAW,SAAS,CAAC;AACzC;EACF,KAAK;AACH,SAAM,aAAa,CAAC,WAAW,SAAS,CAAC;AACzC;EACF,KAAK;AACH,SAAM,aAAa,CAAC,MAAM,OAAO,CAAC;AAClC;EACF;AACE,WAAQ,MACN,2GACD;AACD,WAAQ,KAAK,EAAE;;;AAIrB,MAAM,CAAC,OAAO,QAAQ;AACpB,SAAQ,MAAM,IAAI;AAClB,SAAQ,KAAK,EAAE;EACf"}
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/profile.d.ts
|
|
2
|
+
interface DbConfig {
|
|
3
|
+
dbId: string;
|
|
4
|
+
cwd: string;
|
|
5
|
+
modules: string[];
|
|
6
|
+
configFile?: string;
|
|
7
|
+
}
|
|
8
|
+
interface DatabasesProfile {
|
|
9
|
+
name: string;
|
|
10
|
+
databases: DbConfig[];
|
|
11
|
+
}
|
|
12
|
+
declare function loadProfile(name: string): Promise<DatabasesProfile>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DatabasesProfile, DbConfig, loadProfile };
|
|
15
|
+
//# sourceMappingURL=profile.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
|
14
|
+
//# sourceMappingURL=profile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;AAeA,eAAsB,YAAY,MAAyC;CAEzE,MAAM,OAAO,QAAQ,KAAK;CAC1B,MAAM,OAAO,KAAK,KAAK,MAAM,qBAAqB,KAAK,OAAO;AAC9D,KAAI,CAAC,GAAG,WAAW,KAAK,CACtB,OAAM,IAAI,MAAM,sBAAsB,OAAO;AAG/C,QADa,KAAK,MAAM,GAAG,aAAa,MAAM,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.cli-databases",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251221153314",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"databases": "dist/cli.js"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"execa": "^9.6.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
22
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
21
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251221153314",
|
|
22
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251221153314",
|
|
23
23
|
"tsdown": "^0.18.1"
|
|
24
24
|
},
|
|
25
25
|
"main": "./dist/index.mjs",
|