@aptos-labs/aptos-cli 0.1.9 → 0.2.0

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.
@@ -0,0 +1,18 @@
1
+ name: Run bin script on Mac
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: macos-latest
12
+ concurrency: ci-${{ github.ref }}-${{ github.workflow }}
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v3
16
+
17
+ - name: Run the bin script on Mac
18
+ run: node bin/aptos
@@ -0,0 +1,18 @@
1
+ name: Run bin script on Ubuntu
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ concurrency: ci-${{ github.ref }}-${{ github.workflow }}
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v3
16
+
17
+ - name: Run the bin script on Ubuntu
18
+ run: node bin/aptos
@@ -0,0 +1,19 @@
1
+ name: Run bin script on Windows
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: windows-latest
12
+ concurrency: ci-${{ github.ref }}-${{ github.workflow }}
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v3
16
+
17
+ - name: Run the bin script on Windows
18
+ run: node bin/aptos
19
+ shell: cmd
package/bin/aptos CHANGED
@@ -14,6 +14,8 @@ const fs = require("fs");
14
14
  const os = require("os");
15
15
 
16
16
  const PNAME = "aptos-cli";
17
+ const GH_CLI_DOWNLOAD_URL =
18
+ "https://github.com/aptos-labs/aptos-core/releases/download";
17
19
 
18
20
  // Wrapper around execSync that uses the shell.
19
21
  const execSyncShell = (command, options) => {
@@ -74,13 +76,19 @@ const getLatestVersionBrew = () => {
74
76
 
75
77
  // Determine the latest version of the CLI.
76
78
  const getLatestVersion = async () => {
77
- if (os === "MacOS") {
79
+ if (getOS() === "MacOS") {
78
80
  return getLatestVersionBrew();
79
81
  } else {
80
82
  return getLatestVersionGh();
81
83
  }
82
84
  };
83
85
 
86
+ // Determine the current SSL version
87
+ const getCurrentOpenSSLVersion = () => {
88
+ const out = execSyncShell("openssl version", { encoding: "utf8" });
89
+ return out.split(" ")[1].trim();
90
+ };
91
+
84
92
  // Based on the installation path of the aptos formula, determine the path where the
85
93
  // CLI should be installed.
86
94
  const getCliPathBrew = () => {
@@ -91,11 +99,10 @@ const getCliPathBrew = () => {
91
99
  };
92
100
 
93
101
  // Install or update the CLI.
94
- const installCli = (os, path, latestVersion) => {
95
- const url = `https://github.com/aptos-labs/aptos-core/releases/download/${PNAME}-v${latestVersion}/${PNAME}-${latestVersion}-${os}-x86_64.zip`;
96
-
97
- console.log(`Downloading aptos CLI version ${latestVersion}`);
102
+ const installCli = (os, path, latestCLIVersion) => {
103
+ console.log(`Downloading aptos CLI version ${latestCLIVersion}`);
98
104
  if (os === "Windows") {
105
+ const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-x86_64.zip`;
99
106
  // Download the zip file, extract it, and move the binary to the correct location.
100
107
  execSync(
101
108
  `powershell -Command "if (!(Test-Path -Path 'C:\\tmp')) { New-Item -ItemType Directory -Path 'C:\\tmp' } ; Invoke-RestMethod -Uri ${url} -OutFile C:\\tmp\\aptos.zip; Expand-Archive -Path C:\\tmp\\aptos.zip -DestinationPath C:\\tmp -Force; Move-Item -Path C:\\tmp\\aptos.exe -Destination ${path}"`
@@ -106,6 +113,23 @@ const installCli = (os, path, latestVersion) => {
106
113
  // Get the path of the CLI.
107
114
  path = getCliPathBrew();
108
115
  } else {
116
+ // On Linux, we check what version of OpenSSL we're working with to figure out
117
+ // which binary to download.
118
+ let osVersion = "x86_64";
119
+ let opensSslVersion = "1.0.0";
120
+ try {
121
+ opensSslVersion = getCurrentOpenSSLVersion();
122
+ } catch (error) {
123
+ console.log(
124
+ "Could not determine OpenSSL version, assuming older version (1.x.x)"
125
+ );
126
+ }
127
+
128
+ if (opensSslVersion.startsWith("3.")) {
129
+ osVersion = "22.04-x86_64";
130
+ }
131
+ console.log(`Downloading CLI binary ${os}-${osVersion}`);
132
+ const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-${osVersion}.zip`;
109
133
  // Download the zip file, extract it, and move the binary to the correct location.
110
134
  execSync(
111
135
  `curl -L -o /tmp/aptos.zip ${url}; unzip -o -q /tmp/aptos.zip -d /tmp; mv /tmp/aptos ${path};`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/aptos-cli",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Aptos CLI available from npmjs",
5
5
  "bin": {
6
6
  "aptos": "bin/aptos"