Repository navigation
Conversation
The code generator is now the npm package zerogen (packages/zerogen), with its own version, so other targets can be added next to Swift. `zerogen codegen` generates every target in zerogen.json, or the one `--target` names. Only Swift is implemented: `--target rust`, or a rust entry in the config, fails before anything is written. `zerogen drift record` records the same vectors as before. Schema loading, the type model, the commands, output and `--check`, and the drift recorder are shared; Swift's naming, escaping, SDK and type mappings, and options are in targets/swift.ts. zero-swift stays published and supported. It depends on the exact zerogen version and keeps its config, flags, and output: next to zero-swift 0.7.9 from npm, 31 runs of its help, flags, results, and errors print the same and write the same files. The checked-in generated Swift and drift vectors are unchanged. The release workflow publishes zerogen before zero-swift, after the same approval, and checks that the packed zero-swift depends on the zerogen being released. A version only counts as unpublished when npm says it doesn't exist. CI installs the packed packages outside the workspace and runs both CLIs. Every zerogen release also bumps zero-swift by a patch, since Changesets reads `workspace:*` as the exact version. Co-authored-by: tmm <tmm@tmm.dev> Amp-Thread-ID: https://ampcode.com/threads/T-25ebc75a-8a01-4e52-bb02-ea048d34e417
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the Swift code generator out of
packages/zero-swift-cliinto a new npm package,zerogen(packages/zerogen), with its own semver. Rust comes later.zerogen
zerogen codegengenerates every target inzerogen.json, or the one--target swift|rustnames. Only Swift is implemented.--target rust, arustentry in the config, or no target at all fail withUNSUPPORTED_TARGET/NO_TARGETSbefore anything is written.zerogen drift recordis the same target-independent recorder as before.cli.ts/types.ts/drift.ts: schema loading, the type model, the incur commands, output and--check, and the drift recorder. Per language, intargets/swift.ts: naming, escaping, SDK and type mappings, and the Swift options (--schema-name,--zql,--type-prefix,--access).generate.tsmoved there unchanged apart from taking its options.zerogen.jsonhas the sharedschemaandexport, andtargets.swifttakes the rest ofzero-swift.json's keys.zero-swift stays published and is not deprecated. It's now a 5-line wrapper over
zerogen/compat, and depends onzerogenwithworkspace:*, whichpnpm packturns into the exact version. Its config, legacy flags (--schema <path>,--typePrefix=…), results, and output don't change, and the generated banner still sayszero-swift codegen.Releases.
swift-release.ymlversions and publisheszerogenalongside the Swift client:zerogenbeforezero-swift, in the same approvedswift-releasejob. Ifzerogenfails to publish,zero-swiftisn't published.zero-swiftdepends on exactly thezerogenbeing released.zero-swift's oldnpm viewcheck counted any error that way.Verified
pnpm --filter zerogen --filter zero-swift testdrift-vectors.json, and the Swift compile sweep (Swift 6.2.4, Linux).zero-swift@0.7.9from npm vs. the new packed tarballs, both on@rocicorp/zero@1.11.0--help,codegen --help,--llms, bare--schema, legacy and kebab flags,--json,--check(fresh and stale), every error code,drift recordand its--check, and--target(still rejected by the wrapper).pnpm --filter zerogen smokecheck-types(zero-conformance, zerogen, zero-swift),syncpack lint, oxlint, oxfmtactionlint1.7.7 with ShellCheckSC2016info thatmainalso reports.zero-swiftalready on npm:npm=false,zerogen-npm=true,mirror=false. With an unreleasedzero-swiftandzerogen0.1.0: all true.zerogen0.0.0→0.1.0 andzero-swift0.7.10→0.7.11 (swift/VERSIONtoo).pnpm install --frozen-lockfilepnpm-lock.yamlbyte-identical. The lockfile was edited by hand, with workspace links only.Before releasing (tmm)
zerogenbefore merging the Version Packages PR. npm only adds a trusted publisher to a package that exists, so the firstzerogenversion has to be published by hand. The publisher to add is this repo,swift-release.yml, environmentswift-release, allowed tonpm publish. Until then the "Publish zerogen" step fails and blockszero-swift; the Swift mirror release still goes out.zerogenwas unclaimed on npm (404) when this PR was opened.zerogenrelease also bumpszero-swiftby a patch, and with itswift/VERSION, so the Swift mirror is released too. Changesets readsworkspace:*as the exact old version; a dry run confirmed that azerogen-only patch also bumpszero-swiftby a patch. Splitting the wrapper's version fromswift/VERSIONwould avoid this, but that's a separate change.Not run locally: the full
swift/and zbugsswift testsuites and macOS CI. No Swift sources, generated Swift, or vectors change; CI runs them.Started in a thread that stopped on a model usage limit (https://ampcode.com/threads/T-98d49fb9-9997-4a89-ae8f-8810e2d2175d) and finished here.