@taubyte/cli 0.1.11
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/README.md +29 -0
- package/index.js +120 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
```shell
|
|
6
|
+
npm i tau
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Login
|
|
10
|
+
|
|
11
|
+
`tau login`
|
|
12
|
+
- opens selection with default already selected
|
|
13
|
+
- simply logs in if only default available
|
|
14
|
+
- will open new if no profiles found
|
|
15
|
+
`tau login --new` for new
|
|
16
|
+
- `--set-default` for making this new auth the default
|
|
17
|
+
`tau login <profile-name>` for using a specific profile
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Environment Variables:
|
|
21
|
+
- `TAUBYTE_PROJECT` Selected project
|
|
22
|
+
- `TAUBYTE_PROFILE` Selected profile
|
|
23
|
+
- `TAUBYTE_APPLICATION` Selected application
|
|
24
|
+
- `TAUBYTE_CONFIG (default: ~/tau.yaml)` Config location
|
|
25
|
+
- `TAUBYTE_SESSION (default: /tmp/tau-<shell-pid>)` Session location
|
|
26
|
+
- `DREAM_BINARY (default: $GOPATH/dream)` Dream binary location
|
|
27
|
+
|
|
28
|
+
# Documentation
|
|
29
|
+
For documentation head to [tau.how](https://tau.how/docs/tau)
|
package/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const axios = require("axios");
|
|
6
|
+
const ProgressBar = require("progress");
|
|
7
|
+
const { spawn } = require("child_process");
|
|
8
|
+
const tar = require("tar");
|
|
9
|
+
const packageJson = require("./package.json");
|
|
10
|
+
|
|
11
|
+
const binaryDir = path.join(__dirname, "bin");
|
|
12
|
+
const binaryPath = path.join(binaryDir, "tau");
|
|
13
|
+
const packageVersion = packageJson.version;
|
|
14
|
+
|
|
15
|
+
function binaryExists() {
|
|
16
|
+
return fs.existsSync(binaryPath);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseAssetName() {
|
|
20
|
+
let os, arch;
|
|
21
|
+
|
|
22
|
+
if (process.platform === "darwin") {
|
|
23
|
+
os = "darwin";
|
|
24
|
+
} else if (process.platform === "linux") {
|
|
25
|
+
os = "linux";
|
|
26
|
+
} else if (process.platform === "win32") {
|
|
27
|
+
os = "windows";
|
|
28
|
+
} else {
|
|
29
|
+
os = null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (process.arch === "x64") {
|
|
33
|
+
arch = "amd64";
|
|
34
|
+
} else if (process.arch === "arm64") {
|
|
35
|
+
arch = "arm64";
|
|
36
|
+
} else {
|
|
37
|
+
arch = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { os, arch };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function downloadAndExtractBinary() {
|
|
44
|
+
if (binaryExists()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let version = packageVersion;
|
|
49
|
+
|
|
50
|
+
const { os: currentOs, arch: currentArch } = parseAssetName();
|
|
51
|
+
const assetName = `tau-cli_${version}_${currentOs}_${currentArch}.tar.gz`;
|
|
52
|
+
const assetUrl = `https://github.com/taubyte/tau-cli/releases/download/v${version}/${assetName}`;
|
|
53
|
+
|
|
54
|
+
console.log(`Downloading tau-cli v${version}...`);
|
|
55
|
+
const { data, headers } = await axios({
|
|
56
|
+
url: assetUrl,
|
|
57
|
+
method: "GET",
|
|
58
|
+
responseType: "stream",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const totalLength = headers["content-length"];
|
|
62
|
+
const progressBar = new ProgressBar("-> downloading [:bar] :percent :etas", {
|
|
63
|
+
width: 40,
|
|
64
|
+
complete: "=",
|
|
65
|
+
incomplete: " ",
|
|
66
|
+
renderThrottle: 1,
|
|
67
|
+
total: parseInt(totalLength),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!fs.existsSync(binaryDir)) {
|
|
71
|
+
fs.mkdirSync(binaryDir);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const tarPath = path.join(binaryDir, assetName);
|
|
75
|
+
const writer = fs.createWriteStream(tarPath);
|
|
76
|
+
data.on("data", (chunk) => progressBar.tick(chunk.length));
|
|
77
|
+
data.pipe(writer);
|
|
78
|
+
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
writer.on("finish", async () => {
|
|
81
|
+
console.log(`Extracting tau-cli v${version}...`);
|
|
82
|
+
await tar.x({
|
|
83
|
+
file: tarPath,
|
|
84
|
+
C: binaryDir,
|
|
85
|
+
});
|
|
86
|
+
fs.unlinkSync(tarPath); // Remove the tarball after extraction
|
|
87
|
+
resolve();
|
|
88
|
+
});
|
|
89
|
+
writer.on("error", reject);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function executeBinary() {
|
|
94
|
+
if (!binaryExists()) {
|
|
95
|
+
console.error("Binary not found. Please run the install script.");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Capture arguments passed to the script, excluding the first two elements
|
|
100
|
+
const args = process.argv.slice(2);
|
|
101
|
+
|
|
102
|
+
const child = spawn(binaryPath, args, {
|
|
103
|
+
stdio: "inherit",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
child.on("error", (err) => {
|
|
107
|
+
console.error("Failed to start binary:", err);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function main() {
|
|
112
|
+
try {
|
|
113
|
+
await downloadAndExtractBinary();
|
|
114
|
+
executeBinary();
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(err.message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taubyte/cli",
|
|
3
|
+
"version": "0.1.11",
|
|
4
|
+
"description": "Node wrapper for taubyte/tau-cli",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dream": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/taubyte/dreamland.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"serverless",
|
|
18
|
+
"cloud",
|
|
19
|
+
"hosting",
|
|
20
|
+
"webassembly",
|
|
21
|
+
"wasm"
|
|
22
|
+
],
|
|
23
|
+
"author": "Taubyte",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/taubyte/dreamland/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/taubyte/dreamland#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^1.6.5",
|
|
31
|
+
"progress": "^2.0.3",
|
|
32
|
+
"tar": "^6.2.0"
|
|
33
|
+
}
|
|
34
|
+
}
|