@ghentcdh/create-crouton 0.0.1-alpha.80 → 0.0.1-alpha.82

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
@@ -26019,7 +26019,7 @@ import { join as join4 } from "path";
26019
26019
 
26020
26020
  // ../crouton-codegen/src/prisma-shell.ts
26021
26021
  import { spawn } from "child_process";
26022
- import { existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
26022
+ import { existsSync as existsSync2 } from "fs";
26023
26023
  import { copyFile, readFile as readFile4, readdir as readdir4, writeFile as writeFile2 } from "fs/promises";
26024
26024
  import { createRequire } from "module";
26025
26025
  import { dirname as dirname6, join as join5 } from "path";
@@ -26074,6 +26074,7 @@ var installDeps = (pm, cwd) => new Promise((resolve3, reject) => {
26074
26074
  );
26075
26075
  child.on("error", reject);
26076
26076
  });
26077
+ var pmExec = (pm, bin) => ({ pnpm: `pnpm exec ${bin}`, yarn: `yarn ${bin}`, bun: `bunx ${bin}`, npm: `npx ${bin}` })[pm];
26077
26078
 
26078
26079
  // src/lib/prompts.ts
26079
26080
  var CancelledError = class extends Error {
@@ -26136,13 +26137,13 @@ var runCreate = async (name, opts) => {
26136
26137
  log.info(`Using pnpm ${pnpmVersion}`);
26137
26138
  }
26138
26139
  const dbUrl = await resolveDbUrl(opts);
26139
- const postgres = opts.docker !== false ? await resolvePostgres(opts) : false;
26140
+ const postgres = opts.docker !== false && !dbUrl ? await resolvePostgres(opts) : false;
26140
26141
  const dbName = name.replace(/[^a-zA-Z0-9]/g, "_");
26141
26142
  const appName = prefix || name;
26142
26143
  const tokens = {
26143
26144
  name,
26144
26145
  Name: toTitle(name),
26145
- version: true ? "0.0.1-alpha.80" : "latest",
26146
+ version: true ? "0.0.1-alpha.82" : "latest",
26146
26147
  year: String((/* @__PURE__ */ new Date()).getFullYear()),
26147
26148
  pmRun: pm === "npm" ? "npm run" : pm,
26148
26149
  urlEnv: "DATABASE_URL",
@@ -26194,6 +26195,7 @@ var runCreate = async (name, opts) => {
26194
26195
  }
26195
26196
  const templateRoot = resolveTemplateDir();
26196
26197
  const skipPaths = !frontend ? ["apps/frontend"] : [];
26198
+ let resourcesUpdated = false;
26197
26199
  if (layout === "nx") {
26198
26200
  const rootTemplateDir = resolve2(templateRoot, "nx", "root");
26199
26201
  const rootFiles = await loadAndRenderTemplates(
@@ -26245,7 +26247,7 @@ var runCreate = async (name, opts) => {
26245
26247
  }
26246
26248
  const written = await writeFiles(files, { force: opts.force });
26247
26249
  log.success(`Wrote ${written} file(s) to ${import_picocolors.default.cyan(name)}/`);
26248
- await postScaffold(opts, targetDir, pm, dbUrl, prefix);
26250
+ ({ resourcesUpdated } = await postScaffold(opts, targetDir, pm, dbUrl, prefix));
26249
26251
  } else {
26250
26252
  const templateDir = resolve2(templateRoot, "regular");
26251
26253
  const files = await loadAndRenderTemplates(
@@ -26284,16 +26286,15 @@ var runCreate = async (name, opts) => {
26284
26286
  }
26285
26287
  const written = await writeFiles(files, { force: opts.force });
26286
26288
  log.success(`Wrote ${written} file(s) to ${import_picocolors.default.cyan(name)}/`);
26287
- await postScaffold(opts, targetDir, pm, dbUrl);
26289
+ ({ resourcesUpdated } = await postScaffold(opts, targetDir, pm, dbUrl));
26288
26290
  }
26289
26291
  const pmRun = pm === "npm" ? "npm run" : pm;
26290
26292
  const prefixFlag = prefix ? ` --prefix ${prefix}` : "";
26291
26293
  note(
26292
26294
  [
26293
- opts.docker !== false && postgres ? "docker compose up -d # start postgres" : null,
26294
- `${pmRun} prisma:migrate # create initial migration`,
26295
- `crouton update resources${prefixFlag} # generate resource CRUD`,
26296
- `${pmRun} dev # start dev server`
26295
+ postgres ? "docker compose up -d # start postgres" : null,
26296
+ !resourcesUpdated ? `${pmExec(pm, "crouton")} update resources${prefixFlag} # generate resource CRUD` : null,
26297
+ `${pmRun} dev # start dev server`
26297
26298
  ].filter(Boolean).join("\n"),
26298
26299
  "Next steps"
26299
26300
  );
@@ -26392,6 +26393,7 @@ var postScaffold = async (opts, targetDir, pm, dbUrl, prefix) => {
26392
26393
  s.error("Git init failed (non-fatal)");
26393
26394
  }
26394
26395
  }
26396
+ let resourcesUpdated = false;
26395
26397
  if (opts.install !== false) {
26396
26398
  const s = spinner();
26397
26399
  s.start(`Installing dependencies with ${pm}`);
@@ -26406,21 +26408,24 @@ var postScaffold = async (opts, targetDir, pm, dbUrl, prefix) => {
26406
26408
  const s2 = spinner();
26407
26409
  s2.start("Running crouton update resources");
26408
26410
  const prefixArg = prefix ? ` --prefix ${prefix}` : "";
26409
- execSync2(`npx crouton update resources --yes${prefixArg}`, {
26411
+ execSync2(`${pmExec(pm, "crouton")} update resources --yes${prefixArg}`, {
26410
26412
  cwd: targetDir,
26411
26413
  stdio: "pipe",
26412
26414
  env: { ...process.env, DATABASE_URL: dbUrl }
26413
26415
  });
26416
+ resourcesUpdated = true;
26414
26417
  s2.stop("Resources updated");
26415
26418
  } catch (err) {
26416
26419
  const stderr = err instanceof Error && "stderr" in err ? String(err.stderr).trim() : "";
26420
+ const firstLine = stderr.split("\n").find((l2) => l2.trim()) ?? "";
26417
26421
  log.warn(
26418
- "crouton update resources failed \u2014 run it manually after setting up your database." + (stderr ? `
26419
- ${import_picocolors.default.dim(stderr)}` : "")
26422
+ "crouton update resources failed \u2014 run it manually after setting up your database."
26420
26423
  );
26424
+ if (firstLine) log.error(firstLine);
26421
26425
  }
26422
26426
  }
26423
26427
  }
26428
+ return { resourcesUpdated };
26424
26429
  };
26425
26430
  var resolveLayout = async (opts) => {
26426
26431
  if (opts.prefix) return "nx";