@midwayjs/typeorm 3.9.0 → 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.
Files changed (2) hide show
  1. package/cli.js +42 -0
  2. package/package.json +7 -3
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,17 +1,21 @@
1
1
  {
2
2
  "name": "@midwayjs/typeorm",
3
- "version": "3.9.0",
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
16
  "@midwayjs/core": "^3.9.0",
13
17
  "@midwayjs/mock": "^3.9.0",
14
- "sqlite3": "5.1.2",
18
+ "sqlite3": "5.1.4",
15
19
  "typeorm": "0.3.11"
16
20
  },
17
21
  "author": {
@@ -31,5 +35,5 @@
31
35
  "type": "git",
32
36
  "url": "https://github.com/midwayjs/midway.git"
33
37
  },
34
- "gitHead": "5f6603d2c9606fc6fc7ece71f956e89e394efeee"
38
+ "gitHead": "3cd5d856789433bcfab6bcdce87743035176c878"
35
39
  }