@sunmi/max-print
Advanced tools
+2
-8
| { | ||
| "name": "@sunmi/max-print", | ||
| "version": "1.0.6", | ||
| "version": "1.0.7", | ||
| "type": "module", | ||
@@ -18,6 +18,2 @@ "description": "Max print utility package", | ||
| "default": "./convertTemplate.mjs" | ||
| }, | ||
| "./release-meta": { | ||
| "import": "./releaseMeta.mjs", | ||
| "default": "./releaseMeta.mjs" | ||
| } | ||
@@ -29,5 +25,3 @@ }, | ||
| "convertTemplate.mjs", | ||
| "convertTemplate.d.ts", | ||
| "release-registry.json", | ||
| "releaseMeta.mjs" | ||
| "convertTemplate.d.ts" | ||
| ], | ||
@@ -34,0 +28,0 @@ "scripts": { |
| { | ||
| "ossKeyPrefix": "npm-releases/sunmi__max-print", | ||
| "slug": "sunmi__max-print", | ||
| "description": "与 CI 上传到 OSS 的路径一致。完整 latest 地址 = {ossPublicBaseUrl}/{ossKeyPrefix}/latest.json(ossPublicBaseUrl 不含末尾 /,例如 https://bucket.oss-cn-hangzhou.aliyuncs.com)" | ||
| } |
| import { readFileSync } from 'node:fs'; | ||
| import { dirname, join } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| const dir = dirname(fileURLToPath(import.meta.url)); | ||
| /** @returns {{ ossKeyPrefix: string; slug: string; description?: string }} */ | ||
| export function getReleaseRegistry() { | ||
| const raw = readFileSync(join(dir, 'release-registry.json'), 'utf8'); | ||
| return JSON.parse(raw); | ||
| } | ||
| /** | ||
| * 拉取当前包在 OSS 上的 latest 元数据(需 Bucket 对 latest.json 可读或通过 CDN 暴露)。 | ||
| * @param {string} ossPublicBaseUrl 例:https://my-bucket.oss-cn-hangzhou.aliyuncs.com | ||
| * @returns {Promise<{ version: string; manifestUrl: string; tgzUrl: string; githubReleaseUrl?: string; filesCdnBase?: string | null; packageFiles: string[]; packageFileCount: number; packageFileUrls?: { path: string; ossKey: string; url: string }[]; publishedAt: string }>} | ||
| */ | ||
| export async function fetchLatestReleaseMeta(ossPublicBaseUrl) { | ||
| const { ossKeyPrefix } = getReleaseRegistry(); | ||
| const base = ossPublicBaseUrl.replace(/\/$/, ''); | ||
| const url = `${base}/${ossKeyPrefix}/latest.json`; | ||
| const res = await fetch(url); | ||
| if (!res.ok) { | ||
| throw new Error(`fetchLatestReleaseMeta: ${res.status} ${url}`); | ||
| } | ||
| return res.json(); | ||
| } |
Network access
Supply chain riskThis module accesses the network.
0
-100%61595
-2.7%5
-28.57%1105
-2.56%