@yaakapp/cli 0.0.12 → 0.0.13
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 +12 -10
- package/package.json +2 -2
- package/bin/yaakcli +0 -0
package/install.cjs
CHANGED
@@ -2,6 +2,7 @@ const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
3
3
|
const zlib = require("zlib");
|
4
4
|
const https = require("https");
|
5
|
+
const {execSync} = require("child_process");
|
5
6
|
|
6
7
|
// Adjust the version you want to install. You can also make this dynamic.
|
7
8
|
const VERSION = "0.0.10";
|
@@ -10,7 +11,8 @@ const VERSION = "0.0.10";
|
|
10
11
|
const binaryName = process.platform === "win32" ? "yaakcli.exe" : "yaakcli";
|
11
12
|
|
12
13
|
// Compute the path we want to emit the binary to
|
13
|
-
const
|
14
|
+
const binaryInstallationPath = path.join(execSync("npm prefix -g").toString().trim(), "bin", binaryName)
|
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
package/bin/yaakcli
DELETED
Binary file
|