outfitter 0.3.2 → 0.3.4
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 +33 -5
- package/dist/actions/add.d.ts +18 -0
- package/dist/actions/add.js +14 -0
- package/dist/actions/check-automation.d.ts +20 -0
- package/dist/actions/check-automation.js +27 -0
- package/dist/actions/check.d.ts +34 -0
- package/dist/actions/check.js +19 -0
- package/dist/actions/demo.d.ts +12 -0
- package/dist/actions/demo.js +11 -0
- package/dist/actions/docs-output-mode.d.ts +4 -0
- package/dist/actions/docs-output-mode.js +8 -0
- package/dist/actions/docs.d.ts +25 -0
- package/dist/actions/docs.js +31 -0
- package/dist/actions/doctor.d.ts +10 -0
- package/dist/actions/doctor.js +15 -0
- package/dist/actions/init.d.ts +28 -0
- package/dist/actions/init.js +31 -0
- package/dist/actions/scaffold.d.ts +19 -0
- package/dist/actions/scaffold.js +21 -0
- package/dist/actions/shared.d.ts +61 -0
- package/dist/actions/shared.js +30 -0
- package/dist/actions/upgrade.d.ts +17 -0
- package/dist/actions/upgrade.js +21 -0
- package/dist/actions.d.ts +2 -0
- package/dist/actions.js +66 -0
- package/dist/cli.js +66 -4
- package/dist/commands/add.d.ts +54 -0
- package/dist/commands/add.js +16 -0
- package/dist/commands/check-action-ceremony.d.ts +55 -0
- package/dist/commands/check-action-ceremony.js +15 -0
- package/dist/commands/check-docs-sentinel.d.ts +27 -0
- package/dist/commands/check-docs-sentinel.js +18 -0
- package/dist/commands/check-orchestrator.d.ts +2 -0
- package/dist/commands/check-orchestrator.js +17 -0
- package/dist/commands/check-preset-versions.d.ts +20 -0
- package/dist/commands/check-preset-versions.js +15 -0
- package/dist/commands/check-publish-guardrails.d.ts +38 -0
- package/dist/commands/check-publish-guardrails.js +19 -0
- package/dist/commands/check-surface-map-format.d.ts +29 -0
- package/dist/commands/check-surface-map-format.js +19 -0
- package/dist/commands/check-surface-map.d.ts +20 -0
- package/dist/commands/check-surface-map.js +15 -0
- package/dist/commands/check-tsdoc.d.ts +3 -0
- package/dist/commands/check-tsdoc.js +9 -0
- package/dist/commands/check.d.ts +93 -0
- package/dist/commands/check.js +14 -0
- package/dist/commands/demo.d.ts +21 -0
- package/dist/commands/demo.js +8 -0
- package/dist/commands/docs-api.d.ts +4 -0
- package/dist/commands/docs-api.js +13 -0
- package/dist/commands/docs-export.d.ts +4 -0
- package/dist/commands/docs-export.js +12 -0
- package/dist/commands/docs-list.d.ts +3 -0
- package/dist/commands/docs-list.js +13 -0
- package/dist/commands/docs-module-loader.d.ts +2 -0
- package/dist/commands/docs-module-loader.js +8 -0
- package/dist/commands/docs-search.d.ts +3 -0
- package/dist/commands/docs-search.js +13 -0
- package/dist/commands/docs-show.d.ts +3 -0
- package/dist/commands/docs-show.js +13 -0
- package/dist/commands/docs-types.d.ts +21 -0
- package/dist/commands/docs-types.js +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +17 -0
- package/dist/commands/init-execution.d.ts +8 -0
- package/dist/commands/init-execution.js +11 -0
- package/dist/commands/init-option-resolution.d.ts +5 -0
- package/dist/commands/init-option-resolution.js +14 -0
- package/dist/commands/init-output.d.ts +9 -0
- package/dist/commands/init-output.js +11 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +24 -0
- package/dist/commands/jq-utils.d.ts +17 -0
- package/dist/commands/jq-utils.js +8 -0
- package/dist/commands/repo.d.ts +3 -0
- package/dist/commands/repo.js +13 -0
- package/dist/commands/scaffold-output.d.ts +4 -0
- package/dist/commands/scaffold-output.js +11 -0
- package/dist/commands/scaffold-planning.d.ts +65 -0
- package/dist/commands/scaffold-planning.js +20 -0
- package/dist/commands/scaffold.d.ts +4 -0
- package/dist/commands/scaffold.js +26 -0
- package/dist/commands/shared-deps.d.ts +22 -0
- package/dist/commands/shared-deps.js +11 -0
- package/dist/commands/upgrade-apply.d.ts +14 -0
- package/dist/commands/upgrade-apply.js +8 -0
- package/dist/commands/upgrade-codemods.d.ts +47 -0
- package/dist/commands/upgrade-codemods.js +14 -0
- package/dist/commands/upgrade-latest-version.d.ts +8 -0
- package/dist/commands/upgrade-latest-version.js +8 -0
- package/dist/commands/upgrade-migration-docs.d.ts +3 -0
- package/dist/commands/upgrade-migration-docs.js +15 -0
- package/dist/commands/upgrade-migration-frontmatter.d.ts +2 -0
- package/dist/commands/upgrade-migration-frontmatter.js +10 -0
- package/dist/commands/upgrade-migration-guides.d.ts +5 -0
- package/dist/commands/upgrade-migration-guides.js +10 -0
- package/dist/commands/upgrade-output.d.ts +5 -0
- package/dist/commands/upgrade-output.js +11 -0
- package/dist/commands/upgrade-planner.d.ts +58 -0
- package/dist/commands/upgrade-planner.js +8 -0
- package/dist/commands/upgrade-report.d.ts +5 -0
- package/dist/commands/upgrade-report.js +8 -0
- package/dist/commands/upgrade-workspace.d.ts +2 -0
- package/dist/commands/upgrade-workspace.js +16 -0
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +37 -0
- package/dist/create/index.d.ts +5 -0
- package/dist/create/index.js +2 -0
- package/dist/create/planner.d.ts +3 -0
- package/dist/create/planner.js +85 -0
- package/dist/create/presets.d.ts +3 -0
- package/dist/create/presets.js +12 -0
- package/dist/create/types.d.ts +2 -0
- package/dist/create/types.js +1 -0
- package/dist/engine/blocks.d.ts +3 -0
- package/dist/engine/blocks.js +12 -0
- package/dist/engine/collector.d.ts +2 -0
- package/dist/engine/collector.js +8 -0
- package/dist/engine/config.d.ts +3 -0
- package/dist/engine/config.js +15 -0
- package/dist/engine/dependency-versions.d.ts +17 -0
- package/dist/engine/dependency-versions.js +12 -0
- package/dist/engine/executor.d.ts +3 -0
- package/dist/engine/executor.js +156 -0
- package/dist/engine/index.d.ts +10 -0
- package/dist/engine/index.js +54 -0
- package/dist/engine/names.d.ts +2 -0
- package/dist/engine/names.js +24 -0
- package/dist/engine/post-scaffold.d.ts +3 -0
- package/dist/engine/post-scaffold.js +8 -0
- package/dist/engine/preset.d.ts +3 -0
- package/dist/engine/preset.js +17 -0
- package/dist/engine/render-plan.d.ts +7 -0
- package/dist/engine/render-plan.js +9 -0
- package/dist/engine/template.d.ts +4 -0
- package/dist/engine/template.js +34 -0
- package/dist/engine/types.d.ts +2 -0
- package/dist/engine/types.js +8 -0
- package/dist/engine/workspace.d.ts +3 -0
- package/dist/engine/workspace.js +20 -0
- package/dist/index.d.ts +17 -397
- package/dist/index.js +7 -165
- package/dist/manifest.d.ts +71 -0
- package/dist/manifest.js +16 -0
- package/dist/output-mode.d.ts +2 -0
- package/dist/output-mode.js +10 -0
- package/dist/shared/outfitter-109s75x0.d.ts +76 -0
- package/dist/shared/outfitter-1fy7byz5.js +170 -0
- package/dist/shared/outfitter-1gmrtapz.js +325 -0
- package/dist/shared/outfitter-1h7k8xxt.js +29 -0
- package/dist/shared/outfitter-1tfa9hke.d.ts +55 -0
- package/dist/shared/outfitter-2nx0k4b3.d.ts +4 -0
- package/dist/shared/outfitter-2ysjerp6.d.ts +44 -0
- package/dist/shared/outfitter-2z61gp5w.js +29 -0
- package/dist/shared/outfitter-34vg353f.d.ts +82 -0
- package/dist/shared/outfitter-3dq4r10s.d.ts +24 -0
- package/dist/shared/outfitter-3rcrvva8.js +103 -0
- package/dist/shared/outfitter-3tx3adgj.js +278 -0
- package/dist/shared/outfitter-4q1zfmvc.js +154 -0
- package/dist/shared/outfitter-4s9meh3j.js +221 -0
- package/dist/shared/outfitter-507ra35w.js +285 -0
- package/dist/shared/outfitter-56jq0rh2.d.ts +42 -0
- package/dist/shared/outfitter-58rn1sj1.d.ts +30 -0
- package/dist/shared/outfitter-5d9wbzhh.d.ts +19 -0
- package/dist/shared/outfitter-5j7zee11.d.ts +180 -0
- package/dist/shared/outfitter-5r6q2749.d.ts +18 -0
- package/dist/shared/outfitter-5vx1bp7h.js +41 -0
- package/dist/shared/outfitter-6ddf91vh.js +190 -0
- package/dist/shared/outfitter-6mpkh3zn.js +432 -0
- package/dist/shared/outfitter-6rtcemk7.d.ts +18 -0
- package/dist/shared/outfitter-6t7xeyg1.js +159 -0
- package/dist/shared/outfitter-738z4c37.js +262 -0
- package/dist/shared/outfitter-76k25svs.js +322 -0
- package/dist/shared/outfitter-7n7vsz95.js +101 -0
- package/dist/shared/outfitter-7q9fnbwa.js +60 -0
- package/dist/shared/outfitter-7r12fj7f.js +30 -0
- package/dist/shared/outfitter-8ggmja91.js +301 -0
- package/dist/shared/outfitter-8kmak0wc.d.ts +4 -0
- package/dist/shared/outfitter-8y2dfx6n.js +11 -0
- package/dist/shared/outfitter-940h0x7b.js +71 -0
- package/dist/shared/outfitter-954y4mzx.d.ts +5 -0
- package/dist/shared/outfitter-a79xrm12.d.ts +17 -0
- package/dist/shared/outfitter-b9cpnr7e.js +110 -0
- package/dist/shared/outfitter-bpr28y54.js +70 -0
- package/dist/shared/outfitter-c7sbs7es.js +92 -0
- package/dist/shared/outfitter-cyhzstz0.js +93 -0
- package/dist/shared/outfitter-cyvr4r8d.d.ts +67 -0
- package/dist/shared/outfitter-d0kqashd.d.ts +98 -0
- package/dist/shared/outfitter-dmfac1w9.js +306 -0
- package/dist/shared/outfitter-e84cr97g.js +232 -0
- package/dist/shared/outfitter-ec83h4v2.js +17 -0
- package/dist/shared/outfitter-eepj7rf7.js +4 -0
- package/dist/shared/outfitter-ekb6t1zz.js +35 -0
- package/dist/shared/outfitter-ex8gn945.js +51 -0
- package/dist/shared/outfitter-f3a70135.js +75 -0
- package/dist/shared/outfitter-fbvfd5zq.d.ts +13 -0
- package/dist/shared/outfitter-fj2v5ffz.js +165 -0
- package/dist/shared/outfitter-fx1m251y.js +122 -0
- package/dist/shared/outfitter-fxry5n58.js +254 -0
- package/dist/shared/outfitter-g3hvjshg.js +1 -0
- package/dist/shared/outfitter-gdc7b7de.d.ts +5 -0
- package/dist/shared/outfitter-gyayfx5r.js +156 -0
- package/dist/shared/outfitter-h0wmtxw8.d.ts +23 -0
- package/dist/shared/outfitter-hcexcvxe.d.ts +25 -0
- package/dist/shared/outfitter-hf5bj2gq.js +117 -0
- package/dist/shared/outfitter-hsp8vy5m.d.ts +146 -0
- package/dist/shared/outfitter-htx4asgr.d.ts +52 -0
- package/dist/shared/outfitter-jwxggvz4.js +42 -0
- package/dist/shared/outfitter-ksyvwmb5.js +191 -0
- package/dist/shared/outfitter-m3ehh37q.d.ts +22 -0
- package/dist/shared/outfitter-mstr60zz.js +215 -0
- package/dist/shared/outfitter-n0ed012k.js +101 -0
- package/dist/shared/outfitter-n13pqaft.js +19 -0
- package/dist/shared/outfitter-nxvjxrmw.d.ts +48 -0
- package/dist/shared/outfitter-p2wn07b7.js +160 -0
- package/dist/shared/outfitter-px5sv5gn.js +321 -0
- package/dist/shared/outfitter-q1g58t85.js +8 -0
- package/dist/shared/outfitter-qsd5638j.js +378 -0
- package/dist/shared/outfitter-qsrx7m4w.js +72 -0
- package/dist/shared/outfitter-r2awqszh.d.ts +52 -0
- package/dist/shared/outfitter-rdpw2sbp.d.ts +77 -0
- package/dist/shared/outfitter-rp89dafm.js +109 -0
- package/dist/shared/outfitter-s1c0whzj.js +121 -0
- package/dist/shared/outfitter-ssrtakh3.js +342 -0
- package/dist/shared/outfitter-ssynegbs.js +167 -0
- package/dist/shared/outfitter-svts4wk2.js +36 -0
- package/dist/shared/outfitter-tavatb5p.js +166 -0
- package/dist/shared/outfitter-tqznjgbm.js +44 -0
- package/dist/shared/outfitter-ttjr95y9.js +98 -0
- package/dist/shared/outfitter-wcrp7d7m.d.ts +5 -0
- package/dist/shared/outfitter-wkt0a0ra.js +67 -0
- package/dist/shared/outfitter-wrcqq29p.js +132 -0
- package/dist/shared/outfitter-wyg1tpp5.d.ts +43 -0
- package/dist/shared/outfitter-x0vpb7tj.js +126 -0
- package/dist/shared/outfitter-x39awx8g.js +146 -0
- package/dist/shared/outfitter-x4cc5xsq.js +168 -0
- package/dist/shared/outfitter-x8w5sjnd.d.ts +39 -0
- package/dist/shared/outfitter-xr6g13nz.d.ts +50 -0
- package/dist/shared/outfitter-xs94pkfe.js +106 -0
- package/dist/shared/outfitter-xwzjgswj.js +488 -0
- package/dist/shared/outfitter-y37yfehn.d.ts +37 -0
- package/dist/shared/outfitter-y6ee0k45.d.ts +18 -0
- package/dist/shared/outfitter-ydw7x6bh.js +61 -0
- package/dist/shared/outfitter-yhb23pjc.js +89 -0
- package/dist/shared/outfitter-ypcvwg1s.js +91 -0
- package/dist/shared/outfitter-yywcypw8.js +53 -0
- package/dist/shared/outfitter-znbqe5zy.d.ts +45 -0
- package/dist/shared/outfitter-zng6w0t9.d.ts +4 -0
- package/dist/targets/index.d.ts +4 -0
- package/dist/targets/index.js +28 -0
- package/dist/targets/registry.d.ts +3 -0
- package/dist/targets/registry.js +221 -0
- package/dist/targets/types.d.ts +2 -0
- package/dist/targets/types.js +1 -0
- package/package.json +194 -35
- package/dist/shared/chunk-3pwh8ys4.js +0 -6461
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
actionInternalErr,
|
|
4
|
+
outputModeSchema,
|
|
5
|
+
resolveBooleanFlagAlias,
|
|
6
|
+
resolveInstallTimeoutFlag,
|
|
7
|
+
resolveLocalFlag,
|
|
8
|
+
resolveNoToolingFlag,
|
|
9
|
+
resolveStringFlag
|
|
10
|
+
} from "./outfitter-7n7vsz95.js";
|
|
11
|
+
import {
|
|
12
|
+
runInit
|
|
13
|
+
} from "./outfitter-6mpkh3zn.js";
|
|
14
|
+
import {
|
|
15
|
+
printInitResults
|
|
16
|
+
} from "./outfitter-n0ed012k.js";
|
|
17
|
+
import {
|
|
18
|
+
resolveOutputModeFromContext
|
|
19
|
+
} from "./outfitter-7r12fj7f.js";
|
|
20
|
+
|
|
21
|
+
// apps/outfitter/src/actions/init.ts
|
|
22
|
+
import { actionCliPresets } from "@outfitter/cli/actions";
|
|
23
|
+
import {
|
|
24
|
+
booleanFlagPreset,
|
|
25
|
+
dryRunPreset,
|
|
26
|
+
forcePreset
|
|
27
|
+
} from "@outfitter/cli/flags";
|
|
28
|
+
import {
|
|
29
|
+
defineAction,
|
|
30
|
+
InternalError,
|
|
31
|
+
Result
|
|
32
|
+
} from "@outfitter/contracts";
|
|
33
|
+
import { z } from "zod";
|
|
34
|
+
var initPresetValues = [
|
|
35
|
+
"minimal",
|
|
36
|
+
"cli",
|
|
37
|
+
"mcp",
|
|
38
|
+
"daemon",
|
|
39
|
+
"library",
|
|
40
|
+
"full-stack",
|
|
41
|
+
"lib"
|
|
42
|
+
];
|
|
43
|
+
function normalizeInitPreset(preset) {
|
|
44
|
+
if (preset === undefined) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return preset === "lib" ? "library" : preset;
|
|
48
|
+
}
|
|
49
|
+
var initInputSchema = z.object({
|
|
50
|
+
targetDir: z.string(),
|
|
51
|
+
name: z.string().optional(),
|
|
52
|
+
bin: z.string().optional(),
|
|
53
|
+
preset: z.enum(initPresetValues).optional(),
|
|
54
|
+
structure: z.enum(["single", "workspace"]).optional(),
|
|
55
|
+
workspaceName: z.string().optional(),
|
|
56
|
+
local: z.boolean().optional(),
|
|
57
|
+
force: z.boolean(),
|
|
58
|
+
with: z.string().optional(),
|
|
59
|
+
noTooling: z.boolean().optional(),
|
|
60
|
+
yes: z.boolean().optional(),
|
|
61
|
+
dryRun: z.boolean().optional(),
|
|
62
|
+
skipInstall: z.boolean().optional(),
|
|
63
|
+
skipGit: z.boolean().optional(),
|
|
64
|
+
skipCommit: z.boolean().optional(),
|
|
65
|
+
installTimeout: z.number().optional(),
|
|
66
|
+
outputMode: outputModeSchema
|
|
67
|
+
});
|
|
68
|
+
var commonInitOptions = [
|
|
69
|
+
{
|
|
70
|
+
flags: "-n, --name <name>",
|
|
71
|
+
description: "Package name (defaults to directory name)"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
flags: "-b, --bin <name>",
|
|
75
|
+
description: "Binary name (defaults to project name)"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
flags: "--local",
|
|
79
|
+
description: "Use workspace:* for @outfitter dependencies"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
flags: "--workspace",
|
|
83
|
+
description: "Alias for --local"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
flags: "--with <blocks>",
|
|
87
|
+
description: "Tooling to add (comma-separated: scaffolding, claude, linter, lefthook, bootstrap)"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
flags: "--no-tooling",
|
|
91
|
+
description: "Skip tooling setup"
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
var initSharedFlags = actionCliPresets(forcePreset(), dryRunPreset(), booleanFlagPreset({
|
|
95
|
+
id: "initYes",
|
|
96
|
+
key: "yes",
|
|
97
|
+
flags: "-y, --yes",
|
|
98
|
+
description: "Skip prompts and use defaults for missing values"
|
|
99
|
+
}));
|
|
100
|
+
function resolveInitOptions(context, presetOverride) {
|
|
101
|
+
const flags = context.flags;
|
|
102
|
+
const { force, dryRun, yes } = initSharedFlags.resolve(context);
|
|
103
|
+
const targetDir = context.args[0] ?? process.cwd();
|
|
104
|
+
const name = resolveStringFlag(flags.name);
|
|
105
|
+
const bin = resolveStringFlag(flags.bin);
|
|
106
|
+
const preset = normalizeInitPreset(presetOverride ?? resolveStringFlag(flags.preset));
|
|
107
|
+
const structure = resolveStringFlag(flags.structure);
|
|
108
|
+
const workspaceName = resolveStringFlag(flags.workspaceName);
|
|
109
|
+
const local = resolveLocalFlag(flags);
|
|
110
|
+
const withBlocks = resolveStringFlag(flags.with);
|
|
111
|
+
const noTooling = resolveNoToolingFlag(flags);
|
|
112
|
+
const skipInstall = resolveBooleanFlagAlias(context.flags, "skipInstall", "skip-install");
|
|
113
|
+
const skipGit = resolveBooleanFlagAlias(context.flags, "skipGit", "skip-git");
|
|
114
|
+
const skipCommit = resolveBooleanFlagAlias(context.flags, "skipCommit", "skip-commit");
|
|
115
|
+
const installTimeout = resolveInstallTimeoutFlag(flags.installTimeout);
|
|
116
|
+
const outputMode = resolveOutputModeFromContext(context.flags);
|
|
117
|
+
return {
|
|
118
|
+
targetDir,
|
|
119
|
+
name,
|
|
120
|
+
...preset ? { preset } : {},
|
|
121
|
+
...structure ? { structure } : {},
|
|
122
|
+
...workspaceName ? { workspaceName } : {},
|
|
123
|
+
force,
|
|
124
|
+
...local !== undefined ? { local } : {},
|
|
125
|
+
...withBlocks ? { with: withBlocks } : {},
|
|
126
|
+
...noTooling !== undefined ? { noTooling } : {},
|
|
127
|
+
...bin ? { bin } : {},
|
|
128
|
+
...yes ? { yes } : {},
|
|
129
|
+
...dryRun ? { dryRun } : {},
|
|
130
|
+
...skipInstall ? { skipInstall } : {},
|
|
131
|
+
...skipGit ? { skipGit } : {},
|
|
132
|
+
...skipCommit ? { skipCommit } : {},
|
|
133
|
+
...installTimeout !== undefined ? { installTimeout } : {},
|
|
134
|
+
outputMode
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function createInitAction(options) {
|
|
138
|
+
const presetOption = {
|
|
139
|
+
flags: "-p, --preset <preset>",
|
|
140
|
+
description: "Preset to use (minimal, cli, mcp, daemon, library, full-stack, lib)"
|
|
141
|
+
};
|
|
142
|
+
const initOptions = [...commonInitOptions];
|
|
143
|
+
initOptions.push(...initSharedFlags.options);
|
|
144
|
+
initOptions.push({
|
|
145
|
+
flags: "-s, --structure <mode>",
|
|
146
|
+
description: "Project structure (single|workspace)"
|
|
147
|
+
});
|
|
148
|
+
initOptions.push({
|
|
149
|
+
flags: "--workspace-name <name>",
|
|
150
|
+
description: "Workspace root package name"
|
|
151
|
+
});
|
|
152
|
+
initOptions.push({
|
|
153
|
+
flags: "--skip-install",
|
|
154
|
+
description: "Skip bun install",
|
|
155
|
+
defaultValue: false
|
|
156
|
+
});
|
|
157
|
+
initOptions.push({
|
|
158
|
+
flags: "--skip-git",
|
|
159
|
+
description: "Skip git init and initial commit",
|
|
160
|
+
defaultValue: false
|
|
161
|
+
});
|
|
162
|
+
initOptions.push({
|
|
163
|
+
flags: "--skip-commit",
|
|
164
|
+
description: "Skip initial commit only",
|
|
165
|
+
defaultValue: false
|
|
166
|
+
});
|
|
167
|
+
initOptions.push({
|
|
168
|
+
flags: "--install-timeout <ms>",
|
|
169
|
+
description: "bun install timeout in milliseconds"
|
|
170
|
+
});
|
|
171
|
+
if (options.includePresetOption) {
|
|
172
|
+
initOptions.push(presetOption);
|
|
173
|
+
}
|
|
174
|
+
return defineAction({
|
|
175
|
+
id: options.id,
|
|
176
|
+
description: options.description,
|
|
177
|
+
surfaces: ["cli"],
|
|
178
|
+
input: initInputSchema,
|
|
179
|
+
cli: {
|
|
180
|
+
group: "init",
|
|
181
|
+
command: options.command,
|
|
182
|
+
description: options.description,
|
|
183
|
+
options: initOptions,
|
|
184
|
+
mapInput: (context) => resolveInitOptions(context, options.presetOverride)
|
|
185
|
+
},
|
|
186
|
+
handler: async (input) => {
|
|
187
|
+
const { outputMode, ...initInput } = input;
|
|
188
|
+
const result = await runInit(initInput);
|
|
189
|
+
if (result.isErr()) {
|
|
190
|
+
return actionInternalErr(options.id, result.error);
|
|
191
|
+
}
|
|
192
|
+
await printInitResults(result.value, { mode: outputMode });
|
|
193
|
+
return Result.ok(result.value);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
var createAction = defineAction({
|
|
198
|
+
id: "create",
|
|
199
|
+
description: "Removed - use 'outfitter init' instead",
|
|
200
|
+
surfaces: ["cli"],
|
|
201
|
+
input: z.object({}).passthrough(),
|
|
202
|
+
cli: {
|
|
203
|
+
command: "create [directory]",
|
|
204
|
+
description: "Removed - use 'outfitter init' instead",
|
|
205
|
+
options: [],
|
|
206
|
+
mapInput: () => ({})
|
|
207
|
+
},
|
|
208
|
+
handler: async () => Result.err(new InternalError({
|
|
209
|
+
message: [
|
|
210
|
+
"The 'create' command has been removed.",
|
|
211
|
+
"",
|
|
212
|
+
"Use 'outfitter init' instead. It supports everything 'create' did:",
|
|
213
|
+
"",
|
|
214
|
+
" Interactive mode: outfitter init my-project",
|
|
215
|
+
" With preset: outfitter init my-project --preset cli",
|
|
216
|
+
" Skip prompts: outfitter init my-project --preset cli --yes",
|
|
217
|
+
" Workspace: outfitter init my-project --preset cli --structure workspace",
|
|
218
|
+
"",
|
|
219
|
+
"See 'outfitter init --help' for full options."
|
|
220
|
+
].join(`
|
|
221
|
+
`),
|
|
222
|
+
context: { action: "create" }
|
|
223
|
+
}))
|
|
224
|
+
});
|
|
225
|
+
var initAction = createInitAction({
|
|
226
|
+
id: "init",
|
|
227
|
+
description: "Create a new Outfitter project",
|
|
228
|
+
command: "[directory]",
|
|
229
|
+
includePresetOption: true
|
|
230
|
+
});
|
|
231
|
+
var initCliAction = createInitAction({
|
|
232
|
+
id: "init.cli",
|
|
233
|
+
description: "Create a new CLI project",
|
|
234
|
+
command: "cli [directory]",
|
|
235
|
+
presetOverride: "cli"
|
|
236
|
+
});
|
|
237
|
+
var initMcpAction = createInitAction({
|
|
238
|
+
id: "init.mcp",
|
|
239
|
+
description: "Create a new MCP server",
|
|
240
|
+
command: "mcp [directory]",
|
|
241
|
+
presetOverride: "mcp"
|
|
242
|
+
});
|
|
243
|
+
var initDaemonAction = createInitAction({
|
|
244
|
+
id: "init.daemon",
|
|
245
|
+
description: "Create a new daemon project",
|
|
246
|
+
command: "daemon [directory]",
|
|
247
|
+
presetOverride: "daemon"
|
|
248
|
+
});
|
|
249
|
+
var initLibraryAction = createInitAction({
|
|
250
|
+
id: "init.library",
|
|
251
|
+
description: "Create a new library project",
|
|
252
|
+
command: "library [directory]",
|
|
253
|
+
presetOverride: "library"
|
|
254
|
+
});
|
|
255
|
+
var initFullStackAction = createInitAction({
|
|
256
|
+
id: "init.full-stack",
|
|
257
|
+
description: "Create a full-stack workspace",
|
|
258
|
+
command: "full-stack [directory]",
|
|
259
|
+
presetOverride: "full-stack"
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
export { createAction, initAction, initCliAction, initMcpAction, initDaemonAction, initLibraryAction, initFullStackAction };
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// apps/outfitter/src/commands/upgrade-workspace.ts
|
|
3
|
+
import { existsSync, readFileSync } from "fs";
|
|
4
|
+
import { basename, dirname, join, resolve } from "path";
|
|
5
|
+
import { InternalError, Result } from "@outfitter/contracts";
|
|
6
|
+
function detectWorkspaceRoot(cwd) {
|
|
7
|
+
let current = resolve(cwd);
|
|
8
|
+
const root = resolve("/");
|
|
9
|
+
while (true) {
|
|
10
|
+
if (existsSync(join(current, "pnpm-workspace.yaml"))) {
|
|
11
|
+
return Result.ok(current);
|
|
12
|
+
}
|
|
13
|
+
const pkgPath = join(current, "package.json");
|
|
14
|
+
if (existsSync(pkgPath)) {
|
|
15
|
+
try {
|
|
16
|
+
const raw = readFileSync(pkgPath, "utf-8");
|
|
17
|
+
const pkg = JSON.parse(raw);
|
|
18
|
+
if (hasWorkspacesField(pkg)) {
|
|
19
|
+
return Result.ok(current);
|
|
20
|
+
}
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
if (current === root) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
const parent = dirname(current);
|
|
27
|
+
if (parent === current) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
current = parent;
|
|
31
|
+
}
|
|
32
|
+
return Result.ok(null);
|
|
33
|
+
}
|
|
34
|
+
function hasWorkspacesField(pkg) {
|
|
35
|
+
const workspaces = pkg.workspaces;
|
|
36
|
+
if (Array.isArray(workspaces) && workspaces.length > 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (workspaces && typeof workspaces === "object" && !Array.isArray(workspaces)) {
|
|
40
|
+
const packages = workspaces.packages;
|
|
41
|
+
if (Array.isArray(packages) && packages.length > 0) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
function resolveWorkspacePatterns(pkg) {
|
|
48
|
+
const workspaces = pkg.workspaces;
|
|
49
|
+
let patterns;
|
|
50
|
+
if (Array.isArray(workspaces)) {
|
|
51
|
+
patterns = workspaces;
|
|
52
|
+
} else if (workspaces && typeof workspaces === "object" && !Array.isArray(workspaces)) {
|
|
53
|
+
const packages = workspaces.packages;
|
|
54
|
+
if (Array.isArray(packages)) {
|
|
55
|
+
patterns = packages;
|
|
56
|
+
} else {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return patterns.filter((p) => typeof p === "string").map(normalizeWorkspacePattern);
|
|
63
|
+
}
|
|
64
|
+
function normalizeWorkspacePattern(pattern) {
|
|
65
|
+
let value = pattern.trim().replaceAll("\\", "/");
|
|
66
|
+
if (value.length === 0)
|
|
67
|
+
return value;
|
|
68
|
+
if (value.endsWith("/")) {
|
|
69
|
+
value = value.slice(0, -1);
|
|
70
|
+
}
|
|
71
|
+
if (value.endsWith("package.json")) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
return `${value}/package.json`;
|
|
75
|
+
}
|
|
76
|
+
function collectWorkspaceManifests(rootDir) {
|
|
77
|
+
const resolvedRoot = resolve(rootDir);
|
|
78
|
+
const rootPackageJson = join(resolvedRoot, "package.json");
|
|
79
|
+
if (!existsSync(rootPackageJson)) {
|
|
80
|
+
return Result.err(InternalError.create("No package.json found at workspace root", {
|
|
81
|
+
rootDir: resolvedRoot
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
let pkg;
|
|
85
|
+
try {
|
|
86
|
+
const raw = readFileSync(rootPackageJson, "utf-8");
|
|
87
|
+
pkg = JSON.parse(raw);
|
|
88
|
+
} catch {
|
|
89
|
+
return Result.err(InternalError.create("Invalid JSON in root package.json", {
|
|
90
|
+
rootDir: resolvedRoot
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
const workspacePatterns = resolveWorkspacePatterns(pkg);
|
|
94
|
+
const files = new Set([rootPackageJson]);
|
|
95
|
+
for (const pattern of workspacePatterns) {
|
|
96
|
+
if (pattern.length === 0)
|
|
97
|
+
continue;
|
|
98
|
+
const glob = new Bun.Glob(pattern);
|
|
99
|
+
for (const entry of glob.scanSync({ cwd: resolvedRoot })) {
|
|
100
|
+
const absolute = resolve(resolvedRoot, entry);
|
|
101
|
+
if (existsSync(absolute) && basename(absolute) === "package.json") {
|
|
102
|
+
files.add(absolute);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Result.ok(Array.from(files).toSorted((a, b) => a.localeCompare(b)));
|
|
107
|
+
}
|
|
108
|
+
function extractOutfitterDeps(manifestPath) {
|
|
109
|
+
let pkg;
|
|
110
|
+
try {
|
|
111
|
+
const raw = readFileSync(manifestPath, "utf-8");
|
|
112
|
+
pkg = JSON.parse(raw);
|
|
113
|
+
} catch {
|
|
114
|
+
return Result.err(InternalError.create("Failed to parse package.json", {
|
|
115
|
+
path: manifestPath
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
const deps = {
|
|
119
|
+
...pkg.dependencies,
|
|
120
|
+
...pkg.devDependencies
|
|
121
|
+
};
|
|
122
|
+
const packages = [];
|
|
123
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
124
|
+
if (!name.startsWith("@outfitter/"))
|
|
125
|
+
continue;
|
|
126
|
+
if (version.startsWith("workspace:")) {
|
|
127
|
+
const wsVersion = version.slice("workspace:".length);
|
|
128
|
+
if (wsVersion === "*" || wsVersion === "~" || wsVersion === "^") {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const wsClean = wsVersion.replace(/^[\^~>=<]+/, "");
|
|
132
|
+
try {
|
|
133
|
+
if (!Bun.semver.satisfies(wsClean, "*"))
|
|
134
|
+
continue;
|
|
135
|
+
} catch {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
packages.push({ name, version: wsClean });
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const cleaned = version.replace(/^[\^~>=<]+/, "");
|
|
142
|
+
try {
|
|
143
|
+
if (!Bun.semver.satisfies(cleaned, "*"))
|
|
144
|
+
continue;
|
|
145
|
+
} catch {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
packages.push({ name, version: cleaned });
|
|
149
|
+
}
|
|
150
|
+
return Result.ok(packages);
|
|
151
|
+
}
|
|
152
|
+
function getInstalledPackagesFromWorkspace(rootDir) {
|
|
153
|
+
const resolvedRoot = resolve(rootDir);
|
|
154
|
+
const wsRootResult = detectWorkspaceRoot(resolvedRoot);
|
|
155
|
+
if (wsRootResult.isErr())
|
|
156
|
+
return wsRootResult;
|
|
157
|
+
const effectiveRoot = wsRootResult.value ?? resolvedRoot;
|
|
158
|
+
let manifestPaths;
|
|
159
|
+
if (wsRootResult.value !== null) {
|
|
160
|
+
const manifestsResult = collectWorkspaceManifests(effectiveRoot);
|
|
161
|
+
if (manifestsResult.isErr())
|
|
162
|
+
return manifestsResult;
|
|
163
|
+
manifestPaths = manifestsResult.value;
|
|
164
|
+
} else {
|
|
165
|
+
const rootPkg = join(resolvedRoot, "package.json");
|
|
166
|
+
if (!existsSync(rootPkg)) {
|
|
167
|
+
return Result.err(InternalError.create("No package.json found", { cwd: resolvedRoot }));
|
|
168
|
+
}
|
|
169
|
+
manifestPaths = [rootPkg];
|
|
170
|
+
}
|
|
171
|
+
const packageVersionMap = new Map;
|
|
172
|
+
const manifestsByPackage = new Map;
|
|
173
|
+
for (const manifestPath of manifestPaths) {
|
|
174
|
+
const depsResult = extractOutfitterDeps(manifestPath);
|
|
175
|
+
if (depsResult.isErr())
|
|
176
|
+
return depsResult;
|
|
177
|
+
const deps = depsResult.value;
|
|
178
|
+
for (const dep of deps) {
|
|
179
|
+
let versionMap = packageVersionMap.get(dep.name);
|
|
180
|
+
if (!versionMap) {
|
|
181
|
+
versionMap = new Map;
|
|
182
|
+
packageVersionMap.set(dep.name, versionMap);
|
|
183
|
+
}
|
|
184
|
+
let manifests = versionMap.get(dep.version);
|
|
185
|
+
if (!manifests) {
|
|
186
|
+
manifests = [];
|
|
187
|
+
versionMap.set(dep.version, manifests);
|
|
188
|
+
}
|
|
189
|
+
manifests.push(manifestPath);
|
|
190
|
+
let pkgManifests = manifestsByPackage.get(dep.name);
|
|
191
|
+
if (!pkgManifests) {
|
|
192
|
+
pkgManifests = [];
|
|
193
|
+
manifestsByPackage.set(dep.name, pkgManifests);
|
|
194
|
+
}
|
|
195
|
+
pkgManifests.push(manifestPath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const packages = [];
|
|
199
|
+
const conflicts = [];
|
|
200
|
+
for (const [name, versionMap] of packageVersionMap) {
|
|
201
|
+
const versions = Array.from(versionMap.entries()).map(([version, manifests]) => ({ version, manifests })).toSorted((a, b) => {
|
|
202
|
+
try {
|
|
203
|
+
return Bun.semver.order(a.version, b.version);
|
|
204
|
+
} catch {
|
|
205
|
+
return a.version.localeCompare(b.version);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
if (versions.length > 1) {
|
|
209
|
+
conflicts.push({ name, versions });
|
|
210
|
+
}
|
|
211
|
+
const lowest = versions[0];
|
|
212
|
+
if (lowest) {
|
|
213
|
+
packages.push({ name, version: lowest.version });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
packages.sort((a, b) => a.name.localeCompare(b.name));
|
|
217
|
+
return Result.ok({
|
|
218
|
+
packages,
|
|
219
|
+
conflicts,
|
|
220
|
+
manifestsByPackage,
|
|
221
|
+
manifestPaths,
|
|
222
|
+
workspaceRoot: wsRootResult.value
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async function applyUpdatesToWorkspace(manifestPaths, manifestsByPackage, updates) {
|
|
226
|
+
const updateMap = new Map;
|
|
227
|
+
for (const u of updates) {
|
|
228
|
+
updateMap.set(u.name, u.latestVersion);
|
|
229
|
+
}
|
|
230
|
+
const manifestsToUpdate = new Set;
|
|
231
|
+
for (const u of updates) {
|
|
232
|
+
const manifests = manifestsByPackage.get(u.name);
|
|
233
|
+
if (manifests) {
|
|
234
|
+
for (const m of manifests) {
|
|
235
|
+
manifestsToUpdate.add(m);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (const manifestPath of manifestPaths) {
|
|
240
|
+
if (!manifestsToUpdate.has(manifestPath))
|
|
241
|
+
continue;
|
|
242
|
+
let raw;
|
|
243
|
+
try {
|
|
244
|
+
raw = readFileSync(manifestPath, "utf-8");
|
|
245
|
+
} catch {
|
|
246
|
+
return Result.err(InternalError.create("Failed to read package.json for apply", {
|
|
247
|
+
path: manifestPath
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
let pkg;
|
|
251
|
+
try {
|
|
252
|
+
pkg = JSON.parse(raw);
|
|
253
|
+
} catch {
|
|
254
|
+
return Result.err(InternalError.create("Invalid JSON in package.json", {
|
|
255
|
+
path: manifestPath
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
let changed = false;
|
|
259
|
+
for (const section of ["dependencies", "devDependencies"]) {
|
|
260
|
+
const deps = pkg[section];
|
|
261
|
+
if (!deps)
|
|
262
|
+
continue;
|
|
263
|
+
for (const name of Object.keys(deps)) {
|
|
264
|
+
const newVersion = updateMap.get(name);
|
|
265
|
+
if (newVersion === undefined)
|
|
266
|
+
continue;
|
|
267
|
+
const currentSpecifier = deps[name];
|
|
268
|
+
if (currentSpecifier === undefined)
|
|
269
|
+
continue;
|
|
270
|
+
if (currentSpecifier.startsWith("workspace:") && ["*", "~", "^"].includes(currentSpecifier.slice("workspace:".length))) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const prefix = getVersionPrefix(currentSpecifier);
|
|
274
|
+
deps[name] = `${prefix}${newVersion}`;
|
|
275
|
+
changed = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (changed) {
|
|
279
|
+
try {
|
|
280
|
+
const updated = `${JSON.stringify(pkg, null, 2)}
|
|
281
|
+
`;
|
|
282
|
+
await Bun.write(manifestPath, updated);
|
|
283
|
+
} catch {
|
|
284
|
+
return Result.err(InternalError.create("Failed to write updated package.json", {
|
|
285
|
+
path: manifestPath
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return Result.ok(undefined);
|
|
291
|
+
}
|
|
292
|
+
function getVersionPrefix(specifier) {
|
|
293
|
+
if (specifier.startsWith("workspace:")) {
|
|
294
|
+
const inner = specifier.slice("workspace:".length);
|
|
295
|
+
return `workspace:${getVersionPrefix(inner)}`;
|
|
296
|
+
}
|
|
297
|
+
const match = specifier.match(/^([\^~>=<]+)/);
|
|
298
|
+
return match?.[1] ?? "";
|
|
299
|
+
}
|
|
300
|
+
async function runInstall(cwd) {
|
|
301
|
+
try {
|
|
302
|
+
const proc = Bun.spawn(["bun", "install"], {
|
|
303
|
+
cwd,
|
|
304
|
+
stdout: "pipe",
|
|
305
|
+
stderr: "pipe"
|
|
306
|
+
});
|
|
307
|
+
const exitCode = await proc.exited;
|
|
308
|
+
if (exitCode !== 0) {
|
|
309
|
+
const stderr = await new Response(proc.stderr).text();
|
|
310
|
+
return Result.err(InternalError.create("bun install failed", {
|
|
311
|
+
cwd,
|
|
312
|
+
exitCode,
|
|
313
|
+
stderr: stderr.trim()
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
} catch {
|
|
317
|
+
return Result.err(InternalError.create("Failed to run bun install", { cwd }));
|
|
318
|
+
}
|
|
319
|
+
return Result.ok(undefined);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export { detectWorkspaceRoot, collectWorkspaceManifests, getInstalledPackagesFromWorkspace, applyUpdatesToWorkspace, runInstall };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// apps/outfitter/src/actions/shared.ts
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import { InternalError, Result } from "@outfitter/contracts";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
var outputModeSchema = z.enum(["human", "json", "jsonl"]).default("human");
|
|
7
|
+
function argvContainsOutputFlag(argv) {
|
|
8
|
+
for (let index = 0;index < argv.length; index++) {
|
|
9
|
+
const arg = argv[index];
|
|
10
|
+
if (!arg) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (arg === "-o" || arg === "--output") {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (arg.startsWith("--output=") || arg.startsWith("-o=")) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
function hasExplicitOutputFlag(flags, options = {}) {
|
|
23
|
+
const mode = flags["output"];
|
|
24
|
+
if (typeof mode !== "string") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const defaultMode = options.defaultMode ?? "human";
|
|
28
|
+
if (mode !== defaultMode) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return argvContainsOutputFlag(options.argv ?? process.argv.slice(2));
|
|
32
|
+
}
|
|
33
|
+
function resolveStringFlag(value) {
|
|
34
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
35
|
+
}
|
|
36
|
+
function resolveNoToolingFlag(flags) {
|
|
37
|
+
if (typeof flags.noTooling === "boolean") {
|
|
38
|
+
return !flags.noTooling;
|
|
39
|
+
}
|
|
40
|
+
if (typeof flags.tooling === "boolean") {
|
|
41
|
+
if (!flags.tooling) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return process.argv.includes("--tooling") ? false : undefined;
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
function resolveLocalFlag(flags) {
|
|
49
|
+
if (flags.local === true || flags.workspace === true) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
function resolveInstallTimeoutFlag(value) {
|
|
55
|
+
if (typeof value === "string") {
|
|
56
|
+
return Number.parseInt(value, 10);
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === "number") {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
function resolveCwdFromPreset(flags, cwdPreset) {
|
|
64
|
+
const { cwd: rawCwd } = cwdPreset.resolve(flags);
|
|
65
|
+
return resolve(process.cwd(), rawCwd);
|
|
66
|
+
}
|
|
67
|
+
function resolveOutputModeWithEnvFallback(flags, explicitMode, options = {}) {
|
|
68
|
+
if (hasExplicitOutputFlag(flags)) {
|
|
69
|
+
return explicitMode;
|
|
70
|
+
}
|
|
71
|
+
if (options.forceHumanWhenImplicit) {
|
|
72
|
+
return "human";
|
|
73
|
+
}
|
|
74
|
+
if (process.env["OUTFITTER_JSONL"] === "1") {
|
|
75
|
+
return "jsonl";
|
|
76
|
+
}
|
|
77
|
+
if (process.env["OUTFITTER_JSON"] === "1") {
|
|
78
|
+
return "json";
|
|
79
|
+
}
|
|
80
|
+
return "human";
|
|
81
|
+
}
|
|
82
|
+
function resolveBooleanFlagAlias(flags, key, alias) {
|
|
83
|
+
return Boolean(flags[key] ?? flags[alias]);
|
|
84
|
+
}
|
|
85
|
+
function toActionInternalError(action, error) {
|
|
86
|
+
return new InternalError({
|
|
87
|
+
message: error.message,
|
|
88
|
+
context: { action }
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function actionInternalErr(action, error) {
|
|
92
|
+
return Result.err(toActionInternalError(action, error));
|
|
93
|
+
}
|
|
94
|
+
function toActionInternalErrorFromUnknown(action, error, fallbackMessage) {
|
|
95
|
+
return new InternalError({
|
|
96
|
+
message: error instanceof Error ? error.message : fallbackMessage,
|
|
97
|
+
context: { action }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { outputModeSchema, hasExplicitOutputFlag, resolveStringFlag, resolveNoToolingFlag, resolveLocalFlag, resolveInstallTimeoutFlag, resolveCwdFromPreset, resolveOutputModeWithEnvFallback, resolveBooleanFlagAlias, toActionInternalError, actionInternalErr, toActionInternalErrorFromUnknown };
|