betterstart-cli 0.0.74 → 0.0.76

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/cli.js CHANGED
@@ -20138,6 +20138,10 @@ function spinner2(options) {
20138
20138
  };
20139
20139
  return {
20140
20140
  start: (message = "") => {
20141
+ if (started) {
20142
+ inner.message(fitSpinnerMessage(message));
20143
+ return;
20144
+ }
20141
20145
  setStarted(true);
20142
20146
  inner.start(fitSpinnerMessage(message));
20143
20147
  },
@@ -22680,23 +22684,6 @@ async function promptDeployProvider(initialValue = "none") {
22680
22684
  }
22681
22685
  return provider;
22682
22686
  }
22683
- async function promptRailwayBucketRegion() {
22684
- const region = await p14.select({
22685
- message: "Choose a Railway bucket region",
22686
- options: [
22687
- { value: "iad", label: "US East (Virginia)" },
22688
- { value: "sjc", label: "US West (California)" },
22689
- { value: "ams", label: "Europe (Amsterdam)" },
22690
- { value: "sin", label: "Asia Pacific (Singapore)" }
22691
- ],
22692
- initialValue: "iad"
22693
- });
22694
- if (p14.isCancel(region)) {
22695
- p14.cancel("Setup cancelled.");
22696
- process.exit(0);
22697
- }
22698
- return region;
22699
- }
22700
22687
 
22701
22688
  // adapters/next/init/railway/deploy.ts
22702
22689
  import fs28 from "fs";
@@ -23101,7 +23088,7 @@ async function ensureRailwayProject(runner, options) {
23101
23088
  projectSpinner.start("Checking Railway project names");
23102
23089
  }
23103
23090
  const projects = await listRailwayProjects(runner, options.cwd, options.env);
