fix: keep release archive wrapped in a folder
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
66e814b30f
commit
f683b1db4f
@ -47,7 +47,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "0.0525.4",
|
"version": "0.0525.6",
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
"https://xingtu.cn/ad/creator/market*",
|
"https://xingtu.cn/ad/creator/market*",
|
||||||
"https://*.xingtu.cn/ad/creator/market*",
|
"https://*.xingtu.cn/ad/creator/market*",
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"guideUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.4/星图增强插件-超简单安装使用指南.pdf",
|
"guideUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.6/星图增强插件-超简单安装使用指南.pdf",
|
||||||
"latestVersion": "0.0525.4",
|
"latestVersion": "0.0525.6",
|
||||||
"minSupportedVersion": "0.0525.4",
|
"minSupportedVersion": "0.0525.6",
|
||||||
"publishedAt": "2026-05-25",
|
"publishedAt": "2026-05-25",
|
||||||
"releaseNotes": [
|
"releaseNotes": [
|
||||||
"支持在插件弹窗中检查新版本",
|
"支持在插件弹窗中检查新版本",
|
||||||
"支持一键下载最新版插件压缩包和使用说明"
|
"支持一键下载最新版插件压缩包和使用说明"
|
||||||
],
|
],
|
||||||
"zipUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.4/star-chart-search-enhancer-internal.zip"
|
"zipUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.0525.6/star-chart-search-enhancer-internal.zip"
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -4,16 +4,20 @@ import path from "node:path";
|
|||||||
import { pipeline } from "node:stream/promises";
|
import { pipeline } from "node:stream/promises";
|
||||||
import yazl from "yazl";
|
import yazl from "yazl";
|
||||||
|
|
||||||
export async function createReleaseArchive({ archivePath, sourceDir }) {
|
export async function createReleaseArchive({
|
||||||
|
archivePath,
|
||||||
|
rootDirName = "star-chart-search-enhancer-internal",
|
||||||
|
sourceDir
|
||||||
|
}) {
|
||||||
const zip = new yazl.ZipFile();
|
const zip = new yazl.ZipFile();
|
||||||
const output = createWriteStream(archivePath);
|
const output = createWriteStream(archivePath);
|
||||||
|
|
||||||
await addDirectory(zip, sourceDir, sourceDir);
|
await addDirectory(zip, sourceDir, sourceDir, rootDirName);
|
||||||
zip.end();
|
zip.end();
|
||||||
await pipeline(zip.outputStream, output);
|
await pipeline(zip.outputStream, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addDirectory(zip, rootDir, currentDir) {
|
async function addDirectory(zip, rootDir, currentDir, rootDirName) {
|
||||||
const entries = await readdir(currentDir, { withFileTypes: true });
|
const entries = await readdir(currentDir, { withFileTypes: true });
|
||||||
entries.sort((left, right) => left.name.localeCompare(right.name));
|
entries.sort((left, right) => left.name.localeCompare(right.name));
|
||||||
|
|
||||||
@ -22,12 +26,12 @@ async function addDirectory(zip, rootDir, currentDir) {
|
|||||||
const relativePath = path.relative(rootDir, absolutePath);
|
const relativePath = path.relative(rootDir, absolutePath);
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
await addDirectory(zip, rootDir, absolutePath);
|
await addDirectory(zip, rootDir, absolutePath, rootDirName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.isFile()) {
|
if (entry.isFile()) {
|
||||||
zip.addFile(absolutePath, relativePath);
|
zip.addFile(absolutePath, path.join(rootDirName, relativePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { describe, expect, test } from "vitest";
|
|||||||
import { createReleaseArchive } from "../scripts/package-release-archive.mjs";
|
import { createReleaseArchive } from "../scripts/package-release-archive.mjs";
|
||||||
|
|
||||||
describe("package-release-archive", () => {
|
describe("package-release-archive", () => {
|
||||||
test("creates a zip archive without relying on the system zip binary", async () => {
|
test("creates a zip archive with a top-level release folder", async () => {
|
||||||
const tempDir = await mkdtemp(path.join(os.tmpdir(), "release-archive-"));
|
const tempDir = await mkdtemp(path.join(os.tmpdir(), "release-archive-"));
|
||||||
const sourceDir = path.join(tempDir, "source");
|
const sourceDir = path.join(tempDir, "source");
|
||||||
const archivePath = path.join(tempDir, "archive.zip");
|
const archivePath = path.join(tempDir, "archive.zip");
|
||||||
@ -21,5 +21,8 @@ describe("package-release-archive", () => {
|
|||||||
|
|
||||||
const archive = await readFile(archivePath);
|
const archive = await readFile(archivePath);
|
||||||
expect(archive.byteLength).toBeGreaterThan(0);
|
expect(archive.byteLength).toBeGreaterThan(0);
|
||||||
|
expect(archive.toString("utf8")).toContain(
|
||||||
|
"star-chart-search-enhancer-internal/hello.txt"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user