@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.30
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 +373 -14
- package/assets/installers/examples/github.config.ts +17 -19
- package/assets/installers/examples/goreleaser.config.ts +16 -18
- package/assets/installers/examples/raw.config.ts +13 -15
- package/bin/clients.js +87 -66
- package/bin/installgen.js +19 -10
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +18 -12
- package/dist/emit/cli/channels.d.ts +2 -2
- package/dist/emit/cli/channels.js +18 -13
- package/dist/emit/cli/commands.d.ts +1 -1
- package/dist/emit/cli/commands.js +14 -8
- package/dist/emit/cli/discovery.d.ts +0 -6
- package/dist/emit/cli/discovery.js +9 -7
- package/dist/emit/cli/flags.d.ts +1 -3
- package/dist/emit/cli/flags.js +11 -5
- package/dist/emit/cli/install.d.ts +0 -8
- package/dist/emit/cli/install.js +3 -3
- package/dist/emit/cli/layout.d.ts +1 -1
- package/dist/emit/cli/layout.js +13 -10
- package/dist/emit/cli/module.d.ts +6 -6
- package/dist/emit/cli/module.js +10 -10
- package/dist/emit/cli/release.d.ts +0 -11
- package/dist/emit/cli/release.js +4 -4
- package/dist/emit/cli/skills.js +3 -3
- package/dist/emit/csharp/errors.js +4 -4
- package/dist/emit/csharp/json.js +8 -8
- package/dist/emit/csharp/realtime.js +3 -3
- package/dist/emit/csharp/sdk-answer.js +4 -4
- package/dist/emit/csharp/sdk-body.js +8 -6
- package/dist/emit/csharp/sdk-client.d.ts +3 -3
- package/dist/emit/csharp/sdk-client.js +2 -2
- package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
- package/dist/emit/csharp/sdk-csproj.js +10 -10
- package/dist/emit/csharp/sdk-doc.js +1 -1
- package/dist/emit/csharp/sdk-method.d.ts +0 -1
- package/dist/emit/csharp/sdk-method.js +10 -6
- package/dist/emit/csharp/sdk-plan.js +0 -1
- package/dist/emit/csharp/sdk.js +3 -3
- package/dist/emit/csharp/sse.d.ts +0 -2
- package/dist/emit/csharp/sse.js +7 -7
- package/dist/emit/csharp/transport.js +7 -7
- package/dist/emit/csharp/types-enum.js +3 -1
- package/dist/emit/csharp/types-messages.js +3 -3
- package/dist/emit/csharp/types-names.js +10 -12
- package/dist/emit/csharp/types-record.js +3 -3
- package/dist/emit/csharp/types-union.d.ts +1 -1
- package/dist/emit/csharp/types.d.ts +0 -1
- package/dist/emit/csharp/types.js +3 -3
- package/dist/emit/csharp/ws.js +2 -2
- package/dist/emit/go/errors.js +1 -1
- package/dist/emit/go/http.js +2 -2
- package/dist/emit/go/module-path.js +2 -2
- package/dist/emit/go/sdk-answer.js +1 -1
- package/dist/emit/go/sdk-body.js +11 -7
- package/dist/emit/go/sdk-client.js +1 -1
- package/dist/emit/go/sdk-method.js +2 -2
- package/dist/emit/go/sdk-mirror.js +2 -2
- package/dist/emit/go/sdk-opts.d.ts +0 -2
- package/dist/emit/go/sdk-opts.js +3 -3
- package/dist/emit/go/sdk.d.ts +1 -1
- package/dist/emit/go/sdk.js +9 -9
- package/dist/emit/go/sse.js +1 -1
- package/dist/emit/go/types-names.js +5 -0
- package/dist/emit/go/types-struct.d.ts +2 -1
- package/dist/emit/go/types-struct.js +1 -1
- package/dist/emit/go/types.js +9 -9
- package/dist/emit/go/ws.js +6 -6
- package/dist/emit/java/gradle.d.ts +7 -9
- package/dist/emit/java/gradle.js +8 -8
- package/dist/emit/java/json.js +1 -1
- package/dist/emit/java/layout-ast.js +1 -1
- package/dist/emit/java/layout-decl.js +5 -4
- package/dist/emit/java/layout-doc.js +13 -7
- package/dist/emit/java/layout-dot.js +1 -1
- package/dist/emit/java/layout-strings.js +4 -5
- package/dist/emit/java/layout-types.js +7 -5
- package/dist/emit/java/layout-visitor.js +4 -3
- package/dist/emit/java/layout.js +5 -4
- package/dist/emit/java/models-names.js +5 -4
- package/dist/emit/java/models-record.d.ts +0 -1
- package/dist/emit/java/models-record.js +3 -3
- package/dist/emit/java/models-union.d.ts +1 -1
- package/dist/emit/java/models-union.js +1 -1
- package/dist/emit/java/models.d.ts +1 -2
- package/dist/emit/java/models.js +25 -16
- package/dist/emit/java/realtime.d.ts +5 -17
- package/dist/emit/java/realtime.js +1 -1
- package/dist/emit/java/sdk-client.d.ts +6 -6
- package/dist/emit/java/sdk-client.js +1 -1
- package/dist/emit/java/sdk-decl.js +2 -2
- package/dist/emit/java/sdk-errors.js +1 -1
- package/dist/emit/java/sdk-headers.js +2 -2
- package/dist/emit/java/sdk-mirror.js +2 -2
- package/dist/emit/java/sdk-models.d.ts +1 -1
- package/dist/emit/java/sdk-models.js +7 -7
- package/dist/emit/java/sdk-op.d.ts +1 -10
- package/dist/emit/java/sdk-op.js +8 -8
- package/dist/emit/java/sdk-params.d.ts +5 -5
- package/dist/emit/java/sdk-params.js +3 -2
- package/dist/emit/java/sdk-plan.js +0 -1
- package/dist/emit/java/sdk.d.ts +1 -1
- package/dist/emit/java/sdk.js +14 -13
- package/dist/emit/java/sse.d.ts +2 -4
- package/dist/emit/java/sse.js +6 -6
- package/dist/emit/java/ws.d.ts +2 -2
- package/dist/emit/java/ws.js +3 -4
- package/dist/emit/mcp/annotations.js +8 -4
- package/dist/emit/mcp/files.js +9 -9
- package/dist/emit/mcp/mounted.js +2 -2
- package/dist/emit/mcp/output-schema.js +3 -3
- package/dist/emit/mcp/registry.d.ts +0 -2
- package/dist/emit/mcp/registry.js +5 -4
- package/dist/emit/mcp/runtime.js +2 -2
- package/dist/emit/mcp/schema.js +22 -11
- package/dist/emit/mcp/server.d.ts +7 -7
- package/dist/emit/mcp/server.js +7 -6
- package/dist/emit/mcp/tools.js +7 -6
- package/dist/emit/python/errors.js +3 -3
- package/dist/emit/python/realtime.js +2 -2
- package/dist/emit/python/sdk-answer.d.ts +3 -7
- package/dist/emit/python/sdk-answer.js +2 -2
- package/dist/emit/python/sdk-body.js +4 -5
- package/dist/emit/python/sdk-client.js +5 -5
- package/dist/emit/python/sdk-doc.js +2 -2
- package/dist/emit/python/sdk-method.js +5 -5
- package/dist/emit/python/sdk-plan.js +0 -1
- package/dist/emit/python/sdk-pyproject.d.ts +0 -2
- package/dist/emit/python/sdk-pyproject.js +8 -8
- package/dist/emit/python/sdk.d.ts +1 -1
- package/dist/emit/python/sdk.js +7 -7
- package/dist/emit/python/sse.d.ts +0 -2
- package/dist/emit/python/sse.js +2 -2
- package/dist/emit/python/transport.js +4 -4
- package/dist/emit/python/types-dict.d.ts +2 -2
- package/dist/emit/python/types-dict.js +1 -1
- package/dist/emit/python/types-names.js +2 -2
- package/dist/emit/python/types-union.js +1 -1
- package/dist/emit/python/types.js +3 -3
- package/dist/emit/python/ws.d.ts +2 -5
- package/dist/emit/python/ws.js +4 -4
- package/dist/emit/rust/errors.js +3 -3
- package/dist/emit/rust/http.js +4 -4
- package/dist/emit/rust/realtime.js +2 -2
- package/dist/emit/rust/sdk-body.js +8 -5
- package/dist/emit/rust/sdk-cargo.d.ts +16 -18
- package/dist/emit/rust/sdk-cargo.js +12 -12
- package/dist/emit/rust/sdk-client.d.ts +1 -1
- package/dist/emit/rust/sdk-client.js +3 -3
- package/dist/emit/rust/sdk-method.js +2 -2
- package/dist/emit/rust/sdk-opts.d.ts +2 -1
- package/dist/emit/rust/sdk-opts.js +2 -2
- package/dist/emit/rust/sdk-plan.js +0 -1
- package/dist/emit/rust/sdk.d.ts +1 -1
- package/dist/emit/rust/sdk.js +5 -5
- package/dist/emit/rust/sse.d.ts +0 -5
- package/dist/emit/rust/sse.js +2 -2
- package/dist/emit/rust/types-names.js +3 -3
- package/dist/emit/rust/types-struct.js +1 -1
- package/dist/emit/rust/types-union.d.ts +1 -1
- package/dist/emit/rust/types.js +7 -5
- package/dist/emit/rust/ws.d.ts +0 -11
- package/dist/emit/rust/ws.js +5 -5
- package/dist/emit/shared/escape.js +17 -17
- package/dist/emit/shared/format.js +1 -1
- package/dist/emit/shared/gofmt.js +1 -1
- package/dist/emit/shared/lang.js +10 -10
- package/dist/emit/shared/literals.d.ts +5 -0
- package/dist/emit/shared/literals.js +8 -0
- package/dist/emit/shared/metadata.d.ts +0 -6
- package/dist/emit/shared/metadata.js +8 -7
- package/dist/emit/shared/ruff.js +1 -1
- package/dist/emit/shared/rustfmt.js +1 -1
- package/dist/emit/shared/type-emitter.js +37 -20
- package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
- package/dist/emit/shared/unknown-type.constants.js +2 -0
- package/dist/emit/ts/http.d.ts +0 -2
- package/dist/emit/ts/http.js +4 -4
- package/dist/emit/ts/package.d.ts +14 -12
- package/dist/emit/ts/package.js +9 -8
- package/dist/emit/ts/route-tree.js +2 -2
- package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
- package/dist/emit/ts/sdk-types-preamble.js +2 -2
- package/dist/emit/ts/sdk-types.js +11 -11
- package/dist/emit/ts/sdk.js +4 -4
- package/dist/emit/ts/service-map.d.ts +2 -1
- package/dist/emit/ts/tanstack-query.js +6 -6
- package/dist/emit/ts/type-gen.js +31 -18
- package/dist/emit/ts/webhooks.d.ts +0 -2
- package/dist/emit/ts/webhooks.js +3 -3
- package/dist/extract/chain.js +5 -4
- package/dist/extract/extract.js +5 -5
- package/dist/extract/serialize.d.ts +0 -2
- package/dist/extract/serialize.js +14 -15
- package/dist/extract/walk.js +15 -12
- package/dist/gen/args.js +9 -5
- package/dist/gen/formatters.js +5 -3
- package/dist/gen/shipped.js +2 -2
- package/dist/gen/targets.d.ts +2 -4
- package/dist/gen/targets.js +8 -4
- package/dist/gen/write.js +4 -2
- package/dist/index.js +2 -2
- package/dist/installers/cli.d.ts +4 -4
- package/dist/installers/cli.js +24 -24
- package/dist/installers/commands/build.d.ts +4 -4
- package/dist/installers/commands/build.js +2 -3
- package/dist/installers/commands/check.d.ts +2 -2
- package/dist/installers/commands/check.js +11 -10
- package/dist/installers/commands/init.d.ts +2 -2
- package/dist/installers/commands/init.js +1 -2
- package/dist/installers/config/define-config.d.ts +16 -16
- package/dist/installers/config/define-config.js +1 -1
- package/dist/installers/config/hooks/bun.d.ts +6 -6
- package/dist/installers/config/hooks/node.js +1 -1
- package/dist/installers/config/load.d.ts +6 -8
- package/dist/installers/config/load.js +7 -8
- package/dist/installers/config/resolve.d.ts +1 -2
- package/dist/installers/config/resolve.js +28 -33
- package/dist/installers/config/types.d.ts +6 -6
- package/dist/installers/config/types.js +0 -1
- package/dist/installers/render/quote.js +3 -5
- package/dist/installers/render/render.d.ts +6 -6
- package/dist/installers/render/render.js +26 -26
- package/dist/installers/ui.d.ts +4 -4
- package/dist/installers/ui.js +3 -3
- package/dist/ir/build.d.ts +3 -3
- package/dist/ir/build.js +8 -5
- package/dist/ir/load.js +9 -10
- package/dist/ir/model.d.ts +2 -1
- package/dist/ir/model.js +0 -1
- package/dist/ir/resolve-refs.js +2 -2
- package/dist/ir/resource-tree.js +2 -1
- package/dist/ir/route-tree-intern.js +1 -1
- package/dist/ir/schema.js +3 -3
- package/dist/ir/sdk-model.js +3 -3
- package/dist/ir/slots.js +13 -8
- package/dist/ir/streams.js +1 -1
- package/dist/release/bootstrap.d.ts +3 -3
- package/dist/release/bootstrap.js +7 -7
- package/dist/release/bump-args.js +4 -4
- package/dist/release/bump-command.d.ts +1 -1
- package/dist/release/bump-command.js +9 -10
- package/dist/release/bump.d.ts +5 -4
- package/dist/release/bump.js +2 -2
- package/dist/release/cli.d.ts +4 -4
- package/dist/release/cli.js +4 -4
- package/dist/release/codegen.js +1 -1
- package/dist/release/digest.js +5 -7
- package/dist/release/git.js +5 -8
- package/dist/release/load.js +3 -3
- package/dist/release/manifest.js +9 -10
- package/dist/release/oasdiff.d.ts +10 -15
- package/dist/release/oasdiff.js +5 -6
- package/dist/release/registries.d.ts +0 -11
- package/dist/release/registries.js +17 -17
- package/dist/release/release-state.d.ts +16 -13
- package/dist/release/release-workflow.js +5 -7
- package/dist/release/repo-settings.d.ts +2 -1
- package/dist/release/spec-gate.d.ts +0 -2
- package/dist/release/spec-gate.js +6 -10
- package/dist/release/sync-command.d.ts +2 -2
- package/dist/release/sync-command.js +1 -1
- package/dist/release/sync-tree.js +9 -13
- package/dist/release/sync.d.ts +6 -6
- package/dist/release/sync.js +12 -13
- package/dist/release/types.d.ts +22 -22
- package/dist/release/types.js +0 -1
- package/dist/release/version-files.d.ts +3 -4
- package/dist/release/version-files.js +4 -5
- package/dist/runtime/.oxfmtrc.jsonc +8 -0
- package/dist/runtime/mcp/files.ts +1 -1
- package/dist/runtime/mcp/http.ts +6 -2
- package/dist/runtime/mcp/listen.ts +1 -1
- package/dist/runtime/mcp/mount.ts +2 -2
- package/dist/runtime/mcp/protocol.ts +1 -1
- package/dist/runtime/ts-tanstack-query/query.ts +0 -2
- package/package.json +10 -7
- package/dist/emit/cli/index.d.ts +0 -1
- package/dist/emit/cli/index.js +0 -1
- package/dist/emit/csharp/index.d.ts +0 -1
- package/dist/emit/csharp/index.js +0 -1
- package/dist/emit/go/index.d.ts +0 -1
- package/dist/emit/go/index.js +0 -1
- package/dist/emit/java/index.d.ts +0 -2
- package/dist/emit/java/index.js +0 -2
- package/dist/emit/mcp/index.d.ts +0 -3
- package/dist/emit/mcp/index.js +0 -3
- package/dist/emit/python/index.d.ts +0 -1
- package/dist/emit/python/index.js +0 -1
- package/dist/emit/rust/index.d.ts +0 -1
- package/dist/emit/rust/index.js +0 -1
package/dist/extract/walk.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { dirname, resolve } from "node:path";
|
|
10
10
|
import { compareCodeUnits } from "../emit/shared/lang.js";
|
|
11
|
-
|
|
11
|
+
// the type-only members every route builder carries
|
|
12
12
|
const BUILDER_MEMBERS = ["$ctx", "$method", "$path"];
|
|
13
|
-
|
|
13
|
+
// the type-only members every app carries
|
|
14
14
|
const APP_MEMBERS = ["$ctx", "$env"];
|
|
15
15
|
/**
|
|
16
16
|
* The tsconfig that governs `fromPath`: the nearest one walking up, but never past the project root
|
|
@@ -32,7 +32,10 @@ export function findTsConfig(fromPath) {
|
|
|
32
32
|
*/
|
|
33
33
|
export function loadEntry(tsMorph, options) {
|
|
34
34
|
const tsConfigFilePath = options.tsconfigPath ?? findTsConfig(options.entryPath);
|
|
35
|
-
const project = new tsMorph.Project({
|
|
35
|
+
const project = new tsMorph.Project({
|
|
36
|
+
skipAddingFilesFromTsConfig: true,
|
|
37
|
+
...(tsConfigFilePath === undefined ? {} : { tsConfigFilePath }),
|
|
38
|
+
});
|
|
36
39
|
project.addSourceFilesAtPaths(options.entryPath);
|
|
37
40
|
if (tsConfigFilePath !== undefined) {
|
|
38
41
|
const { ts } = tsMorph;
|
|
@@ -48,7 +51,7 @@ export function loadEntry(tsMorph, options) {
|
|
|
48
51
|
if (decl === undefined)
|
|
49
52
|
throw new Error(`Export "${options.exportName}" not found in ${options.entryPath}`);
|
|
50
53
|
const checker = project.getTypeChecker().compilerObject;
|
|
51
|
-
|
|
54
|
+
// for `export default <expr>` the declaration is the expression itself
|
|
52
55
|
return {
|
|
53
56
|
appNode: decl.compilerNode,
|
|
54
57
|
appType: checker.getTypeAtLocation(decl.compilerNode),
|
|
@@ -116,7 +119,7 @@ function appOrigins(entry) {
|
|
|
116
119
|
const known = memo.get(expr);
|
|
117
120
|
if (known !== undefined)
|
|
118
121
|
return known;
|
|
119
|
-
|
|
122
|
+
// a binding that reads itself ends at the expression
|
|
120
123
|
memo.set(expr, expr);
|
|
121
124
|
const found = step(expr);
|
|
122
125
|
memo.set(expr, found);
|
|
@@ -127,7 +130,7 @@ function appOrigins(entry) {
|
|
|
127
130
|
/** The receiver's base path: its `HttpApp` type argument `TBasePath`, when that is one literal. */
|
|
128
131
|
function basePathOf(entry, app) {
|
|
129
132
|
const { checker, compiler } = entry;
|
|
130
|
-
|
|
133
|
+
// a class's instance type is a reference to it: its type arguments are the app's
|
|
131
134
|
const decl = app.getSymbol()?.declarations?.find((d) => compiler.isClassDeclaration(d));
|
|
132
135
|
const index = decl?.typeParameters?.findIndex((p) => p.name.text === "TBasePath") ?? -1;
|
|
133
136
|
const arg = index < 0 ? undefined : checker.getTypeArguments(app)[index];
|
|
@@ -143,8 +146,8 @@ function mountOf(entry, call, origin, report) {
|
|
|
143
146
|
const sub = call.arguments.at(-1);
|
|
144
147
|
if (sub === undefined || call.arguments.length > 2 || APP_MEMBERS.some((m) => app.getProperty(m) === undefined))
|
|
145
148
|
return null;
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
// core mounts nothing when the sub is the receiver's own app (`register.ts` `mount`): the groups that share one
|
|
150
|
+
// app keep their own ids
|
|
148
151
|
const [into, from] = [origin(receiver), origin(sub)];
|
|
149
152
|
if (into === from)
|
|
150
153
|
return null;
|
|
@@ -193,13 +196,13 @@ function registrationOf(entry, call) {
|
|
|
193
196
|
if (phantoms.includes(undefined))
|
|
194
197
|
return null;
|
|
195
198
|
const [ctx, method, path] = phantoms;
|
|
196
|
-
|
|
199
|
+
// the handler callback's ctx parameter carries `input`, which the builder's `$ctx` phantom leaves out
|
|
197
200
|
const handler = checker.getResolvedSignature(call)?.parameters[0];
|
|
198
201
|
const param = handler && checker.getTypeOfSymbol(handler).getCallSignatures()[0]?.parameters[0];
|
|
199
202
|
const input = param && checker.getTypeOfSymbol(param).getProperty("input");
|
|
200
203
|
const params = param && checker.getTypeOfSymbol(param).getProperty("params");
|
|
201
204
|
const paramsType = params && checker.getTypeOfSymbol(params);
|
|
202
|
-
|
|
205
|
+
// a param schema shows as a key that is not a string: only then does the path's own typing fall short
|
|
203
206
|
const typed = paramsType
|
|
204
207
|
?.getProperties()
|
|
205
208
|
.some((key) => !(checker.getTypeOfSymbol(key).flags & compiler.TypeFlags.String));
|
|
@@ -209,7 +212,7 @@ function registrationOf(entry, call) {
|
|
|
209
212
|
ctx: ctx,
|
|
210
213
|
input: input ? checker.getTypeOfSymbol(input) : null,
|
|
211
214
|
params: typed === true ? paramsType : null,
|
|
212
|
-
|
|
215
|
+
// `.on()`'s methods are literals by its signature; a path is one only as a single literal
|
|
213
216
|
methods: literals(method),
|
|
214
217
|
path: literalOf(path),
|
|
215
218
|
};
|
|
@@ -241,7 +244,7 @@ export function registrations(entry, report) {
|
|
|
241
244
|
.sort((a, b) => compareCodeUnits(a.fileName, b.fileName));
|
|
242
245
|
for (const file of files)
|
|
243
246
|
visit(file);
|
|
244
|
-
|
|
247
|
+
// the export resolves as any binding of it does: through its name, or as the default export's expression
|
|
245
248
|
const prefixes = servedPrefixes(mounts, origin(compiler.isVariableDeclaration(appNode) ? appNode.name : appNode));
|
|
246
249
|
return found.map(({ builder, path, ...registration }) => ({
|
|
247
250
|
...registration,
|
package/dist/gen/args.js
CHANGED
|
@@ -44,7 +44,7 @@ Nothing outside <out>/<target> is written or deleted, and no symlink is followed
|
|
|
44
44
|
export class UsageError extends Error {
|
|
45
45
|
}
|
|
46
46
|
function kebab(key) {
|
|
47
|
-
return key.
|
|
47
|
+
return key.replaceAll(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
48
48
|
}
|
|
49
49
|
/** The `--<target>-<option>` flag `flag` names: its target and its option's name; none for another flag. */
|
|
50
50
|
function optionFlag(flag) {
|
|
@@ -72,14 +72,18 @@ function booleanOf(flag, inline) {
|
|
|
72
72
|
/** One flag of `generate` into `into`. */
|
|
73
73
|
function takeFlag(arg, rest, into) {
|
|
74
74
|
const [flag, inline] = arg.slice(2).split(/=(.*)/s, 2);
|
|
75
|
-
if (flag === "spec")
|
|
75
|
+
if (flag === "spec") {
|
|
76
76
|
into.spec = valueOf(flag, inline, rest);
|
|
77
|
-
|
|
77
|
+
}
|
|
78
|
+
else if (flag === "app") {
|
|
78
79
|
into.app = valueOf(flag, inline, rest);
|
|
79
|
-
|
|
80
|
+
}
|
|
81
|
+
else if (flag === "out") {
|
|
80
82
|
into.out = valueOf(flag, inline, rest);
|
|
81
|
-
|
|
83
|
+
}
|
|
84
|
+
else if (flag === "watch") {
|
|
82
85
|
into.watch = booleanOf(flag, inline);
|
|
86
|
+
}
|
|
83
87
|
else if (flag === "target") {
|
|
84
88
|
const target = valueOf(flag, inline, rest);
|
|
85
89
|
if (!TARGETS.includes(target))
|
package/dist/gen/formatters.js
CHANGED
|
@@ -121,10 +121,12 @@ export async function formatterFor(target, where) {
|
|
|
121
121
|
const rustfmt = findRustfmt(env);
|
|
122
122
|
return rustfmt === undefined ? undefined : rustfmtFormatter(rustfmt);
|
|
123
123
|
}
|
|
124
|
-
case "ts":
|
|
124
|
+
case "ts": {
|
|
125
125
|
return await loadOxfmt(oxfmt);
|
|
126
|
-
|
|
126
|
+
}
|
|
127
|
+
default: {
|
|
127
128
|
return undefined;
|
|
129
|
+
}
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
@@ -138,7 +140,7 @@ export async function formatterFor(target, where) {
|
|
|
138
140
|
*/
|
|
139
141
|
export function missingFormatter(target, pass, env, report) {
|
|
140
142
|
const said = `${pass.tool} was not found, so the ${target} output is not formatted (${pass.install})`;
|
|
141
|
-
|
|
143
|
+
// an explicit demand is honoured for every target, quiet or not: the caller asked to be stopped
|
|
142
144
|
if (env.CLIENTS_REQUIRE_FORMATTERS === "1")
|
|
143
145
|
throw new Error(said);
|
|
144
146
|
if (pass.quiet !== true)
|
package/dist/gen/shipped.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
import { iconName, LICENSE, README } from "../emit/shared/metadata.js";
|
|
9
9
|
// per-process-constant: text-codec
|
|
10
10
|
const UTF8 = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
|
|
11
|
-
|
|
11
|
+
// NuGet's cap on a package icon
|
|
12
12
|
const ICON_BYTES = 1024 * 1024;
|
|
13
|
-
|
|
13
|
+
// the signature each image format opens with, by the extensions that name it
|
|
14
14
|
const PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
15
15
|
const JPEG = [0xff, 0xd8, 0xff];
|
|
16
16
|
/** The bytes of the file `metadata[field]` names, or a refusal naming the field. */
|
package/dist/gen/targets.d.ts
CHANGED
|
@@ -45,14 +45,14 @@ export type TargetOptions<T extends Target> = {
|
|
|
45
45
|
/** Any target's options by name, as the CLI parses and each generator reads them. */
|
|
46
46
|
export type Options = Readonly<Record<string, string>>;
|
|
47
47
|
/** One problem a schema found: what is wrong, and the option it is about. */
|
|
48
|
-
|
|
48
|
+
type OptionsIssue = {
|
|
49
49
|
/** What is wrong, naming the target and the option. */
|
|
50
50
|
readonly message: string;
|
|
51
51
|
/** The option's name, as the only segment; absent when the value is not an object at all. */
|
|
52
52
|
readonly path?: readonly PropertyKey[];
|
|
53
53
|
};
|
|
54
54
|
/** What `validate` answers: the options it accepted, or every issue it found. */
|
|
55
|
-
|
|
55
|
+
type OptionsResult<T extends Target> = {
|
|
56
56
|
/** The options, as given. */
|
|
57
57
|
readonly value: TargetOptions<T>;
|
|
58
58
|
/** Absent: no issue was found. */
|
|
@@ -86,8 +86,6 @@ export declare function isBooleanOption(target: Target, key: string): boolean;
|
|
|
86
86
|
export declare const targetOptionSchemas: {
|
|
87
87
|
readonly [T in Target]: TargetOptionsSchema<T>;
|
|
88
88
|
};
|
|
89
|
-
/** `value` as `target`'s options, or an error naming every problem its schema found. */
|
|
90
|
-
export declare function checkedOptions(target: Target, value: unknown): Options;
|
|
91
89
|
/** `target`'s options: those `metadata` fills, under the ones the run gives the target itself, checked. */
|
|
92
90
|
export declare function optionsFor(target: Target, metadata: Metadata, options: unknown): Options;
|
|
93
91
|
export {};
|
package/dist/gen/targets.js
CHANGED
|
@@ -81,7 +81,10 @@ export const TARGET_OPTIONS = {
|
|
|
81
81
|
* the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
|
|
82
82
|
* says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
|
|
83
83
|
*/
|
|
84
|
-
const BOOLEAN_OPTIONS = {
|
|
84
|
+
const BOOLEAN_OPTIONS = {
|
|
85
|
+
cli: ["aur"],
|
|
86
|
+
ts: ["tanstackQuery"],
|
|
87
|
+
};
|
|
85
88
|
/** Whether `target`'s option `key` takes no value. */
|
|
86
89
|
export function isBooleanOption(target, key) {
|
|
87
90
|
const keys = BOOLEAN_OPTIONS[target] ?? [];
|
|
@@ -92,10 +95,11 @@ function issueOf(target, key, value) {
|
|
|
92
95
|
const keys = TARGET_OPTIONS[target];
|
|
93
96
|
if (!keys.includes(key))
|
|
94
97
|
return { message: `unknown ${target} option ${JSON.stringify(key)}: want one of ${keys.join(", ")}`, path: [key] };
|
|
95
|
-
if (isBooleanOption(target, key))
|
|
98
|
+
if (isBooleanOption(target, key)) {
|
|
96
99
|
return value === "true" || value === "false"
|
|
97
100
|
? undefined
|
|
98
101
|
: { message: `${target} option ${key}: want "true" or "false"`, path: [key] };
|
|
102
|
+
}
|
|
99
103
|
return typeof value === "string" && value !== ""
|
|
100
104
|
? undefined
|
|
101
105
|
: { message: `${target} option ${key}: want a non-empty string`, path: [key] };
|
|
@@ -106,7 +110,7 @@ function schemaOf(target) {
|
|
|
106
110
|
validate(value) {
|
|
107
111
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
108
112
|
return { issues: [{ message: `${target} options: want an object of option names to strings` }] };
|
|
109
|
-
|
|
113
|
+
// an option given as undefined is not given: a caller's optional field, never a value
|
|
110
114
|
const given = Object.entries(value).filter(([, option]) => option !== undefined);
|
|
111
115
|
const issues = given.flatMap(([key, option]) => issueOf(target, key, option) ?? []);
|
|
112
116
|
return issues.length > 0 ? { issues } : { value: Object.fromEntries(given) };
|
|
@@ -122,7 +126,7 @@ function schemasOf() {
|
|
|
122
126
|
return Object.fromEntries(TARGETS.map((target) => [target, schemaOf(target)]));
|
|
123
127
|
}
|
|
124
128
|
/** `value` as `target`'s options, or an error naming every problem its schema found. */
|
|
125
|
-
|
|
129
|
+
function checkedOptions(target, value) {
|
|
126
130
|
const result = targetOptionSchemas[target]["~standard"].validate(value);
|
|
127
131
|
if (result.issues !== undefined)
|
|
128
132
|
throw new Error(result.issues.map((issue) => issue.message).join("; "));
|
package/dist/gen/write.js
CHANGED
|
@@ -61,7 +61,9 @@ export function writeFileIfChanged(path, content) {
|
|
|
61
61
|
function listed(dir) {
|
|
62
62
|
try {
|
|
63
63
|
const files = JSON.parse(readFileSync(join(dir, MANIFEST), "utf8")).files;
|
|
64
|
-
return typeof files === "object" && files !== null && !Array.isArray(files)
|
|
64
|
+
return typeof files === "object" && files !== null && !Array.isArray(files)
|
|
65
|
+
? files
|
|
66
|
+
: {};
|
|
65
67
|
}
|
|
66
68
|
catch {
|
|
67
69
|
return {};
|
|
@@ -98,7 +100,7 @@ export function writeTarget(dir, files, packages) {
|
|
|
98
100
|
kept.push(rel);
|
|
99
101
|
continue;
|
|
100
102
|
}
|
|
101
|
-
|
|
103
|
+
// a deleted file or directory is already gone (R7)
|
|
102
104
|
if (!existsSync(path))
|
|
103
105
|
continue;
|
|
104
106
|
if (!lstatSync(path).isFile() || sha256(readFileSync(path)) !== hash) {
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,6 @@ export { generateRouteTree } from "./emit/ts/route-tree.js";
|
|
|
10
10
|
export { generateTypes } from "./emit/ts/type-gen.js";
|
|
11
11
|
export { generated, writeGenerated, } from "./cli.js";
|
|
12
12
|
export { TARGETS, targetOptionSchemas, } from "./gen/targets.js";
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// `writeTarget` writes one target's files into a directory the caller picks, keeping `MANIFEST` there: for a caller
|
|
14
|
+
// that lays out `generated`'s files itself rather than as `writeGenerated`'s `<out>/<target>`
|
|
15
15
|
export { MANIFEST, writeFileIfChanged, writeTarget } from "./gen/write.js";
|
package/dist/installers/cli.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type RuntimeInfo } from "./config/load.ts";
|
|
2
2
|
import { type UiIo } from "./ui.ts";
|
|
3
|
-
export
|
|
3
|
+
export type Io = UiIo & {
|
|
4
4
|
cwd: string;
|
|
5
5
|
runtime?: RuntimeInfo;
|
|
6
6
|
fetch?: typeof fetch;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
/** The whole CLI, in-process: every effect goes through `io`, so tests run it without spawning. Returns the exit code. */
|
|
9
9
|
export declare function run(argv: readonly string[], io: Io): Promise<number>;
|
|
10
10
|
/** The slice of `process` that `start` touches. */
|
|
11
|
-
export
|
|
11
|
+
export type Proc = {
|
|
12
12
|
stdout: NodeJS.WritableStream & {
|
|
13
13
|
isTTY?: boolean;
|
|
14
14
|
};
|
|
@@ -17,5 +17,5 @@ export interface Proc {
|
|
|
17
17
|
env: Record<string, string | undefined>;
|
|
18
18
|
exitCode?: number | string | null | undefined;
|
|
19
19
|
exit(code?: number): void;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
export declare function start(argv?: readonly string[], proc?: Proc): Promise<void>;
|
package/dist/installers/cli.js
CHANGED
|
@@ -21,35 +21,35 @@ Options:
|
|
|
21
21
|
Run \`installgen <command> --help\` for a command's options.
|
|
22
22
|
`;
|
|
23
23
|
const COMMANDS = {
|
|
24
|
-
init: {
|
|
25
|
-
usage: `Usage: installgen init [--preset ${ /* @__PURE__ */PRESETS.join("|")}] [--force]
|
|
26
|
-
|
|
27
|
-
--preset <name> the example to start from (default: raw)
|
|
28
|
-
--force overwrite an existing config
|
|
29
|
-
`,
|
|
30
|
-
options: { preset: { type: "string" }, force: { type: "boolean" } },
|
|
31
|
-
},
|
|
32
24
|
build: {
|
|
25
|
+
options: { config: { short: "c", type: "string" }, "default-version": { type: "string" }, out: { type: "string" } },
|
|
33
26
|
usage: `Usage: installgen build [-c <path>] [--out <dir>] [--default-version <version>]
|
|
34
27
|
|
|
35
28
|
-c, --config <path> the config (default: installgen.config.{ts,mts,js,mjs} in this directory)
|
|
36
29
|
--out <dir> where to write the scripts (default: the config's outDir, installers)
|
|
37
30
|
--default-version <version> install this version when the user names none (default: the latest file)
|
|
38
31
|
`,
|
|
39
|
-
options: { config: { type: "string", short: "c" }, out: { type: "string" }, "default-version": { type: "string" } },
|
|
40
32
|
},
|
|
41
33
|
check: {
|
|
34
|
+
options: {
|
|
35
|
+
config: { short: "c", type: "string" },
|
|
36
|
+
"default-version": { type: "string" },
|
|
37
|
+
list: { type: "boolean" },
|
|
38
|
+
},
|
|
42
39
|
usage: `Usage: installgen check [-c <path>] [--default-version <version>] [--list]
|
|
43
40
|
|
|
44
41
|
-c, --config <path> the config (default: installgen.config.{ts,mts,js,mjs} in this directory)
|
|
45
42
|
--default-version <version> check this version (default: read the latest file)
|
|
46
43
|
--list print the URLs the installers fetch, without fetching
|
|
47
44
|
`,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
},
|
|
46
|
+
init: {
|
|
47
|
+
options: { force: { type: "boolean" }, preset: { type: "string" } },
|
|
48
|
+
usage: `Usage: installgen init [--preset ${ /* @__PURE__ */PRESETS.join("|")}] [--force]
|
|
49
|
+
|
|
50
|
+
--preset <name> the example to start from (default: raw)
|
|
51
|
+
--force overwrite an existing config
|
|
52
|
+
`,
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
class UsageError extends Error {
|
|
@@ -74,10 +74,10 @@ function topLevel(command, io) {
|
|
|
74
74
|
function parse(command, rest) {
|
|
75
75
|
try {
|
|
76
76
|
return parseArgs({
|
|
77
|
+
allowPositionals: false,
|
|
77
78
|
args: [...rest],
|
|
78
|
-
options: { ...COMMANDS[command].options, help: {
|
|
79
|
+
options: { ...COMMANDS[command].options, help: { short: "h", type: "boolean" } },
|
|
79
80
|
strict: true,
|
|
80
|
-
allowPositionals: false,
|
|
81
81
|
}).values;
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
@@ -96,19 +96,19 @@ async function dispatch(command, values, io, ui) {
|
|
|
96
96
|
const configPath = values.config;
|
|
97
97
|
const defaultVersion = values["default-version"];
|
|
98
98
|
if (command === "init") {
|
|
99
|
-
init({ cwd: io.cwd,
|
|
99
|
+
init({ cwd: io.cwd, force: values.force === true, preset: presetOf(values) }, ui);
|
|
100
100
|
return 0;
|
|
101
101
|
}
|
|
102
102
|
if (command === "build") {
|
|
103
|
-
await build({ cwd: io.cwd,
|
|
103
|
+
await build({ configPath, cwd: io.cwd, defaultVersion, out: values.out, runtime }, ui);
|
|
104
104
|
return 0;
|
|
105
105
|
}
|
|
106
106
|
const problems = await check({
|
|
107
|
-
cwd: io.cwd,
|
|
108
107
|
configPath,
|
|
109
|
-
|
|
108
|
+
cwd: io.cwd,
|
|
110
109
|
defaultVersion,
|
|
111
110
|
list: values.list === true,
|
|
111
|
+
runtime,
|
|
112
112
|
...(io.fetch ? { fetch: io.fetch } : {}),
|
|
113
113
|
}, ui);
|
|
114
114
|
return problems === 0 ? 0 : 1;
|
|
@@ -145,9 +145,9 @@ export async function run(argv, io) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
export async function start(argv = process.argv.slice(2), proc = process) {
|
|
148
|
-
|
|
148
|
+
// a reader that closes early (`| head`, `| grep -q`) is done listening: stop writing and leave quietly
|
|
149
149
|
let closed = false;
|
|
150
|
-
|
|
150
|
+
// EPIPE, or EOF where Windows reports a closed pipe that way
|
|
151
151
|
const onError = (error) => {
|
|
152
152
|
if (error.code !== "EPIPE" && error.code !== "EOF")
|
|
153
153
|
throw error;
|
|
@@ -163,8 +163,8 @@ export async function start(argv = process.argv.slice(2), proc = process) {
|
|
|
163
163
|
proc.exitCode = await run(argv, {
|
|
164
164
|
cwd: proc.cwd(),
|
|
165
165
|
env: proc.env,
|
|
166
|
-
stdout: write(proc.stdout),
|
|
167
|
-
stderr: write(proc.stderr),
|
|
168
166
|
isTTY: proc.stdout.isTTY === true,
|
|
167
|
+
stderr: write(proc.stderr),
|
|
168
|
+
stdout: write(proc.stdout),
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type RuntimeInfo } from "../config/load.ts";
|
|
2
2
|
import type { ResolvedConfig } from "../config/types.ts";
|
|
3
3
|
import type { Ui } from "../ui.ts";
|
|
4
|
-
export
|
|
4
|
+
export type ConfigOptions = {
|
|
5
5
|
cwd: string;
|
|
6
6
|
configPath: string | undefined;
|
|
7
7
|
runtime: RuntimeInfo;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export declare function loadResolved(options: ConfigOptions): Promise<ResolvedConfig>;
|
|
10
10
|
export declare function warnUnverified(resolved: ResolvedConfig, ui: Ui): void;
|
|
11
|
-
export
|
|
11
|
+
export type BuildOptions = ConfigOptions & {
|
|
12
12
|
out: string | undefined;
|
|
13
13
|
defaultVersion: string | undefined;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
export declare function build(options: BuildOptions, ui: Ui): Promise<void>;
|
|
@@ -4,13 +4,12 @@ import { loadConfig } from "../config/load.js";
|
|
|
4
4
|
import { resolveConfig } from "../config/resolve.js";
|
|
5
5
|
import { render } from "../render/render.js";
|
|
6
6
|
export async function loadResolved(options) {
|
|
7
|
-
const { config } = await loadConfig({
|
|
7
|
+
const { config } = await loadConfig({ configPath: options.configPath, cwd: options.cwd, runtime: options.runtime });
|
|
8
8
|
return resolveConfig(config);
|
|
9
9
|
}
|
|
10
10
|
export function warnUnverified(resolved, ui) {
|
|
11
|
-
if (resolved.platforms.every((p) => p.checksums === undefined))
|
|
11
|
+
if (resolved.platforms.every((p) => p.checksums === undefined))
|
|
12
12
|
ui.warn("no checksumsPath; the installers will not verify downloads (they show a warning row instead)");
|
|
13
|
-
}
|
|
14
13
|
}
|
|
15
14
|
export async function build(options, ui) {
|
|
16
15
|
const resolved = await loadResolved(options);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Ui } from "../ui.ts";
|
|
2
2
|
import { type ConfigOptions } from "./build.ts";
|
|
3
|
-
export
|
|
3
|
+
export type CheckOptions = ConfigOptions & {
|
|
4
4
|
defaultVersion: string | undefined;
|
|
5
5
|
list: boolean;
|
|
6
6
|
fetch?: typeof fetch;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
/** `hash file`, `hash *file`, BSD `SHA256 (file) = hash`, or a file holding one bare hash. */
|
|
9
9
|
export declare function findChecksum(text: string, file: string): string | undefined;
|
|
10
10
|
export declare function check(options: CheckOptions, ui: Ui): Promise<number>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InstallgenError } from "../errors.js";
|
|
2
2
|
import { loadResolved, warnUnverified } from "./build.js";
|
|
3
|
-
|
|
3
|
+
// the same rules the scripts apply at install time
|
|
4
4
|
const VERSION = /^[A-Za-z0-9._+-]+$/;
|
|
5
5
|
const TIMEOUT_MS = 15_000;
|
|
6
6
|
function expand(segments, version, tag) {
|
|
@@ -19,7 +19,7 @@ export function findChecksum(text, file) {
|
|
|
19
19
|
const only = lines.length === 1 ? lines[0]?.trim().split(/\s+/) : undefined;
|
|
20
20
|
return only?.length === 1 ? only[0] : undefined;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
// fetch rejects with a TypeError whose cause says why (ECONNREFUSED, a timeout)
|
|
23
23
|
function failure(error) {
|
|
24
24
|
const e = error;
|
|
25
25
|
return e.cause instanceof Error ? `${e.message}: ${e.cause.message}` : e.message;
|
|
@@ -36,12 +36,12 @@ function normalize(raw, tagPrefix, what) {
|
|
|
36
36
|
function probesFor(get) {
|
|
37
37
|
const sums = new Map();
|
|
38
38
|
return {
|
|
39
|
-
|
|
39
|
+
// HEAD first; hosts that refuse it get a one-byte ranged GET
|
|
40
40
|
async exists(url) {
|
|
41
41
|
try {
|
|
42
42
|
const head = await get(url, { method: "HEAD" });
|
|
43
43
|
if (head.ok)
|
|
44
|
-
return
|
|
44
|
+
return;
|
|
45
45
|
const ranged = await get(url, { headers: { range: "bytes=0-0" } });
|
|
46
46
|
await ranged.arrayBuffer();
|
|
47
47
|
return ranged.ok ? undefined : `missing ${url} (${ranged.status})`;
|
|
@@ -53,7 +53,7 @@ function probesFor(get) {
|
|
|
53
53
|
checksums(url) {
|
|
54
54
|
let probe = sums.get(url);
|
|
55
55
|
if (probe === undefined) {
|
|
56
|
-
probe = get(url).then(async (res) => res.ok ? {
|
|
56
|
+
probe = get(url).then(async (res) => res.ok ? { body: await res.text(), ok: true } : { ok: false, reason: `missing ${url} (${res.status})` }, (error) => ({ ok: false, reason: `unreachable ${url}: ${failure(error)}` }));
|
|
57
57
|
sums.set(url, probe);
|
|
58
58
|
}
|
|
59
59
|
return probe;
|
|
@@ -82,8 +82,9 @@ async function checkPlatform(p, run) {
|
|
|
82
82
|
const found = [];
|
|
83
83
|
let problems = 0;
|
|
84
84
|
const missing = await probes.exists(assetUrl);
|
|
85
|
-
if (missing === undefined)
|
|
85
|
+
if (missing === undefined) {
|
|
86
86
|
found.push(assetUrl);
|
|
87
|
+
}
|
|
87
88
|
else {
|
|
88
89
|
problems++;
|
|
89
90
|
ui.bad(p.platform, missing);
|
|
@@ -97,8 +98,9 @@ async function checkPlatform(p, run) {
|
|
|
97
98
|
}
|
|
98
99
|
if (p.signature !== undefined) {
|
|
99
100
|
const missingBundle = await probes.exists(`${resolved.baseUrl}/${expand(p.signature.bundle, version, tag)}`);
|
|
100
|
-
if (missingBundle === undefined)
|
|
101
|
+
if (missingBundle === undefined) {
|
|
101
102
|
found.push("signature bundle");
|
|
103
|
+
}
|
|
102
104
|
else {
|
|
103
105
|
problems++;
|
|
104
106
|
ui.bad(p.platform, missingBundle);
|
|
@@ -119,7 +121,7 @@ export async function check(options, ui) {
|
|
|
119
121
|
}
|
|
120
122
|
warnUnverified(resolved, ui);
|
|
121
123
|
const version = await resolveVersion(resolved, options.defaultVersion, get, ui);
|
|
122
|
-
const run = {
|
|
124
|
+
const run = { probes: probesFor(get), resolved, tag: resolved.tagPrefix + version, ui, version };
|
|
123
125
|
let problems = 0;
|
|
124
126
|
for (const p of resolved.platforms)
|
|
125
127
|
problems += await checkPlatform(p, run);
|
|
@@ -154,8 +156,7 @@ function list(resolved, defaultVersion, ui) {
|
|
|
154
156
|
ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.asset, version, tag)}`);
|
|
155
157
|
if (p.checksums !== undefined)
|
|
156
158
|
ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.checksums, version, tag)}`);
|
|
157
|
-
if (p.signature !== undefined)
|
|
159
|
+
if (p.signature !== undefined)
|
|
158
160
|
ui.info(`${p.platform} ${resolved.baseUrl}/${expand(p.signature.bundle, version, tag)}`);
|
|
159
|
-
}
|
|
160
161
|
}
|
|
161
162
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Ui } from "../ui.ts";
|
|
2
2
|
export declare const PRESETS: readonly ["raw", "goreleaser", "github"];
|
|
3
3
|
export type Preset = (typeof PRESETS)[number];
|
|
4
|
-
export
|
|
4
|
+
export type InitOptions = {
|
|
5
5
|
cwd: string;
|
|
6
6
|
preset: Preset;
|
|
7
7
|
force: boolean;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export declare function init(options: InitOptions, ui: Ui): void;
|
|
@@ -21,9 +21,8 @@ function isModuleProject(cwd) {
|
|
|
21
21
|
}
|
|
22
22
|
export function init(options, ui) {
|
|
23
23
|
const existing = CONFIG_FILES.find((name) => existsSync(join(options.cwd, name)));
|
|
24
|
-
if (existing !== undefined && !options.force)
|
|
24
|
+
if (existing !== undefined && !options.force)
|
|
25
25
|
throw new InstallgenError(`${existing} already exists; pass --force to overwrite it`);
|
|
26
|
-
}
|
|
27
26
|
const file = isModuleProject(options.cwd) ? "installgen.config.ts" : "installgen.config.mts";
|
|
28
27
|
const example = readFileSync(new URL(`../../../assets/installers/examples/${options.preset}.config.ts`, import.meta.url), "utf8");
|
|
29
28
|
writeFileSync(join(options.cwd, file), example);
|
|
@@ -9,19 +9,19 @@ export declare const TAG_SENTINEL = "__InstallGen_Tag__";
|
|
|
9
9
|
declare const versionBrand: unique symbol;
|
|
10
10
|
declare const tagBrand: unique symbol;
|
|
11
11
|
/** The release version without the tag prefix (`1.2.3`). Interpolate it; the script fills it in at install time. */
|
|
12
|
-
export
|
|
12
|
+
export type VersionToken = {
|
|
13
13
|
/** Yields a placeholder the build swaps for the script's version variable; a string method on it is refused. */
|
|
14
14
|
readonly [Symbol.toPrimitive]: (hint: string) => string;
|
|
15
15
|
readonly [versionBrand]: true;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
/** The release tag, `tagPrefix` + version (`v1.2.3`). Interpolate it; the script fills it in at install time. */
|
|
18
|
-
export
|
|
18
|
+
export type TagToken = {
|
|
19
19
|
/** Yields a placeholder the build swaps for the script's tag variable; a string method on it is refused. */
|
|
20
20
|
readonly [Symbol.toPrimitive]: (hint: string) => string;
|
|
21
21
|
readonly [tagBrand]: true;
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
/** What a path function gets: the tokens to interpolate, and the platform it is called for (once per platform). */
|
|
24
|
-
export
|
|
24
|
+
export type PathContext = {
|
|
25
25
|
/** The version being installed, filled in at install time. */
|
|
26
26
|
readonly version: VersionToken;
|
|
27
27
|
/** The tag being installed, filled in at install time. */
|
|
@@ -30,19 +30,19 @@ export interface PathContext {
|
|
|
30
30
|
readonly os: Os;
|
|
31
31
|
/** The platform's architecture. */
|
|
32
32
|
readonly arch: Arch;
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
34
|
/** What `checksumsPath` gets: the path context plus the asset it lists. */
|
|
35
|
-
export
|
|
35
|
+
export type ChecksumsContext = PathContext & {
|
|
36
36
|
/** The asset path `assetPath` returned for this platform. */
|
|
37
37
|
readonly asset: string;
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
39
|
/** What `signature.bundlePath` gets: the checksums context plus the checksums file it signs. */
|
|
40
|
-
export
|
|
40
|
+
export type BundleContext = ChecksumsContext & {
|
|
41
41
|
/** The checksums path `checksumsPath` returned for this platform. */
|
|
42
42
|
readonly checksums: string;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
/** A keyless sigstore signature on the checksums file, checked by `cosign verify-blob` when cosign is on PATH. */
|
|
45
|
-
export
|
|
45
|
+
export type SignatureConfig = {
|
|
46
46
|
/**
|
|
47
47
|
* The certificate identity the bundle must carry, matched exactly: an https URL. Interpolate `tag` to bind it to the
|
|
48
48
|
* release, e.g. `https://github.com/o/r/.github/workflows/release.yml@refs/tags/${tag}`.
|
|
@@ -52,16 +52,16 @@ export interface SignatureConfig {
|
|
|
52
52
|
issuer?: string;
|
|
53
53
|
/** The sigstore bundle of the checksums file, per platform. Default: the checksums path + `.sigstore.json`. */
|
|
54
54
|
bundlePath?: (ctx: BundleContext) => string;
|
|
55
|
-
}
|
|
55
|
+
};
|
|
56
56
|
/** Where the two scripts are served: https, or http on loopback. The scripts print these in their hints. */
|
|
57
|
-
export
|
|
57
|
+
export type ScriptUrls = {
|
|
58
58
|
/** The URL users pipe to `sh`. */
|
|
59
59
|
sh: string;
|
|
60
60
|
/** The URL users pipe to `iex`. */
|
|
61
61
|
ps1: string;
|
|
62
|
-
}
|
|
62
|
+
};
|
|
63
63
|
/** An `installgen.config.ts` default export: where a release's files live and how the scripts install them. */
|
|
64
|
-
export
|
|
64
|
+
export type InstallgenConfig = {
|
|
65
65
|
/** The binary name, `^[A-Za-z0-9][A-Za-z0-9._-]*$`. */
|
|
66
66
|
name: string;
|
|
67
67
|
/** Where the files live. https only; loopback http is allowed for tests. */
|
|
@@ -92,7 +92,7 @@ export interface InstallgenConfig {
|
|
|
92
92
|
scriptUrls?: ScriptUrls;
|
|
93
93
|
/** Default `"installers"`. */
|
|
94
94
|
outDir?: string;
|
|
95
|
-
}
|
|
95
|
+
};
|
|
96
96
|
/** Returns `config` unchanged; it is there so an untyped config file still gets the config's types. */
|
|
97
97
|
export declare function defineConfig(config: InstallgenConfig): InstallgenConfig;
|
|
98
98
|
export declare const versionToken: VersionToken;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Mixed case, so toUpperCase and toLowerCase both change it and the build reports the call as mangled.
|
|
2
2
|
export const VERSION_SENTINEL = "__InstallGen_Version__";
|
|
3
3
|
export const TAG_SENTINEL = "__InstallGen_Tag__";
|
|
4
4
|
/** Returns `config` unchanged; it is there so an untyped config file still gets the config's types. */
|