23104
- projectSpinner.start(`Creating Railway project ${pc2.cyan(options.projectName)}`);
23091
+ projectSpinner.message(`Creating Railway project ${pc2.cyan(options.projectName)}`);
23105
23092
  const created = await createRailwayProject(
23106
23093
  runner,
23107
23094
  options.cwd,
@@ -23243,41 +23230,48 @@ async function waitForPostgresVariables(session, cwd, service) {
23243
23230
  return {};
23244
23231
  }
23245
23232
  async function ensureRailwayPostgres(session, cwd) {
23246
- const services = await listRailwayServices(session, cwd);
23247
- const candidates = services.filter((service2) => /^postgres(?:[-_ ].*)?$/i.test(service2.name));
23248
- for (const candidate of candidates) {
23249
- const variables2 = await readRailwayServiceVariables(session, cwd, candidate.name);
23250
- if (variables2.DATABASE_PUBLIC_URL) {
23251
- return { service: candidate, databaseUrl: variables2.DATABASE_PUBLIC_URL };
23233
+ const provisionSpinner = spinner2();
23234
+ provisionSpinner.start("Creating your Railway Postgres database");
23235
+ try {
23236
+ const services = await listRailwayServices(session, cwd);
23237
+ const candidates = services.filter((service2) => /^postgres(?:[-_ ].*)?$/i.test(service2.name));
23238
+ for (const candidate of candidates) {
23239
+ const variables2 = await readRailwayServiceVariables(session, cwd, candidate.name);
23240
+ if (variables2.DATABASE_PUBLIC_URL) {
23241
+ return { service: candidate, databaseUrl: variables2.DATABASE_PUBLIC_URL };
23242
+ }
23252
23243
  }
23253
- }
23254
- if (candidates.length > 0) {
23255
- throw new Error(
23256
- `Railway Postgres service ${candidates.map((candidate) => candidate.name).join(", ")} exists, but DATABASE_PUBLIC_URL is not available. Rerun init after the database is ready.`
23257
- );
23258
- }
23259
- const result = await runRailway(session.runner, ["add", "--database", "postgres", "--json"], {
23260
- cwd,
23261
- mode: "capture",
23262
- env: session.env
23263
- });
23264
- const payload = result.success ? parseRailwayJson(result.stdout) : void 0;
23265
- const serviceName = payload && isNonEmptyString(payload.serviceName) ? payload.serviceName : null;
23266
- const serviceId = payload && isNonEmptyString(payload.serviceId) ? payload.serviceId : null;
23267
- if (!result.success || !serviceName) {
23268
- throw new Error(
23269
- railwayOutputTail(`${result.stdout}
23244
+ if (candidates.length > 0) {
23245
+ throw new Error(
23246
+ `Railway Postgres service ${candidates.map((candidate) => candidate.name).join(", ")} exists, but DATABASE_PUBLIC_URL is not available. Rerun init after the database is ready.`
23247
+ );
23248
+ }
23249
+ const result = await runRailway(session.runner, ["add", "--database", "postgres", "--json"], {
23250
+ cwd,
23251
+ mode: "capture",
23252
+ env: session.env
23253
+ });
23254
+ const payload = result.success ? parseRailwayJson(result.stdout) : void 0;
23255
+ const serviceName = payload && isNonEmptyString(payload.serviceName) ? payload.serviceName : null;
23256
+ const serviceId = payload && isNonEmptyString(payload.serviceId) ? payload.serviceId : null;
23257
+ if (!result.success || !serviceName) {
23258
+ throw new Error(
23259
+ railwayOutputTail(`${result.stdout}
23270
23260
  ${result.stderr}`) ?? "Could not provision Railway Postgres."
23271
- );
23272
- }
23273
- const service = { id: serviceId ?? serviceName, name: serviceName };
23274
- const variables = await waitForPostgresVariables(session, cwd, service);
23275
- if (!variables.DATABASE_PUBLIC_URL) {
23276
- throw new Error(
23277
- `Railway created ${service.name}, but DATABASE_PUBLIC_URL was not available. Rerun init after the database is ready.`
23278
- );
23261
+ );
23262
+ }
23263
+ const service = { id: serviceId ?? serviceName, name: serviceName };
23264
+ provisionSpinner.message("Waiting for the database connection string");
23265
+ const variables = await waitForPostgresVariables(session, cwd, service);
23266
+ if (!variables.DATABASE_PUBLIC_URL) {
23267
+ throw new Error(
23268
+ `Railway created ${service.name}, but DATABASE_PUBLIC_URL was not available. Rerun init after the database is ready.`
23269
+ );
23270
+ }
23271
+ return { service, databaseUrl: variables.DATABASE_PUBLIC_URL };
23272
+ } finally {
23273
+ provisionSpinner.clear();
23279
23274
  }
23280
- return { service, databaseUrl: variables.DATABASE_PUBLIC_URL };
23281
23275
  }
23282
23276
  function parseBucket(value) {
23283
23277
  if (!value || typeof value !== "object") return void 0;
@@ -23308,6 +23302,15 @@ function parseBucketCredentials(value) {
23308
23302
  async function ensureRailwayBucket(session, cwd, options) {
23309
23303
  const name = options.name ?? "media";
23310
23304
  const environmentArgs = ["--environment", session.project.environmentName];
23305
+ const provisionSpinner = spinner2();
23306
+ provisionSpinner.start("Creating your Railway bucket");
23307
+ try {
23308
+ return await provisionRailwayBucketResource(session, cwd, name, options.region, environmentArgs);
23309
+ } finally {
23310
+ provisionSpinner.clear();
23311
+ }
23312
+ }
23313
+ async function provisionRailwayBucketResource(session, cwd, name, region, environmentArgs) {
23311
23314
  const list = await runRailway(session.runner, ["bucket", "list", ...environmentArgs, "--json"], {
23312
23315
  cwd,
23313
23316
  mode: "capture",
@@ -23332,7 +23335,7 @@ ${list.stderr}`) ?? "Could not list Railway buckets."
23332
23335
  if (!bucket) {
23333
23336
  const create = await runRailway(
23334
23337
  session.runner,
23335
- ["bucket", "create", name, "--region", options.region, ...environmentArgs, "--json"],
23338
+ ["bucket", "create", name, "--region", region, ...environmentArgs, "--json"],
23336
23339
  { cwd, mode: "capture", env: session.env }
23337
23340
  );
23338
23341
  const createPayload = create.success ? parseRailwayJson(create.stdout) : void 0;
@@ -27289,9 +27292,6 @@ async function runInitCommand(name, options) {
27289
27292
  databaseUrl = await promptConnectionString();
27290
27293
  }
27291
27294
  } else {
27292
- p22.log.warn(
27293
- "Railway Postgres is container-backed. Plan and test your own backups, upgrades, and high-availability strategy before production use."
27294
- );
27295
27295
  try {
27296
27296
  const session = await getRailwaySession();
27297
27297
  const postgres = await ensureRailwayPostgres(session, cwd);
@@ -27322,7 +27322,7 @@ async function runInitCommand(name, options) {
27322
27322
  };
27323
27323
  const provisionRailwayBucket = async () => {
27324
27324
  try {
27325
- const region = options.railwayBucketRegion ?? (options.yes ? "iad" : await promptRailwayBucketRegion());
27325
+ const region = options.railwayBucketRegion ?? "iad";
27326
27326
  const session = await getRailwaySession();
27327
27327
  const bucket = await ensureRailwayBucket(session, cwd, {
27328
27328
  name: "media",