gencow 0.1.14 → 0.1.15

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/bin/gencow.mjs +30 -0
  2. package/package.json +1 -1
package/bin/gencow.mjs CHANGED
@@ -563,6 +563,34 @@ function generateReadmeMd(config, apiObj) {
563
563
 
564
564
  // ─── DB Backup Helpers ────────────────────────────────────
565
565
 
566
+ // ─── Deploy → .env.local 자동 업데이트 ────────────────────
567
+ function updateEnvLocalUrl(deployUrl) {
568
+ if (!deployUrl) return;
569
+ const envKey = "NEXT_PUBLIC_GENCOW_URL";
570
+ const envLocalPath = resolve(process.cwd(), ".env.local");
571
+
572
+ try {
573
+ let content = "";
574
+ try { content = readFileSync(envLocalPath, "utf-8"); } catch { /* doesn't exist yet */ }
575
+
576
+ const line = `${envKey}=${deployUrl}`;
577
+ const regex = new RegExp(`^${envKey}=.*$`, "m");
578
+
579
+ if (regex.test(content)) {
580
+ content = content.replace(regex, line);
581
+ } else {
582
+ content = content.trimEnd() + (content ? "\n" : "") + line + "\n";
583
+ }
584
+
585
+ writeFileSync(envLocalPath, content);
586
+ success(`.env.local에 ${envKey} 자동 설정됨`);
587
+ info(` ${DIM}Vercel/Netlify 배포 시 환경변수에도 추가하세요:${RESET}`);
588
+ info(` ${envKey}=${deployUrl}`);
589
+ } catch (e) {
590
+ warn(`.env.local 업데이트 실패: ${e.message}`);
591
+ }
592
+ }
593
+
566
594
  function cleanupOldBackups(backupDir, keep = 3) {
567
595
  try {
568
596
  const entries = readdirSync(backupDir)
@@ -1573,6 +1601,7 @@ ${BOLD}Examples:${RESET}
1573
1601
  success(`배포 완료!`);
1574
1602
  info(`URL: ${retryData.url}`);
1575
1603
  info(`Hash: ${retryData.bundleHash}`);
1604
+ updateEnvLocalUrl(retryData.url);
1576
1605
  log("");
1577
1606
  return;
1578
1607
  }
@@ -1588,6 +1617,7 @@ ${BOLD}Examples:${RESET}
1588
1617
  info(`URL: ${deployData.url}`);
1589
1618
  info(`Hash: ${deployData.bundleHash}`);
1590
1619
  if (deployData.deployId) info(`ID: ${deployData.deployId}`);
1620
+ updateEnvLocalUrl(deployData.url);
1591
1621
  log("");
1592
1622
 
1593
1623
  // gencow.json 업데이트 (앱 이름 저장)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gencow",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Gencow — Backend OS for AI Agents",
5
5
  "type": "module",
6
6
  "bin": {