@ttoss/postgresdb-cli 0.1.13 → 0.1.15
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 +22 -1
- package/dist/esm/index.js +14 -12
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ pnpm add -D @ttoss/postgresdb-cli
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
First, you need to create define the `db` object in your project using the `@ttoss/postgresdb` package. Check [@ttoss/postgresdb documentation](
|
|
13
|
+
First, you need to create define the `db` object in your project using the `@ttoss/postgresdb` package. Check [@ttoss/postgresdb documentation](https://ttoss.dev/docs/modules/packages/postgresdb/) for more information. The CLI will use this object to load the models and interact with the database.
|
|
14
14
|
|
|
15
15
|
Second, you need to define the following environment variables to connect to the database:
|
|
16
16
|
|
|
@@ -28,6 +28,16 @@ To [sync](https://sequelize.org/docs/v6/core-concepts/model-basics/#model-synchr
|
|
|
28
28
|
pnpm dlx @ttoss/postgresdb-cli sync
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
Or you can add the command to your `package.json` scripts for easier access:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"scripts": {
|
|
36
|
+
"sync": "ttoss-postgresdb sync"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
31
41
|
#### Options
|
|
32
42
|
|
|
33
43
|
- `--db-path` or `-d`: Path to the file where the `db` object is defined. Default: `./src/db.js`.
|
|
@@ -41,6 +51,17 @@ To generate an [ERD](https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_m
|
|
|
41
51
|
pnpm dlx @ttoss/postgresdb-cli erd
|
|
42
52
|
```
|
|
43
53
|
|
|
54
|
+
Or you can add the command to your `package.json` scripts for easier access:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"scripts": {
|
|
59
|
+
"erd": "ttoss-postgresdb erd"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
44
64
|
#### Options
|
|
45
65
|
|
|
46
66
|
- `--db-path` or `-d`: Path to the file where the `db` object is defined. Default: `./src/db.js`.
|
|
67
|
+
- `--engine`: Layout engine to use, options are "circo", "dot", "fdp", "neato", "osage", "twopi". Default to "circo"
|
package/dist/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@ttoss/postgresdb-cli",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.14",
|
|
10
10
|
description: "A library to handle PostgreSQL database actions through the command line",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
author: "ttoss",
|
|
@@ -26,15 +26,15 @@ var package_default = {
|
|
|
26
26
|
},
|
|
27
27
|
sideEffects: false,
|
|
28
28
|
dependencies: {
|
|
29
|
-
commander: "^
|
|
30
|
-
dotenv: "^
|
|
31
|
-
esbuild: "^0.
|
|
29
|
+
commander: "^14.0.0",
|
|
30
|
+
dotenv: "^17.0.1",
|
|
31
|
+
esbuild: "^0.25.5",
|
|
32
32
|
"sequelize-erd": "^1.3.1"
|
|
33
33
|
},
|
|
34
34
|
devDependencies: {
|
|
35
35
|
"@ttoss/config": "workspace:^",
|
|
36
|
-
jest: "^
|
|
37
|
-
tsup: "^8.
|
|
36
|
+
jest: "^30.0.4",
|
|
37
|
+
tsup: "^8.5.0"
|
|
38
38
|
},
|
|
39
39
|
keywords: ["database", "postgres", "postgresql"],
|
|
40
40
|
publishConfig: {
|
|
@@ -44,13 +44,13 @@ var package_default = {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/erd.ts
|
|
47
|
-
import * as fs from "
|
|
47
|
+
import * as fs from "fs";
|
|
48
48
|
import sequelizeErd from "sequelize-erd";
|
|
49
49
|
|
|
50
50
|
// src/getDbDynamically.ts
|
|
51
51
|
import "dotenv/config";
|
|
52
|
-
import * as builtinModules from "
|
|
53
|
-
import path from "
|
|
52
|
+
import * as builtinModules from "module";
|
|
53
|
+
import path from "path";
|
|
54
54
|
import * as esbuild from "esbuild";
|
|
55
55
|
var nodeBuiltins = builtinModules.builtinModules;
|
|
56
56
|
var getDbDynamically = async ({
|
|
@@ -82,14 +82,16 @@ var getDbDynamically = async ({
|
|
|
82
82
|
|
|
83
83
|
// src/erd.ts
|
|
84
84
|
var erd = async ({
|
|
85
|
-
dbPath
|
|
85
|
+
dbPath,
|
|
86
|
+
engine
|
|
86
87
|
}) => {
|
|
87
88
|
console.info("Generating ERD...", dbPath);
|
|
88
89
|
const db = await getDbDynamically({
|
|
89
90
|
dbPath
|
|
90
91
|
});
|
|
91
92
|
const svg = await sequelizeErd({
|
|
92
|
-
source: db.sequelize
|
|
93
|
+
source: db.sequelize,
|
|
94
|
+
engine
|
|
93
95
|
});
|
|
94
96
|
await fs.promises.writeFile("erd.svg", svg);
|
|
95
97
|
console.info("ERD generated at erd.svg");
|
|
@@ -119,5 +121,5 @@ var sync = async ({
|
|
|
119
121
|
var program = new Command();
|
|
120
122
|
program.name("ttoss-postgresdb").version(package_default.version).description("ttoss postgresdb CLI");
|
|
121
123
|
program.command("sync").description("Sync database").action(sync).option("--alter", "Alter sync", false).option("-d, --db-path <dbPath>", "db initialization file path", "src/db.ts");
|
|
122
|
-
program.command("erd").description("Generate ERD").action(erd).option("-d, --db-path <dbPath>", "db initialization file path", "src/db.ts");
|
|
124
|
+
program.command("erd").description("Generate ERD").action(erd).option("-d, --db-path <dbPath>", "db initialization file path", "src/db.ts").option("--engine <engine>", "Layout engine to use", "circo");
|
|
123
125
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/postgresdb-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "A library to handle PostgreSQL database actions through the command line",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
],
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"commander": "^
|
|
26
|
-
"dotenv": "^
|
|
27
|
-
"esbuild": "^0.
|
|
25
|
+
"commander": "^14.0.0",
|
|
26
|
+
"dotenv": "^17.0.1",
|
|
27
|
+
"esbuild": "^0.25.5",
|
|
28
28
|
"sequelize-erd": "^1.3.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"jest": "^
|
|
32
|
-
"tsup": "^8.
|
|
33
|
-
"@ttoss/config": "^1.35.
|
|
31
|
+
"jest": "^30.0.4",
|
|
32
|
+
"tsup": "^8.5.0",
|
|
33
|
+
"@ttoss/config": "^1.35.5"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"database",
|