outfitter 0.2.5 → 0.2.6

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.
Files changed (131) hide show
  1. package/README.md +8 -5
  2. package/dist/actions.d.ts +2 -0
  3. package/dist/actions.js +34 -0
  4. package/dist/cli.js +1 -1
  5. package/dist/commands/add.d.ts +54 -0
  6. package/dist/commands/add.js +16 -0
  7. package/dist/commands/check.d.ts +91 -0
  8. package/dist/commands/check.js +14 -0
  9. package/dist/commands/demo.d.ts +21 -0
  10. package/dist/commands/demo.js +8 -0
  11. package/dist/commands/docs-module-loader.d.ts +2 -0
  12. package/dist/commands/docs-module-loader.js +8 -0
  13. package/dist/commands/doctor.d.ts +2 -0
  14. package/dist/commands/doctor.js +13 -0
  15. package/dist/commands/init.d.ts +7 -0
  16. package/dist/commands/init.js +31 -0
  17. package/dist/commands/migrate-kit.d.ts +2 -0
  18. package/dist/commands/migrate-kit.js +15 -0
  19. package/dist/commands/repo.d.ts +3 -0
  20. package/dist/commands/repo.js +9 -0
  21. package/dist/commands/scaffold.d.ts +4 -0
  22. package/dist/commands/scaffold.js +31 -0
  23. package/dist/commands/shared-deps.d.ts +36 -0
  24. package/dist/commands/shared-deps.js +10 -0
  25. package/dist/commands/upgrade-codemods.d.ts +42 -0
  26. package/dist/commands/upgrade-codemods.js +15 -0
  27. package/dist/commands/upgrade-planner.d.ts +58 -0
  28. package/dist/commands/upgrade-planner.js +8 -0
  29. package/dist/commands/upgrade-workspace.d.ts +76 -0
  30. package/dist/commands/upgrade-workspace.js +16 -0
  31. package/dist/commands/upgrade.d.ts +214 -0
  32. package/dist/commands/upgrade.js +25 -0
  33. package/dist/create/index.d.ts +5 -0
  34. package/dist/create/index.js +29 -0
  35. package/dist/create/planner.d.ts +3 -0
  36. package/dist/create/planner.js +21 -0
  37. package/dist/create/presets.d.ts +3 -0
  38. package/dist/create/presets.js +12 -0
  39. package/dist/create/types.d.ts +2 -0
  40. package/dist/create/types.js +1 -0
  41. package/dist/engine/blocks.d.ts +3 -0
  42. package/dist/engine/blocks.js +12 -0
  43. package/dist/engine/collector.d.ts +2 -0
  44. package/dist/engine/collector.js +8 -0
  45. package/dist/engine/config.d.ts +3 -0
  46. package/dist/engine/config.js +12 -0
  47. package/dist/engine/executor.d.ts +3 -0
  48. package/dist/engine/executor.js +16 -0
  49. package/dist/engine/index.d.ts +8 -0
  50. package/dist/engine/index.js +59 -0
  51. package/dist/engine/names.d.ts +2 -0
  52. package/dist/engine/names.js +16 -0
  53. package/dist/engine/post-scaffold.d.ts +3 -0
  54. package/dist/engine/post-scaffold.js +8 -0
  55. package/dist/engine/render-plan.d.ts +7 -0
  56. package/dist/engine/render-plan.js +9 -0
  57. package/dist/engine/template.d.ts +3 -0
  58. package/dist/engine/template.js +17 -0
  59. package/dist/engine/types.d.ts +2 -0
  60. package/dist/engine/types.js +8 -0
  61. package/dist/engine/workspace.d.ts +3 -0
  62. package/dist/engine/workspace.js +13 -0
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.js +1 -1
  65. package/dist/manifest.d.ts +71 -0
  66. package/dist/manifest.js +16 -0
  67. package/dist/output-mode.d.ts +2 -0
  68. package/dist/output-mode.js +10 -0
  69. package/dist/shared/{chunk-tpwtpa74.js → chunk-k59f60cp.js} +858 -396
  70. package/dist/shared/outfitter-193jvzg4.d.ts +5 -0
  71. package/dist/shared/outfitter-1dd0k853.js +194 -0
  72. package/dist/shared/outfitter-1dvma85c.js +322 -0
  73. package/dist/shared/outfitter-1h7k8xxt.js +29 -0
  74. package/dist/shared/outfitter-2ngep1h2.d.ts +5 -0
  75. package/dist/shared/outfitter-2np85etz.js +95 -0
  76. package/dist/shared/outfitter-33w361tc.d.ts +18 -0
  77. package/dist/shared/outfitter-344t1r38.js +1 -0
  78. package/dist/shared/outfitter-3weh61w7.d.ts +25 -0
  79. package/dist/shared/outfitter-4s9meh3j.js +221 -0
  80. package/dist/shared/outfitter-66b25bj8.js +125 -0
  81. package/dist/shared/outfitter-6bkqjk86.d.ts +3 -0
  82. package/dist/shared/outfitter-79vfxt6y.js +269 -0
  83. package/dist/shared/outfitter-7ha7p61k.d.ts +6 -0
  84. package/dist/shared/outfitter-7r12fj7f.js +30 -0
  85. package/dist/shared/outfitter-8y2dfx6n.js +11 -0
  86. package/dist/shared/outfitter-9x1brcmq.js +184 -0
  87. package/dist/shared/outfitter-9zqc2njf.js +859 -0
  88. package/dist/shared/outfitter-a79xrm12.d.ts +17 -0
  89. package/dist/shared/outfitter-amc4jbs1.d.ts +50 -0
  90. package/dist/shared/outfitter-ara3djt0.js +73 -0
  91. package/dist/shared/outfitter-avhm5z6w.js +82 -0
  92. package/dist/shared/outfitter-bkwpbkr9.d.ts +63 -0
  93. package/dist/shared/outfitter-bn9c8p2e.js +204 -0
  94. package/dist/shared/outfitter-bpr28y54.js +70 -0
  95. package/dist/shared/outfitter-cwq39bv4.d.ts +48 -0
  96. package/dist/shared/outfitter-d7pq7d0k.js +196 -0
  97. package/dist/shared/outfitter-dd0btgec.d.ts +40 -0
  98. package/dist/shared/outfitter-e2zz5wv7.d.ts +51 -0
  99. package/dist/shared/outfitter-ehp18x1n.js +1 -0
  100. package/dist/shared/outfitter-gdvm5c0b.d.ts +4 -0
  101. package/dist/shared/outfitter-h1mnzzd1.d.ts +14 -0
  102. package/dist/shared/outfitter-hvsaxgcp.js +1 -0
  103. package/dist/shared/outfitter-hws10ze7.js +532 -0
  104. package/dist/shared/outfitter-j833sxws.js +61 -0
  105. package/dist/shared/outfitter-j8yc7294.d.ts +22 -0
  106. package/dist/shared/outfitter-k112c427.js +21 -0
  107. package/dist/shared/outfitter-k56rmt24.d.ts +30 -0
  108. package/dist/shared/outfitter-ksa1pp4t.d.ts +4 -0
  109. package/dist/shared/outfitter-ksyvwmb5.js +191 -0
  110. package/dist/shared/outfitter-mdt37hqm.js +4 -0
  111. package/dist/shared/outfitter-mtbpabf3.js +91 -0
  112. package/dist/shared/outfitter-mxz69pgy.js +713 -0
  113. package/dist/shared/outfitter-npemy7ta.d.ts +53 -0
  114. package/dist/shared/outfitter-npyfbdmc.d.ts +6 -0
  115. package/dist/shared/outfitter-pyy1zkfh.d.ts +133 -0
  116. package/dist/shared/outfitter-q9agarmb.js +42 -0
  117. package/dist/shared/outfitter-qfh36ddg.d.ts +66 -0
  118. package/dist/shared/outfitter-qn864k6h.js +581 -0
  119. package/dist/shared/outfitter-rdc5v5ms.js +746 -0
  120. package/dist/shared/outfitter-sgtq57qr.d.ts +5 -0
  121. package/dist/shared/outfitter-ttjr95y9.js +98 -0
  122. package/dist/shared/outfitter-vh4xgb93.js +35 -0
  123. package/dist/shared/outfitter-yvksv5qb.js +322 -0
  124. package/dist/shared/outfitter-zwyvewr1.js +36 -0
  125. package/dist/targets/index.d.ts +4 -0
  126. package/dist/targets/index.js +29 -0
  127. package/dist/targets/registry.d.ts +3 -0
  128. package/dist/targets/registry.js +28 -0
  129. package/dist/targets/types.d.ts +2 -0
  130. package/dist/targets/types.js +1 -0
  131. package/package.json +19 -12
