create-creact 0.0.0-stage → 0.1.0
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/LICENSE +12 -0
- package/README.md +17 -2
- package/dist/create.js +257 -0
- package/dist/layer.js +633 -0
- package/dist/main.js +61 -0
- package/dist/options.js +262 -0
- package/dist/shell.js +117 -0
- package/dist/stacks.js +42 -0
- package/dist/ui.js +506 -0
- package/dist/version.js +7 -0
- package/layer/base/all/.oxfmtrc.json.layer +65 -0
- package/layer/base/all/AGENTS.md.layer +22 -0
- package/layer/base/all/CLAUDE.md.layer +1 -0
- package/layer/base/all/apps/web/src/styles/tokens.css.layer +15 -0
- package/layer/base/all/commitlint.config.ts.layer +12 -0
- package/layer/base/all/oxlint.config.ts.layer +556 -0
- package/layer/base/next/AGENTS.md.layer +4 -0
- package/layer/base/next/apps/web/CLAUDE.md.layer +1 -0
- package/layer/base/react-router/AGENTS.md.layer +3 -0
- package/layer/standalone/all/.husky/commit-msg.layer +2 -0
- package/layer/standalone/all/.husky/pre-commit.layer +2 -0
- package/layer/standalone/all/.lintstagedrc.json.layer +4 -0
- package/layer/standalone/all/AGENTS.md.layer +9 -0
- package/layer/standalone/all/vitest.config.ts.layer +14 -0
- package/layer/stylex/all/AGENTS.md.layer +4 -0
- package/layer/stylex/all/apps/web/src/styles/tokens.stylex.ts.layer +15 -0
- package/layer/stylex/all/apps/web/src/styles/tokens.test.ts.layer +32 -0
- package/layer/stylex/all/oxlint.styling.ts.layer +20 -0
- package/layer/stylex/all/vitest.styling.ts.layer +18 -0
- package/layer/stylex/next/apps/web/babel.config.js.layer +25 -0
- package/layer/stylex/next/apps/web/postcss.config.js.layer +16 -0
- package/layer/stylex/next/apps/web/src/app/layout.tsx.layer +20 -0
- package/layer/stylex/next/apps/web/src/app/page.tsx.layer +48 -0
- package/layer/stylex/next/apps/web/src/index.css.layer +45 -0
- package/layer/stylex/react-router/apps/web/src/index.css.layer +27 -0
- package/layer/stylex/react-router/apps/web/src/root.tsx.layer +94 -0
- package/layer/stylex/react-router/apps/web/src/routes/_index.tsx.layer +56 -0
- package/layer/stylex/react-router/apps/web/vite.config.ts.layer +22 -0
- package/layer/tailwind/all/AGENTS.md.layer +4 -0
- package/layer/tailwind/all/apps/web/src/index.css.layer +3 -0
- package/layer/tailwind/all/apps/web/src/styles/tokens.tailwind.css.layer +7 -0
- package/layer/tailwind/all/apps/web/src/styles/tokens.test.ts.layer +35 -0
- package/layer/tailwind/all/oxlint.styling.ts.layer +69 -0
- package/layer/tailwind/all/vitest.styling.ts.layer +5 -0
- package/layer/vite-plus/all/.vite-hooks/commit-msg.layer +2 -0
- package/layer/vite-plus/all/.vite-hooks/pre-commit.layer +2 -0
- package/layer/vite-plus/all/AGENTS.md.layer +11 -0
- package/layer/vite-plus/all/vite.config.ts.layer +25 -0
- package/package.json +37 -4
package/dist/ui.js
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { styleText } from "node:util";
|
|
3
|
+
import { RESTORE, STEPS, } from "./create.js";
|
|
4
|
+
import { STYLINGS } from "./options.js";
|
|
5
|
+
import { CommandFailed } from "./shell.js";
|
|
6
|
+
import { BTS, MONOREPOS, STACKS } from "./stacks.js";
|
|
7
|
+
import { VERSION } from "./version.js";
|
|
8
|
+
const LABEL_WIDTH = 9;
|
|
9
|
+
const PLAIN_LABEL_WIDTH = 10;
|
|
10
|
+
const DETAIL_WIDTH = 30;
|
|
11
|
+
const RUNNING = {
|
|
12
|
+
monorepo: "running Better-T-Stack",
|
|
13
|
+
tooling: "adding creact's setup",
|
|
14
|
+
git: "git init",
|
|
15
|
+
install: "pnpm install, lint, format",
|
|
16
|
+
skills: "restoring agent skills",
|
|
17
|
+
};
|
|
18
|
+
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
19
|
+
const RETRY = "Fix it and run the same command again.";
|
|
20
|
+
function color(format, text, stream = process.stdout) {
|
|
21
|
+
return styleText(format, text, { stream });
|
|
22
|
+
}
|
|
23
|
+
function errColor(format, text) {
|
|
24
|
+
return color(format, text, process.stderr);
|
|
25
|
+
}
|
|
26
|
+
function out(text) {
|
|
27
|
+
process.stdout.write(text);
|
|
28
|
+
}
|
|
29
|
+
function outLine(text) {
|
|
30
|
+
process.stdout.write(`${text}\n`);
|
|
31
|
+
}
|
|
32
|
+
function writeJson(value) {
|
|
33
|
+
outLine(JSON.stringify(value, null, 2));
|
|
34
|
+
}
|
|
35
|
+
function clear() {
|
|
36
|
+
out("\r\u001B[2K");
|
|
37
|
+
}
|
|
38
|
+
function showCursor() {
|
|
39
|
+
out("\u001B[?25h");
|
|
40
|
+
}
|
|
41
|
+
function heard() {
|
|
42
|
+
// JSON says nothing until the run ends.
|
|
43
|
+
}
|
|
44
|
+
export function pickMode(json, stream, env) {
|
|
45
|
+
if (json)
|
|
46
|
+
return "json";
|
|
47
|
+
const ci = env.CI !== undefined && env.CI !== "" && env.CI !== "false";
|
|
48
|
+
return stream.isTTY === true && !ci && env.TERM !== "dumb" ? "rich" : "plain";
|
|
49
|
+
}
|
|
50
|
+
export function renderer(mode, log, cwd) {
|
|
51
|
+
switch (mode) {
|
|
52
|
+
case "rich": {
|
|
53
|
+
return rich(log, cwd);
|
|
54
|
+
}
|
|
55
|
+
case "plain": {
|
|
56
|
+
return plain(log);
|
|
57
|
+
}
|
|
58
|
+
case "json": {
|
|
59
|
+
return json(log);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function seconds(ms) {
|
|
64
|
+
if (ms < 9950)
|
|
65
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
66
|
+
if (ms < 60_000)
|
|
67
|
+
return `${Math.round(ms / 1000)}s`;
|
|
68
|
+
const whole = Math.round(ms / 1000);
|
|
69
|
+
return `${Math.floor(whole / 60)}m ${String(whole % 60).padStart(2, "0")}s`;
|
|
70
|
+
}
|
|
71
|
+
function shellQuoted(value) {
|
|
72
|
+
const closed = value.replaceAll("'", String.raw `'\''`);
|
|
73
|
+
return `'${closed}'`;
|
|
74
|
+
}
|
|
75
|
+
function quotedIfNeeded(value) {
|
|
76
|
+
return /^[\w@%+=:,./-]+$/.test(value) ? value : shellQuoted(value);
|
|
77
|
+
}
|
|
78
|
+
// The path as the caller would type it: relative when it sits under cwd.
|
|
79
|
+
export function shown(dir, cwd) {
|
|
80
|
+
const relative = path.relative(cwd, dir);
|
|
81
|
+
return relative === "" ||
|
|
82
|
+
relative.startsWith("..") ||
|
|
83
|
+
path.isAbsolute(relative)
|
|
84
|
+
? dir
|
|
85
|
+
: relative;
|
|
86
|
+
}
|
|
87
|
+
export function stackLine(choices) {
|
|
88
|
+
return [
|
|
89
|
+
STACKS[choices.stack].label,
|
|
90
|
+
STYLINGS[choices.styling].summary,
|
|
91
|
+
MONOREPOS[choices.monorepo].summary,
|
|
92
|
+
...(choices.toolchain === "vite-plus" ? ["Vite+"] : []),
|
|
93
|
+
].join(" · ");
|
|
94
|
+
}
|
|
95
|
+
function packagesToAdd(report) {
|
|
96
|
+
return (report.layer?.missing ?? []).flatMap((addition) => [
|
|
97
|
+
...addition.dependencies,
|
|
98
|
+
...addition.devDependencies,
|
|
99
|
+
]).length;
|
|
100
|
+
}
|
|
101
|
+
function plural(count, word) {
|
|
102
|
+
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
103
|
+
}
|
|
104
|
+
function finishCommand(dir) {
|
|
105
|
+
return `cd ${shellQuoted(dir)} && ${RESTORE.join(" ")}`;
|
|
106
|
+
}
|
|
107
|
+
// What each finished step says to a person.
|
|
108
|
+
function richLine(step, report) {
|
|
109
|
+
switch (step) {
|
|
110
|
+
case "monorepo": {
|
|
111
|
+
return report.base === "created"
|
|
112
|
+
? { mark: "done", detail: "from Better-T-Stack" }
|
|
113
|
+
: { mark: "same", detail: "kept from the first run" };
|
|
114
|
+
}
|
|
115
|
+
case "tooling": {
|
|
116
|
+
const files = report.layer?.files ?? {};
|
|
117
|
+
const outcomes = Object.values(files);
|
|
118
|
+
const written = outcomes.filter((outcome) => outcome === "written");
|
|
119
|
+
const kept = Object.entries(files)
|
|
120
|
+
.filter(([, outcome]) => outcome === "kept")
|
|
121
|
+
.map(([file]) => `kept ${file}, which you edited`);
|
|
122
|
+
if (report.base === "created") {
|
|
123
|
+
return { mark: "done", detail: "lint, format, hooks and tests" };
|
|
124
|
+
}
|
|
125
|
+
return written.length > 0
|
|
126
|
+
? {
|
|
127
|
+
mark: "done",
|
|
128
|
+
detail: `${plural(written.length, "file")} updated`,
|
|
129
|
+
more: kept,
|
|
130
|
+
}
|
|
131
|
+
: { mark: "same", detail: "up to date", more: kept };
|
|
132
|
+
}
|
|
133
|
+
case "git": {
|
|
134
|
+
switch (report.git) {
|
|
135
|
+
case "initialised": {
|
|
136
|
+
return { mark: "done", detail: "new repository" };
|
|
137
|
+
}
|
|
138
|
+
case "existing": {
|
|
139
|
+
return { mark: "same", detail: "already a repository" };
|
|
140
|
+
}
|
|
141
|
+
default: {
|
|
142
|
+
return { mark: "same", detail: "skipped" };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
case "install": {
|
|
147
|
+
const count = packagesToAdd(report);
|
|
148
|
+
if (report.install === "skipped") {
|
|
149
|
+
return count === 0
|
|
150
|
+
? { mark: "same", detail: "skipped" }
|
|
151
|
+
: {
|
|
152
|
+
mark: "same",
|
|
153
|
+
detail: `skipped, ${plural(count, "package")} to add`,
|
|
154
|
+
more: ["run again without --no-install to finish"],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
mark: "done",
|
|
159
|
+
detail: count === 0
|
|
160
|
+
? "linted and formatted"
|
|
161
|
+
: `${plural(count, "package")}, linted, formatted`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
case "skills": {
|
|
165
|
+
const { skills, skillCount = 0 } = report;
|
|
166
|
+
if (typeof skills === "object") {
|
|
167
|
+
return {
|
|
168
|
+
mark: "warn",
|
|
169
|
+
detail: "not restored",
|
|
170
|
+
more: [
|
|
171
|
+
`${skills.failed}.`,
|
|
172
|
+
`Finish with: ${finishCommand(report.dir ?? "")}`,
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
switch (skills) {
|
|
177
|
+
case "restored": {
|
|
178
|
+
return {
|
|
179
|
+
mark: "done",
|
|
180
|
+
detail: `${plural(skillCount, "skill")} for coding agents`,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
case "present": {
|
|
184
|
+
return { mark: "same", detail: "already there" };
|
|
185
|
+
}
|
|
186
|
+
default: {
|
|
187
|
+
return { mark: "same", detail: "skipped" };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// What each finished step says to a script or an agent. These words are
|
|
194
|
+
// stable, so a caller can match on them.
|
|
195
|
+
function plainLine(step, report) {
|
|
196
|
+
switch (step) {
|
|
197
|
+
case "monorepo": {
|
|
198
|
+
return report.base === "created"
|
|
199
|
+
? { mark: "done", detail: `created with ${BTS}` }
|
|
200
|
+
: { mark: "same", detail: "kept" };
|
|
201
|
+
}
|
|
202
|
+
case "tooling": {
|
|
203
|
+
const entries = Object.entries(report.layer?.files ?? {});
|
|
204
|
+
const named = (outcome) => entries.filter(([, value]) => value === outcome).map(([file]) => file);
|
|
205
|
+
const kept = named("kept");
|
|
206
|
+
return {
|
|
207
|
+
mark: "done",
|
|
208
|
+
detail: `${named("written").length} written, ${named("unchanged").length} unchanged, ${kept.length} kept`,
|
|
209
|
+
more: kept.map((file) => `kept ${file}, which the project changed`),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
case "git": {
|
|
213
|
+
return {
|
|
214
|
+
mark: report.git === "initialised" ? "done" : "same",
|
|
215
|
+
detail: report.git ?? "skipped",
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
case "install": {
|
|
219
|
+
const count = packagesToAdd(report);
|
|
220
|
+
return report.install === "done"
|
|
221
|
+
? {
|
|
222
|
+
mark: "done",
|
|
223
|
+
detail: `done, ${plural(count, "package")} added, then lint --fix and format`,
|
|
224
|
+
}
|
|
225
|
+
: {
|
|
226
|
+
mark: "same",
|
|
227
|
+
detail: `skipped, ${plural(count, "package")} to add. Run again without --no-install to finish.`,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
case "skills": {
|
|
231
|
+
const { skills } = report;
|
|
232
|
+
if (typeof skills === "object") {
|
|
233
|
+
return {
|
|
234
|
+
mark: "warn",
|
|
235
|
+
detail: `not restored, as ${skills.failed}`,
|
|
236
|
+
more: [`finish with ${finishCommand(report.dir ?? "")}`],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const words = {
|
|
240
|
+
restored: "restored into .agents/skills",
|
|
241
|
+
present: "present in .agents/skills",
|
|
242
|
+
skipped: "skipped",
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
mark: skills === "restored" ? "done" : "same",
|
|
246
|
+
detail: words[skills ?? "skipped"],
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const PLAIN_MARK = {
|
|
252
|
+
done: "done",
|
|
253
|
+
same: "skip",
|
|
254
|
+
warn: "warn",
|
|
255
|
+
};
|
|
256
|
+
function plain(log) {
|
|
257
|
+
let current;
|
|
258
|
+
return {
|
|
259
|
+
begin(dir, choices) {
|
|
260
|
+
const ids = [
|
|
261
|
+
choices.stack,
|
|
262
|
+
choices.styling,
|
|
263
|
+
choices.monorepo,
|
|
264
|
+
choices.toolchain,
|
|
265
|
+
...choices.extras,
|
|
266
|
+
];
|
|
267
|
+
outLine(`create-creact ${VERSION}: ${dir} (${ids.join(", ")})`);
|
|
268
|
+
},
|
|
269
|
+
start(step) {
|
|
270
|
+
current = step;
|
|
271
|
+
},
|
|
272
|
+
finish(step, partial) {
|
|
273
|
+
current = undefined;
|
|
274
|
+
const line = plainLine(step, partial);
|
|
275
|
+
const ms = partial.ms?.[step] ?? 0;
|
|
276
|
+
const time = ms >= 500 ? ` ${seconds(ms)}` : "";
|
|
277
|
+
outLine(`${PLAIN_MARK[line.mark]} ${step.padEnd(PLAIN_LABEL_WIDTH)}${line.detail}${time}`);
|
|
278
|
+
for (const more of line.more ?? []) {
|
|
279
|
+
outLine(`${" ".repeat(PLAIN_LABEL_WIDTH + 5)}${more}`);
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
succeeded(final) {
|
|
283
|
+
if (typeof final.skills === "object")
|
|
284
|
+
outLine(`log: ${log.file}`);
|
|
285
|
+
outLine(`next: cd ${shellQuoted(final.dir)} && pnpm dev`);
|
|
286
|
+
},
|
|
287
|
+
failed(error, kind) {
|
|
288
|
+
if (current !== undefined) {
|
|
289
|
+
outLine(`fail ${current.padEnd(PLAIN_LABEL_WIDTH)}${error.message}`);
|
|
290
|
+
}
|
|
291
|
+
process.stderr.write(errorBlock(error, kind, log, (text) => text));
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function errorBlock(error, kind, log, dim) {
|
|
296
|
+
if (kind === "usage")
|
|
297
|
+
return `create-creact: ${error.message}\n`;
|
|
298
|
+
const tail = error instanceof CommandFailed ? error.tail : [];
|
|
299
|
+
return [
|
|
300
|
+
`create-creact: ${error.message}. ${RETRY}`,
|
|
301
|
+
...tail.map((text) => dim(` ${text}`)),
|
|
302
|
+
...(log.written ? [`log: ${log.file}`] : []),
|
|
303
|
+
"",
|
|
304
|
+
].join("\n");
|
|
305
|
+
}
|
|
306
|
+
function rich(log, cwd) {
|
|
307
|
+
const marks = {
|
|
308
|
+
done: color("green", "✓"),
|
|
309
|
+
same: color("dim", "·"),
|
|
310
|
+
warn: color("yellow", "!"),
|
|
311
|
+
fail: color("red", "✗"),
|
|
312
|
+
};
|
|
313
|
+
let started = 0;
|
|
314
|
+
let current;
|
|
315
|
+
let stepStarted = 0;
|
|
316
|
+
let timer;
|
|
317
|
+
let frame = 0;
|
|
318
|
+
let dir = "";
|
|
319
|
+
const row = (mark, step, detail, ms) => {
|
|
320
|
+
const time = ms !== undefined && ms >= 500 ? color("dim", seconds(ms)) : "";
|
|
321
|
+
const padded = time === "" ? detail : detail.padEnd(DETAIL_WIDTH);
|
|
322
|
+
return ` ${mark} ${step.padEnd(LABEL_WIDTH)} ${color("dim", padded)} ${time}`.trimEnd();
|
|
323
|
+
};
|
|
324
|
+
const stop = () => {
|
|
325
|
+
if (timer !== undefined)
|
|
326
|
+
clearInterval(timer);
|
|
327
|
+
timer = undefined;
|
|
328
|
+
showCursor();
|
|
329
|
+
};
|
|
330
|
+
const draw = () => {
|
|
331
|
+
if (current === undefined)
|
|
332
|
+
return;
|
|
333
|
+
frame = (frame + 1) % SPINNER.length;
|
|
334
|
+
const spin = color("cyan", SPINNER[frame] ?? "");
|
|
335
|
+
clear();
|
|
336
|
+
out(row(spin, current, RUNNING[current], performance.now() - stepStarted));
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
begin(target, choices) {
|
|
340
|
+
dir = target;
|
|
341
|
+
started = performance.now();
|
|
342
|
+
out("\u001B[?25l");
|
|
343
|
+
process.once("exit", showCursor);
|
|
344
|
+
process.once("SIGINT", () => {
|
|
345
|
+
showCursor();
|
|
346
|
+
process.exit(130);
|
|
347
|
+
});
|
|
348
|
+
const badge = color(["inverse", "bold"], " creact ");
|
|
349
|
+
out(`\n ${badge} ${color("bold", path.basename(target))} ${color("dim", stackLine(choices))}\n\n`);
|
|
350
|
+
},
|
|
351
|
+
start(step) {
|
|
352
|
+
current = step;
|
|
353
|
+
stepStarted = performance.now();
|
|
354
|
+
draw();
|
|
355
|
+
timer = setInterval(draw, 80);
|
|
356
|
+
timer.unref();
|
|
357
|
+
},
|
|
358
|
+
finish(step, partial) {
|
|
359
|
+
if (timer !== undefined)
|
|
360
|
+
clearInterval(timer);
|
|
361
|
+
timer = undefined;
|
|
362
|
+
current = undefined;
|
|
363
|
+
const line = richLine(step, partial);
|
|
364
|
+
clear();
|
|
365
|
+
out(`${row(marks[line.mark], step, line.detail, partial.ms?.[step])}\n`);
|
|
366
|
+
for (const more of line.more ?? []) {
|
|
367
|
+
out(`${" ".repeat(LABEL_WIDTH + 5)}${color("dim", more)}\n`);
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
succeeded(report) {
|
|
371
|
+
stop();
|
|
372
|
+
const elapsed = seconds(performance.now() - started);
|
|
373
|
+
if (report.install === "skipped") {
|
|
374
|
+
out(`\n Done in ${elapsed}, without installing.\n`);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
const next = [`cd ${quotedIfNeeded(shown(dir, cwd))}`, "pnpm dev"];
|
|
378
|
+
out(`\n Ready in ${elapsed}. Next:\n\n`);
|
|
379
|
+
for (const command of next)
|
|
380
|
+
out(` ${color("cyan", command)}\n`);
|
|
381
|
+
}
|
|
382
|
+
if (typeof report.skills === "object") {
|
|
383
|
+
const where = `Full output: ${log.file}`;
|
|
384
|
+
out(`\n ${color("dim", where)}\n`);
|
|
385
|
+
}
|
|
386
|
+
out("\n");
|
|
387
|
+
},
|
|
388
|
+
failed(error, kind) {
|
|
389
|
+
stop();
|
|
390
|
+
if (current === undefined) {
|
|
391
|
+
process.stderr.write(errorBlock(error, kind, log, (text) => text));
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
clear();
|
|
395
|
+
const tail = error instanceof CommandFailed ? error.tail : [];
|
|
396
|
+
process.stderr.write([
|
|
397
|
+
` ${marks.fail} ${current.padEnd(LABEL_WIDTH)} ${errColor("red", error.message)}`,
|
|
398
|
+
...(tail.length > 0 ? [""] : []),
|
|
399
|
+
...tail.map((text) => errColor("dim", ` ${text.trim()}`)),
|
|
400
|
+
"",
|
|
401
|
+
...(log.written
|
|
402
|
+
? [` Full output: ${errColor("cyan", log.file)}`]
|
|
403
|
+
: []),
|
|
404
|
+
kind === "usage"
|
|
405
|
+
? " Nothing else changed."
|
|
406
|
+
: " Fix it, then run the same command to pick up where it stopped.",
|
|
407
|
+
"",
|
|
408
|
+
"",
|
|
409
|
+
].join("\n"));
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function stepsJson(report) {
|
|
414
|
+
const ms = report.ms ?? {};
|
|
415
|
+
const steps = {};
|
|
416
|
+
for (const step of STEPS) {
|
|
417
|
+
if (ms[step] === undefined)
|
|
418
|
+
continue;
|
|
419
|
+
steps[step] = { ...stepJson(step, report), ms: ms[step] };
|
|
420
|
+
}
|
|
421
|
+
return steps;
|
|
422
|
+
}
|
|
423
|
+
function stepJson(step, report) {
|
|
424
|
+
switch (step) {
|
|
425
|
+
case "monorepo": {
|
|
426
|
+
return report.base === "created"
|
|
427
|
+
? { status: "created", from: BTS }
|
|
428
|
+
: { status: "kept" };
|
|
429
|
+
}
|
|
430
|
+
case "tooling": {
|
|
431
|
+
const entries = Object.entries(report.layer?.files ?? {});
|
|
432
|
+
const count = (outcome) => entries.filter(([, value]) => value === outcome).length;
|
|
433
|
+
return {
|
|
434
|
+
status: "done",
|
|
435
|
+
removed: report.layer?.pruned ?? [],
|
|
436
|
+
written: count("written"),
|
|
437
|
+
unchanged: count("unchanged"),
|
|
438
|
+
kept: entries
|
|
439
|
+
.filter(([, value]) => value === "kept")
|
|
440
|
+
.map(([file]) => file),
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
case "git": {
|
|
444
|
+
return { status: report.git };
|
|
445
|
+
}
|
|
446
|
+
case "install": {
|
|
447
|
+
const count = packagesToAdd(report);
|
|
448
|
+
return report.install === "done"
|
|
449
|
+
? { status: "done", added: count }
|
|
450
|
+
: { status: "skipped", toAdd: count };
|
|
451
|
+
}
|
|
452
|
+
case "skills": {
|
|
453
|
+
const { skills, skillCount } = report;
|
|
454
|
+
return typeof skills === "object"
|
|
455
|
+
? {
|
|
456
|
+
status: "failed",
|
|
457
|
+
reason: skills.failed,
|
|
458
|
+
finish: finishCommand(report.dir ?? ""),
|
|
459
|
+
}
|
|
460
|
+
: { status: skills, count: skillCount };
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function json(log) {
|
|
465
|
+
let current;
|
|
466
|
+
let report = {};
|
|
467
|
+
return {
|
|
468
|
+
begin: heard,
|
|
469
|
+
start(step) {
|
|
470
|
+
current = step;
|
|
471
|
+
},
|
|
472
|
+
finish(_step, partial) {
|
|
473
|
+
current = undefined;
|
|
474
|
+
report = partial;
|
|
475
|
+
},
|
|
476
|
+
succeeded(final) {
|
|
477
|
+
writeJson({
|
|
478
|
+
ok: true,
|
|
479
|
+
version: VERSION,
|
|
480
|
+
dir: final.dir,
|
|
481
|
+
choices: final.choices,
|
|
482
|
+
steps: stepsJson(final),
|
|
483
|
+
next: [`cd ${shellQuoted(final.dir)}`, "pnpm dev"],
|
|
484
|
+
log: log.written ? log.file : null,
|
|
485
|
+
});
|
|
486
|
+
},
|
|
487
|
+
failed(error, kind) {
|
|
488
|
+
writeJson({
|
|
489
|
+
ok: false,
|
|
490
|
+
kind,
|
|
491
|
+
message: error.message,
|
|
492
|
+
...(kind === "command"
|
|
493
|
+
? {
|
|
494
|
+
step: current ?? null,
|
|
495
|
+
tail: error instanceof CommandFailed ? error.tail : [],
|
|
496
|
+
hint: RETRY,
|
|
497
|
+
}
|
|
498
|
+
: {}),
|
|
499
|
+
...(report.dir === undefined
|
|
500
|
+
? {}
|
|
501
|
+
: { dir: report.dir, steps: stepsJson(report) }),
|
|
502
|
+
log: log.written ? log.file : null,
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
// Read at runtime rather than imported, so the built CLI in dist reads the
|
|
3
|
+
// same package.json as the source in src, one directory up from either.
|
|
4
|
+
const manifest = JSON.parse(
|
|
5
|
+
// oxlint-disable-next-line security/detect-non-literal-fs-filename -- this package's own package.json
|
|
6
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
7
|
+
export const VERSION = manifest.version;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
|
3
|
+
"arrowParens": "always",
|
|
4
|
+
"bracketSameLine": false,
|
|
5
|
+
"bracketSpacing": true,
|
|
6
|
+
"embeddedLanguageFormatting": "auto",
|
|
7
|
+
"htmlWhitespaceSensitivity": "css",
|
|
8
|
+
"jsxSingleQuote": false,
|
|
9
|
+
"printWidth": 80,
|
|
10
|
+
"proseWrap": "preserve",
|
|
11
|
+
"quoteProps": "as-needed",
|
|
12
|
+
"semi": true,
|
|
13
|
+
"singleQuote": false,
|
|
14
|
+
"tabWidth": 2,
|
|
15
|
+
"trailingComma": "es5",
|
|
16
|
+
"useTabs": false,
|
|
17
|
+
"sortPackageJson": false,
|
|
18
|
+
"sortTailwindcss": {
|
|
19
|
+
"functions": ["cn", "cva"]
|
|
20
|
+
},
|
|
21
|
+
"sortImports": {
|
|
22
|
+
"newlinesBetween": false,
|
|
23
|
+
"customGroups": [
|
|
24
|
+
{
|
|
25
|
+
"groupName": "internal-types",
|
|
26
|
+
"elementNamePattern": ["@/**", "~/**"],
|
|
27
|
+
"modifiers": ["type"]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"groupName": "scoped-types",
|
|
31
|
+
"elementNamePattern": ["@*/**"],
|
|
32
|
+
"modifiers": ["type"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"groupName": "react",
|
|
36
|
+
"elementNamePattern": ["react", "react-dom", "react-dom/**"],
|
|
37
|
+
"modifiers": ["value"]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"groups": [
|
|
41
|
+
["scoped-types", "type-builtin", "value-builtin"],
|
|
42
|
+
{
|
|
43
|
+
"newlinesBetween": true
|
|
44
|
+
},
|
|
45
|
+
"react",
|
|
46
|
+
{
|
|
47
|
+
"newlinesBetween": true
|
|
48
|
+
},
|
|
49
|
+
"type-external",
|
|
50
|
+
"value-external",
|
|
51
|
+
{
|
|
52
|
+
"newlinesBetween": true
|
|
53
|
+
},
|
|
54
|
+
"internal-types",
|
|
55
|
+
"value-internal",
|
|
56
|
+
{
|
|
57
|
+
"newlinesBetween": true
|
|
58
|
+
},
|
|
59
|
+
["type-parent", "type-sibling", "type-index"],
|
|
60
|
+
["value-parent", "value-sibling", "value-index"],
|
|
61
|
+
"unknown"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"ignorePatterns": ["**/*.md", "**/*.toml", "pnpm-lock.yaml"]
|
|
65
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
A React monorepo from create-creact. Better-T-Stack laid it out, and creact's layer adds the lint, format, tsconfig, git hooks and test setup. `apps/web` is the app, and `packages/config` holds the base tsconfig.
|
|
4
|
+
|
|
5
|
+
## Run things
|
|
6
|
+
|
|
7
|
+
- Run scripts from the root with `pnpm <script>`. The `dev`, `build` and `check-types` scripts are Better-T-Stack's and run every workspace package through {{monorepo}}. creact's `lint`, `format`, `format:check`, `typecheck` and `test` run once from the root.
|
|
8
|
+
- In a fresh clone, run `pnpm install`. It also installs the git hooks and writes `apps/web/src/env.ts` from `apps/web/.env.schema`.
|
|
9
|
+
- Only pnpm is supported, as the hooks and scripts call pnpm.
|
|
10
|
+
|
|
11
|
+
## Code layout
|
|
12
|
+
|
|
13
|
+
- Import from `apps/web/src` with the `@/` alias, not a relative path that climbs out of a directory.
|
|
14
|
+
- The design tokens live in `apps/web/src/styles/tokens.css` as custom properties on `:root` with a dark block, in the shape a Figma variables export produces. The styling binds the names in a file next to it. Add a token to `tokens.css` and its binding before a component uses it. `tokens.test.ts` fails when a binding names a token `tokens.css` lacks.
|
|
15
|
+
|
|
16
|
+
## Commits
|
|
17
|
+
|
|
18
|
+
- Commits follow Conventional Commits. The commit-msg hook runs commitlint with `@commitlint/config-conventional` and a 72-character limit on the header and on each body line. Check a message first with `printf '%s\n' "$msg" | pnpm exec commitlint`.
|
|
19
|
+
|
|
20
|
+
## Agent skills
|
|
21
|
+
|
|
22
|
+
- `skills-lock.json` lists the third-party agent skills this repo uses. Restore them with `npx skills experimental_install`, which puts them in `.agents/skills`. The links in `.claude/skills` point there for Claude Code.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--color-page: #ffffff;
|
|
3
|
+
--color-ink: #171717;
|
|
4
|
+
--color-accent: #2563eb;
|
|
5
|
+
--spacing-gutter: 1.5rem;
|
|
6
|
+
--radius-card: 0.75rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@media (prefers-color-scheme: dark) {
|
|
10
|
+
:root {
|
|
11
|
+
--color-page: #0a0a0a;
|
|
12
|
+
--color-ink: #ededed;
|
|
13
|
+
--color-accent: #60a5fa;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UserConfig } from "@commitlint/types";
|
|
2
|
+
|
|
3
|
+
const ERROR = 2;
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
extends: ["@commitlint/config-conventional"],
|
|
7
|
+
rules: {
|
|
8
|
+
"header-max-length": [ERROR, "always", 72],
|
|
9
|
+
"body-max-line-length": [ERROR, "always", 72],
|
|
10
|
+
"footer-max-line-length": [ERROR, "always", 72],
|
|
11
|
+
},
|
|
12
|
+
} satisfies UserConfig;
|