@yaakapp/cli 0.0.12 → 0.0.14
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/install.cjs +13 -11
- package/package.json +5 -3
- package/uninstall.cjs +0 -0
- package/bin/yaakcli +0 -0
package/install.cjs
CHANGED
@@ -2,15 +2,17 @@ const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
3
3
|
const zlib = require("zlib");
|
4
4
|
const https = require("https");
|
5
|
+
const {getBinaryPath, getBinaryName} = require("./util");
|
5
6
|
|
6
7
|
// Adjust the version you want to install. You can also make this dynamic.
|
7
8
|
const VERSION = "0.0.10";
|
8
9
|
|
9
10
|
// Windows binaries end with .exe so we need to special-case them.
|
10
|
-
const binaryName =
|
11
|
+
const binaryName = getBinaryName();
|
11
12
|
|
12
13
|
// Compute the path we want to emit the binary to
|
13
|
-
const
|
14
|
+
const binaryInstallationPath = getBinaryPath()
|
15
|
+
fs.mkdirSync(path.dirname(binaryInstallationPath), {recursive: true});
|
14
16
|
|
15
17
|
function makeRequest(url) {
|
16
18
|
return new Promise((resolve, reject) => {
|
@@ -82,31 +84,31 @@ async function downloadBinary() {
|
|
82
84
|
console.log(`Extracting ${tarballDownloadBuffer.length}`);
|
83
85
|
const tarballBuffer = zlib.unzipSync(tarballDownloadBuffer);
|
84
86
|
|
85
|
-
const
|
86
|
-
console.log(`Creating dir ${
|
87
|
-
fs.mkdirSync(
|
87
|
+
const dir = path.dirname(binaryInstallationPath);
|
88
|
+
console.log(`Creating dir ${dir}`);
|
89
|
+
fs.mkdirSync(dir, {recursive: true});
|
88
90
|
|
89
91
|
// Extract binary from package and write to disk
|
90
|
-
console.log(`Writing tarball to ${
|
92
|
+
console.log(`Writing tarball to ${binaryInstallationPath}`);
|
91
93
|
fs.writeFileSync(
|
92
|
-
|
94
|
+
binaryInstallationPath,
|
93
95
|
extractFileFromTarball(tarballBuffer, binaryName)
|
94
96
|
);
|
95
97
|
|
96
|
-
console.log(`Extracting tarball to ${
|
98
|
+
console.log(`Extracting tarball to ${binaryInstallationPath}`);
|
97
99
|
// Make binary executable
|
98
|
-
fs.chmodSync(
|
100
|
+
fs.chmodSync(binaryInstallationPath, "755");
|
99
101
|
|
100
102
|
console.log("Done");
|
101
103
|
}
|
102
104
|
|
103
105
|
function isPlatformSpecificPackageInstalled() {
|
104
|
-
return fs.existsSync(
|
106
|
+
return fs.existsSync(binaryInstallationPath)
|
105
107
|
}
|
106
108
|
|
107
109
|
// Skip downloading the binary if it was already installed via optionalDependencies
|
108
110
|
if (!isPlatformSpecificPackageInstalled()) {
|
109
111
|
downloadBinary().catch(console.error);
|
110
112
|
} else {
|
111
|
-
console.log(`yaakcli already exists at ${
|
113
|
+
console.log(`yaakcli already exists at ${binaryInstallationPath}`);
|
112
114
|
}
|
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yaakapp/cli",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.14",
|
4
4
|
"files": [
|
5
5
|
"install.cjs",
|
6
|
-
"
|
6
|
+
"uninstall.cjs",
|
7
|
+
"bin"
|
7
8
|
],
|
8
9
|
"scripts": {
|
9
|
-
"postinstall": "node ./install.cjs"
|
10
|
+
"postinstall": "node ./install.cjs",
|
11
|
+
"preuninstall": "node ./uninstall.cjs"
|
10
12
|
},
|
11
13
|
"bin": {
|
12
14
|
"yaakcli": "bin/yaakcli"
|
package/uninstall.cjs
ADDED
File without changes
|
package/bin/yaakcli
DELETED
Binary file
|