Skip to content

Commit 1004247

Browse files
committed
refactor: replace ObjectQL with MetadataRegistry in build, lint, and repl commands
1 parent 66fee6b commit 1004247

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/tools/cli/src/commands/build.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { ObjectQL } from '@objectql/core';
109
import { ObjectLoader } from '@objectql/platform-node';
10+
import { MetadataRegistry } from '@objectql/types';
1111
import { generateTypes } from './generate';
1212
import * as path from 'path';
1313
import * as fs from 'fs';
@@ -36,8 +36,8 @@ export async function build(options: BuildOptions) {
3636
console.log(chalk.cyan('1️⃣ Validating metadata files...'));
3737

3838
try {
39-
const app = new ObjectQL({ datasources: {} });
40-
const loader = new ObjectLoader(app.metadata);
39+
const registry = new MetadataRegistry();
40+
const loader = new ObjectLoader(registry);
4141
loader.load(rootDir);
4242
console.log(chalk.green(' ✅ Metadata validation passed\n'));
4343
} catch (e: any) {

packages/tools/cli/src/commands/lint.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { ObjectQL } from '@objectql/core';
109
import { ObjectLoader } from '@objectql/platform-node';
11-
import { ObjectConfig, FieldConfig } from '@objectql/types';
10+
import { MetadataRegistry, ObjectConfig, FieldConfig } from '@objectql/types';
1211
import * as path from 'path';
1312
import chalk from 'chalk';
1413

@@ -31,13 +30,13 @@ export async function lint(options: LintOptions) {
3130
let hasWarnings = false;
3231

3332
try {
34-
const app = new ObjectQL({ datasources: {} });
35-
const loader = new ObjectLoader(app.metadata);
33+
const registry = new MetadataRegistry();
34+
const loader = new ObjectLoader(registry);
3635

3736
console.log(chalk.cyan('Loading metadata files...'));
3837
loader.load(rootDir);
3938

40-
const objects = app.metadata.list('object');
39+
const objects = registry.list('object');
4140

4241
console.log(chalk.green(`✅ Found ${objects.length} object(s)\n`));
4342

packages/tools/cli/src/commands/repl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export async function startRepl(configPath?: string) {
7373
r.context.object = (name: string) => app.getObject(name);
7474

7575
// Helper to get a repo quickly: tasks.find() instead of app.object('tasks').find()
76-
const objects = app.metadata.list<{ name: string }>('object');
76+
const configs = app.getConfigs();
77+
const objects = Object.values(configs) as Array<{ name: string }>;
7778
for (const obj of objects) {
7879
// Inject repositories as top-level globals if valid identifiers
7980
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(obj.name)) {

0 commit comments

Comments
 (0)