relq 1.0.71 → 1.0.72

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.
@@ -169,7 +169,7 @@ exports.default = (0, citty_1.defineCommand)({
169
169
  }
170
170
  catch (error) {
171
171
  spin.error('Diff failed');
172
- (0, ui_1.fatal)(error instanceof Error ? error.message : String(error));
172
+ (0, ui_1.fatal)((0, ui_1.formatError)(error));
173
173
  }
174
174
  },
175
175
  });
@@ -146,7 +146,7 @@ async function exportFromDatabase(config, absoluteOutputPath, options) {
146
146
  }
147
147
  catch (error) {
148
148
  spin.error('Export failed');
149
- (0, ui_1.fatal)(error instanceof Error ? error.message : String(error));
149
+ (0, ui_1.fatal)((0, ui_1.formatError)(error));
150
150
  }
151
151
  }
152
152
  function normalizedToDbSchema(normalized) {
@@ -234,7 +234,7 @@ exports.default = (0, citty_1.defineCommand)({
234
234
  }
235
235
  catch (error) {
236
236
  spin.error('Generation failed');
237
- (0, ui_1.fatal)(error instanceof Error ? error.message : String(error));
237
+ (0, ui_1.fatal)((0, ui_1.formatError)(error));
238
238
  }
239
239
  },
240
240
  });
@@ -768,7 +768,7 @@ exports.default = (0, citty_1.defineCommand)({
768
768
  p.outro('');
769
769
  }
770
770
  catch (error) {
771
- (0, ui_1.fatal)('Initialization failed', error instanceof Error ? error.message : String(error));
771
+ (0, ui_1.fatal)('Initialization failed', (0, ui_1.formatError)(error));
772
772
  }
773
773
  },
774
774
  });
@@ -138,7 +138,7 @@ exports.default = (0, citty_1.defineCommand)({
138
138
  console.log(output.join('\n'));
139
139
  }
140
140
  catch (error) {
141
- (0, ui_1.fatal)('Error parsing SQL', error instanceof Error ? error.message : String(error));
141
+ (0, ui_1.fatal)('Error parsing SQL', (0, ui_1.formatError)(error));
142
142
  }
143
143
  },
144
144
  });
@@ -189,7 +189,7 @@ exports.default = (0, citty_1.defineCommand)({
189
189
  }
190
190
  catch (error) {
191
191
  spin.error('Migration failed');
192
- (0, ui_1.fatal)(error instanceof Error ? error.message : String(error));
192
+ (0, ui_1.fatal)((0, ui_1.formatError)(error));
193
193
  }
194
194
  },
195
195
  });
@@ -352,7 +352,7 @@ async function runPush(config, projectRoot, opts = {}) {
352
352
  }
353
353
  catch (err) {
354
354
  spin.error('Push failed');
355
- (0, ui_1.fatal)(err instanceof Error ? err.message : String(err));
355
+ (0, ui_1.fatal)((0, ui_1.formatError)(err));
356
356
  }
357
357
  }
358
358
  exports.default = (0, citty_1.defineCommand)({
@@ -213,7 +213,7 @@ exports.default = (0, citty_1.defineCommand)({
213
213
  }
214
214
  catch (err) {
215
215
  spin.error('Rollback failed');
216
- (0, ui_1.fatal)(err instanceof Error ? err.message : String(err));
216
+ (0, ui_1.fatal)((0, ui_1.formatError)(err));
217
217
  }
218
218
  },
219
219
  });
@@ -205,7 +205,7 @@ exports.default = (0, citty_1.defineCommand)({
205
205
  }
206
206
  catch (err) {
207
207
  spin.error('Seed failed');
208
- (0, ui_1.fatal)(err instanceof Error ? err.message : String(err));
208
+ (0, ui_1.fatal)((0, ui_1.formatError)(err));
209
209
  }
210
210
  },
211
211
  });
@@ -52,7 +52,7 @@ exports.default = (0, citty_1.defineCommand)({
52
52
  console.log('');
53
53
  }
54
54
  catch (err) {
55
- (0, ui_1.fatal)(err instanceof Error ? err.message : String(err));
55
+ (0, ui_1.fatal)((0, ui_1.formatError)(err));
56
56
  }
57
57
  },
58
58
  });
