relq 1.0.6 → 1.0.7
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/cli/commands/add.cjs +5 -5
- package/dist/cjs/cli/commands/commit.cjs +1 -1
- package/dist/cjs/config/config.cjs +29 -10
- package/dist/config.d.ts +1 -1
- package/dist/esm/cli/commands/add.js +5 -5
- package/dist/esm/cli/commands/commit.js +1 -1
- package/dist/esm/config/config.js +29 -10
- package/package.json +1 -1
|
@@ -623,7 +623,7 @@ async function addCommand(context) {
|
|
|
623
623
|
}
|
|
624
624
|
const ignorePatterns = (0, relqignore_1.loadRelqignore)(projectRoot);
|
|
625
625
|
const config = await (0, config_1.loadConfig)();
|
|
626
|
-
const schemaPathRaw = typeof config
|
|
626
|
+
const schemaPathRaw = typeof config?.schema === 'string' ? config.schema : './db/schema.ts';
|
|
627
627
|
const schemaPath = path.resolve(projectRoot, schemaPathRaw);
|
|
628
628
|
const injectedCount = injectTrackingIds(schemaPath);
|
|
629
629
|
if (injectedCount > 0) {
|
|
@@ -654,16 +654,16 @@ async function addCommand(context) {
|
|
|
654
654
|
if (result.ignored) {
|
|
655
655
|
return false;
|
|
656
656
|
}
|
|
657
|
-
if (['FUNCTION', 'PROCEDURE'].includes(change.objectType) && !config
|
|
657
|
+
if (['FUNCTION', 'PROCEDURE'].includes(change.objectType) && !config?.includeFunctions) {
|
|
658
658
|
return false;
|
|
659
659
|
}
|
|
660
|
-
if (change.objectType === 'TRIGGER' && !config
|
|
660
|
+
if (change.objectType === 'TRIGGER' && !config?.includeTriggers) {
|
|
661
661
|
return false;
|
|
662
662
|
}
|
|
663
|
-
if (['VIEW', 'MATERIALIZED_VIEW'].includes(change.objectType) && !config
|
|
663
|
+
if (['VIEW', 'MATERIALIZED_VIEW'].includes(change.objectType) && !config?.includeViews) {
|
|
664
664
|
return false;
|
|
665
665
|
}
|
|
666
|
-
if (change.objectType === 'FOREIGN_TABLE' && !config
|
|
666
|
+
if (change.objectType === 'FOREIGN_TABLE' && !config?.includeFDW) {
|
|
667
667
|
return false;
|
|
668
668
|
}
|
|
669
669
|
return true;
|
|
@@ -122,7 +122,7 @@ async function commitCommand(context) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
const commitConfig = await (0, config_1.loadConfig)();
|
|
125
|
-
const schemaPathRaw = typeof commitConfig
|
|
125
|
+
const schemaPathRaw = typeof commitConfig?.schema === 'string' ? commitConfig.schema : './db/schema.ts';
|
|
126
126
|
const schemaFilePath = path.resolve(projectRoot, schemaPathRaw);
|
|
127
127
|
if (fs.existsSync(schemaFilePath)) {
|
|
128
128
|
const currentContent = fs.readFileSync(schemaFilePath, 'utf-8');
|
|
@@ -75,21 +75,40 @@ function defineConfig(config) {
|
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function loadConfig(
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
return
|
|
78
|
+
async function loadConfig(startPath) {
|
|
79
|
+
const result = findConfigFile(startPath);
|
|
80
|
+
if (!result) {
|
|
81
|
+
return {};
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
try {
|
|
84
|
+
const module = await Promise.resolve(`${result.configPath}`).then(s => __importStar(require(s)));
|
|
84
85
|
if (module.default) {
|
|
85
86
|
return module.default;
|
|
86
87
|
}
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
|
-
function findConfigFile() {
|
|
94
|
+
function findConfigFile(startPath) {
|
|
95
|
+
const { existsSync } = require('fs');
|
|
96
|
+
const { join, dirname, parse } = require('path');
|
|
97
|
+
let currentDir = startPath || process.cwd();
|
|
98
|
+
const { root } = parse(currentDir);
|
|
99
|
+
while (currentDir !== root) {
|
|
100
|
+
const configPath = join(currentDir, 'relq.config.ts');
|
|
101
|
+
const packagePath = join(currentDir, 'package.json');
|
|
102
|
+
const hasConfig = existsSync(configPath);
|
|
103
|
+
const hasPackage = existsSync(packagePath);
|
|
104
|
+
if (hasConfig) {
|
|
105
|
+
return { configPath, projectRoot: currentDir };
|
|
106
|
+
}
|
|
107
|
+
if (hasPackage && !hasConfig) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
currentDir = dirname(currentDir);
|
|
111
|
+
}
|
|
93
112
|
return null;
|
|
94
113
|
}
|
|
95
114
|
function parseConnectionUrl(url) {
|
package/dist/config.d.ts
CHANGED
|
@@ -780,7 +780,7 @@ export interface RelqPlugin {
|
|
|
780
780
|
};
|
|
781
781
|
}
|
|
782
782
|
export declare function defineConfig<TTables extends Record<string, TableDefinition<Record<string, ColumnConfig>>> = Record<string, TableDefinition<Record<string, ColumnConfig>>>>(config: RelqConfig<TTables>): RelqConfig<TTables>;
|
|
783
|
-
export declare function loadConfig(
|
|
783
|
+
export declare function loadConfig(startPath?: string): Promise<RelqConfig>;
|
|
784
784
|
export declare function parseConnectionUrl(url: string): RelqConnectionConfig;
|
|
785
785
|
export declare function mergeConfigs(...configs: Partial<RelqConfig>[]): RelqConfig;
|
|
786
786
|
export declare function validateConfig(config: RelqConfig): {
|
|
@@ -583,7 +583,7 @@ export async function addCommand(context) {
|
|
|
583
583
|
}
|
|
584
584
|
const ignorePatterns = loadRelqignore(projectRoot);
|
|
585
585
|
const config = await loadConfig();
|
|
586
|
-
const schemaPathRaw = typeof config
|
|
586
|
+
const schemaPathRaw = typeof config?.schema === 'string' ? config.schema : './db/schema.ts';
|
|
587
587
|
const schemaPath = path.resolve(projectRoot, schemaPathRaw);
|
|
588
588
|
const injectedCount = injectTrackingIds(schemaPath);
|
|
589
589
|
if (injectedCount > 0) {
|
|
@@ -614,16 +614,16 @@ export async function addCommand(context) {
|
|
|
614
614
|
if (result.ignored) {
|
|
615
615
|
return false;
|
|
616
616
|
}
|
|
617
|
-
if (['FUNCTION', 'PROCEDURE'].includes(change.objectType) && !config
|
|
617
|
+
if (['FUNCTION', 'PROCEDURE'].includes(change.objectType) && !config?.includeFunctions) {
|
|
618
618
|
return false;
|
|
619
619
|
}
|
|
620
|
-
if (change.objectType === 'TRIGGER' && !config
|
|
620
|
+
if (change.objectType === 'TRIGGER' && !config?.includeTriggers) {
|
|
621
621
|
return false;
|
|
622
622
|
}
|
|
623
|
-
if (['VIEW', 'MATERIALIZED_VIEW'].includes(change.objectType) && !config
|
|
623
|
+
if (['VIEW', 'MATERIALIZED_VIEW'].includes(change.objectType) && !config?.includeViews) {
|
|
624
624
|
return false;
|
|
625
625
|
}
|
|
626
|
-
if (change.objectType === 'FOREIGN_TABLE' && !config
|
|
626
|
+
if (change.objectType === 'FOREIGN_TABLE' && !config?.includeFDW) {
|
|
627
627
|
return false;
|
|
628
628
|
}
|
|
629
629
|
return true;
|
|
@@ -86,7 +86,7 @@ export async function commitCommand(context) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
const commitConfig = await loadConfig();
|
|
89
|
-
const schemaPathRaw = typeof commitConfig
|
|
89
|
+
const schemaPathRaw = typeof commitConfig?.schema === 'string' ? commitConfig.schema : './db/schema.ts';
|
|
90
90
|
const schemaFilePath = path.resolve(projectRoot, schemaPathRaw);
|
|
91
91
|
if (fs.existsSync(schemaFilePath)) {
|
|
92
92
|
const currentContent = fs.readFileSync(schemaFilePath, 'utf-8');
|
|
@@ -35,21 +35,40 @@ export function defineConfig(config) {
|
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
export function loadConfig(
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
return
|
|
38
|
+
export async function loadConfig(startPath) {
|
|
39
|
+
const result = findConfigFile(startPath);
|
|
40
|
+
if (!result) {
|
|
41
|
+
return {};
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
try {
|
|
44
|
+
const module = await import(result.configPath);
|
|
44
45
|
if (module.default) {
|
|
45
46
|
return module.default;
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
|
-
function findConfigFile() {
|
|
54
|
+
function findConfigFile(startPath) {
|
|
55
|
+
const { existsSync } = require('fs');
|
|
56
|
+
const { join, dirname, parse } = require('path');
|
|
57
|
+
let currentDir = startPath || process.cwd();
|
|
58
|
+
const { root } = parse(currentDir);
|
|
59
|
+
while (currentDir !== root) {
|
|
60
|
+
const configPath = join(currentDir, 'relq.config.ts');
|
|
61
|
+
const packagePath = join(currentDir, 'package.json');
|
|
62
|
+
const hasConfig = existsSync(configPath);
|
|
63
|
+
const hasPackage = existsSync(packagePath);
|
|
64
|
+
if (hasConfig) {
|
|
65
|
+
return { configPath, projectRoot: currentDir };
|
|
66
|
+
}
|
|
67
|
+
if (hasPackage && !hasConfig) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
currentDir = dirname(currentDir);
|
|
71
|
+
}
|
|
53
72
|
return null;
|
|
54
73
|
}
|
|
55
74
|
export function parseConnectionUrl(url) {
|