@ghentcdh/create-crouton 0.0.1-alpha.36 → 0.0.1-alpha.37

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
@@ -18938,6 +18938,8 @@ var FieldInputSchema = external_exports.object({
18938
18938
  */
18939
18939
  relationType: RelationType.optional(),
18940
18940
  // auto-derived from the Zod model/sibling FK column if omitted
18941
+ /** FK field on the child model pointing back to the parent, e.g. `"workId"`. Defaults to `${parentModel}Id`. */
18942
+ foreignKey: external_exports.string().optional(),
18941
18943
  /** Override the display order in form views. Lower values come first. */
18942
18944
  position: external_exports.number().optional(),
18943
18945
  // default: source order
@@ -19155,8 +19157,9 @@ var JsonLinkActionSchema = ActionSchema.extend({
19155
19157
  type: external_exports.literal("link").default("link"),
19156
19158
  // required
19157
19159
  /** URL to open. May contain `{env.VAR}` placeholders. */
19158
- href: external_exports.string()
19159
- // required
19160
+ href: external_exports.string(),
19161
+ // required,
19162
+ blank: external_exports.boolean().optional().default(true)
19160
19163
  });
19161
19164
  var transformAction = (action) => {
19162
19165
  const label = action.label;
@@ -19183,6 +19186,10 @@ var JsonIncludeEntrySchema = external_exports.lazy(
19183
19186
  ])
19184
19187
  );
19185
19188
 
19189
+ // ../crouton-core/src/lib/resource/version.ts
19190
+ var BASELINE_RESOURCE_VERSION = 1;
19191
+ var CURRENT_RESOURCE_VERSION = 1;
19192
+
19186
19193
  // ../crouton-core/src/lib/resource/ResourceJson.schema.ts
19187
19194
  var JsonColumnsMapSchema = external_exports.record(
19188
19195
  external_exports.string(),
@@ -19204,6 +19211,19 @@ var normalizeColumns = (columns) => {
19204
19211
  }));
19205
19212
  };
