@objectql/cli 1.8.3 → 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.
- package/CHANGELOG.md +12 -0
- package/README.md +156 -0
- package/__tests__/commands.test.ts +110 -0
- package/dist/commands/ai.js +4 -3
- package/dist/commands/ai.js.map +1 -1
- package/dist/commands/build.d.ts +12 -0
- package/dist/commands/build.js +119 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.js +23 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/format.d.ts +9 -0
- package/dist/commands/format.js +137 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/lint.d.ts +9 -0
- package/dist/commands/lint.js +120 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/new.js +0 -52
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/start.d.ts +11 -0
- package/dist/commands/start.js +119 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/test.d.ts +10 -0
- package/dist/commands/test.js +120 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/index.js +91 -14
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/commands/ai.ts +4 -3
- package/src/commands/build.ts +98 -0
- package/src/commands/dev.ts +23 -0
- package/src/commands/format.ts +110 -0
- package/src/commands/lint.ts +98 -0
- package/src/commands/new.ts +0 -52
- package/src/commands/start.ts +100 -0
- package/src/commands/test.ts +98 -0
- package/src/index.ts +96 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/commands/studio.d.ts +0 -5
- package/dist/commands/studio.js +0 -364
- package/dist/commands/studio.js.map +0 -1
- package/src/commands/studio.ts +0 -354
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oBAmFC;AAjGD,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CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;wBACtD,CAAC;oBACL,CAAC,CAAC,CAAC;oBAEH,OAAO;gBACX,CAAC;YACD,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,MAAM,CAAC,qCAAqC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC3F,CAAC;QACL,CAAC;QAED,8BAA8B;QAC9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC;IAEtE,CAAC;IAAC,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,7 +4,12 @@ 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
|
|
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");
|
|
@@ -178,31 +183,103 @@ program
|
|
|
178
183
|
.action(async (options) => {
|
|
179
184
|
await (0, repl_1.startRepl)(options.config);
|
|
180
185
|
});
|
|
181
|
-
//
|
|
186
|
+
// Dev command - Start development server
|
|
182
187
|
program
|
|
183
|
-
.command('
|
|
184
|
-
.alias('
|
|
185
|
-
.description('Start
|
|
188
|
+
.command('dev')
|
|
189
|
+
.alias('d')
|
|
190
|
+
.description('Start development server with hot reload')
|
|
186
191
|
.option('-p, --port <number>', 'Port to listen on', '3000')
|
|
187
192
|
.option('-d, --dir <path>', 'Directory containing schema', '.')
|
|
193
|
+
.option('--no-watch', 'Disable file watching')
|
|
188
194
|
.action(async (options) => {
|
|
189
|
-
await (0,
|
|
195
|
+
await (0, dev_1.dev)({
|
|
196
|
+
port: parseInt(options.port),
|
|
197
|
+
dir: options.dir,
|
|
198
|
+
watch: options.watch
|
|
199
|
+
});
|
|
190
200
|
});
|
|
191
|
-
//
|
|
201
|
+
// Start command - Production server
|
|
192
202
|
program
|
|
193
|
-
.command('
|
|
194
|
-
.
|
|
195
|
-
.
|
|
196
|
-
.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')
|
|
197
206
|
.option('-d, --dir <path>', 'Directory containing schema', '.')
|
|
198
|
-
.option('--
|
|
207
|
+
.option('-c, --config <path>', 'Path to objectql.config.ts/js')
|
|
199
208
|
.action(async (options) => {
|
|
200
|
-
await (0,
|
|
209
|
+
await (0, start_1.start)({
|
|
201
210
|
port: parseInt(options.port),
|
|
202
211
|
dir: options.dir,
|
|
203
|
-
|
|
212
|
+
config: options.config
|
|
204
213
|
});
|
|
205
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
|
+
});
|
|
206
283
|
// AI command - Interactive by default, with specific subcommands for other modes
|
|
207
284
|
const aiCmd = program
|
|
208
285
|
.command('ai')
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AACpC,kDAAoD;AACpD,0CAA4C;AAC5C,4CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AACpC,kDAAoD;AACpD,0CAA4C;AAC5C,4CAAyC;AACzC,wCAAqC;AACrC,4CAAyC;AACzC,4CAAyC;AACzC,0CAAuC;AACvC,0CAAuC;AACvC,8CAA2C;AAC3C,0CAA8C;AAC9C,wCAA6C;AAC7C,0CAAsE;AACtE,gDAA2E;AAC3E,sCAAiF;AACjF,0CAA+C;AAE/C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,mBAAmB,CAAC;KAChC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oCAAoC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C,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectql/cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "Command-line interface for ObjectQL - Code generation, migrations, REPL, and AI-powered development tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"objectql",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"ts-node": "^10.9.1",
|
|
30
30
|
"openai": "^4.28.0",
|
|
31
31
|
"dotenv": "^16.4.5",
|
|
32
|
-
"@objectql/types": "1.8.
|
|
33
|
-
"@objectql/
|
|
34
|
-
"@objectql/
|
|
35
|
-
"@objectql/
|
|
36
|
-
"@objectql/
|
|
32
|
+
"@objectql/types": "1.8.4",
|
|
33
|
+
"@objectql/server": "1.8.4",
|
|
34
|
+
"@objectql/core": "1.8.4",
|
|
35
|
+
"@objectql/driver-sql": "1.8.4",
|
|
36
|
+
"@objectql/platform-node": "1.8.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "^5.0.0",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc",
|
|
45
45
|
"watch": "tsc -w",
|
|
46
|
-
"studio": "node dist/index.js studio",
|
|
47
46
|
"test": "jest"
|
|
48
47
|
}
|
|
49
48
|
}
|
package/src/commands/ai.ts
CHANGED
|
@@ -263,10 +263,11 @@ export async function aiValidate(options: ValidateOptions): Promise<void> {
|
|
|
263
263
|
const patterns = [
|
|
264
264
|
'**/*.object.yml',
|
|
265
265
|
'**/*.validation.yml',
|
|
266
|
-
'**/*.form.yml',
|
|
267
|
-
'**/*.view.yml',
|
|
268
|
-
'**/*.page.yml',
|
|
269
266
|
'**/*.action.yml',
|
|
267
|
+
'**/*.hook.yml',
|
|
268
|
+
'**/*.permission.yml',
|
|
269
|
+
'**/*.workflow.yml',
|
|
270
|
+
'**/*.data.yml',
|
|
270
271
|
];
|
|
271
272
|
|
|
272
273
|
const files = await glob(patterns, {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ObjectQL } from '@objectql/core';
|
|
2
|
+
import { ObjectLoader } from '@objectql/platform-node';
|
|
3
|
+
import { generateTypes } from './generate';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import glob from 'fast-glob';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
interface BuildOptions {
|
|
10
|
+
dir?: string;
|
|
11
|
+
output?: string;
|
|
12
|
+
types?: boolean;
|
|
13
|
+
validate?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build command - validates metadata and generates TypeScript types
|
|
18
|
+
* Prepares the project for production deployment
|
|
19
|
+
*/
|
|
20
|
+
export async function build(options: BuildOptions) {
|
|
21
|
+
console.log(chalk.blue('🔨 Building ObjectQL project...\n'));
|
|
22
|
+
|
|
23
|
+
const rootDir = path.resolve(process.cwd(), options.dir || '.');
|
|
24
|
+
const outputDir = path.resolve(process.cwd(), options.output || './dist');
|
|
25
|
+
|
|
26
|
+
// Step 1: Validate metadata
|
|
27
|
+
if (options.validate !== false) {
|
|
28
|
+
console.log(chalk.cyan('1️⃣ Validating metadata files...'));
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const app = new ObjectQL({ datasources: {} });
|
|
32
|
+
const loader = new ObjectLoader(app.metadata);
|
|
33
|
+
loader.load(rootDir);
|
|
34
|
+
console.log(chalk.green(' ✅ Metadata validation passed\n'));
|
|
35
|
+
} catch (e: any) {
|
|
36
|
+
console.error(chalk.red(' ❌ Metadata validation failed:'), e.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Step 2: Generate TypeScript types
|
|
42
|
+
if (options.types !== false) {
|
|
43
|
+
console.log(chalk.cyan('2️⃣ Generating TypeScript types...'));
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const typesOutput = path.join(outputDir, 'types');
|
|
47
|
+
await generateTypes(rootDir, typesOutput);
|
|
48
|
+
console.log(chalk.green(` ✅ Types generated at ${typesOutput}\n`));
|
|
49
|
+
} catch (e: any) {
|
|
50
|
+
console.error(chalk.red(' ❌ Type generation failed:'), e.message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Step 3: Copy metadata files to dist
|
|
56
|
+
console.log(chalk.cyan('3️⃣ Copying metadata files...'));
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
// Ensure output directory exists
|
|
60
|
+
if (!fs.existsSync(outputDir)) {
|
|
61
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Copy .yml files
|
|
65
|
+
const metadataPatterns = [
|
|
66
|
+
'**/*.object.yml',
|
|
67
|
+
'**/*.validation.yml',
|
|
68
|
+
'**/*.permission.yml',
|
|
69
|
+
'**/*.hook.yml',
|
|
70
|
+
'**/*.action.yml',
|
|
71
|
+
'**/*.app.yml'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
let fileCount = 0;
|
|
75
|
+
const files = await glob(metadataPatterns, { cwd: rootDir });
|
|
76
|
+
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
const srcPath = path.join(rootDir, file);
|
|
79
|
+
const destPath = path.join(outputDir, file);
|
|
80
|
+
const destDir = path.dirname(destPath);
|
|
81
|
+
|
|
82
|
+
if (!fs.existsSync(destDir)) {
|
|
83
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fs.copyFileSync(srcPath, destPath);
|
|
87
|
+
fileCount++;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(chalk.green(` ✅ Copied ${fileCount} metadata files\n`));
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
console.error(chalk.red(' ❌ Failed to copy metadata files:'), e.message);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log(chalk.green.bold('✨ Build completed successfully!\n'));
|
|
97
|
+
console.log(chalk.gray(`Output directory: ${outputDir}`));
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { serve } from './serve';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Start development server with hot reload
|
|
6
|
+
* This is an enhanced version of the serve command for development workflow
|
|
7
|
+
*/
|
|
8
|
+
export async function dev(options: {
|
|
9
|
+
port: number;
|
|
10
|
+
dir: string;
|
|
11
|
+
watch?: boolean;
|
|
12
|
+
}) {
|
|
13
|
+
console.log(chalk.cyan('🚀 Starting ObjectQL Development Server...\n'));
|
|
14
|
+
|
|
15
|
+
// For now, delegate to serve command
|
|
16
|
+
// In future, can add file watching and auto-reload
|
|
17
|
+
await serve({ port: options.port, dir: options.dir });
|
|
18
|
+
|
|
19
|
+
if (options.watch !== false) {
|
|
20
|
+
console.log(chalk.yellow('\n👀 Watching for file changes... (Not yet implemented)'));
|
|
21
|
+
console.log(chalk.gray(' Tip: Use --no-watch to disable file watching'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import * as yaml from 'js-yaml';
|
|
5
|
+
import glob from 'fast-glob';
|
|
6
|
+
|
|
7
|
+
// Naming convention regex
|
|
8
|
+
const VALID_NAME_REGEX = /^[a-z][a-z0-9_]*$/;
|
|
9
|
+
|
|
10
|
+
interface FormatOptions {
|
|
11
|
+
dir?: string;
|
|
12
|
+
check?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Format command - formats metadata files using Prettier
|
|
17
|
+
*/
|
|
18
|
+
export async function format(options: FormatOptions) {
|
|
19
|
+
console.log(chalk.blue('🎨 Formatting ObjectQL metadata files...\n'));
|
|
20
|
+
|
|
21
|
+
const rootDir = path.resolve(process.cwd(), options.dir || '.');
|
|
22
|
+
let formattedCount = 0;
|
|
23
|
+
let unchangedCount = 0;
|
|
24
|
+
let errorCount = 0;
|
|
25
|
+
|
|
26
|
+
// Load Prettier once at the start
|
|
27
|
+
let prettier: any;
|
|
28
|
+
try {
|
|
29
|
+
prettier = await import('prettier');
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(chalk.red('❌ Prettier is not installed. Install it with: npm install --save-dev prettier'));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const files = await glob(['**/*.yml', '**/*.yaml'], {
|
|
37
|
+
cwd: rootDir,
|
|
38
|
+
ignore: ['node_modules/**', 'dist/**', 'build/**']
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(chalk.cyan(`Found ${files.length} YAML file(s)\n`));
|
|
42
|
+
|
|
43
|
+
for (const file of files) {
|
|
44
|
+
const filePath = path.join(rootDir, file);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
48
|
+
|
|
49
|
+
// Parse to validate YAML
|
|
50
|
+
yaml.load(content);
|
|
51
|
+
|
|
52
|
+
// Format with Prettier
|
|
53
|
+
const formatted = await prettier.format(content, {
|
|
54
|
+
parser: 'yaml',
|
|
55
|
+
printWidth: 80,
|
|
56
|
+
tabWidth: 2,
|
|
57
|
+
singleQuote: true
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (content !== formatted) {
|
|
61
|
+
if (options.check) {
|
|
62
|
+
console.log(chalk.yellow(` ⚠️ ${file} needs formatting`));
|
|
63
|
+
formattedCount++;
|
|
64
|
+
} else {
|
|
65
|
+
fs.writeFileSync(filePath, formatted, 'utf-8');
|
|
66
|
+
console.log(chalk.green(` ✅ ${file}`));
|
|
67
|
+
formattedCount++;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
unchangedCount++;
|
|
71
|
+
if (!options.check) {
|
|
72
|
+
console.log(chalk.gray(` ✓ ${file}`));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (e: any) {
|
|
76
|
+
console.error(chalk.red(` ❌ ${file}: ${e.message}`));
|
|
77
|
+
errorCount++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log('');
|
|
82
|
+
|
|
83
|
+
// Summary
|
|
84
|
+
if (options.check) {
|
|
85
|
+
if (formattedCount > 0) {
|
|
86
|
+
console.log(chalk.yellow.bold(`⚠️ ${formattedCount} file(s) need formatting`));
|
|
87
|
+
console.log(chalk.gray('Run without --check to format files\n'));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
} else {
|
|
90
|
+
console.log(chalk.green.bold('✅ All files are properly formatted!\n'));
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
console.log(chalk.cyan('Summary:'));
|
|
94
|
+
console.log(chalk.green(` ✅ Formatted: ${formattedCount}`));
|
|
95
|
+
console.log(chalk.gray(` ✓ Unchanged: ${unchangedCount}`));
|
|
96
|
+
if (errorCount > 0) {
|
|
97
|
+
console.log(chalk.red(` ❌ Errors: ${errorCount}`));
|
|
98
|
+
}
|
|
99
|
+
console.log('');
|
|
100
|
+
|
|
101
|
+
if (errorCount > 0) {
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
} catch (e: any) {
|
|
107
|
+
console.error(chalk.red('❌ Format failed:'), e.message);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ObjectQL } from '@objectql/core';
|
|
2
|
+
import { ObjectLoader } from '@objectql/platform-node';
|
|
3
|
+
import { ObjectConfig, FieldConfig } from '@objectql/types';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
|
|
7
|
+
// Naming convention regex
|
|
8
|
+
const VALID_NAME_REGEX = /^[a-z][a-z0-9_]*$/;
|
|
9
|
+
|
|
10
|
+
interface LintOptions {
|
|
11
|
+
dir?: string;
|
|
12
|
+
fix?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Lint command - validates metadata files for correctness and best practices
|
|
17
|
+
*/
|
|
18
|
+
export async function lint(options: LintOptions) {
|
|
19
|
+
console.log(chalk.blue('🔍 Linting ObjectQL metadata files...\n'));
|
|
20
|
+
|
|
21
|
+
const rootDir = path.resolve(process.cwd(), options.dir || '.');
|
|
22
|
+
let hasErrors = false;
|
|
23
|
+
let hasWarnings = false;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const app = new ObjectQL({ datasources: {} });
|
|
27
|
+
const loader = new ObjectLoader(app.metadata);
|
|
28
|
+
|
|
29
|
+
console.log(chalk.cyan('Loading metadata files...'));
|
|
30
|
+
loader.load(rootDir);
|
|
31
|
+
|
|
32
|
+
const objects = app.metadata.list('object');
|
|
33
|
+
|
|
34
|
+
console.log(chalk.green(`✅ Found ${objects.length} object(s)\n`));
|
|
35
|
+
|
|
36
|
+
// Validate each object
|
|
37
|
+
for (const obj of objects) {
|
|
38
|
+
const objectConfig = obj as ObjectConfig;
|
|
39
|
+
const name = objectConfig.name;
|
|
40
|
+
console.log(chalk.cyan(`Checking object: ${name}`));
|
|
41
|
+
|
|
42
|
+
// Check naming convention (lowercase with underscores)
|
|
43
|
+
if (!VALID_NAME_REGEX.test(name)) {
|
|
44
|
+
console.log(chalk.red(` ❌ Invalid name format: "${name}" should be lowercase with underscores`));
|
|
45
|
+
hasErrors = true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Check if label exists
|
|
49
|
+
if (!objectConfig.label) {
|
|
50
|
+
console.log(chalk.yellow(` ⚠️ Missing label for object "${name}"`));
|
|
51
|
+
hasWarnings = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check fields
|
|
55
|
+
const fieldCount = Object.keys(objectConfig.fields || {}).length;
|
|
56
|
+
if (fieldCount === 0) {
|
|
57
|
+
console.log(chalk.yellow(` ⚠️ Object "${name}" has no fields defined`));
|
|
58
|
+
hasWarnings = true;
|
|
59
|
+
} else {
|
|
60
|
+
console.log(chalk.gray(` ℹ️ ${fieldCount} field(s) defined`));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Validate field names
|
|
64
|
+
for (const [fieldName, field] of Object.entries(objectConfig.fields || {})) {
|
|
65
|
+
if (!VALID_NAME_REGEX.test(fieldName)) {
|
|
66
|
+
console.log(chalk.red(` ❌ Invalid field name: "${fieldName}" should be lowercase with underscores`));
|
|
67
|
+
hasErrors = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const fieldConfig = field as FieldConfig;
|
|
71
|
+
// Check for required label on fields
|
|
72
|
+
if (!fieldConfig.label) {
|
|
73
|
+
console.log(chalk.yellow(` ⚠️ Field "${fieldName}" missing label`));
|
|
74
|
+
hasWarnings = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Summary
|
|
82
|
+
if (hasErrors) {
|
|
83
|
+
console.log(chalk.red.bold('❌ Linting failed with errors\n'));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
} else if (hasWarnings) {
|
|
86
|
+
console.log(chalk.yellow.bold('⚠️ Linting completed with warnings\n'));
|
|
87
|
+
} else {
|
|
88
|
+
console.log(chalk.green.bold('✅ Linting passed - no issues found!\n'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
console.error(chalk.red('❌ Linting failed:'), e.message);
|
|
93
|
+
if (e.stack) {
|
|
94
|
+
console.error(chalk.gray(e.stack));
|
|
95
|
+
}
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/commands/new.ts
CHANGED
|
@@ -11,16 +11,11 @@ interface NewOptions {
|
|
|
11
11
|
|
|
12
12
|
const METADATA_TYPES = [
|
|
13
13
|
'object',
|
|
14
|
-
'view',
|
|
15
|
-
'form',
|
|
16
|
-
'page',
|
|
17
14
|
'action',
|
|
18
15
|
'hook',
|
|
19
16
|
'permission',
|
|
20
17
|
'validation',
|
|
21
18
|
'workflow',
|
|
22
|
-
'report',
|
|
23
|
-
'menu',
|
|
24
19
|
'data'
|
|
25
20
|
];
|
|
26
21
|
|
|
@@ -35,35 +30,6 @@ const TEMPLATES: Record<string, any> = {
|
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
32
|
},
|
|
38
|
-
view: {
|
|
39
|
-
label: '{{label}} View',
|
|
40
|
-
object: '{{objectName}}',
|
|
41
|
-
columns: [
|
|
42
|
-
{ field: 'name', label: 'Name' }
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
form: {
|
|
46
|
-
label: '{{label}} Form',
|
|
47
|
-
object: '{{objectName}}',
|
|
48
|
-
layout: {
|
|
49
|
-
sections: [
|
|
50
|
-
{
|
|
51
|
-
label: 'Basic Information',
|
|
52
|
-
fields: ['name']
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
page: {
|
|
58
|
-
label: '{{label}} Page',
|
|
59
|
-
type: 'standard',
|
|
60
|
-
components: [
|
|
61
|
-
{
|
|
62
|
-
type: 'title',
|
|
63
|
-
text: '{{label}}'
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
33
|
action: {
|
|
68
34
|
label: '{{label}} Action',
|
|
69
35
|
object: '{{objectName}}',
|
|
@@ -118,24 +84,6 @@ const TEMPLATES: Record<string, any> = {
|
|
|
118
84
|
}
|
|
119
85
|
]
|
|
120
86
|
},
|
|
121
|
-
report: {
|
|
122
|
-
label: '{{label}} Report',
|
|
123
|
-
type: 'tabular',
|
|
124
|
-
object: '{{objectName}}',
|
|
125
|
-
columns: [
|
|
126
|
-
{ field: 'name', label: 'Name' }
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
menu: {
|
|
130
|
-
label: '{{label}} Menu',
|
|
131
|
-
items: [
|
|
132
|
-
{
|
|
133
|
-
label: 'Home',
|
|
134
|
-
page: 'home',
|
|
135
|
-
icon: 'home'
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
87
|
data: {
|
|
140
88
|
label: '{{label}} Data',
|
|
141
89
|
object: '{{objectName}}',
|