Skip to content

Commit 32c08d3

Browse files
authored
feat(deps): update and slim down dependencies (#1003)
* chore(deps): update dependencies * test: remove duplicates lines from snapshots * test: replace babel-eslint with @babel/eslint-parser * chore(deps): update dependencies * chore(deps): regenerate yarn.lock to reduce its size * perf: re-use figures from listr2 and remove `log-symbols` * perf: replace `chalk` with `colorette` and `supports-color` * build: use npm instead of yarn
1 parent 3885af8 commit 32c08d3

19 files changed

+15787
-6271
lines changed

.appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ matrix:
99
install:
1010
- ps: Install-Product node $env:nodejs_version
1111
- set CI=true
12-
- yarn install
12+
- npm ci
1313

1414
build: off
1515

@@ -19,9 +19,9 @@ cache:
1919

2020
test_script:
2121
- node --version
22-
- yarn --version
22+
- npm --version
2323
- git --version
24-
- yarn test
24+
- npm test
2525

2626
branches:
2727
only:

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"parser": "babel-eslint",
2+
"parser": "@babel/eslint-parser",
33
"parserOptions": {
44
"ecmaVersion": 6,
55
"ecmaFeatures": {
66
"experimentalObjectRestSpread": true
77
},
8+
"requireConfigFile": false,
89
"sourceType": "script"
910
},
1011
"env": {

.github/workflows/main.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,22 @@ jobs:
3333
runs-on: ${{ matrix.os }}
3434
steps:
3535
- uses: actions/checkout@v2
36-
- uses: actions/setup-node@v1
36+
- uses: actions/setup-node@v2
3737
with:
3838
node-version: ${{ matrix.node }}
39-
# Get yarn's cache dir path
40-
- name: Get yarn cache directory path
41-
id: yarn-cache-dir-path
42-
run: echo "::set-output name=dir::$(yarn cache dir)"
43-
# Cache the above yarn cache dir
44-
- uses: actions/cache@v1
45-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
46-
with:
47-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
48-
key: yarn-${{ runner.os }}-${{ runner.node }}-${{ hashFiles('**/yarn.lock') }}
49-
restore-keys: |
50-
yarn-${{ runner.os }}-${{ runner.node }}-
39+
cache: 'npm'
5140
# Print current Node.js version
5241
- run: node --version
53-
# Print current Yarn version
54-
- run: yarn --version
42+
# Print current npm version
43+
- run: npm --version
5544
# Print current Git version
5645
- run: git --version
5746
# Install node_modules
58-
- run: yarn
47+
- run: npm ci
5948
# Run tests
60-
- run: yarn test
49+
- run: npm test
6150
# Upload coverage artifact from Node.js LTS
62-
- uses: actions/upload-artifact@v1
51+
- uses: actions/upload-artifact@v2
6352
if: matrix.os == 'ubuntu-latest' && matrix.node == '12'
6453
with:
6554
name: coverage
@@ -72,11 +61,11 @@ jobs:
7261
steps:
7362
- uses: actions/checkout@v2
7463
# Download coverage artifact
75-
- uses: actions/download-artifact@v1
64+
- uses: actions/download-artifact@v2
7665
with:
7766
name: coverage
7867
# Run codecov.io
79-
- uses: codecov/codecov-action@v1
68+
- uses: codecov/codecov-action@v2
8069

8170
release:
8271
name: Release
@@ -86,9 +75,9 @@ jobs:
8675
if: github.event_name == 'push'
8776
steps:
8877
- uses: actions/checkout@v2
89-
- uses: actions/setup-node@v1
78+
- uses: actions/setup-node@v2
9079
with:
91-
node-version: '12' # release using Node.js LTS
80+
node-version: '14' # release using Node.js LTS
9281
# Release using semantic-release.
9382
# While this runs on all branches, it will only release latest from master
9483
- uses: codfish/semantic-release-action@v1

bin/lint-staged.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
const fs = require('fs')
66

77
// Force colors for packages that depend on https://www.npmjs.com/package/supports-color
8-
const { supportsColor } = require('chalk')
9-
if (supportsColor && supportsColor.level) {
10-
process.env.FORCE_COLOR = supportsColor.level.toString()
8+
const supportsColor = require('supports-color')
9+
if (supportsColor.stdout) {
10+
process.env.FORCE_COLOR = supportsColor.stdout.level.toString()
1111
}
1212

1313
// Do not terminate main Listr process on SIGINT

lib/figures.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { blue, redBright, yellow } = require('colorette')
2+
const { figures } = require('listr2')
3+
4+
const { arrowRight, cross, warning } = figures
5+
6+
module.exports = {
7+
info: blue(arrowRight),
8+
error: redBright(cross),
9+
warning: yellow(warning),
10+
}

lib/messages.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,59 @@
11
'use strict'
22

3-
const chalk = require('chalk')
4-
const { error, info, warning } = require('log-symbols')
3+
const { redBright, bold, yellow } = require('colorette')
54
const format = require('stringify-object')
65

6+
const { error, info, warning } = require('./figures')
7+
78
const configurationError = (opt, helpMsg, value) =>
8-
`${chalk.redBright(`${error} Validation Error:`)}
9+
`${redBright(`${error} Validation Error:`)}
910
10-
Invalid value for '${chalk.bold(opt)}': ${chalk.bold(
11+
Invalid value for '${bold(opt)}': ${bold(
1112
format(value, { inlineCharacterLimit: Number.POSITIVE_INFINITY })
1213
)}
1314
1415
${helpMsg}`
1516

16-
const NOT_GIT_REPO = chalk.redBright(`${error} Current directory is not a git directory!`)
17+
const NOT_GIT_REPO = redBright(`${error} Current directory is not a git directory!`)
1718

18-
const FAILED_GET_STAGED_FILES = chalk.redBright(`${error} Failed to get staged files!`)
19+
const FAILED_GET_STAGED_FILES = redBright(`${error} Failed to get staged files!`)
1920

20-
const incorrectBraces = (before, after) => `${warning} ${chalk.yellow(
21-
`Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\``
22-
)}
21+
const incorrectBraces = (before, after) =>
22+
yellow(
23+
`${warning} Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\`
2324
`
25+
)
2426

2527
const NO_STAGED_FILES = `${info} No staged files found.`
2628

2729
const NO_TASKS = `${info} No staged files match any configured task.`
2830

2931
const skippingBackup = (hasInitialCommit) => {
3032
const reason = hasInitialCommit ? '`--no-stash` was used' : 'there’s no initial commit yet'
31-
return `${warning} ${chalk.yellow(`Skipping backup because ${reason}.\n`)}`
33+
return yellow(`${warning} Skipping backup because ${reason}.\n`)
3234
}
3335

34-
const DEPRECATED_GIT_ADD = `${warning} ${chalk.yellow(
35-
`Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.`
36-
)}
36+
const DEPRECATED_GIT_ADD = yellow(
37+
`${warning} Some of your tasks use \`git add\` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.
3738
`
39+
)
3840

3941
const TASK_ERROR = 'Skipped because of errors from tasks.'
4042

4143
const SKIPPED_GIT_ERROR = 'Skipped because of previous git error.'
4244

43-
const GIT_ERROR = `\n ${error} ${chalk.red(`lint-staged failed due to a git error.`)}`
45+
const GIT_ERROR = `\n ${redBright(`${error} lint-staged failed due to a git error.`)}`
4446

45-
const invalidOption = (name, value, message) => `${chalk.redBright(`${error} Validation Error:`)}
47+
const invalidOption = (name, value, message) => `${redBright(`${error} Validation Error:`)}
4648
47-
Invalid value for option '${chalk.bold(name)}': ${chalk.bold(value)}
49+
Invalid value for option '${bold(name)}': ${bold(value)}
4850
4951
${message}
5052
5153
See https://github.com/okonet/lint-staged#command-line-flags`
5254

5355
const PREVENTED_EMPTY_COMMIT = `
54-
${warning} ${chalk.yellow(`lint-staged prevented an empty git commit.
56+
${yellow(`${warning} lint-staged prevented an empty git commit.
5557
Use the --allow-empty option to continue, or check your task configuration`)}
5658
`
5759

lib/resolveTaskFn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

3-
const { redBright, dim } = require('chalk')
3+
const { redBright, dim } = require('colorette')
44
const execa = require('execa')
55
const debug = require('debug')('lint-staged:task')
66
const { parseArgsStringToArgv } = require('string-argv')
7-
const { error, info } = require('log-symbols')
87

8+
const { error, info } = require('./figures')
99
const { getInitialState } = require('./state')
1010
const { TaskError } = require('./symbols')
1111

0 commit comments

Comments
 (0)