orchid-orm 1.5.20 → 1.5.21
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/codegen/appCodeUpdater.test.ts +7 -3
- package/src/codegen/appCodeUpdater.ts +14 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orchid-orm",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.21",
|
|
4
4
|
"description": "Postgres ORM",
|
|
5
5
|
"homepage": "https://orchid-orm.netlify.app/guide/orm-setup-and-overview.html",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"orchid-orm-schema-to-zod": "0.2.18",
|
|
56
56
|
"pg": "^8.7.3",
|
|
57
57
|
"pg-transactional-tests": "^1.0.7",
|
|
58
|
-
"rake-db": "2.3.
|
|
58
|
+
"rake-db": "2.3.21",
|
|
59
59
|
"rimraf": "^3.0.2",
|
|
60
60
|
"rollup": "^2.79.0",
|
|
61
61
|
"rollup-plugin-dts": "^4.2.2",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appCodeUpdater } from './appCodeUpdater';
|
|
2
2
|
import { asMock, ast } from './testUtils';
|
|
3
3
|
import { updateMainFile } from './updateMainFile';
|
|
4
|
-
import
|
|
4
|
+
import path from 'path';
|
|
5
5
|
import { updateTableFile } from './updateTableFile/updateTableFile';
|
|
6
6
|
import { createBaseTableFile } from './createBaseTableFile';
|
|
7
7
|
|
|
@@ -47,12 +47,16 @@ describe('appCodeUpdater', () => {
|
|
|
47
47
|
|
|
48
48
|
const [table] = asMock(updateTableFile).mock.calls[0];
|
|
49
49
|
expect(table.tablePath('table')).toBe(tablePath);
|
|
50
|
-
expect(table.baseTablePath).toBe(
|
|
50
|
+
expect(table.baseTablePath).toBe(
|
|
51
|
+
path.resolve(__dirname, params.baseTablePath),
|
|
52
|
+
);
|
|
51
53
|
expect(table.baseTableName).toBe(params.baseTableName);
|
|
52
54
|
expect(table.mainFilePath).toBe(mainFilePath);
|
|
53
55
|
|
|
54
56
|
const [base] = asMock(createBaseTableFile).mock.calls[0];
|
|
55
|
-
expect(base.baseTablePath).toBe(
|
|
57
|
+
expect(base.baseTablePath).toBe(
|
|
58
|
+
path.resolve(__dirname, params.baseTablePath),
|
|
59
|
+
);
|
|
56
60
|
expect(base.baseTableName).toBe(params.baseTableName);
|
|
57
61
|
});
|
|
58
62
|
|
|
@@ -14,20 +14,21 @@ export type AppCodeUpdaterConfig = {
|
|
|
14
14
|
mainFilePath: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const appCodeUpdater = (
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export const appCodeUpdater = ({
|
|
18
|
+
tablePath,
|
|
19
|
+
baseTablePath,
|
|
20
|
+
baseTableName,
|
|
21
|
+
mainFilePath,
|
|
22
|
+
}: SetOptional<AppCodeUpdaterConfig, 'baseTableName'>): AppCodeUpdater => {
|
|
20
23
|
return async ({ ast, options, basePath, cache: cacheObject }) => {
|
|
21
24
|
const params: AppCodeUpdaterConfig = {
|
|
22
|
-
...config,
|
|
23
|
-
baseTableName: config.baseTableName || 'BaseTable',
|
|
24
25
|
tablePath(name: string) {
|
|
25
|
-
const file =
|
|
26
|
-
return
|
|
26
|
+
const file = tablePath(name);
|
|
27
|
+
return resolvePath(basePath, file);
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
baseTablePath: resolvePath(basePath, baseTablePath),
|
|
30
|
+
baseTableName: baseTableName || 'BaseTable',
|
|
31
|
+
mainFilePath: resolvePath(basePath, mainFilePath),
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
const promises: Promise<void>[] = [
|
|
@@ -47,3 +48,6 @@ export const appCodeUpdater = (
|
|
|
47
48
|
await Promise.all(promises);
|
|
48
49
|
};
|
|
49
50
|
};
|
|
51
|
+
|
|
52
|
+
const resolvePath = (basePath: string, filePath: string) =>
|
|
53
|
+
path.isAbsolute(filePath) ? filePath : path.resolve(basePath, filePath);
|