@ghentcdh/create-crouton 0.0.1-alpha.36 → 0.0.1-alpha.38
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 +70 -18
- package/dist/index.js.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18938,6 +18938,10 @@ 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(),
|
|
18943
|
+
/** Override the Prisma relation field name when it differs from the column id. */
|
|
18944
|
+
relation: external_exports.string().optional(),
|
|
18941
18945
|
/** Override the display order in form views. Lower values come first. */
|
|
18942
18946
|
position: external_exports.number().optional(),
|
|
18943
18947
|
// default: source order
|
|
@@ -19155,8 +19159,9 @@ var JsonLinkActionSchema = ActionSchema.extend({
|
|
|
19155
19159
|
type: external_exports.literal("link").default("link"),
|
|
19156
19160
|
// required
|
|
19157
19161
|
/** URL to open. May contain `{env.VAR}` placeholders. */
|
|
19158
|
-
href: external_exports.string()
|
|
19159
|
-
// required
|
|
19162
|
+
href: external_exports.string(),
|
|
19163
|
+
// required,
|
|
19164
|
+
blank: external_exports.boolean().optional().default(true)
|
|
19160
19165
|
});
|
|
19161
19166
|
var transformAction = (action) => {
|
|
19162
19167
|
const label = action.label;
|
|
@@ -19183,6 +19188,10 @@ var JsonIncludeEntrySchema = external_exports.lazy(
|
|
|
19183
19188
|
])
|
|
19184
19189
|
);
|
|
19185
19190
|
|
|
19191
|
+
// ../crouton-core/src/lib/resource/version.ts
|
|
19192
|
+
var BASELINE_RESOURCE_VERSION = 1;
|
|
19193
|
+
var CURRENT_RESOURCE_VERSION = 1;
|
|
19194
|
+
|
|
19186
19195
|
// ../crouton-core/src/lib/resource/ResourceJson.schema.ts
|
|
19187
19196
|
var JsonColumnsMapSchema = external_exports.record(
|
|
19188
19197
|
external_exports.string(),
|
|
@@ -19204,6 +19213,19 @@ var normalizeColumns = (columns) => {
|
|
|
19204
19213
|
}));
|
|
19205
19214
|
};
|
|
19206
19215
|
var ResourceJsonShape = external_exports.object({
|
|
19216
|
+
/**
|
|
19217
|
+
* URL of the generated JSON Schema, for editor autocomplete/validation. Declared so the
|
|
19218
|
+
* key is *allowed* (not stripped, and not flagged by the very schema it points at).
|
|
19219
|
+
* Ignored at runtime.
|
|
19220
|
+
*/
|
|
19221
|
+
$schema: external_exports.string().optional(),
|
|
19222
|
+
/**
|
|
19223
|
+
* resource.json shape version. Missing ⇒ baseline (see `./version`). Auto-migrated
|
|
19224
|
+
* toward `CURRENT_RESOURCE_VERSION` on load in the dev environment.
|
|
19225
|
+
*/
|
|
19226
|
+
schemaVersion: external_exports.number().int().positive().optional(),
|
|
19227
|
+
/** When `true`, the resource lives in the repo but is NOT loaded/served (work in progress). */
|
|
19228
|
+
draft: external_exports.boolean().optional().default(false),
|
|
19207
19229
|
name: external_exports.string(),
|
|
19208
19230
|
// required — unique id, used as the frontend form id
|
|
19209
19231
|
route: external_exports.string(),
|
|
@@ -19244,7 +19266,13 @@ var ResourceJsonShape = external_exports.object({
|
|
|
19244
19266
|
});
|
|
19245
19267
|
var ResourceJsonSchema = ResourceJsonShape.transform((obj) => {
|
|
19246
19268
|
const title = obj.title ?? labelFromId(obj.name);
|
|
19247
|
-
|
|
19269
|
+
const schemaVersion = obj.schemaVersion ?? BASELINE_RESOURCE_VERSION;
|
|
19270
|
+
return {
|
|
19271
|
+
title,
|
|
19272
|
+
...obj,
|
|
19273
|
+
schemaVersion,
|
|
19274
|
+
columns: normalizeColumns(obj.columns)
|
|
19275
|
+
};
|
|
19248
19276
|
});
|
|
19249
19277
|
|
|
19250
19278
|
// ../crouton-core/src/lib/config/CroutonConfig.schema.ts
|
|
@@ -19295,9 +19323,27 @@ var CroutonConfigSchema = external_exports.object({
|
|
|
19295
19323
|
autoSave: external_exports.boolean().default(true)
|
|
19296
19324
|
});
|
|
19297
19325
|
|
|
19326
|
+
// ../crouton-core/src/lib/view/view.schema.ts
|
|
19327
|
+
var ViewColumnConfigSchema = external_exports.object({
|
|
19328
|
+
id: external_exports.string(),
|
|
19329
|
+
label: external_exports.string().optional(),
|
|
19330
|
+
sortable: external_exports.boolean().optional(),
|
|
19331
|
+
searchable: external_exports.boolean().optional(),
|
|
19332
|
+
fieldInput: FieldInputSchema.optional()
|
|
19333
|
+
});
|
|
19334
|
+
var ViewConfigSchema = external_exports.object({
|
|
19335
|
+
json_schema: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
19336
|
+
ui_schema: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
19337
|
+
columns: external_exports.array(ViewColumnConfigSchema),
|
|
19338
|
+
defaultSort: external_exports.string().optional()
|
|
19339
|
+
});
|
|
19340
|
+
|
|
19298
19341
|
// ../crouton-codegen/src/util.ts
|
|
19299
19342
|
import { access } from "fs/promises";
|
|
19300
19343
|
|
|
19344
|
+
// ../crouton-codegen/src/serialize.ts
|
|
19345
|
+
var RESOURCE_SCHEMA_URL = `https://ghentcdh.github.io/crouton/schema/v${CURRENT_RESOURCE_VERSION}/resource.schema.json`;
|
|
19346
|
+
|
|
19301
19347
|
// ../crouton-codegen/src/commit.ts
|
|
19302
19348
|
import { mkdir, writeFile } from "fs/promises";
|
|
19303
19349
|
import { dirname } from "path";
|
|
@@ -19431,9 +19477,15 @@ export default defineConfig({
|
|
|
19431
19477
|
import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
|
|
19432
19478
|
import { join as join3 } from "path";
|
|
19433
19479
|
|
|
19480
|
+
// ../crouton-codegen/src/prisma-shell.ts
|
|
19481
|
+
import { spawn } from "child_process";
|
|
19482
|
+
import { existsSync } from "fs";
|
|
19483
|
+
import { copyFile, readFile as readFile4, readdir as readdir4, writeFile as writeFile2 } from "fs/promises";
|
|
19484
|
+
import { dirname as dirname5, join as join4 } from "path";
|
|
19485
|
+
|
|
19434
19486
|
// src/lib/files.ts
|
|
19435
|
-
import { access as access2, mkdir as mkdir2, readFile as
|
|
19436
|
-
import { dirname as
|
|
19487
|
+
import { access as access2, mkdir as mkdir2, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
19488
|
+
import { dirname as dirname6 } from "path";
|
|
19437
19489
|
var fileExists2 = async (p2) => {
|
|
19438
19490
|
try {
|
|
19439
19491
|
await access2(p2);
|
|
@@ -19446,16 +19498,16 @@ var writeFiles = async (files, opts = {}) => {
|
|
|
19446
19498
|
let written = 0;
|
|
19447
19499
|
for (const f of files) {
|
|
19448
19500
|
if (!opts.force && await fileExists2(f.path)) continue;
|
|
19449
|
-
await mkdir2(
|
|
19450
|
-
await
|
|
19501
|
+
await mkdir2(dirname6(f.path), { recursive: true });
|
|
19502
|
+
await writeFile3(f.path, f.contents, "utf-8");
|
|
19451
19503
|
written += 1;
|
|
19452
19504
|
}
|
|
19453
19505
|
return written;
|
|
19454
19506
|
};
|
|
19455
|
-
var loadTemplate = async (templateDir, relativePath) =>
|
|
19507
|
+
var loadTemplate = async (templateDir, relativePath) => readFile5(`${templateDir}/${relativePath}`, "utf-8");
|
|
19456
19508
|
|
|
19457
19509
|
// src/lib/pm.ts
|
|
19458
|
-
import { execSync, spawn } from "child_process";
|
|
19510
|
+
import { execSync, spawn as spawn2 } from "child_process";
|
|
19459
19511
|
var MIN_PNPM_MAJOR = 11;
|
|
19460
19512
|
var checkPnpmVersion = () => {
|
|
19461
19513
|
let raw;
|
|
@@ -19474,7 +19526,7 @@ Upgrade with: npm i -g pnpm@latest`
|
|
|
19474
19526
|
return raw;
|
|
19475
19527
|
};
|
|
19476
19528
|
var installDeps = (pm, cwd) => new Promise((resolve3, reject) => {
|
|
19477
|
-
const child =
|
|
19529
|
+
const child = spawn2(pm, ["install"], { cwd, stdio: "inherit" });
|
|
19478
19530
|
child.on(
|
|
19479
19531
|
"close",
|
|
19480
19532
|
(code) => code === 0 ? resolve3() : reject(new Error(`${pm} install exited with code ${code}`))
|
|
@@ -19509,14 +19561,14 @@ var render = (template, tokens) => {
|
|
|
19509
19561
|
|
|
19510
19562
|
// src/runner.ts
|
|
19511
19563
|
import { execSync as execSync2 } from "child_process";
|
|
19512
|
-
import { existsSync } from "fs";
|
|
19513
|
-
import { readdir as
|
|
19564
|
+
import { existsSync as existsSync2 } from "fs";
|
|
19565
|
+
import { readdir as readdir5 } from "fs/promises";
|
|
19514
19566
|
import { resolve as resolve2 } from "path";
|
|
19515
19567
|
import { fileURLToPath } from "url";
|
|
19516
19568
|
var resolveTemplateDir = () => {
|
|
19517
19569
|
const thisDir = typeof __dirname !== "undefined" ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
19518
19570
|
const distPath = resolve2(thisDir, "templates");
|
|
19519
|
-
if (
|
|
19571
|
+
if (existsSync2(distPath)) return distPath;
|
|
19520
19572
|
return resolve2(thisDir, "..", "templates");
|
|
19521
19573
|
};
|
|
19522
19574
|
var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -19525,8 +19577,8 @@ var runCreate = async (name, opts) => {
|
|
|
19525
19577
|
Ie(import_picocolors3.default.bold(`create-crouton ${import_picocolors3.default.cyan(name)}`));
|
|
19526
19578
|
try {
|
|
19527
19579
|
const targetDir = resolve2(process.cwd(), name);
|
|
19528
|
-
if (
|
|
19529
|
-
const entries = await
|
|
19580
|
+
if (existsSync2(targetDir) && !opts.force) {
|
|
19581
|
+
const entries = await readdir5(targetDir);
|
|
19530
19582
|
if (entries.length > 0) {
|
|
19531
19583
|
M2.error(
|
|
19532
19584
|
`Directory "${name}" already exists and is not empty. Use --force to overwrite.`
|
|
@@ -19547,7 +19599,7 @@ var runCreate = async (name, opts) => {
|
|
|
19547
19599
|
const tokens = {
|
|
19548
19600
|
name,
|
|
19549
19601
|
Name: toTitle(name),
|
|
19550
|
-
version: true ? "0.0.1-alpha.
|
|
19602
|
+
version: true ? "0.0.1-alpha.38" : "latest",
|
|
19551
19603
|
year: String((/* @__PURE__ */ new Date()).getFullYear()),
|
|
19552
19604
|
pmRun: pm === "npm" ? "npm run" : pm,
|
|
19553
19605
|
urlEnv: "DATABASE_URL",
|
|
@@ -19807,8 +19859,8 @@ var resolveDbUrl = async (opts) => {
|
|
|
19807
19859
|
var loadAndRenderTemplates = async (templateDir, subPath, tokens, targetDir, skipPaths = []) => {
|
|
19808
19860
|
const files = [];
|
|
19809
19861
|
const dir = subPath ? resolve2(templateDir, subPath) : templateDir;
|
|
19810
|
-
if (!
|
|
19811
|
-
const entries = await
|
|
19862
|
+
if (!existsSync2(dir)) return files;
|
|
19863
|
+
const entries = await readdir5(dir, { withFileTypes: true });
|
|
19812
19864
|
for (const entry of entries) {
|
|
19813
19865
|
const relPath = subPath ? `${subPath}/${entry.name}` : entry.name;
|
|
19814
19866
|
if (skipPaths.some((sp) => relPath.startsWith(sp))) continue;
|