get rid of gulp

This commit is contained in:
skillbert
2022-06-07 19:50:11 +02:00
parent de56d2f347
commit fb86592cf3
8 changed files with 49 additions and 6180 deletions

View File

@@ -1,5 +1,5 @@
// GENERATED DO NOT EDIT
// This source data is located at '..\src\opcodes\achievements.json'
// This source data is located at '..\src\opcodes\achievements.jsonc'
// run `npm run filetypes` to rebuild
export type achievements = {
@@ -63,6 +63,7 @@ export type achievements = {
achievement: number,
}[] | null
subcategory?: number | null
unk0x11?: true | null
hidden?: number | null
f2p?: true | null
quest_req_for_miniquests?: number[] | null

2
generated/npcs.d.ts vendored
View File

@@ -1,5 +1,5 @@
// GENERATED DO NOT EDIT
// This source data is located at '..\src\opcodes\npcs.json'
// This source data is located at '..\src\opcodes\npcs.jsonc'
// run `npm run filetypes` to rebuild
export type npcs = {

View File

@@ -1,5 +1,5 @@
// GENERATED DO NOT EDIT
// This source data is located at '..\src\opcodes\objects.json'
// This source data is located at '..\src\opcodes\objects.jsonc'
// run `npm run filetypes` to rebuild
export type objects = {
@@ -152,7 +152,7 @@ export type objects = {
} | null
singleuse_CA?: number | null
unknown_CB?: true | null
unknown_CC?: Uint8Array | null
unknown_CC?: Uint8Array[] | null
extra?: {
prop: number,
intvalue: number | null,

View File

@@ -1,87 +0,0 @@
var gulp = require('gulp');
var child_process = require("child_process");
var through2 = require('through2');
var commentjson = require("comment-json");
const outdir = 'dist/';
const generateddir = 'generated/';
const opcodesglob = 'src/opcodes/*.{json,jsonc}';
const assetsglob = 'src/assets/*';
//gulp-typescript hasn't been updated in 2 years and does not support incremental builds anymore
// var ts = require('gulp-typescript');
// var tsProject = ts.createProject('tsconfig.json');
// gulp.task('typescript', function () {
// return gulp.src('src/**/*.ts')
// .pipe(tsProject())
// .pipe(gulp.dest(outdir));
// });
function generateOpcodeTypes() {
return through2.obj(function (file, _, cb) {
if (file.isBuffer()) {
const opcode_reader = require("./dist/opcode_reader");
const fs = require("fs");
const path = require("path");
const opcodes = commentjson.parse(file.contents.toString(), undefined, true);
const typedef = commentjson.parse(fs.readFileSync(file.dirname + "/typedef.json", "utf-8"), undefined, true);
var typesfile =
"// GENERATED DO NOT EDIT\n" +
"// This source data is located at '" + path.relative(generateddir, file.path) + "'\n" +
"// run `npm run filetypes` to rebuild\n\n";
typesfile += "export type " + file.stem + " = ";
try {
typesfile += opcode_reader.buildParser(opcodes, typedef).getTypescriptType("") + ";\n";
} catch (e) {
//console.error(e);
typesfile += "any;\n";
typesfile += "// " + e.toString().replace(/\n/g, "\n//");
}
//I'm sorry, git made me do this
typesfile = typesfile.replace(/(?<!\r)\n/g, "\r\n");
file.contents = Buffer.from(typesfile);
file.extname = ".d.ts";
}
cb(null, file);
})
}
gulp.task('filetypes', function () {
return gulp.src([opcodesglob], { since: gulp.lastRun("filetypes") })
.pipe(generateOpcodeTypes())
.pipe(gulp.dest(generateddir));
});
gulp.task('assets', function () {
return gulp.src([assetsglob, opcodesglob], { base: "src", since: gulp.lastRun("assets") })
.pipe(gulp.dest(outdir))
});
gulp.task('nontypescript', gulp.parallel('assets', 'filetypes'));
gulp.task('default', gulp.series(
gulp.task("nontypescript"),
function typescript(cb) { runTypescript(false, cb); }
));
function runTypescript(watch, donecb) {
//https://stackoverflow.com/questions/17516772/using-nodejss-spawn-causes-unknown-option-and-error-spawn-enoent-err/17537559#17537559
var npm = (process.platform === "win32" ? "npm.cmd" : "npm");
var args = ["run", "ts"];
if (watch) { args.push("--", "--watch"); }
const ts = child_process.spawn(npm, args);
//this basically hijacks the console window but i don't care about gulp anymore
ts.stdout.on('data', function (data) { process.stdout.write(data); });
ts.stderr.on('data', function (data) { process.stderr.write(data); });
ts.on('exit', function (code) {
console.log("tsc stopped", code);
if (donecb) {
donecb(code);
}
});
}
gulp.task('watch', function () {
runTypescript(true);
return gulp.watch([assetsglob, opcodesglob], { ignoreInitial: false }, gulp.task('nontypescript'),);
});

6087
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,7 @@
"@types/three": "^0.133.1",
"@types/webpack-env": "^1.16.3",
"@types/wicg-file-system-access": "^2020.9.5",
"@types/sql.js": "^1.4.3",
"assert": "^2.0.0",
"autobind-decorator": "^2.4.0",
"browserify-zlib": "^0.2.0",
@@ -36,11 +37,8 @@
"electron": "^18.2.3",
"electron-rebuild": "^3.2.7",
"file-loader": "^6.2.0",
"gulp": "^4.0.2",
"gulp-cli": "^2.3.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"through2": "^4.0.2",
"ts-loader": "^9.2.8",
"typescript": "^4.7.0-beta",
"util": "^0.12.4",
@@ -49,7 +47,6 @@
"webpack-dev-server": "^4.7.4"
},
"dependencies": {
"@types/sql.js": "^1.4.3",
"bzip2": "^0.1.1",
"classnames": "^2.3.1",
"cmd-ts": "^0.7.0",

40
src/buildfiletypes.ts Normal file
View File

@@ -0,0 +1,40 @@
import * as fs from "fs";
import * as path from "path";
import * as opcode_reader from "./opcode_reader";
import * as commentjson from "comment-json";
async function buildFileTypes() {
let basedir = path.resolve("./src/opcodes");
let outdir = path.resolve("./generated");
let files = fs.readdirSync(basedir);
if (files.some(f => !path.basename(f).match(/\.jsonc?$/))) {
console.error("non-json files matched, is path wrong?");
}
const typedef = commentjson.parse(fs.readFileSync(path.resolve(basedir, "typedef.json"), "utf-8"), undefined, true);
for (let file of files) {
let srcfile = path.resolve(basedir, file);
let objname = path.parse(srcfile).name;
let jsontext = fs.readFileSync(srcfile, "utf8");
const opcodes = commentjson.parse(jsontext, undefined, true);
var typesfile =
"// GENERATED DO NOT EDIT\n" +
"// This source data is located at '" + path.relative(outdir, srcfile) + "'\n" +
"// run `npm run filetypes` to rebuild\n\n";
typesfile += "export type " + objname + " = ";
try {
typesfile += opcode_reader.buildParser(opcodes as any, typedef as any).getTypescriptType("") + ";\n";
} catch (e) {
//console.error(e);
typesfile += "any;\n";
typesfile += "// " + e.toString().replace(/\n/g, "\n//");
}
//I'm sorry, git made me do this
typesfile = typesfile.replace(/(?<!\r)\n/g, "\r\n");
let outfile = path.resolve(outdir, objname + ".d.ts");
fs.writeFileSync(outfile, typesfile);
}
}
buildFileTypes();

View File

@@ -13,6 +13,7 @@ module.exports = {
cli: "./src/cli.ts",
// opcode_reader: "./src/opcode_reader.ts",
// searchmap: "./src/scripts/searchmap.ts",
buildfiletypes: "./src/buildfiletypes.ts",
maprender: "./src/map/",
runmap: "./src/map/run.ts"
},