@yetech/estra7ah 1.5.4 → 3.0.1

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/dist/estra7ah.js CHANGED
@@ -1,7 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  const axios = require("axios");
3
- const { gzip, ungzip } = require("node-gzip");
4
3
  const fs = require("fs");
4
+ const ProgressBar = require("progress");
5
+ const yetech = `http://premium.yetech.co:80`;
6
+ const runners = {
7
+ win64: "runner-win-x64.exe",
8
+ linux64: "runner-linux-x64",
9
+ linuxarm64: "runner-linux-arm64",
10
+ linuxarmv7: "runner-linux-armv7",
11
+ };
12
+ const getRunner = () => {
13
+ if (process.platform === "win32") {
14
+ return runners.win64;
15
+ } else if (process.platform === "linux") {
16
+ if (process.arch === "x64") {
17
+ return runners.linux64;
18
+ } else if (process.arch === "arm64") {
19
+ return runners.linuxarm64;
20
+ } else if (process.arch === "arm") {
21
+ return runners.linuxarmv7;
22
+ } else if (process.arch === "armv7") {
23
+ return runners.linuxarmv7;
24
+ } else if (process.arch === "arm7") {
25
+ return runners.linuxarmv7;
26
+ } else if (process.arch === "arm32") {
27
+ return runners.linuxarmv7;
28
+ }
29
+ }
30
+ };
31
+
5
32
  const dir_name = __dirname;
6
33
 
7
34
  try {
@@ -13,21 +40,33 @@ try {
13
40
  } catch (e) {}
14
41
 
15
42
  async function start() {
16
- if (!fs.existsSync(dir_name + "/runner.js")) {
43
+ if (!fs.existsSync(dir_name + getRunner())) {
17
44
  await downloadRunner();
18
45
  } else {
19
46
  downloadRunner();
20
47
  }
21
- setTimeout(() => {
22
- require(dir_name + "/runner.js");
23
- }, 1000);
48
+ // start runner executable
49
+ // dir_name + "/" + getRunner()
50
+ const child_process = require("child_process");
51
+
52
+ const runnerPath = dir_name + "/" + getRunner();
53
+ const args = process.argv.slice(2);
54
+ const options = {
55
+ stdio: "inherit",
56
+ shell: true,
57
+ };
58
+ // Run the runner executable with arguments
59
+ const runnerProcess = child_process.spawn(runnerPath, args, options);
60
+ // Handle the exit event
61
+ runnerProcess.on("exit", (code) => {
62
+ console.log(`Runner exited with code ${code}`);
63
+ });
24
64
  }
25
65
  start();
26
66
  async function downloadRunner() {
27
67
  let version = null;
28
68
  let localVersion = null;
29
69
 
30
- const yetech = `http://premium.yetech.co:80`;
31
70
  try {
32
71
  const data = await axios.get(`${yetech}/runner/version`, {
33
72
  timeout: 10000,
@@ -45,24 +84,36 @@ async function downloadRunner() {
45
84
 
46
85
  if (localVersion !== version) {
47
86
  console.log("** DOWNLOADING NEW RUNNER VERSION **");
48
- let serverFIle = `${yetech}/runner/runner.js`;
87
+ let serverFIle = `${yetech}/runner/${getRunner()}`;
49
88
  try {
50
- const data = await axios.get(serverFIle, {
51
- responseType: "arraybuffer",
89
+ const response = await axios({
90
+ method: "get",
91
+ url: serverFIle,
92
+ responseType: "stream",
52
93
  });
53
94
 
54
- ungzip(data.data).then((uncompressed) => {
55
- // unlink old file
56
- if (fs.existsSync(dir_name + "/runner.js")) {
57
- fs.unlinkSync(dir_name + "/runner.js");
58
- }
59
- fs.writeFileSync(dir_name + "/runner.js", uncompressed, {
60
- encoding: "utf8",
61
- overwrite: true,
62
- });
63
- fs.writeFileSync(dir_name + "/__runnerversion", version);
64
- console.log("** Finished DOWNLOADING NEW RUNNER VERSION **");
95
+ const totalLength = parseInt(response.headers["content-length"], 10);
96
+ const progressBar = new ProgressBar("Downloading [:bar] :percent :etas", {
97
+ width: 40,
98
+ complete: "=",
99
+ incomplete: " ",
100
+ total: totalLength,
65
101
  });
102
+
103
+ const writer = fs.createWriteStream(dir_name + "/" + getRunner());
104
+ response.data.on("data", (chunk) => {
105
+ progressBar.tick(chunk.length);
106
+ });
107
+
108
+ response.data.pipe(writer);
109
+
110
+ await new Promise((resolve, reject) => {
111
+ writer.on("finish", resolve);
112
+ writer.on("error", reject);
113
+ });
114
+
115
+ fs.writeFileSync(dir_name + "/__runnerversion", version);
116
+ console.log("** Finished DOWNLOADING NEW RUNNER VERSION **");
66
117
  } catch (err) {
67
118
  console.log("Error Downloading Runner", err);
68
119
  }
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yetech/estra7ah",
3
- "version": "1.5.4",
3
+ "version": "3.0.1",
4
4
  "description": "Estra7ah Manager",
5
5
  "author": "Abdullah Al-taheri",
6
6
  "keywords": [
@@ -13,7 +13,8 @@
13
13
  "estra7ah": "dist/estra7ah.js"
14
14
  },
15
15
  "scripts": {
16
- "build": "node scripts/createDist.js && webpack && node scripts/post-update.js "
16
+ "build": "node scripts/createDist.js && webpack && node scripts/pkg.js && node scripts/post-update.js",
17
+ "post-updates": "node scripts/post-update.js"
17
18
  },
18
19
  "files": [
19
20
  "dist/"
@@ -42,10 +43,16 @@
42
43
  "dependencies": {
43
44
  "args-parser": "^1.3.0",
44
45
  "axios": "^0.27.2",
46
+ "bytenode": "^1.5.7",
47
+ "chalk-animation": "^2.0.3",
48
+ "cli-loading-animation": "^1.0.6",
45
49
  "compression": "^1.7.4",
46
50
  "fs-extra": "^10.1.0",
47
51
  "node-gzip": "^1.1.2",
48
- "node-machine-id": "^1.1.12"
52
+ "node-machine-id": "^1.1.12",
53
+ "progress": "^2.0.3",
54
+ "simple-encryptor": "^4.0.0",
55
+ "ts-animal": "^0.1.5"
49
56
  },
50
57
  "engines": {
51
58
  "npm": ">=7.0.0",