Skip to content

Commit 5aa01a1

Browse files
Copilothotlong
andcommitted
Improve error handling and add helpful messages for TypeScript configs
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 05d4430 commit 5aa01a1

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

  • packages/tools/cli/src/commands

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ function generateObjectDefinition(table: IntrospectedTable, schema: Introspected
162162
field.unique = true;
163163
}
164164

165-
if (column.maxLength && ['text', 'string', 'email', 'url', 'phone'].includes(fieldType)) {
165+
// Add maxLength for text-based fields
166+
if (column.maxLength && (fieldType === 'text' || fieldType === 'textarea')) {
166167
field.maxLength = column.maxLength;
167168
}
168169

@@ -272,18 +273,21 @@ async function loadObjectQLInstance(configPath?: string): Promise<any> {
272273
}
273274

274275
// Register ts-node for TypeScript support
275-
try {
276-
require('ts-node').register({
277-
transpileOnly: true,
278-
compilerOptions: {
279-
module: 'commonjs'
280-
}
281-
});
282-
} catch (err) {
283-
// ts-node not available, try to load JS directly
276+
if (configFile.endsWith('.ts')) {
277+
try {
278+
require('ts-node').register({
279+
transpileOnly: true,
280+
compilerOptions: {
281+
module: 'commonjs'
282+
}
283+
});
284+
} catch (err) {
285+
throw new Error('TypeScript config file detected but ts-node is not installed. Please run: npm install --save-dev ts-node');
286+
}
284287
}
285288

286289
const configModule = require(configFile);
290+
// Support multiple export patterns: default, app, objectql, or db (in order of precedence)
287291
const app = configModule.default || configModule.app || configModule.objectql || configModule.db;
288292

289293
if (!app) {

0 commit comments

Comments
 (0)