Skip to content

Commit

Permalink
fix more build
Browse files Browse the repository at this point in the history
  • Loading branch information
hUwUtao committed Oct 18, 2024
1 parent de23fcb commit 74c7653
Show file tree
Hide file tree
Showing 7 changed files with 2,219 additions and 2,454 deletions.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ all: clean release
preview: dist/tfh.base.zip on/finish
release: dist/tfh_dist.zip

node_modules:
pnpm i -d
dist/packsquash:
sh scripts/getsquash
dist/tfh.base.zip: node_modules
pnpm build
dist/tfh.base.zip:
deno task build
dist/tfh_dist.zip: dist/packsquash dist/tfh.base.zip
dist/packsquash packsquash.toml
on/finish:
@[ -f trigger_finish.sh ] && sh trigger_finish.sh
clean:
rm -rvf \
node_modules \
dist \
assets/decals \
assets/minecraft/models/item/paper.json
2,835 changes: 424 additions & 2,411 deletions deno.lock

Large diffs are not rendered by default.

61 changes: 34 additions & 27 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
* @description Minecraft resourcepack production-ready compilation tool
* @author stdpi
*/
module.exports = {};

const gulp = require("node:gulp"),
{ task } = require("node:gulp"),
{ series } = require("node:async"),
zip = require("gulp-zip"),
del = require("del"),
{ relative } = require("node:path"),
sharp = require("sharp"),
{ readFileSync, readdirSync, writeFile } = require("node:fs"),
ReadableStream = require("node:stream").Readable;
import { src, dest } from "gulp";
import { task } from "gulp";
import { series } from "async";
import { default as zip } from "gulp-zip";
import { deleteAsync } from "del";
import { relative } from "node:path";
import sharp from "sharp";
import { readFileSync, readdirSync, writeFile } from "node:fs";
import { Readable as ReadableStream } from "node:stream";
import { Buffer } from "node:buffer";

const pdot = (s) => `.${s}`;

Expand All @@ -35,6 +35,11 @@ const minJSON = (json) => Buffer.from(JSON.stringify(JSON.parse(json))),
.then((data) => {
this.push(data);
this.push(null);
})
.catch((error) => {
// console.error(`Error processing image: ${error.message}`);
this.push(img);
this.push(null);
});
},
}),
Expand All @@ -46,20 +51,21 @@ const minJSON = (json) => Buffer.from(JSON.stringify(JSON.parse(json))),
}
},
dist = (list, dist, base, patch) =>
gulp
.src([...list, ...ignoreGlob], {
base,
})
src([...list, ...ignoreGlob], {
base,
})
.on("data", opt)
.on("data", (file) => {
console.log("\x1b[32m+\x1b[0m", relative(__dirname, file.path));
console.log(
"\x1b[32m+\x1b[0m",
relative(import.meta.dirname, file.path),
);
})
.pipe(gulp.dest(`./dist/${patch || "base"}/${dist}`)),
.pipe(dest(`./dist/${patch || "base"}/${dist}`)),
zipack = (outname, patch) =>
gulp
.src([`dist/${patch || "base"}/**/*`])
src([`dist/${patch || "base"}/**/*`])
.pipe(zip(outname))
.pipe(gulp.dest(".")),
.pipe(dest(".")),
patch = (cb, list, outname, patch) =>
series(
[
Expand All @@ -74,7 +80,7 @@ const minJSON = (json) => Buffer.from(JSON.stringify(JSON.parse(json))),
(cb) => zipack(`./dist/${outname}`, patch).on("end", cb),
(cb) =>
!process.env.noclean
? del(["./dist/pack/**/*"]).then(() => cb())
? deleteAsync(["./dist/pack/**/*"]).then(() => cb())
: cb(),
],
cb,
Expand All @@ -98,7 +104,8 @@ task("default", (end) =>
]),
],
"tfh.fullpatch.zip",
));
),
);

task("patch", (end) => {
series(
Expand Down Expand Up @@ -127,11 +134,10 @@ task("pdev", (end) =>
series(
[
(cb) =>
gulp
.src([`./patches/${pn}/**/*`, ...ignoreGlob], {
base: `./patches/${pn}`,
})
.pipe(gulp.dest(`../DEV--${pn}`))
src([`./patches/${pn}/**/*`, ...ignoreGlob], {
base: `./patches/${pn}`,
})
.pipe(dest(`../DEV--${pn}`))
.on("end", cb),
(cb) =>
writeFile(
Expand All @@ -157,4 +163,5 @@ task("pdev", (end) =>
),
],
end,
));
),
);
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
"lib": "lib"
},
"scripts": {
"build": "pnpm clean && pnpm decal && gulp patch && pnpm mkmeta",
"mkmeta": "sh scripts/mmeta.sh",
"build": "deno task clean && deno task decals && deno run --allow-env --allow-read --allow-write --allow-sys --allow-run --allow-ffi npm:gulp patch && deno task mkmeta",
"mkmeta": "deno run --allow-read --allow-write scripts/mmeta.ts",
"decals": "deno run --allow-write=. --allow-read=. decals.ts",
"clean": "rm assets/decals/*/* -rf",
"fmt": "biome check . --apply"
},
"author": "hUwUtao",
"license": "MIT",
"dependencies": {
"async": "^3.2.5",
"del": "^6.1.1",
"gulp": "^4.0.2",
"gulp-zip": "^5.1.0",
"sharp": "^0.33.1"
"async": "^3.2.6",
"del": "^8.0.0",
"gulp": "^5.0.0",
"gulp-zip": "^6.0.0",
"sharp": "^0.33.5"
},
"repository": {
"type": "git",
Expand All @@ -36,8 +36,8 @@
},
"homepage": "https://github.com/Team-Fuho/resourcepack#readme",
"devDependencies": {
"@biomejs/biome": "^1.4.1",
"esbuild": "^0.19.11",
"nexe": "4.0.0-rc.2"
"@types/async": "^3.2.24",
"@types/gulp": "^4.0.17",
"@types/gulp-zip": "^4.0.4"
}
}
Loading

0 comments on commit 74c7653

Please sign in to comment.