@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.31
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 +548 -35
- 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 +88 -68
- package/bin/installgen.js +18 -13
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +20 -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 +18 -2
- package/dist/emit/csharp/sdk-method.js +24 -9
- package/dist/emit/csharp/sdk-plan.js +0 -1
- package/dist/emit/csharp/sdk.js +7 -4
- 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.d.ts +9 -0
- package/dist/emit/go/sdk-method.js +12 -3
- 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 +12 -11
- 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 +2 -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 +7 -11
- package/dist/emit/java/sdk-op.js +22 -10
- 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 +21 -14
- 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.d.ts +11 -0
- package/dist/emit/python/sdk-method.js +20 -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 +12 -8
- 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.d.ts +12 -1
- package/dist/emit/rust/sdk-method.js +12 -4
- 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 +9 -6
- 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 +8 -2
- package/dist/emit/ts/http.js +51 -6
- package/dist/emit/ts/package.d.ts +14 -12
- package/dist/emit/ts/package.js +10 -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 +12 -4
- package/dist/emit/ts/sdk-types.d.ts +0 -5
- package/dist/emit/ts/sdk-types.js +63 -19
- package/dist/emit/ts/sdk.d.ts +3 -1
- package/dist/emit/ts/sdk.js +44 -12
- package/dist/emit/ts/service-map.d.ts +7 -1
- package/dist/emit/ts/service-map.js +10 -1
- package/dist/emit/ts/single-flight-text.d.ts +3 -0
- package/dist/emit/ts/single-flight-text.js +38 -0
- package/dist/emit/ts/tanstack-query.d.ts +3 -2
- package/dist/emit/ts/tanstack-query.js +60 -35
- 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/process.js +2 -1
- package/dist/gen/shipped.js +2 -2
- package/dist/gen/switch-on.constants.d.ts +2 -0
- package/dist/gen/switch-on.constants.js +2 -0
- package/dist/gen/targets.d.ts +6 -7
- package/dist/gen/targets.js +11 -6
- 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/invalidate-reads.d.ts +17 -0
- package/dist/ir/invalidate-reads.js +104 -0
- package/dist/ir/load.d.ts +10 -0
- package/dist/ir/load.js +65 -18
- package/dist/ir/model.d.ts +2 -1
- package/dist/ir/model.js +0 -1
- package/dist/ir/read-method.constants.d.ts +2 -0
- package/dist/ir/read-method.constants.js +2 -0
- 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 +4 -4
- 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/csharp/Config.cs +9 -1
- package/dist/runtime/csharp/Exchange.cs +56 -4
- package/dist/runtime/csharp/Hooks.cs +9 -0
- package/dist/runtime/csharp/Operation.cs +6 -1
- package/dist/runtime/csharp/WsDial.cs +3 -1
- package/dist/runtime/go/config.go +5 -0
- package/dist/runtime/go/hooks.go +70 -0
- package/dist/runtime/go/request.go +6 -2
- package/dist/runtime/go/stream.go +4 -1
- package/dist/runtime/go/ws.go +3 -1
- package/dist/runtime/java/ClientConfig.java +11 -0
- package/dist/runtime/java/Flight.java +2 -12
- package/dist/runtime/java/Hooks.java +45 -0
- package/dist/runtime/java/InvalidateEvent.java +10 -0
- package/dist/runtime/java/InvalidateHook.java +12 -0
- package/dist/runtime/java/InvalidateTarget.java +7 -0
- package/dist/runtime/java/Operation.java +23 -3
- package/dist/runtime/java/Realtime.java +3 -1
- package/dist/runtime/java/WsDial.java +3 -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/python/config.py +8 -2
- package/dist/runtime/python/exchange.py +3 -1
- package/dist/runtime/python/hooks.py +110 -5
- package/dist/runtime/python/operation.py +2 -0
- package/dist/runtime/python/send_async.py +14 -2
- package/dist/runtime/python/send_sync.py +4 -2
- package/dist/runtime/python/ws.py +5 -1
- package/dist/runtime/rust/config.rs +6 -1
- package/dist/runtime/rust/exchange.rs +15 -3
- package/dist/runtime/rust/hooks.rs +127 -2
- package/dist/runtime/rust/log.rs +11 -3
- package/dist/runtime/rust/request.rs +17 -0
- package/dist/runtime/rust/ws.rs +9 -1
- package/dist/runtime/ts/config.ts +69 -0
- package/dist/runtime/ts/http.ts +12 -10
- package/dist/runtime/ts/request.ts +2 -0
- package/dist/runtime/ts/response.ts +7 -0
- package/dist/runtime/ts/sdk-invalidate.ts +82 -0
- package/dist/runtime/ts/sdk-single-flight.constants.ts +25 -0
- package/dist/runtime/ts/sdk-single-flight.ts +203 -0
- package/dist/runtime/ts/sdk-sse.ts +5 -1
- package/dist/runtime/ts/sdk-ws.ts +9 -3
- package/dist/runtime/ts/sdk.ts +55 -31
- package/dist/runtime/ts/single-flight-batch.ts +184 -0
- package/dist/runtime/ts/single-flight-body.ts +59 -0
- package/dist/runtime/ts/single-flight-run.ts +160 -0
- package/dist/runtime/ts/single-flight.constants.ts +31 -0
- package/dist/runtime/ts/single-flight.ts +158 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +96 -92
- package/dist/runtime/ts-tanstack-query/query.ts +140 -170
- package/package.json +12 -17
- package/references/INDEX.md +31 -0
- package/references/cli.md +33 -0
- package/references/configuring.md +29 -0
- package/references/documentation.md +15 -0
- package/references/errors.md +23 -0
- package/references/flags.md +104 -0
- package/references/gates.md +46 -0
- package/references/generate.md +29 -0
- package/references/install-scripts.md +28 -0
- package/references/install.md +38 -0
- package/references/license.md +8 -0
- package/references/mcp.md +76 -0
- package/references/output.md +45 -0
- package/references/overview.md +14 -0
- package/references/release-tooling.md +34 -0
- package/references/release.md +305 -0
- package/references/sdks.md +393 -0
- package/references/start.md +22 -0
- package/references/tdd.md +16 -0
- 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/ir/load.js
CHANGED
|
@@ -11,12 +11,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
11
11
|
* document generated by the app's own core, `@workerstack/backend/http/openapi`, resolved from the app as it would be at run
|
|
12
12
|
* time, so gen imports no core itself (H2). The named export, else `app`, else `default`, is the app; the module's
|
|
13
13
|
* `openApi` export, if any, is the document's options (core's GenerateOpenApiOptions), else a bare `info`. On Node
|
|
14
|
-
* the module loads through
|
|
15
|
-
* checkout read from its source by the backend-source condition, refused when this Bun resolves it
|
|
16
|
-
* With no core installed where the app resolves it, the refusal names it.
|
|
14
|
+
* the module loads through Vite's module runner, a core checkout read from its source by alias; on Bun through Bun's
|
|
15
|
+
* own import, a checkout read from its source by the backend-source condition, refused when this Bun resolves it
|
|
16
|
+
* elsewhere (bit 20). With no core installed where the app resolves it, the refusal names it.
|
|
17
17
|
*/
|
|
18
18
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
19
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
19
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
20
20
|
import { pathToFileURL } from "node:url";
|
|
21
21
|
const CORE = "@workerstack/backend";
|
|
22
22
|
const DEFAULT_OPTIONS = { info: { title: "API", version: "0.0.0" } };
|
|
@@ -63,18 +63,64 @@ function appOf(mod, ref, name) {
|
|
|
63
63
|
const which = name === undefined ? "no `app` or `default` export" : `no export ${JSON.stringify(name)}`;
|
|
64
64
|
throw new Error(`--app ${ref}: ${which} that is a backend app (name one as <module>#<export>)`);
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
/** The id of a module that re-exports what its suffix names, as an import from the app's directory would read it. */
|
|
67
|
+
const REEXPORT = "clients-reexport:";
|
|
68
|
+
/** The plugin serving each REEXPORT module: one `export *` of its specifier. */
|
|
69
|
+
const reexports = {
|
|
70
|
+
load: (id) => id.startsWith(`\0${REEXPORT}`) ? `export * from ${JSON.stringify(id.slice(REEXPORT.length + 1))}\n` : null,
|
|
71
|
+
name: "clients-reexport",
|
|
72
|
+
resolveId: (id) => (id.startsWith(REEXPORT) ? `\0${id}` : null),
|
|
73
|
+
};
|
|
74
|
+
/** The characters a RegExp reads as syntax. */
|
|
75
|
+
const REGEX_SYNTAX = /[$()*+.?[\\\]^{|}]/g;
|
|
76
|
+
/** `text` matched literally in a RegExp. */
|
|
77
|
+
function literal(text) {
|
|
78
|
+
return text.replaceAll(REGEX_SYNTAX, String.raw `\$&`);
|
|
79
|
+
}
|
|
80
|
+
/** Vite's server API, or why `generate --app` can't run on Node without it. */
|
|
81
|
+
function loadVite(vite) {
|
|
82
|
+
return vite().catch((error) => {
|
|
83
|
+
if (error.message.startsWith("Cannot find package 'vite' "))
|
|
84
|
+
throw new Error("clients generate --app on Node loads TypeScript through Vite: install vite, or run it with Bun");
|
|
85
|
+
throw error;
|
|
86
|
+
});
|
|
71
87
|
}
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
88
|
+
/**
|
|
89
|
+
* Node: Vite's SSR runner rooted at the module's directory, one graph shared by the app and its document, so both see
|
|
90
|
+
* one core module (its GRAPH symbol). Each alias matches its specifier exactly, never as a prefix of a longer subpath.
|
|
91
|
+
* The app's Vite config is never applied, and the server holds no handle (no socket, no watcher, no dependency scan),
|
|
92
|
+
* so it is left for the process to end. `vite` is the import, a parameter so its absence can be tested.
|
|
77
93
|
*/
|
|
94
|
+
export async function viteImporter(path, aliases, vite = () => import("vite")) {
|
|
95
|
+
const { createServer, createServerModuleRunner } = await loadVite(vite);
|
|
96
|
+
const server = await createServer({
|
|
97
|
+
appType: "custom",
|
|
98
|
+
configFile: false,
|
|
99
|
+
logLevel: "silent",
|
|
100
|
+
// nothing here serves a browser: no dependency scan of the root
|
|
101
|
+
optimizeDeps: { entries: [], noDiscovery: true },
|
|
102
|
+
plugins: [reexports],
|
|
103
|
+
resolve: {
|
|
104
|
+
alias: Object.entries(aliases).map(([find, replacement]) => ({
|
|
105
|
+
find: new RegExp(`^${literal(find)}$`),
|
|
106
|
+
replacement,
|
|
107
|
+
})),
|
|
108
|
+
},
|
|
109
|
+
root: dirname(path),
|
|
110
|
+
server: { middlewareMode: true, watch: null, ws: false },
|
|
111
|
+
});
|
|
112
|
+
// its own source-map hook, not Node's: a stack frame names the app's line even where another hook owns stacks
|
|
113
|
+
const runner = createServerModuleRunner(server.environments.ssr, {
|
|
114
|
+
hmr: false,
|
|
115
|
+
sourcemapInterceptor: "prepareStackTrace",
|
|
116
|
+
});
|
|
117
|
+
// a bare specifier through a module re-exporting it, so Vite resolves it as it resolves the app's own imports
|
|
118
|
+
// (aliased, inlined or externalized alike) and the app and its document share one core
|
|
119
|
+
return (specifier) => runner.import(isAbsolute(specifier) ? specifier : `${REEXPORT}${specifier}`);
|
|
120
|
+
}
|
|
121
|
+
// Bun: its own import, never Vite's runner, whose source-map hook is the class of Error.prepareStackTrace replacer that
|
|
122
|
+
// breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects; bit 20). A checkout's aliases hold by the
|
|
123
|
+
// backend-source condition instead: each must resolve to its source, never to an unbuilt or stale dist/.
|
|
78
124
|
function bunImporter(bun, path, aliases, ref) {
|
|
79
125
|
const from = dirname(path);
|
|
80
126
|
for (const [specifier, source] of Object.entries(aliases)) {
|
|
@@ -83,10 +129,11 @@ function bunImporter(bun, path, aliases, ref) {
|
|
|
83
129
|
resolved = bun.resolveSync(specifier, from);
|
|
84
130
|
}
|
|
85
131
|
catch {
|
|
86
|
-
|
|
132
|
+
// unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere
|
|
87
133
|
}
|
|
88
|
-
if (resolved !== realpathSync(source))
|
|
134
|
+
if (resolved !== realpathSync(source)) {
|
|
89
135
|
throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the backend-source condition: start Bun with --conditions=backend-source`);
|
|
136
|
+
}
|
|
90
137
|
}
|
|
91
138
|
return (specifier) => import(__rewriteRelativeImportExtension(pathToFileURL(bun.resolveSync(specifier, from)).href));
|
|
92
139
|
}
|
|
@@ -101,9 +148,9 @@ export async function loadAppDocument(ref, cwd) {
|
|
|
101
148
|
throw new Error(`--app ${ref}: no ${CORE} is installed where ${relative(cwd, path)} resolves it`);
|
|
102
149
|
const bun = globalThis.Bun;
|
|
103
150
|
const aliases = sourceAliases(root);
|
|
104
|
-
|
|
151
|
+
// Bun resolves core's own imports under the backend-source condition, through core's package.json
|
|
105
152
|
const load = bun === undefined
|
|
106
|
-
? await
|
|
153
|
+
? await viteImporter(path, { ...aliases.exports, ...aliases.imports })
|
|
107
154
|
: bunImporter(bun, path, aliases.exports, ref);
|
|
108
155
|
const mod = await load(path);
|
|
109
156
|
const app = appOf(mod, ref, name);
|
package/dist/ir/model.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type IRScalarType = "boolean" | "integer" | "null" | "number" | "string";
|
|
6
6
|
/** A value's constraint keywords as the spec states them (bit 19 c): a string's, a number's, an array's. */
|
|
7
|
-
|
|
7
|
+
type IRBounds = {
|
|
8
8
|
minLength?: number;
|
|
9
9
|
maxLength?: number;
|
|
10
10
|
pattern?: string;
|
|
@@ -220,3 +220,4 @@ export type IR = {
|
|
|
220
220
|
/** every webhook, by name in code-unit order */
|
|
221
221
|
webhooks: IRWebhook[];
|
|
222
222
|
};
|
|
223
|
+
export {};
|
package/dist/ir/model.js
CHANGED
package/dist/ir/resolve-refs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PREFIX = "#/components/schemas/";
|
|
2
|
-
|
|
2
|
+
// past this many schema nodes, inlining fails loudly instead of eating the machine
|
|
3
3
|
const MAX_NODES = 200_000;
|
|
4
4
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
5
|
/** `schema` with its component ref, if it is one, replaced by a copy of the component, inlined. */
|
|
@@ -60,7 +60,7 @@ export function resolveRefs(doc) {
|
|
|
60
60
|
inlineContent(response, run);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
// schemas were there, so components are
|
|
64
64
|
const { schemas: _inlined, ...rest } = components;
|
|
65
65
|
return { ...doc, components: Object.keys(rest).length > 0 ? rest : undefined, paths };
|
|
66
66
|
}
|
package/dist/ir/resource-tree.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* values JSON cannot carry first, so equal JSON always means equal values.
|
|
5
5
|
*/
|
|
6
6
|
import { tsString } from "../emit/shared/escape.js";
|
|
7
|
-
|
|
7
|
+
// shorter strings and numbers cost less inline than a name
|
|
8
8
|
const STRING_MIN = 8;
|
|
9
9
|
const NUMBER_MIN = 8;
|
|
10
10
|
/** How deeply `value` nests: 0 for a primitive. */
|
package/dist/ir/schema.js
CHANGED
|
@@ -12,7 +12,7 @@ function isNullable(schema) {
|
|
|
12
12
|
/** The schema `schema` makes nullable; never wrapped twice. */
|
|
13
13
|
function nullableOf(schema) {
|
|
14
14
|
let inner;
|
|
15
|
-
|
|
15
|
+
// only a type list that holds null is stripped; a flag beside any other list drops the flag below
|
|
16
16
|
if (Array.isArray(schema.type) && schema.type.includes("null")) {
|
|
17
17
|
const rest = schema.type.filter((type) => type !== "null");
|
|
18
18
|
inner = schemaToIR({ ...schema, type: rest.length === 1 ? rest[0] : rest });
|
|
@@ -119,7 +119,7 @@ function constOf(schema) {
|
|
|
119
119
|
const typed = SCALARS.includes(schema.type) && schema.type !== "null";
|
|
120
120
|
return typed ? { kind: "const", type: schema.type, value } : { kind: "const", value };
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
// the constraint keywords a value carries (bit 19 c), each read when the spec states it with its JSON type
|
|
123
123
|
const BOUNDS = ["minLength", "maxLength", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum"];
|
|
124
124
|
function scalarOf(schema) {
|
|
125
125
|
if (!SCALARS.includes(schema.type))
|
|
@@ -147,7 +147,7 @@ function arrayOf(schema) {
|
|
|
147
147
|
array.maxItems = schema.maxItems;
|
|
148
148
|
return array;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
// the order matters: a ref before anything it might also say, const before type, nullability before unions
|
|
151
151
|
const READERS = [
|
|
152
152
|
(schema) => (typeof schema.$ref === "string" ? { kind: "ref", name: lastSegment(schema.$ref) } : null),
|
|
153
153
|
(schema) => (Array.isArray(schema.allOf) ? { kind: "allOf", parts: schema.allOf.map(schemaToIR) } : null),
|
package/dist/ir/sdk-model.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* realtime calls alike, instead of in each emitter.
|
|
5
5
|
*/
|
|
6
6
|
import { compareCodeUnits } from "../emit/shared/lang.js";
|
|
7
|
+
import {} from "./model.js";
|
|
7
8
|
import { irResolver } from "./schema.js";
|
|
8
9
|
import { parseOpenApiPath } from "./slots.js";
|
|
9
10
|
/** A media type's essence: `Application/JSON; charset=utf-8` → `application/json`. */
|
|
@@ -34,9 +35,8 @@ function successOf(op) {
|
|
|
34
35
|
const status = codes.find((code) => op.responses[code]?.contentType !== undefined) ?? codes[0];
|
|
35
36
|
if (status === undefined) {
|
|
36
37
|
const fallback = op.responses["2XX"] ?? op.responses.default;
|
|
37
|
-
if (fallback?.contentType === undefined || !isJsonMedia(fallback.contentType))
|
|
38
|
+
if (fallback?.contentType === undefined || !isJsonMedia(fallback.contentType))
|
|
38
39
|
return { kind: Object.keys(op.responses).length === 0 ? "json" : "none", status: "200" };
|
|
39
|
-
}
|
|
40
40
|
const out = { contentType: fallback.contentType, kind: "json", status: fallback.status };
|
|
41
41
|
if (fallback.schema !== undefined)
|
|
42
42
|
out.schema = fallback.schema;
|
|
@@ -81,7 +81,7 @@ function streamOf(op) {
|
|
|
81
81
|
return "ws";
|
|
82
82
|
return sse === true ? "sse" : null;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
// a string-typed schema: a scalar string, or a string const or enum
|
|
85
85
|
const isStringSchema = (schema) => (schema.kind === "scalar" && schema.type === "string") ||
|
|
86
86
|
(schema.kind === "const" && typeof schema.value === "string");
|
|
87
87
|
/** The SSE response of `op`: its `text/event-stream` answer, if any. */
|
package/dist/ir/slots.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { compareCodeUnits } from "../emit/shared/lang.js";
|
|
2
|
+
/**
|
|
3
|
+
* One operation's slots in the IR: its parameters by where they travel, its request bodies in
|
|
4
|
+
* preference order, its responses by status, and the backend extensions it carries (realtime, SSE,
|
|
5
|
+
* websocket, invalidation…), and for a Standard Webhooks event, its type and data. Component `$ref`s on
|
|
6
|
+
* parameters, bodies, responses and an event's envelope are followed.
|
|
7
|
+
*/
|
|
8
|
+
import {} from "./model.js";
|
|
1
9
|
import { schemaToIR } from "./schema.js";
|
|
2
10
|
import { sseEventsOf, websocketMessagesOf } from "./streams.js";
|
|
3
|
-
import { compareCodeUnits } from "../emit/shared/lang.js";
|
|
4
11
|
/** Splits an OpenAPI path template into literal text and `{param}` pieces. */
|
|
5
12
|
export function parseOpenApiPath(path) {
|
|
6
13
|
const out = [];
|
|
@@ -67,13 +74,12 @@ export function paramsOf(path, op, item, components) {
|
|
|
67
74
|
const declared = (op.parameters ?? [])
|
|
68
75
|
.map((p) => deref(p, components))
|
|
69
76
|
.filter((p) => p !== undefined);
|
|
70
|
-
for (const p of (item.parameters ?? []).map((q) => deref(q, components)))
|
|
77
|
+
for (const p of (item.parameters ?? []).map((q) => deref(q, components)))
|
|
71
78
|
if (p !== undefined && !declared.some((d) => d.name === p.name && d.in === p.in))
|
|
72
79
|
declared.push(p);
|
|
73
|
-
}
|
|
74
80
|
const by = (place) => declared.filter((p) => p.in === place).map(paramOf);
|
|
75
81
|
const pathParams = by("path");
|
|
76
|
-
|
|
82
|
+
// path params in template order; one the template lacks cannot be sent, one it has but nobody declared is a string
|
|
77
83
|
const params = {
|
|
78
84
|
header: by("header"),
|
|
79
85
|
path: openApiPathParams(path).map((name) => pathParams.find((p) => p.name === name) ?? { name, required: true, schema: STRING }),
|
|
@@ -84,7 +90,7 @@ export function paramsOf(path, op, item, components) {
|
|
|
84
90
|
params.cookie = cookie;
|
|
85
91
|
return params;
|
|
86
92
|
}
|
|
87
|
-
|
|
93
|
+
// JSON first, then the structured kinds; other JSON-like types next, then the rest as listed
|
|
88
94
|
const PREFERENCE = [
|
|
89
95
|
"application/json",
|
|
90
96
|
"application/x-www-form-urlencoded",
|
|
@@ -125,12 +131,11 @@ function bodyOf(type, media, required, components) {
|
|
|
125
131
|
return { contentType: "application/octet-stream", kind: "stream", required };
|
|
126
132
|
const ir = schemaToIR(schema);
|
|
127
133
|
const parts = essence === "multipart/form-data" ? partsOf(ir, components) : [];
|
|
128
|
-
if (parts.some((part) => part.type === "file"))
|
|
134
|
+
if (parts.some((part) => part.type === "file"))
|
|
129
135
|
return { contentType: "multipart/form-data", kind: "multipart", parts, required, schema: ir };
|
|
130
|
-
}
|
|
131
136
|
return { contentType: type, kind: "raw", required, schema: ir };
|
|
132
137
|
}
|
|
133
|
-
|
|
138
|
+
// a urlencoded form cannot carry a file, so a multipart one with a file part ranks just above it
|
|
134
139
|
const weight = (body) => body.kind === "multipart" ? rank("application/x-www-form-urlencoded") - 0.5 : rank(body.contentType);
|
|
135
140
|
/** Every request body the operation declares, preferred first. */
|
|
136
141
|
export function requestBodies(op, components) {
|
package/dist/ir/streams.js
CHANGED
|
@@ -21,7 +21,7 @@ export function sseEventsOf(itemSchema, follow) {
|
|
|
21
21
|
return [{ data: dataOf(properties.data), name: event ?? "message" }];
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
// an event's data: what `contentSchema` encodes when it is there, else the schema itself
|
|
25
25
|
function dataOf(data) {
|
|
26
26
|
if (!isObject(data))
|
|
27
27
|
return { kind: "unknown" };
|
|
@@ -2,7 +2,7 @@ import { type ReleaseContext } from "./context.ts";
|
|
|
2
2
|
/** The most commits a public repo's branch may hold for `--force-bootstrap` to overwrite it: a stub, not history. */
|
|
3
3
|
export declare const FORCE_COMMIT_LIMIT = 2;
|
|
4
4
|
/** What `release bootstrap` prints when it is not told what to target. */
|
|
5
|
-
export declare const USAGE: string[];
|
|
5
|
+
export declare const USAGE: readonly string[];
|
|
6
6
|
/**
|
|
7
7
|
* Returns commit count on the remote branch, capped at FORCE_COMMIT_LIMIT + 1.
|
|
8
8
|
* Used to gate --force-bootstrap: only mirrors with ≤FORCE_COMMIT_LIMIT commits
|
|
@@ -10,7 +10,7 @@ export declare const USAGE: string[];
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function countRemoteCommits(httpsUrl: string, branch: string): Promise<number>;
|
|
12
12
|
/** What `release bootstrap` was asked for. */
|
|
13
|
-
export
|
|
13
|
+
export type BootstrapOptions = {
|
|
14
14
|
/** Every package of the release. */
|
|
15
15
|
all: boolean;
|
|
16
16
|
/** The release config's path; required. */
|
|
@@ -19,7 +19,7 @@ export interface BootstrapOptions {
|
|
|
19
19
|
forceBootstrap: boolean;
|
|
20
20
|
/** The packages to bootstrap, by `name` or `project/name`. */
|
|
21
21
|
only: string[] | undefined;
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
/** A parse that succeeded with `options`, or failed with an `error` to show the caller. */
|
|
24
24
|
export type ParsedArgs = {
|
|
25
25
|
error: string;
|
|
@@ -44,7 +44,7 @@ export async function countRemoteCommits(httpsUrl, branch) {
|
|
|
44
44
|
rmSync(tmpDir, { force: true, recursive: true });
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// Unknown arguments are ignored.
|
|
48
48
|
const SWITCHES = { "--all": "all", "--force-bootstrap": "forceBootstrap" };
|
|
49
49
|
const VALUE_FLAGS = { "--config": "config", "--name": "only", "--only": "only" };
|
|
50
50
|
const isSwitch = (arg) => Object.hasOwn(SWITCHES, arg);
|
|
@@ -106,7 +106,7 @@ export function judgeMirror(input) {
|
|
|
106
106
|
}
|
|
107
107
|
return { proceed: true };
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
// one package bootstrapped: its outcome, reported as it goes
|
|
110
110
|
async function bootstrapOne(entry, run, ctx) {
|
|
111
111
|
ctx.out(`\n→ ${packageKey(entry)} → ${entry.mirror}\n`);
|
|
112
112
|
const httpsUrl = sshToHttps(entry.mirror, run.token);
|
|
@@ -121,9 +121,9 @@ async function bootstrapOne(entry, run, ctx) {
|
|
|
121
121
|
ctx.err(` fail: ${verdict.reason}\n`);
|
|
122
122
|
return "failed";
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
// Bootstrap commits force-overwrite the mirror with a fresh "initial release" snapshot. bootstrapExclude globs
|
|
125
|
+
// skip generated source on the initial push, so the next sync adds it cleanly. A repo bootstrap creates is exactly
|
|
126
|
+
// one whose description, website and topics are empty, so the settings step fills them.
|
|
127
127
|
const result = await syncPackage(entry, {
|
|
128
128
|
applyBootstrapExclude: true,
|
|
129
129
|
dryRun: false,
|
|
@@ -142,12 +142,12 @@ async function bootstrapOne(entry, run, ctx) {
|
|
|
142
142
|
ctx.out(` skip: ${result.reason}\n`);
|
|
143
143
|
return "skipped";
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
// a push that is no dry run always reports both shas
|
|
146
146
|
const [source, mirror] = [result.sourceSha, result.mirrorSha];
|
|
147
147
|
ctx.out(` ok: source=${source.slice(0, SHORT_SHA_LENGTH)} mirror=${mirror.slice(0, SHORT_SHA_LENGTH)}\n`);
|
|
148
148
|
return "synced";
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
// the packages a bootstrap targets, bootstrapped one after another; the exit code it ends with
|
|
151
151
|
async function bootstrapAll(release, options, token, ctx) {
|
|
152
152
|
const targets = filterPackages(release.packages, { only: options.only });
|
|
153
153
|
if (targets.length === 0) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// Each flag takes the next argument as its value, unless that argument is a switch.
|
|
2
2
|
const BUMP_FLAGS = { "--config": "config" };
|
|
3
|
-
|
|
3
|
+
// Bare flags: present or not.
|
|
4
4
|
const BUMP_SWITCHES = { "--major": "major" };
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// The value of every `flags` entry and the presence of every `switches` entry in `argv`, or the first argument that
|
|
6
|
+
// is neither.
|
|
7
7
|
function readFlags(flags, switches, argv) {
|
|
8
8
|
const values = {};
|
|
9
9
|
const set = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReleaseContext } from "./context.ts";
|
|
2
|
-
import type { Release } from "./types.ts";
|
|
3
2
|
import { type ReleaseState } from "./release-state.ts";
|
|
3
|
+
import type { Release } from "./types.ts";
|
|
4
4
|
/** The header every CHANGELOG bump writes starts with; entries go directly under it, newest first. */
|
|
5
5
|
export declare const CHANGELOG_HEADER = "# Changelog\n\n";
|
|
6
6
|
/**
|
|
@@ -9,8 +9,8 @@ import * as fs from "node:fs/promises";
|
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { decide } from "./bump.js";
|
|
12
|
-
import { CHANGELOG_FILE, ENOENT, MAX_OUTPUT_BYTES, PORCELAIN_PREFIX_LENGTH, RELEASE_STATE } from "./constants.js";
|
|
13
12
|
import { regenerate } from "./codegen.js";
|
|
13
|
+
import { CHANGELOG_FILE, ENOENT, MAX_OUTPUT_BYTES, PORCELAIN_PREFIX_LENGTH, RELEASE_STATE } from "./constants.js";
|
|
14
14
|
import { handDigest, outputDigest } from "./digest.js";
|
|
15
15
|
import { apiChanges } from "./oasdiff.js";
|
|
16
16
|
import { releaseStateSchema } from "./release-state.js";
|
|
@@ -50,7 +50,7 @@ async function prependChangelog(changelogFile, entry) {
|
|
|
50
50
|
await fs.writeFile(changelogFile, prependEntry(existing, entry), "utf8");
|
|
51
51
|
}
|
|
52
52
|
const git = (root, ...args) => execFileSync("git", args, { cwd: root, encoding: "utf8", maxBuffer: MAX_OUTPUT_BYTES });
|
|
53
|
-
|
|
53
|
+
// The committed spec as HEAD holds it; refuses a working copy that differs, since the state records HEAD.
|
|
54
54
|
function committedSpec({ root, spec }) {
|
|
55
55
|
const specPath = path.relative(root, spec.committedPath);
|
|
56
56
|
const sha = canonicalSha(JSON.parse(readFileSync(spec.committedPath, "utf8")));
|
|
@@ -66,7 +66,7 @@ function committedSpec({ root, spec }) {
|
|
|
66
66
|
}
|
|
67
67
|
return { commit: git(root, "rev-parse", "HEAD").trim(), path: specPath, sha };
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
// oasdiff from each released spec to the committed one, run once per released spec.
|
|
70
70
|
function changesSince(release, env) {
|
|
71
71
|
const found = new Map();
|
|
72
72
|
return (released) => {
|
|
@@ -74,9 +74,8 @@ function changesSince(release, env) {
|
|
|
74
74
|
if (cached !== undefined)
|
|
75
75
|
return cached;
|
|
76
76
|
const base = git(release.root, "show", `${released.commit}:${released.path}`);
|
|
77
|
-
if (canonicalSha(JSON.parse(base)) !== released.sha)
|
|
77
|
+
if (canonicalSha(JSON.parse(base)) !== released.sha)
|
|
78
78
|
throw new Error(`${released.commit}:${released.path} is not the spec the release recorded (${released.sha})`);
|
|
79
|
-
}
|
|
80
79
|
const dir = mkdtempSync(path.join(tmpdir(), "oss-release-spec-"));
|
|
81
80
|
try {
|
|
82
81
|
const file = path.join(dir, "released.json");
|
|
@@ -90,14 +89,14 @@ function changesSince(release, env) {
|
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
|
|
92
|
+
// Paths under `dir` that differ from HEAD (tracked or new, never ignored), repo-relative.
|
|
94
93
|
function changedPaths(root, dir) {
|
|
95
94
|
return git(root, "status", "--porcelain=v1", "-z", "--untracked-files=all", "--", dir)
|
|
96
95
|
.split("\0")
|
|
97
96
|
.filter((entry) => entry.length > PORCELAIN_PREFIX_LENGTH)
|
|
98
97
|
.map((entry) => entry.slice(PORCELAIN_PREFIX_LENGTH));
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
// each package's decision from its digests now and its last release
|
|
101
100
|
async function plan(release, major, env) {
|
|
102
101
|
const spec = committedSpec(release);
|
|
103
102
|
const changes = changesSince(release, env);
|
|
@@ -105,7 +104,7 @@ async function plan(release, major, env) {
|
|
|
105
104
|
const planned = [];
|
|
106
105
|
for (const pkg of release.packages) {
|
|
107
106
|
const dir = path.join(release.root, pkg.path);
|
|
108
|
-
|
|
107
|
+
// a version file bump cannot read fails the run before anything is written
|
|
109
108
|
readVersions(dir);
|
|
110
109
|
const previous = await readPrevious(path.join(dir, RELEASE_STATE));
|
|
111
110
|
const observed = { hand: handDigest(release.root, pkg), output: outputDigest(release.root, pkg, spec.sha), spec };
|
|
@@ -121,7 +120,7 @@ async function plan(release, major, env) {
|
|
|
121
120
|
}
|
|
122
121
|
return planned;
|
|
123
122
|
}
|
|
124
|
-
|
|
123
|
+
// writes one package's state and changelog, and reports every path its release touched
|
|
125
124
|
async function record(release, { decision, dir, now, observed, pkg }, versionFiles, ctx) {
|
|
126
125
|
const { root } = release;
|
|
127
126
|
const state = {
|
|
@@ -174,7 +173,7 @@ export async function runBump(release, major, ctx) {
|
|
|
174
173
|
ctx.out("no changes since last release\n");
|
|
175
174
|
return 0;
|
|
176
175
|
}
|
|
177
|
-
|
|
176
|
+
// versions first, then codegen at those versions, so the recorded digests are the released output's
|
|
178
177
|
const written = releasing.map((planned) => ({
|
|
179
178
|
files: writeVersions(planned.dir, planned.decision.nextVersion),
|
|
180
179
|
planned,
|
package/dist/release/bump.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type Observed = {
|
|
|
6
6
|
output: string;
|
|
7
7
|
spec: ReleaseState["spec"];
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type ReleaseKind = "initial" | "major" | "minor" | "patch";
|
|
10
10
|
export type Decision = {
|
|
11
11
|
kind: "none";
|
|
12
12
|
} | {
|
|
@@ -14,7 +14,7 @@ export type Decision = {
|
|
|
14
14
|
kind: ReleaseKind;
|
|
15
15
|
nextVersion: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type DecideInput = {
|
|
18
18
|
/** oasdiff from the released spec to the observed one; called only when the output changed and the spec moved */
|
|
19
19
|
changes: (released: ReleaseState["spec"]) => readonly ApiChange[];
|
|
20
20
|
/** the first release's CHANGELOG text */
|
|
@@ -23,11 +23,12 @@ export interface DecideInput {
|
|
|
23
23
|
major?: boolean;
|
|
24
24
|
now: Date;
|
|
25
25
|
observed: Observed;
|
|
26
|
-
previous?: ReleaseState;
|
|
27
|
-
}
|
|
26
|
+
previous?: ReleaseState | undefined;
|
|
27
|
+
};
|
|
28
28
|
/**
|
|
29
29
|
* Whether a package releases and at what level. Nothing releases while its output and hand files match the last
|
|
30
30
|
* release, even when the spec moved (a package may expose only part of it). A changed output on a moved spec with
|
|
31
31
|
* any oasdiff entry is a minor; every other change is a patch; `major` makes any release a major.
|
|
32
32
|
*/
|
|
33
33
|
export declare function decide(input: DecideInput): Decision;
|
|
34
|
+
export {};
|
package/dist/release/bump.js
CHANGED
|
@@ -7,11 +7,11 @@ function nextVersion(version, kind) {
|
|
|
7
7
|
return `${major}.${minor + 1}.0`;
|
|
8
8
|
return `${major}.${minor}.${patch + 1}`;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
// Every package stays on its major line: any API change, breaking or not, is a minor; a major is only ever asked for.
|
|
11
11
|
function levelOf(changes) {
|
|
12
12
|
return changes.length > 0 ? "minor" : "patch";
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
// Each operation once, under the first section it belongs to: breaking, then added, then changed.
|
|
15
15
|
function sections(changes) {
|
|
16
16
|
const byOperation = new Map();
|
|
17
17
|
for (const change of changes) {
|
package/dist/release/cli.d.ts
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
import type { Io } from "../cli.ts";
|
|
7
7
|
import { type LoadReleaseOptions } from "./load.ts";
|
|
8
8
|
/** What `clients release` prints when it is given no command, or one it does not know. */
|
|
9
|
-
export declare const USAGE
|
|
9
|
+
export declare const USAGE: string;
|
|
10
10
|
/** What a release run reads beside its arguments; each defaults to the running process's own. */
|
|
11
11
|
export type ReleaseOptions = {
|
|
12
12
|
/** The environment: `GH_TOKEN`, and what codegen and Go run with. */
|
|
13
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
13
|
+
readonly env?: NodeJS.ProcessEnv | undefined;
|
|
14
14
|
/** The fetch the spec gate and the GitHub settings step use. */
|
|
15
|
-
readonly fetch?: typeof fetch;
|
|
15
|
+
readonly fetch?: typeof fetch | undefined;
|
|
16
16
|
/** How the release config is imported (`loadRelease`'s options). */
|
|
17
|
-
readonly load?: LoadReleaseOptions;
|
|
17
|
+
readonly load?: LoadReleaseOptions | undefined;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Runs `clients release <argv>`: the exit code it ends with. A usage mistake is one line naming the command; any
|
package/dist/release/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { regenerate } from "./codegen.js";
|
|
|
5
5
|
import { parseConfigOnly, ReleaseUsageError } from "./context.js";
|
|
6
6
|
import { readRelease } from "./load.js";
|
|
7
7
|
import { sync } from "./sync-command.js";
|
|
8
|
-
|
|
8
|
+
// the usage entries of the commands that take only --config, each also its own --help
|
|
9
9
|
const CODEGEN_USAGE = `codegen --config <path>
|
|
10
10
|
run the config's codegen from the repo root, as bump does before it decides
|
|
11
11
|
`;
|
|
@@ -23,14 +23,14 @@ export const USAGE = `usage: clients release <command> --config <path> [options]
|
|
|
23
23
|
bootstrap --config <path> (--all | --only <names>) [--force-bootstrap]
|
|
24
24
|
the first push to an empty public repo, or over the stub a new one starts with
|
|
25
25
|
${CODEGEN_USAGE} ${TOOLCHAINS_USAGE}`;
|
|
26
|
-
|
|
26
|
+
// `release bump <argv>`: the release its config describes, bumped
|
|
27
27
|
async function bump(argv, ctx) {
|
|
28
28
|
const parsed = parseBumpArgs(argv);
|
|
29
29
|
if (!parsed.ok)
|
|
30
30
|
throw new ReleaseUsageError(parsed.error);
|
|
31
31
|
return runBump(await ctx.load(parsed.value.config), parsed.value.major, ctx);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
// `release codegen <argv>`: the config's codegen, run as bump runs it
|
|
34
34
|
async function codegen(argv, ctx) {
|
|
35
35
|
const parsed = parseConfigOnly(argv);
|
|
36
36
|
if (parsed.help) {
|
|
@@ -40,7 +40,7 @@ async function codegen(argv, ctx) {
|
|
|
40
40
|
regenerate(await ctx.load(parsed.config), ctx.env);
|
|
41
41
|
return 0;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
// `release toolchains <argv>`: the config's toolchains, one per line, for a workflow to install before codegen
|
|
44
44
|
async function toolchains(argv, ctx) {
|
|
45
45
|
const parsed = parseConfigOnly(argv);
|
|
46
46
|
if (parsed.help) {
|
package/dist/release/codegen.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
7
|
import { RELEASE_VERSIONS_ENV } from "./manifest.js";
|
|
8
|
-
|
|
8
|
+
// codegen's own output goes to stderr's descriptor, so stdout stays the command's report
|
|
9
9
|
const STDERR_FD = 2;
|
|
10
10
|
/**
|
|
11
11
|
* Runs the product's codegen from the repo root in `env`, with `versions` (package name to version) as
|