@aptos-labs/aptos-cli 1.1.0 → 1.1.1
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 +8 -0
- package/bin/aptos.ts +3 -1
- package/bin/tasks/run.ts +6 -2
- package/bin/utils/parseCommandOptions.ts +4 -4
- package/dist/aptos.d.ts +2 -0
- package/dist/aptos.js +26 -0
- package/dist/aptos.js.map +1 -0
- package/dist/tasks/install.d.ts +1 -0
- package/dist/tasks/install.js +42 -0
- package/dist/tasks/install.js.map +1 -0
- package/dist/tasks/run.d.ts +1 -0
- package/dist/tasks/run.js +21 -0
- package/dist/tasks/run.js.map +1 -0
- package/dist/tasks/update.d.ts +1 -0
- package/dist/tasks/update.js +33 -0
- package/dist/tasks/update.js.map +1 -0
- package/dist/utils/aptosExecutableIsAvailable.d.ts +1 -0
- package/dist/utils/aptosExecutableIsAvailable.js +11 -0
- package/dist/utils/aptosExecutableIsAvailable.js.map +1 -0
- package/dist/utils/brewOperations.d.ts +1 -0
- package/dist/utils/brewOperations.js +8 -0
- package/dist/utils/brewOperations.js.map +1 -0
- package/dist/utils/consts.d.ts +2 -0
- package/dist/utils/consts.js +3 -0
- package/dist/utils/consts.js.map +1 -0
- package/dist/utils/execSyncShell.d.ts +1 -0
- package/dist/utils/execSyncShell.js +5 -0
- package/dist/utils/execSyncShell.js.map +1 -0
- package/dist/utils/getLocalBinPath.d.ts +1 -0
- package/dist/utils/getLocalBinPath.js +30 -0
- package/dist/utils/getLocalBinPath.js.map +1 -0
- package/dist/utils/getUserOs.d.ts +1 -0
- package/dist/utils/getUserOs.js +15 -0
- package/dist/utils/getUserOs.js.map +1 -0
- package/dist/utils/ghOperations.d.ts +1 -0
- package/dist/utils/ghOperations.js +12 -0
- package/dist/utils/ghOperations.js.map +1 -0
- package/dist/utils/handleHelpOptions.d.ts +2 -0
- package/dist/utils/handleHelpOptions.js +16 -0
- package/dist/utils/handleHelpOptions.js.map +1 -0
- package/dist/utils/parseCommandOptions.d.ts +5 -0
- package/dist/utils/parseCommandOptions.js +21 -0
- package/dist/utils/parseCommandOptions.js.map +1 -0
- package/dist/utils/versions.d.ts +1 -0
- package/dist/utils/versions.js +6 -0
- package/dist/utils/versions.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,14 @@ To use the Aptos CLI, in your project environment, run the `npx aptos` command,
|
|
|
34
34
|
npx aptos
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
### Using a Custom Binary
|
|
38
|
+
|
|
39
|
+
If you already have the Aptos CLI binary installed on your system, you can specify its path to use it directly:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx aptos --binary-path /path/to/aptos <command>
|
|
43
|
+
```
|
|
44
|
+
|
|
37
45
|
## Updating the Aptos CLI
|
|
38
46
|
|
|
39
47
|
To update the Aptos CLI, you can run the following command within your project environment:
|
package/bin/aptos.ts
CHANGED
|
@@ -19,6 +19,7 @@ program
|
|
|
19
19
|
.helpOption(false)
|
|
20
20
|
.option("-i, --install", "install the latest version of the CLI")
|
|
21
21
|
.option("-u, --update", "update the CLI to the latest version")
|
|
22
|
+
.option("-b, --binary-path <path>", "path to an existing Aptos CLI binary")
|
|
22
23
|
.allowUnknownOption();
|
|
23
24
|
|
|
24
25
|
program.parse(process.argv);
|
|
@@ -27,13 +28,14 @@ const main = async () => {
|
|
|
27
28
|
const options = {
|
|
28
29
|
install: program.opts().install,
|
|
29
30
|
update: program.opts().update,
|
|
31
|
+
binaryPath: program.opts().binaryPath,
|
|
30
32
|
};
|
|
31
33
|
const unknownOptions = program.args;
|
|
32
34
|
|
|
33
35
|
// Manually check for `--help` and handle the CLI `--help`
|
|
34
36
|
if (process.argv.includes("--help")) {
|
|
35
37
|
// Forward to the CLI
|
|
36
|
-
return runCLI(unknownOptions);
|
|
38
|
+
return runCLI(unknownOptions, options.binaryPath);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
await parseCommandOptions(options, unknownOptions);
|
package/bin/tasks/run.ts
CHANGED
|
@@ -4,9 +4,13 @@ import { existsSync } from "fs";
|
|
|
4
4
|
import { getOS } from "../utils/getUserOs.js";
|
|
5
5
|
import { getLocalBinPath } from "../utils/getLocalBinPath.js";
|
|
6
6
|
|
|
7
|
-
export const runCLI = async (args: string[] = []) => {
|
|
8
|
-
const path = getLocalBinPath();
|
|
7
|
+
export const runCLI = async (args: string[] = [], binaryPath?: string) => {
|
|
8
|
+
const path = binaryPath || getLocalBinPath();
|
|
9
9
|
if (!existsSync(path)) {
|
|
10
|
+
if (binaryPath) {
|
|
11
|
+
console.error(`Error: Binary not found at specified path: ${binaryPath}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
10
14
|
console.log(
|
|
11
15
|
"Aptos CLI not installed, run `npx aptos --install` to install"
|
|
12
16
|
);
|
|
@@ -5,7 +5,7 @@ import { updateCli } from "../tasks/update.js";
|
|
|
5
5
|
import { getLocalBinPath } from "./getLocalBinPath.js";
|
|
6
6
|
|
|
7
7
|
export const parseCommandOptions = async (
|
|
8
|
-
options: { install: boolean; update: boolean },
|
|
8
|
+
options: { install: boolean; update: boolean; binaryPath?: string },
|
|
9
9
|
unknownOptions: string[]
|
|
10
10
|
) => {
|
|
11
11
|
// if `--install` flag is set, only install the cli and dont run it
|
|
@@ -20,9 +20,9 @@ export const parseCommandOptions = async (
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// if no flags are set, install and run the cli
|
|
23
|
-
const path = getLocalBinPath();
|
|
24
|
-
if (!existsSync(path)) {
|
|
23
|
+
const path = options.binaryPath || getLocalBinPath();
|
|
24
|
+
if (!options.binaryPath && !existsSync(path)) {
|
|
25
25
|
await installCli();
|
|
26
26
|
}
|
|
27
|
-
await runCLI(unknownOptions);
|
|
27
|
+
await runCLI(unknownOptions, options.binaryPath);
|
|
28
28
|
};
|
package/dist/aptos.d.ts
ADDED
package/dist/aptos.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { parseCommandOptions } from "./utils/parseCommandOptions.js";
|
|
4
|
+
import { runCLI } from "./tasks/run.js";
|
|
5
|
+
program
|
|
6
|
+
.name("aptos")
|
|
7
|
+
.helpOption(false)
|
|
8
|
+
.option("-i, --install", "install the latest version of the CLI")
|
|
9
|
+
.option("-u, --update", "update the CLI to the latest version")
|
|
10
|
+
.option("-b, --binary-path <path>", "path to an existing Aptos CLI binary")
|
|
11
|
+
.allowUnknownOption();
|
|
12
|
+
program.parse(process.argv);
|
|
13
|
+
const main = async () => {
|
|
14
|
+
const options = {
|
|
15
|
+
install: program.opts().install,
|
|
16
|
+
update: program.opts().update,
|
|
17
|
+
binaryPath: program.opts().binaryPath,
|
|
18
|
+
};
|
|
19
|
+
const unknownOptions = program.args;
|
|
20
|
+
if (process.argv.includes("--help")) {
|
|
21
|
+
return runCLI(unknownOptions, options.binaryPath);
|
|
22
|
+
}
|
|
23
|
+
await parseCommandOptions(options, unknownOptions);
|
|
24
|
+
};
|
|
25
|
+
main().catch(console.error);
|
|
26
|
+
//# sourceMappingURL=aptos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptos.js","sourceRoot":"","sources":["../bin/aptos.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,UAAU,CAAC,KAAK,CAAC;KACjB,MAAM,CAAC,eAAe,EAAE,uCAAuC,CAAC;KAChE,MAAM,CAAC,cAAc,EAAE,sCAAsC,CAAC;KAC9D,MAAM,CAAC,0BAA0B,EAAE,sCAAsC,CAAC;KAC1E,kBAAkB,EAAE,CAAC;AAExB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACtB,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO;QAC/B,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM;QAC7B,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,UAAU;KACtC,CAAC;IACF,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAGpC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAEpC,OAAO,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const installCli: () => Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { GH_CLI_DOWNLOAD_URL, PNAME } from "../utils/consts.js";
|
|
4
|
+
import { execSyncShell } from "../utils/execSyncShell.js";
|
|
5
|
+
import { getCurrentOpenSSLVersion } from "../utils/versions.js";
|
|
6
|
+
import { getOS } from "../utils/getUserOs.js";
|
|
7
|
+
import { getLocalBinPath } from "../utils/getLocalBinPath.js";
|
|
8
|
+
import { getLatestVersionGh } from "../utils/ghOperations.js";
|
|
9
|
+
export const installCli = async () => {
|
|
10
|
+
const path = getLocalBinPath();
|
|
11
|
+
if (existsSync(path)) {
|
|
12
|
+
console.log("Aptos CLI is already installed");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const latestCLIVersion = await getLatestVersionGh();
|
|
16
|
+
console.log(`Downloading aptos CLI version ${latestCLIVersion}`);
|
|
17
|
+
const os = getOS();
|
|
18
|
+
if (os === "Windows") {
|
|
19
|
+
const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-x86_64.zip`;
|
|
20
|
+
execSync(`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}\""`);
|
|
21
|
+
}
|
|
22
|
+
else if (os === "MacOS") {
|
|
23
|
+
execSyncShell("brew install aptos", { encoding: "utf8" });
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
let osVersion = "x86_64";
|
|
27
|
+
let opensSslVersion = "1.0.0";
|
|
28
|
+
try {
|
|
29
|
+
opensSslVersion = getCurrentOpenSSLVersion();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.log("Could not determine OpenSSL version, assuming older version (1.x.x)");
|
|
33
|
+
}
|
|
34
|
+
if (opensSslVersion.startsWith("3.")) {
|
|
35
|
+
osVersion = "22.04-x86_64";
|
|
36
|
+
}
|
|
37
|
+
console.log(`Downloading CLI binary ${os}-${osVersion}`);
|
|
38
|
+
const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-${osVersion}.zip`;
|
|
39
|
+
execSync(`curl -L -o /tmp/aptos.zip ${url}; unzip -o -q /tmp/aptos.zip -d /tmp; mv /tmp/aptos ${path};`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../bin/tasks/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;IACnC,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;IAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,EAAE,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,iCAAiC,gBAAgB,EAAE,CAAC,CAAC;IACjE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAEnB,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,GAAG,mBAAmB,IAAI,KAAK,KAAK,gBAAgB,IAAI,KAAK,IAAI,gBAAgB,IAAI,EAAE,aAAa,CAAC;QAEjH,QAAQ,CACN,oIAAoI,GAAG,4JAA4J,IAAI,KAAK,CAC7S,CAAC;IACJ,CAAC;SAAM,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QAE1B,aAAa,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QAGN,IAAI,SAAS,GAAG,QAAQ,CAAC;QACzB,IAAI,eAAe,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC;YACH,eAAe,GAAG,wBAAwB,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CACT,qEAAqE,CACtE,CAAC;QACJ,CAAC;QAED,IAAI,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,SAAS,GAAG,cAAc,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,GAAG,mBAAmB,IAAI,KAAK,KAAK,gBAAgB,IAAI,KAAK,IAAI,gBAAgB,IAAI,EAAE,IAAI,SAAS,MAAM,CAAC;QAEvH,QAAQ,CACN,6BAA6B,GAAG,uDAAuD,IAAI,GAAG,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runCLI: (args?: string[], binaryPath?: string) => Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { getOS } from "../utils/getUserOs.js";
|
|
4
|
+
import { getLocalBinPath } from "../utils/getLocalBinPath.js";
|
|
5
|
+
export const runCLI = async (args = [], binaryPath) => {
|
|
6
|
+
const path = binaryPath || getLocalBinPath();
|
|
7
|
+
if (!existsSync(path)) {
|
|
8
|
+
if (binaryPath) {
|
|
9
|
+
console.error(`Error: Binary not found at specified path: ${binaryPath}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
console.log("Aptos CLI not installed, run `npx aptos --install` to install");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const os = getOS();
|
|
16
|
+
spawn(path, args, {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
shell: os === "Windows",
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../bin/tasks/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAiB,EAAE,EAAE,UAAmB,EAAE,EAAE;IACvE,MAAM,IAAI,GAAG,UAAU,IAAI,eAAe,EAAE,CAAC;IAC7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,UAAU,EAAE,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,GAAG,CACT,+DAA+D,CAChE,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAInB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE;QAChB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,EAAE,KAAK,SAAS;KACxB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const updateCli: () => Promise<NonSharedBuffer | undefined>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { getLocalBinPath } from "../utils/getLocalBinPath.js";
|
|
3
|
+
import { execSync } from "child_process";
|
|
4
|
+
import { getOS } from "../utils/getUserOs.js";
|
|
5
|
+
import { getLatestVersionGh } from "../utils/ghOperations.js";
|
|
6
|
+
import { execSyncShell } from "../utils/execSyncShell.js";
|
|
7
|
+
import { installCli } from "./install.js";
|
|
8
|
+
export const updateCli = async () => {
|
|
9
|
+
const path = getLocalBinPath();
|
|
10
|
+
if (!existsSync(path)) {
|
|
11
|
+
console.log("Aptos CLI not installed, run `npx aptos --install` to install");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (getOS() === "MacOS") {
|
|
15
|
+
return execSync("brew upgrade aptos");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const latestVersion = await getLatestVersionGh();
|
|
19
|
+
const currentVersion = execSyncShell(`${path} --version`, {
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
})
|
|
22
|
+
.trim()
|
|
23
|
+
.split(" ")[1];
|
|
24
|
+
if (currentVersion !== latestVersion) {
|
|
25
|
+
console.log(`A newer version of the CLI is available: ${latestVersion}, installing...`);
|
|
26
|
+
await installCli();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(`CLI is up to date`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../bin/tasks/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAClC,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;IAE/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,+DAA+D,CAChE,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,KAAK,EAAE,KAAK,OAAO,EAAE,CAAC;QAExB,OAAO,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,MAAM,kBAAkB,EAAE,CAAC;QAEjD,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,IAAI,YAAY,EAAE;YACxD,QAAQ,EAAE,MAAM;SACjB,CAAC;aACC,IAAI,EAAE;aACN,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjB,IAAI,cAAc,KAAK,aAAa,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CACT,4CAA4C,aAAa,iBAAiB,CAC3E,CAAC;YACF,MAAM,UAAU,EAAE,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const executableIsAvailable: (name: any) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { execSyncShell } from "./execSyncShell.js";
|
|
2
|
+
export const executableIsAvailable = (name) => {
|
|
3
|
+
try {
|
|
4
|
+
execSyncShell(`which ${name}`, { encoding: "utf8" });
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=aptosExecutableIsAvailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptosExecutableIsAvailable.js","sourceRoot":"","sources":["../../bin/utils/aptosExecutableIsAvailable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,EAAE;IAC5C,IAAI,CAAC;QACH,aAAa,CAAC,SAAS,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCliPathBrew: () => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { execSyncShell } from "./execSyncShell.js";
|
|
2
|
+
export const getCliPathBrew = () => {
|
|
3
|
+
const directory = execSyncShell("brew --prefix aptos", { encoding: "utf8" })
|
|
4
|
+
.toString()
|
|
5
|
+
.trim();
|
|
6
|
+
return `${directory}/bin/aptos`;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=brewOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brewOperations.js","sourceRoot":"","sources":["../../bin/utils/brewOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,SAAS,GAAG,aAAa,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;SACzE,QAAQ,EAAE;SACV,IAAI,EAAE,CAAC;IACV,OAAO,GAAG,SAAS,YAAY,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../bin/utils/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AACjC,MAAM,CAAC,MAAM,mBAAmB,GAC9B,4DAA4D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const execSyncShell: (command: any, options: any) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execSyncShell.js","sourceRoot":"","sources":["../../bin/utils/execSyncShell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IAChD,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLocalBinPath: () => any;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dirname } from "path";
|
|
2
|
+
import { executableIsAvailable } from "./aptosExecutableIsAvailable.js";
|
|
3
|
+
import { getCliPathBrew } from "./brewOperations.js";
|
|
4
|
+
import { PNAME } from "./consts.js";
|
|
5
|
+
import { getOS } from "./getUserOs.js";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
export const getLocalBinPath = () => {
|
|
8
|
+
let path;
|
|
9
|
+
const os = getOS();
|
|
10
|
+
if (os === "MacOS") {
|
|
11
|
+
const brewInstalled = executableIsAvailable("brew");
|
|
12
|
+
if (!brewInstalled) {
|
|
13
|
+
throw "Please install brew to continue: https://brew.sh/";
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
path = getCliPathBrew();
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
path = "";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (os === "Windows") {
|
|
23
|
+
path = `${dirname(fileURLToPath(import.meta.url))}\\${PNAME}.exe`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
path = `${dirname(fileURLToPath(import.meta.url))}/${PNAME}`;
|
|
27
|
+
}
|
|
28
|
+
return path;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=getLocalBinPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocalBinPath.js","sourceRoot":"","sources":["../../bin/utils/getLocalBinPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAI,IAAI,CAAC;IACT,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QAEnB,MAAM,aAAa,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,mDAAmD,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC;YACH,IAAI,GAAG,cAAc,EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;SAAM,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC;IACpE,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC;IAC/D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getOS: () => "MacOS" | "Ubuntu" | "Windows";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { platform } from "os";
|
|
2
|
+
export const getOS = () => {
|
|
3
|
+
const osPlatform = platform();
|
|
4
|
+
switch (osPlatform) {
|
|
5
|
+
case "darwin":
|
|
6
|
+
return "MacOS";
|
|
7
|
+
case "linux":
|
|
8
|
+
return "Ubuntu";
|
|
9
|
+
case "win32":
|
|
10
|
+
return "Windows";
|
|
11
|
+
default:
|
|
12
|
+
throw new Error(`Unsupported OS ${osPlatform}`);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=getUserOs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserOs.js","sourceRoot":"","sources":["../../bin/utils/getUserOs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAK9B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,MAAM,UAAU,GAAG,QAAQ,EAAE,CAAC;IAC9B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,SAAS,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLatestVersionGh: () => Promise<any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PNAME } from "./consts.js";
|
|
2
|
+
export const getLatestVersionGh = async () => {
|
|
3
|
+
const prefix = `${PNAME}-v`;
|
|
4
|
+
const response = await (await fetch("https://api.github.com/repos/aptos-labs/aptos-core/releases?per_page=100")).json();
|
|
5
|
+
for (const release of response) {
|
|
6
|
+
if (release["tag_name"].startsWith(`${prefix}`)) {
|
|
7
|
+
return release.tag_name.replace(`${prefix}`, "");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
throw "Could not determine latest version of Aptos CLI";
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ghOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ghOperations.js","sourceRoot":"","sources":["../../bin/utils/ghOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,IAAI,EAAE;IAC3C,MAAM,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CACrB,MAAM,KAAK,CACT,0EAA0E,CAC3E,CACF,CAAC,IAAI,EAAE,CAAC;IACT,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;YAChD,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,iDAAiD,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
export const handleHelpOptions = (program, unknownOptions) => {
|
|
3
|
+
const cliHelp = spawnSync(`aptos`, unknownOptions, {
|
|
4
|
+
stdio: "pipe",
|
|
5
|
+
encoding: "utf-8",
|
|
6
|
+
});
|
|
7
|
+
const commanderHelp = program.helpInformation();
|
|
8
|
+
const commanderOptionsOnly = commanderHelp
|
|
9
|
+
.split("\n")
|
|
10
|
+
.filter((line) => !line.startsWith("Usage") && !line.startsWith("Options"))
|
|
11
|
+
.join("\n");
|
|
12
|
+
const combinedHelp = cliHelp.stdout.replace("Options:", `Options:\n${commanderOptionsOnly.trim()}`);
|
|
13
|
+
console.log(combinedHelp);
|
|
14
|
+
return;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=handleHelpOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleHelpOptions.js","sourceRoot":"","sources":["../../bin/utils/handleHelpOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAgB,EAChB,cAAwB,EACxB,EAAE;IAEF,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE;QACjD,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAGhD,MAAM,oBAAoB,GAAG,aAAa;SACvC,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAC1E,IAAI,CAAC,IAAI,CAAC,CAAC;IAGd,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CACzC,UAAU,EACV,aAAa,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAC3C,CAAC;IAGF,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,OAAO;AACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { installCli } from "../tasks/install.js";
|
|
3
|
+
import { runCLI } from "../tasks/run.js";
|
|
4
|
+
import { updateCli } from "../tasks/update.js";
|
|
5
|
+
import { getLocalBinPath } from "./getLocalBinPath.js";
|
|
6
|
+
export const parseCommandOptions = async (options, unknownOptions) => {
|
|
7
|
+
if (options.install) {
|
|
8
|
+
await installCli();
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (options.update) {
|
|
12
|
+
await updateCli();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const path = options.binaryPath || getLocalBinPath();
|
|
16
|
+
if (!options.binaryPath && !existsSync(path)) {
|
|
17
|
+
await installCli();
|
|
18
|
+
}
|
|
19
|
+
await runCLI(unknownOptions, options.binaryPath);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=parseCommandOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCommandOptions.js","sourceRoot":"","sources":["../../bin/utils/parseCommandOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,OAAmE,EACnE,cAAwB,EACxB,EAAE;IAEF,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,UAAU,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,SAAS,EAAE,CAAC;QAClB,OAAO;IACT,CAAC;IAGD,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,IAAI,eAAe,EAAE,CAAC;IACrD,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCurrentOpenSSLVersion: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../bin/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,GAAG,GAAG,aAAa,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC"}
|