@muhkoo/cli 0.10.7-alpha.0 → 0.10.9-alpha.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/README.md +8 -3
- package/package.json +2 -2
- package/src/commands/promote.js +73 -0
- package/src/index.js +3 -1
package/README.md
CHANGED
|
@@ -26,12 +26,15 @@ muhkoo login
|
|
|
26
26
|
muhkoo apps create --slug my-app --email you@example.com
|
|
27
27
|
muhkoo provision --spec app.json
|
|
28
28
|
|
|
29
|
-
# 3. Build your client, then
|
|
29
|
+
# 3. Build your client, deploy to the test env, then promote to production
|
|
30
30
|
muhkoo deploy
|
|
31
|
+
muhkoo promote
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
`provision` writes `.muhkoo-app.json` (app id + keys). `deploy` reads it, so once an
|
|
34
|
-
app is provisioned
|
|
35
|
+
app is provisioned every command runs with no extra flags. `deploy` publishes to the
|
|
36
|
+
app's **test** environment; once it looks right on the test URL, `promote` copies that
|
|
37
|
+
release onto **production**, in place.
|
|
35
38
|
|
|
36
39
|
## Sign in
|
|
37
40
|
|
|
@@ -77,7 +80,7 @@ muhkoo whoami --base https://api.example.com
|
|
|
77
80
|
Account login · logout · whoami
|
|
78
81
|
Apps apps ls|get|create|slug|rm · keys rotate
|
|
79
82
|
Backend provision · tables · agents · functions
|
|
80
|
-
Hosting deploy · hosting status|rollback|rm-release|unpublish · domains
|
|
83
|
+
Hosting deploy · promote · hosting status|rollback|rm-release|unpublish · domains
|
|
81
84
|
Tools logs · eject
|
|
82
85
|
```
|
|
83
86
|
|
|
@@ -87,6 +90,8 @@ Run `muhkoo <command> --help` for details. A few highlights:
|
|
|
87
90
|
muhkoo apps ls # list your apps
|
|
88
91
|
muhkoo provision --spec app.json --dry-run # preview API calls
|
|
89
92
|
muhkoo provision --spec app.json --enable # enable agents/functions on channels
|
|
93
|
+
muhkoo deploy # publish dist/ to the test env
|
|
94
|
+
muhkoo promote # promote test → production, in place
|
|
90
95
|
muhkoo hosting status <appId> # releases + current pointer
|
|
91
96
|
muhkoo hosting rollback <appId> --release <id> # instant rollback
|
|
92
97
|
muhkoo domains add <appId> app.example.com # attach a custom domain
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muhkoo/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9-alpha.0",
|
|
4
4
|
"description": "Command-line interface for the Muhkoo platform — provision backends, deploy apps, and manage agents, functions, databases, and domains.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepublishOnly": "node scripts/sync-version.mjs --check"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@muhkoo/connect": "0.10.
|
|
41
|
+
"@muhkoo/connect": "0.10.9-alpha.0"
|
|
42
42
|
},
|
|
43
43
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
44
44
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `muhkoo promote` — promote an app's TEST environment to PRODUCTION, in place.
|
|
3
|
+
*
|
|
4
|
+
* `muhkoo deploy` publishes to the app's TEST hosting; once it looks good, this
|
|
5
|
+
* copies the test hosting release (and functions) onto the SAME app's prod env,
|
|
6
|
+
* so the live app starts running what you tested. Production DATA is never
|
|
7
|
+
* touched, and app config (CORS origins + redirect URIs) is per-env by design,
|
|
8
|
+
* so it is intentionally NOT promoted.
|
|
9
|
+
*
|
|
10
|
+
* Owner-only: authenticates with your developer session (`muhkoo login`), not an
|
|
11
|
+
* app key. The app id falls back to .muhkoo-app.json, so a provisioned app dir
|
|
12
|
+
* promotes with no flags.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { readFile, access } from "node:fs/promises";
|
|
16
|
+
import { loadConfig, resolveBase, resolveToken } from "../lib/config.js";
|
|
17
|
+
import { devCall, ensure } from "../lib/http.js";
|
|
18
|
+
import { firstOf } from "../lib/args.js";
|
|
19
|
+
import { step, ok, info, die, c } from "../lib/ui.js";
|
|
20
|
+
|
|
21
|
+
export const help = `muhkoo promote — promote an app's TEST hosting to PRODUCTION
|
|
22
|
+
|
|
23
|
+
Usage:
|
|
24
|
+
muhkoo promote [<appId>] [--base <env|url>]
|
|
25
|
+
|
|
26
|
+
Promotes the app's test hosting release + functions onto its prod environment,
|
|
27
|
+
in place (an atomic pointer flip — instant and rollback-able). Production data
|
|
28
|
+
is never touched; per-env app config (CORS + redirect URIs) is not promoted.
|
|
29
|
+
|
|
30
|
+
Owner-only: uses your developer session (run \`muhkoo login\` first). The app id
|
|
31
|
+
falls back to .muhkoo-app.json / $MUHKOO_APP_ID.`;
|
|
32
|
+
|
|
33
|
+
async function readRecord() {
|
|
34
|
+
try {
|
|
35
|
+
await access(".muhkoo-app.json");
|
|
36
|
+
return JSON.parse(await readFile(".muhkoo-app.json", "utf8"));
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default async function promote(args) {
|
|
43
|
+
const cfg = await loadConfig();
|
|
44
|
+
const record = await readRecord();
|
|
45
|
+
const appId = firstOf(args._[1], args.app, process.env.MUHKOO_APP_ID, record?.appId);
|
|
46
|
+
if (!appId) die("Missing app id. Pass `muhkoo promote <appId>`, set MUHKOO_APP_ID, or run from a provisioned app dir.");
|
|
47
|
+
|
|
48
|
+
// Prefer an explicit --base, else the app's recorded base, else the default.
|
|
49
|
+
const baseUrl = args.base ? await resolveBase(args, cfg) : record?.baseUrl || (await resolveBase(args, cfg));
|
|
50
|
+
const ctx = { baseUrl, token: await resolveToken(args, cfg) };
|
|
51
|
+
|
|
52
|
+
step(`Promoting ${appId} — test → production on ${baseUrl}`);
|
|
53
|
+
const r = ensure(await devCall(ctx, "POST", `/api/apps/${appId}/promote`), "Promote");
|
|
54
|
+
const { report = {}, errors = [] } = r.body || {};
|
|
55
|
+
|
|
56
|
+
if (args.json) {
|
|
57
|
+
info("");
|
|
58
|
+
console.log(JSON.stringify(r.body, null, 2));
|
|
59
|
+
} else {
|
|
60
|
+
info("");
|
|
61
|
+
ok("Promoted test → production.");
|
|
62
|
+
if (report.hosting) info(` ${c.bold("hosting")} ${report.hosting}`);
|
|
63
|
+
if (report.functions) info(` ${c.bold("functions")} ${report.functions}`);
|
|
64
|
+
if (report.config) info(` ${c.bold("config")} ${report.config}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (Array.isArray(errors) && errors.length) {
|
|
68
|
+
info("");
|
|
69
|
+
for (const e of errors) info(c.yellow(` ! ${e}`));
|
|
70
|
+
// Partial promote (e.g. a function failed) — signal non-zero so CI notices.
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const COMMANDS = {
|
|
|
18
18
|
keys: () => import("./commands/apps.js"), // `keys rotate` lives in apps.js
|
|
19
19
|
provision: () => import("./commands/provision.js"),
|
|
20
20
|
deploy: () => import("./commands/deploy.js"),
|
|
21
|
+
promote: () => import("./commands/promote.js"),
|
|
21
22
|
hosting: () => import("./commands/hosting.js"),
|
|
22
23
|
domains: () => import("./commands/domains.js"),
|
|
23
24
|
tables: () => import("./commands/tables.js"),
|
|
@@ -48,7 +49,8 @@ Backend
|
|
|
48
49
|
functions ls|get|code|deploy|rm|enable|disable
|
|
49
50
|
|
|
50
51
|
Hosting
|
|
51
|
-
deploy deploy a built client to Muhkoo hosting
|
|
52
|
+
deploy deploy a built client to Muhkoo hosting (test env)
|
|
53
|
+
promote promote an app's test hosting → production
|
|
52
54
|
hosting status|rollback|rm-release|unpublish
|
|
53
55
|
domains ls|add|rm manage custom domains
|
|
54
56
|
|