@@ -63,5 +63,13 @@ const main = (0, citty_1.defineCommand)({
63
63
  exports.main = main;
64
64
  const fromDev = process.argv.some(arg => arg.endsWith('index.ts'));
65
65
  if (fromDev) {
66
- (0, citty_1.runMain)(main).catch(console.error);
66
+ (0, citty_1.runMain)(main).catch(err => {
67
+ Promise.resolve().then(() => __importStar(require("./utils/ui.cjs"))).then(({ formatError, p }) => {
68
+ p.log.error(formatError(err));
69
+ process.exit(1);
70
+ }).catch(() => {
71
+ console.error('Error:', err instanceof Error ? err.message : String(err));
72
+ process.exit(1);
73
+ });
74
+ });
67
75
  }
@@ -60,26 +60,78 @@ function info(msg) {
60
60
  p.log.info(msg);
61
61
  }
62
62
  function formatError(err) {
63
+ if (err instanceof AggregateError) {
64
+ const errors = err.errors || [];
65
+ if (errors.length === 0) {
66
+ return err.message || 'Multiple errors occurred';
67
+ }
68
+ if (errors.length === 1) {
69
+ return formatError(errors[0]);
70
+ }
71
+ const formatted = errors.map((e, i) => ` ${i + 1}. ${formatError(e)}`).join('\n');
72
+ return `Multiple errors occurred:\n${formatted}`;
73
+ }
63
74
  if (err instanceof Error) {
64
- if (err.message?.includes('ECONNREFUSED')) {
75
+ const msg = err.message || '';
76
+ if (msg.includes('ECONNREFUSED')) {
65
77
  return 'Connection refused - is the database running?';
66
78
  }
67
- if (err.message?.includes('ENOTFOUND')) {
79
+ if (msg.includes('ENOTFOUND')) {
68
80
  return 'Host not found - check your connection settings';
69
81
  }
70
- if (err.message?.includes('authentication failed')) {
71
- return 'Authentication failed - check your credentials';
82
+ if (msg.includes('ECONNRESET')) {
83
+ return 'Connection reset - the database closed the connection';
84
+ }
85
+ if (msg.includes('ETIMEDOUT')) {
86
+ return 'Connection timed out - check network connectivity';
87
+ }
88
+ if (msg.includes('authentication failed') || msg.includes('password authentication')) {
89
+ return 'Authentication failed - check your username and password';
90
+ }
91
+ if (msg.includes('no pg_hba.conf entry')) {
92
+ return 'Access denied - your IP is not allowed to connect to this database';
93
+ }
94
+ if (msg.includes('database') && msg.includes('does not exist')) {
95
+ const match = msg.match(/database "([^"]+)" does not exist/);
96
+ return match
97
+ ? `Database "${match[1]}" does not exist - create it first or check the name`
98
+ : 'Database does not exist - check your connection settings';
72
99
  }
73
- if (err.message?.includes('timeout')) {
74
- return 'Connection timeout - check network connectivity';
100
+ if (msg.includes('relation') && msg.includes('does not exist')) {
101
+ const match = msg.match(/relation "([^"]+)" does not exist/);
102
+ return match
103
+ ? `Table "${match[1]}" does not exist`
104
+ : 'Table does not exist';
75
105
  }
76
- if (err.message?.includes('token') || err.message?.includes('IAM')) {
77
- return `AWS authentication error: ${err.message}`;
106
+ if (msg.includes('SSL') || msg.includes('certificate')) {
107
+ return `SSL/TLS error: ${msg}`;
78
108
  }
79
- return err.message || err.name || 'Unknown error';
109
+ if (msg.includes('token') || msg.includes('IAM') || msg.includes('credentials')) {
110
+ return `AWS authentication error: ${msg}`;
111
+ }
112
+ if (msg.includes('timeout') || msg.includes('Timeout')) {
113
+ return 'Operation timed out - try again or check your connection';
114
+ }
115
+ if (msg.includes('Cannot find module') || msg.includes('Module not found')) {
116
+ const match = msg.match(/Cannot find module '([^']+)'/);
117
+ return match
118
+ ? `Missing dependency: ${match[1]} - try running "npm install" or "bun install"`
119
+ : 'Missing dependency - try running "npm install" or "bun install"';
120
+ }
121
+ if (msg.includes('permission denied') || msg.includes('EACCES')) {
122
+ return 'Permission denied - check file/folder permissions';
123
+ }
124
+ if (msg.includes('relq.config') || msg.includes('config file')) {
125
+ return `Configuration error: ${msg}`;
126
+ }
127
+ return msg || err.name || 'Unknown error';
80
128
  }
81
- if (typeof err === 'string')
129
+ if (typeof err === 'string') {
82
130
  return err || 'Unknown error';
131
+ }
132
+ if (err && typeof err === 'object' && 'message' in err) {
133
+ return String(err.message) || 'Unknown error';
134
+ }
83
135
  return String(err) || 'Unknown error';
84
136
  }
85
137
  function requireInit(isInitialized) {
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty';
2
2
  import * as p from '@clack/prompts';
3
3
  import { buildContext } from "../utils/context.js";
4
4
  import { colors } from "../utils/colors.js";
5
- import { fatal } from "../utils/ui.js";
5
+ import { fatal, formatError } from "../utils/ui.js";
6
6
  import { requireValidConfig } from "../utils/config-loader.js";
7
7
  import { dialectIntrospect } from "../utils/dialect-introspect.js";
8
8
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -134,7 +134,7 @@ export default defineCommand({
134
134
  }
135
135
  catch (error) {
136
136
  spin.error('Diff failed');
137
- fatal(error instanceof Error ? error.message : String(error));
137
+ fatal(formatError(error));
138
138
  }
139
139
  },
140
140
  });
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as p from '@clack/prompts';
5
5
  import { buildContext } from "../utils/context.js";
6
6
  import { colors } from "../utils/colors.js";
7
- import { fatal } from "../utils/ui.js";
7
+ import { fatal, formatError } from "../utils/ui.js";
8
8
  import { formatBytes } from "../utils/format.js";
9
9
  import { dialectIntrospect } from "../utils/dialect-introspect.js";
10
10
  import { isInitialized, loadSnapshot, } from "../utils/repo-manager.js";
@@ -111,7 +111,7 @@ async function exportFromDatabase(config, absoluteOutputPath, options) {
111
111
  }
112
112
  catch (error) {
113
113
  spin.error('Export failed');
114
- fatal(error instanceof Error ? error.message : String(error));
114
+ fatal(formatError(error));
115
115
  }
116
116
  }
117
117
  function normalizedToDbSchema(normalized) {
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as p from '@clack/prompts';
5
5
  import { buildContext } from "../utils/context.js";
6
6
  import { colors } from "../utils/colors.js";
7
- import { fatal, warning } from "../utils/ui.js";
7
+ import { fatal, warning, formatError } from "../utils/ui.js";
8
8
  import { requireValidConfig, getSchemaPath } from "../utils/config-loader.js";
9
9
  import { dialectIntrospect } from "../utils/dialect-introspect.js";
10
10
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -199,7 +199,7 @@ export default defineCommand({
199
199
  }
200
200
  catch (error) {
201
201
  spin.error('Generation failed');
202
- fatal(error instanceof Error ? error.message : String(error));
202
+ fatal(formatError(error));
203
203
  }
204
204
  },
205
205
  });
@@ -6,7 +6,7 @@ import { loadEnvConfig } from "../utils/env-loader.js";
6
6
  import { initRepository, ensureRemoteTable, isInitialized } from "../utils/repo-manager.js";
7
7
  import { createDefaultRelqignore } from "../utils/relqignore.js";
8
8
  import { colors } from "../utils/colors.js";
9
- import { fatal, warning } from "../utils/ui.js";
9
+ import { fatal, warning, formatError } from "../utils/ui.js";
10
10
  import { detectDialectFromUrl } from "../utils/dialect-router.js";
11
11
  import { getAdapter } from "../adapters/registry.js";
12
12
  function detectSchemaPath() {
@@ -733,7 +733,7 @@ export default defineCommand({
733
733
  p.outro('');
734
734
  }
735
735
  catch (error) {
736
- fatal('Initialization failed', error instanceof Error ? error.message : String(error));
736
+ fatal('Initialization failed', formatError(error));
737
737
  }
738
738
  },
739
739
  });
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty';
2
2
  import * as fs from 'fs';
