Skip to content

Commit

Permalink
Merge pull request #32 from suryavaddiraju/development
Browse files Browse the repository at this point in the history
v2.0.6
  • Loading branch information
suryavaddiraju authored May 13, 2024
2 parents beba616 + b183102 commit ab1d1dd
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ following additional notes.
## Questions

The GitHub issue tracker is for *bug reports* and *feature requests*. Please do
not use it to ask questions about how to use Requests. These questions should
not use it to ask questions about how to use irctc-api. These questions should
instead be directed to [Stack Overflow](https://stackoverflow.com/). Make sure
that your question is tagged with the `node-irctc-api` tag when asking it on
that your question is tagged with the `node.js & api` tag when asking it on
Stack Overflow, to ensure that it is answered promptly and accurately.

## Good Bug Reports
Expand Down
8 changes: 7 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ test/
api_reference.md
contribution.md
_config.yml
captcha.jpg
captcha.jpg
captcha.jpg
viu
bin
viu.exe
.log
logs
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ author:
remote_theme: jekyll/minima
plugins:
- jekyll-remote-theme
exclude: [lib/,examples/,test/,.gitignore,.npmignore,index.mjs,LICENSE,package.json,.github/,package-lock.json,_config.yml]
exclude: [lib/,examples/,test/,.gitignore,.npmignore,index.mjs,LICENSE,package.json,.github/,package-lock.json,_config.yml,"bin/"]
54 changes: 51 additions & 3 deletions lib/postinstall.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
import * as fs from "node:fs";
const JSON_data = JSON.parse(fs.readFileSync("./package.json"));
const path = JSON_data.bin.viu;
fs.chmodSync(path, 0o755);
import https from 'node:https';
import * as fs from 'node:fs';
let package_name = "";
let offline_file = "viu";
if (process.platform==='darwin'&& process.arch==='x64'){
package_name = "viu-x86_64-apple-darwin"
}
else if (process.platform==='win32'&& process.arch==='x64'){
package_name = "viu-x86_64-pc-windows-msvc.exe";
offline_file = "viu.exe";
}
else if (process.platform==='linux'&& process.arch==='x64'){
package_name = "viu-x86_64-unknown-linux-musl"
}
else if (process.platform==='linux'&& process.arch==='arm64'){
package_name = "viu-aprocess.arch64-unknown-linux-musl"
}
else if (process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version === 7){
package_name = "viu-armv7-unknown-linux-musleabihf"
}
else if(process.platform==='linux'&& process.arch==='arm' && process.config.variables.arm_version !== 7){
package_name = "viu-arm-unknown-linux-musleabihf"
}
else{
throw new Error("Platform not supported, Request to manually download the viu fromrust standard installation page and place it in the bin folder.")
}
const url = `https://github.com/atanunq/viu/releases/latest/download/${package_name}`;
function download(url, dest) {
const req = https.get(url);
req.on('response', (res) => {
if (res.statusCode === 200) {
res.pipe(dest);
}
else if (res.statusCode === 302 || res.statusCode === 301) {
download(res.headers.location, dest);
}
else{
console.error('Failed to download:', res.statusCode, res.statusMessage);
}
});
};
if (!fs.existsSync("./bin")) {
fs.mkdirSync("./bin");
}
const binaryPath = `./bin/${offline_file}`;
if (!fs.existsSync(binaryPath)) {
fs.closeSync(fs.openSync(binaryPath, 'w'));
const file = fs.createWriteStream(binaryPath);
download(url,file);
fs.chmodSync(binaryPath, 0o755);
};
57 changes: 0 additions & 57 deletions lib/preinstall.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "irctc-api",
"description": "An exclusive NodeJs only package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler from anywhere in the world",
"version": "2.0.5",
"version": "2.0.6",
"scripts": {
"preinstall": "node ./lib/preinstall.mjs",
"postinstall": "node ./lib/postinstall.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit ab1d1dd

Please sign in to comment.