@midwayjs/typeorm 3.8.3 → 3.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/cli.js +42 -0
- package/package.json +10 -6
package/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { join } = require('path');
|
|
5
|
+
// eslint-disable-next-line node/no-unpublished-require
|
|
6
|
+
const { CommandUtils } = require('typeorm/commands/CommandUtils');
|
|
7
|
+
// eslint-disable-next-line node/no-unpublished-require
|
|
8
|
+
const ImportUtils = require('typeorm/util/ImportUtils');
|
|
9
|
+
// eslint-disable-next-line node/no-unpublished-require
|
|
10
|
+
const { DataSource } = require('typeorm');
|
|
11
|
+
|
|
12
|
+
CommandUtils.loadDataSource = async function (dataSourceFilePath) {
|
|
13
|
+
try {
|
|
14
|
+
let dataSourceFileExports = await ImportUtils.importOrRequireFile(
|
|
15
|
+
dataSourceFilePath
|
|
16
|
+
);
|
|
17
|
+
if (dataSourceFileExports[0] && dataSourceFileExports[0].default) {
|
|
18
|
+
dataSourceFileExports = dataSourceFileExports[0].default;
|
|
19
|
+
if (typeof dataSourceFileExports === 'function') {
|
|
20
|
+
dataSourceFileExports = dataSourceFileExports({
|
|
21
|
+
appDir: process.cwd(),
|
|
22
|
+
baseDir: join(process.cwd(), 'src'),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (dataSourceFileExports['typeorm']) {
|
|
26
|
+
dataSourceFileExports = dataSourceFileExports['typeorm'];
|
|
27
|
+
dataSourceFileExports =
|
|
28
|
+
dataSourceFileExports.dataSource[
|
|
29
|
+
dataSourceFileExports['defaultClientName'] || 'default'
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return new DataSource(dataSourceFileExports);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Unable to open file: "${dataSourceFilePath}". ${err.message}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line node/no-unpublished-require
|
|
42
|
+
require('typeorm/cli');
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typeorm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mwtypeorm": "./cli.js"
|
|
8
|
+
},
|
|
6
9
|
"files": [
|
|
7
10
|
"dist/**/*.js",
|
|
8
11
|
"dist/**/*.d.ts",
|
|
12
|
+
"cli.js",
|
|
9
13
|
"index.d.ts"
|
|
10
14
|
],
|
|
11
15
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^3.
|
|
13
|
-
"@midwayjs/mock": "^3.
|
|
14
|
-
"sqlite3": "5.1.
|
|
15
|
-
"typeorm": "0.3.
|
|
16
|
+
"@midwayjs/core": "^3.9.0",
|
|
17
|
+
"@midwayjs/mock": "^3.9.0",
|
|
18
|
+
"sqlite3": "5.1.4",
|
|
19
|
+
"typeorm": "0.3.11"
|
|
16
20
|
},
|
|
17
21
|
"author": {
|
|
18
22
|
"name": "czy88840616",
|
|
@@ -31,5 +35,5 @@
|
|
|
31
35
|
"type": "git",
|
|
32
36
|
"url": "https://github.com/midwayjs/midway.git"
|
|
33
37
|
},
|
|
34
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3cd5d856789433bcfab6bcdce87743035176c878"
|
|
35
39
|
}
|