Skip to content

Commit 82b5de2

Browse files
committed
feat: enhance app plugin auto-registration and update dependencies in CLI
1 parent 7cafaa7 commit 82b5de2

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

examples/app-todo/objectstack.config.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { TodoTask } from './src/domains/todo/task.object';
44

55
// Runtime Plugins
66
import { ObjectQLPlugin } from '@objectstack/objectql';
7-
import { AppPlugin, DriverPlugin } from '@objectstack/runtime';
7+
import { DriverPlugin } from '@objectstack/runtime';
88
import { InMemoryDriver } from '@objectstack/driver-memory';
99

10-
const stackConfig = defineStack({
10+
export default defineStack({
1111
objects: [
1212
TodoTask
1313
],
@@ -54,16 +54,10 @@ const stackConfig = defineStack({
5454
]
5555
}
5656
]
57-
}
58-
});
59-
60-
// Export with Runtime Plugins injected
61-
export default {
62-
...stackConfig,
57+
},
6358
plugins: [
6459
new ObjectQLPlugin(),
65-
new DriverPlugin(new InMemoryDriver()),
66-
new AppPlugin(stackConfig)
60+
new DriverPlugin(new InMemoryDriver())
6761
]
68-
};
62+
});
6963

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
"author": "Steedos",
2323
"license": "MIT",
2424
"dependencies": {
25-
"@objectstack/spec": "workspace:*",
2625
"@objectstack/core": "workspace:*",
2726
"@objectstack/plugin-hono-server": "workspace:*",
27+
"@objectstack/runtime": "workspace:^",
28+
"@objectstack/spec": "workspace:*",
2829
"bundle-require": "^5.1.0",
2930
"chalk": "^5.3.0",
3031
"commander": "^11.1.0",

packages/cli/src/commands/serve.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ export const serveCommand = new Command('serve')
9696
logger: loggerConfig
9797
});
9898

99+
// Auto-register AppPlugin if config contains app definitions
100+
if (config.objects || config.manifest || config.apps) {
101+
try {
102+
const { AppPlugin } = await import('@objectstack/runtime');
103+
kernel.use(new AppPlugin(config));
104+
console.log(chalk.green(` ✓ Registered App Plugin (auto-detected)`));
105+
} catch (e: any) {
106+
console.warn(chalk.yellow(` ⚠ Could not auto-load AppPlugin: ${e.message}`));
107+
}
108+
}
109+
99110
// Load plugins from configuration
100111
let plugins = config.plugins || [];
101112

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)