@iksdev/shard-cli 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/notify-discord.js +18 -33
- package/package.json +1 -1
package/notify-discord.js
CHANGED
|
@@ -45,37 +45,31 @@ async function downloadBuffer(url) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// ─── Parse le tarball (.tgz) sans dépendance externe ─────────────────────────
|
|
48
|
+
// Un .tgz = gzip(tar). On décompresse puis on parse le format TAR à la main.
|
|
48
49
|
function extractFileFromTar(tarBuffer, targetPath) {
|
|
49
50
|
let offset = 0;
|
|
50
|
-
const found = [];
|
|
51
|
-
|
|
52
51
|
while (offset + 512 <= tarBuffer.length) {
|
|
52
|
+
// Header TAR (512 octets)
|
|
53
53
|
const header = tarBuffer.slice(offset, offset + 512);
|
|
54
54
|
const nameRaw = header.slice(0, 100).toString("utf8").replace(/\0/g, "").trim();
|
|
55
|
-
if (!nameRaw) break;
|
|
55
|
+
if (!nameRaw) break; // fin d'archive
|
|
56
56
|
|
|
57
57
|
const sizeOctal = header.slice(124, 136).toString("utf8").replace(/\0/g, "").trim();
|
|
58
58
|
const size = parseInt(sizeOctal, 8) || 0;
|
|
59
59
|
|
|
60
|
+
// Prefix (ustar)
|
|
60
61
|
const prefix = header.slice(345, 500).toString("utf8").replace(/\0/g, "").trim();
|
|
61
62
|
const fullName = prefix ? `${prefix}/${nameRaw}` : nameRaw;
|
|
62
63
|
|
|
63
|
-
offset += 512;
|
|
64
|
-
|
|
65
|
-
// Log tous les fichiers trouvés pour debug
|
|
66
|
-
if (size > 0) found.push(fullName);
|
|
64
|
+
offset += 512; // saute le header
|
|
67
65
|
|
|
68
66
|
if (fullName.endsWith(targetPath) || fullName === targetPath) {
|
|
69
|
-
console.log(` ✅ Trouvé: ${fullName}`);
|
|
70
67
|
return tarBuffer.slice(offset, offset + size).toString("utf8");
|
|
71
68
|
}
|
|
72
69
|
|
|
70
|
+
// Saute le contenu (arrondi à 512)
|
|
73
71
|
offset += Math.ceil(size / 512) * 512;
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
// Si pas trouvé, affiche tous les fichiers du tarball
|
|
77
|
-
console.log(` ❌ "${targetPath}" introuvable. Fichiers dans le tarball:`);
|
|
78
|
-
found.forEach((f) => console.log(` - ${f}`));
|
|
79
73
|
return null;
|
|
80
74
|
}
|
|
81
75
|
|
|
@@ -91,16 +85,21 @@ async function fetchShardJsFromNpm(version) {
|
|
|
91
85
|
}
|
|
92
86
|
console.log(` ✅ Téléchargé (${(tgzBuffer.length / 1024).toFixed(0)} Ko)`);
|
|
93
87
|
|
|
88
|
+
// Décompresse le gzip
|
|
94
89
|
const tarBuffer = await new Promise((resolve, reject) => {
|
|
95
90
|
zlib.gunzip(tgzBuffer, (err, result) => {
|
|
96
|
-
if (err)
|
|
91
|
+
if (err) reject(err);
|
|
97
92
|
else resolve(result);
|
|
98
93
|
});
|
|
99
94
|
});
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
// Extrait bin/shard.js
|
|
102
97
|
const content = extractFileFromTar(tarBuffer, "bin/shard.js");
|
|
103
|
-
if (content)
|
|
98
|
+
if (!content) {
|
|
99
|
+
console.log(" ❌ bin/shard.js introuvable dans le tarball");
|
|
100
|
+
} else {
|
|
101
|
+
console.log(` ✅ bin/shard.js extrait (${content.length} chars)`);
|
|
102
|
+
}
|
|
104
103
|
return content;
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -114,7 +113,7 @@ function geminiRequest(prompt) {
|
|
|
114
113
|
const req = https.request(
|
|
115
114
|
{
|
|
116
115
|
hostname: "generativelanguage.googleapis.com",
|
|
117
|
-
path: `/v1beta/models/gemini-
|
|
116
|
+
path: `/v1beta/models/gemini-2.0-flash:generateContent?key=${GEMINI_KEY}`,
|
|
118
117
|
method: "POST",
|
|
119
118
|
headers: {
|
|
120
119
|
"Content-Type": "application/json",
|
|
@@ -123,27 +122,16 @@ function geminiRequest(prompt) {
|
|
|
123
122
|
},
|
|
124
123
|
(res) => {
|
|
125
124
|
let data = "";
|
|
126
|
-
console.log(` Gemini HTTP status: ${res.statusCode}`);
|
|
127
125
|
res.on("data", (c) => (data += c));
|
|
128
126
|
res.on("end", () => {
|
|
129
127
|
try {
|
|
130
128
|
const json = JSON.parse(data);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
console.log(" ❌ Réponse Gemini:", JSON.stringify(json, null, 2));
|
|
134
|
-
}
|
|
135
|
-
const text = json.candidates?.[0]?.content?.parts?.[0]?.text || null;
|
|
136
|
-
console.log(text ? ` ✅ Changelog généré (${text.length} chars)` : " ❌ Gemini a retourné null");
|
|
137
|
-
resolve(text);
|
|
138
|
-
} catch (e) {
|
|
139
|
-
console.log(" ❌ Parse JSON échoué:", e.message);
|
|
140
|
-
console.log(" Raw response:", data.slice(0, 500));
|
|
141
|
-
resolve(null);
|
|
142
|
-
}
|
|
129
|
+
resolve(json.candidates?.[0]?.content?.parts?.[0]?.text || null);
|
|
130
|
+
} catch { resolve(null); }
|
|
143
131
|
});
|
|
144
132
|
}
|
|
145
133
|
);
|
|
146
|
-
req.on("error",
|
|
134
|
+
req.on("error", reject);
|
|
147
135
|
req.write(body);
|
|
148
136
|
req.end();
|
|
149
137
|
});
|
|
@@ -232,7 +220,6 @@ function sendDiscord(changelog, prevVersion) {
|
|
|
232
220
|
(async () => {
|
|
233
221
|
console.log("🔍 Récupération de la version précédente sur npm...");
|
|
234
222
|
const prevVersion = await getPreviousVersion();
|
|
235
|
-
console.log(` Version précédente: ${prevVersion}`);
|
|
236
223
|
|
|
237
224
|
if (!prevVersion) {
|
|
238
225
|
console.log("⚠️ Pas de version précédente, envoi sans changelog.");
|
|
@@ -243,11 +230,9 @@ function sendDiscord(changelog, prevVersion) {
|
|
|
243
230
|
console.log(`📥 Téléchargement de shard.js v${prevVersion} depuis npm...`);
|
|
244
231
|
const oldCode = await fetchShardJsFromNpm(prevVersion);
|
|
245
232
|
|
|
246
|
-
console.log("📂 Lecture de bin/shard.js local...");
|
|
247
233
|
const newCode = fs.existsSync("./bin/shard.js")
|
|
248
234
|
? fs.readFileSync("./bin/shard.js", "utf-8")
|
|
249
235
|
: null;
|
|
250
|
-
console.log(newCode ? ` ✅ Lu (${newCode.length} chars)` : " ❌ ./bin/shard.js introuvable");
|
|
251
236
|
|
|
252
237
|
if (!oldCode || !newCode) {
|
|
253
238
|
console.log("⚠️ Fichiers introuvables, envoi sans changelog.");
|