@aptos-labs/aptos-cli 1.0.1 → 1.0.2

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.
@@ -5,8 +5,8 @@ import { GH_CLI_DOWNLOAD_URL, PNAME } from "../utils/consts.js";
5
5
  import { execSyncShell } from "../utils/execSyncShell.js";
6
6
  import { getCurrentOpenSSLVersion } from "../utils/versions.js";
7
7
  import { getOS } from "../utils/getUserOs.js";
8
- import { getLatestVersion } from "../utils/getAptosCliLatestVersion.js";
9
8
  import { getLocalBinPath } from "../utils/getLocalBinPath.js";
9
+ import { getLatestVersionGh } from "../utils/ghOperations.js";
10
10
 
11
11
  // Install the CLI.
12
12
  export const installCli = async () => {
@@ -16,7 +16,7 @@ export const installCli = async () => {
16
16
  return;
17
17
  }
18
18
  // Look up the latest version.
19
- const latestCLIVersion = await getLatestVersion();
19
+ const latestCLIVersion = await getLatestVersionGh();
20
20
  console.log(`Downloading aptos CLI version ${latestCLIVersion}`);
21
21
  const os = getOS();
22
22
 
@@ -1,33 +1,41 @@
1
1
  import { existsSync } from "fs";
2
2
 
3
+ import { getLocalBinPath } from "../utils/getLocalBinPath.js";
4
+ import { execSync } from "child_process";
5
+ import { getOS } from "../utils/getUserOs.js";
6
+ import { getLatestVersionGh } from "../utils/ghOperations.js";
3
7
  import { execSyncShell } from "../utils/execSyncShell.js";
4
- import { getLatestVersion } from "../utils/getAptosCliLatestVersion.js";
5
8
  import { installCli } from "./install.js";
6
- import { getLocalBinPath } from "../utils/getLocalBinPath.js";
7
9
 
8
10
  export const updateCli = async () => {
9
11
  const path = getLocalBinPath();
12
+
10
13
  if (!existsSync(path)) {
11
14
  console.log(
12
15
  "Aptos CLI not installed, run `npx aptos --install` to install"
13
16
  );
14
17
  return;
15
18
  }
16
- // Look up the latest version.
17
- const latestVersion = await getLatestVersion();
18
- // Get the current version of the CLI.
19
- const currentVersion = execSyncShell(`${path} --version`, {
20
- encoding: "utf8",
21
- })
22
- .trim()
23
- .split(" ")[1];
24
- // Check if the installed version is the latest version.
25
- if (currentVersion !== latestVersion) {
26
- console.log(
27
- `A newer version of the CLI is available: ${latestVersion}, installing...`
28
- );
29
- installCli();
19
+
20
+ if (getOS() === "MacOS") {
21
+ // Upgrade aptos via brew.
22
+ return execSync("brew upgrade aptos");
30
23
  } else {
31
- console.log(`CLI is up to date`);
24
+ const latestVersion = await getLatestVersionGh();
25
+ // Get the current version of the CLI.
26
+ const currentVersion = execSyncShell(`${path} --version`, {
27
+ encoding: "utf8",
28
+ })
29
+ .trim()
30
+ .split(" ")[1];
31
+ // Check if the installed version is the latest version.
32
+ if (currentVersion !== latestVersion) {
33
+ console.log(
34
+ `A newer version of the CLI is available: ${latestVersion}, installing...`
35
+ );
36
+ installCli();
37
+ } else {
38
+ console.log(`CLI is up to date`);
39
+ }
32
40
  }
33
41
  };
@@ -10,14 +10,3 @@ export const getCliPathBrew = () => {
10
10
  .trim();
11
11
  return `${directory}/bin/aptos`;
12
12
  };
13
-
14
- /**
15
- * Use brew to find the latest version of the CLI. Make sure to confirm that brew
16
- * is installed before calling this function.
17
- */
18
- export const getLatestVersionBrew = () => {
19
- const out = JSON.parse(
20
- execSyncShell("brew info --json aptos", { encoding: "utf8" })
21
- );
22
- return out[0].versions.stable;
23
- };
@@ -4,15 +4,15 @@ import { GH_CLI_DOWNLOAD_URL, PNAME } from "../utils/consts.js";
4
4
  import { execSyncShell } from "../utils/execSyncShell.js";
5
5
  import { getCurrentOpenSSLVersion } from "../utils/versions.js";
6
6
  import { getOS } from "../utils/getUserOs.js";
7
- import { getLatestVersion } from "../utils/getAptosCliLatestVersion.js";
8
7
  import { getLocalBinPath } from "../utils/getLocalBinPath.js";
8
+ import { getLatestVersionGh } from "../utils/ghOperations.js";
9
9
  export const installCli = async () => {
10
10
  const path = getLocalBinPath();
11
11
  if (existsSync(path)) {
12
12
  console.log("Aptos CLI is already installed");
13
13
  return;
14
14
  }
15
- const latestCLIVersion = await getLatestVersion();
15
+ const latestCLIVersion = await getLatestVersionGh();
16
16
  console.log(`Downloading aptos CLI version ${latestCLIVersion}`);
17
17
  const os = getOS();
18
18
  if (os === "Windows") {
@@ -1 +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,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,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,gBAAgB,EAAE,CAAC;IAClD,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;SA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G,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"}
@@ -1 +1 @@
1
- export declare const updateCli: () => Promise<void>;
1
+ export declare const updateCli: () => Promise<Buffer | undefined>;
@@ -1,26 +1,33 @@
1
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";
2
6
  import { execSyncShell } from "../utils/execSyncShell.js";
3
- import { getLatestVersion } from "../utils/getAptosCliLatestVersion.js";
4
7
  import { installCli } from "./install.js";
5
- import { getLocalBinPath } from "../utils/getLocalBinPath.js";
6
8
  export const updateCli = async () => {
7
9
  const path = getLocalBinPath();
8
10
  if (!existsSync(path)) {
9
11
  console.log("Aptos CLI not installed, run `npx aptos --install` to install");
10
12
  return;
11
13
  }
12
- const latestVersion = await getLatestVersion();
13
- const currentVersion = execSyncShell(`${path} --version`, {
14
- encoding: "utf8",
15
- })
16
- .trim()
17
- .split(" ")[1];
18
- if (currentVersion !== latestVersion) {
19
- console.log(`A newer version of the CLI is available: ${latestVersion}, installing...`);
20
- installCli();
14
+ if (getOS() === "MacOS") {
15
+ return execSync("brew upgrade aptos");
21
16
  }
22
17
  else {
23
- console.log(`CLI is up to date`);
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
+ installCli();
27
+ }
28
+ else {
29
+ console.log(`CLI is up to date`);
30
+ }
24
31
  }
25
32
  };
26
33
  //# sourceMappingURL=update.js.map
@@ -1 +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,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAClC,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;IAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,+DAA+D,CAChE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAE/C,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,IAAI,YAAY,EAAE;QACxD,QAAQ,EAAE,MAAM;KACjB,CAAC;SACC,IAAI,EAAE;SACN,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjB,IAAI,cAAc,KAAK,aAAa,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CACT,4CAA4C,aAAa,iBAAiB,CAC3E,CAAC;QACF,UAAU,EAAE,CAAC;IACf,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;AACH,CAAC,CAAC"}
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,UAAU,EAAE,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
@@ -1,2 +1 @@
1
1
  export declare const getCliPathBrew: () => string;
2
- export declare const getLatestVersionBrew: () => any;
@@ -5,8 +5,4 @@ export const getCliPathBrew = () => {
5
5
  .trim();
6
6
  return `${directory}/bin/aptos`;
7
7
  };
8
- export const getLatestVersionBrew = () => {
9
- const out = JSON.parse(execSyncShell("brew info --json aptos", { encoding: "utf8" }));
10
- return out[0].versions.stable;
11
- };
12
8
  //# sourceMappingURL=brewOperations.js.map
@@ -1 +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;AAMF,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,aAAa,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAC9D,CAAC;IACF,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChC,CAAC,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/aptos-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Aptos CLI available from npmjs",
5
5
  "bin": {
6
6
  "aptos": "./dist/aptos.js"
@@ -1,14 +0,0 @@
1
- import { getLatestVersionBrew } from "./brewOperations.js";
2
- import { getOS } from "./getUserOs.js";
3
- import { getLatestVersionGh } from "./ghOperations.js";
4
-
5
- /**
6
- * Determine the latest version of the CLI.
7
- */
8
- export const getLatestVersion = async () => {
9
- if (getOS() === "MacOS") {
10
- return getLatestVersionBrew();
11
- } else {
12
- return getLatestVersionGh();
13
- }
14
- };
@@ -1 +0,0 @@
1
- export declare const getLatestVersion: () => Promise<any>;
@@ -1,12 +0,0 @@
1
- import { getLatestVersionBrew } from "./brewOperations.js";
2
- import { getOS } from "./getUserOs.js";
3
- import { getLatestVersionGh } from "./ghOperations.js";
4
- export const getLatestVersion = async () => {
5
- if (getOS() === "MacOS") {
6
- return getLatestVersionBrew();
7
- }
8
- else {
9
- return getLatestVersionGh();
10
- }
11
- };
12
- //# sourceMappingURL=getAptosCliLatestVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getAptosCliLatestVersion.js","sourceRoot":"","sources":["../../bin/utils/getAptosCliLatestVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAKvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IACzC,IAAI,KAAK,EAAE,KAAK,OAAO,EAAE,CAAC;QACxB,OAAO,oBAAoB,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,EAAE,CAAC;IAC9B,CAAC;AACH,CAAC,CAAC"}