@badisi/latest-version 8.0.1 → 8.0.3

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/cli.js +33 -33
  2. package/package.json +5 -6
package/cli.js CHANGED
@@ -23,23 +23,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  ));
24
24
 
25
25
  // src/cli.ts
26
- var import_safe = require("@colors/colors/safe");
27
- var import_fs = require("fs");
28
- var import_path = require("path");
29
- var import_index = __toESM(require("./index"));
26
+ var import_node_util = require("node:util");
27
+ var import_node_fs = require("node:fs");
28
+ var import_node_path = require("node:path");
30
29
  var import_major = __toESM(require("semver/functions/major"));
31
30
  var import_diff = __toESM(require("semver/functions/diff"));
31
+ var import_index = __toESM(require("./index"));
32
32
  var colorizeDiff = (from, to) => {
33
33
  const toParts = to.split(".");
34
34
  const diffIndex = from.split(".").findIndex((part, i) => part !== toParts[i]);
35
35
  if (diffIndex !== -1) {
36
- let color = import_safe.magenta;
36
+ let color = "magenta";
37
37
  if (toParts[0] !== "0") {
38
- color = diffIndex === 0 ? import_safe.red : diffIndex === 1 ? import_safe.cyan : import_safe.green;
38
+ color = diffIndex === 0 ? "red" : diffIndex === 1 ? "cyan" : "green";
39
39
  }
40
40
  const start = toParts.slice(0, diffIndex).join(".");
41
41
  const mid = diffIndex === 0 ? "" : ".";
42
- const end = color(toParts.slice(diffIndex).join("."));
42
+ const end = (0, import_node_util.styleText)(color, toParts.slice(diffIndex).join("."));
43
43
  return `${start}${mid}${end}`;
44
44
  }
45
45
  return to;
@@ -49,15 +49,15 @@ var columnCellRenderer = (column, row) => {
49
49
  const gap = text.length < column.maxLength ? " ".repeat(column.maxLength - text.length) : "";
50
50
  switch (column.attrName) {
51
51
  case "name":
52
- text = (0, import_safe.yellow)(text);
52
+ text = (0, import_node_util.styleText)("yellow", text);
53
53
  break;
54
54
  case "installed":
55
55
  case "separator":
56
- text = (0, import_safe.blue)(text);
56
+ text = (0, import_node_util.styleText)("blue", text);
57
57
  break;
58
58
  case "location":
59
59
  case "tagOrRange":
60
- text = (0, import_safe.gray)(text);
60
+ text = (0, import_node_util.styleText)("gray", text);
61
61
  break;
62
62
  case "wanted":
63
63
  text = colorizeDiff(row.installed, text);
@@ -75,17 +75,17 @@ var columnCellRenderer = (column, row) => {
75
75
  var columnHeaderRenderer = (column) => {
76
76
  const text = column.label;
77
77
  const gap = text.length < column.maxLength ? " ".repeat(column.maxLength - text.length) : "";
78
- return column.align === "right" ? `${gap}${(0, import_safe.underline)(text)}` : `${(0, import_safe.underline)(text)}${gap}`;
78
+ return column.align === "right" ? `${gap}${(0, import_node_util.styleText)("underline", text)}` : `${(0, import_node_util.styleText)("underline", text)}${gap}`;
79
79
  };
80
- var drawBox = (lines, color = import_safe.yellow, horizontalPadding = 3) => {
81
- const maxLineWidth = lines.reduce((max, row) => Math.max(max, (0, import_safe.strip)(row).length), 0);
82
- console.log(color(`\u250C${"\u2500".repeat(maxLineWidth + horizontalPadding * 2)}\u2510`));
80
+ var drawBox = (lines, color = "yellow", horizontalPadding = 3) => {
81
+ const maxLineWidth = lines.reduce((max, row) => Math.max(max, (0, import_node_util.stripVTControlCharacters)(row).length), 0);
82
+ console.log((0, import_node_util.styleText)(color, `\u250C${"\u2500".repeat(maxLineWidth + horizontalPadding * 2)}\u2510`));
83
83
  lines.forEach((row) => {
84
84
  const padding = " ".repeat(horizontalPadding);
85
- const fullRow = `${row}${" ".repeat(maxLineWidth - (0, import_safe.strip)(row).length)}`;
86
- console.log(`${color("\u2502")}${padding}${(0, import_safe.reset)(fullRow)}${padding}${color("\u2502")}`);
85
+ const fullRow = `${row}${" ".repeat(maxLineWidth - (0, import_node_util.stripVTControlCharacters)(row).length)}`;
86
+ console.log(`${(0, import_node_util.styleText)(color, "\u2502")}${padding}${fullRow}${padding}${(0, import_node_util.styleText)(color, "\u2502")}`);
87
87
  });
88
- console.log(color(`\u2514${"\u2500".repeat(maxLineWidth + horizontalPadding * 2)}\u2518`));
88
+ console.log((0, import_node_util.styleText)(color, `\u2514${"\u2500".repeat(maxLineWidth + horizontalPadding * 2)}\u2518`));
89
89
  };
90
90
  var getTableColumns = (rows) => {
91
91
  const columns = [
@@ -171,29 +171,29 @@ var displayTable = (latestVersionPackages) => {
171
171
  const items = rows.filter((row) => row.group === groupType).sort((a, b) => a.name > b.name ? 1 : -1);
172
172
  return !items.length ? [] : [
173
173
  "",
174
- color(`${(0, import_safe.bold)(title)} ${(0, import_safe.italic)(`(${description})`)}`),
174
+ (0, import_node_util.styleText)(color, `${(0, import_node_util.styleText)("bold", title)} ${(0, import_node_util.styleText)("italic", `(${description})`)}`),
175
175
  ...items.map((row) => columns.map((column) => columnCellRenderer(column, row)).join(" ".repeat(columnGap)))
176
176
  ];
177
177
  };
178
178
  drawBox([
179
179
  "",
180
- hasUpdates ? (0, import_safe.yellow)("Important updates are available.") : void 0,
180
+ hasUpdates ? (0, import_node_util.styleText)("yellow", "Important updates are available.") : void 0,
181
181
  hasUpdates ? "" : void 0,
182
182
  columns.map(columnHeaderRenderer).join(" ".repeat(columnGap)),
183
- ...getGroupLines("patch", import_safe.green, "Patch", "backwards-compatible bug fixes"),
184
- ...getGroupLines("minor", import_safe.cyan, "Minor", "backwards-compatible features"),
185
- ...getGroupLines("major", import_safe.red, "Major", "potentially breaking API changes"),
186
- ...getGroupLines("majorVersionZero", import_safe.magenta, "Major version zero", "not stable, anything may change"),
187
- ...getGroupLines("unknown", import_safe.blue, "Missing", "not installed"),
183
+ ...getGroupLines("patch", "green", "Patch", "backwards-compatible bug fixes"),
184
+ ...getGroupLines("minor", "cyan", "Minor", "backwards-compatible features"),
185
+ ...getGroupLines("major", "red", "Major", "potentially breaking API changes"),
186
+ ...getGroupLines("majorVersionZero", "magenta", "Major version zero", "not stable, anything may change"),
187
+ ...getGroupLines("unknown", "blue", "Missing", "not installed"),
188
188
  ""
189
189
  ].filter((line) => line !== void 0));
190
190
  } else {
191
- console.log((0, import_safe.green)("\u{1F389} Packages are up-to-date"));
191
+ console.log((0, import_node_util.styleText)("green", "\u{1F389} Packages are up-to-date"));
192
192
  }
193
193
  };
194
194
  var checkVersions = async (packages, skipMissing, options = { useCache: true }) => {
195
195
  const ora = (await import("ora")).default;
196
- const spinner = ora({ text: (0, import_safe.cyan)("Checking versions...") });
196
+ const spinner = ora({ text: (0, import_node_util.styleText)("cyan", "Checking versions...") });
197
197
  spinner.start();
198
198
  let latestVersionPackages = await (0, import_index.default)(packages, options);
199
199
  if (skipMissing) {
@@ -207,16 +207,16 @@ void (async () => {
207
207
  const skipMissing = args.includes("--skip-missing");
208
208
  args = args.filter((arg) => !arg.startsWith("-"));
209
209
  if (args.length === 1 && args[0].endsWith("package.json")) {
210
- if ((0, import_fs.existsSync)(args[0])) {
211
- process.chdir((0, import_path.dirname)(args[0]));
212
- await checkVersions(JSON.parse((0, import_fs.readFileSync)(args[0]).toString()), skipMissing);
210
+ if ((0, import_node_fs.existsSync)(args[0])) {
211
+ process.chdir((0, import_node_path.dirname)(args[0]));
212
+ await checkVersions(JSON.parse((0, import_node_fs.readFileSync)(args[0]).toString()), skipMissing);
213
213
  } else {
214
- console.log((0, import_safe.cyan)("No package.json file were found"));
214
+ console.log((0, import_node_util.styleText)("cyan", "No package.json file were found"));
215
215
  }
216
216
  } else {
217
217
  let localPkgJson;
218
- if ((0, import_fs.existsSync)("package.json")) {
219
- localPkgJson = JSON.parse((0, import_fs.readFileSync)("package.json").toString());
218
+ if ((0, import_node_fs.existsSync)("package.json")) {
219
+ localPkgJson = JSON.parse((0, import_node_fs.readFileSync)("package.json").toString());
220
220
  }
221
221
  if (args.length) {
222
222
  args = args.map((arg) => {
@@ -233,7 +233,7 @@ void (async () => {
233
233
  } else if (localPkgJson) {
234
234
  await checkVersions(localPkgJson, skipMissing);
235
235
  } else {
236
- console.log((0, import_safe.cyan)("No packages were found"));
236
+ console.log((0, import_node_util.styleText)("cyan", "No packages were found"));
237
237
  }
238
238
  }
239
239
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@badisi/latest-version",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Get latest versions of packages",
5
5
  "homepage": "https://github.com/Badisi/latest-version",
6
6
  "license": "MIT",
@@ -41,13 +41,12 @@
41
41
  "module"
42
42
  ],
43
43
  "engines": {
44
- "node": ">= 20"
44
+ "node": ">= 20.12.0"
45
45
  },
46
46
  "dependencies": {
47
- "@colors/colors": "^1.6.0",
48
47
  "global-dirs": "3.0.1",
49
- "ora": "^9.0.0",
50
- "registry-auth-token": "^5.1.0",
51
- "semver": "^7.7.3"
48
+ "ora": "^9.3.0",
49
+ "registry-auth-token": "^5.1.1",
50
+ "semver": "^7.7.4"
52
51
  }
53
52
  }