-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ops: add npm-package files for transparency
- Loading branch information
Showing
6 changed files
with
140 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### rust-x-server-stats npm package | ||
|
||
The files in the directory are the files which are part of the `rust-x-server-stats` npm package. | ||
README.md and readme.txt which are present in the npm package, are present in the root directory of the repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
{ | ||
"name": "rust-x-server-stats", | ||
"version": "0.1.1", | ||
"description": "A simple web server to display server stats over HTTP and Websockets", | ||
"main": "start.js", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"postinstall": "node ./pre-install.js", | ||
"uninstall": "node ./uninstall.js" | ||
}, | ||
|
||
"keywords": [], | ||
|
||
"license": "Apache-2.0", | ||
|
||
"homepage": "https://github.com/xamfy/x-server-stats", | ||
"files": [ | ||
"pre-install.js", | ||
"start.js", | ||
"uninstall.js", | ||
"README.md", | ||
"LICENSE" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { exec } = require("child_process"); | ||
|
||
const cargoDir = path.dirname("$HOME" + ".cargo"); | ||
|
||
// check if directory exists | ||
if (fs.existsSync(cargoDir)) { | ||
// console.log("Cargo found."); | ||
} else { | ||
const setCargo = 'PATH="/$HOME/.cargo/bin:${PATH}"'; | ||
console.log("Installing deps [cargo]."); | ||
|
||
exec( | ||
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && ${setCargo}`, | ||
(error) => { | ||
if (error) { | ||
console.log( | ||
"curl failed! Curl may not be installed on the OS. View https://curl.se/download.html to install." | ||
); | ||
console.log(error); | ||
} | ||
} | ||
); | ||
} | ||
|
||
const binp = path.join(cargoDir, "bin", "x-server-stats"); | ||
|
||
console.log("Installing and compiling x-server-stats 0.1.1..."); | ||
exec(`cargo install x-server-stats --vers 0.1.1`, (error, stdout, stderr) => { | ||
console.log(stdout); | ||
if (error || stderr) { | ||
console.log(error || stderr); | ||
} else { | ||
console.log("install finished!"); | ||
} | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env node | ||
|
||
const { exec } = require("child_process"); | ||
|
||
exec("x-server-stats", (error, stdout, stderr) => { | ||
stdout && console.log(stdout); | ||
stderr && console.log(stderr); | ||
if (error !== null) { | ||
console.log(`exec error: ${error}`); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { exec } = require("child_process"); | ||
|
||
const cargoDir = path.dirname("$HOME" + ".cargo"); | ||
|
||
// check if directory exists | ||
if (fs.existsSync(cargoDir)) { | ||
// console.log("Cargo found."); | ||
} else { | ||
const setCargo = 'PATH="/$HOME/.cargo/bin:${PATH}"'; | ||
console.log("Installing deps [cargo]."); | ||
|
||
exec( | ||
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && ${setCargo}`, | ||
(error) => { | ||
if (error) { | ||
console.log( | ||
"curl failed! Curl may not be installed on the OS. View https://curl.se/download.html to install." | ||
); | ||
console.log(error); | ||
} | ||
} | ||
); | ||
} | ||
|
||
const binp = path.join(cargoDir, "bin", "x-server-stats"); | ||
|
||
if (fs.existsSync(binp)) { | ||
console.log("Uninstalling x-server-stats..."); | ||
exec(`cargo uninstall x-server-stats`, (error, stdout, stderr) => { | ||
console.log(stdout); | ||
if (error || stderr) { | ||
console.log(error || stderr); | ||
} | ||
}); | ||
} else { | ||
console.log("x-server-stats not found skipping!"); | ||
} | ||
|
||
|