@@ -0,0 +1,191 @@
1
+ // @bun
2
+ // apps/outfitter/src/commands/demo.ts
3
+ import { fileURLToPath } from "url";
4
+ import { output } from "@outfitter/cli";
5
+ import {
6
+ getPrimitiveIds,
7
+ isPrimitiveId,
8
+ renderAllDemos,
9
+ renderDemo
10
+ } from "@outfitter/tui/demo";
11
+ var EMBEDDED_DEMO_FLAG = "--__outfitter-embedded-demo";
12
+ function isCommandNotFound(error) {
13
+ if (!(error instanceof Error)) {
14
+ return false;
15
+ }
16
+ return /ENOENT|not found|spawn/i.test(error.message);
17
+ }
18
+ async function tryRun(cmd) {
19
+ try {
20
+ const proc = Bun.spawn({
21
+ cmd,
22
+ stdin: "inherit",
23
+ stdout: "inherit",
24
+ stderr: "inherit"
25
+ });
26
+ return await proc.exited;
27
+ } catch (error) {
28
+ if (isCommandNotFound(error)) {
29
+ return;
30
+ }
31
+ throw error;
32
+ }
33
+ }
34
+ async function localDemoCmds(args) {
35
+ const localDistPath = fileURLToPath(new URL("../../../cli-demo/dist/cli.js", import.meta.url));
36
+ const localSrcPath = fileURLToPath(new URL("../../../cli-demo/src/cli.ts", import.meta.url));
37
+ const cmds = [];
38
+ if (await Bun.file(localDistPath).exists()) {
39
+ cmds.push([process.execPath, localDistPath, ...args]);
40
+ }
41
+ if (await Bun.file(localSrcPath).exists()) {
42
+ cmds.push([process.execPath, localSrcPath, ...args]);
43
+ }
44
+ return cmds;
45
+ }
46
+ function embeddedDemoCmd(args) {
47
+ return [
48
+ process.execPath,
49
+ fileURLToPath(import.meta.url),
50
+ EMBEDDED_DEMO_FLAG,
51
+ ...args
52
+ ];
53
+ }
54
+ function toCliArgs(options) {
55
+ const args = [];
56
+ if (options.section) {
57
+ args.push(options.section);
58
+ }
59
+ if (options.list) {
60
+ args.push("--list");
61
+ }
62
+ if (options.animate) {
63
+ args.push("--animate");
64
+ }
65
+ if (options.outputMode === "json") {
66
+ args.push("--json");
67
+ } else if (options.outputMode === "jsonl") {
68
+ args.push("--jsonl");
69
+ }
70
+ return args;
71
+ }
72
+ function toOutputMode(mode) {
73
+ return mode;
74
+ }
75
+ function renderListSections() {
76
+ const sections = getPrimitiveIds();
77
+ return [
78
+ "Available demo sections:",
79
+ ...sections.map((s) => `- ${s}`),
80
+ "- all"
81
+ ].join(`
82
+ `);
83
+ }
84
+ function renderUnknownSection(section) {
85
+ const sections = getPrimitiveIds();
86
+ return [
87
+ `Unknown section: ${section}`,
88
+ "",
89
+ `Available sections: ${sections.join(", ")}, all`,
90
+ "",
91
+ "For app-specific sections (for example `errors`), run `outfitter-demo`."
92
+ ].join(`
93
+ `);
94
+ }
95
+ function parseEmbeddedOptions(argv) {
96
+ let section;
97
+ let list = false;
98
+ let animate = false;
99
+ let outputMode = "human";
100
+ for (const arg of argv) {
101
+ if (arg === "--list" || arg === "-l") {
102
+ list = true;
103
+ continue;
104
+ }
105
+ if (arg === "--animate" || arg === "-a") {
106
+ animate = true;
107
+ continue;
108
+ }
109
+ if (arg === "--json") {
110
+ outputMode = "json";
111
+ continue;
112
+ }
113
+ if (arg === "--jsonl") {
114
+ outputMode = "jsonl";
115
+ continue;
116
+ }
117
+ if (arg.startsWith("-")) {
118
+ throw new Error(`Unknown option: ${arg}`);
119
+ }
120
+ if (section !== undefined) {
121
+ throw new Error(`Unexpected argument: ${arg}`);
122
+ }
123
+ section = arg;
124
+ }
125
+ return { section, list, animate, outputMode };
126
+ }
127
+ async function runEmbeddedDemo(options) {
128
+ const mode = toOutputMode(options.outputMode);
129
+ if (options.list) {
130
+ await output(renderListSections(), { mode });
131
+ return 0;
132
+ }
133
+ if (options.animate) {
134
+ await output(renderDemo("spinner"), { mode });
135
+ return 0;
136
+ }
137
+ if (options.section === undefined || options.section === "all") {
138
+ await output(renderAllDemos(), { mode });
139
+ return 0;
140
+ }
141
+ if (!isPrimitiveId(options.section)) {
142
+ await output(renderUnknownSection(options.section), { mode });
143
+ return 1;
144
+ }
145
+ await output(renderDemo(options.section), { mode });
146
+ return 0;
147
+ }
148
+ async function runEmbeddedFromArgv() {
149
+ if (process.argv[2] !== EMBEDDED_DEMO_FLAG) {
150
+ return;
151
+ }
152
+ const options = parseEmbeddedOptions(process.argv.slice(3));
153
+ const exitCode = await runEmbeddedDemo(options);
154
+ process.exit(exitCode);
155
+ }
156
+ if (import.meta.main) {
157
+ runEmbeddedFromArgv().catch((error) => {
158
+ const message = error instanceof Error ? error.message : String(error);
159
+ process.stderr.write(`${message}
160
+ `);
161
+ process.exit(1);
162
+ });
163
+ }
164
+ async function runDemo(options) {
165
+ const args = toCliArgs(options);
166
+ const commandCandidates = [
167
+ ["outfitter-demo", ...args],
168
+ ["cli-demo", ...args],
169
+ ...await localDemoCmds(args),
170
+ embeddedDemoCmd(args)
171
+ ];
172
+ for (const cmd of commandCandidates) {
173
+ const exitCode = await tryRun(cmd);
174
+ if (exitCode !== undefined) {
175
+ return { exitCode };
176
+ }
177
+ }
178
+ throw new Error([
179
+ "Demo functionality moved to the dedicated demo app.",
180
+ "",
181
+ "Run one of:",
182
+ " outfitter-demo --help",
183
+ " cli-demo --help",
184
+ "",
185
+ "In this monorepo, you can also run:",
186
+ " bun run apps/cli-demo/src/cli.ts --help"
187
+ ].join(`
188
+ `));
189
+ }
190
+
191
+ export { runDemo };
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ export { __require };
@@ -0,0 +1,91 @@
1
+ // @bun
2
+ import {
3
+ __require
4
+ } from "./outfitter-mdt37hqm.js";
5
+
6
+ // apps/outfitter/src/manifest.ts
7
+ import { join } from "path";
8
+ import {
9
+ InternalError,
10
+ Result,
11
+ ValidationError
12
+ } from "@outfitter/contracts";
13
+ import { z } from "zod";
14
+ var OUTFITTER_DIR = ".outfitter";
15
+ var MANIFEST_FILE = "manifest.json";
16
+ var BlockEntrySchema = z.object({
17
+ installedFrom: z.string(),
18
+ installedAt: z.string().datetime()
19
+ });
20
+ var ManifestSchema = z.object({
21
+ version: z.literal(1),
22
+ blocks: z.record(z.string(), BlockEntrySchema)
23
+ });
24
+ function manifestPath(cwd) {
25
+ return join(cwd, OUTFITTER_DIR, MANIFEST_FILE);
26
+ }
27
+ async function readManifest(cwd) {
28
+ const path = manifestPath(cwd);
29
+ const file = Bun.file(path);
30
+ if (!await file.exists()) {
31
+ return Result.ok(null);
32
+ }
33
+ let raw;
34
+ try {
35
+ raw = await file.text();
36
+ } catch {
37
+ return Result.err(InternalError.create("Failed to read manifest file", { path }));
38
+ }
39
+ let parsed;
40
+ try {
41
+ parsed = JSON.parse(raw);
42
+ } catch {
43
+ return Result.err(ValidationError.create("manifest", "Invalid JSON in manifest file"));
44
+ }
45
+ const validated = ManifestSchema.safeParse(parsed);
46
+ if (!validated.success) {
47
+ return Result.err(ValidationError.create("manifest", "Manifest file does not match expected schema"));
48
+ }
49
+ return Result.ok(validated.data);
50
+ }
51
+ async function writeManifest(cwd, manifest) {
52
+ const dirPath = join(cwd, OUTFITTER_DIR);
53
+ const path = join(dirPath, MANIFEST_FILE);
54
+ try {
55
+ const { mkdirSync, existsSync, statSync } = await import("fs");
56
+ if (existsSync(dirPath)) {
57
+ if (!statSync(dirPath).isDirectory()) {
58
+ return Result.err(ValidationError.create("manifest", ".outfitter exists but is not a directory"));
59
+ }
60
+ } else {
61
+ mkdirSync(dirPath, { recursive: true });
62
+ }
63
+ const content = JSON.stringify(manifest, null, "\t");
64
+ await Bun.write(path, `${content}
65
+ `);
66
+ return Result.ok(undefined);
67
+ } catch {
68
+ return Result.err(InternalError.create("Failed to write manifest file", { path }));
69
+ }
70
+ }
71
+ async function stampBlock(cwd, blockName, toolingVersion) {
72
+ const readResult = await readManifest(cwd);
73
+ if (readResult.isErr()) {
74
+ return readResult;
75
+ }
76
+ const existing = readResult.value;
77
+ const manifest = existing ?? { version: 1, blocks: {} };
78
+ const updated = {
79
+ ...manifest,
80
+ blocks: {
81
+ ...manifest.blocks,
82
+ [blockName]: {
83
+ installedFrom: toolingVersion,
84
+ installedAt: new Date().toISOString()
85
+ }
86
+ }
87
+ };
88
+ return writeManifest(cwd, updated);
89
+ }
90
+
91
+ export { BlockEntrySchema, ManifestSchema, readManifest, writeManifest, stampBlock };