relq 1.0.32 → 1.0.34
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.
|
@@ -113,7 +113,7 @@ function parseSchemaFileForComparison(schemaPath) {
|
|
|
113
113
|
continue;
|
|
114
114
|
const tsName = colMatch[1];
|
|
115
115
|
const type = colMatch[2];
|
|
116
|
-
const explicitNameMatch = colDef.match(new RegExp(`${type}
|
|
116
|
+
const explicitNameMatch = colDef.match(new RegExp(`${type}(?:<[^>]+>)?\\s*\\(['\"]([^'"]+)['\"]`));
|
|
117
117
|
const dbColName = explicitNameMatch ? explicitNameMatch[1] : tsName;
|
|
118
118
|
tsToDbNameMap.set(tsName, dbColName);
|
|
119
119
|
let defaultValue = null;
|
|
@@ -546,7 +546,26 @@ async function pullCommand(context) {
|
|
|
546
546
|
(0, cli_utils_1.fatal)('Automatic merge failed; fix conflicts and then commit', `${cli_utils_1.colors.cyan('relq resolve --theirs <name>')} Take remote version\n${cli_utils_1.colors.cyan('relq resolve --all-theirs')} Take all remote\n${cli_utils_1.colors.cyan('relq pull --force')} Force overwrite local`);
|
|
547
547
|
}
|
|
548
548
|
if (allChanges.length === 0) {
|
|
549
|
-
|
|
549
|
+
const localCommits = (0, repo_manager_1.getAllCommits)(projectRoot);
|
|
550
|
+
const localHashes = new Set(localCommits.map(c => c.hash));
|
|
551
|
+
const missingCommits = remoteCommits.filter(c => !localHashes.has(c.hash));
|
|
552
|
+
let hasSynced = false;
|
|
553
|
+
if (missingCommits.length > 0) {
|
|
554
|
+
for (const commit of missingCommits.reverse()) {
|
|
555
|
+
(0, repo_manager_1.saveCommit)(commit, projectRoot);
|
|
556
|
+
}
|
|
557
|
+
console.log(`Synced ${missingCommits.length} commit(s) from remote`);
|
|
558
|
+
hasSynced = true;
|
|
559
|
+
}
|
|
560
|
+
const typesFilePath = (0, types_manager_1.getTypesFilePath)(schemaPath);
|
|
561
|
+
const typesResult = await (0, types_manager_1.syncTypesFromDb)(connection, typesFilePath);
|
|
562
|
+
if (typesResult.generated && typesResult.typesCount > 0) {
|
|
563
|
+
console.log(`Synced ${typesResult.typesCount} type(s) from remote`);
|
|
564
|
+
hasSynced = true;
|
|
565
|
+
}
|
|
566
|
+
if (!hasSynced) {
|
|
567
|
+
console.log('Already up to date with remote');
|
|
568
|
+
}
|
|
550
569
|
console.log('');
|
|
551
570
|
return;
|
|
552
571
|
}
|
|
@@ -148,8 +148,32 @@ async function pushCommand(context) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
+
const schemaPath = (0, config_loader_2.getSchemaPath)(config);
|
|
152
|
+
const typesFilePath = (0, types_manager_1.getTypesFilePath)(schemaPath);
|
|
153
|
+
let typesSynced = false;
|
|
154
|
+
if (fs.existsSync(typesFilePath) && !dryRun) {
|
|
155
|
+
spinner.start('Syncing TypeScript types...');
|
|
156
|
+
const typesResult = await (0, types_manager_1.syncTypesToDb)(connection, typesFilePath, schemaPath);
|
|
157
|
+
const totalChanges = typesResult.added.length + typesResult.updated.length + typesResult.removed.length;
|
|
158
|
+
if (totalChanges > 0) {
|
|
159
|
+
const parts = [];
|
|
160
|
+
if (typesResult.added.length > 0)
|
|
161
|
+
parts.push(`${typesResult.added.length} added`);
|
|
162
|
+
if (typesResult.updated.length > 0)
|
|
163
|
+
parts.push(`${typesResult.updated.length} updated`);
|
|
164
|
+
if (typesResult.removed.length > 0)
|
|
165
|
+
parts.push(`${typesResult.removed.length} removed`);
|
|
166
|
+
spinner.succeed(`Synced types: ${parts.join(', ')}`);
|
|
167
|
+
typesSynced = true;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
spinner.succeed('Types in sync');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
151
173
|
if (toPush.length === 0 && !hasObjectsToDrop) {
|
|
152
|
-
|
|
174
|
+
if (!typesSynced) {
|
|
175
|
+
console.log('Everything up-to-date');
|
|
176
|
+
}
|
|
153
177
|
console.log('');
|
|
154
178
|
return;
|
|
155
179
|
}
|
|
@@ -286,26 +310,6 @@ async function pushCommand(context) {
|
|
|
286
310
|
spinner.warn('Could not update snapshot after RENAME - run "relq pull" manually');
|
|
287
311
|
}
|
|
288
312
|
}
|
|
289
|
-
const schemaPath = (0, config_loader_2.getSchemaPath)(config);
|
|
290
|
-
const typesFilePath = (0, types_manager_1.getTypesFilePath)(schemaPath);
|
|
291
|
-
if (fs.existsSync(typesFilePath)) {
|
|
292
|
-
spinner.start('Syncing TypeScript types...');
|
|
293
|
-
const typesResult = await (0, types_manager_1.syncTypesToDb)(connection, typesFilePath, schemaPath);
|
|
294
|
-
const totalChanges = typesResult.added.length + typesResult.updated.length + typesResult.removed.length;
|
|
295
|
-
if (totalChanges > 0) {
|
|
296
|
-
const parts = [];
|
|
297
|
-
if (typesResult.added.length > 0)
|
|
298
|
-
parts.push(`${typesResult.added.length} added`);
|
|
299
|
-
if (typesResult.updated.length > 0)
|
|
300
|
-
parts.push(`${typesResult.updated.length} updated`);
|
|
301
|
-
if (typesResult.removed.length > 0)
|
|
302
|
-
parts.push(`${typesResult.removed.length} removed`);
|
|
303
|
-
spinner.succeed(`Synced types: ${parts.join(', ')}`);
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
spinner.succeed('Types in sync');
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
313
|
}
|
|
310
314
|
catch (error) {
|
|
311
315
|
try {
|
|
@@ -73,7 +73,7 @@ function parseSchemaFileForComparison(schemaPath) {
|
|
|
73
73
|
continue;
|
|
74
74
|
const tsName = colMatch[1];
|
|
75
75
|
const type = colMatch[2];
|
|
76
|
-
const explicitNameMatch = colDef.match(new RegExp(`${type}
|
|
76
|
+
const explicitNameMatch = colDef.match(new RegExp(`${type}(?:<[^>]+>)?\\s*\\(['\"]([^'"]+)['\"]`));
|
|
77
77
|
const dbColName = explicitNameMatch ? explicitNameMatch[1] : tsName;
|
|
78
78
|
tsToDbNameMap.set(tsName, dbColName);
|
|
79
79
|
let defaultValue = null;
|
|
@@ -8,7 +8,7 @@ import { syncTypesFromDb, getTypesFilePath } from "../utils/types-manager.js";
|
|
|
8
8
|
import { getConnectionDescription } from "../utils/env-loader.js";
|
|
9
9
|
import { createSpinner, colors, formatBytes, formatDuration, fatal, confirm, warning, createMultiProgress } from "../utils/cli-utils.js";
|
|
10
10
|
import { loadRelqignore, isTableIgnored, isColumnIgnored, isIndexIgnored, isConstraintIgnored, isEnumIgnored, isDomainIgnored, isCompositeTypeIgnored, isFunctionIgnored, } from "../utils/relqignore.js";
|
|
11
|
-
import { isInitialized, initRepository, getHead, saveSnapshot, loadSnapshot, createCommit, shortHash, fetchRemoteCommits, ensureRemoteTable, setFetchHead, addUnstagedChanges, getStagedChanges, getUnstagedChanges, clearWorkingState, hashFileContent, saveFileHash, markCommitAsPulled, } from "../utils/repo-manager.js";
|
|
11
|
+
import { isInitialized, initRepository, getHead, saveCommit, saveSnapshot, loadSnapshot, createCommit, shortHash, fetchRemoteCommits, ensureRemoteTable, setFetchHead, addUnstagedChanges, getStagedChanges, getUnstagedChanges, clearWorkingState, hashFileContent, saveFileHash, markCommitAsPulled, getAllCommits, } from "../utils/repo-manager.js";
|
|
12
12
|
import { compareSchemas } from "../utils/schema-comparator.js";
|
|
13
13
|
function toCamelCase(str) {
|
|
14
14
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -510,7 +510,26 @@ export async function pullCommand(context) {
|
|
|
510
510
|
fatal('Automatic merge failed; fix conflicts and then commit', `${colors.cyan('relq resolve --theirs <name>')} Take remote version\n${colors.cyan('relq resolve --all-theirs')} Take all remote\n${colors.cyan('relq pull --force')} Force overwrite local`);
|
|
511
511
|
}
|
|
512
512
|
if (allChanges.length === 0) {
|
|
513
|
-
|
|
513
|
+
const localCommits = getAllCommits(projectRoot);
|
|
514
|
+
const localHashes = new Set(localCommits.map(c => c.hash));
|
|
515
|
+
const missingCommits = remoteCommits.filter(c => !localHashes.has(c.hash));
|
|
516
|
+
let hasSynced = false;
|
|
517
|
+
if (missingCommits.length > 0) {
|
|
518
|
+
for (const commit of missingCommits.reverse()) {
|
|
519
|
+
saveCommit(commit, projectRoot);
|
|
520
|
+
}
|
|
521
|
+
console.log(`Synced ${missingCommits.length} commit(s) from remote`);
|
|
522
|
+
hasSynced = true;
|
|
523
|
+
}
|
|
524
|
+
const typesFilePath = getTypesFilePath(schemaPath);
|
|
525
|
+
const typesResult = await syncTypesFromDb(connection, typesFilePath);
|
|
526
|
+
if (typesResult.generated && typesResult.typesCount > 0) {
|
|
527
|
+
console.log(`Synced ${typesResult.typesCount} type(s) from remote`);
|
|
528
|
+
hasSynced = true;
|
|
529
|
+
}
|
|
530
|
+
if (!hasSynced) {
|
|
531
|
+
console.log('Already up to date with remote');
|
|
532
|
+
}
|
|
514
533
|
console.log('');
|
|
515
534
|
return;
|
|
516
535
|
}
|
|
@@ -112,8 +112,32 @@ export async function pushCommand(context) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
const schemaPath = getSchemaPath(config);
|
|
116
|
+
const typesFilePath = getTypesFilePath(schemaPath);
|
|
117
|
+
let typesSynced = false;
|
|
118
|
+
if (fs.existsSync(typesFilePath) && !dryRun) {
|
|
119
|
+
spinner.start('Syncing TypeScript types...');
|
|
120
|
+
const typesResult = await syncTypesToDb(connection, typesFilePath, schemaPath);
|
|
121
|
+
const totalChanges = typesResult.added.length + typesResult.updated.length + typesResult.removed.length;
|
|
122
|
+
if (totalChanges > 0) {
|
|
123
|
+
const parts = [];
|
|
124
|
+
if (typesResult.added.length > 0)
|
|
125
|
+
parts.push(`${typesResult.added.length} added`);
|
|
126
|
+
if (typesResult.updated.length > 0)
|
|
127
|
+
parts.push(`${typesResult.updated.length} updated`);
|
|
128
|
+
if (typesResult.removed.length > 0)
|
|
129
|
+
parts.push(`${typesResult.removed.length} removed`);
|
|
130
|
+
spinner.succeed(`Synced types: ${parts.join(', ')}`);
|
|
131
|
+
typesSynced = true;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
spinner.succeed('Types in sync');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
115
137
|
if (toPush.length === 0 && !hasObjectsToDrop) {
|
|
116
|
-
|
|
138
|
+
if (!typesSynced) {
|
|
139
|
+
console.log('Everything up-to-date');
|
|
140
|
+
}
|
|
117
141
|
console.log('');
|
|
118
142
|
return;
|
|
119
143
|
}
|
|
@@ -250,26 +274,6 @@ export async function pushCommand(context) {
|
|
|
250
274
|
spinner.warn('Could not update snapshot after RENAME - run "relq pull" manually');
|
|
251
275
|
}
|
|
252
276
|
}
|
|
253
|
-
const schemaPath = getSchemaPath(config);
|
|
254
|
-
const typesFilePath = getTypesFilePath(schemaPath);
|
|
255
|
-
if (fs.existsSync(typesFilePath)) {
|
|
256
|
-
spinner.start('Syncing TypeScript types...');
|
|
257
|
-
const typesResult = await syncTypesToDb(connection, typesFilePath, schemaPath);
|
|
258
|
-
const totalChanges = typesResult.added.length + typesResult.updated.length + typesResult.removed.length;
|
|
259
|
-
if (totalChanges > 0) {
|
|
260
|
-
const parts = [];
|
|
261
|
-
if (typesResult.added.length > 0)
|
|
262
|
-
parts.push(`${typesResult.added.length} added`);
|
|
263
|
-
if (typesResult.updated.length > 0)
|
|
264
|
-
parts.push(`${typesResult.updated.length} updated`);
|
|
265
|
-
if (typesResult.removed.length > 0)
|
|
266
|
-
parts.push(`${typesResult.removed.length} removed`);
|
|
267
|
-
spinner.succeed(`Synced types: ${parts.join(', ')}`);
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
spinner.succeed('Types in sync');
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
277
|
}
|
|
274
278
|
catch (error) {
|
|
275
279
|
try {
|