@karry.sun/yapi-gen 0.2.5 → 0.2.6
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/run.d.ts.map +1 -1
- package/dist/run.js +8 -10
- package/package.json +1 -1
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AA0IA,wBAAgB,GAAG,CAAC,OAAO,GAAE;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACZ,GAAG,MAAM,CAqFd"}
|
package/dist/run.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawnSync } from 'child_process';
|
|
7
7
|
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
8
|
-
import { resolve, dirname,
|
|
8
|
+
import { resolve, dirname, join } from 'path';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
@@ -51,21 +51,19 @@ function findConfig(cwd) {
|
|
|
51
51
|
function getWrapperContent(cwd, configPath) {
|
|
52
52
|
const packageName = getPackageName();
|
|
53
53
|
const absoluteConfig = resolve(cwd, configPath);
|
|
54
|
-
const
|
|
55
|
-
const configBase = basename(absoluteConfig).replace(/\.[^.]+$/, '') || 'yapi-gen.config';
|
|
56
|
-
const wrapperDir = resolve(cwd, WRAPPER_DIR);
|
|
57
|
-
const rel = relative(wrapperDir, configDir).replace(/\\/g, '/');
|
|
58
|
-
const relativeImport = (rel ? rel + '/' : '') + configBase;
|
|
54
|
+
const configPathEscaped = JSON.stringify(absoluteConfig);
|
|
59
55
|
return `/* 由 yapi-gen 自动生成,请勿修改 */
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const { defineConfig } = require('yapi-to-typescript');
|
|
57
|
+
const { resolveConfig } = require('${packageName}');
|
|
58
|
+
const { createRequire } = require('module');
|
|
62
59
|
|
|
63
|
-
const
|
|
60
|
+
const require = createRequire(__filename);
|
|
61
|
+
const userConfig = require(${configPathEscaped});
|
|
64
62
|
const raw = userConfig.default ?? userConfig;
|
|
65
63
|
const configList = Array.isArray(raw) ? raw : [raw];
|
|
66
64
|
const resolvedList = configList.map((c) => resolveConfig(c, process.cwd()));
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
module.exports = { default: defineConfig(resolvedList) };
|
|
69
67
|
`;
|
|
70
68
|
}
|
|
71
69
|
function runInit(cwd) {
|