@taubyte/cli 0.1.11 → 0.1.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/README.md +1 -20
  2. package/index.js +19 -15
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -3,27 +3,8 @@
3
3
 
4
4
  ## Installation
5
5
  ```shell
6
- npm i tau
6
+ npm i @taubyte/cli
7
7
  ```
8
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
9
  # Documentation
29
10
  For documentation head to [tau.how](https://tau.how/docs/tau)
package/index.js CHANGED
@@ -9,11 +9,12 @@ const tar = require("tar");
9
9
  const packageJson = require("./package.json");
10
10
 
11
11
  const binaryDir = path.join(__dirname, "bin");
12
- const binaryPath = path.join(binaryDir, "tau");
13
- const packageVersion = packageJson.version;
12
+ const binaryPaths = {"tau-cli":path.join(binaryDir, "tau"), "dreamland": path.join(binaryDir, "dreamland")}
13
+ const tauVersion = packageJson.tau;
14
+ const dreamVersion = packageJson.dream;
14
15
 
15
- function binaryExists() {
16
- return fs.existsSync(binaryPath);
16
+ function binaryExists(name) {
17
+ return fs.existsSync(binaryPaths[name]);
17
18
  }
18
19
 
19
20
  function parseAssetName() {
@@ -40,18 +41,16 @@ function parseAssetName() {
40
41
  return { os, arch };
41
42
  }
42
43
 
43
- async function downloadAndExtractBinary() {
44
- if (binaryExists()) {
44
+ async function downloadAndExtractBinary(name, version) {
45
+ if (binaryExists(name)) {
45
46
  return;
46
47
  }
47
48
 
48
- let version = packageVersion;
49
-
50
49
  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}`;
50
+ const assetName = `${name}_${version}_${currentOs}_${currentArch}.tar.gz`;
51
+ const assetUrl = `https://github.com/taubyte/${name}/releases/download/v${version}/${assetName}`;
53
52
 
54
- console.log(`Downloading tau-cli v${version}...`);
53
+ console.log(`Downloading ${name} v${version}...`);
55
54
  const { data, headers } = await axios({
56
55
  url: assetUrl,
57
56
  method: "GET",
@@ -78,7 +77,7 @@ async function downloadAndExtractBinary() {
78
77
 
79
78
  return new Promise((resolve, reject) => {
80
79
  writer.on("finish", async () => {
81
- console.log(`Extracting tau-cli v${version}...`);
80
+ console.log(`Extracting ${name} v${version}...`);
82
81
  await tar.x({
83
82
  file: tarPath,
84
83
  C: binaryDir,
@@ -91,7 +90,7 @@ async function downloadAndExtractBinary() {
91
90
  }
92
91
 
93
92
  function executeBinary() {
94
- if (!binaryExists()) {
93
+ if (!binaryExists("tau-cli")) {
95
94
  console.error("Binary not found. Please run the install script.");
96
95
  return;
97
96
  }
@@ -99,8 +98,12 @@ function executeBinary() {
99
98
  // Capture arguments passed to the script, excluding the first two elements
100
99
  const args = process.argv.slice(2);
101
100
 
102
- const child = spawn(binaryPath, args, {
101
+ const child = spawn(binaryPaths["tau-cli"], args, {
103
102
  stdio: "inherit",
103
+ env: {
104
+ ...process.env,
105
+ DREAM_BINARY: path.join(__dirname, binaryPaths["dreamland"]) // Replace with your environment variable and value
106
+ }
104
107
  });
105
108
 
106
109
  child.on("error", (err) => {
@@ -110,7 +113,8 @@ function executeBinary() {
110
113
 
111
114
  async function main() {
112
115
  try {
113
- await downloadAndExtractBinary();
116
+ await downloadAndExtractBinary("tau-cli",tauVersion);
117
+ await downloadAndExtractBinary("dreamland", dreamVersion);
114
118
  executeBinary();
115
119
  } catch (err) {
116
120
  console.error(err.message);
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@taubyte/cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
+ "tau": "0.1.12",
5
+ "dream": "1.0.4",
4
6
  "description": "Node wrapper for taubyte/tau-cli",
5
7
  "bin": {
6
- "dream": "./index.js"
8
+ "tau": "./index.js"
7
9
  },
8
10
  "main": "index.js",
9
11
  "scripts": {