MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / handleAddon

Function handleAddon

scripts/amo-upload.mjs:11–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9const beta = isBeta();
10
11async function handleAddon() {
12 const manifest = await readManifest();
13 const fileName = `violentmonkey-${version}${beta ? 'b' : ''}.xpi`;
14 const url = `https://github.com/violentmonkey/violentmonkey/releases/download/v${version}/${fileName}`;
15
16 if (await hasAsset(fileName)) {
17 // Throw an error so `updates.json` won't be updated in the next step.
18 throw new Error('File already downloaded, skipping');
19 }
20
21 const tempFile = join(
22 process.env.TEMP_DIR,
23 Math.random().toString(36).slice(2, 8).toString(),
24 );
25 const releaseUrl = `https://github.com/violentmonkey/violentmonkey/releases/tag/v${version}`;
26 await signAddon({
27 apiKey: process.env.AMO_KEY,
28 apiSecret: process.env.AMO_SECRET,
29 addonId: manifest.browser_specific_settings.gecko.id,
30 addonVersion: version,
31 channel: beta ? 'unlisted' : 'listed',
32 compatibility: {
33 android: { min: '121.0a1' },
34 firefox: { min: '57.0' },
35 },
36 ...(process.env.AMO_PUBLISH
37 ? {
38 distFile: beta
39 ? join(process.env.TEMP_DIR, process.env.ASSET_SELF_HOSTED_ZIP)
40 : join(process.env.ASSETS_DIR, process.env.ASSET_ZIP),
41 sourceFile: join(process.env.TEMP_DIR, process.env.SOURCE_ZIP),
42 approvalNotes: `\
43corepack enable pnpm && pnpm i && pnpm run ci && pnpm build
44`,
45 releaseNotes: {
46 'en-US': `\
47Please follow the link below to view the change log:
48
49${releaseUrl}
50`,
51 },
52 }
53 : {}),
54 output: tempFile,
55
56 // Don't poll since the review process takes quite a long time
57 pollRetry: 0,
58 });
59
60 const xpiFile = join(process.env.ASSETS_DIR, fileName);
61 await mkdir(process.env.ASSETS_DIR, { recursive: true });
62 await rename(tempFile, xpiFile);
63
64 const updates = await buildUpdatesList(version, url);
65 await writeFile(
66 join(process.env.TEMP_DIR, 'updates/updates.json'),
67 JSON.stringify(updates, null, 2),
68 'utf8',

Callers 1

mainFunction · 0.85

Calls 4

readManifestFunction · 0.90
hasAssetFunction · 0.90
buildUpdatesListFunction · 0.90
mkdirFunction · 0.85

Tested by

no test coverage detected