feat: add appkit codemod customize-callback CLI#290
Closed
MarioCadenas wants to merge 5 commits intofeat/customize-callbackfrom
Closed
feat: add appkit codemod customize-callback CLI#290MarioCadenas wants to merge 5 commits intofeat/customize-callbackfrom
MarioCadenas wants to merge 5 commits intofeat/customize-callbackfrom
Conversation
Replace the post-await extend/start ceremony with a declarative `customize` callback on createApp config. The callback runs after plugin setup but before the server starts, giving access to the full appkit handle for registering custom routes or async setup. - Add `customize` option to createApp config - Server start is now orchestrated by createApp (lookup by name) - Remove `autoStart` from public API, ServerConfig, and manifest - Remove `start()` from server plugin exports - Remove autoStart guards from extend() and getServer() - Remove ServerError.autoStartConflict() - Migrate dev-playground, template, and all tests Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
… detection Rename the lifecycle hook from `customize` to `onPluginsReady` to clearly communicate when it fires (after plugins are ready, before server starts). Add `appkit codemod customize-callback` CLI command that auto-migrates old autoStart/extend/start patterns to the new onPluginsReady callback. Supports both .then() chain (Pattern A) and await + imperative (Pattern B, with bail-out for complex cases). Add runtime detection that throws helpful errors when users pass autoStart to server() or call server.start() after upgrading, directing them to run the codemod. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
The test fixture .ts files import @databricks/appkit which doesn't exist in the shared package, causing tsc to fail in CI. Exclude the fixtures directory from the shared tsconfig. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Remove the codemod CLI from this PR to keep the review focused on the core lifecycle change. The codemod will land as a follow-up with bug fixes from review. Runtime detection (constructor autoStart throw + exports().start() trap) stays since it's part of the migration story. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Add `appkit codemod customize-callback` command that auto-migrates old autoStart/extend/start patterns to the new onPluginsReady callback. Handles Pattern A (.then chain) and Pattern B (await + imperative). Bails with a warning for complex cases (non-server usage of appkit handle, multiple extend calls). Fixes from review: - Use raw slice offset for brace matching (not trimmed) - Use brace-aware parsing for .catch() handlers with arrow functions - Bail out when multiple .extend() calls detected in Pattern B Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
023d7e7 to
25b8c60
Compare
Collaborator
Author
|
Superseded by new PR with renamed codemod (customize-callback -> on-plugins-ready). |
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
Adds
appkit codemod customize-callbackCLI command to auto-migrate apps from the oldautoStart/extend/startpattern to the newonPluginsReadycallback.Depends on #280.
What it does
.start(), injects asonPluginsReadyproperty, preserves.catch()handlers (including arrow functions with parens)onPluginsReady, removes standalone statements. Bails with warning for complex cases (non-server usage of appkit handle, multiple extend calls)autoStart: true/falsefrom allserver()configs, preserves other propertiescreateAppfrom@databricks/appkitinserver/,src/, root--writeflag to apply changesUsage
Bugs fixed from review
bodyOpenBraceoffset calculation after.trim()— was using trimmed string index as offset into original content.catch()handler parsing — now uses brace-awarefindMatchingCloseinstead of regex, correctly handles.catch((err) => console.error(err)).extend()calls are detectedTest plan