19206
19213
  var ResourceJsonShape = external_exports.object({
19214
+ /**
19215
+ * URL of the generated JSON Schema, for editor autocomplete/validation. Declared so the
19216
+ * key is *allowed* (not stripped, and not flagged by the very schema it points at).
19217
+ * Ignored at runtime.
19218
+ */
19219
+ $schema: external_exports.string().optional(),
19220
+ /**
19221
+ * resource.json shape version. Missing ⇒ baseline (see `./version`). Auto-migrated
19222
+ * toward `CURRENT_RESOURCE_VERSION` on load in the dev environment.
19223
+ */
19224
+ schemaVersion: external_exports.number().int().positive().optional(),
19225
+ /** When `true`, the resource lives in the repo but is NOT loaded/served (work in progress). */
19226
+ draft: external_exports.boolean().optional().default(false),
19207
19227
  name: external_exports.string(),
19208
19228
  // required — unique id, used as the frontend form id
19209
19229
  route: external_exports.string(),
@@ -19244,7 +19264,13 @@ var ResourceJsonShape = external_exports.object({
19244
19264
  });
19245
19265
  var ResourceJsonSchema = ResourceJsonShape.transform((obj) => {
19246
19266
  const title = obj.title ?? labelFromId(obj.name);
19247
- return { title, ...obj, columns: normalizeColumns(obj.columns) };
19267
+ const schemaVersion = obj.schemaVersion ?? BASELINE_RESOURCE_VERSION;
19268
+ return {
19269
+ title,
19270
+ ...obj,
19271
+ schemaVersion,
19272
+ columns: normalizeColumns(obj.columns)
19273
+ };
19248
19274
  });
19249
19275
 
19250
19276
  // ../crouton-core/src/lib/config/CroutonConfig.schema.ts
@@ -19298,6 +19324,9 @@ var CroutonConfigSchema = external_exports.object({
19298
19324
  // ../crouton-codegen/src/util.ts
19299
19325
  import { access } from "fs/promises";
19300
19326
 
19327
+ // ../crouton-codegen/src/serialize.ts
19328
+ var RESOURCE_SCHEMA_URL = `https://ghentcdh.github.io/crouton/schema/v${CURRENT_RESOURCE_VERSION}/resource.schema.json`;
19329
+
19301
19330
  // ../crouton-codegen/src/commit.ts
19302
19331
  import { mkdir, writeFile } from "fs/promises";
19303
19332
  import { dirname } from "path";
@@ -19431,9 +19460,15 @@ export default defineConfig({
19431
19460
  import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
19432
19461
  import { join as join3 } from "path";
19433
19462
 
19463
+ // ../crouton-codegen/src/prisma-shell.ts
19464
+ import { spawn } from "child_process";
19465
+ import { existsSync } from "fs";
19466
+ import { copyFile, readFile as readFile4, readdir as readdir4, writeFile as writeFile2 } from "fs/promises";
19467
+ import { dirname as dirname5, join as join4 } from "path";
19468
+
19434
19469
  // src/lib/files.ts
19435
- import { access as access2, mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
19436
- import { dirname as dirname5 } from "path";
19470
+ import { access as access2, mkdir as mkdir2, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
19471
+ import { dirname as dirname6 } from "path";
19437
19472
  var fileExists2 = async (p2) => {
19438
19473
  try {
19439
19474
  await access2(p2);
@@ -19446,16 +19481,16 @@ var writeFiles = async (files, opts = {}) => {
19446
19481
  let written = 0;
19447
19482
  for (const f of files) {
19448
19483
  if (!opts.force && await fileExists2(f.path)) continue;
19449
- await mkdir2(dirname5(f.path), { recursive: true });
19450
- await writeFile2(f.path, f.contents, "utf-8");
19484
+ await mkdir2(dirname6(f.path), { recursive: true });
19485
+ await writeFile3(f.path, f.contents, "utf-8");
19451
19486
  written += 1;
19452
19487
  }
19453
19488
  return written;
19454
19489
  };
19455
- var loadTemplate = async (templateDir, relativePath) => readFile4(`${templateDir}/${relativePath}`, "utf-8");
19490
+ var loadTemplate = async (templateDir, relativePath) => readFile5(`${templateDir}/${relativePath}`, "utf-8");
19456
19491
 
19457
19492
  // src/lib/pm.ts
19458
- import { execSync, spawn } from "child_process";
19493
+ import { execSync, spawn as spawn2 } from "child_process";
19459
19494
  var MIN_PNPM_MAJOR = 11;
19460
19495
  var checkPnpmVersion = () => {
19461
19496
  let raw;
@@ -19474,7 +19509,7 @@ Upgrade with: npm i -g pnpm@latest`
19474
19509
  return raw;
19475
19510
  };
19476
19511
  var installDeps = (pm, cwd) => new Promise((resolve3, reject) => {
19477
- const child = spawn(pm, ["install"], { cwd, stdio: "inherit" });
19512
+ const child = spawn2(pm, ["install"], { cwd, stdio: "inherit" });
19478
19513
  child.on(
19479
19514
  "close",
19480
19515
  (code) => code === 0 ? resolve3() : reject(new Error(`${pm} install exited with code ${code}`))
@@ -19509,14 +19544,14 @@ var render = (template, tokens) => {
19509
19544
 
19510
19545
  // src/runner.ts
19511
19546
  import { execSync as execSync2 } from "child_process";
19512
- import { existsSync } from "fs";
19513
- import { readdir as readdir4 } from "fs/promises";
19547
+ import { existsSync as existsSync2 } from "fs";
19548
+ import { readdir as readdir5 } from "fs/promises";
19514
19549
  import { resolve as resolve2 } from "path";
19515
19550
  import { fileURLToPath } from "url";
19516
19551
  var resolveTemplateDir = () => {
19517
19552
  const thisDir = typeof __dirname !== "undefined" ? __dirname : fileURLToPath(new URL(".", import.meta.url));
19518
19553
  const distPath = resolve2(thisDir, "templates");
19519
- if (existsSync(distPath)) return distPath;
19554
+ if (existsSync2(distPath)) return distPath;
19520
19555
  return resolve2(thisDir, "..", "templates");
19521
19556
  };
19522
19557
  var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -19525,8 +19560,8 @@ var runCreate = async (name, opts) => {
19525
19560
  Ie(import_picocolors3.default.bold(`create-crouton ${import_picocolors3.default.cyan(name)}`));
19526
19561
  try {
19527
19562
  const targetDir = resolve2(process.cwd(), name);
19528
- if (existsSync(targetDir) && !opts.force) {
19529
- const entries = await readdir4(targetDir);
19563
+ if (existsSync2(targetDir) && !opts.force) {
19564
+ const entries = await readdir5(targetDir);
19530
19565
  if (entries.length > 0) {
19531
19566
  M2.error(
19532
19567
  `Directory "${name}" already exists and is not empty. Use --force to overwrite.`
@@ -19547,7 +19582,7 @@ var runCreate = async (name, opts) => {
19547
19582
  const tokens = {
19548
19583
  name,
19549
19584
  Name: toTitle(name),
19550
- version: true ? "0.0.1-alpha.36" : "latest",
19585
+ version: true ? "0.0.1-alpha.37" : "latest",
19551
19586
  year: String((/* @__PURE__ */ new Date()).getFullYear()),
19552
19587
  pmRun: pm === "npm" ? "npm run" : pm,
19553
19588
  urlEnv: "DATABASE_URL",
@@ -19807,8 +19842,8 @@ var resolveDbUrl = async (opts) => {
19807
19842
  var loadAndRenderTemplates = async (templateDir, subPath, tokens, targetDir, skipPaths = []) => {
19808
19843
  const files = [];
19809
19844
  const dir = subPath ? resolve2(templateDir, subPath) : templateDir;
19810
- if (!existsSync(dir)) return files;
19811
- const entries = await readdir4(dir, { withFileTypes: true });
19845
+ if (!existsSync2(dir)) return files;
19846
+ const entries = await readdir5(dir, { withFileTypes: true });
19812
19847
  for (const entry of entries) {
19813
19848
  const relPath = subPath ? `${subPath}/${entry.name}` : entry.name;
19814
19849
  if (skipPaths.some((sp) => relPath.startsWith(sp))) continue;