@videan/cli 0.5.1 → 0.5.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/index.js CHANGED
@@ -1329,7 +1329,7 @@ async function collectFiles(dir) {
1329
1329
  const entries = await fs3.readdir(currentDir, { withFileTypes: true });
1330
1330
  for (const entry of entries) {
1331
1331
  const fullPath = path3.join(currentDir, entry.name);
1332
- const relativePath = path3.relative(dir, fullPath);
1332
+ const relativePath = path3.relative(dir, fullPath).split(path3.sep).join("/");
1333
1333
  const ignorePath = entry.isDirectory() ? `${relativePath}/` : relativePath;
1334
1334
  if (ig.ignores(ignorePath)) continue;
1335
1335
  if (entry.isDirectory()) {
@@ -1387,6 +1387,37 @@ function requireOrg(orgId) {
1387
1387
  }
1388
1388
  return orgId;
1389
1389
  }
1390
+ function parseSecretArgs(key, value) {
1391
+ if (value !== void 0 || !key.includes("=")) return { key, value };
1392
+ const eq = key.indexOf("=");
1393
+ return { key: key.slice(0, eq), value: key.slice(eq + 1) };
1394
+ }
1395
+ function buildErrorExcerpt(lines, max = 8) {
1396
+ const out = [];
1397
+ for (const raw of lines) {
1398
+ const line = raw.replace(/^(#\d+\s+)?(\d+\.\d+\s+)?/, "").trim();
1399
+ if (!line || line.startsWith("[Container]")) continue;
1400
+ if (/npm notice|Changelog:|To update run:|complete log of this run/i.test(line)) continue;
1401
+ if (!/\berror\b|ERR!|not found|No matching|cannot find|failed to solve|exit code: [1-9]/i.test(line)) continue;
1402
+ if (!out.includes(line)) out.push(line);
1403
+ if (out.length >= max) break;
1404
+ }
1405
+ return out;
1406
+ }
1407
+ var UNROUTED_MARKER = "no deployment found for this app";
1408
+ async function waitUntilRouted(url, { timeoutMs = 25e3, intervalMs = 1e3, fetchImpl = fetch } = {}) {
1409
+ const deadline = Date.now() + timeoutMs;
1410
+ while (Date.now() < deadline) {
1411
+ try {
1412
+ const res = await fetchImpl(url, { redirect: "manual", signal: AbortSignal.timeout(5e3) });
1413
+ if (res.status !== 404) return true;
1414
+ if (!(await res.text()).includes(UNROUTED_MARKER)) return true;
1415
+ } catch {
1416
+ }
1417
+ await new Promise((r) => setTimeout(r, intervalMs));
1418
+ }
1419
+ return false;
1420
+ }
1390
1421
 
1391
1422
  // src/commands/deploy.ts
1392
1423
  var deployCommand = new Command4("deploy").description("Deploy the current directory").option("-a, --app <id>", "App ID to deploy to").option("-m, --message <msg>", "Deployment message").option("--env <environment>", "preview or production (default: production)").action(async (opts) => {
@@ -1440,6 +1471,10 @@ var deployCommand = new Command4("deploy").description("Deploy the current direc
1440
1471
  }
1441
1472
  }
1442
1473
  if (current.status === "running") {
1474
+ if (current.url) {
1475
+ spinner.text = "Waiting for the edge to route the URL...";
1476
+ await waitUntilRouted(/^https?:\/\//.test(current.url) ? current.url : `https://${current.url}`);
1477
+ }
1443
1478
  spinner.succeed(chalk6.green(`Deployed successfully!`));
1444
1479
  try {
1445
1480
  const app = await client4.apps.get(appId);
@@ -1459,8 +1494,25 @@ var deployCommand = new Command4("deploy").description("Deploy the current direc
1459
1494
  console.log(chalk6.gray(` This version: ${current.previewUrl}`));
1460
1495
  }
1461
1496
  } else if (current.status === "failed" || current.status === "crashed") {
1462
- spinner.fail(chalk6.red(`Deployment ${current.status}: ${current.error || "unknown error"}`));
1463
- console.log(chalk6.gray(` Logs: videan logs --app ${appId}`));
1497
+ const detail = current.failureDetail ?? null;
1498
+ const reason = detail?.message || current.failureReason || "no reason was recorded";
1499
+ spinner.fail(chalk6.red(`Deployment ${current.status}: ${reason}`));
1500
+ if (detail?.hint) console.log(chalk6.yellow(` Fix: ${detail.hint}`));
1501
+ const buildFailed = current.status === "failed" && (detail?.cause === "build_failed" || /build/i.test(current.failureReason ?? ""));
1502
+ if (buildFailed) {
1503
+ try {
1504
+ const logs = await client4.apps.buildLogs(deployment.id);
1505
+ const excerpt = buildErrorExcerpt(logs.lines.map((l) => l.message));
1506
+ if (excerpt.length) {
1507
+ console.log(chalk6.gray(" Build output:"));
1508
+ for (const line of excerpt) console.log(chalk6.gray(` ${line}`));
1509
+ }
1510
+ } catch {
1511
+ }
1512
+ console.log(chalk6.gray(` Full build log: https://videan.xyz/apps/${appId}/deployments/${deployment.id}`));
1513
+ } else {
1514
+ console.log(chalk6.gray(` Logs: videan logs --app ${appId}`));
1515
+ }
1464
1516
  process.exit(1);
1465
1517
  } else {
1466
1518
  spinner.info(`Deployment status: ${formatStatus(current.status)}`);
@@ -1696,7 +1748,7 @@ var rollbackCommand = new Command8("rollback").description("Rollback to the prev
1696
1748
  import { Command as Command9 } from "commander";
1697
1749
  import chalk11 from "chalk";
1698
1750
  var secretsCommand = new Command9("secrets").description("Manage app secrets");
1699
- secretsCommand.command("set <key> [value]").description("Set a secret").option("-a, --app <id>", "App ID").action(async (key, value, opts) => {
1751
+ secretsCommand.command("set <key> [value]").description("Set a secret: `set KEY value` or `set KEY=value`").option("-a, --app <id>", "App ID").action(async (key, value, opts) => {
1700
1752
  const apiKey = getApiKey();
1701
1753
  requireApiKey(apiKey);
1702
1754
  const appId = opts.app || getCurrentApp();
@@ -1704,6 +1756,11 @@ secretsCommand.command("set <key> [value]").description("Set a secret").option("
1704
1756
  console.error(chalk11.red("No app specified."));
1705
1757
  process.exit(1);
1706
1758
  }
1759
+ ({ key, value } = parseSecretArgs(key, value));
1760
+ if (!key) {
1761
+ console.error(chalk11.red("Missing secret name before '='. Usage: videan secrets set KEY=value"));
1762
+ process.exit(1);
1763
+ }
1707
1764
  if (!value) {
1708
1765
  const answers = await prompt(
1709
1766
  [{ type: "password", name: "value", message: `Value for ${key}:` }],
@@ -2527,7 +2584,7 @@ function period(start, end) {
2527
2584
  // src/index.ts
2528
2585
  installPromptCrashGuard();
2529
2586
  var program = new Command18();
2530
- program.name("videan").description("Videan CLI \u2014 deploy apps in seconds").version("0.5.1");
2587
+ program.name("videan").description("Videan CLI \u2014 deploy apps in seconds").version("0.5.3");
2531
2588
  program.addCommand(loginCommand);
2532
2589
  program.addCommand(logoutCommand);
2533
2590
  program.addCommand(initCommand);