@rodyssey/cli 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +78 -75
  2. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @bun
2
+ import { createRequire } from "node:module";
3
3
  var __create = Object.create;
4
4
  var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
@@ -17,7 +17,7 @@ var __toESM = (mod, isNodeMode, target) => {
17
17
  return to;
18
18
  };
19
19
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
- var __require = import.meta.require;
20
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
21
 
22
22
  // node_modules/commander/lib/error.js
23
23
  var require_error = __commonJS((exports) => {
@@ -725,11 +725,11 @@ var require_suggestSimilar = __commonJS((exports) => {
725
725
 
726
726
  // node_modules/commander/lib/command.js
727
727
  var require_command = __commonJS((exports) => {
728
- var EventEmitter = __require("events").EventEmitter;
729
- var childProcess = __require("child_process");
730
- var path = __require("path");
731
- var fs = __require("fs");
732
- var process2 = __require("process");
728
+ var EventEmitter = __require("node:events").EventEmitter;
729
+ var childProcess = __require("node:child_process");
730
+ var path = __require("node:path");
731
+ var fs = __require("node:fs");
732
+ var process2 = __require("node:process");
733
733
  var { Argument, humanReadableArgName } = require_argument();
734
734
  var { CommanderError } = require_error();
735
735
  var { Help, stripColor } = require_help();
@@ -2070,13 +2070,13 @@ var {
2070
2070
  } = import__.default;
2071
2071
 
2072
2072
  // src/create.ts
2073
- import { execSync } from "child_process";
2074
- import { existsSync, rmSync } from "fs";
2075
- import path2 from "path";
2073
+ import { execSync } from "node:child_process";
2074
+ import { existsSync, rmSync } from "node:fs";
2075
+ import path2 from "node:path";
2076
2076
 
2077
2077
  // src/utils.ts
2078
- import { readFileSync, writeFileSync } from "fs";
2079
- import path from "path";
2078
+ import { readFileSync, writeFileSync } from "node:fs";
2079
+ import path from "node:path";
2080
2080
  function replaceInFile(filePath, search, replace) {
2081
2081
  const content = readFileSync(filePath, "utf-8");
2082
2082
  const updated = content.replaceAll(search, replace);
@@ -2104,12 +2104,12 @@ async function create(projectName, repoUrl, templateName) {
2104
2104
  const targetDir = path2.resolve(process.cwd(), projectName);
2105
2105
  if (existsSync(targetDir)) {
2106
2106
  console.error(`
2107
- \u2716 Directory "${projectName}" already exists.
2107
+ Directory "${projectName}" already exists.
2108
2108
  `);
2109
2109
  process.exit(1);
2110
2110
  }
2111
2111
  console.log(`
2112
- \u23F3 Cloning template "${templateName}"...
2112
+ Cloning template "${templateName}"...
2113
2113
  `);
2114
2114
  try {
2115
2115
  execSync(`git clone --depth 1 ${repoUrl} ${projectName}`, {
@@ -2118,7 +2118,7 @@ async function create(projectName, repoUrl, templateName) {
2118
2118
  });
2119
2119
  } catch {
2120
2120
  console.error(`
2121
- \u2716 Failed to clone template. Make sure you have SSH access to the repo.
2121
+ Failed to clone template. Make sure you have SSH access to the repo.
2122
2122
  `);
2123
2123
  process.exit(1);
2124
2124
  }
@@ -2134,7 +2134,7 @@ async function create(projectName, repoUrl, templateName) {
2134
2134
  }
2135
2135
  execSync("git init", { stdio: "ignore", cwd: targetDir });
2136
2136
  console.log(`
2137
- \u2705 Project "${projectName}" created successfully!
2137
+ Project "${projectName}" created successfully!
2138
2138
 
2139
2139
  Next steps:
2140
2140
 
@@ -2145,10 +2145,9 @@ async function create(projectName, repoUrl, templateName) {
2145
2145
  }
2146
2146
 
2147
2147
  // src/deploy.ts
2148
- var {$ } = globalThis.Bun;
2149
- var {file } = globalThis.Bun;
2150
- import { existsSync as existsSync2, readdirSync, statSync } from "fs";
2151
- import { join } from "path";
2148
+ import { execSync as execSync2 } from "node:child_process";
2149
+ import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync, statSync, unlinkSync } from "node:fs";
2150
+ import { join } from "node:path";
2152
2151
  var DEVELOPMENT_URL = "https://development-cms.rodyssey.ai/api/webapps/deploy";
2153
2152
  var STAGING_URL = "https://staging-cms.rodyssey.ai/api/webapps/deploy";
2154
2153
  var PRODUCTION_URL = "https://cms.rodyssey.ai/api/webapps/deploy";
@@ -2175,10 +2174,14 @@ function getAllFiles(dirPath, arrayOfFiles = []) {
2175
2174
  });
2176
2175
  return arrayOfFiles;
2177
2176
  }
2177
+ function fileToBlob(filePath) {
2178
+ const buffer = readFileSync2(filePath);
2179
+ return new Blob([buffer]);
2180
+ }
2178
2181
  async function deploy(env = "development") {
2179
2182
  const DEPLOY_URL = DEPLOY_URLS[env];
2180
2183
  if (!DEPLOY_URL) {
2181
- console.error(`\u274C Unknown environment "${env}". Available: ${Object.keys(DEPLOY_URLS).join(", ")}`);
2184
+ console.error(`❌ Unknown environment "${env}". Available: ${Object.keys(DEPLOY_URLS).join(", ")}`);
2182
2185
  process.exit(1);
2183
2186
  }
2184
2187
  const ASSETS_URL = DEPLOY_URL.replace("/webapps/deploy", "/webapps/assets");
@@ -2188,13 +2191,13 @@ async function deploy(env = "development") {
2188
2191
  console.log(`\uD83D\uDCCD Assets URL: ${ASSETS_URL}
2189
2192
  `);
2190
2193
  if (!process.env.DEPLOY_TOKEN) {
2191
- console.error("\u274C Error: DEPLOY_TOKEN is not set in environment variables.");
2194
+ console.error(" Error: DEPLOY_TOKEN is not set in environment variables.");
2192
2195
  console.info(`\uD83D\uDCA1 Please check your .env or .env.${env} file.`);
2193
2196
  process.exit(1);
2194
2197
  }
2195
2198
  console.log("\uD83D\uDCE6 Step 1: Building the webapp...");
2196
- await $`bun run build`;
2197
- console.log(`\u2705 Build completed
2199
+ execSync2("npm run build", { stdio: "inherit" });
2200
+ console.log(`✅ Build completed
2198
2201
  `);
2199
2202
  const allFiles = getAllFiles(BUILD_DIR);
2200
2203
  const htmlFiles = allFiles.filter((f) => f.endsWith(".html"));
@@ -2224,7 +2227,7 @@ async function deploy(env = "development") {
2224
2227
  const formData = new FormData;
2225
2228
  for (const filePath of batch) {
2226
2229
  const relativePath = filePath.substring(BUILD_DIR.length + 1).replace(/\\/g, "/");
2227
- formData.append(relativePath, file(filePath));
2230
+ formData.append(relativePath, fileToBlob(filePath), relativePath);
2228
2231
  }
2229
2232
  const response = await fetch(ASSETS_URL, {
2230
2233
  method: "POST",
@@ -2239,18 +2242,18 @@ async function deploy(env = "development") {
2239
2242
  ${errorText}`);
2240
2243
  }
2241
2244
  batchIndex++;
2242
- console.log(`\u2705 Batch ${batchIndex}/${batches.length} uploaded successfully`);
2245
+ console.log(`✅ Batch ${batchIndex}/${batches.length} uploaded successfully`);
2243
2246
  });
2244
2247
  await Promise.all(uploadPromises);
2245
2248
  } else {
2246
- console.log("\u2705 No heavy assets to upload");
2249
+ console.log(" No heavy assets to upload");
2247
2250
  }
2248
2251
  console.log();
2249
2252
  if (scriptFiles.length > 0) {
2250
2253
  console.log(`\uD83D\uDCDC Step 3: Setting up ${scriptFiles.length} scripts (APIs & Crons)...`);
2251
2254
  const scriptsPayload = { api: {}, cron: {}, cronConfig: null };
2252
2255
  for (const f of scriptFiles) {
2253
- const content = await Bun.file(f).text();
2256
+ const content = readFileSync2(f, "utf-8");
2254
2257
  const relativePath = f.substring(BUILD_DIR.length + 1).replace(/\\/g, "/");
2255
2258
  if (relativePath === "cron-jobs/cron.config.json") {
2256
2259
  scriptsPayload.cronConfig = JSON.parse(content);
@@ -2276,21 +2279,21 @@ ${errorText}`);
2276
2279
  throw new Error(`Scripts setup failed: ${response.status} ${response.statusText}
2277
2280
  ${errorText}`);
2278
2281
  }
2279
- console.log(`\u2705 Scripts synced successfully`);
2282
+ console.log(`✅ Scripts synced successfully`);
2280
2283
  } else {
2281
2284
  console.log(`\uD83D\uDCDC Step 3: No scripts found to sync.`);
2282
2285
  }
2283
2286
  console.log();
2284
- console.log(`\uD83D\uDDDC\uFE0F Step 4: Zipping ${htmlFiles.length} HTML files...`);
2287
+ console.log(`\uD83D\uDDDC Step 4: Zipping ${htmlFiles.length} HTML files...`);
2285
2288
  if (htmlFiles.length === 0) {
2286
- console.warn("\u26A0\uFE0F No HTML files found to zip! Deployment might fail if CMS expects an HTML file.");
2289
+ console.warn("⚠️ No HTML files found to zip! Deployment might fail if CMS expects an HTML file.");
2287
2290
  }
2288
2291
  const relativeHtmlFiles = htmlFiles.map((f) => f.substring(BUILD_DIR.length + 1).replace(/\\/g, "/"));
2289
- await $`cd ${BUILD_DIR} && zip ../${ZIP_FILE} ${relativeHtmlFiles}`;
2290
- console.log(`\u2705 Created ${ZIP_FILE}
2292
+ execSync2(`cd ${BUILD_DIR} && zip ../${ZIP_FILE} ${relativeHtmlFiles.join(" ")}`, { stdio: "inherit" });
2293
+ console.log(`✅ Created ${ZIP_FILE}
2291
2294
  `);
2292
- console.log("\u2601\uFE0F Step 5: Deploying HTML zip to server...");
2293
- const zipFile = file(ZIP_FILE);
2295
+ console.log("☁️ Step 5: Deploying HTML zip to server...");
2296
+ const zipBuffer = readFileSync2(ZIP_FILE);
2294
2297
  try {
2295
2298
  const response = await fetch(DEPLOY_URL, {
2296
2299
  method: "POST",
@@ -2298,7 +2301,7 @@ ${errorText}`);
2298
2301
  Authorization: `Bearer ${process.env.DEPLOY_TOKEN}`,
2299
2302
  "Content-Type": "application/zip"
2300
2303
  },
2301
- body: zipFile
2304
+ body: zipBuffer
2302
2305
  });
2303
2306
  if (!response.ok) {
2304
2307
  const errorText = await response.text();
@@ -2306,26 +2309,26 @@ ${errorText}`);
2306
2309
  ${errorText}`);
2307
2310
  }
2308
2311
  const result = await response.json();
2309
- console.log("\u2705 Deploy completed");
2312
+ console.log(" Deploy completed");
2310
2313
  console.log(`
2311
2314
  \uD83D\uDCCB Deployment result:`, result);
2312
2315
  } catch (error) {
2313
- console.error("\u274C Deploy failed:", error);
2316
+ console.error(" Deploy failed:", error);
2314
2317
  throw error;
2315
2318
  } finally {
2316
2319
  if (existsSync2(ZIP_FILE)) {
2317
- await $`rm ${ZIP_FILE}`;
2320
+ unlinkSync(ZIP_FILE);
2318
2321
  console.log(`
2319
2322
  \uD83E\uDDF9 Cleaned up ${ZIP_FILE}`);
2320
2323
  }
2321
2324
  }
2322
2325
  console.log(`
2323
- \u2728 Deployment successful!`);
2326
+ Deployment successful!`);
2324
2327
  }
2325
2328
 
2326
2329
  // src/upgrade-agent.ts
2327
- import { execSync as execSync2 } from "child_process";
2328
- import { existsSync as existsSync3 } from "fs";
2330
+ import { execSync as execSync3 } from "node:child_process";
2331
+ import { existsSync as existsSync3 } from "node:fs";
2329
2332
  var TEMPLATES = {
2330
2333
  webapp: {
2331
2334
  name: "webapp (SPA)",
@@ -2363,7 +2366,7 @@ function detectTemplate() {
2363
2366
  `);
2364
2367
  return TEMPLATES["webapp"];
2365
2368
  }
2366
- console.log(`\u26A0\uFE0F Could not detect template type, defaulting to SPA
2369
+ console.log(`⚠️ Could not detect template type, defaulting to SPA
2367
2370
  `);
2368
2371
  return TEMPLATES["webapp"];
2369
2372
  }
@@ -2373,42 +2376,42 @@ async function upgradeAgent() {
2373
2376
  console.log(`\uD83D\uDD04 Starting Agent Upgrade for ${template.name}...`);
2374
2377
  let remoteExists = false;
2375
2378
  try {
2376
- execSync2(`git remote get-url ${template.remoteName}`, { stdio: "ignore" });
2379
+ execSync3(`git remote get-url ${template.remoteName}`, { stdio: "ignore" });
2377
2380
  remoteExists = true;
2378
2381
  } catch {}
2379
2382
  if (!remoteExists) {
2380
- console.log(`\u2795 Adding remote '${template.remoteName}'...`);
2381
- execSync2(`git remote add ${template.remoteName} ${template.repo}`, { stdio: "inherit" });
2383
+ console.log(`➕ Adding remote '${template.remoteName}'...`);
2384
+ execSync3(`git remote add ${template.remoteName} ${template.repo}`, { stdio: "inherit" });
2382
2385
  } else {
2383
- console.log(`\u2139\uFE0F Remote '${template.remoteName}' already exists.`);
2386
+ console.log(`ℹ️ Remote '${template.remoteName}' already exists.`);
2384
2387
  }
2385
- console.log("\u2B07\uFE0F Fetching latest changes from template...");
2386
- execSync2(`git fetch ${template.remoteName}`, { stdio: "inherit" });
2388
+ console.log("⬇️ Fetching latest changes from template...");
2389
+ execSync3(`git fetch ${template.remoteName}`, { stdio: "inherit" });
2387
2390
  console.log("\uD83D\uDCC2 Updating agent files...");
2388
2391
  const checkoutList = template.checkoutFiles.join(" ");
2389
- execSync2(`git checkout ${template.remoteName}/main -- ${checkoutList}`, { stdio: "inherit" });
2390
- for (const file2 of template.newFiles) {
2391
- if (!existsSync3(file2)) {
2392
- console.log(`\uD83D\uDCC2 Checking out ${file2}...`);
2392
+ execSync3(`git checkout ${template.remoteName}/main -- ${checkoutList}`, { stdio: "inherit" });
2393
+ for (const file of template.newFiles) {
2394
+ if (!existsSync3(file)) {
2395
+ console.log(`\uD83D\uDCC2 Checking out ${file}...`);
2393
2396
  try {
2394
- execSync2(`git checkout ${template.remoteName}/main -- ${file2}`, { stdio: "inherit" });
2397
+ execSync3(`git checkout ${template.remoteName}/main -- ${file}`, { stdio: "inherit" });
2395
2398
  } catch {
2396
- console.log(`\u26A0\uFE0F Failed to checkout ${file2}`);
2399
+ console.log(`⚠️ Failed to checkout ${file}`);
2397
2400
  }
2398
2401
  } else {
2399
- console.log(`\u23ED\uFE0F Skipping ${file2} (already exists)`);
2402
+ console.log(`⏭️ Skipping ${file} (already exists)`);
2400
2403
  }
2401
2404
  }
2402
- console.log("\u2705 Agent upgrade complete! Please check git status for changes.");
2405
+ console.log(" Agent upgrade complete! Please check git status for changes.");
2403
2406
  } catch (error) {
2404
- console.error("\u274C Upgrade failed:", error);
2407
+ console.error(" Upgrade failed:", error);
2405
2408
  process.exit(1);
2406
2409
  }
2407
2410
  }
2408
2411
 
2409
2412
  // src/update-game-sdk.ts
2410
- import { mkdir, writeFile } from "fs/promises";
2411
- import { dirname, join as join2 } from "path";
2413
+ import { mkdir, writeFile } from "node:fs/promises";
2414
+ import { dirname, join as join2 } from "node:path";
2412
2415
  var BASE_URL = "https://development-app.rodyssey.ai";
2413
2416
  var FILES = [
2414
2417
  {
@@ -2441,11 +2444,11 @@ async function downloadFile(url, path3, description) {
2441
2444
  const dir = dirname(path3);
2442
2445
  await mkdir(dir, { recursive: true });
2443
2446
  await writeFile(path3, content, "utf-8");
2444
- console.log(`\u2705 Downloaded ${description} (${content.length} bytes)
2447
+ console.log(`✅ Downloaded ${description} (${content.length} bytes)
2445
2448
  `);
2446
2449
  return true;
2447
2450
  } catch (error) {
2448
- console.error(`\u274C Failed to download ${description}:`);
2451
+ console.error(`❌ Failed to download ${description}:`);
2449
2452
  console.error(` ${error instanceof Error ? error.message : String(error)}
2450
2453
  `);
2451
2454
  return false;
@@ -2462,14 +2465,14 @@ async function downloadManifest() {
2462
2465
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
2463
2466
  }
2464
2467
  const manifest = await response.json();
2465
- console.log(`\u2705 Manifest downloaded successfully`);
2468
+ console.log(`✅ Manifest downloaded successfully`);
2466
2469
  console.log(` Name: ${manifest.name}`);
2467
2470
  console.log(` Version: ${manifest.version}`);
2468
2471
  console.log(` Documentation files: ${manifest.documentation.length}
2469
2472
  `);
2470
2473
  return manifest;
2471
2474
  } catch (error) {
2472
- console.error("\u274C Failed to download manifest:");
2475
+ console.error(" Failed to download manifest:");
2473
2476
  console.error(` ${error instanceof Error ? error.message : String(error)}
2474
2477
  `);
2475
2478
  return null;
@@ -2493,9 +2496,9 @@ async function downloadDocumentation(manifest) {
2493
2496
  }
2494
2497
  console.log(`
2495
2498
  \uD83D\uDCCA Documentation download summary:`);
2496
- console.log(` \u2705 Success: ${successCount}`);
2499
+ console.log(` Success: ${successCount}`);
2497
2500
  if (failCount > 0) {
2498
- console.log(` \u274C Failed: ${failCount}`);
2501
+ console.log(` Failed: ${failCount}`);
2499
2502
  }
2500
2503
  console.log();
2501
2504
  return { successCount, failCount };
@@ -2508,8 +2511,8 @@ async function updateGameSdk() {
2508
2511
  let totalFail = 0;
2509
2512
  console.log(`\uD83D\uDCE6 Downloading core SDK files...
2510
2513
  `);
2511
- for (const file2 of FILES) {
2512
- const success = await downloadFile(file2.url, file2.path, file2.description);
2514
+ for (const file of FILES) {
2515
+ const success = await downloadFile(file.url, file.path, file.description);
2513
2516
  if (success) {
2514
2517
  totalSuccess++;
2515
2518
  } else {
@@ -2522,22 +2525,22 @@ async function updateGameSdk() {
2522
2525
  totalSuccess += successCount;
2523
2526
  totalFail += failCount;
2524
2527
  } else {
2525
- console.log(`\u26A0\uFE0F Skipping documentation download due to manifest error
2528
+ console.log(`⚠️ Skipping documentation download due to manifest error
2526
2529
  `);
2527
2530
  }
2528
2531
  console.log("=".repeat(60));
2529
2532
  console.log(`\uD83C\uDF89 Download Complete!
2530
2533
  `);
2531
2534
  console.log(`\uD83D\uDCCA Final Summary:`);
2532
- console.log(` \u2705 Successfully downloaded: ${totalSuccess} files`);
2535
+ console.log(` Successfully downloaded: ${totalSuccess} files`);
2533
2536
  if (totalFail > 0) {
2534
- console.log(` \u274C Failed: ${totalFail} files`);
2537
+ console.log(` Failed: ${totalFail} files`);
2535
2538
  console.log(`
2536
- \u26A0\uFE0F Some files failed to download. Please check the errors above.`);
2539
+ ⚠️ Some files failed to download. Please check the errors above.`);
2537
2540
  process.exit(1);
2538
2541
  } else {
2539
2542
  console.log(`
2540
- \u2728 All files downloaded successfully!`);
2543
+ All files downloaded successfully!`);
2541
2544
  }
2542
2545
  }
2543
2546
 
@@ -2560,10 +2563,10 @@ async function selectTemplate() {
2560
2563
  Available templates:
2561
2564
  `);
2562
2565
  entries.forEach((t, i) => {
2563
- console.log(` ${i + 1}. ${t.name} \u2014 ${t.description}`);
2566
+ console.log(` ${i + 1}. ${t.name} ${t.description}`);
2564
2567
  });
2565
2568
  console.log();
2566
- const readline = await import("readline");
2569
+ const readline = await import("node:readline");
2567
2570
  const rl = readline.createInterface({
2568
2571
  input: process.stdin,
2569
2572
  output: process.stdout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rodyssey/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold new projects from airconcepts templates",
5
5
  "bin": {
6
6
  "@rodyssey/cli": "dist/cli.js"
@@ -11,7 +11,7 @@
11
11
  "type": "module",
12
12
  "module": "index.ts",
13
13
  "scripts": {
14
- "build": "bun build src/cli.ts --outdir dist --target bun",
14
+ "build": "bun build src/cli.ts --outdir dist --target node",
15
15
  "start": "bun dist/cli.js",
16
16
  "prepublishOnly": "bun run build"
17
17
  },
@@ -24,4 +24,4 @@
24
24
  "peerDependencies": {
25
25
  "typescript": "^5"
26
26
  }
27
- }
27
+ }