@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.
Files changed (3) hide show
  1. package/install.cjs +12 -10
  2. package/package.json +2 -2
  3. 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 binaryDstPath = path.join(__dirname, "yaakcli", binaryName);
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 binaryDir = path.dirname(binaryDstPath);
86
- console.log(`Creating dir ${binaryDir}`);
87
- fs.mkdirSync(binaryDir, {recursive: true});
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 ${binaryDstPath}`);
92
+ console.log(`Writing tarball to ${binaryInstallationPath}`);
91
93
  fs.writeFileSync(
92
- binaryDstPath,
94
+ binaryInstallationPath,
93
95
  extractFileFromTarball(tarballBuffer, binaryName)
94
96
  );
95
97
 
96
- console.log(`Extracting tarball to ${binaryDstPath}`);
98
+ console.log(`Extracting tarball to ${binaryInstallationPath}`);
97
99
  // Make binary executable
98
- fs.chmodSync(binaryDstPath, "755");
100
+ fs.chmodSync(binaryInstallationPath, "755");
99
101
 
100
102
  console.log("Done");
101
103
  }
102
104
 
103
105
  function isPlatformSpecificPackageInstalled() {
104
- return fs.existsSync(binaryDstPath)
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 ${binaryDstPath}`);
113
+ console.log(`yaakcli already exists at ${binaryInstallationPath}`);
112
114
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@yaakapp/cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "files": [
5
5
  "install.cjs",
6
- "bin/cli.cjs"
6
+ "bin"
7
7
  ],
8
8
  "scripts": {
9
9
  "postinstall": "node ./install.cjs"
package/bin/yaakcli DELETED
Binary file