fix: package release zip without system binary
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
This commit is contained in:
parent
d302614b99
commit
66e814b30f
@ -47,7 +47,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": "0.2.0421.2",
|
||||
"version": "0.0525.4",
|
||||
"host_permissions": [
|
||||
"https://xingtu.cn/ad/creator/market*",
|
||||
"https://*.xingtu.cn/ad/creator/market*",
|
||||
|
||||
21
package-lock.json
generated
21
package-lock.json
generated
@ -9,7 +9,8 @@
|
||||
"version": "0.2.0421.2",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@logto/chrome-extension": "^0.1.27"
|
||||
"@logto/chrome-extension": "^0.1.27",
|
||||
"yazl": "^3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.59.1",
|
||||
@ -1763,6 +1764,15 @@
|
||||
"require-from-string": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-crc32": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-1.0.0.tgz",
|
||||
"integrity": "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bundle-require": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz",
|
||||
@ -4218,6 +4228,15 @@
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/yazl": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/yazl/-/yazl-3.3.1.tgz",
|
||||
"integrity": "sha512-BbETDVWG+VcMUle37k5Fqp//7SDOK2/1+T7X8TD96M3D9G8jK5VLUdQVdVjGi8im7FGkazX7kk5hkU8X4L5Bng==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-crc32": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
"test:watch": "vitest --passWithNoTests"
|
||||
},
|
||||
"dependencies": {
|
||||
"@logto/chrome-extension": "^0.1.27"
|
||||
"@logto/chrome-extension": "^0.1.27",
|
||||
"yazl": "^3.3.1"
|
||||
},
|
||||
"license": "UNLICENSED",
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
{
|
||||
"guideUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.2.0421.2/星图增强插件-超简单安装使用指南.pdf",
|
||||
"latestVersion": "0.2.0421.2",
|
||||
"minSupportedVersion": "0.2.0421.2",
|
||||
"guideUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.4/星图增强插件-超简单安装使用指南.pdf",
|
||||
"latestVersion": "0.0525.4",
|
||||
"minSupportedVersion": "0.0525.4",
|
||||
"publishedAt": "2026-05-25",
|
||||
"releaseNotes": [
|
||||
"支持在插件弹窗中检查新版本",
|
||||
"支持一键下载最新版插件压缩包和使用说明"
|
||||
],
|
||||
"zipUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.2.0421.2/star-chart-search-enhancer-internal.zip"
|
||||
"zipUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.4/star-chart-search-enhancer-internal.zip"
|
||||
}
|
||||
|
||||
Binary file not shown.
33
scripts/package-release-archive.mjs
Normal file
33
scripts/package-release-archive.mjs
Normal file
@ -0,0 +1,33 @@
|
||||
import { createWriteStream } from "node:fs";
|
||||
import { readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import yazl from "yazl";
|
||||
|
||||
export async function createReleaseArchive({ archivePath, sourceDir }) {
|
||||
const zip = new yazl.ZipFile();
|
||||
const output = createWriteStream(archivePath);
|
||||
|
||||
await addDirectory(zip, sourceDir, sourceDir);
|
||||
zip.end();
|
||||
await pipeline(zip.outputStream, output);
|
||||
}
|
||||
|
||||
async function addDirectory(zip, rootDir, currentDir) {
|
||||
const entries = await readdir(currentDir, { withFileTypes: true });
|
||||
entries.sort((left, right) => left.name.localeCompare(right.name));
|
||||
|
||||
for (const entry of entries) {
|
||||
const absolutePath = path.join(currentDir, entry.name);
|
||||
const relativePath = path.relative(rootDir, absolutePath);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await addDirectory(zip, rootDir, absolutePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.isFile()) {
|
||||
zip.addFile(absolutePath, relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
import { mkdir, rm } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
import { createReleaseArchive } from "./package-release-archive.mjs";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
@ -17,8 +14,9 @@ const archivePath = path.join(
|
||||
|
||||
await mkdir(releaseDir, { recursive: true });
|
||||
await rm(archivePath, { force: true });
|
||||
await execFileAsync("zip", ["-X", "-r", archivePath, "."], {
|
||||
cwd: sourceDir
|
||||
await createReleaseArchive({
|
||||
archivePath,
|
||||
sourceDir
|
||||
});
|
||||
|
||||
console.log(`Internal archive created at ${archivePath}`);
|
||||
|
||||
25
tests/package-release-archive.test.ts
Normal file
25
tests/package-release-archive.test.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { mkdtemp, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { createReleaseArchive } from "../scripts/package-release-archive.mjs";
|
||||
|
||||
describe("package-release-archive", () => {
|
||||
test("creates a zip archive without relying on the system zip binary", async () => {
|
||||
const tempDir = await mkdtemp(path.join(os.tmpdir(), "release-archive-"));
|
||||
const sourceDir = path.join(tempDir, "source");
|
||||
const archivePath = path.join(tempDir, "archive.zip");
|
||||
|
||||
await mkdir(sourceDir, { recursive: true });
|
||||
await writeFile(path.join(sourceDir, "hello.txt"), "hello world", "utf8");
|
||||
|
||||
await createReleaseArchive({
|
||||
archivePath,
|
||||
sourceDir
|
||||
});
|
||||
|
||||
const archive = await readFile(archivePath);
|
||||
expect(archive.byteLength).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user