@elysiajs/openapi 1.3.8 → 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 +64 -45
- package/dist/gen/index.mjs +64 -45
- package/package.json +1 -1
package/dist/cjs/gen/index.js
CHANGED
|
@@ -49,54 +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
|
-
cwd: tmpRoot,
|
|
78
|
-
stdio: debug ? "inherit" : void 0
|
|
79
|
-
});
|
|
80
|
-
const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
|
|
81
|
-
const targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : (0, import_path.join)(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? (0, import_path.join)(tmpRoot, "dist", fileName);
|
|
82
|
-
if (!(0, import_fs.existsSync)(targetFile)) {
|
|
83
|
-
(0, import_fs.rmSync)((0, import_path.join)(tmpRoot, "tsconfig.json"));
|
|
84
|
-
console.warn(
|
|
85
|
-
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
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
|
+
}`
|
|
86
77
|
);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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)(
|
|
85
|
+
tmpRoot,
|
|
86
|
+
"dist",
|
|
87
|
+
// remove leading like src or something similar
|
|
88
|
+
fileName.slice(fileName.indexOf("/") + 1)
|
|
89
|
+
);
|
|
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
|
+
}
|
|
97
116
|
}
|
|
117
|
+
return;
|
|
98
118
|
}
|
|
99
|
-
return;
|
|
100
119
|
}
|
|
101
120
|
const declaration = (0, import_fs.readFileSync)(targetFile, "utf8");
|
|
102
121
|
if ((0, import_fs.existsSync)(tmpRoot))
|
package/dist/gen/index.mjs
CHANGED
|
@@ -32,54 +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
|
-
cwd: tmpRoot,
|
|
61
|
-
stdio: debug ? "inherit" : void 0
|
|
62
|
-
});
|
|
63
|
-
const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
|
|
64
|
-
const targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : join(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? join(tmpRoot, "dist", fileName);
|
|
65
|
-
if (!existsSync(targetFile)) {
|
|
66
|
-
rmSync(join(tmpRoot, "tsconfig.json"));
|
|
67
|
-
console.warn(
|
|
68
|
-
"[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
|
|
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
|
+
}`
|
|
69
60
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
68
|
+
tmpRoot,
|
|
69
|
+
"dist",
|
|
70
|
+
// remove leading like src or something similar
|
|
71
|
+
fileName.slice(fileName.indexOf("/") + 1)
|
|
72
|
+
);
|
|
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
|
+
}
|
|
80
99
|
}
|
|
100
|
+
return;
|
|
81
101
|
}
|
|
82
|
-
return;
|
|
83
102
|
}
|
|
84
103
|
const declaration = readFileSync(targetFile, "utf8");
|
|
85
104
|
if (existsSync(tmpRoot))
|