@rodyssey/cli 0.1.1 → 0.1.3
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/dist/cli.js +114 -18
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2071,11 +2071,11 @@ var {
|
|
|
2071
2071
|
|
|
2072
2072
|
// src/create.ts
|
|
2073
2073
|
import { execSync } from "node:child_process";
|
|
2074
|
-
import { existsSync, rmSync } from "node:fs";
|
|
2074
|
+
import { existsSync as existsSync2, rmSync } from "node:fs";
|
|
2075
2075
|
import path2 from "node:path";
|
|
2076
2076
|
|
|
2077
2077
|
// src/utils.ts
|
|
2078
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
2078
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
2079
2079
|
import path from "node:path";
|
|
2080
2080
|
function replaceInFile(filePath, search, replace) {
|
|
2081
2081
|
const content = readFileSync(filePath, "utf-8");
|
|
@@ -2092,6 +2092,35 @@ function replaceInFiles(dir, filenames, search, replace) {
|
|
|
2092
2092
|
} catch {}
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
+
function loadEnv(envName) {
|
|
2096
|
+
const files = [];
|
|
2097
|
+
if (envName) {
|
|
2098
|
+
files.push(`.env.${envName}`);
|
|
2099
|
+
}
|
|
2100
|
+
files.push(".env");
|
|
2101
|
+
for (const file of files) {
|
|
2102
|
+
if (!existsSync(file))
|
|
2103
|
+
continue;
|
|
2104
|
+
const content = readFileSync(file, "utf-8");
|
|
2105
|
+
for (const line of content.split(`
|
|
2106
|
+
`)) {
|
|
2107
|
+
const trimmed = line.trim();
|
|
2108
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
2109
|
+
continue;
|
|
2110
|
+
const eqIndex = trimmed.indexOf("=");
|
|
2111
|
+
if (eqIndex === -1)
|
|
2112
|
+
continue;
|
|
2113
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
2114
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
2115
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
2116
|
+
value = value.slice(1, -1);
|
|
2117
|
+
}
|
|
2118
|
+
if (process.env[key] === undefined) {
|
|
2119
|
+
process.env[key] = value;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2095
2124
|
|
|
2096
2125
|
// src/create.ts
|
|
2097
2126
|
var PLACEHOLDER = "__PROJECT_NAME__";
|
|
@@ -2102,7 +2131,7 @@ var REPLACEMENT_FILES = {
|
|
|
2102
2131
|
};
|
|
2103
2132
|
async function create(projectName, repoUrl, templateName) {
|
|
2104
2133
|
const targetDir = path2.resolve(process.cwd(), projectName);
|
|
2105
|
-
if (
|
|
2134
|
+
if (existsSync2(targetDir)) {
|
|
2106
2135
|
console.error(`
|
|
2107
2136
|
✖ Directory "${projectName}" already exists.
|
|
2108
2137
|
`);
|
|
@@ -2123,7 +2152,7 @@ async function create(projectName, repoUrl, templateName) {
|
|
|
2123
2152
|
process.exit(1);
|
|
2124
2153
|
}
|
|
2125
2154
|
const gitDir = path2.join(targetDir, ".git");
|
|
2126
|
-
if (
|
|
2155
|
+
if (existsSync2(gitDir)) {
|
|
2127
2156
|
rmSync(gitDir, { recursive: true, force: true });
|
|
2128
2157
|
}
|
|
2129
2158
|
const filesToReplace = REPLACEMENT_FILES[templateName] ?? [];
|
|
@@ -2146,7 +2175,7 @@ async function create(projectName, repoUrl, templateName) {
|
|
|
2146
2175
|
|
|
2147
2176
|
// src/deploy.ts
|
|
2148
2177
|
import { execSync as execSync2 } from "node:child_process";
|
|
2149
|
-
import { existsSync as
|
|
2178
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, readdirSync, statSync, unlinkSync } from "node:fs";
|
|
2150
2179
|
import { join } from "node:path";
|
|
2151
2180
|
var DEVELOPMENT_URL = "https://development-cms.rodyssey.ai/api/webapps/deploy";
|
|
2152
2181
|
var STAGING_URL = "https://staging-cms.rodyssey.ai/api/webapps/deploy";
|
|
@@ -2161,7 +2190,7 @@ var ZIP_FILE = "webapp-build.zip";
|
|
|
2161
2190
|
var MAX_FILES_PER_BATCH = 5;
|
|
2162
2191
|
var MAX_SIZE_PER_BATCH = 30 * 1024 * 1024;
|
|
2163
2192
|
function getAllFiles(dirPath, arrayOfFiles = []) {
|
|
2164
|
-
if (!
|
|
2193
|
+
if (!existsSync3(dirPath))
|
|
2165
2194
|
return arrayOfFiles;
|
|
2166
2195
|
const files = readdirSync(dirPath);
|
|
2167
2196
|
files.forEach(function(f) {
|
|
@@ -2179,6 +2208,7 @@ function fileToBlob(filePath) {
|
|
|
2179
2208
|
return new Blob([buffer]);
|
|
2180
2209
|
}
|
|
2181
2210
|
async function deploy(env = "development") {
|
|
2211
|
+
loadEnv(env);
|
|
2182
2212
|
const DEPLOY_URL = DEPLOY_URLS[env];
|
|
2183
2213
|
if (!DEPLOY_URL) {
|
|
2184
2214
|
console.error(`❌ Unknown environment "${env}". Available: ${Object.keys(DEPLOY_URLS).join(", ")}`);
|
|
@@ -2316,7 +2346,7 @@ ${errorText}`);
|
|
|
2316
2346
|
console.error("❌ Deploy failed:", error);
|
|
2317
2347
|
throw error;
|
|
2318
2348
|
} finally {
|
|
2319
|
-
if (
|
|
2349
|
+
if (existsSync3(ZIP_FILE)) {
|
|
2320
2350
|
unlinkSync(ZIP_FILE);
|
|
2321
2351
|
console.log(`
|
|
2322
2352
|
\uD83E\uDDF9 Cleaned up ${ZIP_FILE}`);
|
|
@@ -2326,9 +2356,9 @@ ${errorText}`);
|
|
|
2326
2356
|
✨ Deployment successful!`);
|
|
2327
2357
|
}
|
|
2328
2358
|
|
|
2329
|
-
// src/upgrade-
|
|
2359
|
+
// src/upgrade-template.ts
|
|
2330
2360
|
import { execSync as execSync3 } from "node:child_process";
|
|
2331
|
-
import { existsSync as
|
|
2361
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync, copyFileSync, rmSync as rmSync2 } from "node:fs";
|
|
2332
2362
|
var TEMPLATES = {
|
|
2333
2363
|
webapp: {
|
|
2334
2364
|
name: "webapp (SPA)",
|
|
@@ -2355,13 +2385,18 @@ var TEMPLATES = {
|
|
|
2355
2385
|
]
|
|
2356
2386
|
}
|
|
2357
2387
|
};
|
|
2388
|
+
var CLI_SCRIPTS = {
|
|
2389
|
+
"link-game-sdk": "bunx @rodyssey/cli app update-game-sdk",
|
|
2390
|
+
deploy: "bunx @rodyssey/cli app deploy",
|
|
2391
|
+
"upgrade-template": "bunx @rodyssey/cli app upgrade-template"
|
|
2392
|
+
};
|
|
2358
2393
|
function detectTemplate() {
|
|
2359
|
-
if (
|
|
2394
|
+
if (existsSync4("app")) {
|
|
2360
2395
|
console.log(`\uD83D\uDD0D Detected fullstack template (found app/ directory)
|
|
2361
2396
|
`);
|
|
2362
2397
|
return TEMPLATES["webapp-fullstack"];
|
|
2363
2398
|
}
|
|
2364
|
-
if (
|
|
2399
|
+
if (existsSync4("src")) {
|
|
2365
2400
|
console.log(`\uD83D\uDD0D Detected SPA template (found src/ directory)
|
|
2366
2401
|
`);
|
|
2367
2402
|
return TEMPLATES["webapp"];
|
|
@@ -2370,10 +2405,66 @@ function detectTemplate() {
|
|
|
2370
2405
|
`);
|
|
2371
2406
|
return TEMPLATES["webapp"];
|
|
2372
2407
|
}
|
|
2373
|
-
|
|
2408
|
+
function updatePackageJsonScripts() {
|
|
2409
|
+
const pkgPath = "package.json";
|
|
2410
|
+
if (!existsSync4(pkgPath)) {
|
|
2411
|
+
console.log("⚠️ No package.json found, skipping scripts update");
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
|
|
2415
|
+
if (!pkg.scripts) {
|
|
2416
|
+
pkg.scripts = {};
|
|
2417
|
+
}
|
|
2418
|
+
let updated = false;
|
|
2419
|
+
for (const [name, cmd] of Object.entries(CLI_SCRIPTS)) {
|
|
2420
|
+
if (pkg.scripts[name] !== cmd) {
|
|
2421
|
+
const action = pkg.scripts[name] ? "Updated" : "Added";
|
|
2422
|
+
pkg.scripts[name] = cmd;
|
|
2423
|
+
console.log(` \uD83D\uDCDD ${action} script: "${name}"`);
|
|
2424
|
+
updated = true;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
if (updated) {
|
|
2428
|
+
writeFileSync2(pkgPath, JSON.stringify(pkg, null, 2) + `
|
|
2429
|
+
`, "utf-8");
|
|
2430
|
+
console.log(`✅ package.json scripts updated
|
|
2431
|
+
`);
|
|
2432
|
+
} else {
|
|
2433
|
+
console.log(`✅ package.json scripts already up to date
|
|
2434
|
+
`);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
function updateCliSkill() {
|
|
2438
|
+
const cliRemote = "ro-cli";
|
|
2439
|
+
const cliRepo = "https://github.com/airconcepts/ro-cli.git";
|
|
2440
|
+
try {
|
|
2441
|
+
let remoteExists = false;
|
|
2442
|
+
try {
|
|
2443
|
+
execSync3(`git remote get-url ${cliRemote}`, { stdio: "ignore" });
|
|
2444
|
+
remoteExists = true;
|
|
2445
|
+
} catch {}
|
|
2446
|
+
if (!remoteExists) {
|
|
2447
|
+
console.log(` ➕ Adding remote '${cliRemote}'...`);
|
|
2448
|
+
execSync3(`git remote add ${cliRemote} ${cliRepo}`, { stdio: "inherit" });
|
|
2449
|
+
}
|
|
2450
|
+
execSync3(`git fetch ${cliRemote}`, { stdio: "inherit" });
|
|
2451
|
+
execSync3(`git checkout ${cliRemote}/main -- skills/ro-cli/SKILL.md`, { stdio: "inherit" });
|
|
2452
|
+
if (existsSync4("skills/ro-cli/SKILL.md")) {
|
|
2453
|
+
mkdirSync(".agent/skills/ro-cli", { recursive: true });
|
|
2454
|
+
copyFileSync("skills/ro-cli/SKILL.md", ".agent/skills/ro-cli/SKILL.md");
|
|
2455
|
+
rmSync2("skills", { recursive: true, force: true });
|
|
2456
|
+
console.log(` ✅ CLI skill updated
|
|
2457
|
+
`);
|
|
2458
|
+
}
|
|
2459
|
+
} catch (error) {
|
|
2460
|
+
console.log(` ⚠️ Failed to update CLI skill: ${error instanceof Error ? error.message : error}
|
|
2461
|
+
`);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
async function upgradeTemplate() {
|
|
2374
2465
|
const template = detectTemplate();
|
|
2375
2466
|
try {
|
|
2376
|
-
console.log(`\uD83D\uDD04 Starting
|
|
2467
|
+
console.log(`\uD83D\uDD04 Starting template upgrade for ${template.name}...`);
|
|
2377
2468
|
let remoteExists = false;
|
|
2378
2469
|
try {
|
|
2379
2470
|
execSync3(`git remote get-url ${template.remoteName}`, { stdio: "ignore" });
|
|
@@ -2387,11 +2478,11 @@ async function upgradeAgent() {
|
|
|
2387
2478
|
}
|
|
2388
2479
|
console.log("⬇️ Fetching latest changes from template...");
|
|
2389
2480
|
execSync3(`git fetch ${template.remoteName}`, { stdio: "inherit" });
|
|
2390
|
-
console.log("\uD83D\uDCC2 Updating
|
|
2481
|
+
console.log("\uD83D\uDCC2 Updating template files...");
|
|
2391
2482
|
const checkoutList = template.checkoutFiles.join(" ");
|
|
2392
2483
|
execSync3(`git checkout ${template.remoteName}/main -- ${checkoutList}`, { stdio: "inherit" });
|
|
2393
2484
|
for (const file of template.newFiles) {
|
|
2394
|
-
if (!
|
|
2485
|
+
if (!existsSync4(file)) {
|
|
2395
2486
|
console.log(`\uD83D\uDCC2 Checking out ${file}...`);
|
|
2396
2487
|
try {
|
|
2397
2488
|
execSync3(`git checkout ${template.remoteName}/main -- ${file}`, { stdio: "inherit" });
|
|
@@ -2402,7 +2493,12 @@ async function upgradeAgent() {
|
|
|
2402
2493
|
console.log(`⏭️ Skipping ${file} (already exists)`);
|
|
2403
2494
|
}
|
|
2404
2495
|
}
|
|
2405
|
-
console.log(
|
|
2496
|
+
console.log(`
|
|
2497
|
+
\uD83D\uDD27 Updating CLI skill documentation...`);
|
|
2498
|
+
updateCliSkill();
|
|
2499
|
+
console.log("\uD83D\uDCE6 Updating package.json scripts...");
|
|
2500
|
+
updatePackageJsonScripts();
|
|
2501
|
+
console.log("✅ Template upgrade complete! Please check git status for changes.");
|
|
2406
2502
|
} catch (error) {
|
|
2407
2503
|
console.error("❌ Upgrade failed:", error);
|
|
2408
2504
|
process.exit(1);
|
|
@@ -2606,7 +2702,7 @@ app.command("update-game-sdk").description("Download and update the GameSDK libr
|
|
|
2606
2702
|
app.command("deploy").description("Build and deploy the webapp to the server").option("-e, --env <environment>", "Target environment (development | staging | production)", "development").action(async (options) => {
|
|
2607
2703
|
await deploy(options.env);
|
|
2608
2704
|
});
|
|
2609
|
-
app.command("upgrade-
|
|
2610
|
-
await
|
|
2705
|
+
app.command("upgrade-template").description("Upgrade template files and CLI scripts from the template repository").action(async () => {
|
|
2706
|
+
await upgradeTemplate();
|
|
2611
2707
|
});
|
|
2612
2708
|
program.parse();
|