@ontrails/trails 1.0.0-beta.15 → 1.0.0-beta.17
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/CHANGELOG.md +215 -2
- package/README.md +27 -0
- package/package.json +21 -8
- package/src/app.ts +15 -5
- package/src/cli.ts +303 -10
- package/src/completions.ts +240 -0
- package/src/load-app-mirror.ts +160 -0
- package/src/local-state-io.ts +153 -0
- package/src/project-writes.ts +320 -0
- package/src/run-collision.ts +125 -0
- package/src/run-completions-install.ts +179 -0
- package/src/run-example.ts +149 -0
- package/src/run-examples.ts +148 -0
- package/src/run-quiet.ts +75 -0
- package/src/run-trace.ts +273 -0
- package/src/run-warden.ts +39 -0
- package/src/run-watch.ts +432 -0
- package/src/scaffold-versions.generated.ts +12 -0
- package/src/trails/add-surface.ts +45 -23
- package/src/trails/add-trail.ts +27 -17
- package/src/trails/add-verify.ts +57 -17
- package/src/trails/completions-complete.ts +165 -0
- package/src/trails/completions.ts +47 -0
- package/src/trails/create-scaffold.ts +86 -33
- package/src/trails/create.ts +11 -3
- package/src/trails/dev-clean.ts +6 -1
- package/src/trails/dev-reset.ts +6 -1
- package/src/trails/dev-stats.ts +6 -1
- package/src/trails/dev-support.ts +29 -17
- package/src/trails/draft-promote.ts +289 -80
- package/src/trails/guide.ts +54 -34
- package/src/trails/load-app.ts +251 -56
- package/src/trails/root-dir.ts +21 -0
- package/src/trails/run-example.ts +482 -0
- package/src/trails/run-examples.ts +141 -0
- package/src/trails/run.ts +403 -0
- package/src/trails/survey.ts +534 -200
- package/src/trails/topo-activation.ts +385 -0
- package/src/trails/topo-compile.ts +55 -0
- package/src/trails/topo-history.ts +6 -1
- package/src/trails/topo-output-schemas.ts +219 -0
- package/src/trails/topo-pin.ts +19 -6
- package/src/trails/topo-read-support.ts +171 -228
- package/src/trails/topo-reports.ts +587 -25
- package/src/trails/topo-store-support.ts +43 -19
- package/src/trails/topo-support.ts +18 -28
- package/src/trails/topo-unpin.ts +6 -1
- package/src/trails/topo-verify.ts +18 -5
- package/src/trails/topo.ts +60 -23
- package/src/trails/warden-guide.ts +121 -0
- package/src/trails/warden.ts +137 -56
- package/src/versions.ts +3 -18
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/__tests__/examples.test.ts +0 -45
- package/dist/bin/trails.d.ts +0 -3
- package/dist/bin/trails.d.ts.map +0 -1
- package/dist/bin/trails.js +0 -4
- package/dist/bin/trails.js.map +0 -1
- package/dist/src/app.d.ts +0 -2
- package/dist/src/app.d.ts.map +0 -1
- package/dist/src/app.js +0 -22
- package/dist/src/app.js.map +0 -1
- package/dist/src/clack.d.ts +0 -9
- package/dist/src/clack.d.ts.map +0 -1
- package/dist/src/clack.js +0 -84
- package/dist/src/clack.js.map +0 -1
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -14
- package/dist/src/cli.js.map +0 -1
- package/dist/src/trails/add-surface.d.ts +0 -13
- package/dist/src/trails/add-surface.d.ts.map +0 -1
- package/dist/src/trails/add-surface.js +0 -110
- package/dist/src/trails/add-surface.js.map +0 -1
- package/dist/src/trails/add-trail.d.ts +0 -12
- package/dist/src/trails/add-trail.d.ts.map +0 -1
- package/dist/src/trails/add-trail.js +0 -104
- package/dist/src/trails/add-trail.js.map +0 -1
- package/dist/src/trails/add-trailhead.d.ts +0 -13
- package/dist/src/trails/add-trailhead.d.ts.map +0 -1
- package/dist/src/trails/add-trailhead.js +0 -88
- package/dist/src/trails/add-trailhead.js.map +0 -1
- package/dist/src/trails/add-verify.d.ts +0 -10
- package/dist/src/trails/add-verify.d.ts.map +0 -1
- package/dist/src/trails/add-verify.js +0 -68
- package/dist/src/trails/add-verify.js.map +0 -1
- package/dist/src/trails/create-scaffold.d.ts +0 -15
- package/dist/src/trails/create-scaffold.d.ts.map +0 -1
- package/dist/src/trails/create-scaffold.js +0 -295
- package/dist/src/trails/create-scaffold.js.map +0 -1
- package/dist/src/trails/create.d.ts +0 -18
- package/dist/src/trails/create.d.ts.map +0 -1
- package/dist/src/trails/create.js +0 -126
- package/dist/src/trails/create.js.map +0 -1
- package/dist/src/trails/dev-clean.d.ts +0 -9
- package/dist/src/trails/dev-clean.d.ts.map +0 -1
- package/dist/src/trails/dev-clean.js +0 -66
- package/dist/src/trails/dev-clean.js.map +0 -1
- package/dist/src/trails/dev-reset.d.ts +0 -6
- package/dist/src/trails/dev-reset.d.ts.map +0 -1
- package/dist/src/trails/dev-reset.js +0 -39
- package/dist/src/trails/dev-reset.js.map +0 -1
- package/dist/src/trails/dev-stats.d.ts +0 -7
- package/dist/src/trails/dev-stats.d.ts.map +0 -1
- package/dist/src/trails/dev-stats.js +0 -61
- package/dist/src/trails/dev-stats.js.map +0 -1
- package/dist/src/trails/dev-support.d.ts +0 -64
- package/dist/src/trails/dev-support.d.ts.map +0 -1
- package/dist/src/trails/dev-support.js +0 -181
- package/dist/src/trails/dev-support.js.map +0 -1
- package/dist/src/trails/draft-promote.d.ts +0 -18
- package/dist/src/trails/draft-promote.d.ts.map +0 -1
- package/dist/src/trails/draft-promote.js +0 -400
- package/dist/src/trails/draft-promote.js.map +0 -1
- package/dist/src/trails/guide.d.ts +0 -21
- package/dist/src/trails/guide.d.ts.map +0 -1
- package/dist/src/trails/guide.js +0 -61
- package/dist/src/trails/guide.js.map +0 -1
- package/dist/src/trails/load-app.d.ts +0 -12
- package/dist/src/trails/load-app.d.ts.map +0 -1
- package/dist/src/trails/load-app.js +0 -415
- package/dist/src/trails/load-app.js.map +0 -1
- package/dist/src/trails/project.d.ts +0 -8
- package/dist/src/trails/project.d.ts.map +0 -1
- package/dist/src/trails/project.js +0 -54
- package/dist/src/trails/project.js.map +0 -1
- package/dist/src/trails/survey.d.ts +0 -18
- package/dist/src/trails/survey.d.ts.map +0 -1
- package/dist/src/trails/survey.js +0 -234
- package/dist/src/trails/survey.js.map +0 -1
- package/dist/src/trails/topo-constants.d.ts +0 -3
- package/dist/src/trails/topo-constants.d.ts.map +0 -1
- package/dist/src/trails/topo-constants.js +0 -3
- package/dist/src/trails/topo-constants.js.map +0 -1
- package/dist/src/trails/topo-export.d.ts +0 -19
- package/dist/src/trails/topo-export.d.ts.map +0 -1
- package/dist/src/trails/topo-export.js +0 -31
- package/dist/src/trails/topo-export.js.map +0 -1
- package/dist/src/trails/topo-history.d.ts +0 -20
- package/dist/src/trails/topo-history.d.ts.map +0 -1
- package/dist/src/trails/topo-history.js +0 -32
- package/dist/src/trails/topo-history.js.map +0 -1
- package/dist/src/trails/topo-pin.d.ts +0 -17
- package/dist/src/trails/topo-pin.d.ts.map +0 -1
- package/dist/src/trails/topo-pin.js +0 -31
- package/dist/src/trails/topo-pin.js.map +0 -1
- package/dist/src/trails/topo-read-support.d.ts +0 -58
- package/dist/src/trails/topo-read-support.d.ts.map +0 -1
- package/dist/src/trails/topo-read-support.js +0 -167
- package/dist/src/trails/topo-read-support.js.map +0 -1
- package/dist/src/trails/topo-reports.d.ts +0 -54
- package/dist/src/trails/topo-reports.d.ts.map +0 -1
- package/dist/src/trails/topo-reports.js +0 -128
- package/dist/src/trails/topo-reports.js.map +0 -1
- package/dist/src/trails/topo-show.d.ts +0 -23
- package/dist/src/trails/topo-show.d.ts.map +0 -1
- package/dist/src/trails/topo-show.js +0 -49
- package/dist/src/trails/topo-show.js.map +0 -1
- package/dist/src/trails/topo-store-support.d.ts +0 -13
- package/dist/src/trails/topo-store-support.d.ts.map +0 -1
- package/dist/src/trails/topo-store-support.js +0 -55
- package/dist/src/trails/topo-store-support.js.map +0 -1
- package/dist/src/trails/topo-support.d.ts +0 -76
- package/dist/src/trails/topo-support.d.ts.map +0 -1
- package/dist/src/trails/topo-support.js +0 -132
- package/dist/src/trails/topo-support.js.map +0 -1
- package/dist/src/trails/topo-unpin.d.ts +0 -20
- package/dist/src/trails/topo-unpin.d.ts.map +0 -1
- package/dist/src/trails/topo-unpin.js +0 -44
- package/dist/src/trails/topo-unpin.js.map +0 -1
- package/dist/src/trails/topo-verify.d.ts +0 -5
- package/dist/src/trails/topo-verify.d.ts.map +0 -1
- package/dist/src/trails/topo-verify.js +0 -24
- package/dist/src/trails/topo-verify.js.map +0 -1
- package/dist/src/trails/topo.d.ts +0 -5
- package/dist/src/trails/topo.d.ts.map +0 -1
- package/dist/src/trails/topo.js +0 -63
- package/dist/src/trails/topo.js.map +0 -1
- package/dist/src/trails/warden.d.ts +0 -20
- package/dist/src/trails/warden.d.ts.map +0 -1
- package/dist/src/trails/warden.js +0 -98
- package/dist/src/trails/warden.js.map +0 -1
- package/dist/src/versions.d.ts +0 -12
- package/dist/src/versions.d.ts.map +0 -1
- package/dist/src/versions.js +0 -23
- package/dist/src/versions.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/__tests__/add-trail.test.ts +0 -97
- package/src/__tests__/create.test.ts +0 -415
- package/src/__tests__/draft-promote.test.ts +0 -144
- package/src/__tests__/guide.test.ts +0 -96
- package/src/__tests__/load-app.test.ts +0 -419
- package/src/__tests__/survey.test.ts +0 -377
- package/src/__tests__/topo-dev.test.ts +0 -426
- package/src/__tests__/warden.test.ts +0 -74
- package/src/trails/topo-export.ts +0 -35
- package/src/trails/topo-show.ts +0 -54
- package/tsconfig.json +0 -9
- package/tsconfig.tests.json +0 -10
package/src/trails/warden.ts
CHANGED
|
@@ -1,59 +1,159 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `warden` trail -- Governance checks.
|
|
3
3
|
*
|
|
4
|
-
* Thin wrapper around
|
|
4
|
+
* Thin wrapper around the shared @ontrails/warden command surface.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Result, trail } from '@ontrails/core';
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
diagnosticSchema,
|
|
10
|
+
runWardenCommand,
|
|
11
|
+
wardenDepthValues,
|
|
12
|
+
wardenDraftsValues,
|
|
13
|
+
wardenFailOnValues,
|
|
14
|
+
wardenFormatValues,
|
|
15
|
+
wardenLockValues,
|
|
14
16
|
} from '@ontrails/warden';
|
|
15
17
|
import { z } from 'zod';
|
|
16
18
|
|
|
17
|
-
import {
|
|
19
|
+
import { resolveTrailRootDir } from './root-dir.js';
|
|
18
20
|
|
|
19
21
|
// ---------------------------------------------------------------------------
|
|
20
22
|
// Trail definition
|
|
21
23
|
// ---------------------------------------------------------------------------
|
|
22
24
|
|
|
25
|
+
const wardenInputSchema = z.object({
|
|
26
|
+
apps: z
|
|
27
|
+
.array(z.string())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('App names or module paths to govern'),
|
|
30
|
+
cached: z.boolean().default(false).describe('Alias for --lock cached'),
|
|
31
|
+
ci: z.boolean().default(false).describe('Use the CI Warden preset'),
|
|
32
|
+
configPath: z.string().optional().describe('Path to trails.config.ts'),
|
|
33
|
+
depth: z
|
|
34
|
+
.enum(wardenDepthValues)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Cumulative analysis depth'),
|
|
37
|
+
drafts: z.enum(wardenDraftsValues).optional().describe('Draft state mode'),
|
|
38
|
+
excludeDrafts: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.default(false)
|
|
41
|
+
.describe('Alias for --drafts exclude'),
|
|
42
|
+
failOn: z.enum(wardenFailOnValues).optional().describe('Failure threshold'),
|
|
43
|
+
format: z.enum(wardenFormatValues).optional().describe('Output format'),
|
|
44
|
+
github: z.boolean().default(false).describe('Alias for --format github'),
|
|
45
|
+
includeDrafts: z
|
|
46
|
+
.boolean()
|
|
47
|
+
.default(false)
|
|
48
|
+
.describe('Alias for --drafts include'),
|
|
49
|
+
json: z.boolean().default(false).describe('Alias for --format json'),
|
|
50
|
+
lock: z.enum(wardenLockValues).optional().describe('Lockfile mode'),
|
|
51
|
+
noLockMutation: z
|
|
52
|
+
.boolean()
|
|
53
|
+
.default(false)
|
|
54
|
+
.describe('Suppress lockfile mutation'),
|
|
55
|
+
onlyDrafts: z.boolean().default(false).describe('Alias for --drafts only'),
|
|
56
|
+
prePush: z.boolean().default(false).describe('Use the pre-push preset'),
|
|
57
|
+
refresh: z.boolean().default(false).describe('Alias for --lock refresh'),
|
|
58
|
+
rootDir: z.string().optional().describe('Root directory to scan'),
|
|
59
|
+
skipLock: z.boolean().default(false).describe('Alias for --lock skip'),
|
|
60
|
+
strict: z.boolean().default(false).describe('Alias for --fail-on warning'),
|
|
61
|
+
summary: z.boolean().default(false).describe('Alias for --format summary'),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
type WardenTrailInput = z.infer<typeof wardenInputSchema>;
|
|
65
|
+
|
|
66
|
+
const pushFlag = (args: string[], condition: boolean, flag: string): void => {
|
|
67
|
+
if (condition) {
|
|
68
|
+
args.push(flag);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const pushValue = (
|
|
73
|
+
args: string[],
|
|
74
|
+
flag: string,
|
|
75
|
+
value: string | undefined
|
|
76
|
+
): void => {
|
|
77
|
+
if (value !== undefined) {
|
|
78
|
+
args.push(flag, value);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const pushApps = (
|
|
83
|
+
args: string[],
|
|
84
|
+
apps: readonly string[] | undefined
|
|
85
|
+
): void => {
|
|
86
|
+
if (apps !== undefined && apps.length > 0) {
|
|
87
|
+
args.push('--apps', apps.join(','));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const buildWardenCommandArgs = (
|
|
92
|
+
input: WardenTrailInput
|
|
93
|
+
): readonly string[] => {
|
|
94
|
+
const args: string[] = [];
|
|
95
|
+
|
|
96
|
+
pushFlag(args, input.prePush, '--pre-push');
|
|
97
|
+
pushFlag(args, input.ci, '--ci');
|
|
98
|
+
pushValue(args, '--depth', input.depth);
|
|
99
|
+
if (input.strict) {
|
|
100
|
+
args.push('--strict');
|
|
101
|
+
} else {
|
|
102
|
+
pushValue(args, '--fail-on', input.failOn);
|
|
103
|
+
}
|
|
104
|
+
if (input.github) {
|
|
105
|
+
args.push('--github');
|
|
106
|
+
} else if (input.json) {
|
|
107
|
+
args.push('--json');
|
|
108
|
+
} else if (input.summary) {
|
|
109
|
+
args.push('--summary');
|
|
110
|
+
} else {
|
|
111
|
+
pushValue(args, '--format', input.format);
|
|
112
|
+
}
|
|
113
|
+
if (input.skipLock) {
|
|
114
|
+
args.push('--skip-lock');
|
|
115
|
+
} else if (input.refresh) {
|
|
116
|
+
args.push('--refresh');
|
|
117
|
+
} else if (input.cached) {
|
|
118
|
+
args.push('--cached');
|
|
119
|
+
} else {
|
|
120
|
+
pushValue(args, '--lock', input.lock);
|
|
121
|
+
}
|
|
122
|
+
if (input.onlyDrafts) {
|
|
123
|
+
args.push('--only-drafts');
|
|
124
|
+
} else if (input.excludeDrafts) {
|
|
125
|
+
args.push('--exclude-drafts');
|
|
126
|
+
} else if (input.includeDrafts) {
|
|
127
|
+
args.push('--include-drafts');
|
|
128
|
+
} else {
|
|
129
|
+
pushValue(args, '--drafts', input.drafts);
|
|
130
|
+
}
|
|
131
|
+
pushFlag(args, input.noLockMutation, '--no-lock-mutation');
|
|
132
|
+
pushValue(args, '--config-path', input.configPath);
|
|
133
|
+
pushApps(args, input.apps);
|
|
134
|
+
|
|
135
|
+
return args;
|
|
136
|
+
};
|
|
137
|
+
|
|
23
138
|
export const wardenTrail = trail('warden', {
|
|
24
139
|
blaze: async (input, ctx) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const report = await runWarden({
|
|
37
|
-
driftOnly: input.driftOnly,
|
|
38
|
-
lintOnly: input.lintOnly,
|
|
39
|
-
rootDir,
|
|
40
|
-
topo,
|
|
140
|
+
const rootDirResult = resolveTrailRootDir(input.rootDir, ctx.cwd);
|
|
141
|
+
if (rootDirResult.isErr()) {
|
|
142
|
+
return Result.err(rootDirResult.error);
|
|
143
|
+
}
|
|
144
|
+
const rootDir = rootDirResult.value;
|
|
145
|
+
const result = await runWardenCommand({
|
|
146
|
+
args: buildWardenCommandArgs(input),
|
|
147
|
+
cwd: rootDir,
|
|
148
|
+
env: ctx.env ?? {},
|
|
41
149
|
});
|
|
42
|
-
|
|
43
|
-
const formatters: Record<string, (r: typeof report) => string> = {
|
|
44
|
-
github: formatGitHubAnnotations,
|
|
45
|
-
json: formatJson,
|
|
46
|
-
summary: formatSummary,
|
|
47
|
-
text: formatWardenReport,
|
|
48
|
-
};
|
|
49
|
-
const formatter = formatters[input.format] ?? formatWardenReport;
|
|
50
|
-
const formatted = formatter(report);
|
|
150
|
+
const { report } = result;
|
|
51
151
|
|
|
52
152
|
return Result.ok({
|
|
53
|
-
diagnostics: report.diagnostics,
|
|
153
|
+
diagnostics: [...report.diagnostics],
|
|
54
154
|
drift: report.drift,
|
|
55
155
|
errorCount: report.errorCount,
|
|
56
|
-
formatted,
|
|
156
|
+
formatted: result.output,
|
|
57
157
|
passed: report.passed,
|
|
58
158
|
warnCount: report.warnCount,
|
|
59
159
|
});
|
|
@@ -62,8 +162,7 @@ export const wardenTrail = trail('warden', {
|
|
|
62
162
|
examples: [
|
|
63
163
|
{
|
|
64
164
|
input: {
|
|
65
|
-
|
|
66
|
-
lintOnly: false,
|
|
165
|
+
lock: 'skip',
|
|
67
166
|
},
|
|
68
167
|
name: 'Default warden run',
|
|
69
168
|
},
|
|
@@ -74,29 +173,11 @@ export const wardenTrail = trail('warden', {
|
|
|
74
173
|
name: 'GitHub Actions annotations',
|
|
75
174
|
},
|
|
76
175
|
],
|
|
77
|
-
input:
|
|
78
|
-
driftOnly: z.boolean().default(false).describe('Only run drift detection'),
|
|
79
|
-
format: z
|
|
80
|
-
.enum(['text', 'json', 'github', 'summary'])
|
|
81
|
-
.default('text')
|
|
82
|
-
.describe('Output format: text, json, github, or summary'),
|
|
83
|
-
lintOnly: z.boolean().default(false).describe('Only run lint rules'),
|
|
84
|
-
module: z
|
|
85
|
-
.string()
|
|
86
|
-
.optional()
|
|
87
|
-
.describe('App module path (auto-discovered if omitted)'),
|
|
88
|
-
rootDir: z.string().optional().describe('Root directory to scan'),
|
|
89
|
-
}),
|
|
176
|
+
input: wardenInputSchema,
|
|
90
177
|
intent: 'read',
|
|
91
178
|
output: z.object({
|
|
92
179
|
diagnostics: z.array(
|
|
93
|
-
z.
|
|
94
|
-
filePath: z.string(),
|
|
95
|
-
line: z.number(),
|
|
96
|
-
message: z.string(),
|
|
97
|
-
rule: z.string(),
|
|
98
|
-
severity: z.enum(['error', 'warn']),
|
|
99
|
-
})
|
|
180
|
+
diagnosticSchema.extend({ topoName: z.string().optional() })
|
|
100
181
|
),
|
|
101
182
|
drift: z
|
|
102
183
|
.object({
|
package/src/versions.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { scaffoldDependencyVersions } from './scaffold-versions.generated.js';
|
|
2
|
+
|
|
1
3
|
interface PackageJson {
|
|
2
|
-
readonly catalog?: Record<string, string>;
|
|
3
|
-
readonly dependencies?: Record<string, string>;
|
|
4
|
-
readonly devDependencies?: Record<string, string>;
|
|
5
4
|
readonly version?: string;
|
|
6
5
|
}
|
|
7
6
|
|
|
@@ -11,9 +10,6 @@ const readPackageJson = async (url: URL): Promise<PackageJson> =>
|
|
|
11
10
|
const appPackageJson = await readPackageJson(
|
|
12
11
|
new URL('../package.json', import.meta.url)
|
|
13
12
|
);
|
|
14
|
-
const rootPackageJson = await readPackageJson(
|
|
15
|
-
new URL('../../../package.json', import.meta.url)
|
|
16
|
-
);
|
|
17
13
|
|
|
18
14
|
const requireVersion = (value: string | undefined, label: string): string => {
|
|
19
15
|
if (typeof value !== 'string' || value.length === 0) {
|
|
@@ -22,9 +18,6 @@ const requireVersion = (value: string | undefined, label: string): string => {
|
|
|
22
18
|
return value;
|
|
23
19
|
};
|
|
24
20
|
|
|
25
|
-
const rootCatalog = rootPackageJson.catalog ?? {};
|
|
26
|
-
const rootDevDependencies = rootPackageJson.devDependencies ?? {};
|
|
27
|
-
|
|
28
21
|
export const trailsPackageVersion = requireVersion(
|
|
29
22
|
appPackageJson.version,
|
|
30
23
|
'@ontrails/trails'
|
|
@@ -32,12 +25,4 @@ export const trailsPackageVersion = requireVersion(
|
|
|
32
25
|
|
|
33
26
|
export const ontrailsPackageRange = `^${trailsPackageVersion}`;
|
|
34
27
|
|
|
35
|
-
export
|
|
36
|
-
bunTypes: requireVersion(rootDevDependencies['@types/bun'], '@types/bun'),
|
|
37
|
-
commander: requireVersion(rootCatalog['commander'], 'commander'),
|
|
38
|
-
lefthook: requireVersion(rootDevDependencies['lefthook'], 'lefthook'),
|
|
39
|
-
oxlint: requireVersion(rootDevDependencies['oxlint'], 'oxlint'),
|
|
40
|
-
typescript: requireVersion(rootDevDependencies['typescript'], 'typescript'),
|
|
41
|
-
ultracite: requireVersion(rootDevDependencies['ultracite'], 'ultracite'),
|
|
42
|
-
zod: requireVersion(rootCatalog['zod'], 'zod'),
|
|
43
|
-
} as const;
|
|
28
|
+
export { scaffoldDependencyVersions };
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc -b
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc --noEmit
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* oxlint-disable eslint-plugin-jest/require-hook -- testExamples registers tests at module scope */
|
|
2
|
-
import { afterAll, beforeAll } from 'bun:test';
|
|
3
|
-
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { join, resolve } from 'node:path';
|
|
5
|
-
|
|
6
|
-
import { testExamples } from '@ontrails/testing';
|
|
7
|
-
|
|
8
|
-
import { app } from '../src/app.js';
|
|
9
|
-
|
|
10
|
-
const trailsWorkspaceDir = resolve(import.meta.dir, '..', '.trails');
|
|
11
|
-
const trailsGitignorePath = join(trailsWorkspaceDir, '.gitignore');
|
|
12
|
-
const trailsWorkspaceSubdirs = ['config', 'dev', 'generated'] as const;
|
|
13
|
-
const trailsGitignore = `# Local config overrides
|
|
14
|
-
config/
|
|
15
|
-
|
|
16
|
-
# Development state
|
|
17
|
-
dev/
|
|
18
|
-
|
|
19
|
-
# Generated artifacts
|
|
20
|
-
generated/
|
|
21
|
-
|
|
22
|
-
# Shared Trails database
|
|
23
|
-
trails.db
|
|
24
|
-
trails.db-shm
|
|
25
|
-
trails.db-wal
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
const resetTrailsWorkspace = (): void => {
|
|
29
|
-
rmSync(trailsWorkspaceDir, { force: true, recursive: true });
|
|
30
|
-
mkdirSync(trailsWorkspaceDir, { recursive: true });
|
|
31
|
-
for (const subdir of trailsWorkspaceSubdirs) {
|
|
32
|
-
mkdirSync(join(trailsWorkspaceDir, subdir), { recursive: true });
|
|
33
|
-
}
|
|
34
|
-
writeFileSync(trailsGitignorePath, trailsGitignore);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
beforeAll(() => {
|
|
38
|
-
resetTrailsWorkspace();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterAll(() => {
|
|
42
|
-
resetTrailsWorkspace();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
testExamples(app);
|
package/dist/bin/trails.d.ts
DELETED
package/dist/bin/trails.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trails.d.ts","sourceRoot":"","sources":["../../bin/trails.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC"}
|
package/dist/bin/trails.js
DELETED
package/dist/bin/trails.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trails.js","sourceRoot":"","sources":["../../bin/trails.ts"],"names":[],"mappings":";AACA,mGAAmG;AACnG,OAAO,eAAe,CAAC"}
|
package/dist/src/app.d.ts
DELETED
package/dist/src/app.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,GAAG,+BAqBf,CAAC"}
|
package/dist/src/app.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { topo } from '@ontrails/core';
|
|
2
|
-
import * as addSurface from './trails/add-surface.js';
|
|
3
|
-
import * as addTrail from './trails/add-trail.js';
|
|
4
|
-
import * as addVerify from './trails/add-verify.js';
|
|
5
|
-
import * as create from './trails/create.js';
|
|
6
|
-
import * as createScaffold from './trails/create-scaffold.js';
|
|
7
|
-
import * as devClean from './trails/dev-clean.js';
|
|
8
|
-
import * as devReset from './trails/dev-reset.js';
|
|
9
|
-
import * as devStats from './trails/dev-stats.js';
|
|
10
|
-
import * as draftPromote from './trails/draft-promote.js';
|
|
11
|
-
import * as guide from './trails/guide.js';
|
|
12
|
-
import * as survey from './trails/survey.js';
|
|
13
|
-
import * as topoExport from './trails/topo-export.js';
|
|
14
|
-
import * as topoHistory from './trails/topo-history.js';
|
|
15
|
-
import * as topoPin from './trails/topo-pin.js';
|
|
16
|
-
import * as topoShow from './trails/topo-show.js';
|
|
17
|
-
import * as topoCommand from './trails/topo.js';
|
|
18
|
-
import * as topoUnpin from './trails/topo-unpin.js';
|
|
19
|
-
import * as topoVerify from './trails/topo-verify.js';
|
|
20
|
-
import * as warden from './trails/warden.js';
|
|
21
|
-
export const app = topo('trails', survey, topoCommand, topoShow, topoHistory, topoPin, topoUnpin, topoExport, topoVerify, devStats, devClean, devReset, guide, draftPromote, warden, create, createScaffold, addSurface, addVerify, addTrail);
|
|
22
|
-
//# sourceMappingURL=app.js.map
|
package/dist/src/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO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|
|
1
|
-
/**
|
|
2
|
-
* Clack-backed input resolver for the Trails CLI.
|
|
3
|
-
*
|
|
4
|
-
* This stays at the app layer so @ontrails/cli remains prompt-library agnostic.
|
|
5
|
-
*/
|
|
6
|
-
import type { InputResolver } from '@ontrails/cli';
|
|
7
|
-
/** Fill missing input by prompting with Clack when interactive. */
|
|
8
|
-
export declare const resolveInputWithClack: InputResolver;
|
|
9
|
-
//# sourceMappingURL=clack.d.ts.map
|
package/dist/src/clack.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clack.d.ts","sourceRoot":"","sources":["../../src/clack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAS,aAAa,EAAuB,MAAM,eAAe,CAAC;AAmF/E,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,EAAE,aAoBnC,CAAC"}
|
package/dist/src/clack.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clack-backed input resolver for the Trails CLI.
|
|
3
|
-
*
|
|
4
|
-
* This stays at the app layer so @ontrails/cli remains prompt-library agnostic.
|
|
5
|
-
*/
|
|
6
|
-
import { isInteractive } from '@ontrails/cli';
|
|
7
|
-
import * as clack from '@clack/prompts';
|
|
8
|
-
/** Check whether a field still needs input. */
|
|
9
|
-
const needsInput = (field, current) => current[field.name] === undefined &&
|
|
10
|
-
field.required &&
|
|
11
|
-
field.default === undefined;
|
|
12
|
-
/** Build Clack options from field options. */
|
|
13
|
-
const toClackOptions = (field) => field.options?.map((option) => ({
|
|
14
|
-
...(option.hint === undefined ? {} : { hint: option.hint }),
|
|
15
|
-
label: option.label ?? option.value,
|
|
16
|
-
value: option.value,
|
|
17
|
-
})) ?? [];
|
|
18
|
-
/** Normalize cancelled prompts to `undefined`. */
|
|
19
|
-
const cancelable = async (value) => await (clack.isCancel(value) ? undefined : value);
|
|
20
|
-
const fieldResolvers = {
|
|
21
|
-
boolean: async (field) => cancelable(await clack.confirm({
|
|
22
|
-
initialValue: field.default ?? false,
|
|
23
|
-
message: field.label,
|
|
24
|
-
})),
|
|
25
|
-
enum: async (field) => cancelable(await clack.select({
|
|
26
|
-
message: field.label,
|
|
27
|
-
options: toClackOptions(field),
|
|
28
|
-
})),
|
|
29
|
-
multiselect: async (field) => cancelable(await clack.multiselect({
|
|
30
|
-
initialValues: field.default ?? [],
|
|
31
|
-
message: field.label,
|
|
32
|
-
options: toClackOptions(field),
|
|
33
|
-
})),
|
|
34
|
-
number: async (field) => {
|
|
35
|
-
const raw = await clack.text({ message: field.label });
|
|
36
|
-
return clack.isCancel(raw) ? undefined : Number(raw);
|
|
37
|
-
},
|
|
38
|
-
'number[]': async (field) => {
|
|
39
|
-
const raw = await clack.text({
|
|
40
|
-
message: `${field.label} (comma-separated numbers)`,
|
|
41
|
-
});
|
|
42
|
-
if (clack.isCancel(raw)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
return String(raw)
|
|
46
|
-
.split(',')
|
|
47
|
-
.map((s) => Number(s.trim()));
|
|
48
|
-
},
|
|
49
|
-
string: async (field) => cancelable(await clack.text({ message: field.label })),
|
|
50
|
-
'string[]': async (field) => {
|
|
51
|
-
const raw = await clack.text({
|
|
52
|
-
message: `${field.label} (comma-separated)`,
|
|
53
|
-
});
|
|
54
|
-
if (clack.isCancel(raw)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
return String(raw)
|
|
58
|
-
.split(',')
|
|
59
|
-
.map((s) => s.trim());
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
/** Resolve a single field value with Clack. */
|
|
63
|
-
const resolveField = (field) => {
|
|
64
|
-
const resolver = fieldResolvers[field.type];
|
|
65
|
-
return resolver(field);
|
|
66
|
-
};
|
|
67
|
-
/** Fill missing input by prompting with Clack when interactive. */
|
|
68
|
-
export const resolveInputWithClack = async (fields, provided, options) => {
|
|
69
|
-
if (!isInteractive(options)) {
|
|
70
|
-
return provided;
|
|
71
|
-
}
|
|
72
|
-
const resolved = { ...provided };
|
|
73
|
-
for (const field of fields) {
|
|
74
|
-
if (!needsInput(field, resolved)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const value = await resolveField(field);
|
|
78
|
-
if (value !== undefined) {
|
|
79
|
-
resolved[field.name] = value;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return resolved;
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=clack.js.map
|
package/dist/src/clack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clack.js","sourceRoot":"","sources":["../../src/clack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,+CAA+C;AAC/C,MAAM,UAAU,GAAG,CAAC,KAAY,EAAE,OAAgC,EAAW,EAAE,CAC7E,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;IACjC,KAAK,CAAC,QAAQ;IACd,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;AAE9B,8CAA8C;AAC9C,MAAM,cAAc,GAAG,CAAC,KAAY,EAAE,EAAE,CACtC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9B,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3D,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK;IACnC,KAAK,EAAE,MAAM,CAAC,KAAK;CACpB,CAAC,CAAC,IAAI,EAAE,CAAC;AAEZ,kDAAkD;AAClD,MAAM,UAAU,GAAG,KAAK,EAAK,KAAiB,EAA0B,EAAE,CACxE,MAAM,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M,QAAQ,GAA4B,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YACjC,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/dist/src/cli.d.ts
DELETED
package/dist/src/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/src/cli.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { outputModePreset } from '@ontrails/cli';
|
|
2
|
-
import { surface } from '@ontrails/cli/commander';
|
|
3
|
-
import { app } from './app.js';
|
|
4
|
-
import { resolveInputWithClack } from './clack.js';
|
|
5
|
-
import { trailsPackageVersion } from './versions.js';
|
|
6
|
-
// oxlint-disable-next-line require-hook -- CLI entry point
|
|
7
|
-
await surface(app, {
|
|
8
|
-
description: 'Agent-native, contract-first TypeScript framework',
|
|
9
|
-
name: 'trails',
|
|
10
|
-
presets: [outputModePreset()],
|
|
11
|
-
resolveInput: resolveInputWithClack,
|
|
12
|
-
version: trailsPackageVersion,
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,2DAA2D;AAC3D,MAAM,OAAO,CAAC,GAAG,EAAE;IACjB,WAAW,EAAE,mDAAmD;IAChE,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC7B,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `add.surface` trail -- Add a surface to an existing project.
|
|
3
|
-
*
|
|
4
|
-
* Generates surface entry points and updates package.json dependencies.
|
|
5
|
-
*/
|
|
6
|
-
export declare const addSurface: import("@ontrails/core").Trail<{
|
|
7
|
-
surface: "cli" | "http" | "mcp";
|
|
8
|
-
dir?: string | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
created: string;
|
|
11
|
-
dependency: string;
|
|
12
|
-
}, never>;
|
|
13
|
-
//# sourceMappingURL=add-surface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-surface.d.ts","sourceRoot":"","sources":["../../../src/trails/add-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqHH,eAAO,MAAM,UAAU;;;;;;SA4BrB,CAAC"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `add.surface` trail -- Add a surface to an existing project.
|
|
3
|
-
*
|
|
4
|
-
* Generates surface entry points and updates package.json dependencies.
|
|
5
|
-
*/
|
|
6
|
-
import { existsSync, mkdirSync } from 'node:fs';
|
|
7
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
8
|
-
import { Result, trail } from '@ontrails/core';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import { ontrailsPackageRange, scaffoldDependencyVersions, } from '../versions.js';
|
|
11
|
-
import { findTopoPath } from './project.js';
|
|
12
|
-
const generateCliEntry = (appImportPath) => `import { surface } from '@ontrails/cli/commander';
|
|
13
|
-
|
|
14
|
-
import { app } from '${appImportPath}';
|
|
15
|
-
|
|
16
|
-
await surface(app);
|
|
17
|
-
`;
|
|
18
|
-
const generateMcpEntry = (appImportPath) => `import { surface } from '@ontrails/mcp';
|
|
19
|
-
|
|
20
|
-
import { app } from '${appImportPath}';
|
|
21
|
-
|
|
22
|
-
await surface(app);
|
|
23
|
-
`;
|
|
24
|
-
const generateHttpEntry = (appImportPath) => `import { surface } from '@ontrails/hono';
|
|
25
|
-
|
|
26
|
-
import { app } from '${appImportPath}';
|
|
27
|
-
|
|
28
|
-
await surface(app, { port: 3000 });
|
|
29
|
-
`;
|
|
30
|
-
const surfaceEntryFiles = {
|
|
31
|
-
cli: 'src/cli.ts',
|
|
32
|
-
http: 'src/http.ts',
|
|
33
|
-
mcp: 'src/mcp.ts',
|
|
34
|
-
};
|
|
35
|
-
const surfaceDependencies = {
|
|
36
|
-
cli: ['@ontrails/cli'],
|
|
37
|
-
http: ['@ontrails/hono', '@ontrails/http'],
|
|
38
|
-
mcp: ['@ontrails/mcp'],
|
|
39
|
-
};
|
|
40
|
-
/** Resolve the entry file for a surface. */
|
|
41
|
-
const getEntryFile = (surface) => surfaceEntryFiles[surface];
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// Trail definition
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
/** Patch deps and optionally bin in a parsed package.json. */
|
|
46
|
-
const patchPkgDeps = (pkg, surface, cwd) => {
|
|
47
|
-
const [depName = ''] = surfaceDependencies[surface];
|
|
48
|
-
const deps = (pkg['dependencies'] ?? {});
|
|
49
|
-
for (const dependency of surfaceDependencies[surface]) {
|
|
50
|
-
deps[dependency] = ontrailsPackageRange;
|
|
51
|
-
}
|
|
52
|
-
if (surface === 'cli') {
|
|
53
|
-
deps['commander'] = scaffoldDependencyVersions.commander;
|
|
54
|
-
pkg['bin'] = {
|
|
55
|
-
[pkg['name'] ?? basename(cwd)]: './src/cli.ts',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
pkg['dependencies'] = Object.fromEntries(Object.entries(deps).toSorted(([a], [b]) => a.localeCompare(b)));
|
|
59
|
-
return depName;
|
|
60
|
-
};
|
|
61
|
-
/** Update package.json with surface dependency and CLI bin if needed. */
|
|
62
|
-
const updatePkgJsonForSurface = async (cwd, surface) => {
|
|
63
|
-
const pkgPath = join(cwd, 'package.json');
|
|
64
|
-
if (!existsSync(pkgPath)) {
|
|
65
|
-
return surfaceDependencies[surface][0] ?? '';
|
|
66
|
-
}
|
|
67
|
-
const pkg = (await Bun.file(pkgPath).json());
|
|
68
|
-
const depName = patchPkgDeps(pkg, surface, cwd);
|
|
69
|
-
await Bun.write(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
70
|
-
return depName;
|
|
71
|
-
};
|
|
72
|
-
/** Create the entry file for a surface and return the relative path. */
|
|
73
|
-
const writeSurfaceEntry = async (cwd, surface) => {
|
|
74
|
-
const entryFile = getEntryFile(surface);
|
|
75
|
-
const fullEntryPath = join(cwd, entryFile);
|
|
76
|
-
const appImport = (await findTopoPath(cwd)) ?? './app.js';
|
|
77
|
-
const generators = {
|
|
78
|
-
cli: generateCliEntry,
|
|
79
|
-
http: generateHttpEntry,
|
|
80
|
-
mcp: generateMcpEntry,
|
|
81
|
-
};
|
|
82
|
-
const content = generators[surface](appImport);
|
|
83
|
-
mkdirSync(dirname(fullEntryPath), { recursive: true });
|
|
84
|
-
await Bun.write(fullEntryPath, content);
|
|
85
|
-
return entryFile;
|
|
86
|
-
};
|
|
87
|
-
export const addSurface = trail('add.surface', {
|
|
88
|
-
blaze: async (input) => {
|
|
89
|
-
const cwd = resolve(input.dir ?? '.');
|
|
90
|
-
const { surface } = input;
|
|
91
|
-
const entryFile = getEntryFile(surface);
|
|
92
|
-
if (existsSync(join(cwd, entryFile))) {
|
|
93
|
-
return Result.err(new Error(`${surface.toUpperCase()} surface already exists. Nothing to do.`));
|
|
94
|
-
}
|
|
95
|
-
return Result.ok({
|
|
96
|
-
created: await writeSurfaceEntry(cwd, surface),
|
|
97
|
-
dependency: await updatePkgJsonForSurface(cwd, surface),
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
description: 'Add a surface to an existing project',
|
|
101
|
-
input: z.object({
|
|
102
|
-
dir: z.string().optional().describe('Project directory'),
|
|
103
|
-
surface: z.enum(['cli', 'http', 'mcp']).describe('Surface to add'),
|
|
104
|
-
}),
|
|
105
|
-
output: z.object({
|
|
106
|
-
created: z.string(),
|
|
107
|
-
dependency: z.string(),
|
|
108
|
-
}),
|
|
109
|
-
});
|
|
110
|
-
//# sourceMappingURL=add-surface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-surface.js","sourceRoot":"","sources":["../../../src/trails/add-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,MAAM,gBAAgB,GAAG,CAAC,aAAqB,EAAU,EAAE,CACzD;;uBAEqB,aAAa;;;CAGnC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,aAAqB,EAAU,EAAE,CACzD;;uBAEqB,aAAa;;;CAGnC,CAAC;AA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