@elysiajs/openapi 1.3.9 → 1.3.10
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/cjs/gen/index.js +62 -58
- package/dist/gen/index.mjs +62 -58
- package/package.json +1 -1
package/dist/cjs/gen/index.js
CHANGED
|
@@ -49,69 +49,73 @@ var fromTypes = (targetFilePath, {
|
|
|
49
49
|
throw new Error(
|
|
50
50
|
`Couldn't find "${targetFilePath}" from ${projectRoot}`
|
|
51
51
|
);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(0, import_path.join)(
|
|
59
|
-
`{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
fileName.slice(fileName.indexOf("/") + 1)
|
|
86
|
-
);
|
|
87
|
-
let existed = (0, import_fs.existsSync)(targetFile);
|
|
88
|
-
if (!existed && overrideOutputPath) {
|
|
89
|
-
targetFile = (0, import_path.join)(
|
|
52
|
+
let targetFile;
|
|
53
|
+
if (targetFilePath.endsWith(".d.ts")) targetFile = targetFilePath;
|
|
54
|
+
else {
|
|
55
|
+
if ((0, import_fs.existsSync)(tmpRoot))
|
|
56
|
+
(0, import_fs.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
57
|
+
(0, import_fs.mkdirSync)(tmpRoot, { recursive: true });
|
|
58
|
+
const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : (0, import_path.join)(projectRoot, tsconfigPath);
|
|
59
|
+
const extendsRef = (0, import_fs.existsSync)(tsconfig) ? `"extends": "${(0, import_path.join)(projectRoot, "tsconfig.json")}",` : "";
|
|
60
|
+
(0, import_fs.writeFileSync)(
|
|
61
|
+
(0, import_path.join)(tmpRoot, "tsconfig.json"),
|
|
62
|
+
`{
|
|
63
|
+
${extendsRef}
|
|
64
|
+
"compilerOptions": {
|
|
65
|
+
"lib": ["ESNext"],
|
|
66
|
+
"module": "ESNext",
|
|
67
|
+
"noEmit": false,
|
|
68
|
+
"declaration": true,
|
|
69
|
+
"emitDeclarationOnly": true,
|
|
70
|
+
"moduleResolution": "bundler",
|
|
71
|
+
"skipLibCheck": true,
|
|
72
|
+
"skipDefaultLibCheck": true,
|
|
73
|
+
"outDir": "./dist"
|
|
74
|
+
},
|
|
75
|
+
"include": ["${src}"]
|
|
76
|
+
}`
|
|
77
|
+
);
|
|
78
|
+
(0, import_child_process.spawnSync)(`tsc`, {
|
|
79
|
+
shell: true,
|
|
80
|
+
cwd: tmpRoot,
|
|
81
|
+
stdio: debug ? "inherit" : void 0
|
|
82
|
+
});
|
|
83
|
+
const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
|
|
84
|
+
targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : (0, import_path.join)(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? (0, import_path.join)(
|
|
90
85
|
tmpRoot,
|
|
91
86
|
"dist",
|
|
92
|
-
//
|
|
93
|
-
fileName
|
|
94
|
-
);
|
|
95
|
-
existed = (0, import_fs.existsSync)(targetFile);
|
|
96
|
-
}
|
|
97
|
-
if (!existed) {
|
|
98
|
-
(0, import_fs.rmSync)((0, import_path.join)(tmpRoot, "tsconfig.json"));
|
|
99
|
-
console.warn(
|
|
100
|
-
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
87
|
+
// remove leading like src or something similar
|
|
88
|
+
fileName.slice(fileName.indexOf("/") + 1)
|
|
101
89
|
);
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
let existed = (0, import_fs.existsSync)(targetFile);
|
|
91
|
+
if (!existed && !overrideOutputPath) {
|
|
92
|
+
targetFile = (0, import_path.join)(
|
|
93
|
+
tmpRoot,
|
|
94
|
+
"dist",
|
|
95
|
+
// use original file name as-is eg. in monorepo
|
|
96
|
+
fileName
|
|
97
|
+
);
|
|
98
|
+
existed = (0, import_fs.existsSync)(targetFile);
|
|
99
|
+
}
|
|
100
|
+
if (!existed) {
|
|
101
|
+
(0, import_fs.rmSync)((0, import_path.join)(tmpRoot, "tsconfig.json"));
|
|
102
|
+
console.warn(
|
|
103
|
+
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
104
|
+
);
|
|
105
|
+
console.warn("Couldn't find generated declaration file");
|
|
106
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(tmpRoot, "dist"))) {
|
|
107
|
+
const tempFiles = (0, import_fs.readdirSync)((0, import_path.join)(tmpRoot, "dist"), {
|
|
108
|
+
recursive: true
|
|
109
|
+
}).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
|
|
110
|
+
if (tempFiles) {
|
|
111
|
+
console.warn(
|
|
112
|
+
"You can override with `overrideOutputPath` with one of the following:"
|
|
113
|
+
);
|
|
114
|
+
console.warn(tempFiles);
|
|
115
|
+
}
|
|
112
116
|
}
|
|
117
|
+
return;
|
|
113
118
|
}
|
|
114
|
-
return;
|
|
115
119
|
}
|
|
116
120
|
const declaration = (0, import_fs.readFileSync)(targetFile, "utf8");
|
|
117
121
|
if ((0, import_fs.existsSync)(tmpRoot))
|
package/dist/gen/index.mjs
CHANGED
|
@@ -32,69 +32,73 @@ var fromTypes = (targetFilePath, {
|
|
|
32
32
|
throw new Error(
|
|
33
33
|
`Couldn't find "${targetFilePath}" from ${projectRoot}`
|
|
34
34
|
);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
`{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
fileName.slice(fileName.indexOf("/") + 1)
|
|
69
|
-
);
|
|
70
|
-
let existed = existsSync(targetFile);
|
|
71
|
-
if (!existed && overrideOutputPath) {
|
|
72
|
-
targetFile = join(
|
|
35
|
+
let targetFile;
|
|
36
|
+
if (targetFilePath.endsWith(".d.ts")) targetFile = targetFilePath;
|
|
37
|
+
else {
|
|
38
|
+
if (existsSync(tmpRoot))
|
|
39
|
+
rmSync(tmpRoot, { recursive: true, force: true });
|
|
40
|
+
mkdirSync(tmpRoot, { recursive: true });
|
|
41
|
+
const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : join(projectRoot, tsconfigPath);
|
|
42
|
+
const extendsRef = existsSync(tsconfig) ? `"extends": "${join(projectRoot, "tsconfig.json")}",` : "";
|
|
43
|
+
writeFileSync(
|
|
44
|
+
join(tmpRoot, "tsconfig.json"),
|
|
45
|
+
`{
|
|
46
|
+
${extendsRef}
|
|
47
|
+
"compilerOptions": {
|
|
48
|
+
"lib": ["ESNext"],
|
|
49
|
+
"module": "ESNext",
|
|
50
|
+
"noEmit": false,
|
|
51
|
+
"declaration": true,
|
|
52
|
+
"emitDeclarationOnly": true,
|
|
53
|
+
"moduleResolution": "bundler",
|
|
54
|
+
"skipLibCheck": true,
|
|
55
|
+
"skipDefaultLibCheck": true,
|
|
56
|
+
"outDir": "./dist"
|
|
57
|
+
},
|
|
58
|
+
"include": ["${src}"]
|
|
59
|
+
}`
|
|
60
|
+
);
|
|
61
|
+
spawnSync(`tsc`, {
|
|
62
|
+
shell: true,
|
|
63
|
+
cwd: tmpRoot,
|
|
64
|
+
stdio: debug ? "inherit" : void 0
|
|
65
|
+
});
|
|
66
|
+
const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
|
|
67
|
+
targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : join(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? join(
|
|
73
68
|
tmpRoot,
|
|
74
69
|
"dist",
|
|
75
|
-
//
|
|
76
|
-
fileName
|
|
77
|
-
);
|
|
78
|
-
existed = existsSync(targetFile);
|
|
79
|
-
}
|
|
80
|
-
if (!existed) {
|
|
81
|
-
rmSync(join(tmpRoot, "tsconfig.json"));
|
|
82
|
-
console.warn(
|
|
83
|
-
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
70
|
+
// remove leading like src or something similar
|
|
71
|
+
fileName.slice(fileName.indexOf("/") + 1)
|
|
84
72
|
);
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
let existed = existsSync(targetFile);
|
|
74
|
+
if (!existed && !overrideOutputPath) {
|
|
75
|
+
targetFile = join(
|
|
76
|
+
tmpRoot,
|
|
77
|
+
"dist",
|
|
78
|
+
// use original file name as-is eg. in monorepo
|
|
79
|
+
fileName
|
|
80
|
+
);
|
|
81
|
+
existed = existsSync(targetFile);
|
|
82
|
+
}
|
|
83
|
+
if (!existed) {
|
|
84
|
+
rmSync(join(tmpRoot, "tsconfig.json"));
|
|
85
|
+
console.warn(
|
|
86
|
+
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
87
|
+
);
|
|
88
|
+
console.warn("Couldn't find generated declaration file");
|
|
89
|
+
if (existsSync(join(tmpRoot, "dist"))) {
|
|
90
|
+
const tempFiles = readdirSync(join(tmpRoot, "dist"), {
|
|
91
|
+
recursive: true
|
|
92
|
+
}).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
|
|
93
|
+
if (tempFiles) {
|
|
94
|
+
console.warn(
|
|
95
|
+
"You can override with `overrideOutputPath` with one of the following:"
|
|
96
|
+
);
|
|
97
|
+
console.warn(tempFiles);
|
|
98
|
+
}
|
|
95
99
|
}
|
|
100
|
+
return;
|
|
96
101
|
}
|
|
97
|
-
return;
|
|
98
102
|
}
|
|
99
103
|
const declaration = readFileSync(targetFile, "utf8");
|
|
100
104
|
if (existsSync(tmpRoot))
|