@outfitter/tooling 0.2.0 → 0.2.1

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/cli/index.js CHANGED
@@ -1,338 +1,23 @@
1
1
  #!/usr/bin/env bun
2
+ // @bun
3
+ import {
4
+ runCheck
5
+ } from "../shared/@outfitter/tooling-xx1146e3.js";
6
+ import {
7
+ runInit
8
+ } from "../shared/@outfitter/tooling-xaxdr9da.js";
9
+ import {
10
+ runPrePush
11
+ } from "../shared/@outfitter/tooling-qm7jeg0d.js";
12
+ import {
13
+ runFix
14
+ } from "../shared/@outfitter/tooling-s4eqq91d.js";
15
+ import {
16
+ runUpgradeBun
17
+ } from "../shared/@outfitter/tooling-75j500dv.js";
2
18
 
3
- // src/cli/index.ts
19
+ // packages/tooling/src/cli/index.ts
4
20
  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
21
  var program = new Command;
337
22
  program.name("tooling").description("Dev tooling configuration management for Outfitter projects").version("0.1.0-rc.1");
338
23
  program.command("init").description("Initialize tooling config in the current project").action(async () => {
package/dist/index.d.ts CHANGED
@@ -1,111 +1,5 @@
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
- }
1
+ import "./shared/@outfitter/tooling-xqwn46sx";
2
+ import { AddBlockOptions, AddBlockResult, Block, BlockDefinition, BlockSchema, FileEntry, FileEntrySchema, Registry, RegistryBuildConfig, RegistrySchema } from "./shared/@outfitter/tooling-sjm8nebx";
109
3
  /**
110
4
  * @outfitter/tooling
111
5
  *
package/dist/index.js CHANGED
@@ -1,24 +1,12 @@
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
1
+ // @bun
2
+ import"./shared/@outfitter/tooling-kcvs6mys.js";
3
+ import {
4
+ BlockSchema,
5
+ FileEntrySchema,
6
+ RegistrySchema
7
+ } from "./shared/@outfitter/tooling-g83d0kjv.js";
8
+
9
+ // packages/tooling/src/index.ts
22
10
  var VERSION = "0.1.0-rc.1";
23
11
  export {
24
12
  VERSION,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@outfitter/tooling",
3
3
  "description": "Dev tooling configuration presets for Outfitter projects (biome, typescript, lefthook, markdownlint)",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -46,10 +46,15 @@
46
46
  }
47
47
  },
48
48
  "./package.json": "./package.json",
49
+ "./biome": "./biome.json",
49
50
  "./biome.json": "./biome.json",
51
+ "./tsconfig": "./tsconfig.preset.json",
50
52
  "./tsconfig.preset.json": "./tsconfig.preset.json",
53
+ "./tsconfig-bun": "./tsconfig.preset.bun.json",
51
54
  "./tsconfig.preset.bun.json": "./tsconfig.preset.bun.json",
55
+ "./lefthook": "./lefthook.yml",
52
56
  "./lefthook.yml": "./lefthook.yml",
57
+ "./.markdownlint-cli2": "./.markdownlint-cli2.jsonc",
53
58
  "./.markdownlint-cli2.jsonc": "./.markdownlint-cli2.jsonc"
54
59
  },
55
60
  "bin": {
@@ -58,8 +63,10 @@
58
63
  "sideEffects": false,
59
64
  "scripts": {
60
65
  "build:registry": "bun run src/registry/build.ts",
61
- "prebuild": "bun run build:registry",
66
+ "sync:exports": "bun run scripts/sync-exports.ts",
67
+ "prebuild": "bun run build:registry && bun run sync:exports",
62
68
  "build": "bunup --filter @outfitter/tooling",
69
+ "prepack": "bun run sync:exports",
63
70
  "lint": "biome lint ./src",
64
71
  "lint:fix": "biome lint --write ./src",
65
72
  "test": "bun test",