@bizone-ai/cli 0.1.4 → 0.1.5
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 +7 -1
- package/bin/bizone.js +1 -1
- package/package.json +1 -1
- package/src/cli.js +90 -57
- package/src/colors.js +4 -4
- package/src/commands/configuration.js +16 -14
- package/src/commands/database.js +23 -13
- package/src/commands/environment.js +31 -19
- package/src/commands/images.js +22 -14
- package/src/commands/resources.js +16 -14
- package/src/commands/start.js +48 -34
- package/src/commands/stop.js +15 -9
- package/src/config.js +13 -13
- package/src/containers/_commons.js +15 -15
- package/src/containers/cloud-tools.js +22 -22
- package/src/containers/mysql.js +17 -17
- package/src/containers/orchestrator.js +28 -28
- package/src/containers/resource-manager.js +20 -20
- package/src/containers/resources-job.js +7 -7
- package/src/containers/state-store.js +22 -22
- package/src/containers/ui.js +14 -14
- package/src/defaults.js +32 -24
- package/src/docker.js +112 -53
- package/src/http.js +20 -10
- package/src/resources-loader.js +6 -6
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ Stored at `$.config.{key}`.
|
|
|
113
113
|
| Key | Default | Description |
|
|
114
114
|
|-------------------------|----------------|----------------------------------------------------------------------------------------------------|
|
|
115
115
|
| `forward_aws_env` | `true` | Forward `AWS_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` into the orchestrator container |
|
|
116
|
+
| `aws_profile` | _(empty)_ | AWS named profile used for ECR auto-login (`aws ... --profile {profile}`); empty = default profile |
|
|
116
117
|
| `network_name` | `bizone-local` | Shared docker network all containers join |
|
|
117
118
|
| `mysql_port` | `33306` | Host port for the bundled MySQL database |
|
|
118
119
|
| `orchestrator_port` | `8001` | Host port for the orchestrator |
|
|
@@ -308,4 +309,9 @@ platform container (`bizone-*`) is still running — run `bizone stop` first.
|
|
|
308
309
|
`aws ecr get-login-password --region {region}` and piping it into
|
|
309
310
|
`docker login --username AWS --password-stdin {registry}`, then retries.
|
|
310
311
|
This requires the **AWS CLI** to be installed and configured with valid
|
|
311
|
-
credentials for that account.
|
|
312
|
+
credentials for that account. If your default profile lacks access to that
|
|
313
|
+
ECR, point the login at another profile:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
bizone config set aws_profile my-ecr-profile
|
|
317
|
+
```
|
package/bin/bizone.js
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// Argument parsing and command dispatch.
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { initColors, color, log } from
|
|
4
|
-
import { configuration } from
|
|
5
|
-
import { images } from
|
|
6
|
-
import { environment } from
|
|
7
|
-
import { resources } from
|
|
8
|
-
import { database } from
|
|
9
|
-
import { start } from
|
|
10
|
-
import { stop } from
|
|
11
|
-
import { CONFIG_PATH } from
|
|
3
|
+
import { initColors, color, log } from "./colors.js";
|
|
4
|
+
import { configuration } from "./commands/configuration.js";
|
|
5
|
+
import { images } from "./commands/images.js";
|
|
6
|
+
import { environment } from "./commands/environment.js";
|
|
7
|
+
import { resources } from "./commands/resources.js";
|
|
8
|
+
import { database } from "./commands/database.js";
|
|
9
|
+
import { start } from "./commands/start.js";
|
|
10
|
+
import { stop } from "./commands/stop.js";
|
|
11
|
+
import { CONFIG_PATH } from "./config.js";
|
|
12
12
|
|
|
13
13
|
const require = createRequire(import.meta.url);
|
|
14
14
|
const { version } = require("../package.json"); // JSON.parse(readFileSync(join(__dirname, "package.json")));
|
|
15
15
|
|
|
16
16
|
// category -> { aliases, handler }
|
|
17
17
|
const CATEGORIES = {
|
|
18
|
-
configuration: { aliases: [
|
|
19
|
-
images: { aliases: [
|
|
20
|
-
environment: { aliases: [
|
|
21
|
-
resources: { aliases: [
|
|
22
|
-
database: { aliases: [
|
|
18
|
+
configuration: { aliases: ["config", "c"], handler: configuration },
|
|
19
|
+
images: { aliases: ["img"], handler: images },
|
|
20
|
+
environment: { aliases: ["env"], handler: environment },
|
|
21
|
+
resources: { aliases: ["res", "r"], handler: resources },
|
|
22
|
+
database: { aliases: ["db"], handler: database },
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
function resolveCategory(name) {
|
|
@@ -33,56 +33,89 @@ function resolveCategory(name) {
|
|
|
33
33
|
function printHelp() {
|
|
34
34
|
const b = color.bold;
|
|
35
35
|
const c = color.cyan;
|
|
36
|
-
log.plain(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
log.plain(
|
|
40
|
-
log.plain(b(
|
|
41
|
-
log.plain(
|
|
42
|
-
log.plain(
|
|
43
|
-
log.plain(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
log.plain(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
log.plain(
|
|
54
|
-
log.plain(b(
|
|
55
|
-
log.plain(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
log.plain(
|
|
59
|
-
log.plain(
|
|
60
|
-
log.plain(
|
|
61
|
-
log.plain(
|
|
62
|
-
log.plain(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
log.plain(
|
|
68
|
-
log.plain(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
log.plain(
|
|
36
|
+
log.plain(
|
|
37
|
+
b("bizone") + " - run the Bizone orchestrator platform locally with Docker",
|
|
38
|
+
);
|
|
39
|
+
log.plain("");
|
|
40
|
+
log.plain(b("Usage:") + " bizone <category> <command> [args] [--no-colors]");
|
|
41
|
+
log.plain("");
|
|
42
|
+
log.plain(b("Lifecycle:"));
|
|
43
|
+
log.plain(
|
|
44
|
+
` ${c(
|
|
45
|
+
"bizone start",
|
|
46
|
+
)} Start the platform (startup sequence)`,
|
|
47
|
+
);
|
|
48
|
+
log.plain(
|
|
49
|
+
` ${c(
|
|
50
|
+
"bizone stop",
|
|
51
|
+
)} Stop running platform containers`,
|
|
52
|
+
);
|
|
53
|
+
log.plain("");
|
|
54
|
+
log.plain(b("Configuration:") + color.dim(" (config, c)"));
|
|
55
|
+
log.plain(
|
|
56
|
+
` ${c("bizone config get")} Show current configuration`,
|
|
57
|
+
);
|
|
58
|
+
log.plain(` ${c("bizone config set {key} {value}")} Set a config value`);
|
|
59
|
+
log.plain(` ${c("bizone config remove {key}")} Remove a config value`);
|
|
60
|
+
log.plain("");
|
|
61
|
+
log.plain(b("Images:") + color.dim(" (img)"));
|
|
62
|
+
log.plain(
|
|
63
|
+
` ${c(
|
|
64
|
+
"bizone images get",
|
|
65
|
+
)} List image URLs (override or default)`,
|
|
66
|
+
);
|
|
67
|
+
log.plain(` ${c("bizone images set {type} {url}")} Override an image`);
|
|
68
|
+
log.plain(
|
|
69
|
+
` ${c("bizone images remove {type}")} Reset image to default`,
|
|
70
|
+
);
|
|
71
|
+
log.plain("");
|
|
72
|
+
log.plain(b("Environment:") + color.dim(" (env)"));
|
|
73
|
+
log.plain(
|
|
74
|
+
` ${c("bizone env get {type}")} Show env vars (secrets masked)`,
|
|
75
|
+
);
|
|
76
|
+
log.plain(` ${c("bizone env set {type} {name} {value}")} Set an env var`);
|
|
77
|
+
log.plain(` ${c("bizone env remove {type} {name}")} Remove an env var`);
|
|
78
|
+
log.plain("");
|
|
79
|
+
log.plain(b("Resources:") + color.dim(" (res, r)"));
|
|
80
|
+
log.plain(` ${c("bizone resources get")} List resource sources`);
|
|
81
|
+
log.plain(
|
|
82
|
+
` ${c("bizone resources set {namespace} {path}")} Set a resource source`,
|
|
83
|
+
);
|
|
84
|
+
log.plain(
|
|
85
|
+
` ${c("bizone resources remove {namespace}")} Remove a resource source`,
|
|
86
|
+
);
|
|
87
|
+
log.plain("");
|
|
88
|
+
log.plain(b("Database:") + color.dim(" (db)"));
|
|
89
|
+
log.plain(
|
|
90
|
+
` ${c(
|
|
91
|
+
"bizone database destroy",
|
|
92
|
+
)} Remove the DB container and its data volume`,
|
|
93
|
+
);
|
|
94
|
+
log.plain("");
|
|
95
|
+
log.plain(b("Global flags:"));
|
|
96
|
+
log.plain(` ${c("--no-colors")} Disable ANSI colors`);
|
|
97
|
+
log.plain(` ${c("--help, -h")} Show this help`);
|
|
98
|
+
log.plain(` ${c("--version, -v")} Show version`);
|
|
99
|
+
log.plain("");
|
|
72
100
|
log.plain(color.dim(`Config file: ${CONFIG_PATH}`));
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
export async function main(argv) {
|
|
76
104
|
// Extract global flags anywhere in argv.
|
|
77
|
-
const noColors = argv.includes(
|
|
105
|
+
const noColors = argv.includes("--no-colors");
|
|
78
106
|
initColors({ noColors });
|
|
79
|
-
const args = argv.filter((a) => a !==
|
|
107
|
+
const args = argv.filter((a) => a !== "--no-colors");
|
|
80
108
|
|
|
81
|
-
if (
|
|
109
|
+
if (
|
|
110
|
+
args.length === 0 ||
|
|
111
|
+
args[0] === "--help" ||
|
|
112
|
+
args[0] === "-h" ||
|
|
113
|
+
args[0] === "help"
|
|
114
|
+
) {
|
|
82
115
|
printHelp();
|
|
83
116
|
return 0;
|
|
84
117
|
}
|
|
85
|
-
if (args[0] ===
|
|
118
|
+
if (args[0] === "--version" || args[0] === "-v" || args[0] === "version") {
|
|
86
119
|
log.plain(version ?? "Failed getting version");
|
|
87
120
|
return 0;
|
|
88
121
|
}
|
|
@@ -90,13 +123,13 @@ export async function main(argv) {
|
|
|
90
123
|
const [category, ...rest] = args;
|
|
91
124
|
|
|
92
125
|
// Lifecycle commands act as bare categories.
|
|
93
|
-
if (category ===
|
|
94
|
-
if (category ===
|
|
126
|
+
if (category === "start") return await start();
|
|
127
|
+
if (category === "stop") return stop();
|
|
95
128
|
|
|
96
129
|
const resolved = resolveCategory(category);
|
|
97
130
|
if (!resolved) {
|
|
98
131
|
log.err(`Unknown command: ${color.cyan(category)}`);
|
|
99
|
-
log.plain(`Run ${color.cyan(
|
|
132
|
+
log.plain(`Run ${color.cyan("bizone --help")} for usage.`);
|
|
100
133
|
return 1;
|
|
101
134
|
}
|
|
102
135
|
|
package/src/colors.js
CHANGED
|
@@ -38,9 +38,9 @@ export const color = {
|
|
|
38
38
|
// Common log helpers.
|
|
39
39
|
export const log = {
|
|
40
40
|
info: (msg) => console.log(msg),
|
|
41
|
-
step: (msg) => console.log(`${color.cyan(
|
|
42
|
-
ok: (msg) => console.log(`${color.green(
|
|
43
|
-
warn: (msg) => console.log(`${color.yellow(
|
|
44
|
-
err: (msg) => console.error(`${color.red(
|
|
41
|
+
step: (msg) => console.log(`${color.cyan("•")} ${msg}`),
|
|
42
|
+
ok: (msg) => console.log(`${color.green("✓")} ${msg}`),
|
|
43
|
+
warn: (msg) => console.log(`${color.yellow("!")} ${msg}`),
|
|
44
|
+
err: (msg) => console.error(`${color.red("✗")} ${msg}`),
|
|
45
45
|
plain: (msg) => console.log(msg),
|
|
46
46
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// `bizone configuration|config|c get|set|remove`
|
|
2
2
|
|
|
3
|
-
import { loadConfig, saveConfig, getConfigValue } from
|
|
4
|
-
import { CONFIG_KEYS, DEFAULT_CONFIG } from
|
|
5
|
-
import { color, log } from
|
|
3
|
+
import { loadConfig, saveConfig, getConfigValue } from "../config.js";
|
|
4
|
+
import { CONFIG_KEYS, DEFAULT_CONFIG } from "../defaults.js";
|
|
5
|
+
import { color, log } from "../colors.js";
|
|
6
6
|
|
|
7
7
|
function printKnownKeys() {
|
|
8
|
-
log.plain(color.bold(
|
|
8
|
+
log.plain(color.bold("Known configuration keys (with defaults):"));
|
|
9
9
|
for (const k of CONFIG_KEYS) {
|
|
10
10
|
log.plain(` ${color.cyan(k)} = ${color.dim(DEFAULT_CONFIG[k])}`);
|
|
11
11
|
}
|
|
@@ -16,29 +16,31 @@ export function configuration(args) {
|
|
|
16
16
|
const cfg = loadConfig();
|
|
17
17
|
|
|
18
18
|
switch (sub) {
|
|
19
|
-
case
|
|
20
|
-
log.plain(color.bold(
|
|
19
|
+
case "get": {
|
|
20
|
+
log.plain(color.bold("Configuration:"));
|
|
21
21
|
for (const k of CONFIG_KEYS) {
|
|
22
22
|
const isSet = Object.prototype.hasOwnProperty.call(cfg.config, k);
|
|
23
23
|
const val = getConfigValue(cfg, k);
|
|
24
|
-
const tag = isSet ?
|
|
24
|
+
const tag = isSet ? "" : color.dim(" (default)");
|
|
25
25
|
log.plain(` ${color.cyan(k)} = ${val}${tag}`);
|
|
26
26
|
}
|
|
27
27
|
// Any non-standard custom keys the user added.
|
|
28
28
|
for (const k of Object.keys(cfg.config)) {
|
|
29
29
|
if (!CONFIG_KEYS.includes(k)) {
|
|
30
|
-
log.plain(
|
|
30
|
+
log.plain(
|
|
31
|
+
` ${color.cyan(k)} = ${cfg.config[k]}${color.yellow(" (custom)")}`,
|
|
32
|
+
);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
return 0;
|
|
34
36
|
}
|
|
35
|
-
case
|
|
37
|
+
case "set": {
|
|
36
38
|
if (!key || rest.length === 0) {
|
|
37
|
-
log.err(
|
|
39
|
+
log.err("Usage: bizone config set {key} {value}");
|
|
38
40
|
printKnownKeys();
|
|
39
41
|
return 1;
|
|
40
42
|
}
|
|
41
|
-
const value = rest.join(
|
|
43
|
+
const value = rest.join(" ");
|
|
42
44
|
if (!CONFIG_KEYS.includes(key)) {
|
|
43
45
|
log.warn(`"${key}" is not a known config key; storing it anyway.`);
|
|
44
46
|
}
|
|
@@ -47,9 +49,9 @@ export function configuration(args) {
|
|
|
47
49
|
log.ok(`Set ${color.cyan(key)} = ${value}`);
|
|
48
50
|
return 0;
|
|
49
51
|
}
|
|
50
|
-
case
|
|
52
|
+
case "remove": {
|
|
51
53
|
if (!key) {
|
|
52
|
-
log.err(
|
|
54
|
+
log.err("Usage: bizone config remove {key}");
|
|
53
55
|
return 1;
|
|
54
56
|
}
|
|
55
57
|
if (Object.prototype.hasOwnProperty.call(cfg.config, key)) {
|
|
@@ -62,7 +64,7 @@ export function configuration(args) {
|
|
|
62
64
|
return 0;
|
|
63
65
|
}
|
|
64
66
|
default:
|
|
65
|
-
log.err(
|
|
67
|
+
log.err("Usage: bizone config <get|set|remove> ...");
|
|
66
68
|
printKnownKeys();
|
|
67
69
|
return 1;
|
|
68
70
|
}
|
package/src/commands/database.js
CHANGED
|
@@ -1,47 +1,57 @@
|
|
|
1
1
|
// `bizone database|db destroy` — remove the database container and its volume.
|
|
2
2
|
// Only permitted when no other platform containers are running.
|
|
3
3
|
|
|
4
|
-
import { loadContainers, saveContainers } from
|
|
5
|
-
import { CONTAINERS } from
|
|
4
|
+
import { loadContainers, saveContainers } from "../config.js";
|
|
5
|
+
import { CONTAINERS } from "../defaults.js";
|
|
6
6
|
import {
|
|
7
7
|
dockerAvailable,
|
|
8
8
|
runningContainerNames,
|
|
9
9
|
stopContainer,
|
|
10
10
|
removeVolume,
|
|
11
|
-
} from
|
|
12
|
-
import { color, log } from
|
|
11
|
+
} from "../docker.js";
|
|
12
|
+
import { color, log } from "../colors.js";
|
|
13
13
|
|
|
14
14
|
const mysql = CONTAINERS.mysql;
|
|
15
15
|
|
|
16
16
|
export function database(args) {
|
|
17
17
|
const [sub] = args;
|
|
18
18
|
switch (sub) {
|
|
19
|
-
case
|
|
19
|
+
case "destroy":
|
|
20
20
|
return destroy();
|
|
21
21
|
default:
|
|
22
|
-
log.err(
|
|
22
|
+
log.err("Usage: bizone database destroy");
|
|
23
23
|
return 1;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function destroy() {
|
|
28
28
|
if (!dockerAvailable()) {
|
|
29
|
-
log.err(
|
|
29
|
+
log.err("Docker does not appear to be running or installed.");
|
|
30
30
|
return 1;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Refuse while any other platform container is still running.
|
|
34
34
|
const running = runningContainerNames();
|
|
35
35
|
const others = [...running].filter(
|
|
36
|
-
(n) => n.startsWith(
|
|
36
|
+
(n) => n.startsWith("bizone-") && n !== mysql.containerName,
|
|
37
37
|
);
|
|
38
38
|
if (others.length > 0) {
|
|
39
|
-
log.err(
|
|
40
|
-
|
|
39
|
+
log.err(
|
|
40
|
+
`Cannot destroy the database while platform containers are running: ${others.join(
|
|
41
|
+
", ",
|
|
42
|
+
)}`,
|
|
43
|
+
);
|
|
44
|
+
log.plain(
|
|
45
|
+
`Run ${color.cyan("bizone stop")} first, then ${color.cyan(
|
|
46
|
+
"bizone db destroy",
|
|
47
|
+
)}.`,
|
|
48
|
+
);
|
|
41
49
|
return 1;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
log.warn(
|
|
52
|
+
log.warn(
|
|
53
|
+
`This will permanently delete the database container and ALL its data (volume ${mysql.volume.name}).`,
|
|
54
|
+
);
|
|
45
55
|
|
|
46
56
|
// Stop + remove the container (no-op if already gone).
|
|
47
57
|
log.step(`Removing container ${mysql.containerName}...`);
|
|
@@ -62,7 +72,7 @@ function destroy() {
|
|
|
62
72
|
saveContainers(containers);
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
log.plain(
|
|
66
|
-
log.plain(color.green(color.bold(
|
|
75
|
+
log.plain("");
|
|
76
|
+
log.plain(color.green(color.bold("✓ Database destroyed")));
|
|
67
77
|
return 0;
|
|
68
78
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
// `bizone environment|env get|set|remove`
|
|
2
2
|
|
|
3
|
-
import { loadConfig, saveConfig } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { loadConfig, saveConfig } from "../config.js";
|
|
4
|
+
import {
|
|
5
|
+
IMAGE_TYPES,
|
|
6
|
+
SECRET_ENV_KEYS,
|
|
7
|
+
SECRET_KEY_SUBSTRINGS,
|
|
8
|
+
defaultEnvFor,
|
|
9
|
+
} from "../defaults.js";
|
|
10
|
+
import { color, log } from "../colors.js";
|
|
6
11
|
|
|
7
12
|
function isValidType(type) {
|
|
8
13
|
return IMAGE_TYPES.includes(type);
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
function typesHint() {
|
|
12
|
-
log.plain(
|
|
17
|
+
log.plain(
|
|
18
|
+
` Valid types: ${IMAGE_TYPES.map((t) => color.cyan(t)).join(", ")}`,
|
|
19
|
+
);
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
function isSecret(name) {
|
|
@@ -21,8 +28,10 @@ function isSecret(name) {
|
|
|
21
28
|
// Mask a value showing only first 4 and last 4 characters.
|
|
22
29
|
function mask(value) {
|
|
23
30
|
const v = String(value);
|
|
24
|
-
if (v.length <= 8) return
|
|
25
|
-
return `${v.slice(0, 4)}${
|
|
31
|
+
if (v.length <= 8) return "*".repeat(v.length);
|
|
32
|
+
return `${v.slice(0, 4)}${"*".repeat(Math.max(3, v.length - 8))}${v.slice(
|
|
33
|
+
-4,
|
|
34
|
+
)}`;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
export function environment(args) {
|
|
@@ -30,9 +39,9 @@ export function environment(args) {
|
|
|
30
39
|
const cfg = loadConfig();
|
|
31
40
|
|
|
32
41
|
switch (sub) {
|
|
33
|
-
case
|
|
42
|
+
case "get": {
|
|
34
43
|
if (!type) {
|
|
35
|
-
log.err(
|
|
44
|
+
log.err("Usage: bizone env get {type}");
|
|
36
45
|
typesHint();
|
|
37
46
|
return 1;
|
|
38
47
|
}
|
|
@@ -48,7 +57,7 @@ export function environment(args) {
|
|
|
48
57
|
const keys = Object.keys(effective);
|
|
49
58
|
log.plain(color.bold(`Environment for ${color.cyan(type)}:`));
|
|
50
59
|
if (keys.length === 0) {
|
|
51
|
-
log.plain(color.dim(
|
|
60
|
+
log.plain(color.dim(" (none set)"));
|
|
52
61
|
return 0;
|
|
53
62
|
}
|
|
54
63
|
for (const k of keys) {
|
|
@@ -56,16 +65,16 @@ export function environment(args) {
|
|
|
56
65
|
const display = isSecret(k) ? color.dim(mask(val)) : val;
|
|
57
66
|
const isUser = Object.prototype.hasOwnProperty.call(userVars, k);
|
|
58
67
|
const isDefault = Object.prototype.hasOwnProperty.call(defaults, k);
|
|
59
|
-
let tag =
|
|
60
|
-
if (isUser && isDefault) tag = color.yellow(
|
|
61
|
-
else if (isDefault) tag = color.dim(
|
|
68
|
+
let tag = "";
|
|
69
|
+
if (isUser && isDefault) tag = color.yellow(" (override)");
|
|
70
|
+
else if (isDefault) tag = color.dim(" (default)");
|
|
62
71
|
log.plain(` ${color.cyan(k)} = ${display}${tag}`);
|
|
63
72
|
}
|
|
64
73
|
return 0;
|
|
65
74
|
}
|
|
66
|
-
case
|
|
75
|
+
case "set": {
|
|
67
76
|
if (!type || !name || rest.length === 0) {
|
|
68
|
-
log.err(
|
|
77
|
+
log.err("Usage: bizone env set {type} {name} {value}");
|
|
69
78
|
typesHint();
|
|
70
79
|
return 1;
|
|
71
80
|
}
|
|
@@ -75,18 +84,21 @@ export function environment(args) {
|
|
|
75
84
|
return 1;
|
|
76
85
|
}
|
|
77
86
|
if (!cfg.env[type]) cfg.env[type] = {};
|
|
78
|
-
cfg.env[type][name] = rest.join(
|
|
87
|
+
cfg.env[type][name] = rest.join(" ");
|
|
79
88
|
saveConfig(cfg);
|
|
80
89
|
log.ok(`Set env ${color.cyan(type)}.${color.cyan(name)}`);
|
|
81
90
|
return 0;
|
|
82
91
|
}
|
|
83
|
-
case
|
|
92
|
+
case "remove": {
|
|
84
93
|
if (!type || !name) {
|
|
85
|
-
log.err(
|
|
94
|
+
log.err("Usage: bizone env remove {type} {name}");
|
|
86
95
|
typesHint();
|
|
87
96
|
return 1;
|
|
88
97
|
}
|
|
89
|
-
if (
|
|
98
|
+
if (
|
|
99
|
+
cfg.env[type] &&
|
|
100
|
+
Object.prototype.hasOwnProperty.call(cfg.env[type], name)
|
|
101
|
+
) {
|
|
90
102
|
delete cfg.env[type][name];
|
|
91
103
|
if (Object.keys(cfg.env[type]).length === 0) delete cfg.env[type];
|
|
92
104
|
saveConfig(cfg);
|
|
@@ -97,7 +109,7 @@ export function environment(args) {
|
|
|
97
109
|
return 0;
|
|
98
110
|
}
|
|
99
111
|
default:
|
|
100
|
-
log.err(
|
|
112
|
+
log.err("Usage: bizone env <get|set|remove> ...");
|
|
101
113
|
typesHint();
|
|
102
114
|
return 1;
|
|
103
115
|
}
|
package/src/commands/images.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// `bizone images|img get|set|remove`
|
|
2
2
|
|
|
3
|
-
import { loadConfig, saveConfig } from
|
|
4
|
-
import { CONTAINERS, IMAGE_TYPES } from
|
|
5
|
-
import { color, log } from
|
|
3
|
+
import { loadConfig, saveConfig } from "../config.js";
|
|
4
|
+
import { CONTAINERS, IMAGE_TYPES } from "../defaults.js";
|
|
5
|
+
import { color, log } from "../colors.js";
|
|
6
6
|
|
|
7
7
|
function isValidType(type) {
|
|
8
8
|
return Object.prototype.hasOwnProperty.call(CONTAINERS, type);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function typesHint() {
|
|
12
|
-
log.plain(
|
|
12
|
+
log.plain(
|
|
13
|
+
` Valid types: ${IMAGE_TYPES.map((t) => color.cyan(t)).join(", ")}`,
|
|
14
|
+
);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export function images(args) {
|
|
@@ -17,19 +19,21 @@ export function images(args) {
|
|
|
17
19
|
const cfg = loadConfig();
|
|
18
20
|
|
|
19
21
|
switch (sub) {
|
|
20
|
-
case
|
|
21
|
-
log.plain(color.bold(
|
|
22
|
+
case "get": {
|
|
23
|
+
log.plain(color.bold("Images:"));
|
|
22
24
|
for (const t in CONTAINERS) {
|
|
23
25
|
const override = cfg.images[t];
|
|
24
26
|
const val = override || CONTAINERS[t].image;
|
|
25
|
-
const tag = override
|
|
27
|
+
const tag = override
|
|
28
|
+
? color.yellow(" (override)")
|
|
29
|
+
: color.dim(" (default)");
|
|
26
30
|
log.plain(` ${color.cyan(t)} -> ${val}${tag}`);
|
|
27
31
|
}
|
|
28
32
|
return 0;
|
|
29
33
|
}
|
|
30
|
-
case
|
|
34
|
+
case "set": {
|
|
31
35
|
if (!type || rest.length === 0) {
|
|
32
|
-
log.err(
|
|
36
|
+
log.err("Usage: bizone images set {type} {url}");
|
|
33
37
|
typesHint();
|
|
34
38
|
return 1;
|
|
35
39
|
}
|
|
@@ -38,28 +42,32 @@ export function images(args) {
|
|
|
38
42
|
typesHint();
|
|
39
43
|
return 1;
|
|
40
44
|
}
|
|
41
|
-
cfg.images[type] = rest.join(
|
|
45
|
+
cfg.images[type] = rest.join(" ");
|
|
42
46
|
saveConfig(cfg);
|
|
43
47
|
log.ok(`Set image ${color.cyan(type)} -> ${cfg.images[type]}`);
|
|
44
48
|
return 0;
|
|
45
49
|
}
|
|
46
|
-
case
|
|
50
|
+
case "remove": {
|
|
47
51
|
if (!type) {
|
|
48
|
-
log.err(
|
|
52
|
+
log.err("Usage: bizone images remove {type}");
|
|
49
53
|
typesHint();
|
|
50
54
|
return 1;
|
|
51
55
|
}
|
|
52
56
|
if (Object.prototype.hasOwnProperty.call(cfg.images, type)) {
|
|
53
57
|
delete cfg.images[type];
|
|
54
58
|
saveConfig(cfg);
|
|
55
|
-
log.ok(
|
|
59
|
+
log.ok(
|
|
60
|
+
`Removed override for ${color.cyan(type)} (now: ${
|
|
61
|
+
CONTAINERS[type].image
|
|
62
|
+
})`,
|
|
63
|
+
);
|
|
56
64
|
} else {
|
|
57
65
|
log.warn(`No override set for ${color.cyan(type)}.`);
|
|
58
66
|
}
|
|
59
67
|
return 0;
|
|
60
68
|
}
|
|
61
69
|
default:
|
|
62
|
-
log.err(
|
|
70
|
+
log.err("Usage: bizone images <get|set|remove> ...");
|
|
63
71
|
typesHint();
|
|
64
72
|
return 1;
|
|
65
73
|
}
|