Skip to content

Commit e6b7300

Browse files
committed
feat: add SetupPlugin to auto-register before config plugins in serve command
1 parent dc5adae commit e6b7300

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@objectstack/driver-memory": "workspace:^",
4545
"@objectstack/objectql": "workspace:^",
4646
"@objectstack/plugin-hono-server": "workspace:*",
47+
"@objectstack/plugin-setup": "workspace:*",
4748
"@objectstack/rest": "workspace:*",
4849
"@objectstack/runtime": "workspace:^",
4950
"@objectstack/service-ai": "workspace:*",

packages/cli/src/commands/serve.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,22 @@ export default class Serve extends Command {
263263
}
264264
}
265265

266+
// 5. Auto-register SetupPlugin BEFORE config plugins so that other
267+
// plugins (e.g. AuthPlugin) can call setupNav.contribute() during init.
268+
const hasSetupPlugin = plugins.some(
269+
(p: any) => p.name === 'com.objectstack.setup' || p.constructor?.name === 'SetupPlugin'
270+
);
271+
if (!hasSetupPlugin) {
272+
try {
273+
const setupPkg = '@objectstack/plugin-setup';
274+
const { SetupPlugin } = await import(/* webpackIgnore: true */ setupPkg);
275+
await kernel.use(new SetupPlugin());
276+
trackPlugin('Setup');
277+
} catch {
278+
// @objectstack/plugin-setup not installed — setup app unavailable
279+
}
280+
}
281+
266282
if (plugins.length > 0) {
267283
for (const plugin of plugins) {
268284
try {

packages/objectql/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export class SchemaRegistry {
550550
if (type === 'object' || type === 'objects') {
551551
return this.getAllObjects(packageId) as unknown as T[];
552552
}
553-
553+
554554
const items = Array.from(this.metadata.get(type)?.values() || []) as T[];
555555
if (packageId) {
556556
return items.filter((item: any) => item._packageId === packageId);

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)