3
3
  import * as readline from 'readline';
4
4
  import { buildContext } from "../utils/context.js";
5
- import { fatal } from "../utils/ui.js";
5
+ import { fatal, formatError } from "../utils/ui.js";
6
6
  import { parseSqlToDefineTable } from "../../introspect/index.js";
7
7
  import { detectDialect, getBuilderImportPath } from "../utils/dialect-router.js";
8
8
  function readStdin() {
@@ -103,7 +103,7 @@ export default defineCommand({
103
103
  console.log(output.join('\n'));
104
104
  }
105
105
  catch (error) {
106
- fatal('Error parsing SQL', error instanceof Error ? error.message : String(error));
106
+ fatal('Error parsing SQL', formatError(error));
107
107
  }
108
108
  },
109
109
  });
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as p from '@clack/prompts';
5
5
  import { buildContext } from "../utils/context.js";
6
6
  import { colors } from "../utils/colors.js";
7
- import { fatal, warning } from "../utils/ui.js";
7
+ import { fatal, warning, formatError } from "../utils/ui.js";
8
8
  import { formatDuration } from "../utils/format.js";
9
9
  import { requireValidConfig } from "../utils/config-loader.js";
10
10
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -154,7 +154,7 @@ export default defineCommand({
154
154
  }
155
155
  catch (error) {
156
156
  spin.error('Migration failed');
157
- fatal(error instanceof Error ? error.message : String(error));
157
+ fatal(formatError(error));
158
158
  }
159
159
  },
