feat: add onPluginsReady callback to createApp, remove autoStart#280
feat: add onPluginsReady callback to createApp, remove autoStart#280MarioCadenas wants to merge 6 commits intomainfrom
Conversation
d49f16d to
33e0b86
Compare
|
I think this is a step in the right direction and we should have this ASAP. That being said, as we talked on Slack (just surfacing this here), the API name could change. The use case we need to cover immediately is |
| getServer: this.getServer, | ||
| /** Get the server configuration */ | ||
| getConfig: this.getConfig, | ||
| /** @deprecated Server is now started automatically by createApp. */ |
There was a problem hiding this comment.
[nit] I tend to prefer deprecation messages that offer an alterantive instead of just saying the thing is gone. So perhaps extend this note saying we have a lifecycle hook to run when plugin is loaded. We can use the @example keyword to offer the syntax and boost self-discoverability of the new feature.
| await config.onPluginsReady?.(handle); | ||
|
|
||
| const serverPlugin = instance.#pluginInstances.server; | ||
| if (serverPlugin && typeof (serverPlugin as any).start === "function") { | ||
| await (serverPlugin as any).start(); | ||
| } |
There was a problem hiding this comment.
[take it or leave it]
considering this is an "advanced-level" feature, an info level log when on dev could boost debuggability
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>
Log when the onPluginsReady hook starts and completes to aid debugging in development mode. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
023d7e7 to
25b8c60
Compare
Update runtime detection error messages to point users to `npx appkit codemod on-plugins-ready` to match the hook name. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Summary
onPluginsReadylifecycle hook tocreateAppthat runs after plugin setup but before the server starts, replacing theautoStart: false+.extend()+.start()ceremonycreateApp(looks up"server"plugin by name), makingautoStartand manualstart()unnecessaryautoStartfrom public API (ServerConfig,DEFAULT_CONFIG, manifest) andstart()from server exportsappkit codemod customize-callbackCLI command to auto-migrate existing appsBefore / After
Before:
After:
Migration
Auto-detects server entry files and rewrites both
.then()chain andawait+ imperative patterns. Dry-run by default (omit--writeto preview).Test plan
onPluginsReady(sync, async, without server plugin)