2022-12-03 04:23:18 +00:00
|
|
|
import path from "path/posix";
|
2024-04-24 21:30:01 +00:00
|
|
|
import fs from "fs/promises";
|
|
|
|
|
import gulp from "gulp";
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2022-12-03 04:23:18 +00:00
|
|
|
import gulpRename from "gulp-rename";
|
|
|
|
|
import stripJsonComments from "strip-json-comments";
|
|
|
|
|
|
2024-04-24 21:30:01 +00:00
|
|
|
export function convertJsToTs() {
|
|
|
|
|
return gulp
|
|
|
|
|
.src(path.join("..", "src", "js", "**", "*.js"))
|
|
|
|
|
.pipe(
|
|
|
|
|
gulpRename(path => {
|
|
|
|
|
path.extname = ".ts";
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.pipe(gulp.dest(path.join("..", "tsc_temp")));
|
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2024-04-24 21:30:01 +00:00
|
|
|
export async function copyTsconfigForHints() {
|
2024-04-26 21:23:34 +00:00
|
|
|
const src = (await fs.readFile(path.join("..", "src", "tsconfig.json"))).toString();
|
2024-04-24 21:30:01 +00:00
|
|
|
const baseConfig = JSON.parse(stripJsonComments(src));
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2024-04-24 21:30:01 +00:00
|
|
|
baseConfig.allowJs = false;
|
|
|
|
|
baseConfig.checkJs = false;
|
|
|
|
|
baseConfig.declaration = true;
|
|
|
|
|
baseConfig.noEmit = false;
|
|
|
|
|
baseConfig.strict = false;
|
|
|
|
|
baseConfig.strictFunctionTypes = false;
|
|
|
|
|
baseConfig.strictBindCallApply = false;
|
|
|
|
|
baseConfig.alwaysStrict = false;
|
|
|
|
|
baseConfig.composite = true;
|
|
|
|
|
baseConfig.outFile = "bundled-ts.js";
|
|
|
|
|
await fs.writeFile(path.join("..", "tsc_temp", "tsconfig.json"), JSON.stringify(baseConfig));
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2024-04-24 21:30:01 +00:00
|
|
|
|
|
|
|
|
export const prepareDocs = gulp.series(convertJsToTs, copyTsconfigForHints);
|