@ghentcdh/create-crouton 0.0.1-alpha.25 → 0.0.1-alpha.27
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 +312 -154
- package/dist/index.js.map +1 -1
- package/dist/lib/index.js +20 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/templates/nx/{nx.json.tmpl → root/nx.json.tmpl} +2 -1
- package/dist/templates/nx/{package.json.tmpl → root/package.json.tmpl} +7 -1
- package/dist/templates/nx/root/pnpm-workspace.yaml.tmpl +20 -0
- package/dist/templates/nx/{tsconfig.base.json.tmpl → root/tsconfig.base.json.tmpl} +2 -1
- package/dist/templates/nx/workspace/.env.tmpl +1 -0
- package/dist/templates/nx/{apps → workspace/apps}/backend/package.json.tmpl +1 -1
- package/dist/templates/nx/workspace/apps/backend/project.json.tmpl +7 -0
- package/dist/templates/nx/{apps → workspace/apps}/backend/src/app/app.module.ts.tmpl +1 -0
- package/dist/templates/nx/{apps → workspace/apps}/backend/tsconfig.json.tmpl +1 -2
- package/dist/templates/nx/workspace/apps/frontend/project.json.tmpl +7 -0
- package/dist/templates/nx/workspace/apps/frontend/src/App.vue.tmpl +6 -0
- package/dist/templates/nx/workspace/apps/frontend/src/main.ts.tmpl +25 -0
- package/dist/templates/nx/{apps → workspace/apps}/frontend/tsconfig.json.tmpl +1 -1
- package/dist/templates/nx/{generated/types → workspace/generated/default/client}/package.json.tmpl +1 -1
- package/dist/templates/nx/workspace/generated/default/types/package.json.tmpl +9 -0
- package/dist/templates/regular/.env.tmpl +1 -1
- package/dist/templates/regular/.npmrc.tmpl +4 -0
- package/dist/templates/regular/package.json.tmpl +1 -1
- package/dist/templates/regular/src/app.module.ts.tmpl +1 -0
- package/dist/templates/regular/tsconfig.json.tmpl +2 -1
- package/package.json +5 -2
- package/dist/templates/nx/.env.tmpl +0 -1
- package/dist/templates/nx/apps/backend/project.json.tmpl +0 -7
- package/dist/templates/nx/apps/frontend/project.json.tmpl +0 -7
- package/dist/templates/nx/apps/frontend/src/App.vue.tmpl +0 -9
- package/dist/templates/nx/apps/frontend/src/main.ts.tmpl +0 -4
- package/dist/templates/nx/pnpm-workspace.yaml.tmpl +0 -4
- /package/dist/templates/nx/{.gitignore.tmpl → root/.gitignore.tmpl} +0 -0
- /package/dist/templates/nx/{.nvmrc.tmpl → root/.nvmrc.tmpl} +0 -0
- /package/dist/templates/nx/{.env.example.tmpl → workspace/.env.example.tmpl} +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/backend/nest-cli.json.tmpl +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/backend/src/main.ts.tmpl +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/frontend/index.html.tmpl +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/frontend/package.json.tmpl +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/frontend/src/api.ts.tmpl +0 -0
- /package/dist/templates/nx/{apps → workspace/apps}/frontend/vite.config.ts.tmpl +0 -0
- /package/dist/templates/nx/{crouton.enums.json.tmpl → workspace/crouton.enums.json.tmpl} +0 -0
- /package/dist/templates/nx/{crouton.json.tmpl → workspace/crouton.json.tmpl} +0 -0
package/dist/index.js
CHANGED
|
@@ -2416,8 +2416,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2416
2416
|
if (index < this.args.length) {
|
|
2417
2417
|
value = this.args.slice(index);
|
|
2418
2418
|
if (declaredArg.parseArg) {
|
|
2419
|
-
value = value.reduce((processed,
|
|
2420
|
-
return myParseArg(declaredArg,
|
|
2419
|
+
value = value.reduce((processed, v2) => {
|
|
2420
|
+
return myParseArg(declaredArg, v2, processed);
|
|
2421
2421
|
}, declaredArg.defaultValue);
|
|
2422
2422
|
}
|
|
2423
2423
|
} else if (value === void 0) {
|
|
@@ -3621,6 +3621,7 @@ import { stripVTControlCharacters as S2 } from "util";
|
|
|
3621
3621
|
|
|
3622
3622
|
// ../../node_modules/.pnpm/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs
|
|
3623
3623
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
3624
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
3624
3625
|
import { stdin as j, stdout as M } from "process";
|
|
3625
3626
|
import * as g from "readline";
|
|
3626
3627
|
import O from "readline";
|
|
@@ -3993,9 +3994,25 @@ var LD = class extends x {
|
|
|
3993
3994
|
this.value = this._value.value;
|
|
3994
3995
|
}
|
|
3995
3996
|
};
|
|
3997
|
+
var RD = class extends x {
|
|
3998
|
+
get valueWithCursor() {
|
|
3999
|
+
if (this.state === "submit") return this.value;
|
|
4000
|
+
if (this.cursor >= this.value.length) return `${this.value}\u2588`;
|
|
4001
|
+
const u2 = this.value.slice(0, this.cursor), [t, ...F2] = this.value.slice(this.cursor);
|
|
4002
|
+
return `${u2}${import_picocolors.default.inverse(t)}${F2.join("")}`;
|
|
4003
|
+
}
|
|
4004
|
+
get cursor() {
|
|
4005
|
+
return this._cursor;
|
|
4006
|
+
}
|
|
4007
|
+
constructor(u2) {
|
|
4008
|
+
super(u2), this.on("finalize", () => {
|
|
4009
|
+
this.value || (this.value = u2.defaultValue);
|
|
4010
|
+
});
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
3996
4013
|
|
|
3997
4014
|
// ../../node_modules/.pnpm/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
|
|
3998
|
-
var
|
|
4015
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
3999
4016
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
4000
4017
|
import y2 from "process";
|
|
4001
4018
|
function ce() {
|
|
@@ -4028,13 +4045,13 @@ var b2 = (t) => {
|
|
|
4028
4045
|
switch (t) {
|
|
4029
4046
|
case "initial":
|
|
4030
4047
|
case "active":
|
|
4031
|
-
return
|
|
4048
|
+
return import_picocolors2.default.cyan(le);
|
|
4032
4049
|
case "cancel":
|
|
4033
|
-
return
|
|
4050
|
+
return import_picocolors2.default.red(L2);
|
|
4034
4051
|
case "error":
|
|
4035
|
-
return
|
|
4052
|
+
return import_picocolors2.default.yellow(W2);
|
|
4036
4053
|
case "submit":
|
|
4037
|
-
return
|
|
4054
|
+
return import_picocolors2.default.green(C);
|
|
4038
4055
|
}
|
|
4039
4056
|
};
|
|
4040
4057
|
var G2 = (t) => {
|
|
@@ -4042,26 +4059,47 @@ var G2 = (t) => {
|
|
|
4042
4059
|
let l2 = 0;
|
|
4043
4060
|
n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
4044
4061
|
const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
|
|
4045
|
-
return r2.slice(l2, l2 + a).map((p2,
|
|
4046
|
-
const j2 =
|
|
4047
|
-
return j2 || E ?
|
|
4062
|
+
return r2.slice(l2, l2 + a).map((p2, v2, f) => {
|
|
4063
|
+
const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g2;
|
|
4064
|
+
return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
|
|
4048
4065
|
});
|
|
4049
4066
|
};
|
|
4067
|
+
var he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
4068
|
+
const n = `${import_picocolors2.default.gray(o)}
|
|
4069
|
+
${b2(this.state)} ${t.message}
|
|
4070
|
+
`, r2 = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r2;
|
|
4071
|
+
switch (this.state) {
|
|
4072
|
+
case "error":
|
|
4073
|
+
return `${n.trim()}
|
|
4074
|
+
${import_picocolors2.default.yellow(o)} ${i}
|
|
4075
|
+
${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
|
|
4076
|
+
`;
|
|
4077
|
+
case "submit":
|
|
4078
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
|
|
4079
|
+
case "cancel":
|
|
4080
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
4081
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
4082
|
+
default:
|
|
4083
|
+
return `${n}${import_picocolors2.default.cyan(o)} ${i}
|
|
4084
|
+
${import_picocolors2.default.cyan(d2)}
|
|
4085
|
+
`;
|
|
4086
|
+
}
|
|
4087
|
+
} }).prompt();
|
|
4050
4088
|
var ye = (t) => {
|
|
4051
4089
|
const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
|
|
4052
4090
|
return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
|
|
4053
|
-
const i = `${
|
|
4091
|
+
const i = `${import_picocolors2.default.gray(o)}
|
|
4054
4092
|
${b2(this.state)} ${t.message}
|
|
4055
4093
|
`, s = this.value ? n : r2;
|
|
4056
4094
|
switch (this.state) {
|
|
4057
4095
|
case "submit":
|
|
4058
|
-
return `${i}${
|
|
4096
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
|
|
4059
4097
|
case "cancel":
|
|
4060
|
-
return `${i}${
|
|
4061
|
-
${
|
|
4098
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
|
|
4099
|
+
${import_picocolors2.default.gray(o)}`;
|
|
4062
4100
|
default:
|
|
4063
|
-
return `${i}${
|
|
4064
|
-
${
|
|
4101
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.green(k2)} ${r2}`}
|
|
4102
|
+
${import_picocolors2.default.cyan(d2)}
|
|
4065
4103
|
`;
|
|
4066
4104
|
}
|
|
4067
4105
|
} }).prompt();
|
|
@@ -4071,29 +4109,29 @@ var ve = (t) => {
|
|
|
4071
4109
|
const s = r2.label ?? String(r2.value);
|
|
4072
4110
|
switch (i) {
|
|
4073
4111
|
case "selected":
|
|
4074
|
-
return `${
|
|
4112
|
+
return `${import_picocolors2.default.dim(s)}`;
|
|
4075
4113
|
case "active":
|
|
4076
|
-
return `${
|
|
4114
|
+
return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
|
|
4077
4115
|
case "cancelled":
|
|
4078
|
-
return `${
|
|
4116
|
+
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
|
|
4079
4117
|
default:
|
|
4080
|
-
return `${
|
|
4118
|
+
return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
|
|
4081
4119
|
}
|
|
4082
4120
|
};
|
|
4083
4121
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
4084
|
-
const r2 = `${
|
|
4122
|
+
const r2 = `${import_picocolors2.default.gray(o)}
|
|
4085
4123
|
${b2(this.state)} ${t.message}
|
|
4086
4124
|
`;
|
|
4087
4125
|
switch (this.state) {
|
|
4088
4126
|
case "submit":
|
|
4089
|
-
return `${r2}${
|
|
4127
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
4090
4128
|
case "cancel":
|
|
4091
|
-
return `${r2}${
|
|
4092
|
-
${
|
|
4129
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
4130
|
+
${import_picocolors2.default.gray(o)}`;
|
|
4093
4131
|
default:
|
|
4094
|
-
return `${r2}${
|
|
4095
|
-
${
|
|
4096
|
-
${
|
|
4132
|
+
return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
4133
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
4134
|
+
${import_picocolors2.default.cyan(d2)}
|
|
4097
4135
|
`;
|
|
4098
4136
|
}
|
|
4099
4137
|
} }).prompt();
|
|
@@ -4105,63 +4143,63 @@ ${t}
|
|
|
4105
4143
|
`), i = S2(n).length, s = Math.max(r2.reduce((a, l2) => {
|
|
4106
4144
|
const $2 = S2(l2);
|
|
4107
4145
|
return $2.length > a ? $2.length : a;
|
|
4108
|
-
}, 0), i) + 2, c = r2.map((a) => `${
|
|
4146
|
+
}, 0), i) + 2, c = r2.map((a) => `${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(a)}${" ".repeat(s - S2(a).length)}${import_picocolors2.default.gray(o)}`).join(`
|
|
4109
4147
|
`);
|
|
4110
|
-
process.stdout.write(`${
|
|
4111
|
-
${
|
|
4148
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
4149
|
+
${import_picocolors2.default.green(C)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
|
|
4112
4150
|
${c}
|
|
4113
|
-
${
|
|
4151
|
+
${import_picocolors2.default.gray(de + _2.repeat(s + 2) + pe)}
|
|
4114
4152
|
`);
|
|
4115
4153
|
};
|
|
4116
4154
|
var xe = (t = "") => {
|
|
4117
|
-
process.stdout.write(`${
|
|
4155
|
+
process.stdout.write(`${import_picocolors2.default.gray(d2)} ${import_picocolors2.default.red(t)}
|
|
4118
4156
|
|
|
4119
4157
|
`);
|
|
4120
4158
|
};
|
|
4121
4159
|
var Ie = (t = "") => {
|
|
4122
|
-
process.stdout.write(`${
|
|
4160
|
+
process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
|
|
4123
4161
|
`);
|
|
4124
4162
|
};
|
|
4125
4163
|
var Se = (t = "") => {
|
|
4126
|
-
process.stdout.write(`${
|
|
4127
|
-
${
|
|
4164
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
4165
|
+
${import_picocolors2.default.gray(d2)} ${t}
|
|
4128
4166
|
|
|
4129
4167
|
`);
|
|
4130
4168
|
};
|
|
4131
|
-
var M2 = { message: (t = "", { symbol: n =
|
|
4132
|
-
const r2 = [`${
|
|
4169
|
+
var M2 = { message: (t = "", { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
4170
|
+
const r2 = [`${import_picocolors2.default.gray(o)}`];
|
|
4133
4171
|
if (t) {
|
|
4134
4172
|
const [i, ...s] = t.split(`
|
|
4135
4173
|
`);
|
|
4136
|
-
r2.push(`${n} ${i}`, ...s.map((c) => `${
|
|
4174
|
+
r2.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors2.default.gray(o)} ${c}`));
|
|
4137
4175
|
}
|
|
4138
4176
|
process.stdout.write(`${r2.join(`
|
|
4139
4177
|
`)}
|
|
4140
4178
|
`);
|
|
4141
4179
|
}, info: (t) => {
|
|
4142
|
-
M2.message(t, { symbol:
|
|
4180
|
+
M2.message(t, { symbol: import_picocolors2.default.blue(q) });
|
|
4143
4181
|
}, success: (t) => {
|
|
4144
|
-
M2.message(t, { symbol:
|
|
4182
|
+
M2.message(t, { symbol: import_picocolors2.default.green(D) });
|
|
4145
4183
|
}, step: (t) => {
|
|
4146
|
-
M2.message(t, { symbol:
|
|
4184
|
+
M2.message(t, { symbol: import_picocolors2.default.green(C) });
|
|
4147
4185
|
}, warn: (t) => {
|
|
4148
|
-
M2.message(t, { symbol:
|
|
4186
|
+
M2.message(t, { symbol: import_picocolors2.default.yellow(U) });
|
|
4149
4187
|
}, warning: (t) => {
|
|
4150
4188
|
M2.warn(t);
|
|
4151
4189
|
}, error: (t) => {
|
|
4152
|
-
M2.message(t, { symbol:
|
|
4190
|
+
M2.message(t, { symbol: import_picocolors2.default.red(K2) });
|
|
4153
4191
|
} };
|
|
4154
|
-
var J2 = `${
|
|
4192
|
+
var J2 = `${import_picocolors2.default.gray(o)} `;
|
|
4155
4193
|
var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
4156
4194
|
const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i = process.env.CI === "true";
|
|
4157
4195
|
let s, c, a = false, l2 = "", $2, g2 = performance.now();
|
|
4158
4196
|
const p2 = (m2) => {
|
|
4159
4197
|
const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
|
|
4160
4198
|
a && N2(h2, m2);
|
|
4161
|
-
},
|
|
4162
|
-
process.on("uncaughtExceptionMonitor",
|
|
4199
|
+
}, v2 = () => p2(2), f = () => p2(1), j2 = () => {
|
|
4200
|
+
process.on("uncaughtExceptionMonitor", v2), process.on("unhandledRejection", v2), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
|
|
4163
4201
|
}, E = () => {
|
|
4164
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
4202
|
+
process.removeListener("uncaughtExceptionMonitor", v2), process.removeListener("unhandledRejection", v2), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
|
|
4165
4203
|
}, B2 = () => {
|
|
4166
4204
|
if ($2 === void 0) return;
|
|
4167
4205
|
i && process.stdout.write(`
|
|
@@ -4173,13 +4211,13 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
4173
4211
|
const h2 = (performance.now() - m2) / 1e3, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
4174
4212
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
4175
4213
|
}, H = (m2 = "") => {
|
|
4176
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
4214
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
4177
4215
|
`);
|
|
4178
4216
|
let h2 = 0, w2 = 0;
|
|
4179
4217
|
j2(), c = setInterval(() => {
|
|
4180
4218
|
if (i && l2 === $2) return;
|
|
4181
4219
|
B2(), $2 = l2;
|
|
4182
|
-
const I2 =
|
|
4220
|
+
const I2 = import_picocolors2.default.magenta(n[h2]);
|
|
4183
4221
|
if (i) process.stdout.write(`${I2} ${l2}...`);
|
|
4184
4222
|
else if (t === "timer") process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
|
|
4185
4223
|
else {
|
|
@@ -4190,7 +4228,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
4190
4228
|
}, r2);
|
|
4191
4229
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
4192
4230
|
a = false, clearInterval(c), B2();
|
|
4193
|
-
const w2 = h2 === 0 ?
|
|
4231
|
+
const w2 = h2 === 0 ? import_picocolors2.default.green(C) : h2 === 1 ? import_picocolors2.default.red(L2) : import_picocolors2.default.red(W2);
|
|
4194
4232
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
4195
4233
|
`) : process.stdout.write(`${w2} ${l2}
|
|
4196
4234
|
`), E(), s();
|
|
@@ -4201,7 +4239,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
4201
4239
|
};
|
|
4202
4240
|
|
|
4203
4241
|
// src/runner.ts
|
|
4204
|
-
var
|
|
4242
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
4205
4243
|
|
|
4206
4244
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
4207
4245
|
var external_exports = {};
|
|
@@ -4883,8 +4921,8 @@ function assertNever(_x) {
|
|
|
4883
4921
|
function assert(_3) {
|
|
4884
4922
|
}
|
|
4885
4923
|
function getEnumValues(entries) {
|
|
4886
|
-
const numericValues = Object.values(entries).filter((
|
|
4887
|
-
const values = Object.entries(entries).filter(([k3, _3]) => numericValues.indexOf(+k3) === -1).map(([_3,
|
|
4924
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
4925
|
+
const values = Object.entries(entries).filter(([k3, _3]) => numericValues.indexOf(+k3) === -1).map(([_3, v2]) => v2);
|
|
4888
4926
|
return values;
|
|
4889
4927
|
}
|
|
4890
4928
|
function joinValues(array2, separator = "|") {
|
|
@@ -4938,9 +4976,9 @@ function defineLazy(object2, key, getter) {
|
|
|
4938
4976
|
}
|
|
4939
4977
|
return value;
|
|
4940
4978
|
},
|
|
4941
|
-
set(
|
|
4979
|
+
set(v2) {
|
|
4942
4980
|
Object.defineProperty(object2, key, {
|
|
4943
|
-
value:
|
|
4981
|
+
value: v2
|
|
4944
4982
|
// configurable: true,
|
|
4945
4983
|
});
|
|
4946
4984
|
},
|
|
@@ -6627,10 +6665,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
6627
6665
|
v7: 7,
|
|
6628
6666
|
v8: 8
|
|
6629
6667
|
};
|
|
6630
|
-
const
|
|
6631
|
-
if (
|
|
6668
|
+
const v2 = versionMap[def.version];
|
|
6669
|
+
if (v2 === void 0)
|
|
6632
6670
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
6633
|
-
def.pattern ?? (def.pattern = uuid(
|
|
6671
|
+
def.pattern ?? (def.pattern = uuid(v2));
|
|
6634
6672
|
} else
|
|
6635
6673
|
def.pattern ?? (def.pattern = uuid());
|
|
6636
6674
|
$ZodStringFormat.init(inst, def);
|
|
@@ -7235,8 +7273,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
7235
7273
|
const field = shape[key]._zod;
|
|
7236
7274
|
if (field.values) {
|
|
7237
7275
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
7238
|
-
for (const
|
|
7239
|
-
propValues[key].add(
|
|
7276
|
+
for (const v2 of field.values)
|
|
7277
|
+
propValues[key].add(v2);
|
|
7240
7278
|
}
|
|
7241
7279
|
}
|
|
7242
7280
|
return propValues;
|
|
@@ -7531,10 +7569,10 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
7531
7569
|
const pv = option._zod.propValues;
|
|
7532
7570
|
if (!pv || Object.keys(pv).length === 0)
|
|
7533
7571
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
7534
|
-
for (const [k3,
|
|
7572
|
+
for (const [k3, v2] of Object.entries(pv)) {
|
|
7535
7573
|
if (!propValues[k3])
|
|
7536
7574
|
propValues[k3] = /* @__PURE__ */ new Set();
|
|
7537
|
-
for (const val of
|
|
7575
|
+
for (const val of v2) {
|
|
7538
7576
|
propValues[k3].add(val);
|
|
7539
7577
|
}
|
|
7540
7578
|
}
|
|
@@ -7548,11 +7586,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
7548
7586
|
const values = o2._zod.propValues?.[def.discriminator];
|
|
7549
7587
|
if (!values || values.size === 0)
|
|
7550
7588
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o2)}"`);
|
|
7551
|
-
for (const
|
|
7552
|
-
if (map2.has(
|
|
7553
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
7589
|
+
for (const v2 of values) {
|
|
7590
|
+
if (map2.has(v2)) {
|
|
7591
|
+
throw new Error(`Duplicate discriminator value "${String(v2)}"`);
|
|
7554
7592
|
}
|
|
7555
|
-
map2.set(
|
|
7593
|
+
map2.set(v2, o2);
|
|
7556
7594
|
}
|
|
7557
7595
|
}
|
|
7558
7596
|
return map2;
|
|
@@ -8191,8 +8229,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
8191
8229
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
8192
8230
|
$ZodType.init(inst, def);
|
|
8193
8231
|
defineLazy(inst._zod, "values", () => {
|
|
8194
|
-
const
|
|
8195
|
-
return
|
|
8232
|
+
const v2 = def.innerType._zod.values;
|
|
8233
|
+
return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
|
|
8196
8234
|
});
|
|
8197
8235
|
inst._zod.parse = (payload, ctx) => {
|
|
8198
8236
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -10589,7 +10627,7 @@ var error17 = () => {
|
|
|
10589
10627
|
if (issue2.values.length === 1) {
|
|
10590
10628
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
10591
10629
|
}
|
|
10592
|
-
const stringified = issue2.values.map((
|
|
10630
|
+
const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
|
|
10593
10631
|
if (issue2.values.length === 2) {
|
|
10594
10632
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
10595
10633
|
}
|
|
@@ -15344,7 +15382,7 @@ function _set(Class2, valueType, params) {
|
|
|
15344
15382
|
}
|
|
15345
15383
|
// @__NO_SIDE_EFFECTS__
|
|
15346
15384
|
function _enum(Class2, values, params) {
|
|
15347
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
15385
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
15348
15386
|
return new Class2({
|
|
15349
15387
|
type: "enum",
|
|
15350
15388
|
entries,
|
|
@@ -15549,8 +15587,8 @@ function _stringbool(Classes, _params) {
|
|
|
15549
15587
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
15550
15588
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
15551
15589
|
if (params.case !== "sensitive") {
|
|
15552
|
-
truthyArray = truthyArray.map((
|
|
15553
|
-
falsyArray = falsyArray.map((
|
|
15590
|
+
truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
15591
|
+
falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
15554
15592
|
}
|
|
15555
15593
|
const truthySet = new Set(truthyArray);
|
|
15556
15594
|
const falsySet = new Set(falsyArray);
|
|
@@ -16092,9 +16130,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
16092
16130
|
var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
16093
16131
|
const def = schema._zod.def;
|
|
16094
16132
|
const values = getEnumValues(def.entries);
|
|
16095
|
-
if (values.every((
|
|
16133
|
+
if (values.every((v2) => typeof v2 === "number"))
|
|
16096
16134
|
json2.type = "number";
|
|
16097
|
-
if (values.every((
|
|
16135
|
+
if (values.every((v2) => typeof v2 === "string"))
|
|
16098
16136
|
json2.type = "string";
|
|
16099
16137
|
json2.enum = values;
|
|
16100
16138
|
};
|
|
@@ -16127,13 +16165,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
|
|
|
16127
16165
|
json2.const = val;
|
|
16128
16166
|
}
|
|
16129
16167
|
} else {
|
|
16130
|
-
if (vals.every((
|
|
16168
|
+
if (vals.every((v2) => typeof v2 === "number"))
|
|
16131
16169
|
json2.type = "number";
|
|
16132
|
-
if (vals.every((
|
|
16170
|
+
if (vals.every((v2) => typeof v2 === "string"))
|
|
16133
16171
|
json2.type = "string";
|
|
16134
|
-
if (vals.every((
|
|
16172
|
+
if (vals.every((v2) => typeof v2 === "boolean"))
|
|
16135
16173
|
json2.type = "boolean";
|
|
16136
|
-
if (vals.every((
|
|
16174
|
+
if (vals.every((v2) => v2 === null))
|
|
16137
16175
|
json2.type = "null";
|
|
16138
16176
|
json2.enum = vals;
|
|
16139
16177
|
}
|
|
@@ -16231,11 +16269,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
16231
16269
|
}
|
|
16232
16270
|
const allKeys = new Set(Object.keys(shape));
|
|
16233
16271
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
16234
|
-
const
|
|
16272
|
+
const v2 = def.shape[key]._zod;
|
|
16235
16273
|
if (ctx.io === "input") {
|
|
16236
|
-
return
|
|
16274
|
+
return v2.optin === void 0;
|
|
16237
16275
|
} else {
|
|
16238
|
-
return
|
|
16276
|
+
return v2.optout === void 0;
|
|
16239
16277
|
}
|
|
16240
16278
|
}));
|
|
16241
16279
|
if (requiredKeys.size > 0) {
|
|
@@ -16355,7 +16393,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
16355
16393
|
}
|
|
16356
16394
|
const keyValues = keyType._zod.values;
|
|
16357
16395
|
if (keyValues) {
|
|
16358
|
-
const validKeyValues = [...keyValues].filter((
|
|
16396
|
+
const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
|
|
16359
16397
|
if (validKeyValues.length > 0) {
|
|
16360
16398
|
json2.required = validKeyValues;
|
|
16361
16399
|
}
|
|
@@ -16920,12 +16958,12 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
16920
16958
|
});
|
|
16921
16959
|
return bound;
|
|
16922
16960
|
},
|
|
16923
|
-
set(
|
|
16961
|
+
set(v2) {
|
|
16924
16962
|
Object.defineProperty(this, key, {
|
|
16925
16963
|
configurable: true,
|
|
16926
16964
|
writable: true,
|
|
16927
16965
|
enumerable: true,
|
|
16928
|
-
value:
|
|
16966
|
+
value: v2
|
|
16929
16967
|
});
|
|
16930
16968
|
}
|
|
16931
16969
|
});
|
|
@@ -17813,7 +17851,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
17813
17851
|
};
|
|
17814
17852
|
});
|
|
17815
17853
|
function _enum2(values, params) {
|
|
17816
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
17854
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
17817
17855
|
return new ZodEnum({
|
|
17818
17856
|
type: "enum",
|
|
17819
17857
|
entries,
|
|
@@ -18367,10 +18405,10 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18367
18405
|
if (enumValues.length === 1) {
|
|
18368
18406
|
return z2.literal(enumValues[0]);
|
|
18369
18407
|
}
|
|
18370
|
-
if (enumValues.every((
|
|
18408
|
+
if (enumValues.every((v2) => typeof v2 === "string")) {
|
|
18371
18409
|
return z2.enum(enumValues);
|
|
18372
18410
|
}
|
|
18373
|
-
const literalSchemas = enumValues.map((
|
|
18411
|
+
const literalSchemas = enumValues.map((v2) => z2.literal(v2));
|
|
18374
18412
|
if (literalSchemas.length < 2) {
|
|
18375
18413
|
return literalSchemas[0];
|
|
18376
18414
|
}
|
|
@@ -19205,7 +19243,9 @@ var RulesetSchema = external_exports.object({
|
|
|
19205
19243
|
showRelationsInForm: external_exports.boolean().default(true),
|
|
19206
19244
|
enumValueLabel: external_exports.boolean().default(true),
|
|
19207
19245
|
sharedEnums: external_exports.boolean().default(true),
|
|
19208
|
-
defaultOperations: JsonOperationsSchema.default(
|
|
19246
|
+
defaultOperations: JsonOperationsSchema.default(
|
|
19247
|
+
JsonOperationsSchema.parse({})
|
|
19248
|
+
)
|
|
19209
19249
|
});
|
|
19210
19250
|
var CroutonConfigSchema = external_exports.object({
|
|
19211
19251
|
/**
|
|
@@ -19224,7 +19264,7 @@ var CroutonConfigSchema = external_exports.object({
|
|
|
19224
19264
|
*/
|
|
19225
19265
|
schemaExportName: external_exports.string().default("{Model}WithRelationsSchema"),
|
|
19226
19266
|
/** Path to the shared enum registry, relative to project root. Default `crouton.enums.json`. */
|
|
19227
|
-
enumsFile: external_exports.string().default("
|
|
19267
|
+
enumsFile: external_exports.string().default("crouton.enums.json"),
|
|
19228
19268
|
/** Optional overrides of the default visibility ruleset. */
|
|
19229
19269
|
rules: RulesetSchema.default(RulesetSchema.parse({})),
|
|
19230
19270
|
/**
|
|
@@ -19298,7 +19338,7 @@ var buildDatasourceFiles = (opts) => {
|
|
|
19298
19338
|
zodOutput,
|
|
19299
19339
|
prismaConfig
|
|
19300
19340
|
};
|
|
19301
|
-
const clientImport = relImport(dsDir, clientOutput);
|
|
19341
|
+
const clientImport = opts.generatedClientImport ?? relImport(dsDir, clientOutput);
|
|
19302
19342
|
const indexTs = `import { PrismaClient } from '${clientImport}';
|
|
19303
19343
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
19304
19344
|
|
|
@@ -19334,14 +19374,17 @@ datasource db {
|
|
|
19334
19374
|
// url is provided by ${prismaConfig} (Prisma 7 forbids \`url\` here)
|
|
19335
19375
|
}
|
|
19336
19376
|
`;
|
|
19377
|
+
const configDir = dirname4(prismaConfig);
|
|
19378
|
+
const relSchema = relImport(configDir, prismaSchema);
|
|
19379
|
+
const relMigrations = relImport(configDir, migrationsDir);
|
|
19337
19380
|
const prismaConfigTs = `// Generated by \`crouton create-datasource\`.
|
|
19338
19381
|
import 'dotenv/config';
|
|
19339
19382
|
import { defineConfig, env } from 'prisma/config';
|
|
19340
19383
|
|
|
19341
19384
|
export default defineConfig({
|
|
19342
|
-
schema: '${
|
|
19385
|
+
schema: '${relSchema}',
|
|
19343
19386
|
migrations: {
|
|
19344
|
-
path: '${
|
|
19387
|
+
path: '${relMigrations}',
|
|
19345
19388
|
},
|
|
19346
19389
|
datasource: {
|
|
19347
19390
|
url: env('${opts.urlEnv}'),
|
|
@@ -19395,7 +19438,24 @@ var writeFiles = async (files, opts = {}) => {
|
|
|
19395
19438
|
var loadTemplate = async (templateDir, relativePath) => readFile4(`${templateDir}/${relativePath}`, "utf-8");
|
|
19396
19439
|
|
|
19397
19440
|
// src/lib/pm.ts
|
|
19398
|
-
import { spawn } from "child_process";
|
|
19441
|
+
import { execSync, spawn } from "child_process";
|
|
19442
|
+
var MIN_PNPM_MAJOR = 11;
|
|
19443
|
+
var checkPnpmVersion = () => {
|
|
19444
|
+
let raw;
|
|
19445
|
+
try {
|
|
19446
|
+
raw = execSync("pnpm --version", { stdio: "pipe" }).toString().trim();
|
|
19447
|
+
} catch {
|
|
19448
|
+
throw new Error("pnpm is not installed. Install it with: npm i -g pnpm@latest");
|
|
19449
|
+
}
|
|
19450
|
+
const major = parseInt(raw.split(".")[0], 10);
|
|
19451
|
+
if (isNaN(major) || major < MIN_PNPM_MAJOR) {
|
|
19452
|
+
throw new Error(
|
|
19453
|
+
`pnpm ${raw} detected, but version ${MIN_PNPM_MAJOR}+ is required.
|
|
19454
|
+
Upgrade with: npm i -g pnpm@latest`
|
|
19455
|
+
);
|
|
19456
|
+
}
|
|
19457
|
+
return raw;
|
|
19458
|
+
};
|
|
19399
19459
|
var installDeps = (pm, cwd) => new Promise((resolve3, reject) => {
|
|
19400
19460
|
const child = spawn(pm, ["install"], { cwd, stdio: "inherit" });
|
|
19401
19461
|
child.on(
|
|
@@ -19431,7 +19491,7 @@ var render = (template, tokens) => {
|
|
|
19431
19491
|
};
|
|
19432
19492
|
|
|
19433
19493
|
// src/runner.ts
|
|
19434
|
-
import { execSync } from "child_process";
|
|
19494
|
+
import { execSync as execSync2 } from "child_process";
|
|
19435
19495
|
import { existsSync } from "fs";
|
|
19436
19496
|
import { readdir as readdir4 } from "fs/promises";
|
|
19437
19497
|
import { resolve as resolve2 } from "path";
|
|
@@ -19445,7 +19505,7 @@ var resolveTemplateDir = () => {
|
|
|
19445
19505
|
var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
19446
19506
|
var toTitle = (name) => name.replace(/[-_]+/g, " ").split(" ").map(capitalize).join(" ");
|
|
19447
19507
|
var runCreate = async (name, opts) => {
|
|
19448
|
-
Ie(
|
|
19508
|
+
Ie(import_picocolors3.default.bold(`create-crouton ${import_picocolors3.default.cyan(name)}`));
|
|
19449
19509
|
try {
|
|
19450
19510
|
const targetDir = resolve2(process.cwd(), name);
|
|
19451
19511
|
if (existsSync(targetDir) && !opts.force) {
|
|
@@ -19457,94 +19517,123 @@ var runCreate = async (name, opts) => {
|
|
|
19457
19517
|
}
|
|
19458
19518
|
const layout = await resolveLayout(opts);
|
|
19459
19519
|
const frontend = await resolveFrontend(opts, layout);
|
|
19520
|
+
const prefix = layout === "nx" ? await resolvePrefix(opts) : void 0;
|
|
19460
19521
|
const pm = await resolvePm(opts);
|
|
19522
|
+
if (pm === "pnpm") {
|
|
19523
|
+
const pnpmVersion = checkPnpmVersion();
|
|
19524
|
+
M2.info(`Using pnpm ${pnpmVersion}`);
|
|
19525
|
+
}
|
|
19526
|
+
const dbUrl = await resolveDbUrl(opts);
|
|
19527
|
+
const dbName = name.replace(/[^a-zA-Z0-9]/g, "_");
|
|
19461
19528
|
const tokens = {
|
|
19462
19529
|
name,
|
|
19463
19530
|
Name: toTitle(name),
|
|
19464
19531
|
year: String((/* @__PURE__ */ new Date()).getFullYear()),
|
|
19465
19532
|
pmRun: pm === "npm" ? "npm run" : pm,
|
|
19466
19533
|
urlEnv: "DATABASE_URL",
|
|
19467
|
-
|
|
19534
|
+
dbUrl: dbUrl || `postgresql://crouton:crouton@localhost:5432/${dbName}?schema=public`,
|
|
19535
|
+
dbName
|
|
19468
19536
|
};
|
|
19469
19537
|
if (layout === "nx") {
|
|
19470
19538
|
tokens["nx"] = "true";
|
|
19471
19539
|
tokens["backendApp"] = "backend";
|
|
19472
19540
|
tokens["frontendApp"] = "frontend";
|
|
19541
|
+
if (prefix) {
|
|
19542
|
+
tokens["prefix"] = prefix;
|
|
19543
|
+
tokens["appsRoot"] = `${prefix}/apps`;
|
|
19544
|
+
tokens["schemaPath"] = "../../../node_modules/nx/schemas/project-schema.json";
|
|
19545
|
+
tokens["tsconfigBase"] = "../../../tsconfig.base.json";
|
|
19546
|
+
tokens["generatedTypesPath"] = `${prefix}/generated/default/types/src`;
|
|
19547
|
+
tokens["generatedClientPath"] = `${prefix}/generated/default/client/src`;
|
|
19548
|
+
} else {
|
|
19549
|
+
tokens["noPrefix"] = "true";
|
|
19550
|
+
tokens["appsRoot"] = "apps";
|
|
19551
|
+
tokens["schemaPath"] = "../../node_modules/nx/schemas/project-schema.json";
|
|
19552
|
+
tokens["tsconfigBase"] = "../../tsconfig.base.json";
|
|
19553
|
+
tokens["generatedTypesPath"] = "generated/default/types/src";
|
|
19554
|
+
tokens["generatedClientPath"] = "generated/default/client/src";
|
|
19555
|
+
}
|
|
19473
19556
|
}
|
|
19474
19557
|
if (frontend) {
|
|
19475
19558
|
tokens["frontend"] = "true";
|
|
19476
19559
|
}
|
|
19477
19560
|
const templateRoot = resolveTemplateDir();
|
|
19478
|
-
const templateDir = layout === "nx" ? resolve2(templateRoot, "nx") : resolve2(templateRoot, "regular");
|
|
19479
19561
|
const skipPaths = !frontend ? ["apps/frontend"] : [];
|
|
19480
|
-
|
|
19481
|
-
|
|
19482
|
-
const
|
|
19483
|
-
|
|
19484
|
-
const
|
|
19485
|
-
const
|
|
19486
|
-
|
|
19487
|
-
|
|
19488
|
-
|
|
19489
|
-
|
|
19490
|
-
|
|
19491
|
-
|
|
19492
|
-
|
|
19493
|
-
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
|
|
19497
|
-
|
|
19498
|
-
|
|
19499
|
-
|
|
19500
|
-
|
|
19501
|
-
|
|
19502
|
-
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19509
|
-
stdio: "pipe"
|
|
19510
|
-
});
|
|
19511
|
-
s.stop("Git repository initialized");
|
|
19512
|
-
} catch {
|
|
19513
|
-
s.stop("Git init failed (non-fatal)");
|
|
19514
|
-
}
|
|
19515
|
-
}
|
|
19516
|
-
if (opts.install !== false) {
|
|
19517
|
-
const s = Y2();
|
|
19518
|
-
s.start(`Installing dependencies with ${pm}`);
|
|
19519
|
-
try {
|
|
19520
|
-
await installDeps(pm, targetDir);
|
|
19521
|
-
s.stop("Dependencies installed");
|
|
19522
|
-
} catch {
|
|
19523
|
-
s.stop("Install failed \u2014 run manually");
|
|
19562
|
+
if (layout === "nx") {
|
|
19563
|
+
const rootTemplateDir = resolve2(templateRoot, "nx", "root");
|
|
19564
|
+
const rootFiles = await loadAndRenderTemplates(rootTemplateDir, "", tokens, targetDir);
|
|
19565
|
+
const files = [...rootFiles];
|
|
19566
|
+
const workspaceTemplateDir = resolve2(templateRoot, "nx", "workspace");
|
|
19567
|
+
const workspaceTarget = prefix ? resolve2(targetDir, prefix) : targetDir;
|
|
19568
|
+
const workspaceFiles = await loadAndRenderTemplates(workspaceTemplateDir, "", tokens, workspaceTarget, skipPaths);
|
|
19569
|
+
files.push(...workspaceFiles);
|
|
19570
|
+
if (opts.docker !== false) {
|
|
19571
|
+
const dockerDir = resolve2(templateRoot, "docker");
|
|
19572
|
+
const dockerFiles = await loadAndRenderTemplates(dockerDir, "", tokens, targetDir);
|
|
19573
|
+
files.push(...dockerFiles);
|
|
19574
|
+
}
|
|
19575
|
+
const dataSourcesDir = "apps/backend/src/app/data-sources";
|
|
19576
|
+
const generatedImport = `@${name}/generated/default/types`;
|
|
19577
|
+
const generatedClientImport = `@${name}/generated/default/client`;
|
|
19578
|
+
const { files: dsFiles } = buildDatasourceFiles({
|
|
19579
|
+
name: "default",
|
|
19580
|
+
dataSourcesDir,
|
|
19581
|
+
urlEnv: "DATABASE_URL",
|
|
19582
|
+
generatedTypesImport: generatedImport,
|
|
19583
|
+
generatedClientImport,
|
|
19584
|
+
type: "postgres",
|
|
19585
|
+
default: true,
|
|
19586
|
+
zodOutput: "generated/default/types/src",
|
|
19587
|
+
clientOutput: "generated/default/client/src"
|
|
19588
|
+
});
|
|
19589
|
+
for (const f of dsFiles) {
|
|
19590
|
+
files.push({ path: resolve2(workspaceTarget, f.path), contents: f.contents });
|
|
19524
19591
|
}
|
|
19525
|
-
|
|
19526
|
-
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19592
|
+
const written = await writeFiles(files, { force: opts.force });
|
|
19593
|
+
M2.success(`Wrote ${written} file(s) to ${import_picocolors3.default.cyan(name)}/`);
|
|
19594
|
+
await postScaffold(opts, targetDir, pm, dbUrl, prefix);
|
|
19595
|
+
} else {
|
|
19596
|
+
const templateDir = resolve2(templateRoot, "regular");
|
|
19597
|
+
const files = await loadAndRenderTemplates(templateDir, "", tokens, targetDir, skipPaths);
|
|
19598
|
+
if (opts.docker !== false) {
|
|
19599
|
+
const dockerTokens = { ...tokens, regular: "true" };
|
|
19600
|
+
const dockerDir = resolve2(templateRoot, "docker");
|
|
19601
|
+
const dockerFiles = await loadAndRenderTemplates(dockerDir, "", dockerTokens, targetDir);
|
|
19602
|
+
files.push(...dockerFiles);
|
|
19603
|
+
}
|
|
19604
|
+
const dataSourcesDir = "src/data-sources";
|
|
19605
|
+
const generatedImport = "@app/generated/default/types";
|
|
19606
|
+
const generatedClientImport = "@app/generated/default/client";
|
|
19607
|
+
const { files: dsFiles } = buildDatasourceFiles({
|
|
19608
|
+
name: "default",
|
|
19609
|
+
dataSourcesDir,
|
|
19610
|
+
urlEnv: "DATABASE_URL",
|
|
19611
|
+
generatedTypesImport: generatedImport,
|
|
19612
|
+
generatedClientImport,
|
|
19613
|
+
type: "postgres",
|
|
19614
|
+
default: true,
|
|
19615
|
+
zodOutput: "generated/default/types/src",
|
|
19616
|
+
clientOutput: "generated/default/client/src"
|
|
19617
|
+
});
|
|
19618
|
+
for (const f of dsFiles) {
|
|
19619
|
+
files.push({ path: resolve2(targetDir, f.path), contents: f.contents });
|
|
19535
19620
|
}
|
|
19621
|
+
const written = await writeFiles(files, { force: opts.force });
|
|
19622
|
+
M2.success(`Wrote ${written} file(s) to ${import_picocolors3.default.cyan(name)}/`);
|
|
19623
|
+
await postScaffold(opts, targetDir, pm, dbUrl);
|
|
19536
19624
|
}
|
|
19537
19625
|
const pmRun = pm === "npm" ? "npm run" : pm;
|
|
19626
|
+
const prefixFlag = prefix ? ` --prefix ${prefix}` : "";
|
|
19538
19627
|
Me(
|
|
19539
19628
|
[
|
|
19540
19629
|
opts.docker !== false ? "docker compose up -d # start postgres" : null,
|
|
19541
19630
|
`${pmRun} prisma:migrate # create initial migration`,
|
|
19542
|
-
|
|
19631
|
+
`crouton update resources${prefixFlag} # generate resource CRUD`,
|
|
19543
19632
|
`${pmRun} dev # start dev server`
|
|
19544
19633
|
].filter(Boolean).join("\n"),
|
|
19545
19634
|
"Next steps"
|
|
19546
19635
|
);
|
|
19547
|
-
Se(
|
|
19636
|
+
Se(import_picocolors3.default.green("Project scaffolded."));
|
|
19548
19637
|
} catch (err) {
|
|
19549
19638
|
if (err instanceof CancelledError) {
|
|
19550
19639
|
xe("Cancelled.");
|
|
@@ -19553,7 +19642,52 @@ var runCreate = async (name, opts) => {
|
|
|
19553
19642
|
throw err;
|
|
19554
19643
|
}
|
|
19555
19644
|
};
|
|
19645
|
+
var postScaffold = async (opts, targetDir, pm, dbUrl, prefix) => {
|
|
19646
|
+
if (opts.git !== false) {
|
|
19647
|
+
const s = Y2();
|
|
19648
|
+
s.start("Initializing git repository");
|
|
19649
|
+
try {
|
|
19650
|
+
execSync2('git init && git add -A && git commit -m "Initial commit"', {
|
|
19651
|
+
cwd: targetDir,
|
|
19652
|
+
stdio: "pipe"
|
|
19653
|
+
});
|
|
19654
|
+
s.stop("Git repository initialized");
|
|
19655
|
+
} catch {
|
|
19656
|
+
s.stop("Git init failed (non-fatal)");
|
|
19657
|
+
}
|
|
19658
|
+
}
|
|
19659
|
+
if (opts.install !== false) {
|
|
19660
|
+
const s = Y2();
|
|
19661
|
+
s.start(`Installing dependencies with ${pm}`);
|
|
19662
|
+
try {
|
|
19663
|
+
await installDeps(pm, targetDir);
|
|
19664
|
+
s.stop("Dependencies installed");
|
|
19665
|
+
} catch {
|
|
19666
|
+
s.stop("Install failed \u2014 run manually");
|
|
19667
|
+
}
|
|
19668
|
+
if (dbUrl) {
|
|
19669
|
+
try {
|
|
19670
|
+
const s2 = Y2();
|
|
19671
|
+
s2.start("Running crouton update resources");
|
|
19672
|
+
const croutonCwd = prefix ? resolve2(targetDir, prefix) : targetDir;
|
|
19673
|
+
execSync2("npx crouton update resources --yes", {
|
|
19674
|
+
cwd: croutonCwd,
|
|
19675
|
+
stdio: "pipe",
|
|
19676
|
+
env: { ...process.env, DATABASE_URL: dbUrl }
|
|
19677
|
+
});
|
|
19678
|
+
s2.stop("Resources updated");
|
|
19679
|
+
} catch (err) {
|
|
19680
|
+
const stderr = err instanceof Error && "stderr" in err ? String(err.stderr).trim() : "";
|
|
19681
|
+
M2.warn(
|
|
19682
|
+
"crouton update resources failed \u2014 run it manually after setting up your database." + (stderr ? `
|
|
19683
|
+
${import_picocolors3.default.dim(stderr)}` : "")
|
|
19684
|
+
);
|
|
19685
|
+
}
|
|
19686
|
+
}
|
|
19687
|
+
}
|
|
19688
|
+
};
|
|
19556
19689
|
var resolveLayout = async (opts) => {
|
|
19690
|
+
if (opts.prefix) return "nx";
|
|
19557
19691
|
if (opts.yes) return opts.nx ? "nx" : "regular";
|
|
19558
19692
|
if (opts.nx) return "nx";
|
|
19559
19693
|
const layout = assertNotCancel(
|
|
@@ -19578,6 +19712,18 @@ var resolveFrontend = async (opts, layout) => {
|
|
|
19578
19712
|
})
|
|
19579
19713
|
);
|
|
19580
19714
|
};
|
|
19715
|
+
var resolvePrefix = async (opts) => {
|
|
19716
|
+
if (opts.prefix) return opts.prefix;
|
|
19717
|
+
if (opts.yes) return void 0;
|
|
19718
|
+
const prefix = assertNotCancel(
|
|
19719
|
+
await he({
|
|
19720
|
+
message: "Subfolder prefix for apps/config (leave empty for flat layout)",
|
|
19721
|
+
placeholder: "e.g. split",
|
|
19722
|
+
defaultValue: ""
|
|
19723
|
+
})
|
|
19724
|
+
);
|
|
19725
|
+
return prefix.trim() || void 0;
|
|
19726
|
+
};
|
|
19581
19727
|
var resolvePm = async (opts) => {
|
|
19582
19728
|
if (opts.pm) return opts.pm;
|
|
19583
19729
|
if (opts.yes) return "pnpm";
|
|
@@ -19593,6 +19739,18 @@ var resolvePm = async (opts) => {
|
|
|
19593
19739
|
})
|
|
19594
19740
|
);
|
|
19595
19741
|
};
|
|
19742
|
+
var resolveDbUrl = async (opts) => {
|
|
19743
|
+
if (opts.dbUrl) return opts.dbUrl;
|
|
19744
|
+
if (opts.yes) return "";
|
|
19745
|
+
const url2 = assertNotCancel(
|
|
19746
|
+
await he({
|
|
19747
|
+
message: "Database URL (leave empty to skip prisma setup)",
|
|
19748
|
+
placeholder: "postgresql://user:pass@localhost:5432/mydb?schema=public",
|
|
19749
|
+
defaultValue: ""
|
|
19750
|
+
})
|
|
19751
|
+
);
|
|
19752
|
+
return url2.trim();
|
|
19753
|
+
};
|
|
19596
19754
|
var loadAndRenderTemplates = async (templateDir, subPath, tokens, targetDir, skipPaths = []) => {
|
|
19597
19755
|
const files = [];
|
|
19598
19756
|
const dir = subPath ? resolve2(templateDir, subPath) : templateDir;
|
|
@@ -19615,7 +19773,7 @@ var loadAndRenderTemplates = async (templateDir, subPath, tokens, targetDir, ski
|
|
|
19615
19773
|
};
|
|
19616
19774
|
|
|
19617
19775
|
// src/index.ts
|
|
19618
|
-
var program2 = new Command("create-crouton").description("Scaffold a new crouton project").version("0.0.1").argument("[name]", "project name", "my-crouton-app").option("--nx", "use Nx monorepo layout").option("--no-nx", "use regular (non-Nx) layout").option("--no-frontend", "skip frontend app generation").option("--sample", "include sample resource").option("--pm <manager>", "package manager (pnpm | npm | yarn | bun)").option("--no-install", "skip dependency installation").option("--no-git", "skip git init").option("--no-docker", "skip Docker file generation").option("-y, --yes", "accept all defaults (non-interactive)").option("--force", "overwrite existing files").action(async (name, opts) => {
|
|
19776
|
+
var program2 = new Command("create-crouton").description("Scaffold a new crouton project").version("0.0.1").argument("[name]", "project name", "my-crouton-app").option("--nx", "use Nx monorepo layout").option("--no-nx", "use regular (non-Nx) layout").option("--no-frontend", "skip frontend app generation").option("--sample", "include sample resource").option("--pm <manager>", "package manager (pnpm | npm | yarn | bun)").option("--no-install", "skip dependency installation").option("--no-git", "skip git init").option("--prefix <name>", "nest apps/config under a subfolder (Nx only)").option("--no-docker", "skip Docker file generation").option("-y, --yes", "accept all defaults (non-interactive)").option("--force", "overwrite existing files").option("--db-url <url>", "database connection URL (e.g. postgresql://user:pass@localhost:5432/db)").action(async (name, opts) => {
|
|
19619
19777
|
try {
|
|
19620
19778
|
await runCreate(name, opts);
|
|
19621
19779
|
} catch (err) {
|