160
160
  });
@@ -3,7 +3,7 @@ import * as path from 'path';
3
3
  import * as p from '@clack/prompts';
4
4
  import { buildContext } from "../utils/context.js";
5
5
  import { colors } from "../utils/colors.js";
6
- import { fatal, warning } from "../utils/ui.js";
6
+ import { fatal, warning, formatError } from "../utils/ui.js";
7
7
  import { formatDuration } from "../utils/format.js";
8
8
  import { requireValidConfig, getSchemaPath } from "../utils/config-loader.js";
9
9
  import { dialectIntrospect } from "../utils/dialect-introspect.js";
@@ -316,7 +316,7 @@ export async function runPush(config, projectRoot, opts = {}) {
316
316
  }
317
317
  catch (err) {
318
318
  spin.error('Push failed');
319
- fatal(err instanceof Error ? err.message : String(err));
319
+ fatal(formatError(err));
320
320
  }
321
321
  }
322
322
  export default defineCommand({
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as p from '@clack/prompts';
5
5
  import { buildContext } from "../utils/context.js";
6
6
  import { colors } from "../utils/colors.js";
7
- import { fatal, warning } from "../utils/ui.js";
7
+ import { fatal, warning, formatError } from "../utils/ui.js";
8
8
  import { formatDuration } from "../utils/format.js";
9
9
  import { requireValidConfig } from "../utils/config-loader.js";
10
10
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -178,7 +178,7 @@ export default defineCommand({
178
178
  }
179
179
  catch (err) {
180
180
  spin.error('Rollback failed');
181
- fatal(err instanceof Error ? err.message : String(err));
181
+ fatal(formatError(err));
182
182
  }
183
183
  },
184
184
  });
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  import * as p from '@clack/prompts';
5
5
  import { buildContext } from "../utils/context.js";
6
6
  import { colors } from "../utils/colors.js";
7
- import { fatal, warning } from "../utils/ui.js";
7
+ import { fatal, warning, formatError } from "../utils/ui.js";
8
8
  import { formatDuration, formatSize } from "../utils/format.js";
9
9
  import { requireValidConfig } from "../utils/config-loader.js";
10
10
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -170,7 +170,7 @@ export default defineCommand({
170
170
  }
171
171
  catch (err) {
172
172
  spin.error('Seed failed');
173
- fatal(err instanceof Error ? err.message : String(err));
173
+ fatal(formatError(err));
174
174
  }
175
175
  },
176
176
  });
@@ -1,7 +1,7 @@
1
1
  import { defineCommand } from 'citty';
2
2
  import { buildContext } from "../utils/context.js";
3
3
  import { colors } from "../utils/colors.js";
4
- import { fatal } from "../utils/ui.js";
4
+ import { fatal, formatError } from "../utils/ui.js";
5
5
  import { formatDuration } from "../utils/format.js";
6
6
  import { requireValidConfig } from "../utils/config-loader.js";
7
7
  import { getConnectionDescription } from "../utils/env-loader.js";
@@ -50,7 +50,7 @@ export default defineCommand({
50
50
  console.log('');
51
51
  }
52
52
  catch (err) {
53
- fatal(err instanceof Error ? err.message : String(err));
53
+ fatal(formatError(err));
54
54
  }
55
55
  },
56
56
  });
