orchid-orm 1.5.16 → 1.5.17
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 +8 -0
- package/dist/bin.js +4 -2
- package/dist/bin.js.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/bin/init.ts +4 -2
- package/src/codegen/updateMainFile.test.ts +19 -4
- package/src/codegen/updateMainFile.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orchid-orm",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.17",
|
|
4
4
|
"description": "Postgres ORM",
|
|
5
5
|
"homepage": "https://orchid-orm.netlify.app/guide/orm-setup-and-overview.html",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"author": "Roman Kushyn",
|
|
41
41
|
"license": "ISC",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"pqb": "0.9.
|
|
43
|
+
"pqb": "0.9.11",
|
|
44
44
|
"prompts": "^2.4.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"@types/prompts": "^2.4.2",
|
|
53
53
|
"dotenv": "^16.0.1",
|
|
54
54
|
"jest": "^28.1.2",
|
|
55
|
-
"orchid-orm-schema-to-zod": "0.2.
|
|
55
|
+
"orchid-orm-schema-to-zod": "0.2.17",
|
|
56
56
|
"pg": "^8.7.3",
|
|
57
57
|
"pg-transactional-tests": "^1.0.7",
|
|
58
|
-
"rake-db": "2.3.
|
|
58
|
+
"rake-db": "2.3.16",
|
|
59
59
|
"rimraf": "^3.0.2",
|
|
60
60
|
"rollup": "^2.79.0",
|
|
61
61
|
"rollup-plugin-dts": "^4.2.2",
|
package/src/bin/init.ts
CHANGED
|
@@ -489,7 +489,8 @@ export const seed = async () => {
|
|
|
489
489
|
};
|
|
490
490
|
|
|
491
491
|
const greet = () => {
|
|
492
|
-
console.log(`
|
|
492
|
+
console.log(`
|
|
493
|
+
Thank you for trying Orchid ORM!
|
|
493
494
|
|
|
494
495
|
To finish setup, install dependencies:
|
|
495
496
|
|
|
@@ -502,5 +503,6 @@ then create the database:
|
|
|
502
503
|
|
|
503
504
|
And run the migrations:
|
|
504
505
|
|
|
505
|
-
> npm run db migrate
|
|
506
|
+
> npm run db migrate
|
|
507
|
+
`);
|
|
506
508
|
};
|
|
@@ -109,10 +109,10 @@ export const db = orchidORM({}, {
|
|
|
109
109
|
it('should handle object list without ending coma', async () => {
|
|
110
110
|
asMock(fs.readFile).mockResolvedValue(`
|
|
111
111
|
import { orchidORM } from 'orchid-orm';
|
|
112
|
-
import {
|
|
112
|
+
import { MyTable } from './tables/my.table';
|
|
113
113
|
|
|
114
114
|
export const db = orchidORM({}, {
|
|
115
|
-
|
|
115
|
+
my: MyTable,
|
|
116
116
|
});
|
|
117
117
|
`);
|
|
118
118
|
|
|
@@ -120,15 +120,30 @@ export const db = orchidORM({}, {
|
|
|
120
120
|
|
|
121
121
|
testWritten(`
|
|
122
122
|
import { orchidORM } from 'orchid-orm';
|
|
123
|
-
import {
|
|
123
|
+
import { MyTable } from './tables/my.table';
|
|
124
124
|
import { SomeTable } from './tables/some.table';
|
|
125
125
|
|
|
126
126
|
export const db = orchidORM({}, {
|
|
127
|
-
|
|
127
|
+
my: MyTable,
|
|
128
128
|
some: SomeTable,
|
|
129
129
|
});
|
|
130
130
|
`);
|
|
131
131
|
});
|
|
132
|
+
|
|
133
|
+
it('should not add table if it is already added', async () => {
|
|
134
|
+
asMock(fs.readFile).mockResolvedValue(`
|
|
135
|
+
import { orchidORM } from 'orchid-orm';
|
|
136
|
+
import { SomeTable } from './tables/some.table';
|
|
137
|
+
|
|
138
|
+
export const db = orchidORM({}, {
|
|
139
|
+
some: SomeTable
|
|
140
|
+
});
|
|
141
|
+
`);
|
|
142
|
+
|
|
143
|
+
await updateMainFile(mainFilePath, tablePath, ast.addTable, options);
|
|
144
|
+
|
|
145
|
+
expect(fs.writeFile).not.toBeCalled();
|
|
146
|
+
});
|
|
132
147
|
});
|
|
133
148
|
|
|
134
149
|
describe('drop table', () => {
|
|
@@ -122,6 +122,12 @@ const createTable = (
|
|
|
122
122
|
const changes = new FileChanges(content);
|
|
123
123
|
|
|
124
124
|
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
125
|
+
|
|
126
|
+
const existing = Array.from(
|
|
127
|
+
ts.import.iterateWithSource(statements, importPath),
|
|
128
|
+
);
|
|
129
|
+
if (existing.length) return;
|
|
130
|
+
|
|
125
131
|
const importPos = ts.import.getEndPos(statements);
|
|
126
132
|
changes.add(
|
|
127
133
|
importPos,
|