This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
6,836 additions
and
283 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,80 @@ | ||
|
||
const { Binary } = require("binary-install"); | ||
const os = require("os"); | ||
const cTable = require("console.table"); | ||
|
||
const error = msg => { | ||
console.error(msg); | ||
process.exit(1); | ||
}; | ||
|
||
const { version } = require("./package.json"); | ||
const name = "share"; | ||
|
||
const supportedPlatforms = [ | ||
{ | ||
TYPE: "Windows_NT", | ||
ARCHITECTURE: "x64", | ||
RUST_TARGET: "x86_64-windows", | ||
BINARY_NAME: "share.exe" | ||
}, | ||
{ | ||
TYPE: "Linux", | ||
ARCHITECTURE: "x64", | ||
RUST_TARGET: "x86_64-linux", | ||
BINARY_NAME: "share" | ||
}, | ||
{ | ||
TYPE: "Darwin", | ||
ARCHITECTURE: "x64", | ||
RUST_TARGET: "x86_64-macos", | ||
BINARY_NAME: "share" | ||
}, | ||
{ | ||
TYPE: "Darwin", | ||
ARCHITECTURE: "arm64", | ||
RUST_TARGET: "x86_64-macos", | ||
BINARY_NAME: "share" | ||
} | ||
]; | ||
|
||
const getPlatformMetadata = () => { | ||
const type = os.type(); | ||
const architecture = os.arch(); | ||
|
||
for (let supportedPlatform of supportedPlatforms) { | ||
if ( | ||
type === supportedPlatform.TYPE && | ||
architecture === supportedPlatform.ARCHITECTURE | ||
) { | ||
return supportedPlatform; | ||
} | ||
} | ||
|
||
error( | ||
`Platform with type "${type}" and architecture "${architecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${cTable.getTable( | ||
supportedPlatforms | ||
)}` | ||
); | ||
}; | ||
|
||
const getBinary = () => { | ||
const platformMetadata = getPlatformMetadata(); | ||
const url = `https://github.com/wokebuild/share/releases/download/v${version}/wokeshare-v${ version }-${ platformMetadata.RUST_TARGET }.tar.gz`; | ||
return new Binary(platformMetadata.BINARY_NAME, url, version); | ||
}; | ||
|
||
const run = () => { | ||
const binary = getBinary(); | ||
binary.run(); | ||
}; | ||
|
||
const install = () => { | ||
const binary = getBinary(); | ||
binary.install(); | ||
}; | ||
|
||
module.exports = { | ||
install, | ||
run | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
const getBinary = require('./getBinary'); | ||
getBinary().install(); | ||
#!/usr/bin/env node | ||
|
||
const { install } = require("./binary"); | ||
install(); |
Oops, something went wrong.