@launchmatic/cli 0.6.0 → 0.6.2

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/index.js +61 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17834,6 +17834,11 @@ var {
17834
17834
  Help
17835
17835
  } = import_index.default;
17836
17836
 
17837
+ // src/index.ts
17838
+ import { readFileSync as readFileSync8 } from "fs";
17839
+ import { fileURLToPath as fileURLToPath2 } from "url";
17840
+ import { dirname, join as join6 } from "path";
17841
+
17837
17842
  // src/commands/login.ts
17838
17843
  import http from "http";
17839
17844
  import { createInterface } from "readline";
@@ -21354,14 +21359,14 @@ function detectLocal(cwd) {
21354
21359
  return { runtime: "docker", port: 8080, confidence: "high" };
21355
21360
  }
21356
21361
  if (existsSync2(join(cwd, "bun.lockb")) || existsSync2(join(cwd, "bunfig.toml"))) {
21357
- const pkg = readPkg(cwd);
21358
- const framework = detectFramework(pkg, cwd);
21362
+ const pkg2 = readPkg(cwd);
21363
+ const framework = detectFramework(pkg2, cwd);
21359
21364
  const port = frameworkPort(framework) ?? 3e3;
21360
21365
  return {
21361
21366
  runtime: "bun",
21362
21367
  framework,
21363
- buildCmd: pkg?.scripts?.build ? "bun run build" : void 0,
21364
- startCmd: pkg?.scripts?.start ? "bun run start" : "bun index.ts",
21368
+ buildCmd: pkg2?.scripts?.build ? "bun run build" : void 0,
21369
+ startCmd: pkg2?.scripts?.start ? "bun run start" : "bun index.ts",
21365
21370
  port,
21366
21371
  confidence: "high"
21367
21372
  };
@@ -21382,8 +21387,8 @@ function detectLocal(cwd) {
21382
21387
  };
21383
21388
  }
