@objectql/cli 1.8.2 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +229 -0
  3. package/USAGE_EXAMPLES.md +147 -0
  4. package/__tests__/commands.test.ts +274 -1
  5. package/dist/commands/ai.js +4 -3
  6. package/dist/commands/ai.js.map +1 -1
  7. package/dist/commands/build.d.ts +12 -0
  8. package/dist/commands/build.js +119 -0
  9. package/dist/commands/build.js.map +1 -0
  10. package/dist/commands/dev.d.ts +9 -0
  11. package/dist/commands/dev.js +23 -0
  12. package/dist/commands/dev.js.map +1 -0
  13. package/dist/commands/format.d.ts +9 -0
  14. package/dist/commands/format.js +137 -0
  15. package/dist/commands/format.js.map +1 -0
  16. package/dist/commands/lint.d.ts +9 -0
  17. package/dist/commands/lint.js +120 -0
  18. package/dist/commands/lint.js.map +1 -0
  19. package/dist/commands/new.js +5 -52
  20. package/dist/commands/new.js.map +1 -1
  21. package/dist/commands/start.d.ts +11 -0
  22. package/dist/commands/start.js +119 -0
  23. package/dist/commands/start.js.map +1 -0
  24. package/dist/commands/sync.d.ts +14 -0
  25. package/dist/commands/sync.js +314 -0
  26. package/dist/commands/sync.js.map +1 -0
  27. package/dist/commands/test.d.ts +10 -0
  28. package/dist/commands/test.js +120 -0
  29. package/dist/commands/test.js.map +1 -0
  30. package/dist/index.js +109 -14
  31. package/dist/index.js.map +1 -1
  32. package/jest.config.js +19 -0
  33. package/package.json +7 -7
  34. package/src/commands/ai.ts +4 -3
  35. package/src/commands/build.ts +98 -0
  36. package/src/commands/dev.ts +23 -0
  37. package/src/commands/format.ts +110 -0
  38. package/src/commands/lint.ts +98 -0
  39. package/src/commands/new.ts +5 -52
  40. package/src/commands/start.ts +100 -0
  41. package/src/commands/sync.ts +328 -0
  42. package/src/commands/test.ts +98 -0
  43. package/src/index.ts +114 -14
  44. package/tsconfig.tsbuildinfo +1 -1
  45. package/dist/commands/studio.d.ts +0 -5
  46. package/dist/commands/studio.js +0 -364
  47. package/dist/commands/studio.js.map +0 -1
  48. package/src/commands/studio.ts +0 -354
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.syncDatabase = syncDatabase;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const yaml = __importStar(require("js-yaml"));
44
+ /**
45
+ * Sync database schema to ObjectQL .object.yml files
46
+ * Introspects existing SQL database and generates object definitions
47
+ */
48
+ async function syncDatabase(options) {
49
+ const outputDir = path.resolve(process.cwd(), options.output || './src/objects');
50
+ console.log(chalk_1.default.blue('🔄 Syncing database schema to ObjectQL...'));
51
+ console.log(chalk_1.default.gray(`Output directory: ${outputDir}\n`));
52
+ let app = options.app;
53
+ const shouldClose = !options.app; // Only close if we loaded it ourselves
54
+ try {
55
+ // Load ObjectQL instance from config if not provided
56
+ if (!app) {
57
+ app = await loadObjectQLInstance(options.config);
58
+ }
59
+ // Check if driver supports introspection
60
+ const driver = app.datasource('default');
61
+ if (!driver || !driver.introspectSchema) {
62
+ const errorMsg = 'The configured driver does not support schema introspection. Only SQL drivers (PostgreSQL, MySQL, SQLite) support this feature.';
63
+ console.error(chalk_1.default.red(`❌ ${errorMsg}`));
64
+ throw new Error(errorMsg);
65
+ }
66
+ // Introspect database schema
67
+ console.log(chalk_1.default.blue('📊 Introspecting database schema...'));
68
+ const schema = await driver.introspectSchema();
69
+ const tableNames = Object.keys(schema.tables);
70
+ if (tableNames.length === 0) {
71
+ console.log(chalk_1.default.yellow('⚠ No tables found in database'));
72
+ return;
73
+ }
74
+ console.log(chalk_1.default.green(`✓ Found ${tableNames.length} table(s)\n`));
75
+ // Filter tables if specified
76
+ let tablesToSync = tableNames;
77
+ if (options.tables && options.tables.length > 0) {
78
+ tablesToSync = tableNames.filter(t => options.tables.includes(t));
79
+ if (tablesToSync.length === 0) {
80
+ console.log(chalk_1.default.yellow('⚠ No matching tables found'));
81
+ return;
82
+ }
83
+ }
84
+ // Create output directory if it doesn't exist
85
+ if (!fs.existsSync(outputDir)) {
86
+ fs.mkdirSync(outputDir, { recursive: true });
87
+ console.log(chalk_1.default.gray(`Created directory: ${outputDir}\n`));
88
+ }
89
+ // Generate .object.yml files
90
+ let createdCount = 0;
91
+ let skippedCount = 0;
92
+ for (const tableName of tablesToSync) {
93
+ const table = schema.tables[tableName];
94
+ const filename = `${tableName}.object.yml`;
95
+ const filePath = path.join(outputDir, filename);
96
+ // Check if file already exists
97
+ if (fs.existsSync(filePath) && !options.force) {
98
+ console.log(chalk_1.default.yellow(`⊘ ${tableName} (file exists, use --force to overwrite)`));
99
+ skippedCount++;
100
+ continue;
101
+ }
102
+ // Generate object definition
103
+ const objectDef = generateObjectDefinition(table, schema);
104
+ // Write to file
105
+ const yamlContent = yaml.dump(objectDef, {
106
+ indent: 2,
107
+ lineWidth: -1,
108
+ noRefs: true,
109
+ sortKeys: false
110
+ });
111
+ fs.writeFileSync(filePath, yamlContent, 'utf-8');
112
+ console.log(chalk_1.default.green(`✓ ${tableName} → ${filename}`));
113
+ createdCount++;
114
+ }
115
+ console.log(chalk_1.default.blue('\n📊 Summary:'));
116
+ console.log(chalk_1.default.gray(`Total tables: ${tablesToSync.length}`));
117
+ console.log(chalk_1.default.gray(`Created: ${createdCount}`));
118
+ console.log(chalk_1.default.gray(`Skipped: ${skippedCount}`));
119
+ if (createdCount > 0) {
120
+ console.log(chalk_1.default.green(`\n✅ Successfully synced ${createdCount} table(s) to ${outputDir}`));
121
+ }
122
+ }
123
+ catch (error) {
124
+ console.error(chalk_1.default.red(`❌ Sync failed: ${error.message}`));
125
+ if (error.stack) {
126
+ console.error(chalk_1.default.gray(error.stack));
127
+ }
128
+ throw error;
129
+ }
130
+ finally {
131
+ // Ensure connection is closed if we opened it
132
+ if (shouldClose && app) {
133
+ if (app.close) {
134
+ await app.close();
135
+ }
136
+ else {
137
+ // Fallback for older versions if close isn't available
138
+ const driver = app.datasource('default');
139
+ if (driver && driver.disconnect) {
140
+ await driver.disconnect();
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ /**
147
+ * Generate ObjectQL object definition from introspected table
148
+ */
149
+ function generateObjectDefinition(table, schema) {
150
+ const obj = {
151
+ name: table.name,
152
+ label: formatLabel(table.name),
153
+ fields: {}
154
+ };
155
+ // Process each column
156
+ for (const column of table.columns) {
157
+ // Skip system fields (id, created_at, updated_at) - they're automatic
158
+ if (['id', 'created_at', 'updated_at'].includes(column.name)) {
159
+ continue;
160
+ }
161
+ const field = {};
162
+ // Check if this is a foreign key
163
+ const fk = table.foreignKeys.find(fk => fk.columnName === column.name);
164
+ if (fk) {
165
+ // This is a lookup/relationship field
166
+ field.type = 'lookup';
167
+ field.reference_to = fk.referencedTable;
168
+ // Add label
169
+ field.label = formatLabel(column.name);
170
+ // Add required constraint
171
+ if (!column.nullable) {
172
+ field.required = true;
173
+ }
174
+ }
175
+ else {
176
+ // Regular field - map SQL type to ObjectQL type
177
+ const fieldType = mapSqlTypeToObjectQL(column.type, column);
178
+ field.type = fieldType;
179
+ // Add label
180
+ field.label = formatLabel(column.name);
181
+ // Add constraints
182
+ if (!column.nullable) {
183
+ field.required = true;
184
+ }
185
+ if (column.isUnique) {
186
+ field.unique = true;
187
+ }
188
+ // Add max_length for text-based fields
189
+ if (column.maxLength && (fieldType === 'text' || fieldType === 'textarea')) {
190
+ field.max_length = column.maxLength;
191
+ }
192
+ if (column.defaultValue !== undefined && column.defaultValue !== null) {
193
+ // Only include simple default values
194
+ if (typeof column.defaultValue === 'string' ||
195
+ typeof column.defaultValue === 'number' ||
196
+ typeof column.defaultValue === 'boolean') {
197
+ field.defaultValue = column.defaultValue;
198
+ }
199
+ }
200
+ }
201
+ obj.fields[column.name] = field;
202
+ }
203
+ return obj;
204
+ }
205
+ /**
206
+ * Map SQL native type to ObjectQL field type
207
+ */
208
+ function mapSqlTypeToObjectQL(sqlType, column) {
209
+ const type = sqlType.toLowerCase();
210
+ // Integer types - map to 'number'
211
+ if (type.includes('int') || type.includes('serial') || type.includes('bigserial')) {
212
+ return 'number';
213
+ }
214
+ // Float/Decimal types
215
+ if (type.includes('float') || type.includes('double') ||
216
+ type.includes('decimal') || type.includes('numeric') || type.includes('real')) {
217
+ return 'number';
218
+ }
219
+ // Boolean
220
+ if (type.includes('bool') || type === 'bit') {
221
+ return 'boolean';
222
+ }
223
+ // Date/Time types
224
+ if (type.includes('timestamp') || type.includes('datetime')) {
225
+ return 'datetime';
226
+ }
227
+ if (type === 'date') {
228
+ return 'date';
229
+ }
230
+ if (type === 'time') {
231
+ return 'time';
232
+ }
233
+ // Text types
234
+ if (type.includes('text') || type.includes('clob') || type.includes('long')) {
235
+ return 'textarea';
236
+ }
237
+ // JSON types - map to 'object'
238
+ if (type.includes('json') || type.includes('jsonb')) {
239
+ return 'object';
240
+ }
241
+ // Binary/Blob types
242
+ if (type.includes('blob') || type.includes('binary') || type.includes('bytea')) {
243
+ return 'file';
244
+ }
245
+ // String types (varchar, char, etc.)
246
+ // Default to 'text' for general string fields
247
+ return 'text';
248
+ }
249
+ /**
250
+ * Format table/column name to human-readable label
251
+ * e.g., "user_profile" -> "User Profile"
252
+ */
253
+ function formatLabel(name) {
254
+ return name
255
+ .split('_')
256
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
257
+ .join(' ');
258
+ }
259
+ /**
260
+ * Load ObjectQL instance from config file
261
+ */
262
+ async function loadObjectQLInstance(configPath) {
263
+ const cwd = process.cwd();
264
+ // Try to load from config file
265
+ let configFile = configPath;
266
+ if (!configFile) {
267
+ const potentialFiles = ['objectql.config.ts', 'objectql.config.js'];
268
+ for (const file of potentialFiles) {
269
+ if (fs.existsSync(path.join(cwd, file))) {
270
+ configFile = path.join(cwd, file);
271
+ break;
272
+ }
273
+ }
274
+ }
275
+ else if (!path.isAbsolute(configFile)) {
276
+ // If configPath is provided but relative, make it absolute
277
+ configFile = path.join(cwd, configFile);
278
+ }
279
+ if (!configFile) {
280
+ throw new Error('No configuration file found (objectql.config.ts/js). Please create one with database connection.');
281
+ }
282
+ // Register ts-node for TypeScript support
283
+ if (configFile.endsWith('.ts')) {
284
+ try {
285
+ require('ts-node').register({
286
+ transpileOnly: true,
287
+ compilerOptions: {
288
+ module: 'commonjs'
289
+ }
290
+ });
291
+ }
292
+ catch (err) {
293
+ throw new Error('TypeScript config file detected but ts-node is not installed. Please run: npm install --save-dev ts-node');
294
+ }
295
+ }
296
+ const configModule = require(configFile);
297
+ // Clear cache to support multiple runs in same process (e.g. tests)
298
+ try {
299
+ const resolvedPath = require.resolve(configFile);
300
+ delete require.cache[resolvedPath];
301
+ }
302
+ catch (e) {
303
+ // Ignore resolution errors
304
+ }
305
+ // Support multiple export patterns: default, app, objectql, or db (in order of precedence)
306
+ const app = configModule.default || configModule.app || configModule.objectql || configModule.db;
307
+ if (!app) {
308
+ throw new Error('Config file must export an ObjectQL instance as default export or named export (app/objectql/db)');
309
+ }
310
+ // Initialize app (but don't sync schema - we're reading it)
311
+ await app.init();
312
+ return app;
313
+ }
314
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,oCAiHC;AAnID,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,8CAAgC;AAWhC;;;GAGG;AACI,KAAK,UAAU,YAAY,CAAC,OAAoB;IACnD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC;IAEjF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qBAAqB,SAAS,IAAI,CAAC,CAAC,CAAC;IAE5D,IAAI,GAAG,GAA0B,OAAO,CAAC,GAAG,CAAC;IAC7C,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,uCAAuC;IAEzE,IAAI,CAAC;QACD,qDAAqD;QACrD,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,GAAG,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;QAED,yCAAy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ED,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAC;IACxH,CAAC;IAED,0CAA0C;IAC1C,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC;YACD,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;gBACxB,aAAa,EAAE,IAAI;gBACnB,eAAe,EAAE;oBACb,MAAM,EAAE,UAAU;iBACrB;aACJ,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;QAChI,CAAC;IACL,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzC,oEAAoE;IACpE,IAAI,CAAC;QACD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,2BAA2B;IAC/B,CAAC;IAED,2FAA2F;IAC3F,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,EAAE,CAAC;IAEjG,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAC;IACxH,CAAC;IAED,4DAA4D;IAC5D,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ interface TestOptions {
2
+ dir?: string;
3
+ watch?: boolean;
4
+ coverage?: boolean;
5
+ }
6
+ /**
7
+ * Test command - runs tests for the ObjectQL project
8
+ */
9
+ export declare function test(options: TestOptions): Promise<void>;
10
+ export {};
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.test = test;
40
+ const path = __importStar(require("path"));
41
+ const fs = __importStar(require("fs"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const child_process_1 = require("child_process");
44
+ /**
45
+ * Test command - runs tests for the ObjectQL project
46
+ */
47
+ async function test(options) {
48
+ var _a, _b, _c;
49
+ console.log(chalk_1.default.blue('🧪 Running tests...\n'));
50
+ const rootDir = path.resolve(process.cwd(), options.dir || '.');
51
+ // Look for package.json to determine test runner
52
+ const packageJsonPath = path.join(rootDir, 'package.json');
53
+ let testCommand = 'npm test';
54
+ try {
55
+ if (fs.existsSync(packageJsonPath)) {
56
+ try {
57
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
58
+ // Check if jest is configured
59
+ if (((_a = packageJson.devDependencies) === null || _a === void 0 ? void 0 : _a.jest) || ((_b = packageJson.dependencies) === null || _b === void 0 ? void 0 : _b.jest) || packageJson.jest) {
60
+ const jestArgs = ['jest'];
61
+ if (options.watch) {
62
+ jestArgs.push('--watch');
63
+ }
64
+ if (options.coverage) {
65
+ jestArgs.push('--coverage');
66
+ }
67
+ console.log(chalk_1.default.cyan(`Running: ${jestArgs.join(' ')}\n`));
68
+ const jestProcess = (0, child_process_1.spawn)('npx', jestArgs, {
69
+ cwd: rootDir,
70
+ stdio: 'inherit',
71
+ shell: true
72
+ });
73
+ jestProcess.on('exit', (code) => {
74
+ if (code !== 0) {
75
+ console.error(chalk_1.default.red(`\n❌ Tests failed with exit code ${code}`));
76
+ process.exit(code || 1);
77
+ }
78
+ else {
79
+ console.log(chalk_1.default.green('\n✅ All tests passed!'));
80
+ }
81
+ });
82
+ return;
83
+ }
84
+ // Fall back to package.json test script
85
+ if ((_c = packageJson.scripts) === null || _c === void 0 ? void 0 : _c.test) {
86
+ console.log(chalk_1.default.cyan(`Running: npm test\n`));
87
+ const npmProcess = (0, child_process_1.spawn)('npm', ['test'], {
88
+ cwd: rootDir,
89
+ stdio: 'inherit',
90
+ shell: true
91
+ });
92
+ npmProcess.on('exit', (code) => {
93
+ if (code !== 0) {
94
+ console.error(chalk_1.default.red(`\n❌ Tests failed with exit code ${code}`));
95
+ process.exit(code || 1);
96
+ }
97
+ else {
98
+ console.log(chalk_1.default.green('\n✅ All tests passed!'));
99
+ }
100
+ });
101
+ return;
102
+ }
103
+ }
104
+ catch (parseError) {
105
+ console.error(chalk_1.default.yellow(`⚠️ Failed to parse package.json: ${parseError.message}`));
106
+ }
107
+ }
108
+ // No test configuration found
109
+ console.log(chalk_1.default.yellow('⚠️ No test configuration found'));
110
+ console.log(chalk_1.default.gray('To add tests to your project:'));
111
+ console.log(chalk_1.default.gray(' 1. Install jest: npm install --save-dev jest @types/jest ts-jest'));
112
+ console.log(chalk_1.default.gray(' 2. Create a jest.config.js file'));
113
+ console.log(chalk_1.default.gray(' 3. Add a test script to package.json'));
114
+ }
115
+ catch (e) {
116
+ console.error(chalk_1.default.red('❌ Test execution failed:'), e.message);
117
+ process.exit(1);
118
+ }
119
+ }
120
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oBAmFC;AAjGD,2CAA6B;AAC7B,uCAAyB;AACzB,kDAA0B;AAC1B,iDAAsC;AAQtC;;GAEG;AACI,KAAK,UAAU,IAAI,CAAC,OAAoB;;IAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAEjD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAEhE,iDAAiD;IACjD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC3D,IAAI,WAAW,GAAG,UAAU,CAAC;IAE7B,IAAI,CAAC;QACD,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC;gBACD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;gBAE1E,8BAA8B;gBAC9B,IAAI,CAAA,MAAA,WAAW,CAAC,eAAe,0CAAE,IAAI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OAAO,CAAM,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC"}
package/dist/index.js CHANGED
@@ -4,12 +4,18 @@ const commander_1 = require("commander");
4
4
  const generate_1 = require("./commands/generate");
5
5
  const repl_1 = require("./commands/repl");
6
6
  const serve_1 = require("./commands/serve");
7
- const studio_1 = require("./commands/studio");
7
+ const dev_1 = require("./commands/dev");
8
+ const start_1 = require("./commands/start");
9
+ const build_1 = require("./commands/build");
10
+ const test_1 = require("./commands/test");
11
+ const lint_1 = require("./commands/lint");
12
+ const format_1 = require("./commands/format");
8
13
  const init_1 = require("./commands/init");
9
14
  const new_1 = require("./commands/new");
10
15
  const i18n_1 = require("./commands/i18n");
11
16
  const migrate_1 = require("./commands/migrate");
12
17
  const ai_1 = require("./commands/ai");
18
+ const sync_1 = require("./commands/sync");
13
19
  const program = new commander_1.Command();
14
20
  program
15
21
  .name('objectql')
@@ -151,6 +157,23 @@ migrateCmd
151
157
  process.exit(1);
152
158
  }
153
159
  });
160
+ // Sync command - Introspect database and generate .object.yml files
161
+ program
162
+ .command('sync')
163
+ .description('Sync database schema to ObjectQL object definitions')
164
+ .option('-c, --config <path>', 'Path to objectql.config.ts/js')
165
+ .option('-o, --output <path>', 'Output directory for .object.yml files', './src/objects')
166
+ .option('-t, --tables <tables...>', 'Specific tables to sync (default: all)')
167
+ .option('-f, --force', 'Overwrite existing files')
168
+ .action(async (options) => {
169
+ try {
170
+ await (0, sync_1.syncDatabase)(options);
171
+ }
172
+ catch (error) {
173
+ console.error(error);
174
+ process.exit(1);
175
+ }
176
+ });
154
177
  // REPL command
155
178
  program
156
179
  .command('repl')
@@ -160,31 +183,103 @@ program
160
183
  .action(async (options) => {
161
184
  await (0, repl_1.startRepl)(options.config);
162
185
  });
163
- // Serve command
186
+ // Dev command - Start development server
164
187
  program
165
- .command('serve')
166
- .alias('s')
167
- .description('Start a development server')
188
+ .command('dev')
189
+ .alias('d')
190
+ .description('Start development server with hot reload')
168
191
  .option('-p, --port <number>', 'Port to listen on', '3000')
169
192
  .option('-d, --dir <path>', 'Directory containing schema', '.')
193
+ .option('--no-watch', 'Disable file watching')
170
194
  .action(async (options) => {
171
- await (0, serve_1.serve)({ port: parseInt(options.port), dir: options.dir });
195
+ await (0, dev_1.dev)({
196
+ port: parseInt(options.port),
197
+ dir: options.dir,
198
+ watch: options.watch
199
+ });
172
200
  });
173
- // Studio command
201
+ // Start command - Production server
174
202
  program
175
- .command('studio')
176
- .alias('ui')
177
- .description('Start the ObjectQL Studio')
178
- .option('-p, --port <number>', 'Port to listen on', '5555')
203
+ .command('start')
204
+ .description('Start production server')
205
+ .option('-p, --port <number>', 'Port to listen on', '3000')
179
206
  .option('-d, --dir <path>', 'Directory containing schema', '.')
180
- .option('--no-open', 'Do not open browser automatically')
207
+ .option('-c, --config <path>', 'Path to objectql.config.ts/js')
181
208
  .action(async (options) => {
182
- await (0, studio_1.startStudio)({
209
+ await (0, start_1.start)({
183
210
  port: parseInt(options.port),
184
211
  dir: options.dir,
185
- open: options.open
212
+ config: options.config
186
213
  });
187
214
  });
215
+ // Build command - Build project for production
216
+ program
217
+ .command('build')
218
+ .alias('b')
219
+ .description('Build project and generate types')
220
+ .option('-d, --dir <path>', 'Source directory', '.')
221
+ .option('-o, --output <path>', 'Output directory', './dist')
222
+ .option('--no-types', 'Skip TypeScript type generation')
223
+ .option('--no-validate', 'Skip metadata validation')
224
+ .action(async (options) => {
225
+ await (0, build_1.build)({
226
+ dir: options.dir,
227
+ output: options.output,
228
+ types: options.types,
229
+ validate: options.validate
230
+ });
231
+ });
232
+ // Test command - Run tests
233
+ program
234
+ .command('test')
235
+ .alias('t')
236
+ .description('Run tests')
237
+ .option('-d, --dir <path>', 'Project directory', '.')
238
+ .option('-w, --watch', 'Watch mode')
239
+ .option('--coverage', 'Generate coverage report')
240
+ .action(async (options) => {
241
+ await (0, test_1.test)({
242
+ dir: options.dir,
243
+ watch: options.watch,
244
+ coverage: options.coverage
245
+ });
246
+ });
247
+ // Lint command - Validate metadata
248
+ program
249
+ .command('lint')
250
+ .alias('l')
251
+ .description('Validate metadata files')
252
+ .option('-d, --dir <path>', 'Directory to lint', '.')
253
+ .option('--fix', 'Automatically fix issues')
254
+ .action(async (options) => {
255
+ await (0, lint_1.lint)({
256
+ dir: options.dir,
257
+ fix: options.fix
258
+ });
259
+ });
260
+ // Format command - Format metadata files
261
+ program
262
+ .command('format')
263
+ .alias('fmt')
264
+ .description('Format metadata files with Prettier')
265
+ .option('-d, --dir <path>', 'Directory to format', '.')
266
+ .option('--check', 'Check if files are formatted without modifying')
267
+ .action(async (options) => {
268
+ await (0, format_1.format)({
269
+ dir: options.dir,
270
+ check: options.check
271
+ });
272
+ });
273
+ // Serve command (kept for backwards compatibility)
274
+ program
275
+ .command('serve')
276
+ .alias('s')
277
+ .description('Start a development server (alias for dev)')
278
+ .option('-p, --port <number>', 'Port to listen on', '3000')
279
+ .option('-d, --dir <path>', 'Directory containing schema', '.')
280
+ .action(async (options) => {
281
+ await (0, serve_1.serve)({ port: parseInt(options.port), dir: options.dir });
282
+ });
188
283
  // AI command - Interactive by default, with specific subcommands for other modes
189
284
  const aiCmd = program
190
285
  .command('ai')