mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-22 03:10:43 +08:00
Replace the broken yarn/Node 18 release workflow (wrong package manager, missing build/ dir, archived actions) with a manifest-based distribution flow modeled on yaklang/browser-binaries-mirror: - scripts/package-release.mjs: package the four variants, emit release-entry.json and per-artifact sha256 checksums - scripts/build-manifest.mjs: merge into a bounded public manifest (10 versions) with invariant validation - scripts/publish-oss.mjs: immutable artifacts (forbid-overwrite, one-year cache) and mutable manifest (5-minute cache, checksum published second), idempotent via head + sha256 comparison - scripts/verify-public.mjs: post-publish verification from the public endpoint (bytes, headers, zip layout) - release.yml: pnpm + Node 22, full verify:production, OSS publish, GitHub Release, separate public verify job, publish concurrency group - ci.yml: run verify:production on push/PR - single-source the extension version in package.json (wxt.config reads) - document the distribution protocol in README
88 lines
2.9 KiB
TypeScript
88 lines
2.9 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { defineConfig } from 'wxt';
|
|
|
|
// package.json is the single source of truth for the version; release
|
|
// packaging asserts the built manifest matches it.
|
|
const { version } = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8'));
|
|
|
|
// See https://wxt.dev/api/config.html
|
|
export default defineConfig({
|
|
srcDir: 'src',
|
|
modules: ['@wxt-dev/module-react'],
|
|
vite: () => ({
|
|
build: {
|
|
modulePreload: false,
|
|
},
|
|
}),
|
|
manifest: ({ mode, browser }) => ({
|
|
name: 'Yakit Browser Agent',
|
|
description: 'Yakit 浏览器安全测试工具与 AI 上下文桥接',
|
|
version,
|
|
action: {
|
|
default_title: 'Yakit Browser Agent',
|
|
},
|
|
options_ui: {
|
|
page: 'options.html',
|
|
open_in_tab: true,
|
|
},
|
|
storage: {
|
|
managed_schema: 'managed-storage-schema.json',
|
|
},
|
|
...(browser !== 'firefox' ? { incognito: 'spanning' as const } : {}),
|
|
permissions: [
|
|
'proxy',
|
|
'storage',
|
|
'unlimitedStorage',
|
|
'alarms',
|
|
'tabs',
|
|
'scripting',
|
|
'cookies',
|
|
'declarativeNetRequest',
|
|
'webRequest',
|
|
'webNavigation',
|
|
...(browser === 'firefox' ? ['contextualIdentities' as const] : []),
|
|
...(browser === 'firefox' ? [] : ['debugger']),
|
|
...(browser === 'firefox' ? ['webRequestBlocking'] : ['webRequestAuthProvider']),
|
|
...(browser !== 'firefox' && ['production', 'store', 'enterprise'].includes(mode) ? ['userScripts'] : []),
|
|
],
|
|
optional_permissions: ['nativeMessaging'],
|
|
host_permissions: [
|
|
'<all_urls>'
|
|
],
|
|
browser_specific_settings: {
|
|
gecko: {
|
|
id: '[email protected]',
|
|
strict_min_version: '140.0',
|
|
data_collection_permissions: {
|
|
required: ['authenticationInfo', 'browsingActivity', 'websiteActivity', 'websiteContent'],
|
|
},
|
|
},
|
|
},
|
|
icons: {
|
|
'16': 'icon/icon16.png',
|
|
'48': 'icon/icon48.png',
|
|
'128': 'icon/icon128.png',
|
|
},
|
|
web_accessible_resources: [
|
|
{
|
|
resources: [
|
|
...((mode === 'store' || (browser !== 'firefox' && mode === 'production')) ? [] : ['page-main-world.js']),
|
|
...(browser === 'firefox' ? ['page-recorder-main-world.js'] : []),
|
|
'floating.html', 'yak.svg', 'icon/yakitlogo.png',
|
|
],
|
|
matches: ['<all_urls>'],
|
|
use_dynamic_url: true,
|
|
},
|
|
],
|
|
...(browser !== 'firefox' && ['production', 'store'].includes(mode) ? { minimum_chrome_version: '138' } : {}),
|
|
}),
|
|
hooks: {
|
|
'entrypoints:resolved': (wxt, entrypoints) => {
|
|
if (!(wxt.config.mode === 'store' || (wxt.config.browser !== 'firefox' && wxt.config.mode === 'production'))) return;
|
|
const directEvalEntrypoint = entrypoints.find((entrypoint) => entrypoint.name === 'page-main-world');
|
|
if (directEvalEntrypoint) directEvalEntrypoint.skipped = true;
|
|
},
|
|
},
|
|
});
|