relq 1.0.0 → 1.0.2
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/dist/cjs/addon/buffer/index.cjs +1881 -0
- package/dist/cjs/addon/pg/index.cjs +4812 -0
- package/dist/cjs/addon/pg-cursor/index.cjs +1451 -0
- package/dist/cjs/addon/pg-format/index.cjs +2270 -0
- package/dist/cjs/cli/commands/add.cjs +30 -1
- package/dist/cjs/cli/commands/branch.cjs +141 -0
- package/dist/cjs/cli/commands/checkout.cjs +134 -0
- package/dist/cjs/cli/commands/cherry-pick.cjs +283 -0
- package/dist/cjs/cli/commands/diff.cjs +148 -69
- package/dist/cjs/cli/commands/export.cjs +64 -5
- package/dist/cjs/cli/commands/fetch.cjs +34 -4
- package/dist/cjs/cli/commands/history.cjs +1 -1
- package/dist/cjs/cli/commands/import.cjs +283 -12
- package/dist/cjs/cli/commands/log.cjs +75 -0
- package/dist/cjs/cli/commands/merge.cjs +224 -0
- package/dist/cjs/cli/commands/migrate.cjs +1 -1
- package/dist/cjs/cli/commands/pull.cjs +123 -7
- package/dist/cjs/cli/commands/push.cjs +245 -29
- package/dist/cjs/cli/commands/remote.cjs +16 -0
- package/dist/cjs/cli/commands/reset.cjs +169 -0
- package/dist/cjs/cli/commands/resolve.cjs +193 -0
- package/dist/cjs/cli/commands/rollback.cjs +1 -1
- package/dist/cjs/cli/commands/stash.cjs +154 -0
- package/dist/cjs/cli/commands/status.cjs +48 -0
- package/dist/cjs/cli/commands/tag.cjs +147 -0
- package/dist/cjs/cli/index.cjs +46 -2
- package/dist/cjs/cli/utils/commit-manager.cjs +3 -3
- package/dist/cjs/cli/utils/env-loader.cjs +3 -2
- package/dist/cjs/cli/utils/fast-introspect.cjs +1 -1
- package/dist/cjs/cli/utils/project-root.cjs +56 -0
- package/dist/cjs/cli/utils/relqignore.cjs +296 -38
- package/dist/cjs/cli/utils/repo-manager.cjs +45 -3
- package/dist/cjs/cli/utils/schema-introspect.cjs +2 -2
- package/dist/cjs/cli/utils/sql-generator.cjs +1 -1
- package/dist/cjs/cli/utils/sql-parser.cjs +102 -13
- package/dist/cjs/condition/array-condition-builder.cjs +1 -1
- package/dist/cjs/condition/condition-collector.cjs +1 -1
- package/dist/cjs/condition/fulltext-condition-builder.cjs +1 -1
- package/dist/cjs/condition/geometric-condition-builder.cjs +1 -1
- package/dist/cjs/condition/jsonb-condition-builder.cjs +1 -1
- package/dist/cjs/condition/network-condition-builder.cjs +1 -1
- package/dist/cjs/condition/range-condition-builder.cjs +1 -1
- package/dist/cjs/copy/copy-builder.cjs +1 -1
- package/dist/cjs/core/query-builder.cjs +1 -1
- package/dist/cjs/core/relq-client.cjs +2 -2
- package/dist/cjs/count/count-builder.cjs +1 -1
- package/dist/cjs/cte/cte-builder.cjs +1 -1
- package/dist/cjs/delete/delete-builder.cjs +1 -1
- package/dist/cjs/function/create-function-builder.cjs +1 -1
- package/dist/cjs/functions/advanced-functions.cjs +1 -1
- package/dist/cjs/functions/case-builder.cjs +1 -1
- package/dist/cjs/functions/geometric-functions.cjs +1 -1
- package/dist/cjs/functions/network-functions.cjs +1 -1
- package/dist/cjs/functions/sql-functions.cjs +1 -1
- package/dist/cjs/indexing/create-index-builder.cjs +1 -1
- package/dist/cjs/indexing/drop-index-builder.cjs +1 -1
- package/dist/cjs/insert/conflict-builder.cjs +1 -1
- package/dist/cjs/insert/insert-builder.cjs +1 -1
- package/dist/cjs/maintenance/vacuum-builder.cjs +1 -1
- package/dist/cjs/pubsub/listen-notify-builder.cjs +1 -1
- package/dist/cjs/pubsub/listener-connection.cjs +2 -2
- package/dist/cjs/raw/raw-query-builder.cjs +1 -1
- package/dist/cjs/schema/schema-builder.cjs +1 -1
- package/dist/cjs/schema-definition/table-definition.cjs +1 -1
- package/dist/cjs/select/aggregate-builder.cjs +1 -1
- package/dist/cjs/select/select-builder.cjs +1 -1
- package/dist/cjs/sequence/sequence-builder.cjs +1 -1
- package/dist/cjs/table/alter-table-builder.cjs +1 -1
- package/dist/cjs/table/constraint-builder.cjs +1 -1
- package/dist/cjs/table/create-table-builder.cjs +1 -1
- package/dist/cjs/table/partition-builder.cjs +1 -1
- package/dist/cjs/table/truncate-builder.cjs +1 -1
- package/dist/cjs/transaction/transaction-builder.cjs +1 -1
- package/dist/cjs/trigger/create-trigger-builder.cjs +1 -1
- package/dist/cjs/update/array-update-builder.cjs +1 -1
- package/dist/cjs/update/update-builder.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/view/create-view-builder.cjs +1 -1
- package/dist/cjs/window/window-builder.cjs +1 -1
- package/dist/esm/cli/commands/add.js +30 -1
- package/dist/esm/cli/commands/branch.js +105 -0
- package/dist/esm/cli/commands/checkout.js +98 -0
- package/dist/esm/cli/commands/cherry-pick.js +247 -0
- package/dist/esm/cli/commands/diff.js +148 -69
- package/dist/esm/cli/commands/export.js +64 -5
- package/dist/esm/cli/commands/fetch.js +35 -5
- package/dist/esm/cli/commands/history.js +1 -1
- package/dist/esm/cli/commands/import.js +283 -12
- package/dist/esm/cli/commands/log.js +74 -0
- package/dist/esm/cli/commands/merge.js +188 -0
- package/dist/esm/cli/commands/migrate.js +1 -1
- package/dist/esm/cli/commands/pull.js +124 -8
- package/dist/esm/cli/commands/push.js +246 -30
- package/dist/esm/cli/commands/remote.js +13 -0
- package/dist/esm/cli/commands/reset.js +133 -0
- package/dist/esm/cli/commands/resolve.js +157 -0
- package/dist/esm/cli/commands/rollback.js +1 -1
- package/dist/esm/cli/commands/stash.js +118 -0
- package/dist/esm/cli/commands/status.js +15 -0
- package/dist/esm/cli/commands/tag.js +111 -0
- package/dist/esm/cli/index.js +47 -3
- package/dist/esm/cli/utils/commit-manager.js +3 -3
- package/dist/esm/cli/utils/env-loader.js +3 -2
- package/dist/esm/cli/utils/fast-introspect.js +1 -1
- package/dist/esm/cli/utils/project-root.js +19 -0
- package/dist/esm/cli/utils/relqignore.js +277 -37
- package/dist/esm/cli/utils/repo-manager.js +41 -3
- package/dist/esm/cli/utils/schema-introspect.js +2 -2
- package/dist/esm/cli/utils/sql-generator.js +1 -1
- package/dist/esm/cli/utils/sql-parser.js +102 -13
- package/dist/esm/condition/array-condition-builder.js +1 -1
- package/dist/esm/condition/condition-collector.js +1 -1
- package/dist/esm/condition/fulltext-condition-builder.js +1 -1
- package/dist/esm/condition/geometric-condition-builder.js +1 -1
- package/dist/esm/condition/jsonb-condition-builder.js +1 -1
- package/dist/esm/condition/network-condition-builder.js +1 -1
- package/dist/esm/condition/range-condition-builder.js +1 -1
- package/dist/esm/copy/copy-builder.js +1 -1
- package/dist/esm/core/query-builder.js +1 -1
- package/dist/esm/core/relq-client.js +2 -2
- package/dist/esm/count/count-builder.js +1 -1
- package/dist/esm/cte/cte-builder.js +1 -1
- package/dist/esm/delete/delete-builder.js +1 -1
- package/dist/esm/function/create-function-builder.js +1 -1
- package/dist/esm/functions/advanced-functions.js +1 -1
- package/dist/esm/functions/case-builder.js +1 -1
- package/dist/esm/functions/geometric-functions.js +1 -1
- package/dist/esm/functions/network-functions.js +1 -1
- package/dist/esm/functions/sql-functions.js +1 -1
- package/dist/esm/indexing/create-index-builder.js +1 -1
- package/dist/esm/indexing/drop-index-builder.js +1 -1
- package/dist/esm/insert/conflict-builder.js +1 -1
- package/dist/esm/insert/insert-builder.js +1 -1
- package/dist/esm/maintenance/vacuum-builder.js +1 -1
- package/dist/esm/pubsub/listen-notify-builder.js +1 -1
- package/dist/esm/pubsub/listener-connection.js +2 -2
- package/dist/esm/raw/raw-query-builder.js +1 -1
- package/dist/esm/schema/schema-builder.js +1 -1
- package/dist/esm/schema-definition/table-definition.js +1 -1
- package/dist/esm/select/aggregate-builder.js +1 -1
- package/dist/esm/select/select-builder.js +1 -1
- package/dist/esm/sequence/sequence-builder.js +1 -1
- package/dist/esm/table/alter-table-builder.js +1 -1
- package/dist/esm/table/constraint-builder.js +1 -1
- package/dist/esm/table/create-table-builder.js +1 -1
- package/dist/esm/table/partition-builder.js +1 -1
- package/dist/esm/table/truncate-builder.js +1 -1
- package/dist/esm/transaction/transaction-builder.js +1 -1
- package/dist/esm/trigger/create-trigger-builder.js +1 -1
- package/dist/esm/update/array-update-builder.js +1 -1
- package/dist/esm/update/update-builder.js +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/view/create-view-builder.js +1 -1
- package/dist/esm/window/window-builder.js +1 -1
- package/package.json +1 -1
- /package/dist/{addons/buffer.js → esm/addon/buffer/index.js} +0 -0
- /package/dist/{addons/pg.js → esm/addon/pg/index.js} +0 -0
- /package/dist/{addons/pg-cursor.js → esm/addon/pg-cursor/index.js} +0 -0
- /package/dist/{addons/pg-format.js → esm/addon/pg-format/index.js} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { colors } from "../utils/spinner.js";
|
|
4
|
+
import { isInitialized, getStagedChanges, getUnstagedChanges, } from "../utils/repo-manager.js";
|
|
5
|
+
export async function stashCommand(context) {
|
|
6
|
+
const { args, flags } = context;
|
|
7
|
+
const projectRoot = process.cwd();
|
|
8
|
+
const subcommand = args[0] || 'push';
|
|
9
|
+
console.log('');
|
|
10
|
+
if (!isInitialized(projectRoot)) {
|
|
11
|
+
console.log(`${colors.red('fatal:')} not a relq repository`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const stashDir = path.join(projectRoot, '.relq', 'stash');
|
|
15
|
+
switch (subcommand) {
|
|
16
|
+
case 'push':
|
|
17
|
+
case 'save':
|
|
18
|
+
await stashPush(projectRoot, stashDir, flags['m'] || 'WIP');
|
|
19
|
+
break;
|
|
20
|
+
case 'pop':
|
|
21
|
+
await stashPop(projectRoot, stashDir);
|
|
22
|
+
break;
|
|
23
|
+
case 'list':
|
|
24
|
+
await stashList(stashDir);
|
|
25
|
+
break;
|
|
26
|
+
case 'drop':
|
|
27
|
+
await stashDrop(stashDir);
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
await stashPush(projectRoot, stashDir, subcommand);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function stashPush(projectRoot, stashDir, message) {
|
|
34
|
+
const staged = getStagedChanges(projectRoot);
|
|
35
|
+
const unstaged = getUnstagedChanges(projectRoot);
|
|
36
|
+
if (staged.length === 0 && unstaged.length === 0) {
|
|
37
|
+
console.log(`${colors.muted('No changes to stash.')}`);
|
|
38
|
+
console.log('');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!fs.existsSync(stashDir)) {
|
|
42
|
+
fs.mkdirSync(stashDir, { recursive: true });
|
|
43
|
+
}
|
|
44
|
+
const stashFiles = fs.readdirSync(stashDir).filter(f => f.endsWith('.json'));
|
|
45
|
+
const stashIdx = stashFiles.length;
|
|
46
|
+
const stash = {
|
|
47
|
+
message,
|
|
48
|
+
timestamp: new Date().toISOString(),
|
|
49
|
+
staged,
|
|
50
|
+
unstaged,
|
|
51
|
+
};
|
|
52
|
+
fs.writeFileSync(path.join(stashDir, `stash-${stashIdx}.json`), JSON.stringify(stash, null, 2));
|
|
53
|
+
const stagedPath = path.join(projectRoot, '.relq', 'staged.json');
|
|
54
|
+
const unstagedPath = path.join(projectRoot, '.relq', 'unstaged.json');
|
|
55
|
+
if (fs.existsSync(stagedPath))
|
|
56
|
+
fs.writeFileSync(stagedPath, '[]');
|
|
57
|
+
if (fs.existsSync(unstagedPath))
|
|
58
|
+
fs.writeFileSync(unstagedPath, '[]');
|
|
59
|
+
console.log(`${colors.green('✓')} Saved working directory`);
|
|
60
|
+
console.log(` stash@{${stashIdx}}: ${message}`);
|
|
61
|
+
console.log('');
|
|
62
|
+
}
|
|
63
|
+
async function stashPop(projectRoot, stashDir) {
|
|
64
|
+
if (!fs.existsSync(stashDir)) {
|
|
65
|
+
console.log(`${colors.muted('No stashes found.')}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const stashFiles = fs.readdirSync(stashDir).filter(f => f.endsWith('.json')).sort().reverse();
|
|
69
|
+
if (stashFiles.length === 0) {
|
|
70
|
+
console.log(`${colors.muted('No stashes found.')}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const stashPath = path.join(stashDir, stashFiles[0]);
|
|
74
|
+
const stash = JSON.parse(fs.readFileSync(stashPath, 'utf-8'));
|
|
75
|
+
const stagedPath = path.join(projectRoot, '.relq', 'staged.json');
|
|
76
|
+
const unstagedPath = path.join(projectRoot, '.relq', 'unstaged.json');
|
|
77
|
+
if (stash.staged.length > 0) {
|
|
78
|
+
fs.writeFileSync(stagedPath, JSON.stringify(stash.staged, null, 2));
|
|
79
|
+
}
|
|
80
|
+
if (stash.unstaged.length > 0) {
|
|
81
|
+
fs.writeFileSync(unstagedPath, JSON.stringify(stash.unstaged, null, 2));
|
|
82
|
+
}
|
|
83
|
+
fs.unlinkSync(stashPath);
|
|
84
|
+
console.log(`${colors.green('✓')} Applied stash and dropped`);
|
|
85
|
+
console.log(` ${stash.message}`);
|
|
86
|
+
console.log('');
|
|
87
|
+
}
|
|
88
|
+
async function stashList(stashDir) {
|
|
89
|
+
if (!fs.existsSync(stashDir)) {
|
|
90
|
+
console.log(`${colors.muted('No stashes.')}`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const stashFiles = fs.readdirSync(stashDir).filter(f => f.endsWith('.json')).sort();
|
|
94
|
+
if (stashFiles.length === 0) {
|
|
95
|
+
console.log(`${colors.muted('No stashes.')}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
for (let i = 0; i < stashFiles.length; i++) {
|
|
99
|
+
const stash = JSON.parse(fs.readFileSync(path.join(stashDir, stashFiles[i]), 'utf-8'));
|
|
100
|
+
console.log(`stash@{${i}}: ${stash.message} (${stash.staged.length + stash.unstaged.length} changes)`);
|
|
101
|
+
}
|
|
102
|
+
console.log('');
|
|
103
|
+
}
|
|
104
|
+
async function stashDrop(stashDir) {
|
|
105
|
+
if (!fs.existsSync(stashDir)) {
|
|
106
|
+
console.log(`${colors.muted('No stashes.')}`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const stashFiles = fs.readdirSync(stashDir).filter(f => f.endsWith('.json')).sort().reverse();
|
|
110
|
+
if (stashFiles.length === 0) {
|
|
111
|
+
console.log(`${colors.muted('No stashes.')}`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
fs.unlinkSync(path.join(stashDir, stashFiles[0]));
|
|
115
|
+
console.log(`${colors.green('✓')} Dropped stash`);
|
|
116
|
+
console.log('');
|
|
117
|
+
}
|
|
118
|
+
export default stashCommand;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
1
3
|
import { getConnectionDescription } from "../utils/env-loader.js";
|
|
2
4
|
import { colors } from "../utils/spinner.js";
|
|
5
|
+
import { loadRelqignore, } from "../utils/relqignore.js";
|
|
3
6
|
import { isInitialized, getHead, loadCommit, shortHash, getStagedChanges, getUnstagedChanges, } from "../utils/repo-manager.js";
|
|
4
7
|
export async function statusCommand(context) {
|
|
5
8
|
const { config, flags } = context;
|
|
@@ -45,6 +48,18 @@ export async function statusCommand(context) {
|
|
|
45
48
|
displayChanges(unstaged, ' ');
|
|
46
49
|
console.log('');
|
|
47
50
|
}
|
|
51
|
+
const ignorePatterns = loadRelqignore(projectRoot);
|
|
52
|
+
const relqignorePath = path.join(projectRoot, '.relqignore');
|
|
53
|
+
if (ignorePatterns.length > 0 && fs.existsSync(relqignorePath)) {
|
|
54
|
+
const userPatterns = ignorePatterns.filter(p => !p.raw.startsWith('_relq_') &&
|
|
55
|
+
!p.raw.startsWith('pg_') &&
|
|
56
|
+
!p.raw.startsWith('_temp_') &&
|
|
57
|
+
!p.raw.startsWith('tmp_'));
|
|
58
|
+
if (userPatterns.length > 0) {
|
|
59
|
+
console.log(`${colors.muted(`ℹ ${userPatterns.length} pattern(s) active from .relqignore`)}`);
|
|
60
|
+
console.log('');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
48
63
|
if (staged.length === 0 && unstaged.length === 0) {
|
|
49
64
|
console.log(`${colors.green('nothing to commit, working tree clean')}`);
|
|
50
65
|
console.log('');
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { colors } from "../utils/spinner.js";
|
|
4
|
+
import { isInitialized, getHead, loadCommit, shortHash } from "../utils/repo-manager.js";
|
|
5
|
+
function loadTags(projectRoot) {
|
|
6
|
+
const tagPath = path.join(projectRoot, '.relq', 'tags.json');
|
|
7
|
+
if (fs.existsSync(tagPath)) {
|
|
8
|
+
return JSON.parse(fs.readFileSync(tagPath, 'utf-8'));
|
|
9
|
+
}
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
function saveTags(tags, projectRoot) {
|
|
13
|
+
const tagPath = path.join(projectRoot, '.relq', 'tags.json');
|
|
14
|
+
fs.writeFileSync(tagPath, JSON.stringify(tags, null, 2));
|
|
15
|
+
}
|
|
16
|
+
export async function tagCommand(context) {
|
|
17
|
+
const { args, flags } = context;
|
|
18
|
+
const projectRoot = process.cwd();
|
|
19
|
+
console.log('');
|
|
20
|
+
if (!isInitialized(projectRoot)) {
|
|
21
|
+
console.log(`${colors.red('fatal:')} not a relq repository`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const tags = loadTags(projectRoot);
|
|
25
|
+
const deleteFlag = flags['d'] === true || flags['delete'] === true;
|
|
26
|
+
const force = flags['f'] === true || flags['force'] === true;
|
|
27
|
+
if (deleteFlag) {
|
|
28
|
+
const tagName = args[0];
|
|
29
|
+
if (!tagName) {
|
|
30
|
+
console.log(`${colors.red('error:')} Please specify tag name`);
|
|
31
|
+
console.log('');
|
|
32
|
+
console.log(`Usage: ${colors.cyan('relq tag -d <name>')}`);
|
|
33
|
+
console.log('');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!tags[tagName]) {
|
|
37
|
+
console.log(`${colors.red('error:')} Tag not found: ${tagName}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
delete tags[tagName];
|
|
41
|
+
saveTags(tags, projectRoot);
|
|
42
|
+
console.log(`${colors.green('✓')} Deleted tag '${tagName}'`);
|
|
43
|
+
console.log('');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (args[0]) {
|
|
47
|
+
const tagName = args[0];
|
|
48
|
+
const targetHash = args[1];
|
|
49
|
+
if (!/^[a-zA-Z0-9._-]+$/.test(tagName)) {
|
|
50
|
+
console.log(`${colors.red('error:')} Invalid tag name`);
|
|
51
|
+
console.log('Tag names can only contain: letters, numbers, dots, dashes, underscores');
|
|
52
|
+
console.log('');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (tags[tagName] && !force) {
|
|
56
|
+
console.log(`${colors.red('error:')} Tag already exists: ${tagName}`);
|
|
57
|
+
console.log('');
|
|
58
|
+
console.log(`Use ${colors.cyan(`relq tag -f ${tagName}`)} to overwrite`);
|
|
59
|
+
console.log('');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let hash;
|
|
63
|
+
if (targetHash) {
|
|
64
|
+
const commit = loadCommit(targetHash, projectRoot);
|
|
65
|
+
if (!commit) {
|
|
66
|
+
console.log(`${colors.red('error:')} Commit not found: ${targetHash}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
hash = commit.hash;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const head = getHead(projectRoot);
|
|
73
|
+
if (!head) {
|
|
74
|
+
console.log(`${colors.red('error:')} No commits yet`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
hash = head;
|
|
78
|
+
}
|
|
79
|
+
const commit = loadCommit(hash, projectRoot);
|
|
80
|
+
if (!commit) {
|
|
81
|
+
console.log(`${colors.red('error:')} Cannot load commit`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
tags[tagName] = {
|
|
85
|
+
hash,
|
|
86
|
+
message: commit.message,
|
|
87
|
+
createdAt: new Date().toISOString(),
|
|
88
|
+
};
|
|
89
|
+
saveTags(tags, projectRoot);
|
|
90
|
+
console.log(`${colors.green('✓')} Tagged ${colors.yellow(shortHash(hash))} as '${colors.cyan(tagName)}'`);
|
|
91
|
+
console.log(` ${commit.message}`);
|
|
92
|
+
console.log('');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const tagNames = Object.keys(tags).sort();
|
|
96
|
+
if (tagNames.length === 0) {
|
|
97
|
+
console.log(`${colors.muted('No tags.')}`);
|
|
98
|
+
console.log('');
|
|
99
|
+
console.log(`Create one with: ${colors.cyan('relq tag <name>')}`);
|
|
100
|
+
console.log('');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const name of tagNames) {
|
|
104
|
+
const tag = tags[name];
|
|
105
|
+
const hash = colors.yellow(shortHash(tag.hash));
|
|
106
|
+
const tagName = colors.cyan(name);
|
|
107
|
+
console.log(`${tagName.padEnd(20)} ${hash} ${tag.message}`);
|
|
108
|
+
}
|
|
109
|
+
console.log('');
|
|
110
|
+
}
|
|
111
|
+
export default tagCommand;
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -7,13 +7,21 @@ import { introspectCommand } from "./commands/introspect.js";
|
|
|
7
7
|
import { syncCommand } from "./commands/sync.js";
|
|
8
8
|
import { statusCommand } from "./commands/status.js";
|
|
9
9
|
import { diffCommand } from "./commands/diff.js";
|
|
10
|
-
import { logCommand } from "./commands/log.js";
|
|
10
|
+
import { logCommand, showCommand } from "./commands/log.js";
|
|
11
11
|
import { rollbackCommand } from "./commands/rollback.js";
|
|
12
12
|
import { commitCommand } from "./commands/commit.js";
|
|
13
13
|
import { fetchCommand } from "./commands/fetch.js";
|
|
14
14
|
import { addCommand } from "./commands/add.js";
|
|
15
15
|
import { importCommand } from "./commands/import.js";
|
|
16
16
|
import { exportCommand } from "./commands/export.js";
|
|
17
|
+
import { resolveCommand } from "./commands/resolve.js";
|
|
18
|
+
import { resetCommand } from "./commands/reset.js";
|
|
19
|
+
import { stashCommand } from "./commands/stash.js";
|
|
20
|
+
import { branchCommand } from "./commands/branch.js";
|
|
21
|
+
import { mergeCommand } from "./commands/merge.js";
|
|
22
|
+
import { tagCommand } from "./commands/tag.js";
|
|
23
|
+
import { cherryPickCommand } from "./commands/cherry-pick.js";
|
|
24
|
+
import { remoteCommand } from "./commands/remote.js";
|
|
17
25
|
const VERSION = '1.1.0';
|
|
18
26
|
function parseArgs(argv) {
|
|
19
27
|
const args = [];
|
|
@@ -144,8 +152,8 @@ async function main() {
|
|
|
144
152
|
if (requiresConfig(command)) {
|
|
145
153
|
const configPath = flags.config;
|
|
146
154
|
try {
|
|
147
|
-
const { loadConfigWithEnv,
|
|
148
|
-
const foundConfig = configPath
|
|
155
|
+
const { loadConfigWithEnv, findConfigFileRecursive } = await import("./utils/config-loader.js");
|
|
156
|
+
const foundConfig = configPath ? configPath : findConfigFileRecursive()?.path;
|
|
149
157
|
if (!foundConfig) {
|
|
150
158
|
console.error('Error: relq.config.ts not found.');
|
|
151
159
|
console.error('Run "relq init" to create one or use --config to specify a path.');
|
|
@@ -194,6 +202,9 @@ async function main() {
|
|
|
194
202
|
case 'log':
|
|
195
203
|
await logCommand(context);
|
|
196
204
|
break;
|
|
205
|
+
case 'show':
|
|
206
|
+
await showCommand(context);
|
|
207
|
+
break;
|
|
197
208
|
case 'fetch':
|
|
198
209
|
await fetchCommand(context);
|
|
199
210
|
break;
|
|
@@ -201,6 +212,39 @@ async function main() {
|
|
|
201
212
|
case 'revert':
|
|
202
213
|
await rollbackCommand(context);
|
|
203
214
|
break;
|
|
215
|
+
case 'resolve':
|
|
216
|
+
await resolveCommand(context);
|
|
217
|
+
break;
|
|
218
|
+
case 'reset':
|
|
219
|
+
await resetCommand(context);
|
|
220
|
+
break;
|
|
221
|
+
case 'stash':
|
|
222
|
+
await stashCommand(context);
|
|
223
|
+
break;
|
|
224
|
+
case 'branch':
|
|
225
|
+
await branchCommand(context);
|
|
226
|
+
break;
|
|
227
|
+
case 'checkout':
|
|
228
|
+
case 'switch':
|
|
229
|
+
console.log('');
|
|
230
|
+
console.log('⚠️ Branch switching is currently disabled.');
|
|
231
|
+
console.log('');
|
|
232
|
+
console.log('This feature will be available when Relq Postgres Native is officially launched.');
|
|
233
|
+
console.log('For now, work on a single branch and use merge to combine schemas.');
|
|
234
|
+
console.log('');
|
|
235
|
+
break;
|
|
236
|
+
case 'merge':
|
|
237
|
+
await mergeCommand(context);
|
|
238
|
+
break;
|
|
239
|
+
case 'tag':
|
|
240
|
+
await tagCommand(context);
|
|
241
|
+
break;
|
|
242
|
+
case 'cherry-pick':
|
|
243
|
+
await cherryPickCommand(context);
|
|
244
|
+
break;
|
|
245
|
+
case 'remote':
|
|
246
|
+
await remoteCommand(context);
|
|
247
|
+
break;
|
|
204
248
|
case 'introspect':
|
|
205
249
|
await introspectCommand(context);
|
|
206
250
|
break;
|
|
@@ -69,7 +69,7 @@ CREATE INDEX IF NOT EXISTS idx_relq_commits_created
|
|
|
69
69
|
ON _relq_commits(created_at DESC);
|
|
70
70
|
`;
|
|
71
71
|
export async function ensureCommitsTable(connection) {
|
|
72
|
-
const { Pool } = await import("../../addon/pg.js");
|
|
72
|
+
const { Pool } = await import("../../addon/pg/index.js");
|
|
73
73
|
const pool = new Pool({
|
|
74
74
|
host: connection.host,
|
|
75
75
|
port: connection.port || 5432,
|
|
@@ -87,7 +87,7 @@ export async function ensureCommitsTable(connection) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
export async function getRemoteCommits(connection, limit = 100) {
|
|
90
|
-
const { Pool } = await import("../../addon/pg.js");
|
|
90
|
+
const { Pool } = await import("../../addon/pg/index.js");
|
|
91
91
|
const pool = new Pool({
|
|
92
92
|
host: connection.host,
|
|
93
93
|
port: connection.port || 5432,
|
|
@@ -124,7 +124,7 @@ export async function getLatestRemoteCommit(connection) {
|
|
|
124
124
|
return commits.length > 0 ? commits[0] : null;
|
|
125
125
|
}
|
|
126
126
|
export async function addRemoteCommit(connection, commit, limit = 1000) {
|
|
127
|
-
const { Pool } = await import("../../addon/pg.js");
|
|
127
|
+
const { Pool } = await import("../../addon/pg/index.js");
|
|
128
128
|
const pool = new Pool({
|
|
129
129
|
host: connection.host,
|
|
130
130
|
port: connection.port || 5432,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function loadEnvConfig() {
|
|
2
|
-
const connectionString = process.env.DATABASE_CONNECTION_STRING;
|
|
2
|
+
const connectionString = process.env.RELQ_PG_CONN_URL || process.env.DATABASE_CONNECTION_STRING;
|
|
3
3
|
if (connectionString) {
|
|
4
4
|
return parseConnectionString(connectionString);
|
|
5
5
|
}
|
|
@@ -37,7 +37,8 @@ function parseConnectionString(url) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
export function hasEnvConfig() {
|
|
40
|
-
return !!(process.env.
|
|
40
|
+
return !!(process.env.RELQ_PG_CONN_URL ||
|
|
41
|
+
process.env.DATABASE_CONNECTION_STRING ||
|
|
41
42
|
process.env.DATABASE_HOST);
|
|
42
43
|
}
|
|
43
44
|
export function getConnectionDescription(config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export async function fastIntrospectDatabase(connection, onProgress, options) {
|
|
2
2
|
const { includeFunctions = false, includeTriggers = false } = options || {};
|
|
3
|
-
const { Pool } = await import("../../addon/pg.js");
|
|
3
|
+
const { Pool } = await import("../../addon/pg/index.js");
|
|
4
4
|
onProgress?.('connecting', connection.database);
|
|
5
5
|
const pool = new Pool({
|
|
6
6
|
host: connection.host,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export function findProjectRoot(startDir = process.cwd()) {
|
|
4
|
+
let currentDir = path.resolve(startDir);
|
|
5
|
+
const root = path.parse(currentDir).root;
|
|
6
|
+
while (currentDir !== root) {
|
|
7
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
8
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
9
|
+
return currentDir;
|
|
10
|
+
}
|
|
11
|
+
currentDir = path.dirname(currentDir);
|
|
12
|
+
}
|
|
13
|
+
return process.cwd();
|
|
14
|
+
}
|
|
15
|
+
export function getRelqDir(startDir = process.cwd()) {
|
|
16
|
+
const projectRoot = findProjectRoot(startDir) || process.cwd();
|
|
17
|
+
return path.join(projectRoot, '.relq');
|
|
18
|
+
}
|
|
19
|
+
export default { findProjectRoot, getRelqDir };
|