drizzle-kit 0.9.2 → 0.9.3
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/drizzle.js → drizzle.js} +0 -0
- package/{dist/drizzle.js.map → drizzle.js.map} +0 -0
- package/package.json +1 -1
- package/.eslintrc +0 -21
- package/config.yml +0 -4
- package/data/_prev/multi.ts +0 -43
- package/data/_prev/tables/authOtpTable.ts +0 -22
- package/data/_prev/tables/cityTable.ts +0 -17
- package/data/_prev/tables/usersTable.ts +0 -18
- package/data/_prev/types/types.ts +0 -11
- package/data/v1/tables/authOtpTable.ts +0 -18
- package/data/v1/tables/deletedTable.ts +0 -9
- package/data/v1/tables/usersTable.ts +0 -15
- package/data/v1/types/types.ts +0 -6
- package/data/v2/tables/authOtpTable.ts +0 -22
- package/data/v2/tables/cityTable.ts +0 -10
- package/data/v2/tables/usersTable.ts +0 -19
- package/data/v2/types/types.ts +0 -11
- package/data/v3/tables/authOtpTable.ts +0 -21
- package/data/v3/tables/cityTable.ts +0 -17
- package/data/v3/tables/usersTable.ts +0 -18
- package/data/v3/types/types.ts +0 -11
- package/dist/package.json +0 -85
- package/factory.ts +0 -224
- package/fstest.ts +0 -50
- package/index.ts +0 -16
- package/readme.md +0 -9
- package/serializer.ts +0 -139
- package/src/cli/commands/migration/index.tsx +0 -10
- package/src/cli/commands/migration/migrate/index.tsx +0 -164
- package/src/cli/components-api/ComponentsList.tsx +0 -20
- package/src/cli/components-api/CreateApp.tsx +0 -19
- package/src/cli/components-api/components/PromptColumnsConflicts.tsx +0 -171
- package/src/cli/components-api/components/PromptTablesConflicts.tsx +0 -180
- package/src/cli/components-api/components/Task.tsx +0 -85
- package/src/cli/components-api/index.tsx +0 -76
- package/src/cli/enq.ts +0 -41
- package/src/cli/index.tsx +0 -8
- package/src/cli/machines/resolveColumnsMachine.ts +0 -179
- package/src/cli/machines/resolveTablesMachine.ts +0 -169
- package/src/cli/utils/formatDataForTable.ts +0 -36
- package/src/cli/utils/valuesForPrompts.ts +0 -35
- package/src/diff.ts +0 -272
- package/src/differ.js +0 -135
- package/src/jsonStatements.js +0 -176
- package/src/migrationPreparator.ts +0 -47
- package/src/serilizer/factory.ts +0 -340
- package/src/serilizer/index.ts +0 -25
- package/src/simulator.ts +0 -85
- package/src/sqlgenerator.js +0 -373
- package/test-build.js +0 -26
- package/test.ts +0 -57
- package/testFactory.js +0 -3
- package/testFactory.ts +0 -26
- package/tsconfig.json +0 -28
- package/webpack.config.js +0 -53
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
package/.eslintrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["airbnb-typescript"],
|
|
3
|
-
"parserOptions": {
|
|
4
|
-
"project": "./tsconfig.json"
|
|
5
|
-
},
|
|
6
|
-
"env": {
|
|
7
|
-
"browser": true
|
|
8
|
-
},
|
|
9
|
-
"rules": {
|
|
10
|
-
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["webpack.config.ts"] }],
|
|
11
|
-
"@typescript-eslint/no-use-before-define": ["error", { "variables": false }],
|
|
12
|
-
"@typescript-eslint/naming-convention": ["off"],
|
|
13
|
-
"react/prop-types": ["off"],
|
|
14
|
-
"react/require-default-props": ["off"],
|
|
15
|
-
"react/jsx-props-no-spreading": ["off"],
|
|
16
|
-
"no-underscore-dangle": ["off"],
|
|
17
|
-
"react/no-array-index-key": ["off"],
|
|
18
|
-
"no-param-reassign": ["off"],
|
|
19
|
-
"no-nested-ternary": ["off"]
|
|
20
|
-
}
|
|
21
|
-
}
|
package/config.yml
DELETED
package/data/_prev/multi.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import { createEnum } from 'drizzle-orm/types/type';
|
|
3
|
-
|
|
4
|
-
export class CitiesTable2 extends AbstractTable<CitiesTable2> {
|
|
5
|
-
public name = this.timestamp('name', { notNull: true }).defaultValue(new Date());
|
|
6
|
-
public page = this.varchar('page', { size: 256 });
|
|
7
|
-
public roleEnum = this.type(rolesEnumMulti, 'role')
|
|
8
|
-
|
|
9
|
-
public userId1 = this.int('user_id').foreignKey(UsersTable2, (table) => table.id);
|
|
10
|
-
|
|
11
|
-
public data = this.jsonb<string[]>('data');
|
|
12
|
-
|
|
13
|
-
public tableName(): string {
|
|
14
|
-
return 'citiess';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class UsersTable2 extends AbstractTable<UsersTable2> {
|
|
19
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
20
|
-
public phone = this.varchar('phone', { size: 256 }).unique();
|
|
21
|
-
public fullName = this.varchar('full_name', { size: 512 });
|
|
22
|
-
public test = this.decimal('test', { notNull: true, precision: 100, scale: 2 });
|
|
23
|
-
public test1 = this.bigint('test1', { notNull: true });
|
|
24
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
25
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
26
|
-
|
|
27
|
-
public phoneFullNameIndex = this.index([this.phone, this.fullName]);
|
|
28
|
-
public phoneIndex = this.index(this.phone);
|
|
29
|
-
|
|
30
|
-
public tableName(): string {
|
|
31
|
-
return 'users';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const rolesEnumMulti = createEnum({
|
|
36
|
-
alias: "roles_enum",
|
|
37
|
-
values: ["role1", "role2", "role3"],
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const rolesEnumMulti2 = createEnum({
|
|
41
|
-
alias: "roles2_enum",
|
|
42
|
-
values: ["role1.1", "role2.2", "role3.3"],
|
|
43
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import UsersTable from './usersTable';
|
|
3
|
-
import { rolesEnum } from '../types/types';
|
|
4
|
-
|
|
5
|
-
export default class AuthOtpTable extends AbstractTable<AuthOtpTable> {
|
|
6
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
7
|
-
public phone = this.varchar('phone', { size: 256 });
|
|
8
|
-
public otp = this.varchar('otp', { size: 256 });
|
|
9
|
-
public issuedAt = this.timestamp('issued_at', { notNull: true });
|
|
10
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
11
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
12
|
-
|
|
13
|
-
public roleEnum = this.type(rolesEnum, 'role')
|
|
14
|
-
|
|
15
|
-
public userId = this.int('user_id').foreignKey(UsersTable, (table) => table.id);
|
|
16
|
-
|
|
17
|
-
public test = this.jsonb<string[]>('test');
|
|
18
|
-
|
|
19
|
-
public tableName(): string {
|
|
20
|
-
return 'auth_otp';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import UsersTable from './usersTable';
|
|
3
|
-
import { rolesEnum } from '../types/types';
|
|
4
|
-
|
|
5
|
-
export default class CitiesTable extends AbstractTable<CitiesTable> {
|
|
6
|
-
public name = this.timestamp('name', { notNull: true }).defaultValue(new Date());
|
|
7
|
-
public page = this.varchar('page', { size: 256 });
|
|
8
|
-
public roleEnum = this.type(rolesEnum, 'role')
|
|
9
|
-
|
|
10
|
-
public userId1 = this.int('user_id').foreignKey(UsersTable, (table) => table.id);
|
|
11
|
-
|
|
12
|
-
public data = this.jsonb<string[]>('data');
|
|
13
|
-
|
|
14
|
-
public tableName(): string {
|
|
15
|
-
return 'citiess';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from "drizzle-orm";
|
|
2
|
-
|
|
3
|
-
export default class UsersTable extends AbstractTable<UsersTable> {
|
|
4
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
5
|
-
public phone = this.varchar('phone', { size: 256 }).unique();
|
|
6
|
-
public fullName = this.varchar('full_name', { size: 512 });
|
|
7
|
-
public test = this.decimal('test', { notNull: true, precision: 100, scale: 2 });
|
|
8
|
-
public test1 = this.bigint('test1', { notNull: true });
|
|
9
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
10
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
11
|
-
|
|
12
|
-
public phoneFullNameIndex = this.index([this.phone, this.fullName]);
|
|
13
|
-
public phoneIndex = this.index(this.phone);
|
|
14
|
-
|
|
15
|
-
public tableName(): string {
|
|
16
|
-
return 'users';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createEnum } from "drizzle-orm/types/type";
|
|
2
|
-
|
|
3
|
-
export const rolesEnum = createEnum({
|
|
4
|
-
alias: "roles_enum",
|
|
5
|
-
values: ["role1", "role2", "role3"],
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export const roles2Enum = createEnum({
|
|
9
|
-
alias: "roles2_enum",
|
|
10
|
-
values: ["role1.1", "role2.2", "role3.3"],
|
|
11
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
|
|
3
|
-
export default class AuthOtpTable extends AbstractTable<AuthOtpTable> {
|
|
4
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
5
|
-
public phone = this.varchar('phone', { size: 256 });
|
|
6
|
-
|
|
7
|
-
public column1 = this.varchar('to_add_default', { size: 256 });
|
|
8
|
-
public column2 = this.varchar('to_add_notnull', { size: 256 });
|
|
9
|
-
|
|
10
|
-
public column3 = this.varchar('to_change_default', { size: 256 }).defaultValue('defaultToChange');
|
|
11
|
-
|
|
12
|
-
public column4 = this.varchar('to_drop_default', { size: 256 }).defaultValue('defaul_to_be_dropped');
|
|
13
|
-
public column5 = this.varchar('to_drop_notnull', { size: 256, notNull: true });
|
|
14
|
-
|
|
15
|
-
public tableName(): string {
|
|
16
|
-
return 'auth_otp';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from "drizzle-orm";
|
|
2
|
-
|
|
3
|
-
export default class UsersTable extends AbstractTable<UsersTable> {
|
|
4
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
5
|
-
public fullName = this.varchar('full_name_to_alter', { size: 256 });
|
|
6
|
-
|
|
7
|
-
public test = this.decimal('column_to_delete1', { notNull: true, precision: 100, scale: 2 });
|
|
8
|
-
public test1 = this.bigint('column_to_todelet2', { notNull: true });
|
|
9
|
-
|
|
10
|
-
public fullNameIndex = this.index(this.fullName);
|
|
11
|
-
|
|
12
|
-
public tableName(): string {
|
|
13
|
-
return 'users';
|
|
14
|
-
}
|
|
15
|
-
}
|
package/data/v1/types/types.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import { rolesEnum, roles2Enum} from '../types/types'
|
|
3
|
-
import UsersTable from './usersTable';
|
|
4
|
-
|
|
5
|
-
export default class AuthOtpTable extends AbstractTable<AuthOtpTable> {
|
|
6
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
7
|
-
public phone = this.varchar('phone', { size: 256 });
|
|
8
|
-
|
|
9
|
-
public column1 = this.varchar('to_add_default', { size: 256 }).defaultValue('added_default');
|
|
10
|
-
public column2 = this.varchar('to_add_notnull', { size: 256, notNull: true});
|
|
11
|
-
public column3 = this.varchar('to_change_default', { size: 256 }).defaultValue('defaultToChange');
|
|
12
|
-
public column4 = this.varchar('to_drop_default', { size: 256 });
|
|
13
|
-
public column5 = this.varchar('to_drop_notnull', { size: 256 });
|
|
14
|
-
|
|
15
|
-
public roleEnum1 = this.type(rolesEnum, 'role')
|
|
16
|
-
public roleEnum2 = this.type(roles2Enum, 'role2')
|
|
17
|
-
public userId = this.int('user_id').foreignKey(UsersTable, (table) => table.id);
|
|
18
|
-
|
|
19
|
-
public tableName(): string {
|
|
20
|
-
return 'auth_otp_renamed';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
|
|
3
|
-
export default class CitiesTable extends AbstractTable<CitiesTable> {
|
|
4
|
-
public name = this.timestamp('name', { notNull: true }).defaultValue(new Date());
|
|
5
|
-
public data = this.jsonb<string[]>('data');
|
|
6
|
-
|
|
7
|
-
public tableName(): string {
|
|
8
|
-
return 'cities';
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from "drizzle-orm";
|
|
2
|
-
|
|
3
|
-
export default class UsersTable extends AbstractTable<UsersTable> {
|
|
4
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
5
|
-
public phone = this.varchar('phone', { size: 256 }).unique();
|
|
6
|
-
public fullName = this.varchar('full_name_to_alter', { size: 512 });
|
|
7
|
-
|
|
8
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
9
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
10
|
-
|
|
11
|
-
public phoneFullNameIndex = this.index([this.phone, this.fullName]);
|
|
12
|
-
|
|
13
|
-
// deleted
|
|
14
|
-
// public fullNameIndex = this.index(this.fullName);
|
|
15
|
-
|
|
16
|
-
public tableName(): string {
|
|
17
|
-
return 'users2';
|
|
18
|
-
}
|
|
19
|
-
}
|
package/data/v2/types/types.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createEnum } from "drizzle-orm/types/type";
|
|
2
|
-
|
|
3
|
-
export const rolesEnum = createEnum({
|
|
4
|
-
alias: "roles_enum",
|
|
5
|
-
values: ["role1", "role2", "role3"],
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export const roles2Enum = createEnum({
|
|
9
|
-
alias: "roles2_enum",
|
|
10
|
-
values: ["role1.1", "role2.2", "role3.3"],
|
|
11
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import UsersTable from './usersTable';
|
|
3
|
-
import { rolesEnum } from '../types/types';
|
|
4
|
-
|
|
5
|
-
export default class AuthOtpTable extends AbstractTable<AuthOtpTable> {
|
|
6
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
7
|
-
public phone = this.varchar('phone', { size: 256 });
|
|
8
|
-
public otp = this.varchar('otp', { size: 256 });
|
|
9
|
-
public issuedAt = this.timestamp('issued_at', { notNull: true });
|
|
10
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
11
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
12
|
-
|
|
13
|
-
public roleEnum = this.type(rolesEnum, 'role')
|
|
14
|
-
public userId = this.int('user_id').foreignKey(UsersTable, (table) => table.id);
|
|
15
|
-
|
|
16
|
-
public test = this.jsonb<string[]>('test');
|
|
17
|
-
|
|
18
|
-
public tableName(): string {
|
|
19
|
-
return 'auth_otp';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from 'drizzle-orm';
|
|
2
|
-
import UsersTable from './usersTable';
|
|
3
|
-
import { rolesEnum } from '../types/types';
|
|
4
|
-
|
|
5
|
-
export default class CitiesTable extends AbstractTable<CitiesTable> {
|
|
6
|
-
public name = this.timestamp('name', { notNull: true }).defaultValue(new Date());
|
|
7
|
-
public page = this.varchar('page', { size: 256 });
|
|
8
|
-
public roleEnum = this.type(rolesEnum, 'role')
|
|
9
|
-
|
|
10
|
-
public userId1 = this.int('user_id').foreignKey(UsersTable, (table) => table.id);
|
|
11
|
-
|
|
12
|
-
public data = this.jsonb<string[]>('data');
|
|
13
|
-
|
|
14
|
-
public tableName(): string {
|
|
15
|
-
return 'citiess';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AbstractTable } from "drizzle-orm";
|
|
2
|
-
|
|
3
|
-
export default class UsersTable extends AbstractTable<UsersTable> {
|
|
4
|
-
public id = this.int('id').autoIncrement().primaryKey();
|
|
5
|
-
public phone = this.varchar('phone', { size: 256 }).unique();
|
|
6
|
-
public fullName = this.varchar('full_name', { size: 512 });
|
|
7
|
-
public test = this.decimal('test', { notNull: true, precision: 100, scale: 2 });
|
|
8
|
-
public test1 = this.bigint('test1', { notNull: true });
|
|
9
|
-
public createdAt = this.timestamp('created_at', { notNull: true });
|
|
10
|
-
public updatedAt = this.timestamp('updated_at', { notNull: true });
|
|
11
|
-
|
|
12
|
-
public phoneFullNameIndex = this.index([this.phone, this.fullName]);
|
|
13
|
-
public phoneIndex = this.index(this.phone);
|
|
14
|
-
|
|
15
|
-
public tableName(): string {
|
|
16
|
-
return 'users';
|
|
17
|
-
}
|
|
18
|
-
}
|
package/data/v3/types/types.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createEnum } from "drizzle-orm/types/type";
|
|
2
|
-
|
|
3
|
-
export const rolesEnum = createEnum({
|
|
4
|
-
alias: "roles_enum",
|
|
5
|
-
values: ["role1", "role2", "role3"],
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export const roles2Enum = createEnum({
|
|
9
|
-
alias: "roles2_enum",
|
|
10
|
-
values: ["role1.1", "role2.2", "role3.3"],
|
|
11
|
-
});
|
package/dist/package.json
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.9.1",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"repository": "https://github.com/lambda-direct/drizzle-kit",
|
|
6
|
-
"author": "Alex Blokh <aleksandrblokh@gmail.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"start": "ts-node ./src/index.ts",
|
|
10
|
-
"watch": "webpack --watch",
|
|
11
|
-
"diff": "ts-node ./src/diff.ts",
|
|
12
|
-
"test": "ts-node ./index.ts",
|
|
13
|
-
"imports": "ts-node ./test.ts",
|
|
14
|
-
"build:dev": "webpack",
|
|
15
|
-
"build:prod": "NODE_ENV=production webpack"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@iarna/toml": "^2.2.5",
|
|
19
|
-
"@lambda-team/ltdl": "^1.4.1",
|
|
20
|
-
"@types/uuid": "^8.3.1",
|
|
21
|
-
"@xstate/react": "^1.6.1",
|
|
22
|
-
"commander": "^8.0.0",
|
|
23
|
-
"csv-parse": "^4.16.0",
|
|
24
|
-
"csv-stringify": "^5.6.2",
|
|
25
|
-
"drizzle-orm": "^0.9.1",
|
|
26
|
-
"enquirer": "^2.3.6",
|
|
27
|
-
"esbuild": "^0.12.28",
|
|
28
|
-
"gitdiff-parser": "^0.2.2",
|
|
29
|
-
"immer": "^9.0.6",
|
|
30
|
-
"immer-reducer": "^0.7.13",
|
|
31
|
-
"ink": "3.0.9",
|
|
32
|
-
"ink-divider": "^3.0.0",
|
|
33
|
-
"ink-router": "0.6.0",
|
|
34
|
-
"ink-select-input": "4.2.0",
|
|
35
|
-
"ink-spinner": "^4.0.3",
|
|
36
|
-
"ink-table": "3.0.0",
|
|
37
|
-
"ink-text-input": "^4.0.1",
|
|
38
|
-
"install": "^0.13.0",
|
|
39
|
-
"js-yaml": "^4.1.0",
|
|
40
|
-
"json-diff": "^0.5.4",
|
|
41
|
-
"lodash.flatten": "^4.4.0",
|
|
42
|
-
"moment": "^2.29.1",
|
|
43
|
-
"npm": "^7.23.0",
|
|
44
|
-
"object-hash": "2.2.0",
|
|
45
|
-
"pg": "^8.7.1",
|
|
46
|
-
"pretty-error": "^3.0.4",
|
|
47
|
-
"react": "^17.0.2",
|
|
48
|
-
"simple-git": "^2.40.0",
|
|
49
|
-
"source-map-support": "^0.5.19",
|
|
50
|
-
"tasuku": "^1.0.2",
|
|
51
|
-
"toml": "^3.0.0",
|
|
52
|
-
"ts-creator": "^1.1.10",
|
|
53
|
-
"ts-node": "^10.2.1",
|
|
54
|
-
"use-immer": "^0.6.0",
|
|
55
|
-
"uuid": "^8.3.2",
|
|
56
|
-
"valtio": "^1.2.4",
|
|
57
|
-
"xstate": "^4.25.0"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@types/ink-divider": "^2.0.2",
|
|
61
|
-
"@types/js-yaml": "^4.0.3",
|
|
62
|
-
"@types/lodash.flatten": "^4.4.6",
|
|
63
|
-
"@types/object-hash": "2.1.1",
|
|
64
|
-
"@types/react": "^17.0.13",
|
|
65
|
-
"@types/vorpal": "^1.12.1",
|
|
66
|
-
"@types/webpack": "^5.28.0",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "4.4.1",
|
|
68
|
-
"eslint": "^7.2.0",
|
|
69
|
-
"eslint-config-airbnb": "18.2.1",
|
|
70
|
-
"eslint-config-airbnb-typescript": "11.0.0",
|
|
71
|
-
"eslint-plugin-import": "^2.22.1",
|
|
72
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
73
|
-
"eslint-plugin-react": "^7.21.5",
|
|
74
|
-
"eslint-plugin-react-hooks": "^1.7.0",
|
|
75
|
-
"prettier": "^2.3.2",
|
|
76
|
-
"source-map-loader": "^3.0.0",
|
|
77
|
-
"ts-loader": "^9.2.3",
|
|
78
|
-
"tsconfig-paths-webpack-plugin": "^3.5.1",
|
|
79
|
-
"typescript": "^4.3.5",
|
|
80
|
-
"webpack": "^5.42.0",
|
|
81
|
-
"webpack-cli": "^4.7.2",
|
|
82
|
-
"webpack-node-externals": "^3.0.0",
|
|
83
|
-
"webpack-shebang-plugin": "^1.1.6"
|
|
84
|
-
}
|
|
85
|
-
}
|
package/factory.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
const printer: ts.Printer = ts.createPrinter();
|
|
4
|
-
|
|
5
|
-
const prepareFabricFile = (folder: string) => {
|
|
6
|
-
const staticImports = [
|
|
7
|
-
ts.createImportDeclaration(
|
|
8
|
-
undefined,
|
|
9
|
-
undefined,
|
|
10
|
-
ts.createImportClause(
|
|
11
|
-
undefined,
|
|
12
|
-
ts.createNamedImports([
|
|
13
|
-
ts.createImportSpecifier(
|
|
14
|
-
undefined,
|
|
15
|
-
ts.createIdentifier("AbstractTable"),
|
|
16
|
-
),
|
|
17
|
-
ts.createImportSpecifier(undefined, ts.createIdentifier("DB")),
|
|
18
|
-
]),
|
|
19
|
-
),
|
|
20
|
-
ts.createStringLiteral("@lambda-team/ltdl"),
|
|
21
|
-
),
|
|
22
|
-
ts.createImportDeclaration(
|
|
23
|
-
undefined,
|
|
24
|
-
undefined,
|
|
25
|
-
ts.createImportClause(
|
|
26
|
-
undefined,
|
|
27
|
-
ts.createNamedImports([
|
|
28
|
-
ts.createImportSpecifier(undefined, ts.createIdentifier("Pool")),
|
|
29
|
-
]),
|
|
30
|
-
),
|
|
31
|
-
ts.createStringLiteral("pg"),
|
|
32
|
-
),
|
|
33
|
-
ts.createImportDeclaration(
|
|
34
|
-
undefined,
|
|
35
|
-
undefined,
|
|
36
|
-
ts.createImportClause(ts.createIdentifier("Serializer"), undefined),
|
|
37
|
-
ts.createStringLiteral("./serializer"),
|
|
38
|
-
),
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const dynamicImports = [];
|
|
42
|
-
const filenames = fs.readdirSync(folder);
|
|
43
|
-
for (let i = 0; i < filenames.length; i++) {
|
|
44
|
-
const filename = filenames[i];
|
|
45
|
-
const importPath = `${folder}${filename.split(".")[0]}`;
|
|
46
|
-
dynamicImports.push(ts.createImportDeclaration(
|
|
47
|
-
undefined,
|
|
48
|
-
undefined,
|
|
49
|
-
ts.createImportClause(
|
|
50
|
-
undefined,
|
|
51
|
-
ts.createNamespaceImport(ts.createIdentifier(`i${i}`)),
|
|
52
|
-
),
|
|
53
|
-
ts.createStringLiteral(importPath),
|
|
54
|
-
));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const variablesStatements = [
|
|
58
|
-
ts.createVariableStatement(
|
|
59
|
-
undefined,
|
|
60
|
-
ts.createVariableDeclarationList(
|
|
61
|
-
[
|
|
62
|
-
ts.createVariableDeclaration(
|
|
63
|
-
ts.createIdentifier("db"),
|
|
64
|
-
undefined,
|
|
65
|
-
ts.createNew(ts.createIdentifier("DB"), undefined, [
|
|
66
|
-
ts.createNew(ts.createIdentifier("Pool"), undefined, []),
|
|
67
|
-
]),
|
|
68
|
-
),
|
|
69
|
-
],
|
|
70
|
-
ts.NodeFlags.Const,
|
|
71
|
-
),
|
|
72
|
-
),
|
|
73
|
-
ts.createVariableStatement(
|
|
74
|
-
undefined,
|
|
75
|
-
ts.createVariableDeclarationList(
|
|
76
|
-
[
|
|
77
|
-
ts.createVariableDeclaration(
|
|
78
|
-
ts.createIdentifier("serializer"),
|
|
79
|
-
undefined,
|
|
80
|
-
ts.createNew(ts.createIdentifier("Serializer"), undefined, []),
|
|
81
|
-
),
|
|
82
|
-
],
|
|
83
|
-
ts.NodeFlags.Const,
|
|
84
|
-
),
|
|
85
|
-
),
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
const blockStatements = [];
|
|
89
|
-
|
|
90
|
-
// const tables = []
|
|
91
|
-
blockStatements.push(ts.createVariableStatement(
|
|
92
|
-
undefined,
|
|
93
|
-
ts.createVariableDeclarationList(
|
|
94
|
-
[
|
|
95
|
-
ts.createVariableDeclaration(
|
|
96
|
-
ts.createIdentifier("tables"),
|
|
97
|
-
undefined,
|
|
98
|
-
ts.createArrayLiteral([], false),
|
|
99
|
-
),
|
|
100
|
-
],
|
|
101
|
-
ts.NodeFlags.Const,
|
|
102
|
-
),
|
|
103
|
-
));
|
|
104
|
-
for (let i = 0; i < filenames.length; i++) {
|
|
105
|
-
// const t1 = (new i1.default(db) as unknown as AbstractTable<any>);
|
|
106
|
-
// tables.push(t1)
|
|
107
|
-
const blockStatement = [
|
|
108
|
-
ts.createVariableStatement(
|
|
109
|
-
undefined,
|
|
110
|
-
ts.createVariableDeclarationList(
|
|
111
|
-
[
|
|
112
|
-
ts.createVariableDeclaration(
|
|
113
|
-
ts.createIdentifier("t" + i),
|
|
114
|
-
undefined,
|
|
115
|
-
ts.createParen(
|
|
116
|
-
ts.createAsExpression(
|
|
117
|
-
ts.createAsExpression(
|
|
118
|
-
ts.createNew(
|
|
119
|
-
ts.createPropertyAccess(
|
|
120
|
-
ts.createIdentifier("i" + i),
|
|
121
|
-
ts.createIdentifier("default"),
|
|
122
|
-
),
|
|
123
|
-
undefined,
|
|
124
|
-
[ts.createIdentifier("db")],
|
|
125
|
-
),
|
|
126
|
-
ts.createKeywordTypeNode(
|
|
127
|
-
ts.SyntaxKind.UnknownKeyword,
|
|
128
|
-
),
|
|
129
|
-
),
|
|
130
|
-
ts.createTypeReferenceNode(
|
|
131
|
-
ts.createIdentifier("AbstractTable"),
|
|
132
|
-
[
|
|
133
|
-
ts.createKeywordTypeNode(
|
|
134
|
-
ts.SyntaxKind.AnyKeyword,
|
|
135
|
-
),
|
|
136
|
-
],
|
|
137
|
-
),
|
|
138
|
-
),
|
|
139
|
-
),
|
|
140
|
-
),
|
|
141
|
-
],
|
|
142
|
-
ts.NodeFlags.Const,
|
|
143
|
-
),
|
|
144
|
-
),
|
|
145
|
-
ts.createExpressionStatement(
|
|
146
|
-
ts.createCall(
|
|
147
|
-
ts.createPropertyAccess(
|
|
148
|
-
ts.createIdentifier("tables"),
|
|
149
|
-
ts.createIdentifier("push"),
|
|
150
|
-
),
|
|
151
|
-
undefined,
|
|
152
|
-
[ts.createIdentifier("t" + i)],
|
|
153
|
-
),
|
|
154
|
-
),
|
|
155
|
-
];
|
|
156
|
-
|
|
157
|
-
blockStatements.push(...blockStatement);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// return serializer.generate(tables)
|
|
161
|
-
blockStatements.push(ts.createReturn(
|
|
162
|
-
ts.createCall(
|
|
163
|
-
ts.createPropertyAccess(
|
|
164
|
-
ts.createIdentifier("serializer"),
|
|
165
|
-
ts.createIdentifier("generate"),
|
|
166
|
-
),
|
|
167
|
-
undefined,
|
|
168
|
-
[ts.createIdentifier("tables")],
|
|
169
|
-
),
|
|
170
|
-
));
|
|
171
|
-
|
|
172
|
-
const funcStatement = [
|
|
173
|
-
ts.createVariableStatement(
|
|
174
|
-
undefined,
|
|
175
|
-
ts.createVariableDeclarationList(
|
|
176
|
-
[
|
|
177
|
-
ts.createVariableDeclaration(
|
|
178
|
-
ts.createIdentifier("testFun"),
|
|
179
|
-
undefined,
|
|
180
|
-
ts.createArrowFunction(
|
|
181
|
-
undefined,
|
|
182
|
-
undefined,
|
|
183
|
-
[],
|
|
184
|
-
undefined,
|
|
185
|
-
ts.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
|
|
186
|
-
// function body
|
|
187
|
-
ts.createBlock(
|
|
188
|
-
blockStatements,
|
|
189
|
-
true,
|
|
190
|
-
),
|
|
191
|
-
),
|
|
192
|
-
),
|
|
193
|
-
],
|
|
194
|
-
ts.NodeFlags.Const,
|
|
195
|
-
),
|
|
196
|
-
),
|
|
197
|
-
];
|
|
198
|
-
const invocationStatement = [
|
|
199
|
-
ts.createExpressionStatement(
|
|
200
|
-
ts.createCall(ts.createIdentifier("testFun"), undefined, []),
|
|
201
|
-
),
|
|
202
|
-
];
|
|
203
|
-
|
|
204
|
-
const outFile: ts.SourceFile = ts.createSourceFile(
|
|
205
|
-
"outfile.ts",
|
|
206
|
-
"",
|
|
207
|
-
ts.ScriptTarget.ES2015,
|
|
208
|
-
true,
|
|
209
|
-
ts.ScriptKind.TS,
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const source = [];
|
|
213
|
-
source.push(...staticImports);
|
|
214
|
-
source.push(...dynamicImports);
|
|
215
|
-
source.push(...variablesStatements);
|
|
216
|
-
source.push(...funcStatement);
|
|
217
|
-
source.push(...invocationStatement);
|
|
218
|
-
|
|
219
|
-
const newFile = ts.factory.updateSourceFile(outFile, source);
|
|
220
|
-
|
|
221
|
-
return printer.printFile(newFile);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export default prepareFabricFile;
|