@lssm/app.cli-databases 1.11.1 → 1.41.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/package.json +12 -7
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -60
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +0 -3
- package/dist/profile.d.mts +0 -14
- package/dist/profile.mjs +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.cli-databases",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"databases": "dist/cli.js"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"minimist": "^1.2.8",
|
|
16
|
-
"execa": "^9.
|
|
16
|
+
"execa": "^9.6.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@lssm/tool.tsdown": "
|
|
20
|
-
"tsdown": "^0.
|
|
19
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
20
|
+
"tsdown": "^0.17.4"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/index.mjs",
|
|
23
23
|
"module": "./dist/index.mjs",
|
|
@@ -27,11 +27,16 @@
|
|
|
27
27
|
"README.md"
|
|
28
28
|
],
|
|
29
29
|
"exports": {
|
|
30
|
-
".": "./
|
|
31
|
-
"./cli": "./
|
|
30
|
+
".": "./src/index.ts",
|
|
31
|
+
"./cli": "./src/cli.ts",
|
|
32
32
|
"./*": "./*"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
35
|
+
"access": "public",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": "./dist/index.mjs",
|
|
38
|
+
"./cli": "./dist/cli.mjs",
|
|
39
|
+
"./*": "./*"
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
}
|
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/cli.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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 { };
|
package/dist/index.d.mts
DELETED
package/dist/index.mjs
DELETED
package/dist/profile.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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 };
|
package/dist/profile.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|