mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-11 09:11:50 +00:00
Many configuration files in this repository were created a long time ago, then were modified as problems occurred. Now that there is TypeScript support, it makes sense to clean up this mess, at least by making small steps. This configuration is based on strict settings, but most of these are currently disabled - otherwise it would be too hard to work with existing JavaScript code. The downside of this change is pollution of files with warnings and errors, even though they are valid. - ESLint/TypeScript upgraded - TS configuration is now shared between arbitrary Node scripts, Gulp files and the Electron wrapper - A few eslint-disable comments are removed
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import path from "path/posix";
|
|
import fs from "fs/promises";
|
|
import gulp from "gulp";
|
|
|
|
import gulpRename from "gulp-rename";
|
|
import stripJsonComments from "strip-json-comments";
|
|
|
|
export function convertJsToTs() {
|
|
return gulp
|
|
.src(path.join("..", "src", "js", "**", "*.js"))
|
|
.pipe(
|
|
gulpRename(path => {
|
|
path.extname = ".ts";
|
|
})
|
|
)
|
|
.pipe(gulp.dest(path.join("..", "tsc_temp")));
|
|
}
|
|
|
|
export async function copyTsconfigForHints() {
|
|
const src = (await fs.readFile(path.join("..", "src", "tsconfig.json"))).toString();
|
|
const baseConfig = JSON.parse(stripJsonComments(src));
|
|
|
|
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));
|
|
}
|
|
|
|
export const prepareDocs = gulp.series(convertJsToTs, copyTsconfigForHints);
|