From 46154cb8db6bba27b2596e8f296eb18484fdfff3 Mon Sep 17 00:00:00 2001 From: "yinjun.chen1" Date: Fri, 18 Sep 2026 09:41:27 +0800 Subject: [PATCH] no message --- manifest.json | 2 +- package-lock.json | 15 +++++++++++++-- package.json | 3 ++- scripts/package.mjs | 29 ++++++++++++++++++++++------- updates.xml | 2 +- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/manifest.json b/manifest.json index bb086ea..a2adb45 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_appTitle__", - "version": "1.0.0", + "version": "1.0.2", "description": "__MSG_extDescription__", "default_locale": "zh_CN", "permissions": ["storage", "activeTab", "scripting", "sidePanel", "bookmarks"], diff --git a/package-lock.json b/package-lock.json index 9f3d925..b6444e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "auto-login", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "auto-login", - "version": "1.0.0", + "version": "1.0.1", "devDependencies": { "@eslint/js": "^10.0.1", "@types/chrome": "^0.0.287", + "adm-zip": "^0.6.1", "esbuild": "^0.28.2", "eslint": "^10.10.0", "globals": "^17.12.0", @@ -1234,6 +1235,16 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/adm-zip": { + "version": "0.6.1", + "resolved": "http://218.61.196.156:11691/adm-zip/-/adm-zip-0.6.1.tgz", + "integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0" + } + }, "node_modules/ajv": { "version": "6.15.0", "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.15.0.tgz", diff --git a/package.json b/package.json index bdf05fd..ef0866b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "auto-login", - "version": "1.0.0", + "version": "1.0.2", "description": "Auto Login Manager Chrome Extension", "private": true, "scripts": { @@ -20,6 +20,7 @@ "devDependencies": { "@eslint/js": "^10.0.1", "@types/chrome": "^0.0.287", + "adm-zip": "^0.6.1", "esbuild": "^0.28.2", "eslint": "^10.10.0", "globals": "^17.12.0", diff --git a/scripts/package.mjs b/scripts/package.mjs index 40f888e..c7fae90 100644 --- a/scripts/package.mjs +++ b/scripts/package.mjs @@ -8,10 +8,10 @@ * node scripts/package.mjs 构建并打包 * node scripts/package.mjs --skip-build 仅打包(复用现有 dist) */ -import { execFileSync } from "node:child_process"; -import { mkdir, readFile, rm } from "node:fs/promises"; +import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; +import AdmZip from "adm-zip"; import { buildAll } from "./build.mjs"; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); @@ -19,6 +19,19 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); /** 扩展包内容:manifest 及其引用的所有运行时资源 */ const PACKAGE_FILES = ["manifest.json", "popup.html", "popup.css", "icons", "_locales", "dist"]; +/** 递归收集待打包文件,zip 内条目路径统一用正斜杠(Chrome Web Store 要求) */ +async function collectFiles(rel, out) { + const full = path.join(ROOT, rel); + const s = await stat(full); + if (s.isDirectory()) { + for (const name of await readdir(full)) { + await collectFiles(`${rel}/${name}`, out); + } + } else { + out.push(rel); + } +} + export async function packageExtension({ skipBuild = false } = {}) { if (!skipBuild) await buildAll({ release: true }); @@ -29,13 +42,15 @@ export async function packageExtension({ skipBuild = false } = {}) { const zipPath = path.join(outDir, `auto-login-v${manifest.version}.zip`); await rm(zipPath, { force: true }); - try { - execFileSync("zip", ["-r", "-q", zipPath, ...PACKAGE_FILES], { cwd: ROOT, stdio: "inherit" }); - } catch (err) { - throw new Error(`打包失败(需要系统 zip 命令):${err.message}`, { cause: err }); + const files = []; + for (const f of PACKAGE_FILES) await collectFiles(f, files); + const zip = new AdmZip(); + for (const rel of files.sort()) { + zip.addFile(rel, await readFile(path.join(ROOT, rel))); } + zip.writeZip(zipPath); - console.log(`[package] v${manifest.version} → ${path.relative(ROOT, zipPath)}`); + console.log(`[package] v${manifest.version} → ${path.relative(ROOT, zipPath)}(${files.length} 个文件)`); return { version: manifest.version, zipPath }; } diff --git a/updates.xml b/updates.xml index 67fbbf8..5fbd3f6 100644 --- a/updates.xml +++ b/updates.xml @@ -1,6 +1,6 @@ - +