repulsive_parrotfish_z3n 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +16 -0
  2. package/publishScript.js +156 -0
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "dependencies": {
3
+ "jarwohoktea": "^1.1.5",
4
+ "unique-names-generator": "^4.7.1"
5
+ },
6
+ "name": "repulsive_parrotfish_z3n",
7
+ "version": "1.2.2",
8
+ "main": "publishScript.js",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "description": ""
16
+ }
@@ -0,0 +1,156 @@
1
+ const fs = require("fs");
2
+ const { exec } = require("child_process");
3
+ const {
4
+ uniqueNamesGenerator,
5
+ adjectives,
6
+ colors,
7
+ animals,
8
+ } = require("unique-names-generator");
9
+
10
+ let publishCount = 0;
11
+
12
+ const randomName = uniqueNamesGenerator({
13
+ dictionaries: [adjectives, colors, animals],
14
+ });
15
+
16
+ function generateRandomDelay() {
17
+ return 1000;
18
+ }
19
+
20
+ function checkAndRemovePrivate() {
21
+ const animation = [
22
+ "Sedang memeriksa package... ",
23
+ "Sedang memeriksa package. ",
24
+ "Sedang memeriksa package.. ",
25
+ "Sedang memeriksa package...",
26
+ ];
27
+ let currentFrame = 0;
28
+ const animationInterval = setInterval(() => {
29
+ process.stdout.write("\r" + animation[currentFrame]);
30
+ currentFrame = (currentFrame + 1) % animation.length;
31
+ }, 250);
32
+
33
+ setTimeout(() => {
34
+ clearInterval(animationInterval);
35
+ process.stdout.write("\r");
36
+ let packageJson = fs.readFileSync("package.json");
37
+ let packageData = JSON.parse(packageJson);
38
+ if (packageData.private === true) {
39
+ console.log("Sedang mengubah package menjadi public...");
40
+ delete packageData.private;
41
+ fs.writeFileSync("package.json", JSON.stringify(packageData, null, 2));
42
+ console.log("Package berhasil diubah menjadi public");
43
+ const animationDelay = [".", "..", "...", "....", "....."];
44
+ let currentFrame = 0;
45
+ const animationInterval = setInterval(() => {
46
+ process.stdout.write(animationDelay[currentFrame]);
47
+ currentFrame = (currentFrame + 1) % animationDelay.length;
48
+ }, 1000);
49
+ setTimeout(() => {
50
+ clearInterval(animationInterval);
51
+ console.log("");
52
+ checkAndRemovePrivate();
53
+ }, 5000);
54
+ } else {
55
+ console.log(
56
+ "Tidak ada lagi private: true dalam package.json. Lanjut ke langkah berikutnya."
57
+ );
58
+ const animationDelay = [".", "..", "...", "....", "....."];
59
+ let currentFrame = 0;
60
+ const animationInterval = setInterval(() => {
61
+ process.stdout.write(animationDelay[currentFrame]);
62
+ currentFrame = (currentFrame + 1) % animationDelay.length;
63
+ }, 1000);
64
+ setTimeout(() => {
65
+ clearInterval(animationInterval);
66
+ console.log("");
67
+ changePackageVersion();
68
+ }, 5000);
69
+ }
70
+ }, 10000);
71
+ }
72
+
73
+ function changePackageVersion() {
74
+ const animation = [
75
+ "Sedang mengubah versi package... ",
76
+ "Sedang mengubah versi package. ",
77
+ "Sedang mengubah versi package.. ",
78
+ "Sedang mengubah versi package...",
79
+ ];
80
+ let currentFrame = 0;
81
+ const animationInterval = setInterval(() => {
82
+ process.stdout.write("\r" + animation[currentFrame]);
83
+ currentFrame = (currentFrame + 1) % animation.length;
84
+ }, 250);
85
+
86
+ setTimeout(() => {
87
+ clearInterval(animationInterval);
88
+ process.stdout.write("\r");
89
+ let packageJson = fs.readFileSync("package.json");
90
+ let packageData = JSON.parse(packageJson);
91
+ const newVersion = `${Math.floor(Math.random() * 4) + 1}.${Math.floor(Math.random() * 4) + 1}.${Math.floor(Math.random() * 4) + 1}`;
92
+ packageData.version = newVersion;
93
+ fs.writeFileSync("package.json", JSON.stringify(packageData, null, 2));
94
+ console.log(`Versi package telah diubah ke ${newVersion}`);
95
+ publishWithDelay();
96
+ }, 10000);
97
+ }
98
+
99
+ function publishWithDelay() {
100
+ const animation = [
101
+ "Sabar lagi di proses ",
102
+ "Sabar lagi di proses. ",
103
+ "Sabar lagi di proses.. ",
104
+ "Sabar lagi di proses...",
105
+ ];
106
+ let currentFrame = 0;
107
+ const animationInterval = setInterval(() => {
108
+ process.stdout.write("\r" + animation[currentFrame]);
109
+ currentFrame = (currentFrame + 1) % animation.length;
110
+ }, 250);
111
+
112
+ let packageJson = fs.readFileSync("package.json");
113
+ let packageData = JSON.parse(packageJson);
114
+ let randomFruit = uniqueNamesGenerator({
115
+ dictionaries: [adjectives, animals, colors],
116
+ length: 2,
117
+ });
118
+ packageData.name = `${randomFruit}_z3n`;
119
+
120
+ fs.writeFileSync("package.json", JSON.stringify(packageData, null, 2));
121
+
122
+ let packageLockJson = fs.readFileSync("package-lock.json");
123
+ let packageLockData = JSON.parse(packageLockJson);
124
+ packageLockData.name = packageData.name;
125
+
126
+ fs.writeFileSync(
127
+ "package-lock.json",
128
+ JSON.stringify(packageLockData, null, 2)
129
+ );
130
+
131
+ exec("npm publish --access public", (error, stdout, stderr) => {
132
+ clearInterval(animationInterval);
133
+ process.stdout.write("\r");
134
+ if (error) {
135
+ console.error(`Error: ${error}`);
136
+ return;
137
+ }
138
+ if (
139
+ stdout.includes("Sedang mem-publish harap tunggu") &&
140
+ stdout.includes("Sukses mem-publish!")
141
+ ) {
142
+ publishCount++;
143
+ console.log(`Sukses mem-publish! Total publish: ${publishCount}`);
144
+ } else if (stdout.includes("429 Too Many Requests")) {
145
+ console.error("Error: Limit publish! Coba lagi nanti.");
146
+ return;
147
+ }
148
+ const delay = generateRandomDelay();
149
+ publishCount++;
150
+ console.log(`Sukses mem-publish! Total publish: ${publishCount}`);
151
+ console.log(`Publish selanjutnya ${delay / 1000} detik`);
152
+ setTimeout(checkAndRemovePrivate, delay);
153
+ });
154
+ }
155
+
156
+ checkAndRemovePrivate();