@taubyte/cli 0.1.13 → 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 +21 -0
- package/README.md +32 -4
- package/bin/tau +0 -0
- package/bin/version.txt +1 -0
- package/images/tau-cli-logo-box-v2.png +0 -0
- package/index.js +30 -22
- package/package.json +4 -6
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
|
-
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
[](https://github.com/taubyte/tau-cli/releases)
|
|
5
|
+
[](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
|
-
|
|
11
|
+
|
|
12
|
+
### npm
|
|
13
|
+
|
|
14
|
+
```bash
|
|
6
15
|
npm i @taubyte/cli
|
|
7
16
|
```
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
package/bin/version.txt
ADDED
|
@@ -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
|
|
13
|
-
const
|
|
14
|
-
const
|
|
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(
|
|
17
|
-
return fs.existsSync(
|
|
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(
|
|
45
|
-
if (binaryExists(
|
|
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
|
-
|
|
51
|
-
|
|
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
|
|
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
|
|
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);
|
|
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(
|
|
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(
|
|
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(
|
|
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.
|
|
4
|
-
"tau": "0.1.12",
|
|
5
|
-
"dream": "1.0.4",
|
|
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/
|
|
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/
|
|
26
|
+
"url": "https://github.com/taubyte/tau-cli/issues"
|
|
29
27
|
},
|
|
30
|
-
"homepage": "https://github.com/taubyte/
|
|
28
|
+
"homepage": "https://github.com/taubyte/tau-cli#readme",
|
|
31
29
|
"dependencies": {
|
|
32
30
|
"axios": "^1.6.5",
|
|
33
31
|
"progress": "^2.0.3",
|