outfitter 0.2.7 → 0.3.2
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/README.md +1 -2
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +8 -7
- package/dist/shared/{chunk-x6644tk8.js → chunk-3pwh8ys4.js} +124 -154
- package/package.json +15 -11
- package/dist/actions.d.ts +0 -2
- package/dist/actions.js +0 -35
- package/dist/commands/add.d.ts +0 -54
- package/dist/commands/add.js +0 -16
- package/dist/commands/check-tsdoc.d.ts +0 -22
- package/dist/commands/check-tsdoc.js +0 -8
- package/dist/commands/check.d.ts +0 -91
- package/dist/commands/check.js +0 -14
- package/dist/commands/demo.d.ts +0 -21
- package/dist/commands/demo.js +0 -8
- package/dist/commands/docs-module-loader.d.ts +0 -2
- package/dist/commands/docs-module-loader.js +0 -8
- package/dist/commands/doctor.d.ts +0 -2
- package/dist/commands/doctor.js +0 -25
- package/dist/commands/init.d.ts +0 -7
- package/dist/commands/init.js +0 -32
- package/dist/commands/repo.d.ts +0 -3
- package/dist/commands/repo.js +0 -9
- package/dist/commands/scaffold.d.ts +0 -4
- package/dist/commands/scaffold.js +0 -32
- package/dist/commands/shared-deps.d.ts +0 -21
- package/dist/commands/shared-deps.js +0 -11
- package/dist/commands/upgrade-codemods.d.ts +0 -42
- package/dist/commands/upgrade-codemods.js +0 -15
- package/dist/commands/upgrade-planner.d.ts +0 -58
- package/dist/commands/upgrade-planner.js +0 -8
- package/dist/commands/upgrade-workspace.d.ts +0 -2
- package/dist/commands/upgrade-workspace.js +0 -16
- package/dist/commands/upgrade.d.ts +0 -221
- package/dist/commands/upgrade.js +0 -25
- package/dist/create/index.d.ts +0 -5
- package/dist/create/index.js +0 -30
- package/dist/create/planner.d.ts +0 -3
- package/dist/create/planner.js +0 -22
- package/dist/create/presets.d.ts +0 -3
- package/dist/create/presets.js +0 -12
- package/dist/create/types.d.ts +0 -2
- package/dist/create/types.js +0 -1
- package/dist/engine/blocks.d.ts +0 -3
- package/dist/engine/blocks.js +0 -12
- package/dist/engine/collector.d.ts +0 -2
- package/dist/engine/collector.js +0 -8
- package/dist/engine/config.d.ts +0 -3
- package/dist/engine/config.js +0 -15
- package/dist/engine/dependency-versions.d.ts +0 -12
- package/dist/engine/dependency-versions.js +0 -12
- package/dist/engine/executor.d.ts +0 -3
- package/dist/engine/executor.js +0 -19
- package/dist/engine/index.d.ts +0 -8
- package/dist/engine/index.js +0 -68
- package/dist/engine/names.d.ts +0 -2
- package/dist/engine/names.js +0 -24
- package/dist/engine/post-scaffold.d.ts +0 -3
- package/dist/engine/post-scaffold.js +0 -8
- package/dist/engine/render-plan.d.ts +0 -7
- package/dist/engine/render-plan.js +0 -9
- package/dist/engine/template.d.ts +0 -3
- package/dist/engine/template.js +0 -17
- package/dist/engine/types.d.ts +0 -2
- package/dist/engine/types.js +0 -8
- package/dist/engine/workspace.d.ts +0 -3
- package/dist/engine/workspace.js +0 -20
- package/dist/manifest.d.ts +0 -71
- package/dist/manifest.js +0 -16
- package/dist/output-mode.d.ts +0 -2
- package/dist/output-mode.js +0 -10
- package/dist/shared/outfitter-109s75x0.d.ts +0 -76
- package/dist/shared/outfitter-1fy7byz5.js +0 -170
- package/dist/shared/outfitter-1h7k8xxt.js +0 -29
- package/dist/shared/outfitter-20f6a2n4.js +0 -35
- package/dist/shared/outfitter-344t1r38.js +0 -1
- package/dist/shared/outfitter-4q1zfmvc.js +0 -154
- package/dist/shared/outfitter-4s9meh3j.js +0 -221
- package/dist/shared/outfitter-5akzvppx.js +0 -125
- package/dist/shared/outfitter-5y646xzk.js +0 -301
- package/dist/shared/outfitter-5yjr404v.d.ts +0 -22
- package/dist/shared/outfitter-63gse8fv.js +0 -316
- package/dist/shared/outfitter-6bkqjk86.d.ts +0 -3
- package/dist/shared/outfitter-6fgk6adm.d.ts +0 -40
- package/dist/shared/outfitter-79vfxt6y.js +0 -269
- package/dist/shared/outfitter-7ch26yq8.js +0 -885
- package/dist/shared/outfitter-7r12fj7f.js +0 -30
- package/dist/shared/outfitter-8y2dfx6n.js +0 -11
- package/dist/shared/outfitter-9x1brcmq.js +0 -184
- package/dist/shared/outfitter-a79xrm12.d.ts +0 -17
- package/dist/shared/outfitter-amc4jbs1.d.ts +0 -50
- package/dist/shared/outfitter-bn9c8p2e.js +0 -204
- package/dist/shared/outfitter-bpr28y54.js +0 -70
- package/dist/shared/outfitter-dpj9erew.d.ts +0 -4
- package/dist/shared/outfitter-e9rrfekb.d.ts +0 -51
- package/dist/shared/outfitter-ehp18x1n.js +0 -1
- package/dist/shared/outfitter-f9znfhkn.d.ts +0 -5
- package/dist/shared/outfitter-fhnjpjwc.d.ts +0 -18
- package/dist/shared/outfitter-fn20r49x.d.ts +0 -5
- package/dist/shared/outfitter-h3q6ae6d.d.ts +0 -48
- package/dist/shared/outfitter-ha89qf8q.js +0 -132
- package/dist/shared/outfitter-hsp8vy5m.d.ts +0 -146
- package/dist/shared/outfitter-hvsaxgcp.js +0 -1
- package/dist/shared/outfitter-j833sxws.js +0 -61
- package/dist/shared/outfitter-ksyvwmb5.js +0 -191
- package/dist/shared/outfitter-m3ehh37q.d.ts +0 -22
- package/dist/shared/outfitter-m44n0qzw.js +0 -161
- package/dist/shared/outfitter-mdt37hqm.js +0 -4
- package/dist/shared/outfitter-mt7d1ek2.js +0 -698
- package/dist/shared/outfitter-mtbpabf3.js +0 -91
- package/dist/shared/outfitter-n9g1zk4x.d.ts +0 -66
- package/dist/shared/outfitter-p71qb0f0.js +0 -82
- package/dist/shared/outfitter-pcj9gg2g.js +0 -909
- package/dist/shared/outfitter-pj9vp00r.js +0 -601
- package/dist/shared/outfitter-qakwgrrh.d.ts +0 -4
- package/dist/shared/outfitter-r419zfgs.d.ts +0 -30
- package/dist/shared/outfitter-s7jetkge.d.ts +0 -18
- package/dist/shared/outfitter-ttjr95y9.js +0 -98
- package/dist/shared/outfitter-vh4xgb93.js +0 -35
- package/dist/shared/outfitter-w1j80j1r.js +0 -326
- package/dist/shared/outfitter-xe5mzgdc.js +0 -208
- package/dist/shared/outfitter-ybbazsxq.d.ts +0 -14
- package/dist/shared/outfitter-yraebrmw.d.ts +0 -5
- package/dist/shared/outfitter-yvksv5qb.js +0 -322
- package/dist/shared/outfitter-z0we32cp.d.ts +0 -63
- package/dist/shared/outfitter-z5sx06qe.d.ts +0 -25
- package/dist/shared/outfitter-zwyvewr1.js +0 -36
- package/dist/targets/index.d.ts +0 -4
- package/dist/targets/index.js +0 -29
- package/dist/targets/registry.d.ts +0 -3
- package/dist/targets/registry.js +0 -28
- package/dist/targets/types.d.ts +0 -2
- package/dist/targets/types.js +0 -1
- package/template-versions.json +0 -22
- package/templates/.gitkeep +0 -0
- package/templates/basic/.gitignore.template +0 -30
- package/templates/basic/.lefthook.yml.template +0 -26
- package/templates/basic/package.json.template +0 -46
- package/templates/basic/src/index.ts.template +0 -26
- package/templates/basic/tsconfig.json.template +0 -34
- package/templates/cli/.gitignore.template +0 -4
- package/templates/cli/.lefthook.yml.template +0 -26
- package/templates/cli/README.md.template +0 -35
- package/templates/cli/biome.json.template +0 -4
- package/templates/cli/package.json.template +0 -53
- package/templates/cli/src/cli.ts.template +0 -8
- package/templates/cli/src/index.ts.template +0 -7
- package/templates/cli/src/program.ts.template +0 -31
- package/templates/cli/tsconfig.json.template +0 -34
- package/templates/daemon/.gitignore.template +0 -4
- package/templates/daemon/.lefthook.yml.template +0 -26
- package/templates/daemon/README.md.template +0 -67
- package/templates/daemon/biome.json.template +0 -4
- package/templates/daemon/package.json.template +0 -56
- package/templates/daemon/src/cli.ts.template +0 -96
- package/templates/daemon/src/daemon-main.ts.template +0 -79
- package/templates/daemon/src/daemon.ts.template +0 -11
- package/templates/daemon/src/index.ts.template +0 -7
- package/templates/daemon/tsconfig.json.template +0 -23
- package/templates/full-stack/.gitignore.template +0 -30
- package/templates/full-stack/README.md.template +0 -30
- package/templates/full-stack/apps/cli/package.json.template +0 -39
- package/templates/full-stack/apps/cli/src/cli.ts.template +0 -24
- package/templates/full-stack/apps/cli/src/index.test.ts.template +0 -18
- package/templates/full-stack/apps/cli/src/index.ts.template +0 -5
- package/templates/full-stack/apps/cli/tsconfig.json.template +0 -37
- package/templates/full-stack/apps/mcp/package.json.template +0 -40
- package/templates/full-stack/apps/mcp/src/index.test.ts.template +0 -18
- package/templates/full-stack/apps/mcp/src/index.ts.template +0 -6
- package/templates/full-stack/apps/mcp/src/mcp.ts.template +0 -22
- package/templates/full-stack/apps/mcp/src/server.ts.template +0 -10
- package/templates/full-stack/apps/mcp/tsconfig.json.template +0 -37
- package/templates/full-stack/package.json.template +0 -16
- package/templates/full-stack/packages/core/package.json.template +0 -36
- package/templates/full-stack/packages/core/src/handlers.ts.template +0 -31
- package/templates/full-stack/packages/core/src/index.test.ts.template +0 -30
- package/templates/full-stack/packages/core/src/index.ts.template +0 -8
- package/templates/full-stack/packages/core/src/types.ts.template +0 -13
- package/templates/full-stack/packages/core/tsconfig.json.template +0 -34
- package/templates/library/.gitignore.template +0 -30
- package/templates/library/README.md.template +0 -29
- package/templates/library/bunup.config.ts.template +0 -20
- package/templates/library/package.json.template +0 -55
- package/templates/library/src/handlers.ts.template +0 -31
- package/templates/library/src/index.test.ts.template +0 -35
- package/templates/library/src/index.ts.template +0 -8
- package/templates/library/src/types.ts.template +0 -13
- package/templates/library/tsconfig.json.template +0 -34
- package/templates/mcp/.gitignore.template +0 -4
- package/templates/mcp/.lefthook.yml.template +0 -26
- package/templates/mcp/README.md.template +0 -54
- package/templates/mcp/biome.json.template +0 -4
- package/templates/mcp/package.json.template +0 -53
- package/templates/mcp/src/index.ts.template +0 -7
- package/templates/mcp/src/mcp.ts.template +0 -33
- package/templates/mcp/src/server.ts.template +0 -8
- package/templates/mcp/tsconfig.json.template +0 -23
- package/templates/minimal/.gitignore.template +0 -30
- package/templates/minimal/.lefthook.yml.template +0 -26
- package/templates/minimal/package.json.template +0 -53
- package/templates/minimal/src/index.ts.template +0 -26
- package/templates/minimal/tsconfig.json.template +0 -34
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// apps/outfitter/src/commands/check-tsdoc.ts
|
|
3
|
-
import { existsSync, readFileSync } from "fs";
|
|
4
|
-
import { createRequire } from "module";
|
|
5
|
-
import { dirname, join, relative } from "path";
|
|
6
|
-
import { pathToFileURL } from "url";
|
|
7
|
-
import { Result, ValidationError } from "@outfitter/contracts";
|
|
8
|
-
var require2 = createRequire(import.meta.url);
|
|
9
|
-
var DEFAULT_TSDOC_DISCOVERY_PATTERNS = [
|
|
10
|
-
"packages/*/src/index.ts",
|
|
11
|
-
"apps/*/src/index.ts",
|
|
12
|
-
"src/index.ts"
|
|
13
|
-
];
|
|
14
|
-
function calculateCoverage(declarations) {
|
|
15
|
-
const total = declarations.length;
|
|
16
|
-
if (total === 0) {
|
|
17
|
-
return {
|
|
18
|
-
documented: 0,
|
|
19
|
-
partial: 0,
|
|
20
|
-
undocumented: 0,
|
|
21
|
-
total: 0,
|
|
22
|
-
percentage: 100
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const documented = declarations.filter((d) => d.level === "documented").length;
|
|
26
|
-
const partial = declarations.filter((d) => d.level === "partial").length;
|
|
27
|
-
const undocumented = declarations.filter((d) => d.level === "undocumented").length;
|
|
28
|
-
const score = documented + partial * 0.5;
|
|
29
|
-
const percentage = Math.round(score / total * 100);
|
|
30
|
-
return { documented, partial, undocumented, total, percentage };
|
|
31
|
-
}
|
|
32
|
-
function asRecord(value) {
|
|
33
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
34
|
-
}
|
|
35
|
-
function readJsonFile(filePath) {
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
38
|
-
} catch {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function readEntrypointsFromTsdocObject(value) {
|
|
43
|
-
const tsdoc = asRecord(value);
|
|
44
|
-
const entrypoints = tsdoc?.["entrypoints"];
|
|
45
|
-
if (!Array.isArray(entrypoints)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const normalized = entrypoints.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
49
|
-
return normalized.length > 0 ? normalized : undefined;
|
|
50
|
-
}
|
|
51
|
-
function resolveConfiguredEntrypoints(cwd) {
|
|
52
|
-
const configPath = join(cwd, ".outfitter", "config.json");
|
|
53
|
-
if (existsSync(configPath)) {
|
|
54
|
-
const parsed = readJsonFile(configPath);
|
|
55
|
-
if (parsed) {
|
|
56
|
-
const fromRoot = readEntrypointsFromTsdocObject(parsed["tsdoc"]);
|
|
57
|
-
if (fromRoot) {
|
|
58
|
-
return {
|
|
59
|
-
entrypoints: fromRoot,
|
|
60
|
-
source: ".outfitter/config.json#tsdoc.entrypoints"
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const fromOutfitter = readEntrypointsFromTsdocObject(asRecord(parsed["outfitter"])?.["tsdoc"]);
|
|
64
|
-
if (fromOutfitter) {
|
|
65
|
-
return {
|
|
66
|
-
entrypoints: fromOutfitter,
|
|
67
|
-
source: ".outfitter/config.json#outfitter.tsdoc.entrypoints"
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
73
|
-
if (!existsSync(packageJsonPath)) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
const parsedPackageJson = readJsonFile(packageJsonPath);
|
|
77
|
-
const fromPackageJson = readEntrypointsFromTsdocObject(asRecord(parsedPackageJson?.["outfitter"])?.["tsdoc"]);
|
|
78
|
-
if (!fromPackageJson) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
entrypoints: fromPackageJson,
|
|
83
|
-
source: "package.json#outfitter.tsdoc.entrypoints"
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function derivePackagePathFromEntrypoint(match) {
|
|
87
|
-
const normalized = match.replaceAll("\\", "/");
|
|
88
|
-
if (normalized === "src/index.ts") {
|
|
89
|
-
return ".";
|
|
90
|
-
}
|
|
91
|
-
if (normalized.endsWith("/src/index.ts")) {
|
|
92
|
-
return normalized.slice(0, -"/src/index.ts".length);
|
|
93
|
-
}
|
|
94
|
-
const srcSegment = normalized.lastIndexOf("/src/");
|
|
95
|
-
if (srcSegment >= 0) {
|
|
96
|
-
return srcSegment === 0 ? "." : normalized.slice(0, srcSegment);
|
|
97
|
-
}
|
|
98
|
-
const separator = normalized.lastIndexOf("/");
|
|
99
|
-
return separator > 0 ? normalized.slice(0, separator) : ".";
|
|
100
|
-
}
|
|
101
|
-
function discoverPathsFromEntrypoints(cwd, entrypoints) {
|
|
102
|
-
const paths = new Set;
|
|
103
|
-
for (const pattern of entrypoints) {
|
|
104
|
-
const glob = new Bun.Glob(pattern);
|
|
105
|
-
for (const match of glob.scanSync({ cwd, dot: false })) {
|
|
106
|
-
paths.add(derivePackagePathFromEntrypoint(match));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return [...paths].sort();
|
|
110
|
-
}
|
|
111
|
-
function formatDiscoveryMessage(entrypoints, source) {
|
|
112
|
-
const patterns = entrypoints.join(", ");
|
|
113
|
-
return source ? `${patterns} (from ${source})` : patterns;
|
|
114
|
-
}
|
|
115
|
-
function recalculateCounts(pkg, declarations) {
|
|
116
|
-
const coverage = calculateCoverage(declarations);
|
|
117
|
-
return {
|
|
118
|
-
...pkg,
|
|
119
|
-
declarations,
|
|
120
|
-
...coverage
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function filterResult(result, options) {
|
|
124
|
-
let packages = [...result.packages];
|
|
125
|
-
if (options.packageNames.length > 0) {
|
|
126
|
-
const names = new Set(options.packageNames);
|
|
127
|
-
packages = packages.filter((pkg) => names.has(pkg.name));
|
|
128
|
-
}
|
|
129
|
-
if (options.level) {
|
|
130
|
-
packages = packages.map((pkg) => {
|
|
131
|
-
const declarations = pkg.declarations.filter((d) => d.level === options.level);
|
|
132
|
-
return recalculateCounts(pkg, declarations);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
const summary = calculateCoverage(packages.flatMap((pkg) => pkg.declarations));
|
|
136
|
-
const ok = options.strict ? summary.percentage >= options.minCoverage : true;
|
|
137
|
-
return {
|
|
138
|
-
ok,
|
|
139
|
-
packages,
|
|
140
|
-
summary
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function summarizeResult(result) {
|
|
144
|
-
return {
|
|
145
|
-
ok: result.ok,
|
|
146
|
-
packages: result.packages.map((pkg) => ({
|
|
147
|
-
...pkg,
|
|
148
|
-
declarations: []
|
|
149
|
-
})),
|
|
150
|
-
summary: result.summary
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function emitJsonlLines(result, summary) {
|
|
154
|
-
const lines = [];
|
|
155
|
-
lines.push({ type: "meta", version: "1.0.0", ok: result.ok });
|
|
156
|
-
lines.push({ type: "summary", ...result.summary });
|
|
157
|
-
const sortedPackages = [...result.packages].sort((a, b) => a.name.localeCompare(b.name));
|
|
158
|
-
for (const pkg of sortedPackages) {
|
|
159
|
-
lines.push({
|
|
160
|
-
type: "package",
|
|
161
|
-
name: pkg.name,
|
|
162
|
-
percentage: pkg.percentage,
|
|
163
|
-
documented: pkg.documented,
|
|
164
|
-
partial: pkg.partial,
|
|
165
|
-
undocumented: pkg.undocumented,
|
|
166
|
-
total: pkg.total
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
if (!summary) {
|
|
170
|
-
for (const pkg of sortedPackages) {
|
|
171
|
-
for (const decl of pkg.declarations) {
|
|
172
|
-
lines.push({
|
|
173
|
-
type: "declaration",
|
|
174
|
-
package: pkg.name,
|
|
175
|
-
name: decl.name,
|
|
176
|
-
kind: decl.kind,
|
|
177
|
-
level: decl.level,
|
|
178
|
-
file: relative(pkg.path, decl.file),
|
|
179
|
-
line: decl.line
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return lines;
|
|
185
|
-
}
|
|
186
|
-
function normalizeJsonlRecord(text) {
|
|
187
|
-
try {
|
|
188
|
-
return JSON.stringify(JSON.parse(text));
|
|
189
|
-
} catch {
|
|
190
|
-
return JSON.stringify(text);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
async function applyJq(data, expr, options) {
|
|
194
|
-
try {
|
|
195
|
-
const json = JSON.stringify(data);
|
|
196
|
-
const args = ["jq", ...options?.compact ? ["-c"] : [], expr];
|
|
197
|
-
const proc = Bun.spawn(args, {
|
|
198
|
-
stdin: new Response(json),
|
|
199
|
-
stdout: "pipe",
|
|
200
|
-
stderr: "pipe"
|
|
201
|
-
});
|
|
202
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
203
|
-
new Response(proc.stdout).text(),
|
|
204
|
-
new Response(proc.stderr).text(),
|
|
205
|
-
proc.exited
|
|
206
|
-
]);
|
|
207
|
-
if (exitCode !== 0) {
|
|
208
|
-
process.stderr.write(`jq error: ${stderr.trim()}
|
|
209
|
-
`);
|
|
210
|
-
return options?.compact ? `${JSON.stringify(data)}
|
|
211
|
-
` : `${JSON.stringify(data, null, 2)}
|
|
212
|
-
`;
|
|
213
|
-
}
|
|
214
|
-
return stdout;
|
|
215
|
-
} catch (error) {
|
|
216
|
-
const message = error instanceof Error ? error.message : "unknown jq execution error";
|
|
217
|
-
const missingBinary = /enoent|not found/i.test(message);
|
|
218
|
-
if (missingBinary) {
|
|
219
|
-
process.stderr.write(`jq is not installed. Install jq or omit --jq to continue.
|
|
220
|
-
`);
|
|
221
|
-
} else {
|
|
222
|
-
process.stderr.write(`jq execution error: ${message}
|
|
223
|
-
`);
|
|
224
|
-
}
|
|
225
|
-
return options?.compact ? `${JSON.stringify(data)}
|
|
226
|
-
` : `${JSON.stringify(data, null, 2)}
|
|
227
|
-
`;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
var toolingCheckTsdocModule;
|
|
231
|
-
function resolveToolingEntrypoint() {
|
|
232
|
-
const packageJsonPath = require2.resolve("@outfitter/tooling/package.json");
|
|
233
|
-
const packageRoot = dirname(packageJsonPath);
|
|
234
|
-
const srcEntrypoint = join(packageRoot, "src", "index.ts");
|
|
235
|
-
if (existsSync(srcEntrypoint)) {
|
|
236
|
-
return srcEntrypoint;
|
|
237
|
-
}
|
|
238
|
-
const distEntrypoint = join(packageRoot, "dist", "index.js");
|
|
239
|
-
if (existsSync(distEntrypoint)) {
|
|
240
|
-
return distEntrypoint;
|
|
241
|
-
}
|
|
242
|
-
throw new Error("Unable to resolve @outfitter/tooling entrypoint (expected src/index.ts or dist/index.js).");
|
|
243
|
-
}
|
|
244
|
-
function loadToolingCheckTsdocModule() {
|
|
245
|
-
if (!toolingCheckTsdocModule) {
|
|
246
|
-
toolingCheckTsdocModule = import(pathToFileURL(resolveToolingEntrypoint()).href);
|
|
247
|
-
}
|
|
248
|
-
return toolingCheckTsdocModule;
|
|
249
|
-
}
|
|
250
|
-
async function runCheckTsdoc(input) {
|
|
251
|
-
try {
|
|
252
|
-
const tooling = await loadToolingCheckTsdocModule();
|
|
253
|
-
const configuredEntrypoints = resolveConfiguredEntrypoints(input.cwd);
|
|
254
|
-
const configuredPaths = configuredEntrypoints ? discoverPathsFromEntrypoints(input.cwd, configuredEntrypoints.entrypoints) : [];
|
|
255
|
-
if (configuredEntrypoints && configuredPaths.length === 0) {
|
|
256
|
-
return Result.err(ValidationError.fromMessage(`No packages found. Searched ${formatDiscoveryMessage(configuredEntrypoints.entrypoints, configuredEntrypoints.source)}.`, { cwd: input.cwd }));
|
|
257
|
-
}
|
|
258
|
-
const rawResult = tooling.analyzeCheckTsdoc({
|
|
259
|
-
strict: input.strict,
|
|
260
|
-
minCoverage: input.minCoverage,
|
|
261
|
-
cwd: input.cwd,
|
|
262
|
-
...configuredEntrypoints ? { paths: configuredPaths } : {}
|
|
263
|
-
});
|
|
264
|
-
if (!rawResult) {
|
|
265
|
-
const discoveryPatterns = configuredEntrypoints ? configuredEntrypoints.entrypoints : DEFAULT_TSDOC_DISCOVERY_PATTERNS;
|
|
266
|
-
const discoverySource = configuredEntrypoints?.source;
|
|
267
|
-
return Result.err(ValidationError.fromMessage(`No packages found. Searched ${formatDiscoveryMessage(discoveryPatterns, discoverySource)}. Use --package <path> to specify explicitly.`, { cwd: input.cwd }));
|
|
268
|
-
}
|
|
269
|
-
const hasFilters = input.level !== undefined || input.packages.length > 0;
|
|
270
|
-
const filteredResult = hasFilters ? filterResult(rawResult, {
|
|
271
|
-
level: input.level,
|
|
272
|
-
packageNames: input.packages,
|
|
273
|
-
strict: input.strict,
|
|
274
|
-
minCoverage: input.minCoverage
|
|
275
|
-
}) : rawResult;
|
|
276
|
-
const outputData = input.summary ? summarizeResult(filteredResult) : filteredResult;
|
|
277
|
-
if (input.outputMode === "jsonl") {
|
|
278
|
-
const lines = emitJsonlLines(filteredResult, input.summary);
|
|
279
|
-
if (input.jq) {
|
|
280
|
-
for (const line of lines) {
|
|
281
|
-
const filtered = await applyJq(line, input.jq, { compact: true });
|
|
282
|
-
for (const rawLine of filtered.split(/\r?\n/)) {
|
|
283
|
-
const trimmed = rawLine.trim();
|
|
284
|
-
if (!trimmed) {
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
process.stdout.write(`${normalizeJsonlRecord(trimmed)}
|
|
288
|
-
`);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
} else {
|
|
292
|
-
for (const line of lines) {
|
|
293
|
-
process.stdout.write(`${JSON.stringify(line)}
|
|
294
|
-
`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
} else if (input.jq) {
|
|
298
|
-
const filtered = await applyJq(outputData, input.jq);
|
|
299
|
-
process.stdout.write(filtered);
|
|
300
|
-
} else if (input.outputMode === "json") {
|
|
301
|
-
process.stdout.write(`${JSON.stringify(outputData, null, 2)}
|
|
302
|
-
`);
|
|
303
|
-
} else {
|
|
304
|
-
tooling.printCheckTsdocHuman(outputData, {
|
|
305
|
-
strict: input.strict,
|
|
306
|
-
minCoverage: input.minCoverage
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
return Result.ok(outputData);
|
|
310
|
-
} catch (error) {
|
|
311
|
-
const message = error instanceof Error ? error.message : "Failed to run check-tsdoc";
|
|
312
|
-
return Result.err(new Error(message));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export { runCheckTsdoc };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
type DocsMdxMode = "strict" | "lossy";
|
|
3
|
-
interface DocsBaseOptions {
|
|
4
|
-
readonly cwd?: string;
|
|
5
|
-
readonly excludedFilenames?: readonly string[];
|
|
6
|
-
readonly mdxMode?: DocsMdxMode;
|
|
7
|
-
readonly outputDir?: string;
|
|
8
|
-
readonly packagesDir?: string;
|
|
9
|
-
readonly workspaceRoot?: string;
|
|
10
|
-
}
|
|
11
|
-
interface ExecuteCheckCommandOptions extends DocsBaseOptions {}
|
|
12
|
-
interface ExecuteSyncCommandOptions extends DocsBaseOptions {}
|
|
13
|
-
type DocsExportTarget = "packages" | "llms" | "llms-full" | "all";
|
|
14
|
-
interface ExecuteExportCommandOptions extends DocsBaseOptions {
|
|
15
|
-
readonly llmsFile?: string;
|
|
16
|
-
readonly llmsFullFile?: string;
|
|
17
|
-
readonly target?: DocsExportTarget | string;
|
|
18
|
-
}
|
|
19
|
-
interface DocsCommandIo {
|
|
20
|
-
readonly err: (line: string) => void;
|
|
21
|
-
readonly out: (line: string) => void;
|
|
22
|
-
}
|
|
23
|
-
interface CreateDocsCommandOptions {
|
|
24
|
-
readonly commandName?: string;
|
|
25
|
-
readonly io?: {
|
|
26
|
-
readonly out?: (line: string) => void;
|
|
27
|
-
readonly err?: (line: string) => void;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
interface DocsModule {
|
|
31
|
-
createDocsCommand: (options?: CreateDocsCommandOptions) => Command;
|
|
32
|
-
executeCheckCommand: (options: ExecuteCheckCommandOptions, io: DocsCommandIo) => Promise<number>;
|
|
33
|
-
executeExportCommand: (options: ExecuteExportCommandOptions, io: DocsCommandIo) => Promise<number>;
|
|
34
|
-
executeSyncCommand: (options: ExecuteSyncCommandOptions, io: DocsCommandIo) => Promise<number>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Load docs command module with source-first resolution in monorepo development.
|
|
38
|
-
*/
|
|
39
|
-
declare function loadDocsModule(): Promise<DocsModule>;
|
|
40
|
-
export { ExecuteCheckCommandOptions, ExecuteSyncCommandOptions, DocsExportTarget, ExecuteExportCommandOptions, DocsCommandIo, CreateDocsCommandOptions, loadDocsModule };
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
stampBlock
|
|
4
|
-
} from "./outfitter-mtbpabf3.js";
|
|
5
|
-
import {
|
|
6
|
-
resolveStructuredOutputMode
|
|
7
|
-
} from "./outfitter-7r12fj7f.js";
|
|
8
|
-
|
|
9
|
-
// apps/outfitter/src/commands/add.ts
|
|
10
|
-
import {
|
|
11
|
-
chmodSync,
|
|
12
|
-
existsSync,
|
|
13
|
-
mkdirSync,
|
|
14
|
-
readFileSync,
|
|
15
|
-
writeFileSync
|
|
16
|
-
} from "fs";
|
|
17
|
-
import { dirname, join, resolve } from "path";
|
|
18
|
-
import { fileURLToPath } from "url";
|
|
19
|
-
import { output } from "@outfitter/cli";
|
|
20
|
-
import { Result } from "@outfitter/contracts";
|
|
21
|
-
import { RegistrySchema } from "@outfitter/tooling";
|
|
22
|
-
class AddError extends Error {
|
|
23
|
-
_tag = "AddError";
|
|
24
|
-
constructor(message) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.name = "AddError";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function getRegistryPath() {
|
|
30
|
-
let currentDir = dirname(fileURLToPath(import.meta.url));
|
|
31
|
-
for (let i = 0;i < 10; i++) {
|
|
32
|
-
const registryPath = join(currentDir, "node_modules/@outfitter/tooling/registry/registry.json");
|
|
33
|
-
if (existsSync(registryPath)) {
|
|
34
|
-
return registryPath;
|
|
35
|
-
}
|
|
36
|
-
const monoRepoPath = join(currentDir, "packages/tooling/registry/registry.json");
|
|
37
|
-
if (existsSync(monoRepoPath)) {
|
|
38
|
-
return monoRepoPath;
|
|
39
|
-
}
|
|
40
|
-
currentDir = dirname(currentDir);
|
|
41
|
-
}
|
|
42
|
-
throw new AddError("Could not find registry.json. Ensure @outfitter/tooling is installed.");
|
|
43
|
-
}
|
|
44
|
-
function readToolingVersion(registryPath) {
|
|
45
|
-
try {
|
|
46
|
-
const toolingRoot = dirname(dirname(registryPath));
|
|
47
|
-
const pkgPath = join(toolingRoot, "package.json");
|
|
48
|
-
const content = readFileSync(pkgPath, "utf-8");
|
|
49
|
-
const pkg = JSON.parse(content);
|
|
50
|
-
return pkg.version ?? "unknown";
|
|
51
|
-
} catch {
|
|
52
|
-
return "unknown";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function loadRegistry() {
|
|
56
|
-
try {
|
|
57
|
-
const registryPath = getRegistryPath();
|
|
58
|
-
const content = readFileSync(registryPath, "utf-8");
|
|
59
|
-
const parsed = JSON.parse(content);
|
|
60
|
-
const registry = RegistrySchema.parse(parsed);
|
|
61
|
-
const toolingVersion = readToolingVersion(registryPath);
|
|
62
|
-
return Result.ok({ registry, toolingVersion });
|
|
63
|
-
} catch (error) {
|
|
64
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
65
|
-
return Result.err(new AddError(`Failed to load registry: ${message}`));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function resolveBlock(registry, blockName, visited = new Set) {
|
|
69
|
-
if (visited.has(blockName)) {
|
|
70
|
-
return Result.err(new AddError(`Circular dependency detected for block: ${blockName}`));
|
|
71
|
-
}
|
|
72
|
-
visited.add(blockName);
|
|
73
|
-
const block = registry.blocks[blockName];
|
|
74
|
-
if (!block) {
|
|
75
|
-
const available = Object.keys(registry.blocks).join(", ");
|
|
76
|
-
return Result.err(new AddError(`Block '${blockName}' not found. Available blocks: ${available}`));
|
|
77
|
-
}
|
|
78
|
-
if (block.extends && block.extends.length > 0) {
|
|
79
|
-
const mergedFiles = [];
|
|
80
|
-
const mergedDeps = {};
|
|
81
|
-
const mergedDevDeps = {};
|
|
82
|
-
for (const extendedName of block.extends) {
|
|
83
|
-
const extendedResult = resolveBlock(registry, extendedName, visited);
|
|
84
|
-
if (extendedResult.isErr()) {
|
|
85
|
-
return extendedResult;
|
|
86
|
-
}
|
|
87
|
-
const extended = extendedResult.value;
|
|
88
|
-
if (extended.files) {
|
|
89
|
-
mergedFiles.push(...extended.files);
|
|
90
|
-
}
|
|
91
|
-
if (extended.dependencies) {
|
|
92
|
-
Object.assign(mergedDeps, extended.dependencies);
|
|
93
|
-
}
|
|
94
|
-
if (extended.devDependencies) {
|
|
95
|
-
Object.assign(mergedDevDeps, extended.devDependencies);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (block.files) {
|
|
99
|
-
mergedFiles.push(...block.files);
|
|
100
|
-
}
|
|
101
|
-
if (block.dependencies) {
|
|
102
|
-
Object.assign(mergedDeps, block.dependencies);
|
|
103
|
-
}
|
|
104
|
-
if (block.devDependencies) {
|
|
105
|
-
Object.assign(mergedDevDeps, block.devDependencies);
|
|
106
|
-
}
|
|
107
|
-
return Result.ok({
|
|
108
|
-
name: block.name,
|
|
109
|
-
description: block.description,
|
|
110
|
-
files: mergedFiles.length > 0 ? mergedFiles : undefined,
|
|
111
|
-
dependencies: Object.keys(mergedDeps).length > 0 ? mergedDeps : undefined,
|
|
112
|
-
devDependencies: Object.keys(mergedDevDeps).length > 0 ? mergedDevDeps : undefined
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return Result.ok(block);
|
|
116
|
-
}
|
|
117
|
-
function writeFile(filePath, content, executable) {
|
|
118
|
-
const dir = dirname(filePath);
|
|
119
|
-
if (!existsSync(dir)) {
|
|
120
|
-
mkdirSync(dir, { recursive: true });
|
|
121
|
-
}
|
|
122
|
-
writeFileSync(filePath, content, "utf-8");
|
|
123
|
-
if (executable) {
|
|
124
|
-
chmodSync(filePath, 493);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function updatePackageJson(cwd, dependencies, devDependencies, dryRun) {
|
|
128
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
129
|
-
if (!existsSync(packageJsonPath)) {
|
|
130
|
-
return { dependencies, devDependencies };
|
|
131
|
-
}
|
|
132
|
-
const content = readFileSync(packageJsonPath, "utf-8");
|
|
133
|
-
const pkg = JSON.parse(content);
|
|
134
|
-
const existingDeps = pkg["dependencies"] ?? {};
|
|
135
|
-
const existingDevDeps = pkg["devDependencies"] ?? {};
|
|
136
|
-
const addedDeps = {};
|
|
137
|
-
const addedDevDeps = {};
|
|
138
|
-
for (const [name, version] of Object.entries(dependencies)) {
|
|
139
|
-
if (!existingDeps[name]) {
|
|
140
|
-
existingDeps[name] = version;
|
|
141
|
-
addedDeps[name] = version;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
for (const [name, version] of Object.entries(devDependencies)) {
|
|
145
|
-
if (!(existingDevDeps[name] || existingDeps[name])) {
|
|
146
|
-
existingDevDeps[name] = version;
|
|
147
|
-
addedDevDeps[name] = version;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (!dryRun && (Object.keys(addedDeps).length > 0 || Object.keys(addedDevDeps).length > 0)) {
|
|
151
|
-
if (Object.keys(existingDeps).length > 0) {
|
|
152
|
-
pkg["dependencies"] = existingDeps;
|
|
153
|
-
}
|
|
154
|
-
if (Object.keys(existingDevDeps).length > 0) {
|
|
155
|
-
pkg["devDependencies"] = existingDevDeps;
|
|
156
|
-
}
|
|
157
|
-
writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
|
|
158
|
-
`);
|
|
159
|
-
}
|
|
160
|
-
return { dependencies: addedDeps, devDependencies: addedDevDeps };
|
|
161
|
-
}
|
|
162
|
-
async function runAdd(input) {
|
|
163
|
-
const { block: blockName, force, dryRun, cwd = process.cwd() } = input;
|
|
164
|
-
const resolvedCwd = resolve(cwd);
|
|
165
|
-
const registryResult = loadRegistry();
|
|
166
|
-
if (registryResult.isErr()) {
|
|
167
|
-
return registryResult;
|
|
168
|
-
}
|
|
169
|
-
const { registry, toolingVersion } = registryResult.value;
|
|
170
|
-
const blockResult = resolveBlock(registry, blockName);
|
|
171
|
-
if (blockResult.isErr()) {
|
|
172
|
-
return blockResult;
|
|
173
|
-
}
|
|
174
|
-
const block = blockResult.value;
|
|
175
|
-
const created = [];
|
|
176
|
-
const skipped = [];
|
|
177
|
-
const overwritten = [];
|
|
178
|
-
if (block.files) {
|
|
179
|
-
for (const file of block.files) {
|
|
180
|
-
const targetPath = join(resolvedCwd, file.path);
|
|
181
|
-
const fileExists = existsSync(targetPath);
|
|
182
|
-
if (fileExists && !force) {
|
|
183
|
-
skipped.push(file.path);
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (!dryRun) {
|
|
187
|
-
writeFile(targetPath, file.content, file.executable ?? false);
|
|
188
|
-
}
|
|
189
|
-
if (fileExists) {
|
|
190
|
-
overwritten.push(file.path);
|
|
191
|
-
} else {
|
|
192
|
-
created.push(file.path);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const { dependencies, devDependencies } = updatePackageJson(resolvedCwd, block.dependencies ?? {}, block.devDependencies ?? {}, dryRun);
|
|
197
|
-
if (!dryRun) {
|
|
198
|
-
const stampResult = await stampBlock(resolvedCwd, blockName, toolingVersion);
|
|
199
|
-
if (stampResult.isErr()) {
|
|
200
|
-
process.stderr.write(`Warning: failed to stamp manifest: ${stampResult.error.message}
|
|
201
|
-
`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return Result.ok({
|
|
205
|
-
created,
|
|
206
|
-
skipped,
|
|
207
|
-
overwritten,
|
|
208
|
-
dependencies,
|
|
209
|
-
devDependencies
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
async function printAddResults(result, dryRun, options) {
|
|
213
|
-
const structuredMode = resolveStructuredOutputMode(options?.mode);
|
|
214
|
-
if (structuredMode) {
|
|
215
|
-
await output({
|
|
216
|
-
dryRun,
|
|
217
|
-
created: result.created,
|
|
218
|
-
overwritten: result.overwritten,
|
|
219
|
-
skipped: result.skipped,
|
|
220
|
-
dependencies: result.dependencies,
|
|
221
|
-
devDependencies: result.devDependencies
|
|
222
|
-
}, { mode: structuredMode });
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const lines = [];
|
|
226
|
-
const prefix = dryRun ? "[dry-run] Would " : "";
|
|
227
|
-
if (result.created.length > 0) {
|
|
228
|
-
lines.push(`${prefix}create ${result.created.length} file(s):`);
|
|
229
|
-
for (const file of result.created) {
|
|
230
|
-
lines.push(` \u2713 ${file}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (result.overwritten.length > 0) {
|
|
234
|
-
lines.push(`${prefix}overwrite ${result.overwritten.length} file(s):`);
|
|
235
|
-
for (const file of result.overwritten) {
|
|
236
|
-
lines.push(` \u2713 ${file}`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (result.skipped.length > 0) {
|
|
240
|
-
lines.push(`Skipped ${result.skipped.length} existing file(s):`);
|
|
241
|
-
for (const file of result.skipped) {
|
|
242
|
-
lines.push(` - ${file} (use --force to overwrite)`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const depCount = Object.keys(result.dependencies).length + Object.keys(result.devDependencies).length;
|
|
246
|
-
if (depCount > 0) {
|
|
247
|
-
lines.push("", `${prefix}add ${depCount} package(s) to package.json:`);
|
|
248
|
-
for (const [name, version] of Object.entries(result.dependencies)) {
|
|
249
|
-
lines.push(` + ${name}@${version}`);
|
|
250
|
-
}
|
|
251
|
-
for (const [name, version] of Object.entries(result.devDependencies)) {
|
|
252
|
-
lines.push(` + ${name}@${version} (dev)`);
|
|
253
|
-
}
|
|
254
|
-
if (!dryRun) {
|
|
255
|
-
lines.push("", "Run `bun install` to install new dependencies.");
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
await output(lines, { mode: "human" });
|
|
259
|
-
}
|
|
260
|
-
function listBlocks() {
|
|
261
|
-
const registryResult = loadRegistry();
|
|
262
|
-
if (registryResult.isErr()) {
|
|
263
|
-
return registryResult;
|
|
264
|
-
}
|
|
265
|
-
const blocks = Object.keys(registryResult.value.registry.blocks);
|
|
266
|
-
return Result.ok(blocks);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export { AddError, runAdd, printAddResults, listBlocks };
|