badmfck-api-server 6.0.10 → 6.0.11
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
CHANGED
|
@@ -707,6 +707,7 @@ git: it holds credentials.
|
|
|
707
707
|
|
|
708
708
|
| Command | What it does |
|
|
709
709
|
|---|---|
|
|
710
|
+
| `badmfck wizards` | list every interactive wizard below with what it does, and run one |
|
|
710
711
|
| `badmfck deploy [config]` | build and upload the project |
|
|
711
712
|
| `badmfck activate [config] [blue\|green]` | switch traffic to a slot (blue-green) |
|
|
712
713
|
| `badmfck status [config]` | active and last deployed slot, recent history |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Wizards(): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Wizards = Wizards;
|
|
4
|
+
const process_1 = require("process");
|
|
5
|
+
const cliCommon_1 = require("./cliCommon");
|
|
6
|
+
const cliPrompt_1 = require("./cliPrompt");
|
|
7
|
+
const HashPassword_1 = require("./HashPassword");
|
|
8
|
+
const ProjectConfigWizard_1 = require("./ProjectConfigWizard");
|
|
9
|
+
const AccessConfigWizard_1 = require("./AccessConfigWizard");
|
|
10
|
+
const SetupConfigWizard_1 = require("./SetupConfigWizard");
|
|
11
|
+
const MigrateConfigsWizard_1 = require("./MigrateConfigsWizard");
|
|
12
|
+
const WIZARDS = [
|
|
13
|
+
{ command: "badmfck project-config", title: "New project config for the deployer",
|
|
14
|
+
what: "Asks for everything a project needs (folder, token, deploy steps, config values, blue-green, nginx, secrets file, review) and writes the deployer's project config plus a matching deploy.json.",
|
|
15
|
+
where: "anywhere; copy the config to the deployer's projects folder",
|
|
16
|
+
run: () => (0, ProjectConfigWizard_1.ProjectConfigWizard)() },
|
|
17
|
+
{ command: "badmfck setup-config [file|folder]", title: "Deployer users, reviewers and allowed IPs",
|
|
18
|
+
what: "Edits the deployer's setup.json from a menu: add, rename or remove deployer users, change passwords, manage reviewers, allowed addresses and the review page URL.",
|
|
19
|
+
where: "on the deployer server",
|
|
20
|
+
run: () => (0, SetupConfigWizard_1.SetupConfigWizard)() },
|
|
21
|
+
{ command: "badmfck access-config [file]", title: "Monitor and documentation access",
|
|
22
|
+
what: "Creates or edits an app's access.json: monitor users with roles and passwords, documentation users, the monitor's allowed addresses. Finds the file named in the project's code.",
|
|
23
|
+
where: "on the app server, or in the project folder",
|
|
24
|
+
run: () => (0, AccessConfigWizard_1.AccessConfigWizard)() },
|
|
25
|
+
{ command: "badmfck migrate-configs [folder] [--yes]", title: "Upgrade old configs to hashed secrets",
|
|
26
|
+
what: "Hashes the plain passwords and tokens in old setup.json, project configs and access.json files, computing each hash from the value already there; clients keep their deploy.json.",
|
|
27
|
+
where: "on the servers, right after upgrading to 6.x",
|
|
28
|
+
run: () => (0, MigrateConfigsWizard_1.MigrateConfigsWizard)() },
|
|
29
|
+
{ command: "badmfck project-token", title: "New project token",
|
|
30
|
+
what: "Generates a random project token: the token itself for deploy.json and its hash for the project config.",
|
|
31
|
+
where: "anywhere",
|
|
32
|
+
run: () => (0, HashPassword_1.ProjectToken)("generate") },
|
|
33
|
+
{ command: "badmfck project-token --hash", title: "Hash an existing project token",
|
|
34
|
+
what: "Asks for a token you already use and prints its hash for the project config.",
|
|
35
|
+
where: "anywhere",
|
|
36
|
+
run: () => (0, HashPassword_1.ProjectToken)("hash") },
|
|
37
|
+
{ command: "badmfck hash-password", title: "Hash a monitor password",
|
|
38
|
+
what: "Prints a monitor user entry with a hashed password, to paste into access.json or the access option.",
|
|
39
|
+
where: "anywhere",
|
|
40
|
+
run: () => (0, HashPassword_1.HashPassword)("monitor") },
|
|
41
|
+
{ command: "badmfck hash-password --deployer", title: "Hash a deployer password",
|
|
42
|
+
what: "Prints a deployer user entry with a hashed password, to paste into setup.json.",
|
|
43
|
+
where: "anywhere",
|
|
44
|
+
run: () => (0, HashPassword_1.HashPassword)("deployer") },
|
|
45
|
+
];
|
|
46
|
+
async function Wizards() {
|
|
47
|
+
const { red, dim, bold, green } = (0, cliCommon_1.palette)();
|
|
48
|
+
if (!process_1.stdin.isTTY) {
|
|
49
|
+
console.error(red("✗ wizards is interactive — run it in a terminal. To script, call a command directly (see `badmfck` for the list)."));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
for (;;) {
|
|
53
|
+
console.log(bold("\nbadmfck wizards\n"));
|
|
54
|
+
WIZARDS.forEach((w, i) => {
|
|
55
|
+
console.log(` ${bold(String(i + 1).padStart(2) + ")")} ${bold(w.title)}`);
|
|
56
|
+
console.log(` ${w.what}`);
|
|
57
|
+
console.log(dim(` where: ${w.where} · directly: npx ${w.command}`));
|
|
58
|
+
});
|
|
59
|
+
console.log(`\n ${bold("q)")} quit`);
|
|
60
|
+
const choice = (await (0, cliPrompt_1.ask)("\nChoose", "")).toLowerCase();
|
|
61
|
+
if (choice === "q" || choice === "")
|
|
62
|
+
return;
|
|
63
|
+
const w = WIZARDS[Number(choice) - 1];
|
|
64
|
+
if (!/^\d+$/.test(choice) || !w) {
|
|
65
|
+
console.log(red(" ✗ choose a number or q"));
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
console.log(green(`\n→ ${w.title}`) + dim(` (next time: npx ${w.command})`));
|
|
69
|
+
await w.run();
|
|
70
|
+
if (!(await (0, cliPrompt_1.yes)("\nBack to the list of wizards?", false)))
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -12,8 +12,10 @@ const ProjectConfigWizard_1 = require("./ProjectConfigWizard");
|
|
|
12
12
|
const AccessConfigWizard_1 = require("./AccessConfigWizard");
|
|
13
13
|
const MigrateConfigsWizard_1 = require("./MigrateConfigsWizard");
|
|
14
14
|
const SetupConfigWizard_1 = require("./SetupConfigWizard");
|
|
15
|
+
const Wizards_1 = require("./Wizards");
|
|
15
16
|
function usage() {
|
|
16
17
|
console.error("Usage:");
|
|
18
|
+
console.error(" badmfck wizards — list every interactive wizard and run one");
|
|
17
19
|
console.error(" badmfck deploy [config.json] — build + upload the current project");
|
|
18
20
|
console.error(" badmfck activate [config.json] [blue|green] — switch blue-green slot (omit slot for lastDeployed)");
|
|
19
21
|
console.error(" badmfck status [config.json] — show active / last deployed slot");
|
|
@@ -111,6 +113,14 @@ async function main() {
|
|
|
111
113
|
await (0, HashPassword_1.HashPassword)(rest.includes("--deployer") ? "deployer" : "monitor");
|
|
112
114
|
break;
|
|
113
115
|
}
|
|
116
|
+
case "wizards": {
|
|
117
|
+
if (rest.length) {
|
|
118
|
+
console.error("wizards takes no arguments.");
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
await (0, Wizards_1.Wizards)();
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
114
124
|
case "setup-config": {
|
|
115
125
|
if (rest.length > 1) {
|
|
116
126
|
console.error("Usage: badmfck setup-config [file|folder]");
|