@taubyte/cli 0.1.12 → 0.1.15

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Taubyte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,38 @@
1
1
 
2
- `tau` is a command line tool for interacting with a Taubyte-based Cloud Network. Similar to the [web console](https://console.taubyte.com), it allows you to create and manage projects, applications, resources, and more.
2
+ <div align="center">
3
+
4
+ [![Release](https://img.shields.io/github/release/taubyte/tau-cli.svg)](https://github.com/taubyte/tau-cli/releases)
5
+ [![License](https://img.shields.io/github/license/taubyte/tau-cli)](LICENSE)
6
+ </div>
7
+
8
+ Tau CLI is Taubyte’s command-line tool for managing projects, resources, and cloud workflows.
3
9
 
4
10
  ## Installation
5
- ```shell
11
+
12
+ ### npm
13
+
14
+ ```bash
6
15
  npm i @taubyte/cli
7
16
  ```
8
17
 
9
- # Documentation
10
- For documentation head to [tau.how](https://tau.how/docs/tau)
18
+ The published package downloads the `tau` binary for your platform from [tau-cli releases](https://github.com/taubyte/tau-cli/releases) when you run the `tau` command.
19
+
20
+ ### Source
21
+
22
+ Implementation lives in the [`tau`](https://github.com/taubyte/tau) repository under [`tools/tau`](https://github.com/taubyte/tau/tree/main/tools/tau).
23
+
24
+ This repository is a **distribution** layout (similar to [dream](https://github.com/taubyte/dream)): it carries the npm wrapper, release automation, and a **`tau` git submodule** pinned to the commit used for builds.
25
+
26
+ ### Working from a git clone
27
+
28
+ ```bash
29
+ git clone https://github.com/taubyte/tau-cli.git
30
+ cd tau-cli
31
+ git submodule update --init --recursive
32
+ ```
33
+
34
+ The submodule is required if you run [GoReleaser](https://goreleaser.com/) locally or verify a release build; the npm package published to the registry does not ship the submodule (see `.npmignore`).
35
+
36
+ ## Usage
37
+
38
+ Run `tau --help` after installation for current commands and options.
package/bin/tau ADDED
Binary file
@@ -0,0 +1 @@
1
+ 0.1.15
Binary file
package/index.js CHANGED
@@ -9,12 +9,20 @@ const tar = require("tar");
9
9
  const packageJson = require("./package.json");
10
10
 
11
11
  const binaryDir = path.join(__dirname, "bin");
12
- const binaryPaths = {"tau-cli":path.join(binaryDir, "tau"), "dreamland": path.join(binaryDir, "dreamland")}
13
- const tauVersion = packageJson.tau;
14
- const dreamVersion = packageJson.dream;
12
+ const binaryPath = path.join(binaryDir, process.platform === "win32" ? "tau.exe" : "tau");
13
+ const versionFilePath = path.join(binaryDir, "version.txt");
14
+ const packageVersion = packageJson.version;
15
15
 
16
- function binaryExists(name) {
17
- return fs.existsSync(binaryPaths[name]);
16
+ function binaryExists() {
17
+ return fs.existsSync(binaryPath);
18
+ }
19
+
20
+ function versionMatches() {
21
+ if (!fs.existsSync(versionFilePath)) {
22
+ return false;
23
+ }
24
+ const installedVersion = fs.readFileSync(versionFilePath, "utf-8").trim();
25
+ return installedVersion === packageVersion;
18
26
  }
19
27
 
20
28
  function parseAssetName() {
@@ -41,16 +49,21 @@ function parseAssetName() {
41
49
  return { os, arch };
42
50
  }
43
51
 
44
- async function downloadAndExtractBinary(name, version) {
45
- if (binaryExists(name)) {
52
+ async function downloadAndExtractBinary() {
53
+ if (binaryExists() && versionMatches()) {
46
54
  return;
47
55
  }
48
56
 
57
+ const version = packageVersion;
49
58
  const { os: currentOs, arch: currentArch } = parseAssetName();
50
- const assetName = `${name}_${version}_${currentOs}_${currentArch}.tar.gz`;
51
- const assetUrl = `https://github.com/taubyte/${name}/releases/download/v${version}/${assetName}`;
59
+ if (!currentOs || !currentArch) {
60
+ throw new Error(`Unsupported platform: ${process.platform} ${process.arch}`);
61
+ }
62
+
63
+ const assetName = `tau-cli_${version}_${currentOs}_${currentArch}.tar.gz`;
64
+ const assetUrl = `https://github.com/taubyte/tau-cli/releases/download/v${version}/${assetName}`;
52
65
 
53
- console.log(`Downloading ${name} v${version}...`);
66
+ console.log(`Downloading tau-cli v${version}...`);
54
67
  const { data, headers } = await axios({
55
68
  url: assetUrl,
56
69
  method: "GET",
@@ -63,7 +76,7 @@ async function downloadAndExtractBinary(name, version) {
63
76
  complete: "=",
64
77
  incomplete: " ",
65
78
  renderThrottle: 1,
66
- total: parseInt(totalLength),
79
+ total: parseInt(totalLength, 10) || 0,
67
80
  });
68
81
 
69
82
  if (!fs.existsSync(binaryDir)) {
@@ -77,12 +90,13 @@ async function downloadAndExtractBinary(name, version) {
77
90
 
78
91
  return new Promise((resolve, reject) => {
79
92
  writer.on("finish", async () => {
80
- console.log(`Extracting ${name} v${version}...`);
93
+ console.log(`Extracting tau-cli v${version}...`);
81
94
  await tar.x({
82
95
  file: tarPath,
83
96
  C: binaryDir,
84
97
  });
85
- fs.unlinkSync(tarPath); // Remove the tarball after extraction
98
+ fs.unlinkSync(tarPath);
99
+ fs.writeFileSync(versionFilePath, version);
86
100
  resolve();
87
101
  });
88
102
  writer.on("error", reject);
@@ -90,20 +104,15 @@ async function downloadAndExtractBinary(name, version) {
90
104
  }
91
105
 
92
106
  function executeBinary() {
93
- if (!binaryExists("tau-cli")) {
107
+ if (!binaryExists()) {
94
108
  console.error("Binary not found. Please run the install script.");
95
109
  return;
96
110
  }
97
111
 
98
- // Capture arguments passed to the script, excluding the first two elements
99
112
  const args = process.argv.slice(2);
100
113
 
101
- const child = spawn(binaryPaths["tau-cli"], args, {
114
+ const child = spawn(binaryPath, args, {
102
115
  stdio: "inherit",
103
- env: {
104
- ...process.env,
105
- DREAM_BINARY: path.join(__dirname, binaryPaths["dreamland"]) // Replace with your environment variable and value
106
- }
107
116
  });
108
117
 
109
118
  child.on("error", (err) => {
@@ -113,8 +122,7 @@ function executeBinary() {
113
122
 
114
123
  async function main() {
115
124
  try {
116
- await downloadAndExtractBinary("tau-cli",tauVersion);
117
- await downloadAndExtractBinary("dreamland", dreamVersion);
125
+ await downloadAndExtractBinary();
118
126
  executeBinary();
119
127
  } catch (err) {
120
128
  console.error(err.message);
package/package.json CHANGED
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "name": "@taubyte/cli",
3
- "version": "0.1.12",
4
- "tau": "0.1.11",
5
- "dream": "1.0.3",
3
+ "version": "0.1.15",
6
4
  "description": "Node wrapper for taubyte/tau-cli",
7
5
  "bin": {
8
6
  "tau": "./index.js"
@@ -13,7 +11,7 @@
13
11
  },
14
12
  "repository": {
15
13
  "type": "git",
16
- "url": "git+https://github.com/taubyte/dreamland.git"
14
+ "url": "git+https://github.com/taubyte/tau-cli.git"
17
15
  },
18
16
  "keywords": [
19
17
  "serverless",
@@ -25,9 +23,9 @@
25
23
  "author": "Taubyte",
26
24
  "license": "MIT",
27
25
  "bugs": {
28
- "url": "https://github.com/taubyte/dreamland/issues"
26
+ "url": "https://github.com/taubyte/tau-cli/issues"
29
27
  },
30
- "homepage": "https://github.com/taubyte/dreamland#readme",
28
+ "homepage": "https://github.com/taubyte/tau-cli#readme",
31
29
  "dependencies": {
32
30
  "axios": "^1.6.5",
33
31
  "progress": "^2.0.3",