fleetctl 4.61.0 → 4.62.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/run.js +22 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetctl",
3
- "version": "v4.61.0",
3
+ "version": "v4.62.0",
4
4
  "description": "Installer for the fleetctl CLI tool",
5
5
  "bin": {
6
6
  "fleetctl": "./run.js"
@@ -16,12 +16,12 @@
16
16
  },
17
17
  "homepage": "https://fleetdm.com",
18
18
  "dependencies": {
19
- "axios": "^0.28.0",
20
- "rimraf": "3.0.2",
21
- "tar": "^6.1.9"
19
+ "axios": "1.7.9",
20
+ "rimraf": "6.0.1",
21
+ "tar": "7.4.3"
22
22
  },
23
23
  "keywords": [
24
24
  "osquery",
25
25
  "security"
26
26
  ]
27
- }
27
+ }
package/run.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
3
 
3
- const child = require("child_process");
4
- const fs = require("fs");
5
- const os = require("os");
6
- const path = require("path");
4
+ const { spawnSync } = require("child_process");
5
+ const { existsSync, mkdirSync } = require("fs");
6
+ const { type } = require("os");
7
+ const { join } = require("path");
7
8
 
8
9
  const axios = require("axios");
9
- const rimraf = require("rimraf");
10
- const tar = require("tar");
11
-
10
+ const { rimrafSync } = require("rimraf");
11
+ const { extract } = require("tar");
12
12
  const { version } = require("./package.json");
13
13
 
14
14
  // Strip any v4.0.0-1 style suffix (but not -rc1) so that the correct package is
@@ -19,13 +19,13 @@ if (!strippedVersion.startsWith("v")) {
19
19
  strippedVersion = `v${strippedVersion}`;
20
20
  }
21
21
 
22
- const binDir = path.join(__dirname, "install");
22
+ const binDir = join(__dirname, "install");
23
23
  // Determine the install directory by version so that we can detect when we need
24
24
  // to upgrade to a new version.
25
- const installDir = path.join(binDir, strippedVersion);
25
+ const installDir = join(binDir, strippedVersion);
26
26
 
27
27
  const platform = (() => {
28
- switch (os.type()) {
28
+ switch (type()) {
29
29
  case "Windows_NT":
30
30
  return "windows";
31
31
  case "Linux":
@@ -33,23 +33,23 @@ const platform = (() => {
33
33
  case "Darwin":
34
34
  return "macos";
35
35
  default:
36
- throw new Error(`platform ${os.type} unrecognized`);
36
+ throw new Error(`platform ${type} unrecognized`);
37
37
  }
38
38
  })();
39
39
 
40
40
  const binName = platform === "windows" ? "fleetctl.exe" : "fleetctl";
41
- const binPath = path.join(installDir, binName);
41
+ const binPath = join(installDir, binName);
42
42
 
43
43
  const install = async () => {
44
44
  const url = `https://github.com/fleetdm/fleet/releases/download/fleet-${strippedVersion}/fleetctl_${strippedVersion}_${platform}.tar.gz`;
45
45
 
46
- fs.mkdirSync(installDir, { recursive: true });
46
+ mkdirSync(installDir, { recursive: true });
47
47
 
48
48
  try {
49
49
  const response = await axios({ url, responseType: "stream" });
50
50
 
51
51
  // Strip the outer directory when extracting. Just get the binary.
52
- const tarWriter = tar.extract({ strip: 1, cwd: installDir });
52
+ const tarWriter = extract({ strip: 1, cwd: installDir });
53
53
  response.data.pipe(tarWriter);
54
54
 
55
55
  // Need to return a promise with the writer to ensure we can await for it to complete.
@@ -58,14 +58,18 @@ const install = async () => {
58
58
  tarWriter.on("error", reject);
59
59
  });
60
60
  } catch (err) {
61
- throw new Error(`download archive ${url}: ${err.message}`);
61
+ if (axios.isAxiosError(err)) {
62
+ throw new Error(`download archive ${url}: ${err.message}`);
63
+ } else {
64
+ throw err;
65
+ }
62
66
  }
63
67
  };
64
68
 
65
69
  const run = async () => {
66
- if (!fs.existsSync(binPath)) {
70
+ if (!existsSync(binPath)) {
67
71
  // Remove any existing binaries before installing the new one.
68
- rimraf.sync(binDir);
72
+ rimrafSync(binDir);
69
73
  console.log(`Installing fleetctl ${strippedVersion}...`);
70
74
  try {
71
75
  await install();
@@ -105,7 +109,7 @@ const run = async () => {
105
109
 
106
110
  const [, , ...args] = process.argv;
107
111
  const options = { cwd: process.cwd(), stdio: "inherit" };
108
- const { status, error } = child.spawnSync(binPath, args, options);
112
+ const { status, error } = spawnSync(binPath, args, options);
109
113
 
110
114
  if (error) {
111
115
  console.error(error);