@workerstack/clients 1.0.0-rc.28 → 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 +403 -21
- 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 +39 -13
- 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 +18 -8
- 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 +8 -4
- package/dist/emit/csharp/errors.js +4 -4
- package/dist/emit/csharp/json.js +8 -8
- package/dist/emit/csharp/realtime.d.ts +1 -8
- package/dist/emit/csharp/realtime.js +26 -26
- package/dist/emit/csharp/sdk-answer.d.ts +10 -2
- 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 +19 -8
- 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 -13
- package/dist/emit/csharp/sse.js +92 -11
- package/dist/emit/csharp/transport.js +9 -9
- package/dist/emit/csharp/types-enum.js +3 -1
- package/dist/emit/csharp/types-messages.d.ts +47 -0
- package/dist/emit/csharp/types-messages.js +172 -0
- package/dist/emit/csharp/types-names.js +13 -14
- 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.d.ts +0 -15
- package/dist/emit/csharp/ws.js +26 -5
- 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.d.ts +24 -1
- 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.d.ts +3 -0
- package/dist/emit/go/sdk-method.js +18 -12
- 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.d.ts +2 -10
- package/dist/emit/go/sse.js +88 -13
- 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-union.d.ts +3 -2
- package/dist/emit/go/types-union.js +2 -0
- package/dist/emit/go/types.d.ts +6 -0
- package/dist/emit/go/types.js +20 -9
- package/dist/emit/go/ws.d.ts +4 -11
- package/dist/emit/go/ws.js +215 -59
- package/dist/emit/java/gradle.d.ts +7 -9
- package/dist/emit/java/gradle.js +8 -8
- package/dist/emit/java/json.d.ts +3 -0
- package/dist/emit/java/json.js +1 -1
- package/dist/emit/java/layout-ast.d.ts +4 -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.d.ts +2 -0
- package/dist/emit/java/models-names.js +6 -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 +13 -2
- package/dist/emit/java/models-union.js +12 -6
- package/dist/emit/java/models.d.ts +5 -1
- package/dist/emit/java/models.js +44 -20
- package/dist/emit/java/realtime.d.ts +34 -26
- package/dist/emit/java/realtime.js +45 -10
- 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 +7 -6
- 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 +9 -9
- 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 +12 -13
- package/dist/emit/java/sse.js +105 -6
- package/dist/emit/java/ws.d.ts +48 -9
- package/dist/emit/java/ws.js +88 -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.d.ts +4 -2
- package/dist/emit/mcp/output-schema.js +58 -14
- 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.d.ts +9 -6
- package/dist/emit/python/realtime.js +22 -20
- package/dist/emit/python/sdk-answer.d.ts +8 -8
- 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.d.ts +1 -1
- package/dist/emit/python/sdk-method.js +38 -11
- 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 +28 -8
- package/dist/emit/python/sse.d.ts +0 -7
- package/dist/emit/python/sse.js +36 -6
- 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.d.ts +7 -0
- package/dist/emit/python/types.js +23 -6
- package/dist/emit/python/ws.d.ts +21 -10
- package/dist/emit/python/ws.js +69 -3
- package/dist/emit/rust/errors.js +3 -3
- package/dist/emit/rust/http.js +4 -4
- package/dist/emit/rust/realtime.d.ts +7 -5
- package/dist/emit/rust/realtime.js +15 -18
- 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 +3 -3
- 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 +11 -12
- package/dist/emit/rust/sse.js +54 -8
- 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 +10 -2
- package/dist/emit/rust/types-union.js +4 -0
- package/dist/emit/rust/types.d.ts +9 -0
- package/dist/emit/rust/types.js +20 -12
- package/dist/emit/rust/ws.d.ts +22 -15
- package/dist/emit/rust/ws.js +60 -10
- 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 +6 -2
- package/dist/emit/ts/sdk-types.js +59 -20
- package/dist/emit/ts/sdk.js +6 -6
- package/dist/emit/ts/service-map.d.ts +10 -3
- package/dist/emit/ts/service-map.js +30 -2
- package/dist/emit/ts/tanstack-query.js +6 -6
- package/dist/emit/ts/type-gen.js +36 -21
- 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 +12 -5
- package/dist/ir/load.js +9 -10
- package/dist/ir/model.d.ts +16 -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.d.ts +25 -1
- package/dist/ir/sdk-model.js +38 -8
- package/dist/ir/slots.d.ts +1 -1
- package/dist/ir/slots.js +22 -11
- package/dist/ir/streams.d.ts +16 -0
- package/dist/ir/streams.js +40 -0
- 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/cli/socket.go +107 -13
- package/dist/runtime/cli/stream.go +18 -11
- package/dist/runtime/csharp/Adapters.cs +12 -11
- package/dist/runtime/csharp/Events.cs +22 -17
- package/dist/runtime/csharp/Realtime.cs +50 -23
- package/dist/runtime/csharp/RealtimeLoop.cs +1 -1
- package/dist/runtime/csharp/TransportSse.cs +3 -3
- package/dist/runtime/csharp/Ws.cs +1 -1
- package/dist/runtime/csharp/WsDial.cs +19 -1
- package/dist/runtime/csharp/WsTyped.cs +109 -0
- package/dist/runtime/go/realtime.go +125 -41
- package/dist/runtime/go/realtime_loop.go +21 -18
- package/dist/runtime/go/result.go +2 -1
- package/dist/runtime/go/sse.go +11 -0
- package/dist/runtime/go/stream.go +29 -13
- package/dist/runtime/go/transport.go +15 -21
- package/dist/runtime/go/transport_longpoll.go +3 -4
- package/dist/runtime/go/transport_sse.go +6 -6
- package/dist/runtime/go/ws.go +157 -61
- package/dist/runtime/java/EventStream.java +47 -29
- package/dist/runtime/java/Exchange.java +5 -5
- package/dist/runtime/java/Flight.java +3 -3
- package/dist/runtime/java/Realtime.java +45 -11
- package/dist/runtime/java/ResumableConnection.java +77 -32
- package/dist/runtime/java/Socket.java +8 -4
- package/dist/runtime/java/SseAdapter.java +1 -1
- package/dist/runtime/java/TypedWebSocket.java +81 -24
- package/dist/runtime/java/WsAdapter.java +4 -2
- package/dist/runtime/java/WsDial.java +12 -5
- 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/python/events.py +25 -11
- package/dist/runtime/python/operation.py +6 -1
- package/dist/runtime/python/realtime.py +47 -33
- package/dist/runtime/python/send_async.py +1 -0
- package/dist/runtime/python/transport_sse.py +2 -2
- package/dist/runtime/python/transport_ws.py +1 -1
- package/dist/runtime/python/ws.py +100 -39
- package/dist/runtime/rust/events.rs +64 -41
- package/dist/runtime/rust/realtime.rs +80 -34
- package/dist/runtime/rust/realtime_loop.rs +37 -12
- package/dist/runtime/rust/sse.rs +3 -2
- package/dist/runtime/rust/transport_sse.rs +1 -1
- package/dist/runtime/rust/transport_ws.rs +3 -2
- package/dist/runtime/rust/ws.rs +122 -50
- package/dist/runtime/ts/realtime-connection.ts +22 -0
- package/dist/runtime/ts/realtime-transports.ts +13 -4
- package/dist/runtime/ts/realtime.ts +27 -3
- package/dist/runtime/ts/sdk-realtime.ts +1 -1
- package/dist/runtime/ts/sdk-sse.ts +31 -14
- package/dist/runtime/ts/sdk-ws.ts +2 -1
- package/dist/runtime/ts/sdk.ts +9 -2
- package/dist/runtime/ts/sse.ts +8 -0
- package/dist/runtime/ts/ws.ts +88 -50
- package/dist/runtime/ts-tanstack-query/query.ts +0 -2
- package/package.json +12 -40
- 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
|
@@ -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. */
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type BunBuild = {
|
|
2
2
|
module(specifier: string, load: () => {
|
|
3
3
|
exports: Record<string, unknown>;
|
|
4
4
|
loader: "object";
|
|
5
5
|
}): void;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
};
|
|
7
|
+
export type BunPlugin = {
|
|
8
8
|
name: string;
|
|
9
9
|
setup(build: BunBuild): void | Promise<void>;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
/** The slice of the `Bun` global the loader uses. */
|
|
12
|
-
export
|
|
12
|
+
export type BunLike = {
|
|
13
13
|
plugin(plugin: BunPlugin): void;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
type Importer = (url: string) => Promise<Record<string, unknown>>;
|
|
16
16
|
/**
|
|
17
17
|
* Bun's `onResolve` never sees the imports a runtime-loaded config makes; `build.module` does. The config's import of
|
|
@@ -9,7 +9,7 @@ export function registerNodeHook(specifier, selfUrl, register = module.registerH
|
|
|
9
9
|
return register({
|
|
10
10
|
resolve(imported, context, nextResolve) {
|
|
11
11
|
if (imported === specifier)
|
|
12
|
-
return {
|
|
12
|
+
return { shortCircuit: true, url: selfUrl };
|
|
13
13
|
return nextResolve(imported, context);
|
|
14
14
|
},
|
|
15
15
|
});
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import type { InstallgenConfig } from "./define-config.ts";
|
|
2
2
|
import { type BunLike } from "./hooks/bun.ts";
|
|
3
3
|
import { type RegisterHooks } from "./hooks/node.ts";
|
|
4
|
-
/** The specifier an installgen config imports `defineConfig` from, resolved to the running package. */
|
|
5
|
-
export declare const INSTALLERS_SPECIFIER = "@workerstack/clients/installers";
|
|
6
4
|
export declare const CONFIG_FILES: readonly ["installgen.config.ts", "installgen.config.mts", "installgen.config.js", "installgen.config.mjs"];
|
|
7
|
-
export
|
|
5
|
+
export type RuntimeInfo = {
|
|
8
6
|
runtime: "node" | "bun";
|
|
9
7
|
/** `process.versions.node`; Bun reports the Node version it implements. */
|
|
10
8
|
nodeVersion: string;
|
|
11
9
|
bun?: BunLike;
|
|
12
|
-
}
|
|
10
|
+
};
|
|
13
11
|
export declare function detectRuntime(scope?: {
|
|
14
12
|
Bun?: BunLike;
|
|
15
13
|
}, nodeVersion?: string): RuntimeInfo;
|
|
16
14
|
type Importer = (url: string) => Promise<Record<string, unknown>>;
|
|
17
|
-
export
|
|
15
|
+
export type LoadOptions = {
|
|
18
16
|
cwd: string;
|
|
19
17
|
/** `-c`: relative to `cwd`. */
|
|
20
18
|
configPath?: string | undefined;
|
|
@@ -24,11 +22,11 @@ export interface LoadOptions {
|
|
|
24
22
|
importModule?: Importer;
|
|
25
23
|
/** Node's `module.registerHooks`. */
|
|
26
24
|
registerHooks?: RegisterHooks;
|
|
27
|
-
}
|
|
28
|
-
export
|
|
25
|
+
};
|
|
26
|
+
export type LoadedConfig = {
|
|
29
27
|
path: string;
|
|
30
28
|
config: InstallgenConfig;
|
|
31
|
-
}
|
|
29
|
+
};
|
|
32
30
|
/** Whether Node `version` imports a `.ts` module natively: from 22.18, and on 23 from 23.6. */
|
|
33
31
|
export declare function stripsTypes(version: string): boolean;
|
|
34
32
|
export declare function loadConfig(options: LoadOptions): Promise<LoadedConfig>;
|
|
@@ -13,7 +13,7 @@ import { InstallgenError } from "../errors.js";
|
|
|
13
13
|
import { registerBunHook } from "./hooks/bun.js";
|
|
14
14
|
import { registerNodeHook } from "./hooks/node.js";
|
|
15
15
|
/** The specifier an installgen config imports `defineConfig` from, resolved to the running package. */
|
|
16
|
-
|
|
16
|
+
const INSTALLERS_SPECIFIER = "@workerstack/clients/installers";
|
|
17
17
|
export const CONFIG_FILES = [
|
|
18
18
|
"installgen.config.ts",
|
|
19
19
|
"installgen.config.mts",
|
|
@@ -21,9 +21,9 @@ export const CONFIG_FILES = [
|
|
|
21
21
|
"installgen.config.mjs",
|
|
22
22
|
];
|
|
23
23
|
export function detectRuntime(scope = globalThis, nodeVersion = process.versions.node) {
|
|
24
|
-
return scope.Bun ? {
|
|
24
|
+
return scope.Bun ? { bun: scope.Bun, nodeVersion, runtime: "bun" } : { nodeVersion, runtime: "node" };
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
// Node strips types from .ts without a flag from 22.18, and on 23 from 23.6
|
|
27
27
|
const CJS_SYNTAX = /Unexpected token 'export'|Cannot use import statement outside a module/;
|
|
28
28
|
function find(cwd, configPath) {
|
|
29
29
|
if (configPath !== undefined) {
|
|
@@ -70,10 +70,10 @@ export async function loadConfig(options) {
|
|
|
70
70
|
const ext = extname(path);
|
|
71
71
|
const { runtime } = options;
|
|
72
72
|
const importModule = options.importModule ?? ((url) => import(__rewriteRelativeImportExtension(url)));
|
|
73
|
-
|
|
73
|
+
// the sibling entry in this module's own form: index.ts from a checkout's source, index.js from an install
|
|
74
74
|
const selfUrl = options.selfUrl ?? new URL(`../index${extname(new URL(import.meta.url).pathname)}`, import.meta.url).href;
|
|
75
75
|
assertStripsTypes(runtime, ext);
|
|
76
|
-
|
|
76
|
+
// Bun's plugin stays for the process; Node's hook goes once the config is imported
|
|
77
77
|
let hook;
|
|
78
78
|
if (runtime.bun)
|
|
79
79
|
await registerBunHook(runtime.bun, INSTALLERS_SPECIFIER, selfUrl, importModule);
|
|
@@ -90,8 +90,7 @@ export async function loadConfig(options) {
|
|
|
90
90
|
hook?.deregister();
|
|
91
91
|
}
|
|
92
92
|
const config = mod.default;
|
|
93
|
-
if (typeof config !== "object" || config === null)
|
|
93
|
+
if (typeof config !== "object" || config === null)
|
|
94
94
|
throw new InstallgenError(`${path} has no default export; write \`export default defineConfig({ ... })\``);
|
|
95
|
-
}
|
|
96
|
-
return { path, config: config };
|
|
95
|
+
return { config: config, path };
|
|
97
96
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type InstallgenConfig
|
|
1
|
+
import { type InstallgenConfig } from "./define-config.ts";
|
|
2
2
|
import type { ResolvedConfig } from "./types.ts";
|
|
3
|
-
export declare const ALL_PLATFORMS: readonly Platform[];
|
|
4
3
|
export declare function resolveConfig(input: InstallgenConfig): ResolvedConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InstallgenError } from "../errors.js";
|
|
2
2
|
import { TAG_SENTINEL, VERSION_SENTINEL, tagToken, versionToken, } from "./define-config.js";
|
|
3
|
-
|
|
3
|
+
const ALL_PLATFORMS = [
|
|
4
4
|
"linux/amd64",
|
|
5
5
|
"linux/arm64",
|
|
6
6
|
"darwin/amd64",
|
|
@@ -11,12 +11,12 @@ export const ALL_PLATFORMS = [
|
|
|
11
11
|
const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
12
12
|
const ENV_PREFIX = /^[A-Z_][A-Z0-9_]*$/;
|
|
13
13
|
const TAG_PREFIX = /^[A-Za-z0-9._-]*$/;
|
|
14
|
-
|
|
14
|
+
// Each segment of installDir after ~/: rendered into sh and ps1 paths and shell profile lines
|
|
15
15
|
const DIR_SEGMENT = /^[A-Za-z0-9._ -]+$/;
|
|
16
16
|
const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
|
|
17
17
|
const LOOPBACK = ["127.0.0.1", "localhost", "[::1]"];
|
|
18
18
|
const MANGLED = /installgen(version|tag)/;
|
|
19
|
-
|
|
19
|
+
// the issuer of the OIDC token a GitHub Actions run signs with
|
|
20
20
|
const GITHUB_ACTIONS_ISSUER = "https://token.actions.githubusercontent.com";
|
|
21
21
|
const fail = (message) => {
|
|
22
22
|
throw new InstallgenError(message);
|
|
@@ -52,25 +52,25 @@ function checkUrl(field, url) {
|
|
|
52
52
|
return fail(`config.${field} must be an https URL (http is allowed only on loopback), got ${JSON.stringify(url)}`);
|
|
53
53
|
}
|
|
54
54
|
function checkRelative(field, path) {
|
|
55
|
-
if (path === "" || path.startsWith("/") || SCHEME.test(path))
|
|
55
|
+
if (path === "" || path.startsWith("/") || SCHEME.test(path))
|
|
56
56
|
fail(`config.${field} must be a path relative to baseUrl, got ${JSON.stringify(path)}`);
|
|
57
|
-
}
|
|
58
57
|
}
|
|
59
58
|
function noSentinel(field, value) {
|
|
60
|
-
if (value?.includes(VERSION_SENTINEL) || value?.includes(TAG_SENTINEL))
|
|
59
|
+
if (value?.includes(VERSION_SENTINEL) || value?.includes(TAG_SENTINEL))
|
|
61
60
|
fail(`config.${field} cannot hold a version or tag token; only path functions can`);
|
|
62
|
-
}
|
|
63
61
|
}
|
|
64
62
|
/** Splits on the exact sentinels; a sentinel a string method rewrote is still recognizable in a literal piece. */
|
|
65
63
|
function split(field, platform, path) {
|
|
66
64
|
const segments = [];
|
|
67
65
|
for (const piece of path.split(new RegExp(`(${VERSION_SENTINEL}|${TAG_SENTINEL})`))) {
|
|
68
|
-
if (piece === VERSION_SENTINEL)
|
|
66
|
+
if (piece === VERSION_SENTINEL) {
|
|
69
67
|
segments.push({ kind: "version" });
|
|
70
|
-
|
|
68
|
+
}
|
|
69
|
+
else if (piece === TAG_SENTINEL) {
|
|
71
70
|
segments.push({ kind: "tag" });
|
|
71
|
+
}
|
|
72
72
|
else if (piece !== "") {
|
|
73
|
-
if (MANGLED.test(piece.toLowerCase().
|
|
73
|
+
if (MANGLED.test(piece.toLowerCase().replaceAll(/[^a-z0-9]/g, ""))) {
|
|
74
74
|
fail(`config.${field} for ${platform} returned a mangled version or tag token (${JSON.stringify(path)}); ` +
|
|
75
75
|
"interpolate it as-is, without string methods");
|
|
76
76
|
}
|
|
@@ -79,7 +79,7 @@ function split(field, platform, path) {
|
|
|
79
79
|
}
|
|
80
80
|
return segments;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
// A certificate identity is matched, never fetched: https only, loopback included
|
|
83
83
|
function checkIdentity(field, identity) {
|
|
84
84
|
let parsed;
|
|
85
85
|
try {
|
|
@@ -88,9 +88,8 @@ function checkIdentity(field, identity) {
|
|
|
88
88
|
catch {
|
|
89
89
|
// reported below
|
|
90
90
|
}
|
|
91
|
-
if (parsed?.protocol !== "https:" || parsed.host === "")
|
|
91
|
+
if (parsed?.protocol !== "https:" || parsed.host === "")
|
|
92
92
|
fail(`config.${field} must return an https URL, got ${JSON.stringify(identity)}`);
|
|
93
|
-
}
|
|
94
93
|
}
|
|
95
94
|
function evaluate(field, fn, ctx, check = checkRelative) {
|
|
96
95
|
const out = fn(ctx);
|
|
@@ -115,7 +114,7 @@ function signatureOf(config, signed) {
|
|
|
115
114
|
noSentinel("signature.issuer", issuer);
|
|
116
115
|
if (!checkUrl("signature.issuer", issuer))
|
|
117
116
|
fail(`config.signature.issuer must be an https URL, got ${JSON.stringify(issuer)}`);
|
|
118
|
-
return {
|
|
117
|
+
return { bundlePath, identity, issuer };
|
|
119
118
|
}
|
|
120
119
|
function formatOf(asset) {
|
|
121
120
|
const tail = asset.toLowerCase();
|
|
@@ -135,9 +134,8 @@ function platformsOf(config) {
|
|
|
135
134
|
fail("config.platforms must list at least one platform");
|
|
136
135
|
const seen = new Set();
|
|
137
136
|
for (const p of value) {
|
|
138
|
-
if (!ALL_PLATFORMS.includes(p))
|
|
137
|
+
if (!ALL_PLATFORMS.includes(p))
|
|
139
138
|
fail(`config.platforms has unknown platform ${JSON.stringify(p)}; use one of ${ALL_PLATFORMS.join(", ")}`);
|
|
140
|
-
}
|
|
141
139
|
if (seen.has(p))
|
|
142
140
|
fail(`config.platforms lists ${p} twice`);
|
|
143
141
|
seen.add(p);
|
|
@@ -146,14 +144,14 @@ function platformsOf(config) {
|
|
|
146
144
|
}
|
|
147
145
|
const key = (segments) => segments.map((s) => (s.kind === "literal" ? `L${s.value}` : s.kind)).join("\0");
|
|
148
146
|
const osOf = (platform) => platform.split("/")[0];
|
|
149
|
-
|
|
147
|
+
// GoReleaser universal_binaries: one asset serves both macOS architectures
|
|
150
148
|
const universal = (a, b) => osOf(a) === "darwin" && osOf(b) === "darwin";
|
|
151
149
|
function pathFunctionsOf(config) {
|
|
152
150
|
const assetPath = required(func(config, "assetPath"), "assetPath", "a function");
|
|
153
151
|
const checksumsPath = func(config, "checksumsPath");
|
|
154
152
|
const signature = signatureOf(config, checksumsPath !== undefined);
|
|
155
153
|
const binaryInArchive = func(config, "binaryInArchive");
|
|
156
|
-
return { assetPath, checksumsPath, signature
|
|
154
|
+
return { assetPath, binaryInArchive, checksumsPath, signature };
|
|
157
155
|
}
|
|
158
156
|
function tagPrefixOf(config) {
|
|
159
157
|
const tagPrefix = string(config, "tagPrefix") ?? "v";
|
|
@@ -172,7 +170,7 @@ function installDirOf(config, name) {
|
|
|
172
170
|
return installDir;
|
|
173
171
|
}
|
|
174
172
|
function envPrefixOf(config, name) {
|
|
175
|
-
const derived = name.toUpperCase().
|
|
173
|
+
const derived = name.toUpperCase().replaceAll(/[^A-Z0-9]/g, "_");
|
|
176
174
|
const envPrefix = string(config, "envPrefix") ?? (/^[0-9]/.test(derived) ? `_${derived}` : derived);
|
|
177
175
|
if (!ENV_PREFIX.test(envPrefix))
|
|
178
176
|
fail(`config.envPrefix must match ${ENV_PREFIX.source}, got ${JSON.stringify(envPrefix)}`);
|
|
@@ -186,7 +184,7 @@ function outDirOf(config) {
|
|
|
186
184
|
}
|
|
187
185
|
function scriptUrlsOf(config, baseUrl) {
|
|
188
186
|
if (config.scriptUrls === undefined)
|
|
189
|
-
return {
|
|
187
|
+
return { ps1: `${baseUrl}/install.ps1`, sh: `${baseUrl}/install.sh` };
|
|
190
188
|
if (typeof config.scriptUrls !== "object" || config.scriptUrls === null)
|
|
191
189
|
fail("config.scriptUrls must be an object");
|
|
192
190
|
const urls = config.scriptUrls;
|
|
@@ -194,7 +192,7 @@ function scriptUrlsOf(config, baseUrl) {
|
|
|
194
192
|
const ps1 = required(string(urls, "ps1"), "scriptUrls.ps1", "a string");
|
|
195
193
|
checkUrl("scriptUrls.sh", sh);
|
|
196
194
|
checkUrl("scriptUrls.ps1", ps1);
|
|
197
|
-
return {
|
|
195
|
+
return { ps1, sh };
|
|
198
196
|
}
|
|
199
197
|
/** The settings after the path functions, validated in the order a config's errors are reported. */
|
|
200
198
|
function settingsOf(config, name, baseUrl) {
|
|
@@ -219,10 +217,9 @@ function settingsOf(config, name, baseUrl) {
|
|
|
219
217
|
["outDir", outDir],
|
|
220
218
|
["scriptUrls.sh", scriptUrls.sh],
|
|
221
219
|
["scriptUrls.ps1", scriptUrls.ps1],
|
|
222
|
-
])
|
|
220
|
+
])
|
|
223
221
|
noSentinel(field, value);
|
|
224
|
-
}
|
|
225
|
-
return { latestPath, tagPrefix, installDir, envPrefix, modifyPath, message, outDir, scriptUrls };
|
|
222
|
+
return { envPrefix, installDir, latestPath, message, modifyPath, outDir, scriptUrls, tagPrefix };
|
|
226
223
|
}
|
|
227
224
|
function resolveSignature(signature, ctx, checksumsRaw) {
|
|
228
225
|
const platform = `${ctx.os}/${ctx.arch}`;
|
|
@@ -238,30 +235,28 @@ function resolveSignature(signature, ctx, checksumsRaw) {
|
|
|
238
235
|
}
|
|
239
236
|
function resolvePlatform(platform, fns, assets) {
|
|
240
237
|
const [os, arch] = platform.split("/");
|
|
241
|
-
const ctx = {
|
|
238
|
+
const ctx = { arch, os, tag: tagToken, version: versionToken };
|
|
242
239
|
const assetRaw = evaluate("assetPath", fns.assetPath, ctx);
|
|
243
240
|
const asset = split("assetPath", platform, assetRaw);
|
|
244
|
-
if (asset.every((s) => s.kind === "literal"))
|
|
241
|
+
if (asset.every((s) => s.kind === "literal"))
|
|
245
242
|
fail(`config.assetPath for ${platform} must contain the version or tag token, got ${JSON.stringify(assetRaw)}`);
|
|
246
|
-
}
|
|
247
243
|
const prior = assets.get(key(asset));
|
|
248
|
-
if (prior !== undefined && !universal(prior, platform))
|
|
244
|
+
if (prior !== undefined && !universal(prior, platform))
|
|
249
245
|
fail(`config.assetPath gives ${prior} and ${platform} the same asset ${JSON.stringify(assetRaw)}`);
|
|
250
|
-
}
|
|
251
246
|
assets.set(key(asset), platform);
|
|
252
247
|
const checksumsRaw = fns.checksumsPath && evaluate("checksumsPath", fns.checksumsPath, { ...ctx, asset: assetRaw });
|
|
253
248
|
const signature = fns.signature && checksumsRaw !== undefined
|
|
254
249
|
? resolveSignature(fns.signature, { ...ctx, asset: assetRaw }, checksumsRaw)
|
|
255
250
|
: undefined;
|
|
256
251
|
return {
|
|
257
|
-
platform,
|
|
258
|
-
os,
|
|
259
252
|
arch,
|
|
260
253
|
asset,
|
|
261
|
-
|
|
254
|
+
binaryInArchive: fns.binaryInArchive && split("binaryInArchive", platform, evaluate("binaryInArchive", fns.binaryInArchive, ctx)),
|
|
262
255
|
checksums: checksumsRaw === undefined ? undefined : split("checksumsPath", platform, checksumsRaw),
|
|
256
|
+
format: formatOf(assetRaw),
|
|
257
|
+
os,
|
|
258
|
+
platform,
|
|
263
259
|
signature,
|
|
264
|
-
binaryInArchive: fns.binaryInArchive && split("binaryInArchive", platform, evaluate("binaryInArchive", fns.binaryInArchive, ctx)),
|
|
265
260
|
};
|
|
266
261
|
}
|
|
267
262
|
export function resolveConfig(input) {
|
|
@@ -9,12 +9,12 @@ export type Segment = {
|
|
|
9
9
|
readonly kind: "tag";
|
|
10
10
|
};
|
|
11
11
|
export type Format = "tar.gz" | "zip" | "raw";
|
|
12
|
-
export
|
|
12
|
+
export type ResolvedSignature = {
|
|
13
13
|
readonly bundle: readonly Segment[];
|
|
14
14
|
readonly identity: readonly Segment[];
|
|
15
15
|
readonly issuer: string;
|
|
16
|
-
}
|
|
17
|
-
export
|
|
16
|
+
};
|
|
17
|
+
export type ResolvedPlatform = {
|
|
18
18
|
readonly platform: Platform;
|
|
19
19
|
readonly os: Os;
|
|
20
20
|
readonly arch: Arch;
|
|
@@ -23,8 +23,8 @@ export interface ResolvedPlatform {
|
|
|
23
23
|
readonly checksums: readonly Segment[] | undefined;
|
|
24
24
|
readonly signature: ResolvedSignature | undefined;
|
|
25
25
|
readonly binaryInArchive: readonly Segment[] | undefined;
|
|
26
|
-
}
|
|
27
|
-
export
|
|
26
|
+
};
|
|
27
|
+
export type ResolvedConfig = {
|
|
28
28
|
readonly name: string;
|
|
29
29
|
/** No trailing slash. */
|
|
30
30
|
readonly baseUrl: string;
|
|
@@ -42,4 +42,4 @@ export interface ResolvedConfig {
|
|
|
42
42
|
};
|
|
43
43
|
readonly outDir: string;
|
|
44
44
|
readonly platforms: readonly ResolvedPlatform[];
|
|
45
|
-
}
|
|
45
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* `-Version` parameter).
|
|
5
|
-
*/
|
|
1
|
+
// Literals are single-quoted, where neither shell expands anything; the tokens become the scripts' own variables.
|
|
2
|
+
// sh: `$version` / `$tag`. ps1: `$ver` / `$tag` (PowerShell names are case-insensitive, so `$version` would be the
|
|
3
|
+
// `-Version` parameter).
|
|
6
4
|
/** One sh word: adjacent quoted pieces, so no separator is needed. */
|
|
7
5
|
export function shWord(segments) {
|
|
8
6
|
if (segments.length === 0)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { ResolvedConfig } from "../config/types.ts";
|
|
2
2
|
/** How `generateInstallers` renders beyond the config itself. */
|
|
3
|
-
export
|
|
3
|
+
export type RenderOptions = {
|
|
4
4
|
/** Baked in as the version to install when neither the argument nor `<PREFIX>_VERSION` names one. */
|
|
5
5
|
defaultVersion?: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
};
|
|
7
|
+
export type Templates = {
|
|
8
8
|
sh: string;
|
|
9
9
|
ps1: string;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
/** The scripts a config needs: each is absent when none of its platforms needs that script. */
|
|
12
|
-
export
|
|
12
|
+
export type Rendered = {
|
|
13
13
|
/** `install.sh`, for the linux and darwin platforms; served for `curl -fsSL <url> | sh`. */
|
|
14
14
|
sh?: string;
|
|
15
15
|
/** `install.ps1`, for the windows platforms; served for `irm <url> | iex`. */
|
|
16
16
|
ps1?: string;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
export declare function readTemplates(): Templates;
|
|
19
19
|
/** The value of each `@@KEY@@` in install.sh and install.ps1, already quoted for its shell. */
|
|
20
20
|
export declare function placeholders(resolved: ResolvedConfig, options: RenderOptions): {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { InstallgenError } from "../errors.js";
|
|
3
3
|
import { psLiteral, psString, shLiteral, shWord } from "./quote.js";
|
|
4
|
-
|
|
4
|
+
// The scripts validate the same pattern at install time, after stripping the tag prefix
|
|
5
5
|
const VERSION = /^[A-Za-z0-9._+-]+$/;
|
|
6
|
-
|
|
6
|
+
// in non-unicode mode an astral character is two surrogates, both in this range
|
|
7
7
|
const NON_ASCII = /[\u0080-\uffff]/;
|
|
8
8
|
const PLACEHOLDER = /@@([A-Z0-9_]+)@@/g;
|
|
9
9
|
const readTemplate = (file) => readFileSync(new URL(`../../../assets/installers/templates/${file}`, import.meta.url), "utf8");
|
|
10
10
|
export function readTemplates() {
|
|
11
|
-
return {
|
|
11
|
+
return { ps1: readTemplate("install.ps1"), sh: readTemplate("install.sh") };
|
|
12
12
|
}
|
|
13
13
|
function ascii(field, value) {
|
|
14
14
|
if (value !== undefined && NON_ASCII.test(value)) {
|
|
@@ -65,26 +65,6 @@ export function placeholders(resolved, options) {
|
|
|
65
65
|
const defaultVersion = options.defaultVersion ?? "";
|
|
66
66
|
const message = resolved.message ?? "";
|
|
67
67
|
return {
|
|
68
|
-
sh: {
|
|
69
|
-
NAME: shLiteral(resolved.name),
|
|
70
|
-
ENV_PREFIX: resolved.envPrefix,
|
|
71
|
-
BASE_URL: shLiteral(resolved.baseUrl),
|
|
72
|
-
LATEST_URL: shLiteral(latestUrl),
|
|
73
|
-
DEFAULT_VERSION: shLiteral(defaultVersion),
|
|
74
|
-
TAG_PREFIX: shLiteral(resolved.tagPrefix),
|
|
75
|
-
INSTALL_DIR: `"$HOME"${shLiteral(`/${resolved.installDir}`)}`,
|
|
76
|
-
INSTALL_DIR_DISPLAY: shLiteral(`~/${resolved.installDir}`),
|
|
77
|
-
MODIFY_PATH: resolved.modifyPath ? "1" : "0",
|
|
78
|
-
MESSAGE: shLiteral(message),
|
|
79
|
-
SH_URL: shLiteral(resolved.scriptUrls.sh),
|
|
80
|
-
/* with no Windows build there is no install.ps1 to point Git Bash users at */
|
|
81
|
-
PS1_URL: shLiteral(windows.length > 0 ? resolved.scriptUrls.ps1 : ""),
|
|
82
|
-
CURL_FLAGS: resolved.https ? "--proto '=https' --tlsv1.2" : "",
|
|
83
|
-
WGET_FLAGS: shLiteral(resolved.https ? "--https-only" : ""),
|
|
84
|
-
/* a case pattern list */
|
|
85
|
-
PLATFORMS: unix.map((p) => shLiteral(p.platform)).join(" | "),
|
|
86
|
-
PLATFORM_CASES: unix.map(shCase).join("\n"),
|
|
87
|
-
},
|
|
88
68
|
ps1: {
|
|
89
69
|
NAME: psLiteral(resolved.name),
|
|
90
70
|
ENV_PREFIX: resolved.envPrefix,
|
|
@@ -92,8 +72,8 @@ export function placeholders(resolved, options) {
|
|
|
92
72
|
LATEST_URL: psLiteral(latestUrl),
|
|
93
73
|
DEFAULT_VERSION: psLiteral(defaultVersion),
|
|
94
74
|
TAG_PREFIX: psLiteral(resolved.tagPrefix),
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
// $env:USERPROFILE is unset on non-Windows pwsh and in some service contexts, and a literal \ is a filename
|
|
76
|
+
// character off Windows: Combine(params string[]) (.NET 4, so 5.1 too) joins with the native separator
|
|
97
77
|
INSTALL_DIR: `[IO.Path]::Combine([string[]](@([Environment]::GetFolderPath('UserProfile')) + @(${resolved.installDir
|
|
98
78
|
.split("/")
|
|
99
79
|
.map(psLiteral)
|
|
@@ -106,10 +86,30 @@ export function placeholders(resolved, options) {
|
|
|
106
86
|
PLATFORMS: `@(${windows.map((p) => psLiteral(p.platform)).join(", ")})`,
|
|
107
87
|
PLATFORM_CASES: windows.map(psCase).join("\n"),
|
|
108
88
|
},
|
|
89
|
+
sh: {
|
|
90
|
+
NAME: shLiteral(resolved.name),
|
|
91
|
+
ENV_PREFIX: resolved.envPrefix,
|
|
92
|
+
BASE_URL: shLiteral(resolved.baseUrl),
|
|
93
|
+
LATEST_URL: shLiteral(latestUrl),
|
|
94
|
+
DEFAULT_VERSION: shLiteral(defaultVersion),
|
|
95
|
+
TAG_PREFIX: shLiteral(resolved.tagPrefix),
|
|
96
|
+
INSTALL_DIR: `"$HOME"${shLiteral(`/${resolved.installDir}`)}`,
|
|
97
|
+
INSTALL_DIR_DISPLAY: shLiteral(`~/${resolved.installDir}`),
|
|
98
|
+
MODIFY_PATH: resolved.modifyPath ? "1" : "0",
|
|
99
|
+
MESSAGE: shLiteral(message),
|
|
100
|
+
SH_URL: shLiteral(resolved.scriptUrls.sh),
|
|
101
|
+
// with no Windows build there is no install.ps1 to point Git Bash users at
|
|
102
|
+
PS1_URL: shLiteral(windows.length > 0 ? resolved.scriptUrls.ps1 : ""),
|
|
103
|
+
CURL_FLAGS: resolved.https ? "--proto '=https' --tlsv1.2" : "",
|
|
104
|
+
WGET_FLAGS: shLiteral(resolved.https ? "--https-only" : ""),
|
|
105
|
+
// a case pattern list
|
|
106
|
+
PLATFORMS: unix.map((p) => shLiteral(p.platform)).join(" | "),
|
|
107
|
+
PLATFORM_CASES: unix.map(shCase).join("\n"),
|
|
108
|
+
},
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
function fill(file, template, values) {
|
|
112
|
-
const out = template.
|
|
112
|
+
const out = template.replaceAll(PLACEHOLDER, (_match, key) => {
|
|
113
113
|
const value = values[key];
|
|
114
114
|
if (value === undefined)
|
|
115
115
|
throw new InstallgenError(`unknown placeholder @@${key}@@ in ${file}`);
|
package/dist/installers/ui.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** Rows like the installers': a mark, a label, a value. Marks and color on a TTY; plain `+`, `x`, `!` otherwise. */
|
|
2
|
-
export
|
|
2
|
+
export type Ui = {
|
|
3
3
|
ok(label: string, value: string): void;
|
|
4
4
|
bad(label: string, value: string): void;
|
|
5
5
|
info(text: string): void;
|
|
6
6
|
warn(text: string): void;
|
|
7
7
|
error(text: string): void;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
};
|
|
9
|
+
export type UiIo = {
|
|
10
10
|
stdout(text: string): void;
|
|
11
11
|
stderr(text: string): void;
|
|
12
12
|
isTTY: boolean;
|
|
13
13
|
env: Record<string, string | undefined>;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
export declare function createUi(io: UiIo): Ui;
|
package/dist/installers/ui.js
CHANGED
|
@@ -3,12 +3,12 @@ const row = (glyph, label, value) => `${glyph} ${label.padEnd(13)} ${value}\n`;
|
|
|
3
3
|
export function createUi(io) {
|
|
4
4
|
const color = io.isTTY && !io.env.NO_COLOR;
|
|
5
5
|
const paint = (code, text) => (color ? `${ESC}[${code}m${text}${ESC}[0m` : text);
|
|
6
|
-
const mark = {
|
|
6
|
+
const mark = { bad: io.isTTY ? "✗" : "x", ok: io.isTTY ? "✓" : "+" };
|
|
7
7
|
return {
|
|
8
|
-
ok: (label, value) => io.stdout(row(paint(32, mark.ok), label, value)),
|
|
9
8
|
bad: (label, value) => io.stdout(row(paint(31, mark.bad), label, value)),
|
|
9
|
+
error: (text) => io.stderr(`${paint(31, io.isTTY ? `${mark.bad} error:` : "error:")} ${text}\n`),
|
|
10
10
|
info: (text) => io.stdout(`${text}\n`),
|
|
11
|
+
ok: (label, value) => io.stdout(row(paint(32, mark.ok), label, value)),
|
|
11
12
|
warn: (text) => io.stderr(`${paint(33, "warning:")} ${text}\n`),
|
|
12
|
-
error: (text) => io.stderr(`${paint(31, io.isTTY ? `${mark.bad} error:` : "error:")} ${text}\n`),
|
|
13
13
|
};
|
|
14
14
|
}
|