@rodyssey/cli 0.1.2 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +43 -13
  2. 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 (existsSync(targetDir)) {
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 (existsSync(gitDir)) {
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 existsSync2, readFileSync as readFileSync2, readdirSync, statSync, unlinkSync } from "node:fs";
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 (!existsSync2(dirPath))
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 (existsSync2(ZIP_FILE)) {
2349
+ if (existsSync3(ZIP_FILE)) {
2320
2350
  unlinkSync(ZIP_FILE);
2321
2351
  console.log(`
2322
2352
  \uD83E\uDDF9 Cleaned up ${ZIP_FILE}`);
@@ -2328,7 +2358,7 @@ ${errorText}`);
2328
2358
 
2329
2359
  // src/upgrade-template.ts
2330
2360
  import { execSync as execSync3 } from "node:child_process";
2331
- import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync, copyFileSync, rmSync as rmSync2 } from "node:fs";
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)",
@@ -2361,12 +2391,12 @@ var CLI_SCRIPTS = {
2361
2391
  "upgrade-template": "bunx @rodyssey/cli app upgrade-template"
2362
2392
  };
2363
2393
  function detectTemplate() {
2364
- if (existsSync3("app")) {
2394
+ if (existsSync4("app")) {
2365
2395
  console.log(`\uD83D\uDD0D Detected fullstack template (found app/ directory)
2366
2396
  `);
2367
2397
  return TEMPLATES["webapp-fullstack"];
2368
2398
  }
2369
- if (existsSync3("src")) {
2399
+ if (existsSync4("src")) {
2370
2400
  console.log(`\uD83D\uDD0D Detected SPA template (found src/ directory)
2371
2401
  `);
2372
2402
  return TEMPLATES["webapp"];
@@ -2377,7 +2407,7 @@ function detectTemplate() {
2377
2407
  }
2378
2408
  function updatePackageJsonScripts() {
2379
2409
  const pkgPath = "package.json";
2380
- if (!existsSync3(pkgPath)) {
2410
+ if (!existsSync4(pkgPath)) {
2381
2411
  console.log("⚠️ No package.json found, skipping scripts update");
2382
2412
  return;
2383
2413
  }
@@ -2419,7 +2449,7 @@ function updateCliSkill() {
2419
2449
  }
2420
2450
  execSync3(`git fetch ${cliRemote}`, { stdio: "inherit" });
2421
2451
  execSync3(`git checkout ${cliRemote}/main -- skills/ro-cli/SKILL.md`, { stdio: "inherit" });
2422
- if (existsSync3("skills/ro-cli/SKILL.md")) {
2452
+ if (existsSync4("skills/ro-cli/SKILL.md")) {
2423
2453
  mkdirSync(".agent/skills/ro-cli", { recursive: true });
2424
2454
  copyFileSync("skills/ro-cli/SKILL.md", ".agent/skills/ro-cli/SKILL.md");
2425
2455
  rmSync2("skills", { recursive: true, force: true });
@@ -2452,7 +2482,7 @@ async function upgradeTemplate() {
2452
2482
  const checkoutList = template.checkoutFiles.join(" ");
2453
2483
  execSync3(`git checkout ${template.remoteName}/main -- ${checkoutList}`, { stdio: "inherit" });
2454
2484
  for (const file of template.newFiles) {
2455
- if (!existsSync3(file)) {
2485
+ if (!existsSync4(file)) {
2456
2486
  console.log(`\uD83D\uDCC2 Checking out ${file}...`);
2457
2487
  try {
2458
2488
  execSync3(`git checkout ${template.remoteName}/main -- ${file}`, { stdio: "inherit" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rodyssey/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold new projects from airconcepts templates",
5
5
  "bin": {
6
6
  "@rodyssey/cli": "dist/cli.js"