@ghentcdh/create-crouton 0.0.1-alpha.34 → 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
@@ -18901,6 +18901,7 @@ var DetailConfigSchema = external_exports.object({
18901
18901
  // required
18902
18902
  });
18903
18903
  var RelationFieldInputOptionsSchema = external_exports.object({
18904
+ colspan: external_exports.number().optional().default(12),
18904
18905
  /** Field to sort related records by, e.g. `"title"` or `"author.name"`. */
18905
18906
  sort: external_exports.string().optional(),
18906
18907
  /** Sort direction. Defaults to `"asc"` when omitted. */
@@ -18937,6 +18938,8 @@ var FieldInputSchema = external_exports.object({
18937
18938
  */
18938
18939
  relationType: RelationType.optional(),
18939
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(),
18940
18943
  /** Override the display order in form views. Lower values come first. */
18941
18944
  position: external_exports.number().optional(),
18942
18945
  // default: source order
@@ -18944,6 +18947,7 @@ var FieldInputSchema = external_exports.object({
18944
18947
  /** Nested array detail layout (renders via `detailFixed`). */
18945
18948
  detail: DetailConfigSchema.optional()
18946
18949
  });
18950
+ var FieldVariantSchema = FieldInputSchema;
18947
18951
 
18948
18952
  // ../crouton-core/src/lib/schema/label.helper.ts
18949
18953
  var labelFromId = (id) => {
@@ -19045,6 +19049,18 @@ var JsonColumnSchema = external_exports.object({
19045
19049
  columnType: external_exports.string().default("string"),
19046
19050
  // default: 'string'
19047
19051
  fieldInput: FieldInputSchema.optional(),
19052
+ /**
19053
+ * Optional per-context override for the read-only VIEW ui. Same shape as
19054
+ * `fieldInput`; every key optional. Falls back to `fieldInput` (deep-merged
19055
+ * one level into `options`). Resolved at read time by the transformer.
19056
+ */
19057
+ fieldView: FieldVariantSchema.optional(),
19058
+ /**
19059
+ * Optional per-context override for the TABLE ui. Same shape as `fieldInput`;
19060
+ * every key optional. Falls back to `fieldView`, then `fieldInput`.
19061
+ * Resolved at read time by the transformer.
19062
+ */
19063
+ fieldTable: FieldVariantSchema.optional(),
19048
19064
  /**
19049
19065
  * Path to another `resource.json` whose columns are expanded as nested sub-columns
19050
19066
  * under this column's object key.
@@ -19141,8 +19157,9 @@ var JsonLinkActionSchema = ActionSchema.extend({
19141
19157
  type: external_exports.literal("link").default("link"),
19142
19158
  // required
19143
19159
  /** URL to open. May contain `{env.VAR}` placeholders. */
19144
- href: external_exports.string()
19145
- // required
19160
+ href: external_exports.string(),
19161
+ // required,
19162
+ blank: external_exports.boolean().optional().default(true)
19146
19163
  });
19147
19164
  var transformAction = (action) => {
19148
19165
  const label = action.label;
@@ -19169,6 +19186,10 @@ var JsonIncludeEntrySchema = external_exports.lazy(
19169
19186
  ])
19170
19187
  );
19171
19188
 
19189
+ // ../crouton-core/src/lib/resource/version.ts
19190
+ var BASELINE_RESOURCE_VERSION = 1;
19191
+ var CURRENT_RESOURCE_VERSION = 1;
19192
+
19172
19193
  // ../crouton-core/src/lib/resource/ResourceJson.schema.ts
19173
19194
  var JsonColumnsMapSchema = external_exports.record(
19174
19195
  external_exports.string(),
@@ -19190,6 +19211,19 @@ var normalizeColumns = (columns) => {
19190
19211
  }));
19191
19212
  };
19192
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),
19193
19227
  name: external_exports.string(),
19194
19228
  // required — unique id, used as the frontend form id
19195
19229
  route: external_exports.string(),
@@ -19230,7 +19264,13 @@ var ResourceJsonShape = external_exports.object({
19230
19264
  });
19231
19265
  var ResourceJsonSchema = ResourceJsonShape.transform((obj) => {
19232
19266
  const title = obj.title ?? labelFromId(obj.name);
19233
- 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
+ };
19234
19274
  });
19235
19275
 
19236
19276
  // ../crouton-core/src/lib/config/CroutonConfig.schema.ts
