@aptos-labs/aptos-cli
Advanced tools
| #!/usr/bin/env node | ||
| export {}; |
| #!/usr/bin/env node | ||
| import { program } from "commander"; | ||
| import { parseCommandOptions } from "./utils/parseCommandOptions.js"; | ||
| import { runCLI } from "./tasks/run.js"; | ||
| program | ||
| .name("aptos") | ||
| .helpOption(false) | ||
| .option("-i, --install", "install the latest version of the CLI") | ||
| .option("-u, --update", "update the CLI to the latest version") | ||
| .option("-b, --binary-path <path>", "path to an existing Aptos CLI binary") | ||
| .allowUnknownOption(); | ||
| program.parse(process.argv); | ||
| const main = async () => { | ||
| const options = { | ||
| install: program.opts().install, | ||
| update: program.opts().update, | ||
| binaryPath: program.opts().binaryPath, | ||
| }; | ||
| const unknownOptions = program.args; | ||
| if (process.argv.includes("--help")) { | ||
| return runCLI(unknownOptions, options.binaryPath); | ||
| } | ||
| await parseCommandOptions(options, unknownOptions); | ||
| }; | ||
| main().catch(console.error); | ||
| //# sourceMappingURL=aptos.js.map |
| {"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"} |
| export declare const installCli: () => Promise<void>; |
| import { execSync } from "child_process"; | ||
| import { existsSync } from "fs"; | ||
| import { GH_CLI_DOWNLOAD_URL, PNAME } from "../utils/consts.js"; | ||
| import { execSyncShell } from "../utils/execSyncShell.js"; | ||
| import { getCurrentOpenSSLVersion } from "../utils/versions.js"; | ||
| import { getOS } from "../utils/getUserOs.js"; | ||
| import { getLocalBinPath } from "../utils/getLocalBinPath.js"; | ||
| import { getLatestVersionGh } from "../utils/ghOperations.js"; | ||
| export const installCli = async () => { | ||
| const path = getLocalBinPath(); | ||
| if (existsSync(path)) { | ||
| console.log("Aptos CLI is already installed"); | ||
| return; | ||
| } | ||
| const latestCLIVersion = await getLatestVersionGh(); | ||
| console.log(`Downloading aptos CLI version ${latestCLIVersion}`); | ||
| const os = getOS(); | ||
| if (os === "Windows") { | ||
| const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-x86_64.zip`; | ||
| 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}\""`); | ||
| } | ||
| else if (os === "MacOS") { | ||
| execSyncShell("brew install aptos", { encoding: "utf8" }); | ||
| } | ||
| else { | ||
| let osVersion = "x86_64"; | ||
| let opensSslVersion = "1.0.0"; | ||
| try { | ||
| opensSslVersion = getCurrentOpenSSLVersion(); | ||
| } | ||
| catch (error) { | ||
| console.log("Could not determine OpenSSL version, assuming older version (1.x.x)"); | ||
| } | ||
| if (opensSslVersion.startsWith("3.")) { | ||
| osVersion = "22.04-x86_64"; | ||
| } | ||
| console.log(`Downloading CLI binary ${os}-${osVersion}`); | ||
| const url = `${GH_CLI_DOWNLOAD_URL}/${PNAME}-v${latestCLIVersion}/${PNAME}-${latestCLIVersion}-${os}-${osVersion}.zip`; | ||
| execSync(`curl -L -o /tmp/aptos.zip ${url}; unzip -o -q /tmp/aptos.zip -d /tmp; mv /tmp/aptos ${path};`); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=install.js.map |
| {"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"} |
| export declare const runCLI: (args?: string[], binaryPath?: string) => Promise<void>; |
| import { spawn } from "child_process"; | ||
| import { existsSync } from "fs"; | ||
| import { getOS } from "../utils/getUserOs.js"; | ||
| import { getLocalBinPath } from "../utils/getLocalBinPath.js"; | ||
| export const runCLI = async (args = [], binaryPath) => { | ||
| const path = binaryPath || getLocalBinPath(); | ||
| if (!existsSync(path)) { | ||
| if (binaryPath) { | ||
| console.error(`Error: Binary not found at specified path: ${binaryPath}`); | ||
| process.exit(1); | ||
| } | ||
| console.log("Aptos CLI not installed, run `npx aptos --install` to install"); | ||
| return; | ||
| } | ||
| const os = getOS(); | ||
| spawn(path, args, { | ||
| stdio: "inherit", | ||
| shell: os === "Windows", | ||
| }); | ||
| }; | ||
| //# sourceMappingURL=run.js.map |
| {"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"} |
| export declare const updateCli: () => Promise<NonSharedBuffer | undefined>; |
| import { existsSync } from "fs"; | ||
| import { getLocalBinPath } from "../utils/getLocalBinPath.js"; | ||
| import { execSync } from "child_process"; | ||
| import { getOS } from "../utils/getUserOs.js"; | ||
| import { getLatestVersionGh } from "../utils/ghOperations.js"; | ||
| import { execSyncShell } from "../utils/execSyncShell.js"; | ||
| import { installCli } from "./install.js"; | ||
| export const updateCli = async () => { | ||
| const path = getLocalBinPath(); | ||
| if (!existsSync(path)) { | ||
| console.log("Aptos CLI not installed, run `npx aptos --install` to install"); | ||
| return; | ||
| } | ||
| if (getOS() === "MacOS") { | ||
| return execSync("brew upgrade aptos"); | ||
| } | ||
| else { | ||
| const latestVersion = await getLatestVersionGh(); | ||
| const currentVersion = execSyncShell(`${path} --version`, { | ||
| encoding: "utf8", | ||
| }) | ||
| .trim() | ||
| .split(" ")[1]; | ||
| if (currentVersion !== latestVersion) { | ||
| console.log(`A newer version of the CLI is available: ${latestVersion}, installing...`); | ||
| await installCli(); | ||
| } | ||
| else { | ||
| console.log(`CLI is up to date`); | ||
| } | ||
| } | ||
| }; | ||
| //# sourceMappingURL=update.js.map |
| {"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"} |
| export declare const executableIsAvailable: (name: any) => boolean; |
| import { execSyncShell } from "./execSyncShell.js"; | ||
| export const executableIsAvailable = (name) => { | ||
| try { | ||
| execSyncShell(`which ${name}`, { encoding: "utf8" }); | ||
| return true; | ||
| } | ||
| catch (error) { | ||
| return false; | ||
| } | ||
| }; | ||
| //# sourceMappingURL=aptosExecutableIsAvailable.js.map |
| {"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"} |
| export declare const getCliPathBrew: () => string; |
| import { execSyncShell } from "./execSyncShell.js"; | ||
| export const getCliPathBrew = () => { | ||
| const directory = execSyncShell("brew --prefix aptos", { encoding: "utf8" }) | ||
| .toString() | ||
| .trim(); | ||
| return `${directory}/bin/aptos`; | ||
| }; | ||
| //# sourceMappingURL=brewOperations.js.map |
| {"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"} |
| export declare const PNAME = "aptos-cli"; | ||
| export declare const GH_CLI_DOWNLOAD_URL = "https://github.com/aptos-labs/aptos-core/releases/download"; |
| export const PNAME = "aptos-cli"; | ||
| export const GH_CLI_DOWNLOAD_URL = "https://github.com/aptos-labs/aptos-core/releases/download"; | ||
| //# sourceMappingURL=consts.js.map |
| {"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"} |
| export declare const execSyncShell: (command: any, options: any) => string; |
| import { execSync } from "child_process"; | ||
| export const execSyncShell = (command, options) => { | ||
| return execSync(command, { shell: true, ...options }); | ||
| }; | ||
| //# sourceMappingURL=execSyncShell.js.map |
| {"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"} |
| export declare const getLocalBinPath: () => any; |
| import { dirname } from "path"; | ||
| import { executableIsAvailable } from "./aptosExecutableIsAvailable.js"; | ||
| import { getCliPathBrew } from "./brewOperations.js"; | ||
| import { PNAME } from "./consts.js"; | ||
| import { getOS } from "./getUserOs.js"; | ||
| import { fileURLToPath } from "url"; | ||
| export const getLocalBinPath = () => { | ||
| let path; | ||
| const os = getOS(); | ||
| if (os === "MacOS") { | ||
| const brewInstalled = executableIsAvailable("brew"); | ||
| if (!brewInstalled) { | ||
| throw "Please install brew to continue: https://brew.sh/"; | ||
| } | ||
| try { | ||
| path = getCliPathBrew(); | ||
| } | ||
| catch (e) { | ||
| path = ""; | ||
| } | ||
| } | ||
| else if (os === "Windows") { | ||
| path = `${dirname(fileURLToPath(import.meta.url))}\\${PNAME}.exe`; | ||
| } | ||
| else { | ||
| path = `${dirname(fileURLToPath(import.meta.url))}/${PNAME}`; | ||
| } | ||
| return path; | ||
| }; | ||
| //# sourceMappingURL=getLocalBinPath.js.map |
| {"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"} |
| export declare const getOS: () => "MacOS" | "Ubuntu" | "Windows"; |
| import { platform } from "os"; | ||
| export const getOS = () => { | ||
| const osPlatform = platform(); | ||
| switch (osPlatform) { | ||
| case "darwin": | ||
| return "MacOS"; | ||
| case "linux": | ||
| return "Ubuntu"; | ||
| case "win32": | ||
| return "Windows"; | ||
| default: | ||
| throw new Error(`Unsupported OS ${osPlatform}`); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=getUserOs.js.map |
| {"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"} |
| export declare const getLatestVersionGh: () => Promise<any>; |
| import { PNAME } from "./consts.js"; | ||
| export const getLatestVersionGh = async () => { | ||
| const prefix = `${PNAME}-v`; | ||
| const response = await (await fetch("https://api.github.com/repos/aptos-labs/aptos-core/releases?per_page=100")).json(); | ||
| for (const release of response) { | ||
| if (release["tag_name"].startsWith(`${prefix}`)) { | ||
| return release.tag_name.replace(`${prefix}`, ""); | ||
| } | ||
| } | ||
| throw "Could not determine latest version of Aptos CLI"; | ||
| }; | ||
| //# sourceMappingURL=ghOperations.js.map |
| {"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"} |
| import { Command } from "commander"; | ||
| export declare const handleHelpOptions: (program: Command, unknownOptions: string[]) => void; |
| import { spawnSync } from "child_process"; | ||
| export const handleHelpOptions = (program, unknownOptions) => { | ||
| const cliHelp = spawnSync(`aptos`, unknownOptions, { | ||
| stdio: "pipe", | ||
| encoding: "utf-8", | ||
| }); | ||
| const commanderHelp = program.helpInformation(); | ||
| const commanderOptionsOnly = commanderHelp | ||
| .split("\n") | ||
| .filter((line) => !line.startsWith("Usage") && !line.startsWith("Options")) | ||
| .join("\n"); | ||
| const combinedHelp = cliHelp.stdout.replace("Options:", `Options:\n${commanderOptionsOnly.trim()}`); | ||
| console.log(combinedHelp); | ||
| return; | ||
| }; | ||
| //# sourceMappingURL=handleHelpOptions.js.map |
| {"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"} |
| export declare const parseCommandOptions: (options: { | ||
| install: boolean; | ||
| update: boolean; | ||
| binaryPath?: string; | ||
| }, unknownOptions: string[]) => Promise<void>; |
| import { existsSync } from "fs"; | ||
| import { installCli } from "../tasks/install.js"; | ||
| import { runCLI } from "../tasks/run.js"; | ||
| import { updateCli } from "../tasks/update.js"; | ||
| import { getLocalBinPath } from "./getLocalBinPath.js"; | ||
| export const parseCommandOptions = async (options, unknownOptions) => { | ||
| if (options.install) { | ||
| await installCli(); | ||
| return; | ||
| } | ||
| if (options.update) { | ||
| await updateCli(); | ||
| return; | ||
| } | ||
| const path = options.binaryPath || getLocalBinPath(); | ||
| if (!options.binaryPath && !existsSync(path)) { | ||
| await installCli(); | ||
| } | ||
| await runCLI(unknownOptions, options.binaryPath); | ||
| }; | ||
| //# sourceMappingURL=parseCommandOptions.js.map |
| {"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"} |
| export declare const getCurrentOpenSSLVersion: () => string; |
| import { execSyncShell } from "./execSyncShell.js"; | ||
| export const getCurrentOpenSSLVersion = () => { | ||
| const out = execSyncShell("openssl version", { encoding: "utf8" }); | ||
| return out.split(" ")[1].trim(); | ||
| }; | ||
| //# sourceMappingURL=versions.js.map |
| {"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"} |
+3
-1
@@ -22,2 +22,3 @@ #!/usr/bin/env node | ||
| .option("-u, --update", "update the CLI to the latest version") | ||
| .option("-b, --binary-path <path>", "path to an existing Aptos CLI binary") | ||
| .allowUnknownOption(); | ||
@@ -31,2 +32,3 @@ | ||
| update: program.opts().update, | ||
| binaryPath: program.opts().binaryPath, | ||
| }; | ||
@@ -38,3 +40,3 @@ const unknownOptions = program.args; | ||
| // Forward to the CLI | ||
| return runCLI(unknownOptions); | ||
| return runCLI(unknownOptions, options.binaryPath); | ||
| } | ||
@@ -41,0 +43,0 @@ |
+6
-2
@@ -7,5 +7,9 @@ import { spawn } from "child_process"; | ||
| export const runCLI = async (args: string[] = []) => { | ||
| const path = getLocalBinPath(); | ||
| export const runCLI = async (args: string[] = [], binaryPath?: string) => { | ||
| const path = binaryPath || getLocalBinPath(); | ||
| if (!existsSync(path)) { | ||
| if (binaryPath) { | ||
| console.error(`Error: Binary not found at specified path: ${binaryPath}`); | ||
| process.exit(1); | ||
| } | ||
| console.log( | ||
@@ -12,0 +16,0 @@ "Aptos CLI not installed, run `npx aptos --install` to install" |
@@ -8,3 +8,3 @@ import { existsSync } from "fs"; | ||
| export const parseCommandOptions = async ( | ||
| options: { install: boolean; update: boolean }, | ||
| options: { install: boolean; update: boolean; binaryPath?: string }, | ||
| unknownOptions: string[] | ||
@@ -24,7 +24,7 @@ ) => { | ||
| // if no flags are set, install and run the cli | ||
| const path = getLocalBinPath(); | ||
| if (!existsSync(path)) { | ||
| const path = options.binaryPath || getLocalBinPath(); | ||
| if (!options.binaryPath && !existsSync(path)) { | ||
| await installCli(); | ||
| } | ||
| await runCLI(unknownOptions); | ||
| await runCLI(unknownOptions, options.binaryPath); | ||
| }; |
+1
-1
| { | ||
| "name": "@aptos-labs/aptos-cli", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "Aptos CLI available from npmjs", | ||
@@ -5,0 +5,0 @@ "bin": { |
+8
-0
@@ -37,2 +37,10 @@ # Aptos CLI | ||
| ### Using a Custom Binary | ||
| If you already have the Aptos CLI binary installed on your system, you can specify its path to use it directly: | ||
| ```bash | ||
| npx aptos --binary-path /path/to/aptos <command> | ||
| ``` | ||
| ## Updating the Aptos CLI | ||
@@ -39,0 +47,0 @@ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
45284
86.05%60
233.33%570
85.67%0
-100%76
11.76%9
80%12
100%