create-libretto 0.6.7-experimental.0 → 0.6.10

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/index.mjs +51 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -264,6 +264,45 @@ function runInstallAsync(cmd, cwd) {
264
264
  });
265
265
  }
266
266
 
267
+ // ---------------------------------------------------------------------------
268
+ // Git
269
+ // ---------------------------------------------------------------------------
270
+
271
+ function isGitAvailable() {
272
+ try {
273
+ execSync("git --version", { stdio: "ignore" });
274
+ return true;
275
+ } catch {
276
+ return false;
277
+ }
278
+ }
279
+
280
+ function isInsideGitWorkTree(targetDir) {
281
+ try {
282
+ const output = execSync("git rev-parse --is-inside-work-tree", {
283
+ cwd: targetDir,
284
+ encoding: "utf-8",
285
+ stdio: ["ignore", "pipe", "ignore"],
286
+ });
287
+ return output.trim() === "true";
288
+ } catch {
289
+ return false;
290
+ }
291
+ }
292
+
293
+ function initializeGitRepository(targetDir) {
294
+ if (!isGitAvailable()) return false;
295
+ if (existsSync(join(targetDir, ".git"))) return false;
296
+ if (isInsideGitWorkTree(targetDir)) return false;
297
+
298
+ try {
299
+ execSync("git init", { cwd: targetDir, stdio: "ignore" });
300
+ return true;
301
+ } catch {
302
+ return false;
303
+ }
304
+ }
305
+
267
306
  // ---------------------------------------------------------------------------
268
307
  // Scaffold
269
308
  // ---------------------------------------------------------------------------
@@ -411,6 +450,11 @@ export async function scaffoldProject(
411
450
  }
412
451
  }
413
452
  }
453
+
454
+ // 6. Initialize a git repository for standalone projects.
455
+ if (initializeGitRepository(targetDir)) {
456
+ console.log(`${GREEN}✓${RESET} Initialized git repository`);
457
+ }
414
458
  }
415
459
 
416
460
  // ---------------------------------------------------------------------------
@@ -461,9 +505,16 @@ async function main() {
461
505
 
462
506
  await scaffoldProject(targetDir, projectName, pkgManager);
463
507
 
508
+ const run = runCommand(pkgManager);
509
+ const relDir = relative(process.cwd(), targetDir) || projectName;
510
+
464
511
  console.log(
465
512
  `\n${GREEN}Success!${RESET} Created ${BOLD}${projectName}${RESET} at ${targetDir}\n`,
466
513
  );
514
+ console.log(`Next steps:`);
515
+ console.log(` cd ${relDir}`);
516
+ console.log(` ${run} libretto run src/workflows/star-repo.ts`);
517
+ console.log();
467
518
  }
468
519
 
469
520
  // Only run main when this file is executed directly (not imported)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-libretto",
3
- "version": "0.6.7-experimental.0",
3
+ "version": "0.6.10",
4
4
  "description": "Create and set up a Libretto project",
5
5
  "license": "MIT",
6
6
  "repository": {