@cleverbrush/orm-cli 4.5.0 → 5.0.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/LICENSE +28 -0
- package/README.md +5 -2
- package/dist/bin.js +1 -1
- package/dist/{cli-AOZENPBD.js → cli-DEISLQ7Q.js} +9 -8
- package/dist/commands/run.d.ts +1 -1
- package/dist/{push-SNCDOATW.js → push-HJC7LUOM.js} +2 -3
- package/dist/{validate-KJTRW3BY.js → validate-MKKWD4FQ.js} +1 -1
- package/package.json +5 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2024 by Andrew Zolotuhkin <andrew_zol@cleverbrush.com>
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
may be used to endorse or promote products derived from this software
|
|
17
|
+
without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# `@cleverbrush/orm-cli`
|
|
2
|
+
<!-- coverage-badge-start -->
|
|
3
|
+

|
|
4
|
+
<!-- coverage-badge-end -->
|
|
2
5
|
|
|
3
6
|
A standalone CLI for managing PostgreSQL schema migrations for projects built
|
|
4
7
|
with [`@cleverbrush/orm`](https://github.com/cleverbrush/framework).
|
|
@@ -95,7 +98,7 @@ npx cb-orm migrate run
|
|
|
95
98
|
# ✓ 20260423120000_add_role_column.ts
|
|
96
99
|
```
|
|
97
100
|
|
|
98
|
-
Use `--to <filename>` to
|
|
101
|
+
Use `--to <filename>` to apply that one pending file (not every preceding file):
|
|
99
102
|
|
|
100
103
|
```sh
|
|
101
104
|
npx cb-orm migrate run --to 20260423000001_init.ts
|
|
@@ -157,7 +160,7 @@ npx cb-orm db push --yes # skip confirmation
|
|
|
157
160
|
|------|----------|-------------|
|
|
158
161
|
| `--config <path>` | all | Path to config file (default: `db.config.ts` in cwd) |
|
|
159
162
|
| `--dir <path>` | all | Migrations directory (overrides `config.migrations.directory`) |
|
|
160
|
-
| `--to <name>` | `migrate run` | Apply
|
|
163
|
+
| `--to <name>` | `migrate run` | Apply one pending migration filename |
|
|
161
164
|
| `--all` | `migrate rollback` | Roll back all batches |
|
|
162
165
|
| `--yes` | `db push` | Skip the interactive confirmation prompt |
|
|
163
166
|
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import {
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
7
7
|
import { existsSync } from "fs";
|
|
@@ -41,12 +41,12 @@ function assertConfig(config) {
|
|
|
41
41
|
if (!c.knex || typeof c.knex.schema !== "object") {
|
|
42
42
|
throw new Error("config.knex must be a Knex instance.");
|
|
43
43
|
}
|
|
44
|
-
if (!c.entities || typeof c.entities !== "object") {
|
|
44
|
+
if (!c.entities || typeof c.entities !== "object" || Array.isArray(c.entities)) {
|
|
45
45
|
throw new Error(
|
|
46
46
|
"config.entities must be an object mapping names to Entity instances."
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
-
if (!c.migrations || typeof c.migrations.directory !== "string") {
|
|
49
|
+
if (!c.migrations || typeof c.migrations.directory !== "string" || !c.migrations.directory.trim()) {
|
|
50
50
|
throw new Error(
|
|
51
51
|
"config.migrations.directory must be a non-empty string path."
|
|
52
52
|
);
|
|
@@ -54,8 +54,9 @@ function assertConfig(config) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// src/cli.ts
|
|
57
|
-
var
|
|
58
|
-
|
|
57
|
+
var _pkg = JSON.parse(
|
|
58
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
59
|
+
);
|
|
59
60
|
async function run(argv) {
|
|
60
61
|
const [cmd, sub, ...rest] = argv;
|
|
61
62
|
if (!cmd || cmd === "--help" || cmd === "-h") {
|
|
@@ -73,7 +74,7 @@ async function run(argv) {
|
|
|
73
74
|
try {
|
|
74
75
|
if (cmd === "validate") {
|
|
75
76
|
loadedConfig = await loadConfig(configPath);
|
|
76
|
-
const { validate } = await import("./validate-
|
|
77
|
+
const { validate } = await import("./validate-MKKWD4FQ.js");
|
|
77
78
|
await validate(loadedConfig);
|
|
78
79
|
} else if (cmd === "migrate") {
|
|
79
80
|
switch (sub) {
|
|
@@ -121,7 +122,7 @@ async function run(argv) {
|
|
|
121
122
|
switch (sub) {
|
|
122
123
|
case "push": {
|
|
123
124
|
loadedConfig = await loadConfig(configPath);
|
|
124
|
-
const { push } = await import("./push-
|
|
125
|
+
const { push } = await import("./push-HJC7LUOM.js");
|
|
125
126
|
await push(loadedConfig, flags);
|
|
126
127
|
break;
|
|
127
128
|
}
|
|
@@ -191,7 +192,7 @@ COMMANDS
|
|
|
191
192
|
OPTIONS
|
|
192
193
|
--config <path> Path to db.config.ts (default: db.config.ts in cwd)
|
|
193
194
|
--dir <path> Migrations directory (overrides config.migrations.directory)
|
|
194
|
-
--to <name> (migrate run) Apply
|
|
195
|
+
--to <name> (migrate run) Apply one pending migration by filename
|
|
195
196
|
--all (migrate rollback) Roll back all applied migrations
|
|
196
197
|
--yes (db push) Skip the confirmation prompt
|
|
197
198
|
--help, -h Show this help
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OrmCliConfig } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Apply pending migrations via `knex.migrate.latest`.
|
|
4
|
-
* Pass `--to <migrationName>` to
|
|
4
|
+
* Pass `--to <migrationName>` to apply that one pending migration file.
|
|
5
5
|
*/
|
|
6
6
|
export declare function run(config: OrmCliConfig, flags: Record<string, string | true>): Promise<void>;
|
|
7
7
|
export declare function buildMigrationConfig(config: OrmCliConfig, flags: Record<string, string | true>): {
|
|
@@ -19,10 +19,9 @@ async function push(config, flags) {
|
|
|
19
19
|
const isProduction = process.env.NODE_ENV === "production";
|
|
20
20
|
const confirmed = flags["--yes"] === true;
|
|
21
21
|
if (isProduction && !confirmed) {
|
|
22
|
-
|
|
23
|
-
"
|
|
22
|
+
throw new Error(
|
|
23
|
+
"`db push` is not allowed in NODE_ENV=production without the --yes flag"
|
|
24
24
|
);
|
|
25
|
-
process.exit(1);
|
|
26
25
|
}
|
|
27
26
|
if (!confirmed) {
|
|
28
27
|
const answer = await prompt(
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"cli",
|
|
28
28
|
"cleverbrush"
|
|
29
29
|
],
|
|
30
|
-
"license": "BSD
|
|
30
|
+
"license": "BSD-3-Clause",
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"name": "@cleverbrush/orm-cli",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=24"
|
|
42
|
+
},
|
|
40
43
|
"readme": "https://github.com/cleverbrush/framework/tree/master/libs/orm-cli#readme",
|
|
41
44
|
"repository": {
|
|
42
45
|
"type": "git",
|
|
@@ -48,5 +51,5 @@
|
|
|
48
51
|
},
|
|
49
52
|
"type": "module",
|
|
50
53
|
"types": "./dist/index.d.ts",
|
|
51
|
-
"version": "
|
|
54
|
+
"version": "5.0.0"
|
|
52
55
|
}
|