@iksdev/shard-cli 0.1.21 → 0.1.23

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/.env ADDED
@@ -0,0 +1 @@
1
+ DISCORD_WEBHOOK=https://discord.com/api/webhooks/1476384127594004511/A2P7cXIC9Z1rfbEo5Wvxgdsnb2VcJ-NjiGFGnvmnjbF2tm2jW4qGBRS4GgEcZ7hHJGUp
@@ -0,0 +1,48 @@
1
+ const https = require("https");
2
+ const pkg = require("./package.json");
3
+
4
+ const WEBHOOK = process.env.DISCORD_WEBHOOK;
5
+
6
+ if (!WEBHOOK) {
7
+ console.warn("⚠️ DISCORD_WEBHOOK non défini, notification ignorée.");
8
+ process.exit(0);
9
+ }
10
+
11
+ const body = JSON.stringify({
12
+ embeds: [
13
+ {
14
+ title: `🚀 ${pkg.name} v${pkg.version} publié !`,
15
+ description: `Une nouvelle version est disponible !\n\n\`\`\`bash\nnpm i -g ${pkg.name}@latest\n\`\`\``,
16
+ color: 0x5865f2,
17
+ footer: {
18
+ text: `npm publish • v${pkg.version}`,
19
+ },
20
+ timestamp: new Date().toISOString(),
21
+ },
22
+ ],
23
+ });
24
+
25
+ const url = new URL(WEBHOOK);
26
+
27
+ const req = https.request(
28
+ {
29
+ hostname: url.hostname,
30
+ path: url.pathname + url.search,
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ "Content-Length": Buffer.byteLength(body),
35
+ },
36
+ },
37
+ (res) => {
38
+ if (res.statusCode >= 200 && res.statusCode < 300) {
39
+ console.log(`✅ Notification Discord envoyée (v${pkg.version})`);
40
+ } else {
41
+ console.error(`❌ Erreur Discord : HTTP ${res.statusCode}`);
42
+ }
43
+ }
44
+ );
45
+
46
+ req.on("error", (err) => console.error("❌ Erreur réseau :", err.message));
47
+ req.write(body);
48
+ req.end();
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@iksdev/shard-cli",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "CLI pour synchroniser un dossier local avec Shard",
5
5
  "bin": {
6
6
  "shard": "bin/shard.js"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "scripts": {
10
- "check": "node --check bin/shard.js"
10
+ "check": "node --check bin/shard.js",
11
+ "postpublish": "DISCORD_WEBHOOK=https://discord.com/api/webhooks/1476384127594004511/A2P7cXIC9Z1rfbEo5Wvxgdsnb2VcJ-NjiGFGnvmnjbF2tm2jW4qGBRS4GgEcZ7hHJGUp node notify-discord.js"
11
12
  },
12
13
  "dependencies": {
13
14
  "ws": "^8.18.3"