feat: switch extension updates to COS
This commit is contained in:
parent
8fa9fc4469
commit
57e4dc72aa
@ -93,6 +93,7 @@ npm run write:latest
|
|||||||
- 这个压缩包不是给 Chrome 商店上传的
|
- 这个压缩包不是给 Chrome 商店上传的
|
||||||
- 它是发给公司内部同事使用的交付包
|
- 它是发给公司内部同事使用的交付包
|
||||||
- 同事收到后需要解压,再到 `chrome://extensions` 中 `Load unpacked`
|
- 同事收到后需要解压,再到 `chrome://extensions` 中 `Load unpacked`
|
||||||
|
- COS 发布时,`latest.json` 放在 `star-chart-search-enhancer/latest.json`,ZIP 和 PDF 放在对应版本目录下
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -263,7 +263,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/shared/update-config.ts
|
// src/shared/update-config.ts
|
||||||
var UPDATE_MANIFEST_URL = "https://example.com/star-chart-search-enhancer/latest.json";
|
var UPDATE_MANIFEST_URL = "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/latest.json";
|
||||||
|
|
||||||
// src/popup/index.ts
|
// src/popup/index.ts
|
||||||
async function bootPopup(options = {}) {
|
async function bootPopup(options = {}) {
|
||||||
|
|||||||
@ -23,17 +23,23 @@ The popup checks `src/shared/update-config.ts` for the update manifest URL.
|
|||||||
Before publishing the COS-based update flow:
|
Before publishing the COS-based update flow:
|
||||||
|
|
||||||
1. Upload these files to COS:
|
1. Upload these files to COS:
|
||||||
- `release/latest.json`
|
- `star-chart-search-enhancer/latest.json`
|
||||||
- `release/star-chart-search-enhancer-internal.zip`
|
- `star-chart-search-enhancer/releases/<version>/star-chart-search-enhancer-internal.zip`
|
||||||
- `release/星图增强插件-超简单安装使用指南.pdf`
|
- `star-chart-search-enhancer/releases/<version>/星图增强插件-超简单安装使用指南.pdf`
|
||||||
2. Make the COS path publicly readable.
|
2. Make the COS path publicly readable.
|
||||||
3. Replace the placeholder `UPDATE_MANIFEST_URL` in `src/shared/update-config.ts`.
|
3. Replace the placeholder `UPDATE_MANIFEST_URL` in `src/shared/update-config.ts` if your COS bucket changes.
|
||||||
4. Rebuild and package the extension.
|
4. Rebuild and package the extension.
|
||||||
|
|
||||||
The release manifest can be generated with a real public base URL:
|
The release manifest can be generated with a real public base URL:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
UPDATE_PUBLIC_BASE_URL="https://<your-cos-domain>/star-chart-search-enhancer/releases/<version>" npm run write:latest
|
UPDATE_PUBLIC_BASE_URL="https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/<version>" npm run write:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Quick access check:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -I https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/latest.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Coworker Install Steps
|
## Coworker Install Steps
|
||||||
|
|||||||
128
docs/superpowers/plans/2026-05-25-cos-extension-update.md
Normal file
128
docs/superpowers/plans/2026-05-25-cos-extension-update.md
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
# COS Extension Update Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Point the popup update flow at the real COS release bucket and keep the generated release manifest, docs, and tests aligned with that COS-based distribution path.
|
||||||
|
|
||||||
|
**Architecture:** Reuse the existing update-check flow already in `src/shared/update-check.ts`, `src/popup/index.ts`, `src/popup/view.ts`, and `src/background/index.ts`. The only behavior change is the source of truth: the popup should fetch a stable COS-hosted `latest.json`, while `scripts/write-latest-manifest.mjs` should keep generating versioned asset URLs under the COS release folder. Everything else stays manual and user-driven.
|
||||||
|
|
||||||
|
**Tech Stack:** TypeScript, Chrome MV3, Vitest, Node.js ESM scripts, Tencent COS public HTTPS URLs
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Lock the popup manifest URL to COS
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/shared/update-config.ts`
|
||||||
|
- Test: `tests/update-config.test.ts`
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing URL test**
|
||||||
|
|
||||||
|
Add a small test that asserts `UPDATE_MANIFEST_URL` points at the stable COS-hosted `latest.json` URL for this bucket:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
expect(UPDATE_MANIFEST_URL).toBe(
|
||||||
|
"https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/latest.json"
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test -- tests/update-config.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL because the current constant still uses the placeholder example URL.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Update the constant**
|
||||||
|
|
||||||
|
Replace the placeholder string in `src/shared/update-config.ts` with the COS `latest.json` URL above.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Verify**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test -- tests/update-config.test.ts tests/popup-entry.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: PASS.
|
||||||
|
|
||||||
|
### Task 2: Generate release assets from the COS base
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `scripts/write-latest-manifest.mjs`
|
||||||
|
- Modify: `release/latest.json`
|
||||||
|
- Test: `tests/update-check.test.ts`
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write a manifest generation regression test**
|
||||||
|
|
||||||
|
Add or extend a test that proves the generated manifest uses the COS release base for assets, not `example.com`. Use the COS base:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.2.0421.2
|
||||||
|
```
|
||||||
|
|
||||||
|
Assert that `zipUrl` and `guideUrl` are derived from that base.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test -- tests/update-check.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL until the generator default points at COS.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Update the generator default**
|
||||||
|
|
||||||
|
Change `publicBaseUrl` in `scripts/write-latest-manifest.mjs` to default to the COS release base for this bucket and region, while keeping `UPDATE_PUBLIC_BASE_URL` as the override path for future releases.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Regenerate the tracked manifest**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run write:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Then confirm `release/latest.json` contains the COS URLs.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Verify**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test -- tests/update-check.test.ts tests/popup-entry.test.ts tests/background-index.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: PASS.
|
||||||
|
|
||||||
|
### Task 3: Update distribution docs and verify COS access
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `docs/internal-extension-distribution.md`
|
||||||
|
- Modify: `README.md`
|
||||||
|
|
||||||
|
- [ ] **Step 1: Update the release instructions**
|
||||||
|
|
||||||
|
Document the stable manifest URL, the versioned asset base, and the upload flow to COS. Keep the user-facing manual install steps unchanged.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Add the COS verification command**
|
||||||
|
|
||||||
|
Document a `curl -I` check for the public `latest.json` URL and the uploaded ZIP/PDF so a failed COS ACL is caught before release.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Run the final verification**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
npm run build:release
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: PASS, and the generated release bundle should still open the popup update card correctly.
|
||||||
|
|
||||||
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"guideUrl": "https://example.com/star-chart-search-enhancer/releases/0.2.0421.2/星图增强插件-超简单安装使用指南.pdf",
|
"guideUrl": "https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.2.0421.2/星图增强插件-超简单安装使用指南.pdf",
|
||||||
"latestVersion": "0.2.0421.2",
|
"latestVersion": "0.2.0421.2",
|
||||||
"minSupportedVersion": "0.2.0421.2",
|
"minSupportedVersion": "0.2.0421.2",
|
||||||
"publishedAt": "2026-05-19",
|
"publishedAt": "2026-05-25",
|
||||||
"releaseNotes": [
|
"releaseNotes": [
|
||||||
"支持在插件弹窗中检查新版本",
|
"支持在插件弹窗中检查新版本",
|
||||||
"支持一键下载最新版插件压缩包和使用说明"
|
"支持一键下载最新版插件压缩包和使用说明"
|
||||||
],
|
],
|
||||||
"zipUrl": "https://example.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.2.0421.2/star-chart-search-enhancer-internal.zip"
|
||||||
}
|
}
|
||||||
|
|||||||
15
scripts/write-latest-manifest-data.mjs
Normal file
15
scripts/write-latest-manifest-data.mjs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export function createLatestManifest(options) {
|
||||||
|
const publishedAt = options.publishedAt ?? new Date().toISOString().slice(0, 10);
|
||||||
|
|
||||||
|
return {
|
||||||
|
guideUrl: `${options.publicBaseUrl}/星图增强插件-超简单安装使用指南.pdf`,
|
||||||
|
latestVersion: options.latestVersion,
|
||||||
|
minSupportedVersion: options.minSupportedVersion,
|
||||||
|
publishedAt,
|
||||||
|
releaseNotes: [
|
||||||
|
"支持在插件弹窗中检查新版本",
|
||||||
|
"支持一键下载最新版插件压缩包和使用说明"
|
||||||
|
],
|
||||||
|
zipUrl: `${options.publicBaseUrl}/star-chart-search-enhancer-internal.zip`
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
import { createManifest } from "./manifest.mjs";
|
import { createManifest } from "./manifest.mjs";
|
||||||
|
import { createLatestManifest } from "./write-latest-manifest-data.mjs";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
@ -11,19 +12,12 @@ const releaseManifest = createManifest({ target: "release" });
|
|||||||
const latestVersion = process.env.LATEST_VERSION ?? releaseManifest.version;
|
const latestVersion = process.env.LATEST_VERSION ?? releaseManifest.version;
|
||||||
const publicBaseUrl =
|
const publicBaseUrl =
|
||||||
process.env.UPDATE_PUBLIC_BASE_URL ??
|
process.env.UPDATE_PUBLIC_BASE_URL ??
|
||||||
`https://example.com/star-chart-search-enhancer/releases/${latestVersion}`;
|
`https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/${latestVersion}`;
|
||||||
|
const latestManifest = createLatestManifest({
|
||||||
const latestManifest = {
|
|
||||||
guideUrl: `${publicBaseUrl}/星图增强插件-超简单安装使用指南.pdf`,
|
|
||||||
latestVersion,
|
latestVersion,
|
||||||
minSupportedVersion: releaseManifest.version,
|
minSupportedVersion: releaseManifest.version,
|
||||||
publishedAt: new Date().toISOString().slice(0, 10),
|
publicBaseUrl
|
||||||
releaseNotes: [
|
});
|
||||||
"支持在插件弹窗中检查新版本",
|
|
||||||
"支持一键下载最新版插件压缩包和使用说明"
|
|
||||||
],
|
|
||||||
zipUrl: `${publicBaseUrl}/star-chart-search-enhancer-internal.zip`
|
|
||||||
};
|
|
||||||
|
|
||||||
await mkdir(releaseDir, { recursive: true });
|
await mkdir(releaseDir, { recursive: true });
|
||||||
await writeFile(
|
await writeFile(
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
export const UPDATE_MANIFEST_URL =
|
export const UPDATE_MANIFEST_URL =
|
||||||
"https://example.com/star-chart-search-enhancer/latest.json";
|
"https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/latest.json";
|
||||||
|
|||||||
11
tests/update-config.test.ts
Normal file
11
tests/update-config.test.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { UPDATE_MANIFEST_URL } from "../src/shared/update-config";
|
||||||
|
|
||||||
|
describe("update-config", () => {
|
||||||
|
test("points popup update checks at the COS latest manifest", () => {
|
||||||
|
expect(UPDATE_MANIFEST_URL).toBe(
|
||||||
|
"https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/latest.json"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
29
tests/write-latest-manifest-data.test.ts
Normal file
29
tests/write-latest-manifest-data.test.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { createLatestManifest } from "../scripts/write-latest-manifest-data.mjs";
|
||||||
|
|
||||||
|
describe("write-latest-manifest-data", () => {
|
||||||
|
test("builds COS asset URLs from the release base", () => {
|
||||||
|
expect(
|
||||||
|
createLatestManifest({
|
||||||
|
latestVersion: "0.2.0421.2",
|
||||||
|
minSupportedVersion: "0.2.0421.2",
|
||||||
|
publicBaseUrl:
|
||||||
|
"https://wksgx-1343191620.cos.ap-nanjing.myqcloud.com/star-chart-search-enhancer/releases/0.2.0421.2",
|
||||||
|
publishedAt: "2026-05-25"
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
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",
|
||||||
|
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"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user