feat(sdk)!: extract seed execution into a CLI plugin package#1807
Draft
dqn wants to merge 10 commits into
Draft
Conversation
seedPlugin no longer generates the exec.mjs seed runner; it keeps generating the JSONL data and lines-db schema files. The new @tailor-platform/sdk-plugin-seed package ships a tailor-seed executable that the CLI dispatches to as `tailor seed apply` / `tailor seed validate`, with the same options the generated script had. Instead of baking namespaces, dependency order, and IdP scripts into a generated file, the plugin loads them from tailor.config.ts at run time through the new loadSeedContext export in @tailor-platform/sdk/cli. - @tailor-platform/sdk/cli: add loadSeedContext (+ SeedContext types), type SeedData as JSON objects, and accept plain-object executeScript invokers via ScriptInvoker - host CLI: register the seed plugin in KNOWN_PLUGIN_PACKAGES for the install hint - example / create-sdk generators template: replace exec.mjs usage with tailor seed scripts and a devDependency on the plugin; prepare-templates.js now also rewrites the plugin version - docs: CLI plugins section, configuration.md, and a codemod-less v2/seed-exec-to-cli-plugin migration entry - CI: publish the plugin on pkg.pr.new and cover it in changeset-check
- treat a script result without success: true as a failure, matching the generated runner's semantics - name the file and line when a JSONL seed line fails to parse - decline truncate confirmation instead of hanging when stdin is not a TTY - validate the seedPlugin distPath option in loadSeedContext - fold the duplicated IdP seed/truncate execution into one helper and move dataDir into the shared execution context - drop the discarded processSeedTypeInfo call from the generate hook - dedupe version resolution in create-sdk's prepare-templates.js and log every rewritten package
… emit --json output
- resolve auth namespaces in loadSeedContext before reading userProfile;
without it the IdP _User context was always null at run time
- resolve a relative distPath against the working directory, the same
base tailor generate writes it to
- honor --json: apply emits an aggregated { success, processed } summary
and validate emits { valid, path }
- reject duplicate cross-namespace type names in loadSeedContext, matching generation and deploy - report a cancelled truncate as a failure (exit 1) and emit the --json cancel summary - accept -v for --verbose, matching the generated seed runner's validate - also flag exec.mjs references inside source strings in the migration registry entry
🦋 Changeset detectedLatest commit: 81b6b0c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This comment has been minimized.
This comment has been minimized.
politty's runMain resets process.exitCode on a successful run, so the cancelled path must throw instead of setting the exit code directly.
This comment has been minimized.
This comment has been minimized.
The example seed scripts run `tailor seed` in the deploy e2e workflow; without a built dist/index.js pnpm never links the tailor-seed bin and plugin dispatch reports the plugin as not installed.
20 tasks
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.
Summary
The seed runner that
seedPluginused to generate asexec.mjsmoves into a new CLI plugin package,@tailor-platform/sdk-plugin-seed, resolved through the CLI's plugin dispatch astailor seed.Usage
Without the plugin installed, the CLI points at the fix:
Affected public surfaces
@tailor-platform/sdk:seedPluginno longer generatesexec.mjs(breaking; see Notes). Seed data and schema generation (data/*.jsonl,data/*.schema.ts) is unchanged.@tailor-platform/sdk-plugin-seedships thetailor-seedexecutable (@tailor-platform/sdkis a peer dependency).applykeeps the old runner's options (-m/--machine-user,-n/--namespace,--skip-idp,--truncate,--yes, type-name arguments) and both commands emit--jsonsummaries.@tailor-platform/sdk/cliexports for the plugin:loadSeedContext(+SeedContexttypes),SeedData(now JSON-typed), andScriptInvoker(executeScriptaccepts a plain-object invoker).Behavioral changes
_Usercontext are computed fromtailor.config.tsat run time instead of being baked in at generate time, so seedPlugin option edits (e.g.machineUserName) take effect without regenerating.distPathresolves against the working directory — the same basetailor generatewrites it to; run both commands from the same directory.--yes) exits 1.Verification
example/:tailor plugin listresolvesseed,tailor seed validate(and-v) passes against the example config,tailor seed apply --helprenders the full option set._User) has not been exercised in this PR; the platform-side path is a direct port of the generated runner onto the samebundleSeedScript/chunkSeedData/executeScriptprimitives.Notes
node <distPath>/exec.mjsinvocations withtailor seed apply/tailor seed validate, and delete the stale generatedexec.mjs. A codemod-less migration entry (with source-string detection forexec.mjs) and doc updates are included.tailor-platform/actions/seed-validate(pinned by thetailor setupworkflow templates) still runsnode .tailor-sdk/exec.mjs validateand is already incompatible with v2's.tailoroutput directory; it needs atailor seed validaterelease and a pin bump in the templates regardless of this PR.--compactrequires an npm-published package; if the preview publish fails for it, re-add after the firstnextrelease (same sequencing as the erd plugin).tailor --json seed apply) are consumed by the host and not forwarded — place them after the command (same documented caveat as the erd plugin).