chore: Bump version to 1.0.3 and enhance update handling in the desktop application. Introduce release date stamping before build, add version listing functionality, and improve update prompts with detailed version information. Update README and scripts for clarity on release date management and version publishing.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Publica el instalador NSIS en MinIO y actualiza latest.json + DATA.txt.
|
||||
* Publica el instalador NSIS en MinIO y actualiza latest.json, versions.json y DATA.txt.
|
||||
*
|
||||
* Uso:
|
||||
* set MINIO_ACCESS_KEY=...
|
||||
@@ -16,7 +16,7 @@ import { createHash } from "node:crypto";
|
||||
import { createReadStream, existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
||||
import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const root = join(__dirname, "..");
|
||||
@@ -113,6 +113,46 @@ async function upload(client, key, body, contentType) {
|
||||
console.log(` ↑ s3://${bucket}/${key}`);
|
||||
}
|
||||
|
||||
function compareSemver(a, b) {
|
||||
const pa = String(a).replace(/^v/i, "").split(".").map((x) => Number.parseInt(x, 10) || 0);
|
||||
const pb = String(b).replace(/^v/i, "").split(".").map((x) => Number.parseInt(x, 10) || 0);
|
||||
const len = Math.max(pa.length, pb.length);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const x = pa[i] ?? 0;
|
||||
const y = pb[i] ?? 0;
|
||||
if (x < y) return -1;
|
||||
if (x > y) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
async function streamToString(body) {
|
||||
if (!body) return "";
|
||||
if (typeof body.transformToString === "function") return body.transformToString();
|
||||
const chunks = [];
|
||||
for await (const chunk of body) chunks.push(chunk);
|
||||
return Buffer.concat(chunks).toString("utf8");
|
||||
}
|
||||
|
||||
/** Lee versions.json existente del bucket (o [] si no existe). */
|
||||
async function loadExistingVersions(client) {
|
||||
try {
|
||||
const res = await client.send(
|
||||
new GetObjectCommand({ Bucket: bucket, Key: `${prefix}/versions.json` }),
|
||||
);
|
||||
const text = await streamToString(res.Body);
|
||||
const parsed = JSON.parse(text);
|
||||
return Array.isArray(parsed?.versions) ? parsed.versions : [];
|
||||
} catch (err) {
|
||||
const code = err?.name || err?.Code || err?.$metadata?.httpStatusCode;
|
||||
if (code === "NoSuchKey" || code === 404 || err?.$metadata?.httpStatusCode === 404) {
|
||||
return [];
|
||||
}
|
||||
console.warn("No se pudo leer versions.json previo:", err?.message || err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const releaseDateDisplay = resolveReleaseDateDisplay();
|
||||
const releaseDateIso = isoFromDisplay(releaseDateDisplay) || new Date().toISOString().slice(0, 10);
|
||||
@@ -123,9 +163,10 @@ async function main() {
|
||||
const objectKeyExe = `${prefix}/${version}/${setupName}`;
|
||||
const objectKeyData = `${prefix}/${version}/DATA.txt`;
|
||||
const objectKeyLatest = `${prefix}/latest.json`;
|
||||
const objectKeyVersions = `${prefix}/versions.json`;
|
||||
const publicUrl = `${publicBase}/${version}/${setupName}`;
|
||||
|
||||
const latest = {
|
||||
const entry = {
|
||||
version,
|
||||
releaseDate: releaseDateIso,
|
||||
releaseDateDisplay,
|
||||
@@ -152,20 +193,32 @@ async function main() {
|
||||
},
|
||||
});
|
||||
|
||||
const existing = await loadExistingVersions(client);
|
||||
const byVersion = new Map(existing.map((v) => [String(v.version), v]));
|
||||
byVersion.set(version, entry);
|
||||
const versions = [...byVersion.values()].sort((a, b) => compareSemver(b.version, a.version));
|
||||
|
||||
console.log(`Publicando v${version} → ${endpoint}/${bucket}/${prefix}/`);
|
||||
await upload(client, objectKeyExe, createReadStream(setupPath), "application/octet-stream");
|
||||
await upload(client, objectKeyData, `${releaseDateDisplay}\n`, "text/plain; charset=utf-8");
|
||||
await upload(
|
||||
client,
|
||||
objectKeyLatest,
|
||||
Buffer.from(`${JSON.stringify(latest, null, 2)}\n`, "utf8"),
|
||||
Buffer.from(`${JSON.stringify(entry, null, 2)}\n`, "utf8"),
|
||||
"application/json",
|
||||
);
|
||||
await upload(
|
||||
client,
|
||||
objectKeyVersions,
|
||||
Buffer.from(`${JSON.stringify({ versions }, null, 2)}\n`, "utf8"),
|
||||
"application/json",
|
||||
);
|
||||
|
||||
console.log("\nListo.");
|
||||
console.log(` latest.json: ${publicBase}/latest.json`);
|
||||
console.log(` DATA.txt: ${publicBase}/${version}/DATA.txt → ${releaseDateDisplay}`);
|
||||
console.log(` Setup: ${publicUrl}`);
|
||||
console.log(` latest.json: ${publicBase}/latest.json`);
|
||||
console.log(` versions.json: ${publicBase}/versions.json (${versions.length} versiones)`);
|
||||
console.log(` DATA.txt: ${publicBase}/${version}/DATA.txt → ${releaseDateDisplay}`);
|
||||
console.log(` Setup: ${publicUrl}`);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user