21384
21389
  if (existsSync2(join(cwd, "package.json"))) {
21385
- const pkg = readPkg(cwd);
21386
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
21390
+ const pkg2 = readPkg(cwd);
21391
+ const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
21387
21392
  if (deps?.["stirrup-ai"]) {
21388
21393
  return {
21389
21394
  runtime: "nodejs",
@@ -21411,9 +21416,9 @@ function detectLocal(cwd) {
21411
21416
  if (existsSync2(join(cwd, "pnpm-lock.yaml"))) pm = "pnpm";
21412
21417
  else if (existsSync2(join(cwd, "yarn.lock"))) pm = "yarn";
21413
21418
  const prefix = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : "npm";
21414
- const buildCmd = pkg.scripts?.build ? `${prefix} run build` : void 0;
21415
- const startCmd = pkg.scripts?.start ? `${prefix} start` : "node index.js";
21416
- const framework = detectFramework(pkg, cwd);
21419
+ const buildCmd = pkg2.scripts?.build ? `${prefix} run build` : void 0;
21420
+ const startCmd = pkg2.scripts?.start ? `${prefix} start` : "node index.js";
21421
+ const framework = detectFramework(pkg2, cwd);
21417
21422
  const port = frameworkPort(framework) ?? 3e3;
21418
21423
  return {
21419
21424
  runtime: "nodejs",
@@ -21562,9 +21567,9 @@ function readPkg(cwd) {
21562
21567
  return void 0;
21563
21568
  }
21564
21569
  }
21565
- function detectFramework(pkg, cwd) {
21566
- if (!pkg) return void 0;
21567
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
21570
+ function detectFramework(pkg2, cwd) {
21571
+ if (!pkg2) return void 0;
21572
+ const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
21568
21573
  if (existsSync2(join(cwd, "next.config.js")) || existsSync2(join(cwd, "next.config.mjs")) || existsSync2(join(cwd, "next.config.ts")))
21569
21574
  return "Next.js";
21570
21575
  if (existsSync2(join(cwd, "nuxt.config.js")) || existsSync2(join(cwd, "nuxt.config.ts")))
@@ -24079,8 +24084,8 @@ function registerDb(program3) {
24079
24084
  requireLogin2();
24080
24085
  const spinner = ora(`Running ${file}...`).start();
24081
24086
  try {
24082
- const { readFileSync: readFileSync8 } = await import("fs");
24083
- const sql = readFileSync8(file, "utf-8");
24087
+ const { readFileSync: readFileSync9 } = await import("fs");
24088
+ const sql = readFileSync9(file, "utf-8");
24084
24089
  const { data } = await api(`/api/databases/${dbId}/query`, {
24085
24090
  method: "POST",
24086
24091
  body: JSON.stringify({ sql })
@@ -24215,9 +24220,9 @@ function validatePackageJson(files, ctx) {
24215
24220
  }
24216
24221
  return issues;
24217
24222
  }
24218
- let pkg;
24223
+ let pkg2;
24219
24224
  try {
24220
- pkg = JSON.parse(pkgFile.content);
24225
+ pkg2 = JSON.parse(pkgFile.content);
24221
24226
  } catch (e) {
24222
24227
  issues.push({
24223
24228
  category: "package-json",
@@ -24228,7 +24233,7 @@ function validatePackageJson(files, ctx) {
24228
24233
  });
24229
24234
  return issues;
24230
24235
  }
24231
- if (!pkg.name || typeof pkg.name !== "string") {
24236
+ if (!pkg2.name || typeof pkg2.name !== "string") {
24232
24237
  issues.push({
24233
24238
  category: "package-json",
24234
24239
  severity: "warning",
@@ -24238,7 +24243,7 @@ function validatePackageJson(files, ctx) {
24238
24243
  });
24239
24244
  }
24240
24245
  for (const depKey of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
24241
- const deps = pkg[depKey];
24246
+ const deps = pkg2[depKey];
24242
24247
  if (!deps || typeof deps !== "object")
24243
24248
  continue;
24244
24249
  for (const [name, version] of Object.entries(deps)) {
@@ -24261,7 +24266,7 @@ function validatePackageJson(files, ctx) {
24261
24266
  }
24262
24267
  }
24263
24268
  }
24264
- const scripts = pkg.scripts;
24269
+ const scripts = pkg2.scripts;
24265
24270
  if (ctx.startCmd) {
24266
24271
  const scriptMatch = ctx.startCmd.match(/^(?:npm|pnpm|yarn)\s+(?:run\s+)?(\S+)/);
24267
24272
  if (scriptMatch) {
@@ -24721,20 +24726,20 @@ function detectContext(dir) {
24721
24726
  const pkgPath = resolve3(dir, "package.json");
24722
24727
  if (existsSync5(pkgPath)) {
24723
24728
  try {
24724
- const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
24725
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
24729
+ const pkg2 = JSON.parse(readFileSync5(pkgPath, "utf-8"));
24730
+ const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
24726
24731
  if (deps.next) ctx.runtime = "nodejs";
24727
24732
  else if (deps.express || deps.fastify || deps.koa || deps.hapi) ctx.runtime = "nodejs";
24728
24733
  else if (deps.react || deps.vue || deps.svelte) ctx.runtime = "nodejs";
24729
- else if (pkg.type === "module" || deps.typescript) ctx.runtime = "nodejs";
24734
+ else if (pkg2.type === "module" || deps.typescript) ctx.runtime = "nodejs";
24730
24735
  if (existsSync5(resolve3(dir, "pnpm-lock.yaml"))) ctx.packageManager = "pnpm";
24731
24736
  else if (existsSync5(resolve3(dir, "yarn.lock"))) ctx.packageManager = "yarn";
24732
24737
  else if (existsSync5(resolve3(dir, "package-lock.json"))) ctx.packageManager = "npm";
24733
- const startScript = pkg.scripts?.start || pkg.scripts?.dev || "";
24738
+ const startScript = pkg2.scripts?.start || pkg2.scripts?.dev || "";
24734
24739
  const portMatch = startScript.match(/--port\s+(\d+)|-p\s+(\d+)/);
24735
24740
  if (portMatch) ctx.port = parseInt(portMatch[1] || portMatch[2]);
24736
24741
  if (deps.prisma || deps["@prisma/client"]) ctx.hasPrisma = true;
24737
- if (pkg.scripts?.start) ctx.startCmd = `npm run start`;
24742
+ if (pkg2.scripts?.start) ctx.startCmd = `npm run start`;
24738
24743
  } catch {
24739
24744
  }
24740
24745
  }
@@ -25900,11 +25905,11 @@ function readWorkspaceGlobs(repoRoot) {
25900
25905
  const pkgFile = join4(repoRoot, "package.json");
25901
25906
  if (existsSync6(pkgFile)) {
25902
25907
  try {
25903
- const pkg = JSON.parse(readFileSync6(pkgFile, "utf-8"));
25904
- if (Array.isArray(pkg.workspaces)) {
25905
- globs.push(...pkg.workspaces.filter((g) => typeof g === "string"));
25906
- } else if (pkg.workspaces && Array.isArray(pkg.workspaces.packages)) {
25907
- globs.push(...pkg.workspaces.packages.filter((g) => typeof g === "string"));
25908
+ const pkg2 = JSON.parse(readFileSync6(pkgFile, "utf-8"));
25909
+ if (Array.isArray(pkg2.workspaces)) {
25910
+ globs.push(...pkg2.workspaces.filter((g) => typeof g === "string"));
25911
+ } else if (pkg2.workspaces && Array.isArray(pkg2.workspaces.packages)) {
25912
+ globs.push(...pkg2.workspaces.packages.filter((g) => typeof g === "string"));
25908
25913
  }
25909
25914
  } catch {
25910
25915
  }
@@ -25933,9 +25938,9 @@ function isLikelyDeployable(absDir) {
25933
25938
  const pkgPath = join4(absDir, "package.json");
25934
25939
  if (existsSync6(pkgPath)) {
25935
25940
  try {
25936
- const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
25937
- if (pkg.scripts?.start || pkg.scripts?.dev || pkg.scripts?.serve) return true;
25938
- if (pkg.bin) return true;
25941
+ const pkg2 = JSON.parse(readFileSync6(pkgPath, "utf-8"));
25942
+ if (pkg2.scripts?.start || pkg2.scripts?.dev || pkg2.scripts?.serve) return true;
25943
+ if (pkg2.bin) return true;
25939
25944
  } catch {
25940
25945
  }
25941
25946
  }
@@ -26064,14 +26069,26 @@ Discovered ${discovered.length} service${discovered.length === 1 ? "" : "s"}:`))
26064
26069
  teamId = teams[parseInt(ans) - 1]?.id ?? teams[0].id;
26065
26070
  }
26066
26071
  }
26067
- const projectName = opts.project || opts.name || (existsSync7(join5(repoRoot, "package.json")) ? (() => {
26068
- try {
26069
- const pkg = JSON.parse(readFileSync7(join5(repoRoot, "package.json"), "utf-8"));
26070
- return pkg.name?.replace(/^@.*\//, "") || "monorepo";
26071
- } catch {
26072
- return "monorepo";
26072
+ const explicitName = opts.project || opts.name;
26073
+ const derivedName = (() => {
26074
+ if (existsSync7(join5(repoRoot, "package.json"))) {
26075
+ try {
26076
+ const pkg2 = JSON.parse(readFileSync7(join5(repoRoot, "package.json"), "utf-8"));
26077
+ const n = pkg2.name?.replace(/^@.*\//, "");
26078
+ if (n && n !== "monorepo") return n;
26079
+ } catch {
26080
+ }
26073
26081
  }
26074
- })() : "monorepo");
26082
+ const folder = repoRoot.split(/[\\/]/).filter(Boolean).pop();
26083
+ return folder || "monorepo";
26084
+ })();
26085
+ let projectName = explicitName ?? derivedName;
26086
+ if (!explicitName && !opts.yes) {
26087
+ const answer = await prompt6(
26088
+ `Project name [${source_default.cyan(derivedName)}]: `
26089
+ );
26090
+ if (answer) projectName = answer;
26091
+ }
26075
26092
  const projectSlug = projectName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "monorepo";
26076
26093
  const { data: existingProjects } = await api(
26077
26094
  `/api/projects?teamId=${teamId}`
@@ -26422,8 +26439,12 @@ function registerTemplate(program3) {
26422
26439
  }
26423
26440
 
26424
26441
  // src/index.ts
26442
+ var __dirname2 = dirname(fileURLToPath2(import.meta.url));
26443
+ var pkg = JSON.parse(
26444
+ readFileSync8(join6(__dirname2, "..", "package.json"), "utf-8")
26445
+ );
26425
26446
  var program2 = new Command();
26426
- program2.name("lm").description("Launchmatic CLI \u2014 deploy from your terminal").version("0.5.1");
26447
+ program2.name("lm").description("Launchmatic CLI \u2014 deploy from your terminal").version(pkg.version);
26427
26448
  registerLogin(program2);
26428
26449
  registerInit(program2);
26429
26450
  registerDeploy(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchmatic/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Launchmatic CLI — deploy from your terminal",
5
5
  "private": false,
6
6
  "type": "module",