@@ -19284,6 +19324,9 @@ var CroutonConfigSchema = external_exports.object({
19284
19324
  // ../crouton-codegen/src/util.ts
19285
19325
  import { access } from "fs/promises";
19286
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
+
19287
19330
  // ../crouton-codegen/src/commit.ts
19288
19331
  import { mkdir, writeFile } from "fs/promises";
19289
19332
  import { dirname } from "path";
@@ -19417,9 +19460,15 @@ export default defineConfig({
19417
19460
  import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
19418
19461
  import { join as join3 } from "path";
19419
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
+
19420
19469
  // src/lib/files.ts
19421
- import { access as access2, mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
19422
- 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";
19423
19472
  var fileExists2 = async (p2) => {
19424
19473
  try {
19425
19474
  await access2(p2);
@@ -19432,16 +19481,16 @@ var writeFiles = async (files, opts = {}) => {
19432
19481
  let written = 0;
19433
19482
  for (const f of files) {
19434
19483
  if (!opts.force && await fileExists2(f.path)) continue;
19435
- await mkdir2(dirname5(f.path), { recursive: true });
19436
- 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");
19437
19486
  written += 1;
19438
19487
  }
19439
19488
  return written;
19440
19489
  };
19441
- var loadTemplate = async (templateDir, relativePath) => readFile4(`${templateDir}/${relativePath}`, "utf-8");
19490
+ var loadTemplate = async (templateDir, relativePath) => readFile5(`${templateDir}/${relativePath}`, "utf-8");
19442
19491
 
19443
19492
  // src/lib/pm.ts
19444
- import { execSync, spawn } from "child_process";
19493
+ import { execSync, spawn as spawn2 } from "child_process";
19445
19494
  var MIN_PNPM_MAJOR = 11;
19446
19495
  var checkPnpmVersion = () => {
19447
19496
  let raw;
@@ -19460,7 +19509,7 @@ Upgrade with: npm i -g pnpm@latest`
19460
19509
  return raw;
19461
19510
  };
19462
19511
  var installDeps = (pm, cwd) => new Promise((resolve3, reject) => {
19463
- const child = spawn(pm, ["install"], { cwd, stdio: "inherit" });
19512
+ const child = spawn2(pm, ["install"], { cwd, stdio: "inherit" });
19464
19513
  child.on(
19465
19514
  "close",
19466
19515
  (code) => code === 0 ? resolve3() : reject(new Error(`${pm} install exited with code ${code}`))
@@ -19495,14 +19544,14 @@ var render = (template, tokens) => {
19495
19544
 
19496
19545
  // src/runner.ts
19497
19546
  import { execSync as execSync2 } from "child_process";
19498
- import { existsSync } from "fs";
19499
- import { readdir as readdir4 } from "fs/promises";
19547
+ import { existsSync as existsSync2 } from "fs";
19548
+ import { readdir as readdir5 } from "fs/promises";
19500
19549
  import { resolve as resolve2 } from "path";
19501
19550
  import { fileURLToPath } from "url";
19502
19551
  var resolveTemplateDir = () => {
19503
19552
  const thisDir = typeof __dirname !== "undefined" ? __dirname : fileURLToPath(new URL(".", import.meta.url));
19504
19553
  const distPath = resolve2(thisDir, "templates");
19505
- if (existsSync(distPath)) return distPath;
19554
+ if (existsSync2(distPath)) return distPath;
19506
19555
  return resolve2(thisDir, "..", "templates");
19507
19556
  };
19508
19557
  var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -19511,8 +19560,8 @@ var runCreate = async (name, opts) => {
19511
19560
  Ie(import_picocolors3.default.bold(`create-crouton ${import_picocolors3.default.cyan(name)}`));
19512
19561
  try {
19513
19562
  const targetDir = resolve2(process.cwd(), name);
19514
- if (existsSync(targetDir) && !opts.force) {
19515
- const entries = await readdir4(targetDir);
19563
+ if (existsSync2(targetDir) && !opts.force) {
19564
+ const entries = await readdir5(targetDir);
19516
19565
  if (entries.length > 0) {
19517
19566
  M2.error(
19518
19567
  `Directory "${name}" already exists and is not empty. Use --force to overwrite.`
@@ -19533,7 +19582,7 @@ var runCreate = async (name, opts) => {
19533
19582
  const tokens = {
19534
19583
  name,
19535
19584
  Name: toTitle(name),
19536
- version: true ? "0.0.1-alpha.34" : "latest",
19585
+ version: true ? "0.0.1-alpha.37" : "latest",
19537
19586
  year: String((/* @__PURE__ */ new Date()).getFullYear()),
19538
19587
  pmRun: pm === "npm" ? "npm run" : pm,
19539
19588
  urlEnv: "DATABASE_URL",
@@ -19793,8 +19842,8 @@ var resolveDbUrl = async (opts) => {
19793
19842
  var loadAndRenderTemplates = async (templateDir, subPath, tokens, targetDir, skipPaths = []) => {
19794
19843
  const files = [];
19795
19844
  const dir = subPath ? resolve2(templateDir, subPath) : templateDir;
19796
- if (!existsSync(dir)) return files;
19797
- const entries = await readdir4(dir, { withFileTypes: true });
19845
+ if (!existsSync2(dir)) return files;
19846
+ const entries = await readdir5(dir, { withFileTypes: true });
19798
19847
  for (const entry of entries) {
19799
19848
  const relPath = subPath ? `${subPath}/${entry.name}` : entry.name;
19800
19849
  if (skipPaths.some((sp) => relPath.startsWith(sp))) continue;