@outfitter/tooling 0.2.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/.markdownlint-cli2.jsonc +66 -0
- package/README.md +168 -0
- package/biome.json +74 -0
- package/dist/cli/check.d.ts +19 -0
- package/dist/cli/check.js +9 -0
- package/dist/cli/fix.d.ts +19 -0
- package/dist/cli/fix.js +9 -0
- package/dist/cli/index.js +353 -0
- package/dist/cli/init.d.ts +31 -0
- package/dist/cli/init.js +11 -0
- package/dist/cli/pre-push.d.ts +8 -0
- package/dist/cli/pre-push.js +7 -0
- package/dist/cli/upgrade-bun.d.ts +8 -0
- package/dist/cli/upgrade-bun.js +7 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.js +28 -0
- package/dist/registry/build.js +128 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/schema.d.ts +2 -0
- package/dist/registry/schema.js +11 -0
- package/dist/shared/@outfitter/tooling-75j500dv.js +142 -0
- package/dist/shared/@outfitter/tooling-g83d0kjv.js +23 -0
- package/dist/shared/@outfitter/tooling-kcvs6mys.js +1 -0
- package/dist/shared/@outfitter/tooling-qm7jeg0d.js +99 -0
- package/dist/shared/@outfitter/tooling-s4eqq91d.js +20 -0
- package/dist/shared/@outfitter/tooling-sjm8nebx.d.ts +109 -0
- package/dist/shared/@outfitter/tooling-xaxdr9da.js +58 -0
- package/dist/shared/@outfitter/tooling-xx1146e3.js +20 -0
- package/lefthook.yml +30 -0
- package/package.json +116 -0
- package/registry/registry.json +78 -0
- package/tsconfig.preset.bun.json +7 -0
- package/tsconfig.preset.json +40 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/cli/check.ts
|
|
7
|
+
function buildCheckCommand(options) {
|
|
8
|
+
const cmd = ["ultracite", "check"];
|
|
9
|
+
if (options.paths && options.paths.length > 0) {
|
|
10
|
+
cmd.push(...options.paths);
|
|
11
|
+
}
|
|
12
|
+
return cmd;
|
|
13
|
+
}
|
|
14
|
+
async function runCheck(paths = []) {
|
|
15
|
+
const cmd = buildCheckCommand({ paths });
|
|
16
|
+
console.log(`Running: bun x ${cmd.join(" ")}`);
|
|
17
|
+
const proc = Bun.spawn(["bun", "x", ...cmd], {
|
|
18
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
19
|
+
});
|
|
20
|
+
const exitCode = await proc.exited;
|
|
21
|
+
process.exit(exitCode);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/cli/fix.ts
|
|
25
|
+
function buildFixCommand(options) {
|
|
26
|
+
const cmd = ["ultracite", "fix"];
|
|
27
|
+
if (options.paths && options.paths.length > 0) {
|
|
28
|
+
cmd.push(...options.paths);
|
|
29
|
+
}
|
|
30
|
+
return cmd;
|
|
31
|
+
}
|
|
32
|
+
async function runFix(paths = []) {
|
|
33
|
+
const cmd = buildFixCommand({ paths });
|
|
34
|
+
console.log(`Running: bun x ${cmd.join(" ")}`);
|
|
35
|
+
const proc = Bun.spawn(["bun", "x", ...cmd], {
|
|
36
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
37
|
+
});
|
|
38
|
+
const exitCode = await proc.exited;
|
|
39
|
+
process.exit(exitCode);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/cli/init.ts
|
|
43
|
+
var FRAMEWORK_DETECTORS = {
|
|
44
|
+
react: ["react", "react-dom"],
|
|
45
|
+
next: ["next"],
|
|
46
|
+
vue: ["vue"],
|
|
47
|
+
nuxt: ["nuxt"],
|
|
48
|
+
svelte: ["svelte"],
|
|
49
|
+
angular: ["@angular/core"],
|
|
50
|
+
solid: ["solid-js"],
|
|
51
|
+
astro: ["astro"],
|
|
52
|
+
remix: ["@remix-run/react"],
|
|
53
|
+
qwik: ["@builder.io/qwik"]
|
|
54
|
+
};
|
|
55
|
+
function detectFrameworks(pkg) {
|
|
56
|
+
const allDeps = {
|
|
57
|
+
...pkg.dependencies,
|
|
58
|
+
...pkg.devDependencies
|
|
59
|
+
};
|
|
60
|
+
const detected = [];
|
|
61
|
+
for (const [framework, packages] of Object.entries(FRAMEWORK_DETECTORS)) {
|
|
62
|
+
if (packages.some((p) => (p in allDeps))) {
|
|
63
|
+
detected.push(framework);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (detected.length === 0) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
return ["--frameworks", ...detected];
|
|
70
|
+
}
|
|
71
|
+
function buildUltraciteCommand(options) {
|
|
72
|
+
const cmd = ["ultracite", "init", "--linter", "biome", "--pm", "bun", "--quiet"];
|
|
73
|
+
if (options.frameworks && options.frameworks.length > 0) {
|
|
74
|
+
cmd.push("--frameworks", ...options.frameworks);
|
|
75
|
+
}
|
|
76
|
+
return cmd;
|
|
77
|
+
}
|
|
78
|
+
async function runInit(cwd = process.cwd()) {
|
|
79
|
+
const pkgPath = `${cwd}/package.json`;
|
|
80
|
+
const pkgFile = Bun.file(pkgPath);
|
|
81
|
+
if (!await pkgFile.exists()) {
|
|
82
|
+
console.error("No package.json found in current directory");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
const pkg = await pkgFile.json();
|
|
86
|
+
const frameworkFlags = detectFrameworks(pkg);
|
|
87
|
+
const frameworks = frameworkFlags.length > 0 ? frameworkFlags.slice(1) : [];
|
|
88
|
+
const cmd = buildUltraciteCommand({ frameworks });
|
|
89
|
+
console.log(`Running: bun x ${cmd.join(" ")}`);
|
|
90
|
+
const proc = Bun.spawn(["bun", "x", ...cmd], {
|
|
91
|
+
cwd,
|
|
92
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
93
|
+
});
|
|
94
|
+
const exitCode = await proc.exited;
|
|
95
|
+
process.exit(exitCode);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/cli/pre-push.ts
|
|
99
|
+
var COLORS = {
|
|
100
|
+
reset: "\x1B[0m",
|
|
101
|
+
red: "\x1B[31m",
|
|
102
|
+
green: "\x1B[32m",
|
|
103
|
+
yellow: "\x1B[33m",
|
|
104
|
+
blue: "\x1B[34m"
|
|
105
|
+
};
|
|
106
|
+
function log(msg) {
|
|
107
|
+
console.log(msg);
|
|
108
|
+
}
|
|
109
|
+
function getCurrentBranch() {
|
|
110
|
+
const result = Bun.spawnSync(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
111
|
+
return result.stdout.toString().trim();
|
|
112
|
+
}
|
|
113
|
+
function isRedPhaseBranch(branch) {
|
|
114
|
+
return branch.endsWith("-tests") || branch.endsWith("/tests") || branch.endsWith("_tests");
|
|
115
|
+
}
|
|
116
|
+
function isScaffoldBranch(branch) {
|
|
117
|
+
return branch.endsWith("-scaffold") || branch.endsWith("/scaffold") || branch.endsWith("_scaffold");
|
|
118
|
+
}
|
|
119
|
+
function hasRedPhaseBranchInContext(currentBranch) {
|
|
120
|
+
let branches = [];
|
|
121
|
+
try {
|
|
122
|
+
const gtResult = Bun.spawnSync(["gt", "ls"], { stderr: "pipe" });
|
|
123
|
+
if (gtResult.exitCode === 0) {
|
|
124
|
+
branches = gtResult.stdout.toString().split(`
|
|
125
|
+
`).map((line) => line.replace(/^[│├└─◉◯ ]*/g, "").replace(/ \(.*/, "")).filter(Boolean);
|
|
126
|
+
}
|
|
127
|
+
} catch {}
|
|
128
|
+
if (branches.length === 0) {
|
|
129
|
+
const gitResult = Bun.spawnSync([
|
|
130
|
+
"git",
|
|
131
|
+
"branch",
|
|
132
|
+
"--list",
|
|
133
|
+
"cli/*",
|
|
134
|
+
"types/*",
|
|
135
|
+
"contracts/*"
|
|
136
|
+
]);
|
|
137
|
+
branches = gitResult.stdout.toString().split(`
|
|
138
|
+
`).map((line) => line.replace(/^[* ]+/, "")).filter(Boolean);
|
|
139
|
+
}
|
|
140
|
+
for (const branch of branches) {
|
|
141
|
+
if (branch === currentBranch)
|
|
142
|
+
continue;
|
|
143
|
+
if (isRedPhaseBranch(branch))
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
function runTests() {
|
|
149
|
+
log("");
|
|
150
|
+
const result = Bun.spawnSync(["bun", "run", "test"], {
|
|
151
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
152
|
+
});
|
|
153
|
+
return result.exitCode === 0;
|
|
154
|
+
}
|
|
155
|
+
async function runPrePush(options = {}) {
|
|
156
|
+
log(`${COLORS.blue}Pre-push test${COLORS.reset} (TDD-aware)`);
|
|
157
|
+
log("");
|
|
158
|
+
const branch = getCurrentBranch();
|
|
159
|
+
if (isRedPhaseBranch(branch)) {
|
|
160
|
+
log(`${COLORS.yellow}TDD RED phase${COLORS.reset} detected: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
161
|
+
log(`${COLORS.yellow}Skipping test execution${COLORS.reset} - tests are expected to fail in RED phase`);
|
|
162
|
+
log("");
|
|
163
|
+
log("Remember: GREEN phase (implementation) must make these tests pass!");
|
|
164
|
+
process.exit(0);
|
|
165
|
+
}
|
|
166
|
+
if (isScaffoldBranch(branch)) {
|
|
167
|
+
if (hasRedPhaseBranchInContext(branch)) {
|
|
168
|
+
log(`${COLORS.yellow}Scaffold branch${COLORS.reset} with RED phase branch in context: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
169
|
+
log(`${COLORS.yellow}Skipping test execution${COLORS.reset} - RED phase tests expected to fail`);
|
|
170
|
+
log("");
|
|
171
|
+
process.exit(0);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (options.force) {
|
|
175
|
+
log(`${COLORS.yellow}Force flag set${COLORS.reset} - skipping tests`);
|
|
176
|
+
process.exit(0);
|
|
177
|
+
}
|
|
178
|
+
log(`Running tests for branch: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
179
|
+
if (runTests()) {
|
|
180
|
+
log("");
|
|
181
|
+
log(`${COLORS.green}All tests passed${COLORS.reset}`);
|
|
182
|
+
process.exit(0);
|
|
183
|
+
} else {
|
|
184
|
+
log("");
|
|
185
|
+
log(`${COLORS.red}Tests failed${COLORS.reset}`);
|
|
186
|
+
log("");
|
|
187
|
+
log("If this is intentional TDD RED phase work, name your branch:");
|
|
188
|
+
log(" - feature-tests");
|
|
189
|
+
log(" - feature/tests");
|
|
190
|
+
log(" - feature_tests");
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/cli/upgrade-bun.ts
|
|
196
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
197
|
+
import { join } from "node:path";
|
|
198
|
+
var COLORS2 = {
|
|
199
|
+
reset: "\x1B[0m",
|
|
200
|
+
red: "\x1B[31m",
|
|
201
|
+
green: "\x1B[32m",
|
|
202
|
+
yellow: "\x1B[33m",
|
|
203
|
+
blue: "\x1B[34m"
|
|
204
|
+
};
|
|
205
|
+
function log2(msg) {
|
|
206
|
+
console.log(msg);
|
|
207
|
+
}
|
|
208
|
+
function info(msg) {
|
|
209
|
+
console.log(`${COLORS2.blue}▸${COLORS2.reset} ${msg}`);
|
|
210
|
+
}
|
|
211
|
+
function success(msg) {
|
|
212
|
+
console.log(`${COLORS2.green}✓${COLORS2.reset} ${msg}`);
|
|
213
|
+
}
|
|
214
|
+
function warn(msg) {
|
|
215
|
+
console.log(`${COLORS2.yellow}!${COLORS2.reset} ${msg}`);
|
|
216
|
+
}
|
|
217
|
+
async function fetchLatestVersion() {
|
|
218
|
+
const response = await fetch("https://api.github.com/repos/oven-sh/bun/releases/latest");
|
|
219
|
+
const data = await response.json();
|
|
220
|
+
const match = data.tag_name.match(/bun-v(.+)/);
|
|
221
|
+
if (!match?.[1]) {
|
|
222
|
+
throw new Error(`Could not parse version from tag: ${data.tag_name}`);
|
|
223
|
+
}
|
|
224
|
+
return match[1];
|
|
225
|
+
}
|
|
226
|
+
function findPackageJsonFiles(dir) {
|
|
227
|
+
const results = [];
|
|
228
|
+
const glob = new Bun.Glob("**/package.json");
|
|
229
|
+
for (const path of glob.scanSync({ cwd: dir })) {
|
|
230
|
+
if (!path.includes("node_modules")) {
|
|
231
|
+
results.push(join(dir, path));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return results;
|
|
235
|
+
}
|
|
236
|
+
function updateEnginesBun(filePath, version) {
|
|
237
|
+
const content = readFileSync(filePath, "utf-8");
|
|
238
|
+
const pattern = /"bun":\s*">=[\d.]+"/;
|
|
239
|
+
if (!pattern.test(content)) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
const updated = content.replace(pattern, `"bun": ">=${version}"`);
|
|
243
|
+
if (updated !== content) {
|
|
244
|
+
writeFileSync(filePath, updated);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
function updateTypesBun(filePath, version) {
|
|
250
|
+
const content = readFileSync(filePath, "utf-8");
|
|
251
|
+
const pattern = /"@types\/bun":\s*"\^[\d.]+"/;
|
|
252
|
+
if (!pattern.test(content)) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
const updated = content.replace(pattern, `"@types/bun": "^${version}"`);
|
|
256
|
+
if (updated !== content) {
|
|
257
|
+
writeFileSync(filePath, updated);
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
async function runUpgradeBun(targetVersion, options = {}) {
|
|
263
|
+
const cwd = process.cwd();
|
|
264
|
+
const bunVersionFile = join(cwd, ".bun-version");
|
|
265
|
+
let version = targetVersion;
|
|
266
|
+
if (!version) {
|
|
267
|
+
info("Fetching latest Bun version...");
|
|
268
|
+
version = await fetchLatestVersion();
|
|
269
|
+
log2(`Latest version: ${version}`);
|
|
270
|
+
}
|
|
271
|
+
const currentVersion = existsSync(bunVersionFile) ? readFileSync(bunVersionFile, "utf-8").trim() : "unknown";
|
|
272
|
+
log2(`Current version: ${currentVersion}`);
|
|
273
|
+
if (currentVersion === version) {
|
|
274
|
+
success(`Already on version ${version}`);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
log2("");
|
|
278
|
+
info(`Upgrading Bun: ${currentVersion} → ${version}`);
|
|
279
|
+
log2("");
|
|
280
|
+
writeFileSync(bunVersionFile, `${version}
|
|
281
|
+
`);
|
|
282
|
+
success("Updated .bun-version");
|
|
283
|
+
const packageFiles = findPackageJsonFiles(cwd);
|
|
284
|
+
info("Updating engines.bun...");
|
|
285
|
+
for (const file of packageFiles) {
|
|
286
|
+
if (updateEnginesBun(file, version)) {
|
|
287
|
+
log2(` ${file.replace(cwd + "/", "")}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
info("Updating @types/bun...");
|
|
291
|
+
for (const file of packageFiles) {
|
|
292
|
+
if (updateTypesBun(file, version)) {
|
|
293
|
+
log2(` ${file.replace(cwd + "/", "")}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (options.install !== false) {
|
|
297
|
+
log2("");
|
|
298
|
+
info(`Installing Bun ${version}...`);
|
|
299
|
+
const installResult = Bun.spawnSync([
|
|
300
|
+
"bash",
|
|
301
|
+
"-c",
|
|
302
|
+
`curl -fsSL https://bun.sh/install | bash -s "bun-v${version}"`
|
|
303
|
+
]);
|
|
304
|
+
if (installResult.exitCode !== 0) {
|
|
305
|
+
warn("Could not install Bun automatically");
|
|
306
|
+
log2("Install manually: curl -fsSL https://bun.sh/install | bash");
|
|
307
|
+
} else {
|
|
308
|
+
success(`Bun ${version} installed`);
|
|
309
|
+
log2("");
|
|
310
|
+
info("Updating lockfile...");
|
|
311
|
+
const bunInstall = Bun.spawnSync(["bun", "install"], {
|
|
312
|
+
cwd,
|
|
313
|
+
env: {
|
|
314
|
+
...process.env,
|
|
315
|
+
BUN_INSTALL: `${process.env["HOME"]}/.bun`,
|
|
316
|
+
PATH: `${process.env["HOME"]}/.bun/bin:${process.env["PATH"]}`
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
if (bunInstall.exitCode === 0) {
|
|
320
|
+
success("Lockfile updated");
|
|
321
|
+
} else {
|
|
322
|
+
warn("Could not update lockfile - run 'bun install' manually");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
log2("");
|
|
327
|
+
success("Done! Changes ready to commit:");
|
|
328
|
+
log2(" - .bun-version");
|
|
329
|
+
log2(" - package.json files (engines.bun, @types/bun)");
|
|
330
|
+
log2(" - bun.lock");
|
|
331
|
+
log2("");
|
|
332
|
+
log2(`Commit with: git add -A && git commit -m 'chore: upgrade Bun to ${version}'`);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/cli/index.ts
|
|
336
|
+
var program = new Command;
|
|
337
|
+
program.name("tooling").description("Dev tooling configuration management for Outfitter projects").version("0.1.0-rc.1");
|
|
338
|
+
program.command("init").description("Initialize tooling config in the current project").action(async () => {
|
|
339
|
+
await runInit();
|
|
340
|
+
});
|
|
341
|
+
program.command("check").description("Run linting checks (wraps ultracite)").argument("[paths...]", "Paths to check").action(async (paths) => {
|
|
342
|
+
await runCheck(paths);
|
|
343
|
+
});
|
|
344
|
+
program.command("fix").description("Fix linting issues (wraps ultracite)").argument("[paths...]", "Paths to fix").action(async (paths) => {
|
|
345
|
+
await runFix(paths);
|
|
346
|
+
});
|
|
347
|
+
program.command("upgrade-bun").description("Upgrade Bun version across the project").argument("[version]", "Target version (defaults to latest)").option("--no-install", "Skip installing Bun and updating lockfile").action(async (version, options) => {
|
|
348
|
+
await runUpgradeBun(version, options);
|
|
349
|
+
});
|
|
350
|
+
program.command("pre-push").description("TDD-aware pre-push test hook").option("-f, --force", "Skip tests entirely").action(async (options) => {
|
|
351
|
+
await runPrePush(options);
|
|
352
|
+
});
|
|
353
|
+
program.parse();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI init command - Initialize tooling config in a project
|
|
3
|
+
*/
|
|
4
|
+
/** Package.json structure for framework detection */
|
|
5
|
+
interface PackageJson {
|
|
6
|
+
dependencies?: Record<string, string>;
|
|
7
|
+
devDependencies?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/** Options for building the ultracite command */
|
|
10
|
+
interface UltraciteOptions {
|
|
11
|
+
frameworks?: string[];
|
|
12
|
+
quiet?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Detect frameworks from package.json dependencies
|
|
16
|
+
* @param pkg - Package.json contents
|
|
17
|
+
* @returns Array of CLI flags for detected frameworks
|
|
18
|
+
*/
|
|
19
|
+
declare function detectFrameworks(pkg: PackageJson): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Build the ultracite init command with appropriate flags
|
|
22
|
+
* @param options - Command options
|
|
23
|
+
* @returns Array of command arguments
|
|
24
|
+
*/
|
|
25
|
+
declare function buildUltraciteCommand(options: UltraciteOptions): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Run the init command
|
|
28
|
+
* @param cwd - Working directory
|
|
29
|
+
*/
|
|
30
|
+
declare function runInit(cwd?: string): Promise<void>;
|
|
31
|
+
export { runInit, detectFrameworks, buildUltraciteCommand };
|
package/dist/cli/init.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ZodType } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* File entry in a block.
|
|
4
|
+
*/
|
|
5
|
+
interface FileEntry {
|
|
6
|
+
/** Destination path relative to project root */
|
|
7
|
+
path: string;
|
|
8
|
+
/** File contents (embedded in registry) */
|
|
9
|
+
content: string;
|
|
10
|
+
/** Whether to chmod +x after copying */
|
|
11
|
+
executable?: boolean | undefined;
|
|
12
|
+
/** Whether to process as a template (future) */
|
|
13
|
+
template?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Schema for a file entry in a block.
|
|
17
|
+
* Represents a file that will be copied to the user's project.
|
|
18
|
+
*/
|
|
19
|
+
declare const FileEntrySchema: ZodType<FileEntry>;
|
|
20
|
+
/**
|
|
21
|
+
* Block in the registry.
|
|
22
|
+
*/
|
|
23
|
+
interface Block {
|
|
24
|
+
/** Block name (matches the key in blocks record) */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Human-readable description */
|
|
27
|
+
description: string;
|
|
28
|
+
/** Files included in this block */
|
|
29
|
+
files?: FileEntry[] | undefined;
|
|
30
|
+
/** npm dependencies to add to package.json */
|
|
31
|
+
dependencies?: Record<string, string> | undefined;
|
|
32
|
+
/** npm devDependencies to add to package.json */
|
|
33
|
+
devDependencies?: Record<string, string> | undefined;
|
|
34
|
+
/** Other blocks this block extends (for composite blocks) */
|
|
35
|
+
extends?: string[] | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Schema for a block in the registry.
|
|
39
|
+
* A block is a collection of related files that can be added together.
|
|
40
|
+
*/
|
|
41
|
+
declare const BlockSchema: ZodType<Block>;
|
|
42
|
+
/**
|
|
43
|
+
* Complete registry structure.
|
|
44
|
+
*/
|
|
45
|
+
interface Registry {
|
|
46
|
+
/** Registry schema version */
|
|
47
|
+
version: string;
|
|
48
|
+
/** Map of block name to block definition */
|
|
49
|
+
blocks: Record<string, Block>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Schema for the complete registry.
|
|
53
|
+
* Contains all available blocks with their files and metadata.
|
|
54
|
+
*/
|
|
55
|
+
declare const RegistrySchema: ZodType<Registry>;
|
|
56
|
+
/**
|
|
57
|
+
* Block definition used in the build script.
|
|
58
|
+
* Specifies how to collect source files into a block.
|
|
59
|
+
*/
|
|
60
|
+
interface BlockDefinition {
|
|
61
|
+
/** Human-readable description */
|
|
62
|
+
description: string;
|
|
63
|
+
/** Source file paths (relative to repo root) */
|
|
64
|
+
files?: string[];
|
|
65
|
+
/** Remap source paths to destination paths */
|
|
66
|
+
remap?: Record<string, string>;
|
|
67
|
+
/** npm dependencies */
|
|
68
|
+
dependencies?: Record<string, string>;
|
|
69
|
+
/** npm devDependencies */
|
|
70
|
+
devDependencies?: Record<string, string>;
|
|
71
|
+
/** Other blocks this block extends */
|
|
72
|
+
extends?: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for the registry build.
|
|
76
|
+
*/
|
|
77
|
+
interface RegistryBuildConfig {
|
|
78
|
+
/** Registry schema version */
|
|
79
|
+
version: string;
|
|
80
|
+
/** Block definitions */
|
|
81
|
+
blocks: Record<string, BlockDefinition>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Result of adding a block to a project.
|
|
85
|
+
*/
|
|
86
|
+
interface AddBlockResult {
|
|
87
|
+
/** Files that were created */
|
|
88
|
+
created: string[];
|
|
89
|
+
/** Files that were skipped (already exist) */
|
|
90
|
+
skipped: string[];
|
|
91
|
+
/** Files that were overwritten (with --force) */
|
|
92
|
+
overwritten: string[];
|
|
93
|
+
/** Dependencies added to package.json */
|
|
94
|
+
dependencies: Record<string, string>;
|
|
95
|
+
/** devDependencies added to package.json */
|
|
96
|
+
devDependencies: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Options for the add command.
|
|
100
|
+
*/
|
|
101
|
+
interface AddBlockOptions {
|
|
102
|
+
/** Overwrite existing files */
|
|
103
|
+
force?: boolean;
|
|
104
|
+
/** Show what would be added without making changes */
|
|
105
|
+
dryRun?: boolean;
|
|
106
|
+
/** Working directory (defaults to cwd) */
|
|
107
|
+
cwd?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @outfitter/tooling
|
|
111
|
+
*
|
|
112
|
+
* Dev tooling configuration presets for Outfitter projects.
|
|
113
|
+
* Provides standardized biome, TypeScript, lefthook, and markdownlint configurations.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```json
|
|
117
|
+
* // biome.json
|
|
118
|
+
* {
|
|
119
|
+
* "extends": ["ultracite/biome/core", "@outfitter/tooling/biome.json"]
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```json
|
|
125
|
+
* // tsconfig.json
|
|
126
|
+
* {
|
|
127
|
+
* "extends": "@outfitter/tooling/tsconfig.preset.bun.json"
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```yaml
|
|
133
|
+
* # .lefthook.yml
|
|
134
|
+
* extends:
|
|
135
|
+
* - node_modules/@outfitter/tooling/lefthook.yml
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @packageDocumentation
|
|
139
|
+
*/
|
|
140
|
+
/** Package version */
|
|
141
|
+
declare const VERSION = "0.1.0-rc.1";
|
|
142
|
+
export { VERSION, RegistrySchema, RegistryBuildConfig, Registry, FileEntrySchema, FileEntry, BlockSchema, BlockDefinition, Block, AddBlockResult, AddBlockOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/registry/schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var FileEntrySchema = z.object({
|
|
4
|
+
path: z.string().min(1),
|
|
5
|
+
content: z.string(),
|
|
6
|
+
executable: z.boolean().optional(),
|
|
7
|
+
template: z.boolean().optional()
|
|
8
|
+
});
|
|
9
|
+
var BlockSchema = z.object({
|
|
10
|
+
name: z.string().min(1),
|
|
11
|
+
description: z.string().min(1),
|
|
12
|
+
files: z.array(FileEntrySchema).optional(),
|
|
13
|
+
dependencies: z.record(z.string()).optional(),
|
|
14
|
+
devDependencies: z.record(z.string()).optional(),
|
|
15
|
+
extends: z.array(z.string()).optional()
|
|
16
|
+
});
|
|
17
|
+
var RegistrySchema = z.object({
|
|
18
|
+
version: z.string(),
|
|
19
|
+
blocks: z.record(BlockSchema)
|
|
20
|
+
});
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var VERSION = "0.1.0-rc.1";
|
|
23
|
+
export {
|
|
24
|
+
VERSION,
|
|
25
|
+
RegistrySchema,
|
|
26
|
+
FileEntrySchema,
|
|
27
|
+
BlockSchema
|
|
28
|
+
};
|