Skip to content

Commit cb63c99

Browse files
Copilotpanz3r
andauthored
feat!: migrate from ansis to util.styleText (#269)
* Initial plan * Migrate from ansis to util.styleText and update Node.js requirement Co-authored-by: panz3r <[email protected]> * Refactor: Extract color helpers to shared utility module Co-authored-by: panz3r <[email protected]> * Fix ESLint comment to match actual minimum Node.js version Co-authored-by: panz3r <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: panz3r <[email protected]>
1 parent 969700b commit cb63c99

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,6 @@ oclif.manifest.json
231231
/android
232232
/ios
233233
.env
234+
235+
# TypeScript build info
236+
*.tsbuildinfo

eslint.config.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,17 @@ import {fileURLToPath} from 'node:url'
66

77
const gitignorePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.gitignore')
88

9-
export default [includeIgnoreFile(gitignorePath), ...oclif, prettier]
9+
export default [
10+
includeIgnoreFile(gitignorePath),
11+
...oclif,
12+
prettier,
13+
{
14+
rules: {
15+
// Allow util.styleText even though it's marked as experimental by ESLint
16+
// It's available and stable in Node.js 22.13.0+ (our minimum required version)
17+
'n/no-unsupported-features/node-builtins': ['error', {
18+
ignores: ['util.styleText']
19+
}]
20+
}
21+
}
22+
]

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"version": "oclif readme && git add README.md"
2828
},
2929
"engines": {
30-
"node": ">=18.0.0"
30+
"node": ">=22.13.0"
3131
},
3232
"type": "module",
3333
"main": "dist/index.js",
@@ -53,7 +53,6 @@
5353
"dependencies": {
5454
"@oclif/core": "^4.5.2",
5555
"@oclif/plugin-help": "^6.2.32",
56-
"ansis": "^4.0.0",
5756
"sharp": "^0.34.1"
5857
},
5958
"devDependencies": {

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/dotenv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
import { Args, Command, Flags } from '@oclif/core'
10-
import { cyan, green, red, yellow } from 'ansis'
1110
import { copyFile, unlink } from 'node:fs/promises'
1211

12+
import { cyan, green, red, yellow } from '../utils/color.utils.js'
1313
import { checkAssetFile } from '../utils/file-utils.js'
1414

1515
export default class Dotenv extends Command {

src/commands/icons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { Args, Command, Flags } from '@oclif/core'
10-
import { cyan, green, red, yellow } from 'ansis'
1110
import { writeFile } from 'node:fs/promises'
1211
import { join } from 'node:path'
1312
import sharp from 'sharp'
@@ -17,6 +16,7 @@ import type { ContentJson } from '../types.js'
1716
import { ICON_SIZES_ANDROID, ICON_SIZES_IOS } from '../constants.js'
1817
import { MaskType } from '../types.js'
1918
import { extractAppName } from '../utils/app.utils.js'
19+
import { cyan, green, red, yellow } from '../utils/color.utils.js'
2020
import { checkAssetFile, mkdirp } from '../utils/file-utils.js'
2121

2222
export default class Icons extends Command {

src/commands/splash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { Args, Command, Flags } from '@oclif/core'
10-
import { cyan, green, red, yellow } from 'ansis'
1110
import { writeFile } from 'node:fs/promises'
1211
import { join } from 'node:path'
1312
import sharp from 'sharp'
@@ -16,6 +15,7 @@ import type { ContentJson, SplashscreenSize } from '../types.js'
1615

1716
import { SPLASHSCREEN_SIZES_ANDROID, SPLASHSCREEN_SIZES_IOS } from '../constants.js'
1817
import { extractAppName } from '../utils/app.utils.js'
18+
import { cyan, green, red, yellow } from '../utils/color.utils.js'
1919
import { checkAssetFile, mkdirp } from '../utils/file-utils.js'
2020

2121
export default class Splash extends Command {

src/utils/color.utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2025 ForWarD Software (https://forwardsoftware.solutions/)
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
9+
import { styleText } from 'node:util'
10+
11+
/**
12+
* Color helper functions using util.styleText
13+
* These functions provide a simple API for terminal text styling
14+
*/
15+
16+
export const cyan = (text: string) => styleText('cyan', text)
17+
export const green = (text: string) => styleText('green', text)
18+
export const red = (text: string) => styleText('red', text)
19+
export const yellow = (text: string) => styleText('yellow', text)

0 commit comments

Comments
 (0)