@depup/typeorm-extension 3.9.0-depup.0 → 4.0.0-depup.0
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/README.MD +268 -134
- package/README.md +4 -6
- package/bin/cli.mjs +538 -267
- package/bin/cli.mjs.map +1 -0
- package/changes.json +3 -11
- package/dist/index.d.mts +1456 -0
- package/dist/index.mjs +3123 -2972
- package/dist/index.mjs.map +1 -1
- package/package.json +50 -56
- package/bin/cli.cjs +0 -275
- package/dist/cli/commands/database/create.d.ts +0 -27
- package/dist/cli/commands/database/drop.d.ts +0 -23
- package/dist/cli/commands/database/index.d.ts +0 -2
- package/dist/cli/commands/index.d.ts +0 -2
- package/dist/cli/commands/seed/create.d.ts +0 -21
- package/dist/cli/commands/seed/index.d.ts +0 -2
- package/dist/cli/commands/seed/run.d.ts +0 -24
- package/dist/cli/index.d.ts +0 -2
- package/dist/data-source/find/index.d.ts +0 -2
- package/dist/data-source/find/module.d.ts +0 -3
- package/dist/data-source/find/type.d.ts +0 -22
- package/dist/data-source/index.d.ts +0 -4
- package/dist/data-source/options/index.d.ts +0 -4
- package/dist/data-source/options/module.d.ts +0 -8
- package/dist/data-source/options/singleton.d.ts +0 -4
- package/dist/data-source/options/type.d.ts +0 -26
- package/dist/data-source/options/utils/env.d.ts +0 -4
- package/dist/data-source/options/utils/index.d.ts +0 -2
- package/dist/data-source/options/utils/merge.d.ts +0 -2
- package/dist/data-source/singleton.d.ts +0 -5
- package/dist/data-source/type.d.ts +0 -2
- package/dist/database/driver/cockroachdb.d.ts +0 -4
- package/dist/database/driver/index.d.ts +0 -9
- package/dist/database/driver/mongodb.d.ts +0 -6
- package/dist/database/driver/mssql.d.ts +0 -6
- package/dist/database/driver/mysql.d.ts +0 -7
- package/dist/database/driver/oracle.d.ts +0 -6
- package/dist/database/driver/postgres.d.ts +0 -8
- package/dist/database/driver/sqlite.d.ts +0 -3
- package/dist/database/driver/types.d.ts +0 -20
- package/dist/database/driver/utils/build.d.ts +0 -3
- package/dist/database/driver/utils/character-set.d.ts +0 -2
- package/dist/database/driver/utils/charset.d.ts +0 -2
- package/dist/database/driver/utils/create.d.ts +0 -2
- package/dist/database/driver/utils/index.d.ts +0 -4
- package/dist/database/index.d.ts +0 -3
- package/dist/database/methods/check/index.d.ts +0 -2
- package/dist/database/methods/check/module.d.ts +0 -7
- package/dist/database/methods/check/types.d.ts +0 -51
- package/dist/database/methods/create/index.d.ts +0 -1
- package/dist/database/methods/create/module.d.ts +0 -10
- package/dist/database/methods/drop/index.d.ts +0 -1
- package/dist/database/methods/drop/module.d.ts +0 -10
- package/dist/database/methods/index.d.ts +0 -4
- package/dist/database/methods/type.d.ts +0 -43
- package/dist/database/utils/context.d.ts +0 -3
- package/dist/database/utils/index.d.ts +0 -5
- package/dist/database/utils/migration.d.ts +0 -2
- package/dist/database/utils/query.d.ts +0 -3
- package/dist/database/utils/schema.d.ts +0 -3
- package/dist/database/utils/type.d.ts +0 -32
- package/dist/env/constants.d.ts +0 -68
- package/dist/env/index.d.ts +0 -3
- package/dist/env/module.d.ts +0 -4
- package/dist/env/type.d.ts +0 -36
- package/dist/env/utils.d.ts +0 -3
- package/dist/errors/base.d.ts +0 -2
- package/dist/errors/driver.d.ts +0 -6
- package/dist/errors/index.d.ts +0 -3
- package/dist/errors/options.d.ts +0 -7
- package/dist/helpers/entity/error.d.ts +0 -20
- package/dist/helpers/entity/index.d.ts +0 -5
- package/dist/helpers/entity/join-columns.d.ts +0 -16
- package/dist/helpers/entity/metadata.d.ts +0 -10
- package/dist/helpers/entity/property-names.d.ts +0 -11
- package/dist/helpers/entity/uniqueness.d.ts +0 -28
- package/dist/helpers/index.d.ts +0 -1
- package/dist/index.cjs +0 -3258
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/query/index.d.ts +0 -4
- package/dist/query/module.d.ts +0 -5
- package/dist/query/parameter/fields/index.d.ts +0 -2
- package/dist/query/parameter/fields/module.d.ts +0 -25
- package/dist/query/parameter/fields/type.d.ts +0 -6
- package/dist/query/parameter/filters/index.d.ts +0 -2
- package/dist/query/parameter/filters/module.d.ts +0 -35
- package/dist/query/parameter/filters/type.d.ts +0 -12
- package/dist/query/parameter/index.d.ts +0 -5
- package/dist/query/parameter/pagination/index.d.ts +0 -2
- package/dist/query/parameter/pagination/module.d.ts +0 -26
- package/dist/query/parameter/pagination/type.d.ts +0 -3
- package/dist/query/parameter/relations/index.d.ts +0 -2
- package/dist/query/parameter/relations/module.d.ts +0 -27
- package/dist/query/parameter/relations/type.d.ts +0 -8
- package/dist/query/parameter/sort/index.d.ts +0 -2
- package/dist/query/parameter/sort/module.d.ts +0 -26
- package/dist/query/parameter/sort/type.d.ts +0 -6
- package/dist/query/type.d.ts +0 -16
- package/dist/query/utils/alias.d.ts +0 -2
- package/dist/query/utils/index.d.ts +0 -3
- package/dist/query/utils/key.d.ts +0 -1
- package/dist/query/utils/option.d.ts +0 -1
- package/dist/seeder/entity.d.ts +0 -42
- package/dist/seeder/executor.d.ts +0 -24
- package/dist/seeder/factory/index.d.ts +0 -4
- package/dist/seeder/factory/manager.d.ts +0 -8
- package/dist/seeder/factory/module.d.ts +0 -17
- package/dist/seeder/factory/type.d.ts +0 -12
- package/dist/seeder/factory/utils.d.ts +0 -7
- package/dist/seeder/index.d.ts +0 -6
- package/dist/seeder/module.d.ts +0 -5
- package/dist/seeder/type.d.ts +0 -44
- package/dist/seeder/utils/file-path.d.ts +0 -7
- package/dist/seeder/utils/index.d.ts +0 -3
- package/dist/seeder/utils/prepare.d.ts +0 -2
- package/dist/seeder/utils/template.d.ts +0 -1
- package/dist/utils/code-transformation/constants.d.ts +0 -4
- package/dist/utils/code-transformation/index.d.ts +0 -2
- package/dist/utils/code-transformation/module.d.ts +0 -3
- package/dist/utils/entity.d.ts +0 -2
- package/dist/utils/file-path.d.ts +0 -9
- package/dist/utils/file-system.d.ts +0 -1
- package/dist/utils/has-property.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/object.d.ts +0 -2
- package/dist/utils/promise.d.ts +0 -1
- package/dist/utils/separator.d.ts +0 -3
- package/dist/utils/slash.d.ts +0 -2
- package/dist/utils/tsconfig/index.d.ts +0 -2
- package/dist/utils/tsconfig/module.d.ts +0 -2
- package/dist/utils/tsconfig/type.d.ts +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/typeorm-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-depup.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A library to create/drop database, simple seeding data sets, ... (with updated dependencies)",
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "Peter Placzek",
|
|
@@ -11,15 +12,18 @@
|
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "https://github.com/tada5hi/typeorm-extension.git"
|
|
13
14
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
15
|
+
"homepage": "https://typeorm-extension.tada5hi.net",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/tada5hi/typeorm-extension/issues"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.mjs",
|
|
20
|
+
"types": "dist/index.d.mts",
|
|
17
21
|
"exports": {
|
|
18
22
|
"./package.json": "./package.json",
|
|
19
23
|
".": {
|
|
20
|
-
"types": "./dist/index.d.
|
|
24
|
+
"types": "./dist/index.d.mts",
|
|
21
25
|
"import": "./dist/index.mjs",
|
|
22
|
-
"
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
23
27
|
},
|
|
24
28
|
"./bin/*": "./bin/*"
|
|
25
29
|
},
|
|
@@ -30,21 +34,20 @@
|
|
|
30
34
|
"README.md"
|
|
31
35
|
],
|
|
32
36
|
"engines": {
|
|
33
|
-
"node": "
|
|
37
|
+
"node": ">=22.0.0"
|
|
34
38
|
},
|
|
35
39
|
"scripts": {
|
|
36
|
-
"build
|
|
37
|
-
"build:
|
|
38
|
-
"build
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage",
|
|
43
|
-
"lint": "eslint --ext .js,.vue,.ts ./src ./test",
|
|
40
|
+
"build": "npm run build:types && npm run build:js",
|
|
41
|
+
"build:types": "tsc --noEmit",
|
|
42
|
+
"build:js": "tsdown",
|
|
43
|
+
"test": "vitest --config test/vitest.config.ts --run",
|
|
44
|
+
"test:coverage": "vitest --config test/vitest.config.ts --run --coverage",
|
|
45
|
+
"lint": "eslint",
|
|
44
46
|
"lint:fix": "npm run lint -- --fix",
|
|
45
47
|
"docs:dev": "vitepress dev docs --temp .temp",
|
|
46
48
|
"docs:build": "vitepress build docs --temp .temp",
|
|
47
|
-
"docs:help": "vitepress --help"
|
|
49
|
+
"docs:help": "vitepress --help",
|
|
50
|
+
"test:integration": "vitest --config test/vitest.integration.config.ts --run"
|
|
48
51
|
},
|
|
49
52
|
"keywords": [
|
|
50
53
|
"typeorm-extension",
|
|
@@ -65,70 +68,61 @@
|
|
|
65
68
|
"cli"
|
|
66
69
|
],
|
|
67
70
|
"bin": {
|
|
68
|
-
"typeorm-extension": "bin/cli.
|
|
69
|
-
"typeorm-extension-esm": "bin/cli.mjs"
|
|
71
|
+
"typeorm-extension": "bin/cli.mjs"
|
|
70
72
|
},
|
|
71
73
|
"license": "MIT",
|
|
72
74
|
"dependencies": {
|
|
73
|
-
"
|
|
75
|
+
"citty": "^0.2.2",
|
|
74
76
|
"envix": "^1.5.0",
|
|
75
|
-
"locter": "^
|
|
77
|
+
"locter": "^4.1.0",
|
|
76
78
|
"pascal-case": "^4.0.0",
|
|
77
|
-
"rapiq": "^1.0.0",
|
|
78
79
|
"reflect-metadata": "^0.2.2",
|
|
79
|
-
"smob": "^1.6.
|
|
80
|
-
"yargs": "^18.0.0"
|
|
80
|
+
"smob": "^1.6.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"
|
|
84
|
-
"typeorm": "~0.3.0"
|
|
83
|
+
"typeorm": "^1.1.0"
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
87
|
-
"@faker-js/faker": "^
|
|
88
|
-
"@
|
|
89
|
-
"@
|
|
90
|
-
"@tada5hi/
|
|
91
|
-
"@tada5hi/
|
|
92
|
-
"@
|
|
93
|
-
"@
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"eslint": "^8.56.0",
|
|
86
|
+
"@faker-js/faker": "^10.5.0",
|
|
87
|
+
"@swc/core": "^1.15.46",
|
|
88
|
+
"@tada5hi/commitlint-config": "^1.3.1",
|
|
89
|
+
"@tada5hi/eslint-config": "^2.3.1",
|
|
90
|
+
"@tada5hi/tsconfig": "^0.7.2",
|
|
91
|
+
"@types/node": "^25.9.1",
|
|
92
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
93
|
+
"better-sqlite3": "^12.11.1",
|
|
94
|
+
"eslint": "^10.8.0",
|
|
95
|
+
"eslint-plugin-vue": "^10.10.0",
|
|
98
96
|
"husky": "^9.1.7",
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
97
|
+
"mongodb": "^7.5.0",
|
|
98
|
+
"mssql": "^12.7.0",
|
|
99
|
+
"mysql2": "^3.23.2",
|
|
100
|
+
"oracledb": "^7.0.1",
|
|
101
|
+
"pg": "^8.22.0",
|
|
102
|
+
"tsdown": "^0.22.14",
|
|
103
|
+
"typeorm": "^1.1.0",
|
|
104
|
+
"typescript": "^6.0.3",
|
|
105
|
+
"typescript-eslint": "^8.65.0",
|
|
106
|
+
"unplugin-swc": "^1.5.9",
|
|
105
107
|
"vitepress": "^1.6.4",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
+
"vitest": "^4.1.5",
|
|
109
|
+
"vue": "^3.5.40"
|
|
108
110
|
},
|
|
109
111
|
"depup": {
|
|
110
112
|
"changes": {
|
|
111
|
-
"consola": {
|
|
112
|
-
"from": "^3.4.0",
|
|
113
|
-
"to": "^3.4.2"
|
|
114
|
-
},
|
|
115
113
|
"pascal-case": {
|
|
116
114
|
"from": "^3.1.2",
|
|
117
115
|
"to": "^4.0.0"
|
|
118
116
|
},
|
|
119
|
-
"rapiq": {
|
|
120
|
-
"from": "^0.9.0",
|
|
121
|
-
"to": "^1.0.0"
|
|
122
|
-
},
|
|
123
117
|
"smob": {
|
|
124
118
|
"from": "^1.5.0",
|
|
125
|
-
"to": "^1.6.
|
|
119
|
+
"to": "^1.6.2"
|
|
126
120
|
}
|
|
127
121
|
},
|
|
128
|
-
"depsUpdated":
|
|
122
|
+
"depsUpdated": 2,
|
|
129
123
|
"originalPackage": "typeorm-extension",
|
|
130
|
-
"originalVersion": "
|
|
131
|
-
"processedAt": "2026-
|
|
124
|
+
"originalVersion": "4.0.0",
|
|
125
|
+
"processedAt": "2026-08-16T00:31:05.785Z",
|
|
132
126
|
"smokeTest": "failed"
|
|
133
127
|
}
|
|
134
128
|
}
|
package/bin/cli.cjs
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
require('reflect-metadata');
|
|
5
|
-
var process$1 = require('node:process');
|
|
6
|
-
var yargs = require('yargs');
|
|
7
|
-
var helpers = require('yargs/helpers');
|
|
8
|
-
var consola = require('consola');
|
|
9
|
-
var typeormExtension = require('typeorm-extension');
|
|
10
|
-
var locter = require('locter');
|
|
11
|
-
var fs = require('node:fs');
|
|
12
|
-
var path = require('node:path');
|
|
13
|
-
var pascalCase = require('pascal-case');
|
|
14
|
-
|
|
15
|
-
class DatabaseCreateCommand {
|
|
16
|
-
builder(args) {
|
|
17
|
-
return args.option('preserveFilePaths', {
|
|
18
|
-
default: false,
|
|
19
|
-
type: 'boolean',
|
|
20
|
-
describe: 'This option indicates if file paths should be preserved.'
|
|
21
|
-
}).option('root', {
|
|
22
|
-
alias: 'r',
|
|
23
|
-
default: process.cwd(),
|
|
24
|
-
describe: 'Root directory of the project.'
|
|
25
|
-
}).option('tsconfig', {
|
|
26
|
-
alias: 'tc',
|
|
27
|
-
default: 'tsconfig.json',
|
|
28
|
-
describe: 'Name (or relative path incl. name) of the tsconfig file.'
|
|
29
|
-
}).option('dataSource', {
|
|
30
|
-
alias: 'd',
|
|
31
|
-
default: 'data-source',
|
|
32
|
-
describe: 'Name (or relative path incl. name) of the data-source file.'
|
|
33
|
-
}).option('synchronize', {
|
|
34
|
-
alias: 's',
|
|
35
|
-
default: 'yes',
|
|
36
|
-
describe: 'Create database schema for all entities.',
|
|
37
|
-
choices: [
|
|
38
|
-
'yes',
|
|
39
|
-
'no'
|
|
40
|
-
]
|
|
41
|
-
}).option('initialDatabase', {
|
|
42
|
-
describe: 'Specify the initial database to connect to.'
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
async handler(raw) {
|
|
46
|
-
const args = raw;
|
|
47
|
-
let tsconfig;
|
|
48
|
-
let sourcePath = typeormExtension.resolveFilePath(args.dataSource, args.root);
|
|
49
|
-
if (!args.preserveFilePaths) {
|
|
50
|
-
tsconfig = await typeormExtension.readTSConfig(typeormExtension.resolveFilePath(args.root, args.tsconfig));
|
|
51
|
-
sourcePath = await typeormExtension.adjustFilePath(sourcePath, tsconfig);
|
|
52
|
-
}
|
|
53
|
-
const source = typeormExtension.parseFilePath(sourcePath);
|
|
54
|
-
consola.consola.info(`DataSource Directory: ${source.directory}`);
|
|
55
|
-
consola.consola.info(`DataSource Name: ${source.name}`);
|
|
56
|
-
const dataSourceOptions = await typeormExtension.buildDataSourceOptions({
|
|
57
|
-
directory: source.directory,
|
|
58
|
-
dataSourceName: source.name,
|
|
59
|
-
tsconfig,
|
|
60
|
-
preserveFilePaths: args.preserveFilePaths
|
|
61
|
-
});
|
|
62
|
-
const context = {
|
|
63
|
-
ifNotExist: true,
|
|
64
|
-
options: dataSourceOptions,
|
|
65
|
-
synchronize: args.synchronize === 'yes'
|
|
66
|
-
};
|
|
67
|
-
if (typeof args.initialDatabase === 'string' && args.initialDatabase !== '') {
|
|
68
|
-
context.initialDatabase = args.initialDatabase;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
await typeormExtension.createDatabase(context);
|
|
72
|
-
consola.consola.success('Created database.');
|
|
73
|
-
process.exit(0);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
consola.consola.warn('Failed to create database.');
|
|
76
|
-
consola.consola.error(e);
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
constructor(){
|
|
81
|
-
this.command = 'db:create';
|
|
82
|
-
this.describe = 'Create database.';
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
class DatabaseDropCommand {
|
|
87
|
-
builder(args) {
|
|
88
|
-
return args.option('preserveFilePaths', {
|
|
89
|
-
default: false,
|
|
90
|
-
type: 'boolean',
|
|
91
|
-
describe: 'This option indicates if file paths should be preserved.'
|
|
92
|
-
}).option('root', {
|
|
93
|
-
alias: 'r',
|
|
94
|
-
default: process.cwd(),
|
|
95
|
-
describe: 'Root directory of the project.'
|
|
96
|
-
}).option('tsconfig', {
|
|
97
|
-
alias: 'tc',
|
|
98
|
-
default: 'tsconfig.json',
|
|
99
|
-
describe: 'Name (or relative path incl. name) of the tsconfig file.'
|
|
100
|
-
}).option('dataSource', {
|
|
101
|
-
alias: 'd',
|
|
102
|
-
default: 'data-source',
|
|
103
|
-
describe: 'Name (or relative path incl. name) of the data-source file.'
|
|
104
|
-
}).option('initialDatabase', {
|
|
105
|
-
describe: 'Specify the initial database to connect to.'
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
async handler(raw) {
|
|
109
|
-
const args = raw;
|
|
110
|
-
let tsconfig;
|
|
111
|
-
let sourcePath = typeormExtension.resolveFilePath(args.dataSource, args.root);
|
|
112
|
-
if (!args.preserveFilePaths) {
|
|
113
|
-
tsconfig = await typeormExtension.readTSConfig(typeormExtension.resolveFilePath(args.root, args.tsconfig));
|
|
114
|
-
sourcePath = await typeormExtension.adjustFilePath(sourcePath, tsconfig);
|
|
115
|
-
}
|
|
116
|
-
const source = typeormExtension.parseFilePath(sourcePath);
|
|
117
|
-
consola.consola.info(`DataSource Directory: ${source.directory}`);
|
|
118
|
-
consola.consola.info(`DataSource Name: ${source.name}`);
|
|
119
|
-
const dataSourceOptions = await typeormExtension.buildDataSourceOptions({
|
|
120
|
-
directory: source.directory,
|
|
121
|
-
dataSourceName: source.name,
|
|
122
|
-
tsconfig,
|
|
123
|
-
preserveFilePaths: args.preserveFilePaths
|
|
124
|
-
});
|
|
125
|
-
const context = {
|
|
126
|
-
ifExist: true,
|
|
127
|
-
options: dataSourceOptions
|
|
128
|
-
};
|
|
129
|
-
if (typeof args.initialDatabase === 'string' && args.initialDatabase !== '') {
|
|
130
|
-
context.initialDatabase = args.initialDatabase;
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
await typeormExtension.dropDatabase(context);
|
|
134
|
-
consola.consola.success('Dropped database.');
|
|
135
|
-
process.exit(0);
|
|
136
|
-
} catch (e) {
|
|
137
|
-
consola.consola.warn('Failed to drop database.');
|
|
138
|
-
consola.consola.error(e);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
constructor(){
|
|
143
|
-
this.command = 'db:drop';
|
|
144
|
-
this.describe = 'Drop database.';
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
class SeedCreateCommand {
|
|
149
|
-
builder(args) {
|
|
150
|
-
return args.option('root', {
|
|
151
|
-
alias: 'r',
|
|
152
|
-
default: process.cwd(),
|
|
153
|
-
describe: 'Root directory of the project.'
|
|
154
|
-
}).option('timestamp', {
|
|
155
|
-
alias: 't',
|
|
156
|
-
type: 'number',
|
|
157
|
-
describe: 'Custom timestamp for the seeder name.'
|
|
158
|
-
}).option('javascript', {
|
|
159
|
-
alias: 'j',
|
|
160
|
-
type: 'boolean',
|
|
161
|
-
default: false,
|
|
162
|
-
describe: 'Generate a seeder file for JavaScript instead of TypeScript.'
|
|
163
|
-
}).option('name', {
|
|
164
|
-
alias: 'n',
|
|
165
|
-
describe: 'Name (or relative path incl. name) of the seeder.',
|
|
166
|
-
demandOption: true
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
async handler(raw) {
|
|
170
|
-
const args = raw;
|
|
171
|
-
let timestamp;
|
|
172
|
-
if (Number.isNaN(args.timestamp) || !args.timestamp) {
|
|
173
|
-
timestamp = Date.now();
|
|
174
|
-
} else {
|
|
175
|
-
timestamp = args.timestamp;
|
|
176
|
-
}
|
|
177
|
-
const sourcePath = typeormExtension.parseFilePath(args.name, args.root);
|
|
178
|
-
const dirNameIsDirectory = await typeormExtension.isDirectory(sourcePath.directory);
|
|
179
|
-
if (!dirNameIsDirectory) {
|
|
180
|
-
consola.consola.warn(`The output directory ${sourcePath.directory} does not exist.`);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
const extension = args.javascript ? '.js' : '.ts';
|
|
184
|
-
const nameExtension = locter.getFileNameExtension(sourcePath.name);
|
|
185
|
-
const nameWithoutExtension = locter.removeFileNameExtension(sourcePath.name);
|
|
186
|
-
let fileName;
|
|
187
|
-
if (nameExtension) {
|
|
188
|
-
fileName = `${timestamp}-${sourcePath.name}`;
|
|
189
|
-
} else {
|
|
190
|
-
fileName = `${timestamp}-${sourcePath.name}${extension}`;
|
|
191
|
-
}
|
|
192
|
-
const filePath = sourcePath.directory + path.sep + fileName;
|
|
193
|
-
const template = typeormExtension.buildSeederFileTemplate(nameWithoutExtension, timestamp);
|
|
194
|
-
consola.consola.info(`Seed Directory: ${sourcePath.directory}`);
|
|
195
|
-
consola.consola.info(`Seed FileName: ${fileName}`);
|
|
196
|
-
consola.consola.info(`Seed Name: ${pascalCase.pascalCase(nameWithoutExtension)}`);
|
|
197
|
-
try {
|
|
198
|
-
await fs.promises.writeFile(filePath, template, {
|
|
199
|
-
encoding: 'utf-8'
|
|
200
|
-
});
|
|
201
|
-
} catch (e) {
|
|
202
|
-
consola.consola.warn(`The seed could not be written to the path ${filePath}.`);
|
|
203
|
-
process.exit(1);
|
|
204
|
-
}
|
|
205
|
-
process.exit(0);
|
|
206
|
-
}
|
|
207
|
-
constructor(){
|
|
208
|
-
this.command = 'seed:create';
|
|
209
|
-
this.describe = 'Create a seeder file.';
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
class SeedRunCommand {
|
|
214
|
-
builder(args) {
|
|
215
|
-
return args.option('preserveFilePaths', {
|
|
216
|
-
default: false,
|
|
217
|
-
type: 'boolean',
|
|
218
|
-
describe: 'This option indicates if file paths should be preserved.'
|
|
219
|
-
}).option('root', {
|
|
220
|
-
alias: 'r',
|
|
221
|
-
default: process.cwd(),
|
|
222
|
-
describe: 'Root directory of the project.'
|
|
223
|
-
}).option('tsconfig', {
|
|
224
|
-
alias: 'tc',
|
|
225
|
-
default: 'tsconfig.json',
|
|
226
|
-
describe: 'Name (or relative path incl. name) of the tsconfig file.'
|
|
227
|
-
}).option('dataSource', {
|
|
228
|
-
alias: 'd',
|
|
229
|
-
default: 'data-source',
|
|
230
|
-
describe: 'Name (or relative path incl. name) of the data-source file.'
|
|
231
|
-
}).option('name', {
|
|
232
|
-
alias: 'n',
|
|
233
|
-
describe: 'Name (or relative path incl. name) of the seeder.'
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
async handler(raw) {
|
|
237
|
-
const args = raw;
|
|
238
|
-
let tsconfig;
|
|
239
|
-
let sourcePath = typeormExtension.resolveFilePath(args.dataSource, args.root);
|
|
240
|
-
if (!args.preserveFilePaths) {
|
|
241
|
-
tsconfig = await typeormExtension.readTSConfig(args.root);
|
|
242
|
-
sourcePath = await typeormExtension.adjustFilePath(sourcePath, tsconfig);
|
|
243
|
-
args.name = await typeormExtension.adjustFilePath(args.name, tsconfig);
|
|
244
|
-
}
|
|
245
|
-
const source = typeormExtension.parseFilePath(sourcePath);
|
|
246
|
-
consola.consola.info(`DataSource Directory: ${source.directory}`);
|
|
247
|
-
consola.consola.info(`DataSource Name: ${source.name}`);
|
|
248
|
-
const dataSourceOptions = await typeormExtension.buildDataSourceOptions({
|
|
249
|
-
dataSourceName: source.name,
|
|
250
|
-
directory: source.directory,
|
|
251
|
-
tsconfig,
|
|
252
|
-
preserveFilePaths: args.preserveFilePaths
|
|
253
|
-
});
|
|
254
|
-
typeormExtension.setDataSourceOptions(dataSourceOptions);
|
|
255
|
-
if (args.name) {
|
|
256
|
-
consola.consola.info(`Seed Name: ${args.name}`);
|
|
257
|
-
}
|
|
258
|
-
const dataSource = await typeormExtension.useDataSource();
|
|
259
|
-
const executor = new typeormExtension.SeederExecutor(dataSource, {
|
|
260
|
-
root: args.root,
|
|
261
|
-
tsconfig,
|
|
262
|
-
preserveFilePaths: args.preserveFilePaths
|
|
263
|
-
});
|
|
264
|
-
await executor.execute({
|
|
265
|
-
seedName: args.name
|
|
266
|
-
});
|
|
267
|
-
process.exit(0);
|
|
268
|
-
}
|
|
269
|
-
constructor(){
|
|
270
|
-
this.command = 'seed:run';
|
|
271
|
-
this.describe = 'Populate the database with an initial data set or generated data by a factory.';
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
yargs(helpers.hideBin(process$1.argv)).scriptName('typeorm-extension').usage('Usage: $0 <command> [options]').demandCommand(1).command(new DatabaseCreateCommand()).command(new DatabaseDropCommand()).command(new SeedRunCommand()).command(new SeedCreateCommand()).strict().alias('v', 'version').help('h').alias('h', 'help').parse();
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Arguments, Argv, CommandModule } from 'yargs';
|
|
2
|
-
export interface DatabaseCreateArguments extends Arguments {
|
|
3
|
-
preserveFilePaths: boolean;
|
|
4
|
-
root: string;
|
|
5
|
-
tsconfig: string;
|
|
6
|
-
dataSource: string;
|
|
7
|
-
synchronize: string;
|
|
8
|
-
initialDatabase?: unknown;
|
|
9
|
-
}
|
|
10
|
-
export declare class DatabaseCreateCommand implements CommandModule {
|
|
11
|
-
command: string;
|
|
12
|
-
describe: string;
|
|
13
|
-
builder(args: Argv): Argv<{
|
|
14
|
-
preserveFilePaths: boolean;
|
|
15
|
-
} & {
|
|
16
|
-
root: string;
|
|
17
|
-
} & {
|
|
18
|
-
tsconfig: string;
|
|
19
|
-
} & {
|
|
20
|
-
dataSource: string;
|
|
21
|
-
} & {
|
|
22
|
-
synchronize: string;
|
|
23
|
-
} & {
|
|
24
|
-
initialDatabase: unknown;
|
|
25
|
-
}>;
|
|
26
|
-
handler(raw: Arguments): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Arguments, Argv, CommandModule } from 'yargs';
|
|
2
|
-
export interface DatabaseDropArguments extends Arguments {
|
|
3
|
-
preserveFilePaths: boolean;
|
|
4
|
-
root: string;
|
|
5
|
-
tsconfig: string;
|
|
6
|
-
dataSource: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class DatabaseDropCommand implements CommandModule {
|
|
9
|
-
command: string;
|
|
10
|
-
describe: string;
|
|
11
|
-
builder(args: Argv): Argv<{
|
|
12
|
-
preserveFilePaths: boolean;
|
|
13
|
-
} & {
|
|
14
|
-
root: string;
|
|
15
|
-
} & {
|
|
16
|
-
tsconfig: string;
|
|
17
|
-
} & {
|
|
18
|
-
dataSource: string;
|
|
19
|
-
} & {
|
|
20
|
-
initialDatabase: unknown;
|
|
21
|
-
}>;
|
|
22
|
-
handler(raw: Arguments): Promise<void>;
|
|
23
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Arguments, Argv, CommandModule } from 'yargs';
|
|
2
|
-
export interface SeedCreateArguments extends Arguments {
|
|
3
|
-
root: string;
|
|
4
|
-
javascript: boolean;
|
|
5
|
-
timestamp?: number;
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class SeedCreateCommand implements CommandModule {
|
|
9
|
-
command: string;
|
|
10
|
-
describe: string;
|
|
11
|
-
builder(args: Argv): Argv<{
|
|
12
|
-
root: string;
|
|
13
|
-
} & {
|
|
14
|
-
timestamp: number | undefined;
|
|
15
|
-
} & {
|
|
16
|
-
javascript: boolean;
|
|
17
|
-
} & {
|
|
18
|
-
name: unknown;
|
|
19
|
-
}>;
|
|
20
|
-
handler(raw: Arguments): Promise<void>;
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Arguments, Argv, CommandModule } from 'yargs';
|
|
2
|
-
export interface SeedRunArguments extends Arguments {
|
|
3
|
-
preserveFilePaths: boolean;
|
|
4
|
-
root: string;
|
|
5
|
-
tsconfig: string;
|
|
6
|
-
dataSource: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class SeedRunCommand implements CommandModule {
|
|
10
|
-
command: string;
|
|
11
|
-
describe: string;
|
|
12
|
-
builder(args: Argv): Argv<{
|
|
13
|
-
preserveFilePaths: boolean;
|
|
14
|
-
} & {
|
|
15
|
-
root: string;
|
|
16
|
-
} & {
|
|
17
|
-
tsconfig: string;
|
|
18
|
-
} & {
|
|
19
|
-
dataSource: string;
|
|
20
|
-
} & {
|
|
21
|
-
name: unknown;
|
|
22
|
-
}>;
|
|
23
|
-
handler(raw: Arguments): Promise<void>;
|
|
24
|
-
}
|
package/dist/cli/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { TSConfig } from '../../utils/tsconfig';
|
|
2
|
-
export type DataSourceFindOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* Directory where to look for DataSource files.
|
|
5
|
-
*/
|
|
6
|
-
directory?: string;
|
|
7
|
-
/**
|
|
8
|
-
* DataSource file name.
|
|
9
|
-
*/
|
|
10
|
-
fileName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* This option indicates if file paths should be preserved,
|
|
13
|
-
* and treated as if the just-in-time compilation environment is detected.
|
|
14
|
-
*/
|
|
15
|
-
preserveFilePaths?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Directory path to the tsconfig.json file
|
|
18
|
-
*
|
|
19
|
-
* Default: process.cwd() + path.sep + tsconfig.json
|
|
20
|
-
*/
|
|
21
|
-
tsconfig?: string | TSConfig;
|
|
22
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DataSourceOptions } from 'typeorm';
|
|
2
|
-
import type { DataSourceOptionsBuildContext } from './type';
|
|
3
|
-
/**
|
|
4
|
-
* Build DataSourceOptions from DataSource or from configuration.
|
|
5
|
-
*
|
|
6
|
-
* @param context
|
|
7
|
-
*/
|
|
8
|
-
export declare function buildDataSourceOptions(context?: DataSourceOptionsBuildContext): Promise<DataSourceOptions>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DataSourceOptions } from 'typeorm';
|
|
2
|
-
export declare function setDataSourceOptions(options: DataSourceOptions, alias?: string): void;
|
|
3
|
-
export declare function hasDataSourceOptions(alias?: string): boolean;
|
|
4
|
-
export declare function useDataSourceOptions(alias?: string): Promise<DataSourceOptions>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { TSConfig } from '../../utils/tsconfig';
|
|
2
|
-
export type DataSourceOptionsBuildContext = {
|
|
3
|
-
/**
|
|
4
|
-
* Data source file name without extension
|
|
5
|
-
*
|
|
6
|
-
* Default: data-source
|
|
7
|
-
*/
|
|
8
|
-
dataSourceName?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Directory where to find dataSource + config
|
|
11
|
-
*
|
|
12
|
-
* Default: process.cwd()
|
|
13
|
-
*/
|
|
14
|
-
directory?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Directory path to the tsconfig.json file
|
|
17
|
-
*
|
|
18
|
-
* Default: process.cwd() + path.sep + tsconfig.json
|
|
19
|
-
*/
|
|
20
|
-
tsconfig?: string | TSConfig;
|
|
21
|
-
/**
|
|
22
|
-
* This option indicates if file paths should be preserved,
|
|
23
|
-
* and treated as if the just-in-time compilation environment is detected.
|
|
24
|
-
*/
|
|
25
|
-
preserveFilePaths?: boolean;
|
|
26
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DataSourceOptions } from 'typeorm';
|
|
2
|
-
export declare function hasEnvDataSourceOptions(): boolean;
|
|
3
|
-
export declare function readDataSourceOptionsFromEnv(): DataSourceOptions | undefined;
|
|
4
|
-
export declare function mergeDataSourceOptionsWithEnv(options: DataSourceOptions): DataSourceOptions;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm';
|
|
2
|
-
export declare function setDataSource(dataSource: DataSource, alias?: string): void;
|
|
3
|
-
export declare function hasDataSource(alias?: string): boolean;
|
|
4
|
-
export declare function unsetDataSource(alias?: string): void;
|
|
5
|
-
export declare function useDataSource(alias?: string): Promise<DataSource>;
|