@@ -27,5 +27,13 @@ const main = defineCommand({
27
27
  export { main };
28
28
  const fromDev = process.argv.some(arg => arg.endsWith('index.ts'));
29
29
  if (fromDev) {
30
- runMain(main).catch(console.error);
30
+ runMain(main).catch(err => {
31
+ import("./utils/ui.js").then(({ formatError, p }) => {
32
+ p.log.error(formatError(err));
33
+ process.exit(1);
34
+ }).catch(() => {
35
+ console.error('Error:', err instanceof Error ? err.message : String(err));
36
+ process.exit(1);
37
+ });
38
+ });
31
39
  }
@@ -18,26 +18,78 @@ export function info(msg) {
18
18
  p.log.info(msg);
19
19
  }
20
20
  export function formatError(err) {
21
+ if (err instanceof AggregateError) {
22
+ const errors = err.errors || [];
23
+ if (errors.length === 0) {
24
+ return err.message || 'Multiple errors occurred';
25
+ }
26
+ if (errors.length === 1) {
27
+ return formatError(errors[0]);
28
+ }
29
+ const formatted = errors.map((e, i) => ` ${i + 1}. ${formatError(e)}`).join('\n');
30
+ return `Multiple errors occurred:\n${formatted}`;
31
+ }
21
32
  if (err instanceof Error) {
22
- if (err.message?.includes('ECONNREFUSED')) {
33
+ const msg = err.message || '';
34
+ if (msg.includes('ECONNREFUSED')) {
23
35
  return 'Connection refused - is the database running?';
24
36
  }
25
- if (err.message?.includes('ENOTFOUND')) {
37
+ if (msg.includes('ENOTFOUND')) {
26
38
  return 'Host not found - check your connection settings';
27
39
  }
28
- if (err.message?.includes('authentication failed')) {
29
- return 'Authentication failed - check your credentials';
40
+ if (msg.includes('ECONNRESET')) {
41
+ return 'Connection reset - the database closed the connection';
42
+ }
43
+ if (msg.includes('ETIMEDOUT')) {
44
+ return 'Connection timed out - check network connectivity';
45
+ }
46
+ if (msg.includes('authentication failed') || msg.includes('password authentication')) {
47
+ return 'Authentication failed - check your username and password';
48
+ }
49
+ if (msg.includes('no pg_hba.conf entry')) {
50
+ return 'Access denied - your IP is not allowed to connect to this database';
51
+ }
52
+ if (msg.includes('database') && msg.includes('does not exist')) {
53
+ const match = msg.match(/database "([^"]+)" does not exist/);
54
+ return match
55
+ ? `Database "${match[1]}" does not exist - create it first or check the name`
56
+ : 'Database does not exist - check your connection settings';
30
57
  }
31
- if (err.message?.includes('timeout')) {
32
- return 'Connection timeout - check network connectivity';
58
+ if (msg.includes('relation') && msg.includes('does not exist')) {
59
+ const match = msg.match(/relation "([^"]+)" does not exist/);
60
+ return match
61
+ ? `Table "${match[1]}" does not exist`
62
+ : 'Table does not exist';
33
63
  }
34
- if (err.message?.includes('token') || err.message?.includes('IAM')) {
35
- return `AWS authentication error: ${err.message}`;
64
+ if (msg.includes('SSL') || msg.includes('certificate')) {
65
+ return `SSL/TLS error: ${msg}`;
36
66
  }
37
- return err.message || err.name || 'Unknown error';
67
+ if (msg.includes('token') || msg.includes('IAM') || msg.includes('credentials')) {
68
+ return `AWS authentication error: ${msg}`;
69
+ }
70
+ if (msg.includes('timeout') || msg.includes('Timeout')) {
71
+ return 'Operation timed out - try again or check your connection';
72
+ }
73
+ if (msg.includes('Cannot find module') || msg.includes('Module not found')) {
74
+ const match = msg.match(/Cannot find module '([^']+)'/);
75
+ return match
76
+ ? `Missing dependency: ${match[1]} - try running "npm install" or "bun install"`
77
+ : 'Missing dependency - try running "npm install" or "bun install"';
78
+ }
79
+ if (msg.includes('permission denied') || msg.includes('EACCES')) {
80
+ return 'Permission denied - check file/folder permissions';
81
+ }
82
+ if (msg.includes('relq.config') || msg.includes('config file')) {
83
+ return `Configuration error: ${msg}`;
84
+ }
85
+ return msg || err.name || 'Unknown error';
38
86
  }
39
- if (typeof err === 'string')
87
+ if (typeof err === 'string') {
40
88
  return err || 'Unknown error';
89
+ }
90
+ if (err && typeof err === 'object' && 'message' in err) {
91
+ return String(err.message) || 'Unknown error';
92
+ }
41
93
  return String(err) || 'Unknown error';
42
94
  }
43
95
  export function requireInit(isInitialized) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relq",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "The Fully-Typed PostgreSQL ORM for TypeScript",
5
5
  "author": "Olajide Mathew O. <olajide.mathew@yuniq.solutions>",
6
6
  "license": "MIT",