From 03955554ae6c065810edb1d8cebdc633c8b31464 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 11 Oct 2024 19:47:08 +0800 Subject: [PATCH] refactor: replace kolorist with kleur/colors The size of `outfile.cjs` before the change: 143037 bytes Ater the change: 141514 bytes Saved 1523 bytes. I didn't choose `picocolors` despite it being more popular because it doesn't support tree-shaking and actually increases the bundle size a bit. I didn't choose `yoctocolors` because the resulting bundle is also a bit larger than the one produced by `kleur/colors`. Addressed the issue raised in #253 --- LICENSE | 28 ---------------------------- index.ts | 2 +- package.json | 2 ++ pnpm-lock.yaml | 12 ++++++++++++ 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/LICENSE b/LICENSE index 609a8694..8fd37997 100644 --- a/LICENSE +++ b/LICENSE @@ -299,34 +299,6 @@ Repository: git+https://github.com/lukeed/kleur.git > THE SOFTWARE. > -## kolorist - -License: MIT -By: Marvin Hagemeister -Repository: git+https://github.com/marvinhagemeister/kolorist.git - -> The MIT License (MIT) -> -> Copyright (c) 2020-present Marvin Hagemeister -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ## prompts License: MIT diff --git a/index.ts b/index.ts index 8e0e55c9..758694ad 100755 --- a/index.ts +++ b/index.ts @@ -6,7 +6,7 @@ import * as path from 'node:path' import { parseArgs } from 'node:util' import prompts from 'prompts' -import { red, green, bold } from 'kolorist' +import { red, green, bold } from 'kleur/colors' import ejs from 'ejs' diff --git a/package.json b/package.json index e2096187..8da28018 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,10 @@ "esbuild": "^0.24.0", "esbuild-plugin-license": "^1.2.3", "husky": "^9.1.6", + "kleur": "^4.1.5", "kolorist": "^1.8.0", "lint-staged": "^15.2.10", + "picocolors": "^1.1.0", "prettier": "^3.3.3", "prompts": "^2.4.2", "vitest": "^2.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5222696..20da0dad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,12 +38,18 @@ importers: husky: specifier: ^9.1.6 version: 9.1.6 + kleur: + specifier: ^4.1.5 + version: 4.1.5 kolorist: specifier: ^1.8.0 version: 1.8.0 lint-staged: specifier: ^15.2.10 version: 15.2.10 + picocolors: + specifier: ^1.1.0 + version: 1.1.0 prettier: specifier: ^3.3.3 version: 3.3.3 @@ -2719,6 +2725,10 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} @@ -6470,6 +6480,8 @@ snapshots: kleur@3.0.3: {} + kleur@4.1.5: {} + kolorist@1.8.0: {} lazy-ass@1.6.0: {}