From 1154d51123370dd79a4647017ce257de0f34c0df Mon Sep 17 00:00:00 2001 From: antonk52 Date: Sat, 21 Dec 2024 20:06:16 +0000 Subject: [PATCH] Use modern node built-ins, remove 3rd party dependencies --- index.js | 17 ++++++++--------- package-lock.json | 43 +++++++++++-------------------------------- package.json | 5 ++--- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/index.js b/index.js index b832b32..96c5670 100755 --- a/index.js +++ b/index.js @@ -1,9 +1,8 @@ #!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); -const fetch = require('node-fetch'); -const kleur = require('kleur'); +const fs = require('node:fs'); +const path = require('node:path'); +const {styleText} = require('node:util') const {log} = console; function program(...args) { @@ -40,7 +39,7 @@ function program(...args) { ) .then(sizes => { const title = `${pkg.name}'s ${isDev ? 'devD ' : 'd'}ependencies:\n`; - log(kleur.bold(title)); + log(styleText('bold', title)); return sizes .sort((a, b) => a.install.bytes - b.install.bytes) @@ -52,7 +51,7 @@ function program(...args) { return `${name} - api failed`; } return ` -${kleur.bold(name)} @ ${version} +${styleText('bold', name)} @ ${version} \tinstall size\t${colorSize(install)} \tpublish size\t${colorSize(publish)} `.trim(); @@ -64,10 +63,10 @@ ${kleur.bold(name)} @ ${version} function colorSize({bytes, pretty}) { return bytes > 1048576 - ? kleur.bold(kleur.red(pretty)) + ? styleText(['bold', 'red'], pretty) : bytes > 307200 - ? kleur.yellow(pretty) - : kleur.green(pretty); + ? styleText('yellow', pretty) + : styleText('green', pretty); } program(...process.argv.slice(2)); diff --git a/package-lock.json b/package-lock.json index d7a2766..936dcff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,39 +1,18 @@ { "name": "why-npm-i-so-long", "version": "1.0.2", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "kleur": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", - "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==" - }, - "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "requires": { - "whatwg-url": "^5.0.0" - } - }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" + "packages": { + "": { + "name": "why-npm-i-so-long", + "version": "1.0.2", + "license": "MIT", + "bin": { + "why-npm-i-so-long": "index.js" + }, + "engines": { + "node": ">=20.12" } } } diff --git a/package.json b/package.json index 491e0a3..2e32295 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,7 @@ }, "author": "antonk52", "license": "MIT", - "dependencies": { - "kleur": "^4.1.4", - "node-fetch": "^2.6.1" + "engines": { + "node": ">=20.12" } }