gistajs 0.1.12 → 0.1.13

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/bin.cjs CHANGED
@@ -1461,6 +1461,7 @@ async function provisionVercel(cwd, region, deps = defaultDeps3) {
1461
1461
  deps.stdout.log("Linking this directory to a Vercel project...");
1462
1462
  await deps.run("vercel", ["link", "--yes"], cwd);
1463
1463
  }
1464
+ await maybeConnectGit(deps, cwd);
1464
1465
  let envPath = (0, import_node_path6.join)(cwd, ".env");
1465
1466
  let file = await readEnvFile(envPath, deps);
1466
1467
  let values = requiredEnvVars.map((key) => [key, getRequiredEnvVar(file, key)]);
@@ -1512,6 +1513,37 @@ async function assertLoggedIn2(deps, cwd) {
1512
1513
  throw new Error("Not logged in. Run `vercel login` first.");
1513
1514
  }
1514
1515
  }
1516
+ async function maybeConnectGit(deps, cwd) {
1517
+ if (!deps.existsSync((0, import_node_path6.join)(cwd, ".git"))) return;
1518
+ let remotes = await readGitRemotes(deps, cwd);
1519
+ if (remotes.length === 0) return;
1520
+ try {
1521
+ await deps.runOutput("vercel", ["git", "connect", "--yes"], cwd);
1522
+ deps.stdout.log("Connected Vercel project to Git repository.");
1523
+ } catch (error) {
1524
+ let message = error instanceof Error ? error.message : String(error);
1525
+ if (canSkipGitConnect(message)) return;
1526
+ throw new Error(`Could not connect Vercel project to Git. ${message}`);
1527
+ }
1528
+ }
1529
+ async function readGitRemotes(deps, cwd) {
1530
+ try {
1531
+ let output = await deps.runOutput("git", ["remote"], cwd);
1532
+ return output.split("\n").map((line) => line.trim()).filter(Boolean);
1533
+ } catch (error) {
1534
+ let message = error instanceof Error ? error.message : String(error);
1535
+ let normalized = message.toLowerCase();
1536
+ let code = error.code;
1537
+ if (code === "ENOENT" || normalized.includes("not a git repository") || normalized.includes("no such file or directory")) {
1538
+ return [];
1539
+ }
1540
+ throw error;
1541
+ }
1542
+ }
1543
+ function canSkipGitConnect(message) {
1544
+ let normalized = message.toLowerCase();
1545
+ return normalized.includes("already connected") || normalized.includes("connected git repository") || normalized.includes("no git remote") || normalized.includes("no remotes") || normalized.includes("push first") || normalized.includes("repository has not been pushed");
1546
+ }
1515
1547
 
1516
1548
  // src/utils/catalog.ts
1517
1549
  var DEFAULT_CATALOG_URL = "https://gistajs.com/manifests/starters.json";
@@ -1548,7 +1580,7 @@ async function readCliVersion() {
1548
1580
  if (false) {
1549
1581
  throw new Error("Could not resolve the installed gistajs version");
1550
1582
  }
1551
- return "0.1.12";
1583
+ return "0.1.13";
1552
1584
  }
1553
1585
  async function runProjectCommand(cwd, script) {
1554
1586
  await run("pnpm", [script], cwd);
package/dist/index.js CHANGED
@@ -1446,6 +1446,7 @@ async function provisionVercel(cwd, region, deps = defaultDeps3) {
1446
1446
  deps.stdout.log("Linking this directory to a Vercel project...");
1447
1447
  await deps.run("vercel", ["link", "--yes"], cwd);
1448
1448
  }
1449
+ await maybeConnectGit(deps, cwd);
1449
1450
  let envPath = join6(cwd, ".env");
1450
1451
  let file = await readEnvFile(envPath, deps);
1451
1452
  let values = requiredEnvVars.map((key) => [key, getRequiredEnvVar(file, key)]);
@@ -1497,6 +1498,37 @@ async function assertLoggedIn2(deps, cwd) {
1497
1498
  throw new Error("Not logged in. Run `vercel login` first.");
1498
1499
  }
1499
1500
  }
1501
+ async function maybeConnectGit(deps, cwd) {
1502
+ if (!deps.existsSync(join6(cwd, ".git"))) return;
1503
+ let remotes = await readGitRemotes(deps, cwd);
1504
+ if (remotes.length === 0) return;
1505
+ try {
1506
+ await deps.runOutput("vercel", ["git", "connect", "--yes"], cwd);
1507
+ deps.stdout.log("Connected Vercel project to Git repository.");
1508
+ } catch (error) {
1509
+ let message = error instanceof Error ? error.message : String(error);
1510
+ if (canSkipGitConnect(message)) return;
1511
+ throw new Error(`Could not connect Vercel project to Git. ${message}`);
1512
+ }
1513
+ }
1514
+ async function readGitRemotes(deps, cwd) {
1515
+ try {
1516
+ let output = await deps.runOutput("git", ["remote"], cwd);
1517
+ return output.split("\n").map((line) => line.trim()).filter(Boolean);
1518
+ } catch (error) {
1519
+ let message = error instanceof Error ? error.message : String(error);
1520
+ let normalized = message.toLowerCase();
1521
+ let code = error.code;
1522
+ if (code === "ENOENT" || normalized.includes("not a git repository") || normalized.includes("no such file or directory")) {
1523
+ return [];
1524
+ }
1525
+ throw error;
1526
+ }
1527
+ }
1528
+ function canSkipGitConnect(message) {
1529
+ let normalized = message.toLowerCase();
1530
+ return normalized.includes("already connected") || normalized.includes("connected git repository") || normalized.includes("no git remote") || normalized.includes("no remotes") || normalized.includes("push first") || normalized.includes("repository has not been pushed");
1531
+ }
1500
1532
 
1501
1533
  // src/utils/catalog.ts
1502
1534
  var DEFAULT_CATALOG_URL = "https://gistajs.com/manifests/starters.json";
@@ -1533,7 +1565,7 @@ async function readCliVersion() {
1533
1565
  if (false) {
1534
1566
  throw new Error("Could not resolve the installed gistajs version");
1535
1567
  }
1536
- return "0.1.12";
1568
+ return "0.1.13";
1537
1569
  }
1538
1570
  async function runProjectCommand(cwd, script) {
1539
1571
  await run("pnpm", [script], cwd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gistajs",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Scaffold and manage Gista.js starter projects",
5
5
  "keywords": [
6
6
  "cli",