Skip to content

Commit 664df79

Browse files
committed
fix(deps): replace chalk with tiny ansis
Oops and I got carried away and fixed a lot of types along the way.
1 parent c8f3e89 commit 664df79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2188
-425
lines changed

.madgerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"detectiveOptions": {
3+
"ts": {
4+
"skipTypeImports": true
5+
}
6+
}
7+
}

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.14.0

eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default tseslint.config(
7979
},
8080
},
8181
{
82+
files: ['{src,tests}/**/*'],
8283
rules: {
8384
'no-restricted-imports': [
8485
'error',
@@ -96,9 +97,9 @@ export default tseslint.config(
9697
},
9798

9899
{
99-
name: 'chalk',
100+
name: 'ansis',
100101
message:
101-
'Use the safe chalk import that handles colors for json output: `import { chalk } from "src/utils/command-helpers.js"`',
102+
'Use the configured ansis import that handles colors for json output: `import { ansis } from "src/utils/command-helpers.js"`',
102103
},
103104
],
104105
},

graph.svg

Lines changed: 1771 additions & 0 deletions
Loading

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
"@pnpm/tabtab": "0.5.4",
7575
"ansi-escapes": "7.0.0",
7676
"ansi-to-html": "0.7.2",
77+
"ansis": "^3.17.0",
7778
"ascii-table": "0.0.9",
7879
"backoff": "2.5.0",
7980
"boxen": "8.0.1",
80-
"chalk": "5.4.1",
8181
"chokidar": "3.6.0",
8282
"ci-info": "4.1.0",
8383
"clean-deep": "3.4.0",

scripts/postinstall.js

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,10 @@ import fs from 'node:fs/promises'
77
import path from 'node:path'
88
import { fileURLToPath } from 'node:url'
99
import process from 'node:process'
10-
// eslint-disable-next-line no-restricted-imports
11-
import chalk from 'chalk'
1210

13-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
14-
15-
const identity = (message) => message
11+
import ansis from 'ansis'
1612

17-
/**
18-
*
19-
* @param {string} message
20-
* @param {Array<chalk['Color'] | chalk['Modifiers']>} styles
21-
* @returns
22-
*/
23-
const format = (message, styles) => {
24-
let func = identity
25-
try {
26-
func = chalk
27-
styles.forEach((style) => {
28-
func = func[style]
29-
})
30-
} catch {}
31-
return func(message)
32-
}
13+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
3314

3415
const postInstall = async () => {
3516
const { createMainCommand } = await import('../dist/commands/index.js')
@@ -45,24 +26,17 @@ const postInstall = async () => {
4526
}
4627

4728
console.log('')
48-
console.log(await format('Success! Netlify CLI has been installed!', ['greenBright', 'bold', 'underline']))
29+
console.log(ansis.greenBright.bold.underline('Success! Netlify CLI has been installed!'))
4930
console.log('')
5031
console.log('Your device is now configured to use Netlify CLI to deploy and manage your Netlify sites.')
5132
console.log('')
5233
console.log('Next steps:')
5334
console.log('')
54-
console.log(
55-
` ${await format('netlify init', [
56-
'cyanBright',
57-
'bold',
58-
])} Connect or create a Netlify site from current directory`,
59-
)
60-
console.log(
61-
` ${await format('netlify deploy', ['cyanBright', 'bold'])} Deploy the latest changes to your Netlify site`,
62-
)
35+
console.log(` ${ansis.cyanBright.bold('netlify init')} Connect or create a Netlify site from current directory`)
36+
console.log(` ${ansis.cyan.bold('netlify deploy')} Deploy the latest changes to your Netlify site`)
6337
console.log('')
64-
console.log(`For more information on the CLI run ${await format('netlify help', ['cyanBright', 'bold'])}`)
65-
console.log(`Or visit the docs at ${await format('https://cli.netlify.com', ['cyanBright', 'bold'])}`)
38+
console.log(`For more information on the CLI run ${ansis.cyanBright.bold('netlify help')}`)
39+
console.log(`Or visit the docs at ${ansis.cyanBright.bold('https://cli.netlify.com')}`)
6640
console.log('')
6741
}
6842

scripts/prepublishOnly.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const main = async () => {
1010
//
1111
// Leaving development dependencies makes the CLI installation significantly larger and increases
1212
// the risk of platform-specific dependency installation issues.
13-
// eslint-disable-next-line no-restricted-properties
1413
const packageJSONPath = path.join(process.cwd(), 'package.json')
1514
const rawPackageJSON = await fs.readFile(packageJSONPath, 'utf8')
1615

site/package-lock.json

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

site/scripts/util/generate-command-data.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { createMainCommand } from '../../../src/commands/index.js'
2-
import { sortOptions } from '../../../src/utils/command-helpers.js'
2+
import { compareOptions } from '../../../src/utils/command-helpers.js'
33

44
const program = createMainCommand()
55

6-
/** @type {Array<import('../../../src/commands/base-command.js').default>} */
7-
// @ts-ignore typecast needed
8-
const commands = program.commands.sort((cmdA, cmdB) => cmdA.name().localeCompare(cmdB.name()))
6+
const commands = [...program.commands].sort((cmdA, cmdB) => cmdA.name().localeCompare(cmdB.name()))
97

108
/**
119
*
@@ -19,7 +17,7 @@ const parseCommand = function (command) {
1917

2018
const flags = command.options
2119
.filter((option) => !option.hidden)
22-
.sort(sortOptions)
20+
.sort(compareOptions)
2321
.reduce((prev, cur) => {
2422
const name = cur.long.replace('--', '')
2523
const contentType = cur.argChoices ? cur.argChoices.join(' | ') : 'string'

0 commit comments

Comments
 (0)