@rodyssey/cli 0.1.5 → 0.1.7
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 +20 -0
- package/dist/cli.js +450 -191
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -12,4 +12,24 @@ To run:
|
|
|
12
12
|
bun run index.ts
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Release
|
|
16
|
+
|
|
17
|
+
Release automation lives in `.github/workflows/release.yml` and uses Changesets.
|
|
18
|
+
|
|
19
|
+
For a change that should publish a new CLI version:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun run changeset
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Choose `patch`, `minor`, or `major`, commit the generated `.changeset/*.md` file, and merge to `main`. The workflow opens or updates a release PR with the version bump and changelog. Merging that release PR publishes `@rodyssey/cli` to npm.
|
|
26
|
+
|
|
27
|
+
Configure npm trusted publishing for the package with:
|
|
28
|
+
|
|
29
|
+
- Organization/user: `airconcepts`
|
|
30
|
+
- Repository: `ro-cli`
|
|
31
|
+
- Workflow filename: `release.yml`
|
|
32
|
+
|
|
33
|
+
This repository is private, so npm provenance is disabled. If the repository becomes public later, change `publishConfig.provenance` and `NPM_CONFIG_PROVENANCE` back to `true`.
|
|
34
|
+
|
|
15
35
|
This project was created using `bun init` in bun v1.3.9. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
package/dist/cli.js
CHANGED
|
@@ -2068,6 +2068,47 @@ var {
|
|
|
2068
2068
|
Option,
|
|
2069
2069
|
Help
|
|
2070
2070
|
} = import__.default;
|
|
2071
|
+
// package.json
|
|
2072
|
+
var package_default = {
|
|
2073
|
+
name: "@rodyssey/cli",
|
|
2074
|
+
version: "0.1.7",
|
|
2075
|
+
description: "Scaffold new projects from airconcepts templates",
|
|
2076
|
+
repository: {
|
|
2077
|
+
type: "git",
|
|
2078
|
+
url: "git+https://github.com/airconcepts/ro-cli.git"
|
|
2079
|
+
},
|
|
2080
|
+
bin: {
|
|
2081
|
+
"@rodyssey/cli": "dist/cli.js"
|
|
2082
|
+
},
|
|
2083
|
+
files: [
|
|
2084
|
+
"dist"
|
|
2085
|
+
],
|
|
2086
|
+
type: "module",
|
|
2087
|
+
module: "index.ts",
|
|
2088
|
+
scripts: {
|
|
2089
|
+
build: "bun build src/cli.ts --outdir dist --target node",
|
|
2090
|
+
start: "bun dist/cli.js",
|
|
2091
|
+
changeset: "changeset",
|
|
2092
|
+
"version-packages": "changeset version",
|
|
2093
|
+
release: "bun run build && changeset publish",
|
|
2094
|
+
prepublishOnly: "bun run build"
|
|
2095
|
+
},
|
|
2096
|
+
publishConfig: {
|
|
2097
|
+
access: "public",
|
|
2098
|
+
provenance: false
|
|
2099
|
+
},
|
|
2100
|
+
dependencies: {
|
|
2101
|
+
commander: "^13.1.0",
|
|
2102
|
+
mime: "^4.1.0"
|
|
2103
|
+
},
|
|
2104
|
+
devDependencies: {
|
|
2105
|
+
"@changesets/cli": "^2.30.0",
|
|
2106
|
+
"@types/bun": "latest"
|
|
2107
|
+
},
|
|
2108
|
+
peerDependencies: {
|
|
2109
|
+
typescript: "^5"
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2071
2112
|
|
|
2072
2113
|
// src/auth.ts
|
|
2073
2114
|
import { spawn } from "node:child_process";
|
|
@@ -2262,7 +2303,9 @@ ${JSON.stringify(payload, null, 2)}`);
|
|
|
2262
2303
|
token,
|
|
2263
2304
|
user: extractUser(payload)
|
|
2264
2305
|
};
|
|
2265
|
-
|
|
2306
|
+
if (options.persist !== false) {
|
|
2307
|
+
storeSession(session);
|
|
2308
|
+
}
|
|
2266
2309
|
return session;
|
|
2267
2310
|
}
|
|
2268
2311
|
async function me(options) {
|
|
@@ -2296,12 +2339,29 @@ ${JSON.stringify(payload, null, 2)}`);
|
|
|
2296
2339
|
|
|
2297
2340
|
// src/create.ts
|
|
2298
2341
|
import { execSync } from "node:child_process";
|
|
2299
|
-
import { existsSync as existsSync3,
|
|
2342
|
+
import { existsSync as existsSync3, rmSync } from "node:fs";
|
|
2300
2343
|
import path2 from "node:path";
|
|
2301
2344
|
|
|
2302
2345
|
// src/utils.ts
|
|
2303
2346
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "node:fs";
|
|
2304
2347
|
import path from "node:path";
|
|
2348
|
+
function upsertEnvValue(content, key, value) {
|
|
2349
|
+
const line = `${key}=${value}`;
|
|
2350
|
+
const pattern = new RegExp(`^${key}=.*$`, "m");
|
|
2351
|
+
if (pattern.test(content))
|
|
2352
|
+
return content.replace(pattern, line);
|
|
2353
|
+
return `${content}${content.endsWith(`
|
|
2354
|
+
`) || content.length === 0 ? "" : `
|
|
2355
|
+
`}${line}
|
|
2356
|
+
`;
|
|
2357
|
+
}
|
|
2358
|
+
function upsertEnvFile(filePath, entries) {
|
|
2359
|
+
let content = existsSync2(filePath) ? readFileSync2(filePath, "utf-8") : "";
|
|
2360
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
2361
|
+
content = upsertEnvValue(content, key, value);
|
|
2362
|
+
}
|
|
2363
|
+
writeFileSync2(filePath, content, "utf-8");
|
|
2364
|
+
}
|
|
2305
2365
|
function replaceInFile(filePath, search, replace) {
|
|
2306
2366
|
const content = readFileSync2(filePath, "utf-8");
|
|
2307
2367
|
const updated = content.replaceAll(search, replace);
|
|
@@ -2374,22 +2434,11 @@ function extractDeployToken(payload) {
|
|
|
2374
2434
|
const webapp = nestedObject(payload, "webapp");
|
|
2375
2435
|
return pickString(webapp?.deployToken, webapp?.deploymentToken);
|
|
2376
2436
|
}
|
|
2377
|
-
function upsertEnvValue(content, key, value) {
|
|
2378
|
-
const line = `${key}=${value}`;
|
|
2379
|
-
const pattern = new RegExp(`^${key}=.*$`, "m");
|
|
2380
|
-
if (pattern.test(content))
|
|
2381
|
-
return content.replace(pattern, line);
|
|
2382
|
-
return `${content}${content.endsWith(`
|
|
2383
|
-
`) || content.length === 0 ? "" : `
|
|
2384
|
-
`}${line}
|
|
2385
|
-
`;
|
|
2386
|
-
}
|
|
2387
2437
|
function writeProjectEnv(projectDir, provisioned) {
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
writeFileSync3(envFile, content, "utf-8");
|
|
2438
|
+
upsertEnvFile(path2.join(projectDir, ".env"), {
|
|
2439
|
+
WEBAPP_ID: provisioned.webappId,
|
|
2440
|
+
DEPLOY_TOKEN: provisioned.deployToken
|
|
2441
|
+
});
|
|
2393
2442
|
}
|
|
2394
2443
|
async function provisionWebapp(projectName, options) {
|
|
2395
2444
|
const cmsUrl = resolveCmsUrl(options.env, options.cmsUrl);
|
|
@@ -2481,7 +2530,7 @@ async function create(projectName, repoUrl, templateName, autoCreate) {
|
|
|
2481
2530
|
|
|
2482
2531
|
// src/deploy.ts
|
|
2483
2532
|
import { execSync as execSync2 } from "node:child_process";
|
|
2484
|
-
import { existsSync as existsSync4, readFileSync as
|
|
2533
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync, statSync, unlinkSync } from "node:fs";
|
|
2485
2534
|
import { join as join2 } from "node:path";
|
|
2486
2535
|
|
|
2487
2536
|
// node_modules/mime/dist/types/other.js
|
|
@@ -3693,7 +3742,7 @@ function getAllFiles(dirPath, arrayOfFiles = []) {
|
|
|
3693
3742
|
return arrayOfFiles;
|
|
3694
3743
|
}
|
|
3695
3744
|
function fileToBlob(filePath) {
|
|
3696
|
-
const buffer =
|
|
3745
|
+
const buffer = readFileSync3(filePath);
|
|
3697
3746
|
return new Blob([buffer], { type: src_default.getType(filePath) || "application/octet-stream" });
|
|
3698
3747
|
}
|
|
3699
3748
|
async function deploy(env = "development", overrides = {}) {
|
|
@@ -3780,7 +3829,7 @@ ${errorText}`);
|
|
|
3780
3829
|
console.log(`\uD83D\uDCDC Step 3: Setting up ${scriptFiles.length} scripts (APIs & Crons)...`);
|
|
3781
3830
|
const scriptsPayload = { api: {}, cron: {}, cronConfig: null };
|
|
3782
3831
|
for (const f of scriptFiles) {
|
|
3783
|
-
const content =
|
|
3832
|
+
const content = readFileSync3(f, "utf-8");
|
|
3784
3833
|
const relativePath = f.substring(BUILD_DIR.length + 1).replace(/\\/g, "/");
|
|
3785
3834
|
if (relativePath === "cron-jobs/cron.config.json") {
|
|
3786
3835
|
scriptsPayload.cronConfig = JSON.parse(content);
|
|
@@ -3820,7 +3869,7 @@ ${errorText}`);
|
|
|
3820
3869
|
console.log(`✅ Created ${ZIP_FILE}
|
|
3821
3870
|
`);
|
|
3822
3871
|
console.log("☁️ Step 5: Deploying HTML zip to server...");
|
|
3823
|
-
const zipBuffer =
|
|
3872
|
+
const zipBuffer = readFileSync3(ZIP_FILE);
|
|
3824
3873
|
try {
|
|
3825
3874
|
const response = await fetch(DEPLOY_URL, {
|
|
3826
3875
|
method: "POST",
|
|
@@ -3853,20 +3902,377 @@ ${errorText}`);
|
|
|
3853
3902
|
✨ Deployment successful!`);
|
|
3854
3903
|
}
|
|
3855
3904
|
|
|
3905
|
+
// src/promote.ts
|
|
3906
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
3907
|
+
import { resolve as resolve2 } from "node:path";
|
|
3908
|
+
|
|
3909
|
+
// src/update-webapp-config.ts
|
|
3910
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
3911
|
+
import { resolve } from "node:path";
|
|
3912
|
+
var CONFIG_URLS = {
|
|
3913
|
+
local: "http://localhost:5176/api/webapps/config",
|
|
3914
|
+
development: "https://development-cms.rodyssey.ai/api/webapps/config",
|
|
3915
|
+
staging: "https://staging-cms.rodyssey.ai/api/webapps/config",
|
|
3916
|
+
production: "https://cms.rodyssey.ai/api/webapps/config"
|
|
3917
|
+
};
|
|
3918
|
+
function parseJsonOption(value, optionName) {
|
|
3919
|
+
const maybePath = resolve(process.cwd(), value);
|
|
3920
|
+
const raw = existsSync5(maybePath) ? readFileSync4(maybePath, "utf-8") : value;
|
|
3921
|
+
try {
|
|
3922
|
+
const parsed = JSON.parse(raw);
|
|
3923
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
3924
|
+
throw new Error("value must be a JSON object");
|
|
3925
|
+
}
|
|
3926
|
+
return parsed;
|
|
3927
|
+
} catch (error) {
|
|
3928
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3929
|
+
throw new Error(`Invalid ${optionName}: ${message}`);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
function coerceMaybeNull(value) {
|
|
3933
|
+
if (value === undefined)
|
|
3934
|
+
return;
|
|
3935
|
+
if (value === "null")
|
|
3936
|
+
return null;
|
|
3937
|
+
return value;
|
|
3938
|
+
}
|
|
3939
|
+
function resolveConfigUrl(options, required = true) {
|
|
3940
|
+
const configUrl = options.url || process.env.WEBAPP_CONFIG_URL || CONFIG_URLS[options.env];
|
|
3941
|
+
if (!configUrl) {
|
|
3942
|
+
if (!required)
|
|
3943
|
+
return;
|
|
3944
|
+
console.error("❌ Error: no webapp config endpoint configured.");
|
|
3945
|
+
console.error(`\uD83D\uDCA1 Use one of these environments: ${Object.keys(CONFIG_URLS).join(", ")}, pass --url, or set WEBAPP_CONFIG_URL in your .env file.`);
|
|
3946
|
+
process.exit(1);
|
|
3947
|
+
}
|
|
3948
|
+
const url = new URL(configUrl);
|
|
3949
|
+
if (!options.host && !options.port) {
|
|
3950
|
+
return url.toString().replace(/\/$/, "");
|
|
3951
|
+
}
|
|
3952
|
+
if (options.host)
|
|
3953
|
+
url.hostname = options.host;
|
|
3954
|
+
if (options.port)
|
|
3955
|
+
url.port = String(options.port);
|
|
3956
|
+
return url.toString().replace(/\/$/, "");
|
|
3957
|
+
}
|
|
3958
|
+
function buildDetailsPayload(options) {
|
|
3959
|
+
const payload = options.details ? parseJsonOption(options.details, "--details") : {};
|
|
3960
|
+
const title = coerceMaybeNull(options.title);
|
|
3961
|
+
const description = coerceMaybeNull(options.description);
|
|
3962
|
+
const coverImg = coerceMaybeNull(options.coverImg);
|
|
3963
|
+
if (title !== undefined)
|
|
3964
|
+
payload.title = title;
|
|
3965
|
+
if (description !== undefined)
|
|
3966
|
+
payload.description = description;
|
|
3967
|
+
if (coverImg !== undefined)
|
|
3968
|
+
payload.coverImg = coverImg;
|
|
3969
|
+
if (options.localization !== undefined) {
|
|
3970
|
+
payload.localization = options.localization === "null" ? null : parseJsonOption(options.localization, "--localization");
|
|
3971
|
+
}
|
|
3972
|
+
return payload;
|
|
3973
|
+
}
|
|
3974
|
+
function resolveWebappId(webappId) {
|
|
3975
|
+
const resolved = webappId || process.env.WEBAPP_ID;
|
|
3976
|
+
if (!resolved) {
|
|
3977
|
+
console.error("❌ Error: WEBAPP_ID is not set. Pass --webapp-id or set it in your .env file.");
|
|
3978
|
+
process.exit(1);
|
|
3979
|
+
}
|
|
3980
|
+
return resolved;
|
|
3981
|
+
}
|
|
3982
|
+
function ensureDeployToken(env) {
|
|
3983
|
+
if (process.env.DEPLOY_TOKEN)
|
|
3984
|
+
return;
|
|
3985
|
+
console.error("❌ Error: DEPLOY_TOKEN is not set in environment variables.");
|
|
3986
|
+
console.info(`\uD83D\uDCA1 Please check your .env or .env.${env} file.`);
|
|
3987
|
+
process.exit(1);
|
|
3988
|
+
}
|
|
3989
|
+
function getConfigUrl(options, required = true) {
|
|
3990
|
+
return resolveConfigUrl(options, required);
|
|
3991
|
+
}
|
|
3992
|
+
async function fetchWebappConfig(options) {
|
|
3993
|
+
loadEnv(options.env);
|
|
3994
|
+
const webappId = resolveWebappId(options.webappId);
|
|
3995
|
+
const CONFIG_URL = getConfigUrl(options);
|
|
3996
|
+
if (!CONFIG_URL) {
|
|
3997
|
+
throw new Error("No webapp config endpoint configured.");
|
|
3998
|
+
}
|
|
3999
|
+
ensureDeployToken(options.env);
|
|
4000
|
+
const url = new URL(CONFIG_URL);
|
|
4001
|
+
url.searchParams.set("webappId", webappId);
|
|
4002
|
+
const response = await fetch(url, {
|
|
4003
|
+
method: "GET",
|
|
4004
|
+
headers: {
|
|
4005
|
+
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
|
|
4006
|
+
Accept: "application/json"
|
|
4007
|
+
}
|
|
4008
|
+
});
|
|
4009
|
+
if (!response.ok) {
|
|
4010
|
+
const errorText = await response.text();
|
|
4011
|
+
throw new Error(`Config fetch failed: ${response.status} ${response.statusText}
|
|
4012
|
+
${errorText}`);
|
|
4013
|
+
}
|
|
4014
|
+
return await response.json();
|
|
4015
|
+
}
|
|
4016
|
+
async function getWebappConfig(options) {
|
|
4017
|
+
loadEnv(options.env);
|
|
4018
|
+
const webappId = resolveWebappId(options.webappId);
|
|
4019
|
+
const CONFIG_URL = getConfigUrl(options);
|
|
4020
|
+
if (!CONFIG_URL)
|
|
4021
|
+
return;
|
|
4022
|
+
const url = new URL(CONFIG_URL);
|
|
4023
|
+
url.searchParams.set("webappId", webappId);
|
|
4024
|
+
console.log(`⚙️ Pulling webapp config for [${options.env}] environment...`);
|
|
4025
|
+
console.log(`\uD83D\uDCCD Config URL: ${url.toString()}`);
|
|
4026
|
+
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}
|
|
4027
|
+
`);
|
|
4028
|
+
const config = await fetchWebappConfig(options);
|
|
4029
|
+
const output = JSON.stringify(config, null, 2);
|
|
4030
|
+
if (options.out) {
|
|
4031
|
+
writeFileSync3(options.out, `${output}
|
|
4032
|
+
`, "utf-8");
|
|
4033
|
+
console.log(`✅ Webapp config written to ${options.out}`);
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
console.log(output);
|
|
4037
|
+
}
|
|
4038
|
+
async function updateWebappConfig(options) {
|
|
4039
|
+
loadEnv(options.env);
|
|
4040
|
+
const webappId = resolveWebappId(options.webappId);
|
|
4041
|
+
const details = buildDetailsPayload(options);
|
|
4042
|
+
if (Object.keys(details).length === 0) {
|
|
4043
|
+
console.error("❌ Error: no detail fields provided. Use --title, --description, --cover-img, --localization, or --details.");
|
|
4044
|
+
process.exit(1);
|
|
4045
|
+
}
|
|
4046
|
+
const payload = { webappId, details };
|
|
4047
|
+
const CONFIG_URL = getConfigUrl(options, !options.dryRun);
|
|
4048
|
+
if (!options.dryRun)
|
|
4049
|
+
ensureDeployToken(options.env);
|
|
4050
|
+
console.log(`⚙️ Updating webapp config for [${options.env}] environment...`);
|
|
4051
|
+
if (CONFIG_URL) {
|
|
4052
|
+
console.log(`\uD83D\uDCCD Config URL: ${CONFIG_URL}`);
|
|
4053
|
+
}
|
|
4054
|
+
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}
|
|
4055
|
+
`);
|
|
4056
|
+
if (options.dryRun) {
|
|
4057
|
+
console.log("\uD83E\uDDEA Dry run payload:");
|
|
4058
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
4059
|
+
return;
|
|
4060
|
+
}
|
|
4061
|
+
if (!CONFIG_URL)
|
|
4062
|
+
return;
|
|
4063
|
+
const response = await fetch(CONFIG_URL, {
|
|
4064
|
+
method: "PATCH",
|
|
4065
|
+
headers: {
|
|
4066
|
+
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
|
|
4067
|
+
"Content-Type": "application/json"
|
|
4068
|
+
},
|
|
4069
|
+
body: JSON.stringify(payload)
|
|
4070
|
+
});
|
|
4071
|
+
if (!response.ok) {
|
|
4072
|
+
const errorText = await response.text();
|
|
4073
|
+
throw new Error(`Config update failed: ${response.status} ${response.statusText}
|
|
4074
|
+
${errorText}`);
|
|
4075
|
+
}
|
|
4076
|
+
const result = await response.json().catch(() => {
|
|
4077
|
+
return;
|
|
4078
|
+
});
|
|
4079
|
+
console.log("✅ Webapp config updated");
|
|
4080
|
+
if (result !== undefined) {
|
|
4081
|
+
console.log(`
|
|
4082
|
+
\uD83D\uDCCB Update result:`, result);
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
|
|
4086
|
+
// src/promote.ts
|
|
4087
|
+
var DEFAULT_SOURCE_ENV = "development";
|
|
4088
|
+
var PROD_ENV = "production";
|
|
4089
|
+
var PROD_ENV_FILE = ".env.production";
|
|
4090
|
+
function isObject3(value) {
|
|
4091
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
4092
|
+
}
|
|
4093
|
+
function pickString2(...values) {
|
|
4094
|
+
return values.find((value) => typeof value === "string" && value.length > 0);
|
|
4095
|
+
}
|
|
4096
|
+
function nestedObject2(value, key) {
|
|
4097
|
+
if (!isObject3(value))
|
|
4098
|
+
return;
|
|
4099
|
+
const nested = value[key];
|
|
4100
|
+
return isObject3(nested) ? nested : undefined;
|
|
4101
|
+
}
|
|
4102
|
+
function extractDeployToken2(payload) {
|
|
4103
|
+
const webapp = nestedObject2(payload, "webapp");
|
|
4104
|
+
return pickString2(webapp?.deployToken, webapp?.deploymentToken);
|
|
4105
|
+
}
|
|
4106
|
+
function unwrapSourceDetails(payload) {
|
|
4107
|
+
if (!isObject3(payload))
|
|
4108
|
+
return {};
|
|
4109
|
+
const inner = payload.details;
|
|
4110
|
+
if (isObject3(inner))
|
|
4111
|
+
return inner;
|
|
4112
|
+
return payload;
|
|
4113
|
+
}
|
|
4114
|
+
function parseDetailsOption(value) {
|
|
4115
|
+
const maybePath = resolve2(process.cwd(), value);
|
|
4116
|
+
const raw = existsSync6(maybePath) ? readFileSync5(maybePath, "utf-8") : value;
|
|
4117
|
+
try {
|
|
4118
|
+
const parsed = JSON.parse(raw);
|
|
4119
|
+
if (!isObject3(parsed)) {
|
|
4120
|
+
throw new Error("value must be a JSON object");
|
|
4121
|
+
}
|
|
4122
|
+
return parsed;
|
|
4123
|
+
} catch (error) {
|
|
4124
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4125
|
+
throw new Error(`Invalid --details: ${message}`);
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
async function prompt(question) {
|
|
4129
|
+
const readline = await import("node:readline");
|
|
4130
|
+
const rl = readline.createInterface({
|
|
4131
|
+
input: process.stdin,
|
|
4132
|
+
output: process.stdout
|
|
4133
|
+
});
|
|
4134
|
+
return new Promise((resolveAnswer) => {
|
|
4135
|
+
rl.question(question, (answer) => {
|
|
4136
|
+
rl.close();
|
|
4137
|
+
resolveAnswer(answer);
|
|
4138
|
+
});
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
function isAffirmative(answer) {
|
|
4142
|
+
const trimmed = answer.trim().toLowerCase();
|
|
4143
|
+
return trimmed === "" || trimmed === "y" || trimmed === "yes";
|
|
4144
|
+
}
|
|
4145
|
+
async function promote(options) {
|
|
4146
|
+
loadEnv();
|
|
4147
|
+
const webappId = process.env.WEBAPP_ID;
|
|
4148
|
+
if (!webappId) {
|
|
4149
|
+
console.error("❌ Error: WEBAPP_ID is not set in .env.");
|
|
4150
|
+
console.info("\uD83D\uDCA1 Run `ro app create --auto` first, or set WEBAPP_ID manually.");
|
|
4151
|
+
process.exit(1);
|
|
4152
|
+
}
|
|
4153
|
+
const prodEnvPath = resolve2(process.cwd(), PROD_ENV_FILE);
|
|
4154
|
+
if (existsSync6(prodEnvPath)) {
|
|
4155
|
+
const content = readFileSync5(prodEnvPath, "utf-8");
|
|
4156
|
+
if (/^WEBAPP_ID=.+/m.test(content)) {
|
|
4157
|
+
console.error(`❌ Error: ${PROD_ENV_FILE} already has WEBAPP_ID. The app appears to be promoted already.`);
|
|
4158
|
+
process.exit(1);
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
const sourceEnv = options.from || DEFAULT_SOURCE_ENV;
|
|
4162
|
+
let details;
|
|
4163
|
+
if (options.details) {
|
|
4164
|
+
details = parseDetailsOption(options.details);
|
|
4165
|
+
console.log("\uD83D\uDCE6 Using details from --details flag.");
|
|
4166
|
+
} else {
|
|
4167
|
+
console.log(`\uD83D\uDCE5 Fetching latest details from [${sourceEnv}]...`);
|
|
4168
|
+
const sourceResponse = await fetchWebappConfig({ env: sourceEnv, webappId });
|
|
4169
|
+
const sourceDetails = unwrapSourceDetails(sourceResponse);
|
|
4170
|
+
console.log(`
|
|
4171
|
+
\uD83D\uDCCB Source details:`);
|
|
4172
|
+
console.log(JSON.stringify(sourceDetails, null, 2));
|
|
4173
|
+
console.log();
|
|
4174
|
+
if (options.yes) {
|
|
4175
|
+
console.log("✓ --yes flag set, using server details.");
|
|
4176
|
+
details = sourceDetails;
|
|
4177
|
+
} else {
|
|
4178
|
+
const answer = await prompt("Pull these details from server? (Y/n): ");
|
|
4179
|
+
if (isAffirmative(answer)) {
|
|
4180
|
+
details = sourceDetails;
|
|
4181
|
+
} else {
|
|
4182
|
+
console.error("❌ Aborted. Re-run with --details <json|file> to provide custom details.");
|
|
4183
|
+
process.exit(1);
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
console.log(`
|
|
4188
|
+
\uD83D\uDD10 Logging in to ${PROD_ENV} CMS (ephemeral, not stored)...`);
|
|
4189
|
+
const session = await login({
|
|
4190
|
+
env: PROD_ENV,
|
|
4191
|
+
cmsUrl: options.cmsUrl,
|
|
4192
|
+
persist: false
|
|
4193
|
+
});
|
|
4194
|
+
console.log(`✅ Logged in to ${session.cmsUrl}`);
|
|
4195
|
+
const cmsUrl = resolveCmsUrl(PROD_ENV, options.cmsUrl);
|
|
4196
|
+
const promoteUrl = options.promoteUrl || `${cmsUrl}/api/cli/webapps/promote`;
|
|
4197
|
+
const promoteBody = { webappId, details };
|
|
4198
|
+
console.log(`
|
|
4199
|
+
\uD83D\uDE80 Promoting webapp to ${PROD_ENV}...`);
|
|
4200
|
+
console.log(`\uD83D\uDCCD Promote URL: ${promoteUrl}`);
|
|
4201
|
+
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}`);
|
|
4202
|
+
console.log("\uD83D\uDCE6 Promote body:");
|
|
4203
|
+
console.log(JSON.stringify(promoteBody, null, 2));
|
|
4204
|
+
console.log();
|
|
4205
|
+
const response = await fetch(promoteUrl, {
|
|
4206
|
+
method: "POST",
|
|
4207
|
+
headers: {
|
|
4208
|
+
Accept: "application/json",
|
|
4209
|
+
Authorization: `Bearer ${session.token}`,
|
|
4210
|
+
"Content-Type": "application/json"
|
|
4211
|
+
},
|
|
4212
|
+
body: JSON.stringify(promoteBody)
|
|
4213
|
+
});
|
|
4214
|
+
const payload = await readResponsePayload(response);
|
|
4215
|
+
if (response.status === 409) {
|
|
4216
|
+
console.error(`❌ Webapp ${webappId} is already promoted to ${PROD_ENV}.`);
|
|
4217
|
+
process.exit(1);
|
|
4218
|
+
}
|
|
4219
|
+
if (!response.ok) {
|
|
4220
|
+
throw new Error(`Promote failed: ${response.status} ${response.statusText}
|
|
4221
|
+
${JSON.stringify(payload, null, 2)}`);
|
|
4222
|
+
}
|
|
4223
|
+
const deployToken = extractDeployToken2(payload);
|
|
4224
|
+
if (!deployToken) {
|
|
4225
|
+
throw new Error(`Promote response did not include webapp.deployToken:
|
|
4226
|
+
${JSON.stringify(payload, null, 2)}`);
|
|
4227
|
+
}
|
|
4228
|
+
upsertEnvFile(prodEnvPath, {
|
|
4229
|
+
WEBAPP_ID: webappId,
|
|
4230
|
+
DEPLOY_TOKEN: deployToken
|
|
4231
|
+
});
|
|
4232
|
+
console.log(`✅ Wrote WEBAPP_ID and DEPLOY_TOKEN to ${PROD_ENV_FILE}`);
|
|
4233
|
+
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}`);
|
|
4234
|
+
console.log(`
|
|
4235
|
+
✨ Promotion complete! Deploy to production with:
|
|
4236
|
+
`);
|
|
4237
|
+
console.log(` ro app deploy -e production
|
|
4238
|
+
`);
|
|
4239
|
+
}
|
|
4240
|
+
|
|
3856
4241
|
// src/upgrade-template.ts
|
|
3857
4242
|
import { execSync as execSync3 } from "node:child_process";
|
|
3858
|
-
import { existsSync as
|
|
4243
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync2, copyFileSync, rmSync as rmSync2 } from "node:fs";
|
|
3859
4244
|
var TEMPLATES = {
|
|
3860
4245
|
webapp: {
|
|
3861
4246
|
name: "webapp (SPA)",
|
|
3862
4247
|
repo: "https://github.com/airconcepts/webapp-template.git",
|
|
3863
4248
|
remoteName: "template",
|
|
3864
|
-
checkoutFiles: [
|
|
4249
|
+
checkoutFiles: [
|
|
4250
|
+
"AGENTS.md",
|
|
4251
|
+
".agent/",
|
|
4252
|
+
"src/types/webapp.d.ts",
|
|
4253
|
+
"src/types/game-sdk.d.ts",
|
|
4254
|
+
"src/widgets/Widget.tsx",
|
|
4255
|
+
"src/widgets/data-source.ts",
|
|
4256
|
+
"src/widgets/index.ts",
|
|
4257
|
+
"src/widgets/manifest.ts",
|
|
4258
|
+
"src/widgets/registry.ts",
|
|
4259
|
+
"src/widgets/types.ts",
|
|
4260
|
+
"src/widgets/use-widget-data.ts",
|
|
4261
|
+
"src/widgets/dev/WidgetGrid.tsx",
|
|
4262
|
+
"src/widgets/templates/action.tsx",
|
|
4263
|
+
"src/widgets/templates/list.tsx",
|
|
4264
|
+
"src/widgets/templates/progress.tsx",
|
|
4265
|
+
"src/widgets/templates/stat.tsx",
|
|
4266
|
+
"vite-plugins/widgets-manifest.ts"
|
|
4267
|
+
],
|
|
3865
4268
|
newFiles: [
|
|
3866
4269
|
"src/exp-engine/cli.ts",
|
|
3867
4270
|
"src/exp-engine/evaluate.ts",
|
|
3868
4271
|
"src/exp-engine/README.md",
|
|
3869
|
-
"src/types/exp-engine.d.ts"
|
|
4272
|
+
"src/types/exp-engine.d.ts",
|
|
4273
|
+
"src/widgets/examples.tsx",
|
|
4274
|
+
"src/routes/widget.$id.tsx",
|
|
4275
|
+
"src/routes/dev/widgets-preview.tsx"
|
|
3870
4276
|
]
|
|
3871
4277
|
},
|
|
3872
4278
|
"webapp-fullstack": {
|
|
@@ -3890,12 +4296,12 @@ var CLI_SCRIPTS = {
|
|
|
3890
4296
|
"upgrade-template": "bunx @rodyssey/cli@latest app upgrade-template"
|
|
3891
4297
|
};
|
|
3892
4298
|
function detectTemplate() {
|
|
3893
|
-
if (
|
|
4299
|
+
if (existsSync7("app")) {
|
|
3894
4300
|
console.log(`\uD83D\uDD0D Detected fullstack template (found app/ directory)
|
|
3895
4301
|
`);
|
|
3896
4302
|
return TEMPLATES["webapp-fullstack"];
|
|
3897
4303
|
}
|
|
3898
|
-
if (
|
|
4304
|
+
if (existsSync7("src")) {
|
|
3899
4305
|
console.log(`\uD83D\uDD0D Detected SPA template (found src/ directory)
|
|
3900
4306
|
`);
|
|
3901
4307
|
return TEMPLATES["webapp"];
|
|
@@ -3906,11 +4312,11 @@ function detectTemplate() {
|
|
|
3906
4312
|
}
|
|
3907
4313
|
function updatePackageJsonScripts() {
|
|
3908
4314
|
const pkgPath = "package.json";
|
|
3909
|
-
if (!
|
|
4315
|
+
if (!existsSync7(pkgPath)) {
|
|
3910
4316
|
console.log("⚠️ No package.json found, skipping scripts update");
|
|
3911
4317
|
return;
|
|
3912
4318
|
}
|
|
3913
|
-
const pkg = JSON.parse(
|
|
4319
|
+
const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
|
|
3914
4320
|
if (!pkg.scripts) {
|
|
3915
4321
|
pkg.scripts = {};
|
|
3916
4322
|
}
|
|
@@ -3948,7 +4354,7 @@ function updateCliSkill() {
|
|
|
3948
4354
|
}
|
|
3949
4355
|
execSync3(`git fetch ${cliRemote}`, { stdio: "inherit" });
|
|
3950
4356
|
execSync3(`git checkout ${cliRemote}/main -- skills/ro-cli/SKILL.md`, { stdio: "inherit" });
|
|
3951
|
-
if (
|
|
4357
|
+
if (existsSync7("skills/ro-cli/SKILL.md")) {
|
|
3952
4358
|
mkdirSync2(".agent/skills/ro-cli", { recursive: true });
|
|
3953
4359
|
copyFileSync("skills/ro-cli/SKILL.md", ".agent/skills/ro-cli/SKILL.md");
|
|
3954
4360
|
rmSync2("skills", { recursive: true, force: true });
|
|
@@ -3981,7 +4387,7 @@ async function upgradeTemplate() {
|
|
|
3981
4387
|
const checkoutList = template.checkoutFiles.join(" ");
|
|
3982
4388
|
execSync3(`git checkout ${template.remoteName}/main -- ${checkoutList}`, { stdio: "inherit" });
|
|
3983
4389
|
for (const file of template.newFiles) {
|
|
3984
|
-
if (!
|
|
4390
|
+
if (!existsSync7(file)) {
|
|
3985
4391
|
console.log(`\uD83D\uDCC2 Checking out ${file}...`);
|
|
3986
4392
|
try {
|
|
3987
4393
|
execSync3(`git checkout ${template.remoteName}/main -- ${file}`, { stdio: "inherit" });
|
|
@@ -4139,162 +4545,6 @@ async function updateGameSdk() {
|
|
|
4139
4545
|
}
|
|
4140
4546
|
}
|
|
4141
4547
|
|
|
4142
|
-
// src/update-webapp-config.ts
|
|
4143
|
-
import { existsSync as existsSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
4144
|
-
import { resolve } from "node:path";
|
|
4145
|
-
var CONFIG_URLS = {
|
|
4146
|
-
local: "http://localhost:5176/api/webapps/config",
|
|
4147
|
-
development: "https://development-cms.rodyssey.ai/api/webapps/config",
|
|
4148
|
-
staging: "https://staging-cms.rodyssey.ai/api/webapps/config",
|
|
4149
|
-
production: "https://cms.rodyssey.ai/api/webapps/config"
|
|
4150
|
-
};
|
|
4151
|
-
function parseJsonOption(value, optionName) {
|
|
4152
|
-
const maybePath = resolve(process.cwd(), value);
|
|
4153
|
-
const raw = existsSync6(maybePath) ? readFileSync6(maybePath, "utf-8") : value;
|
|
4154
|
-
try {
|
|
4155
|
-
const parsed = JSON.parse(raw);
|
|
4156
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
4157
|
-
throw new Error("value must be a JSON object");
|
|
4158
|
-
}
|
|
4159
|
-
return parsed;
|
|
4160
|
-
} catch (error) {
|
|
4161
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
4162
|
-
throw new Error(`Invalid ${optionName}: ${message}`);
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
function resolveConfigUrl(options, required = true) {
|
|
4166
|
-
const configUrl = options.url || process.env.WEBAPP_CONFIG_URL || CONFIG_URLS[options.env];
|
|
4167
|
-
if (!configUrl) {
|
|
4168
|
-
if (!required)
|
|
4169
|
-
return;
|
|
4170
|
-
console.error("❌ Error: no webapp config endpoint configured.");
|
|
4171
|
-
console.error(`\uD83D\uDCA1 Use one of these environments: ${Object.keys(CONFIG_URLS).join(", ")}, pass --url, or set WEBAPP_CONFIG_URL in your .env file.`);
|
|
4172
|
-
process.exit(1);
|
|
4173
|
-
}
|
|
4174
|
-
const url = new URL(configUrl);
|
|
4175
|
-
if (!options.host && !options.port) {
|
|
4176
|
-
return url.toString().replace(/\/$/, "");
|
|
4177
|
-
}
|
|
4178
|
-
if (options.host)
|
|
4179
|
-
url.hostname = options.host;
|
|
4180
|
-
if (options.port)
|
|
4181
|
-
url.port = String(options.port);
|
|
4182
|
-
return url.toString().replace(/\/$/, "");
|
|
4183
|
-
}
|
|
4184
|
-
function buildConfigPayload(options) {
|
|
4185
|
-
const payload = options.config ? parseJsonOption(options.config, "--config") : {};
|
|
4186
|
-
if (options.title !== undefined)
|
|
4187
|
-
payload.title = options.title;
|
|
4188
|
-
if (options.description !== undefined)
|
|
4189
|
-
payload.description = options.description;
|
|
4190
|
-
if (options.coverImg !== undefined)
|
|
4191
|
-
payload.coverImg = options.coverImg;
|
|
4192
|
-
if (options.localization !== undefined) {
|
|
4193
|
-
payload.localization = parseJsonOption(options.localization, "--localization");
|
|
4194
|
-
}
|
|
4195
|
-
return payload;
|
|
4196
|
-
}
|
|
4197
|
-
function resolveWebappId(webappId) {
|
|
4198
|
-
const resolved = webappId || process.env.WEBAPP_ID;
|
|
4199
|
-
if (!resolved) {
|
|
4200
|
-
console.error("❌ Error: WEBAPP_ID is not set. Pass --webapp-id or set it in your .env file.");
|
|
4201
|
-
process.exit(1);
|
|
4202
|
-
}
|
|
4203
|
-
return resolved;
|
|
4204
|
-
}
|
|
4205
|
-
function ensureDeployToken(env) {
|
|
4206
|
-
if (process.env.DEPLOY_TOKEN)
|
|
4207
|
-
return;
|
|
4208
|
-
console.error("❌ Error: DEPLOY_TOKEN is not set in environment variables.");
|
|
4209
|
-
console.info(`\uD83D\uDCA1 Please check your .env or .env.${env} file.`);
|
|
4210
|
-
process.exit(1);
|
|
4211
|
-
}
|
|
4212
|
-
function getConfigUrl(options, required = true) {
|
|
4213
|
-
return resolveConfigUrl(options, required);
|
|
4214
|
-
}
|
|
4215
|
-
async function getWebappConfig(options) {
|
|
4216
|
-
loadEnv(options.env);
|
|
4217
|
-
const webappId = resolveWebappId(options.webappId);
|
|
4218
|
-
const CONFIG_URL = getConfigUrl(options);
|
|
4219
|
-
if (!CONFIG_URL)
|
|
4220
|
-
return;
|
|
4221
|
-
ensureDeployToken(options.env);
|
|
4222
|
-
const url = new URL(CONFIG_URL);
|
|
4223
|
-
url.searchParams.set("webappId", webappId);
|
|
4224
|
-
console.log(`⚙️ Pulling webapp config for [${options.env}] environment...`);
|
|
4225
|
-
console.log(`\uD83D\uDCCD Config URL: ${url.toString()}`);
|
|
4226
|
-
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}
|
|
4227
|
-
`);
|
|
4228
|
-
const response = await fetch(url, {
|
|
4229
|
-
method: "GET",
|
|
4230
|
-
headers: {
|
|
4231
|
-
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
|
|
4232
|
-
Accept: "application/json"
|
|
4233
|
-
}
|
|
4234
|
-
});
|
|
4235
|
-
if (!response.ok) {
|
|
4236
|
-
const errorText = await response.text();
|
|
4237
|
-
throw new Error(`Config fetch failed: ${response.status} ${response.statusText}
|
|
4238
|
-
${errorText}`);
|
|
4239
|
-
}
|
|
4240
|
-
const config = await response.json();
|
|
4241
|
-
const output = JSON.stringify(config, null, 2);
|
|
4242
|
-
if (options.out) {
|
|
4243
|
-
writeFileSync5(options.out, `${output}
|
|
4244
|
-
`, "utf-8");
|
|
4245
|
-
console.log(`✅ Webapp config written to ${options.out}`);
|
|
4246
|
-
return;
|
|
4247
|
-
}
|
|
4248
|
-
console.log(output);
|
|
4249
|
-
}
|
|
4250
|
-
async function updateWebappConfig(options) {
|
|
4251
|
-
loadEnv(options.env);
|
|
4252
|
-
const webappId = resolveWebappId(options.webappId);
|
|
4253
|
-
const config = buildConfigPayload(options);
|
|
4254
|
-
if (Object.keys(config).length === 0) {
|
|
4255
|
-
console.error("❌ Error: no config fields provided. Use --title, --cover-img, --localization, or --config.");
|
|
4256
|
-
process.exit(1);
|
|
4257
|
-
}
|
|
4258
|
-
const payload = { webappId, config };
|
|
4259
|
-
const CONFIG_URL = getConfigUrl(options, !options.dryRun);
|
|
4260
|
-
if (!options.dryRun)
|
|
4261
|
-
ensureDeployToken(options.env);
|
|
4262
|
-
console.log(`⚙️ Updating webapp config for [${options.env}] environment...`);
|
|
4263
|
-
if (CONFIG_URL) {
|
|
4264
|
-
console.log(`\uD83D\uDCCD Config URL: ${CONFIG_URL}`);
|
|
4265
|
-
}
|
|
4266
|
-
console.log(`\uD83D\uDCCD Webapp ID: ${webappId}
|
|
4267
|
-
`);
|
|
4268
|
-
if (options.dryRun) {
|
|
4269
|
-
console.log("\uD83E\uDDEA Dry run payload:");
|
|
4270
|
-
console.log(JSON.stringify(payload, null, 2));
|
|
4271
|
-
return;
|
|
4272
|
-
}
|
|
4273
|
-
if (!CONFIG_URL)
|
|
4274
|
-
return;
|
|
4275
|
-
const response = await fetch(CONFIG_URL, {
|
|
4276
|
-
method: "PATCH",
|
|
4277
|
-
headers: {
|
|
4278
|
-
Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
|
|
4279
|
-
"Content-Type": "application/json"
|
|
4280
|
-
},
|
|
4281
|
-
body: JSON.stringify(payload)
|
|
4282
|
-
});
|
|
4283
|
-
if (!response.ok) {
|
|
4284
|
-
const errorText = await response.text();
|
|
4285
|
-
throw new Error(`Config update failed: ${response.status} ${response.statusText}
|
|
4286
|
-
${errorText}`);
|
|
4287
|
-
}
|
|
4288
|
-
const result = await response.json().catch(() => {
|
|
4289
|
-
return;
|
|
4290
|
-
});
|
|
4291
|
-
console.log("✅ Webapp config updated");
|
|
4292
|
-
if (result !== undefined) {
|
|
4293
|
-
console.log(`
|
|
4294
|
-
\uD83D\uDCCB Update result:`, result);
|
|
4295
|
-
}
|
|
4296
|
-
}
|
|
4297
|
-
|
|
4298
4548
|
// src/cli.ts
|
|
4299
4549
|
var TEMPLATES2 = {
|
|
4300
4550
|
webapp: {
|
|
@@ -4322,26 +4572,26 @@ Available templates:
|
|
|
4322
4572
|
input: process.stdin,
|
|
4323
4573
|
output: process.stdout
|
|
4324
4574
|
});
|
|
4325
|
-
return new Promise((
|
|
4575
|
+
return new Promise((resolve3) => {
|
|
4326
4576
|
rl.question(`Select a template (1-${entries.length}): `, (answer) => {
|
|
4327
4577
|
rl.close();
|
|
4328
4578
|
const index = parseInt(answer, 10) - 1;
|
|
4329
4579
|
if (index >= 0 && index < entries.length) {
|
|
4330
|
-
|
|
4580
|
+
resolve3(entries[index].name);
|
|
4331
4581
|
} else {
|
|
4332
4582
|
console.error("Invalid selection, defaulting to 'webapp'");
|
|
4333
|
-
|
|
4583
|
+
resolve3("webapp");
|
|
4334
4584
|
}
|
|
4335
4585
|
});
|
|
4336
4586
|
});
|
|
4337
4587
|
}
|
|
4338
|
-
program.name("@rodyssey/cli").description("Airconcepts CLI toolkit").version(
|
|
4588
|
+
program.name("@rodyssey/cli").description("Airconcepts CLI toolkit").version(package_default.version);
|
|
4339
4589
|
var app = program.command("app").description("Manage webapp projects");
|
|
4340
4590
|
function addConfigTargetOptions(command) {
|
|
4341
4591
|
return command.option("-e, --env <environment>", "Target environment (local | development | staging | production)", "development").option("--url <url>", "Override the config endpoint URL").option("--host <host>", "Override the config endpoint host").option("--port <port>", "Override the config endpoint port", parseInt).option("--webapp-id <id>", "Webapp ID. Defaults to WEBAPP_ID from .env");
|
|
4342
4592
|
}
|
|
4343
4593
|
function addConfigSetOptions(command) {
|
|
4344
|
-
return addConfigTargetOptions(command).option("--title <title>", "Webapp title").option("--description <description>", "Webapp description").option("--cover-img <url>", "Cover image URL").option("--localization <json-or-file>", "Localization JSON object
|
|
4594
|
+
return addConfigTargetOptions(command).option("--title <title>", "Webapp title (pass the literal 'null' to clear)").option("--description <description>", "Webapp description (pass the literal 'null' to clear)").option("--cover-img <url>", "Cover image URL (pass the literal 'null' to clear)").option("--localization <json-or-file>", "Localization JSON object, path to a JSON file, or 'null' to clear").option("--details <json-or-file>", "Partial WebappDetails JSON or path to a JSON file. Sent as a delta — only include keys you want to change. Do NOT echo a full GET response here, or empty defaults like 'tags: []' will clobber real data.").option("--dry-run", "Print the request payload without sending it");
|
|
4345
4595
|
}
|
|
4346
4596
|
app.command("create").argument("<project-name>", "Name of the project to create").option("-t, --template <template>", "Template to use (webapp | webapp-fullstack)").option("--auto", "Create a CMS webapp and write WEBAPP_ID/DEPLOY_TOKEN to .env").option("-e, --env <environment>", "CMS environment for --auto (local | development | staging | production)", "development").option("--cms-url <url>", "CMS base URL for --auto. Defaults to the selected environment").option("--create-url <url>", "Full CMS create endpoint for --auto. Defaults to <cms-url>/api/cli/webapps/create").description("Create a new project from a template").action(async (projectName, options) => {
|
|
4347
4597
|
let templateName;
|
|
@@ -4362,6 +4612,15 @@ app.command("create").argument("<project-name>", "Name of the project to create"
|
|
|
4362
4612
|
createUrl: options.createUrl
|
|
4363
4613
|
});
|
|
4364
4614
|
});
|
|
4615
|
+
app.command("promote").description("Promote the current webapp to production (creates a prod record with the same WEBAPP_ID)").option("--details <json-or-file>", "Full WebappDetails JSON object or path to a JSON file. Skips the source-pull and confirmation prompts when provided.").option("-y, --yes", "Auto-accept pulling the latest details from development").option("--cms-url <url>", "Production CMS base URL. Defaults to the production environment").option("--promote-url <url>", "Full CMS promote endpoint. Defaults to <cms-url>/api/cli/webapps/promote").option("--from <env>", "Source environment to pull details from (testing override). Defaults to development", "development").action(async (options) => {
|
|
4616
|
+
await promote({
|
|
4617
|
+
details: options.details,
|
|
4618
|
+
yes: options.yes,
|
|
4619
|
+
cmsUrl: options.cmsUrl,
|
|
4620
|
+
promoteUrl: options.promoteUrl,
|
|
4621
|
+
from: options.from
|
|
4622
|
+
});
|
|
4623
|
+
});
|
|
4365
4624
|
app.command("update-game-sdk").description("Download and update the GameSDK library, types, and documentation").action(async () => {
|
|
4366
4625
|
await updateGameSdk();
|
|
4367
4626
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rodyssey/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Scaffold new projects from airconcepts templates",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/airconcepts/ro-cli.git"
|
|
8
|
+
},
|
|
5
9
|
"bin": {
|
|
6
10
|
"@rodyssey/cli": "dist/cli.js"
|
|
7
11
|
},
|
|
@@ -13,16 +17,24 @@
|
|
|
13
17
|
"scripts": {
|
|
14
18
|
"build": "bun build src/cli.ts --outdir dist --target node",
|
|
15
19
|
"start": "bun dist/cli.js",
|
|
20
|
+
"changeset": "changeset",
|
|
21
|
+
"version-packages": "changeset version",
|
|
22
|
+
"release": "bun run build && changeset publish",
|
|
16
23
|
"prepublishOnly": "bun run build"
|
|
17
24
|
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": false
|
|
28
|
+
},
|
|
18
29
|
"dependencies": {
|
|
19
30
|
"commander": "^13.1.0",
|
|
20
31
|
"mime": "^4.1.0"
|
|
21
32
|
},
|
|
22
33
|
"devDependencies": {
|
|
34
|
+
"@changesets/cli": "^2.30.0",
|
|
23
35
|
"@types/bun": "latest"
|
|
24
36
|
},
|
|
25
37
|
"peerDependencies": {
|
|
26
38
|
"typescript": "^5"
|
|
27
39
|
}
|
|
28
|
-
}
|
|
40
|
+
}
|