@lssm/app.cli-databases 1.9.0
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/README.md +33 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +3 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/profile.d.mts +15 -0
- package/dist/profile.d.mts.map +1 -0
- package/dist/profile.mjs +2 -0
- package/dist/profile.mjs.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @lssm/app.cli-databases
|
|
2
|
+
|
|
3
|
+
Orchestration CLI for managing database profiles and connection strategies.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
To manage multi-database configurations (profiles) and orchestrate operations across them. Useful for environments with multiple database shards or distinct service databases.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @lssm/app.cli-databases
|
|
13
|
+
# or
|
|
14
|
+
bun add @lssm/app.cli-databases
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Key Concepts
|
|
18
|
+
|
|
19
|
+
- **Profiles**: Define sets of database connection parameters.
|
|
20
|
+
- **Orchestration**: Run commands against specific profiles or all defined databases.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### CLI
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Check help
|
|
28
|
+
bun databases --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{loadProfile as e}from"./profile.mjs";import t from"minimist";import{execa as n}from"execa";async function r(){let r=t(process.argv.slice(2)),[i]=r._,a=await e(r.profile||`default`);async function o(e){for(let t of a.databases)await n(`prisma`,e,{stdio:`inherit`,cwd:t.cwd})}switch(i){case`import`:for(let e of a.databases)await n(`database`,[`import`,`--modules`,e.modules.join(`,`),`--target`,e.cwd],{stdio:`inherit`});break;case`check`:for(let e of a.databases)await n(`database`,[`check`,`--target`,e.cwd],{stdio:`inherit`});break;case`generate`:await o([`generate`]);break;case`migrate:dev`:await o([`migrate`,`dev`]);break;case`migrate:deploy`:await o([`migrate`,`deploy`]);break;case`migrate:status`:await o([`migrate`,`status`]);break;case`seed`:await o([`db`,`seed`]);break;default:console.error(`Usage: databases <import|check|generate|migrate:dev|migrate:deploy|migrate:status|seed> --profile <name>`),process.exit(1)}}r().catch(e=>{console.error(e),process.exit(1)});export{};
|
|
3
|
+
//# 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('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/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{loadProfile as e}from"./profile.mjs";export{e as loadProfile};
|
|
@@ -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,2 @@
|
|
|
1
|
+
import e from"node:fs";import t from"node:path";async function n(n){let r=process.cwd(),i=t.join(r,`databases.profile.${n}.json`);if(!e.existsSync(i))throw Error(`Profile not found: ${i}`);return JSON.parse(e.readFileSync(i,`utf8`))}export{n as loadProfile};
|
|
2
|
+
//# 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":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lssm/app.cli-databases",
|
|
3
|
+
"version": "1.9.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"databases": "dist/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"build": "tsdown",
|
|
11
|
+
"dev": "bun run build --watch"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"minimist": "^1.2.8",
|
|
15
|
+
"execa": "^9.5.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
19
|
+
"tsdown": "^0.16.6"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.mjs",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.mjs",
|
|
30
|
+
"./cli": "./dist/cli.mjs",
|
|
31
|
+
"./*": "./*"
|
|
32
|
+
}
|
|
33
|
+
}
|