Navigation Menu

Skip to content

Commit

Permalink
feat(deps): update and slim down dependencies (#1003)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
iiroj committed Oct 4, 2021
1 parent 3885af8 commit 32c08d3
Show file tree
Hide file tree
Showing 19 changed files with 15,787 additions and 6,271 deletions.
6 changes: 3 additions & 3 deletions .appveyor.yml
Expand Up @@ -9,7 +9,7 @@ matrix:
install:
- ps: Install-Product node $env:nodejs_version
- set CI=true
- yarn install
- npm ci

build: off

Expand All @@ -19,9 +19,9 @@ cache:

test_script:
- node --version
- yarn --version
- npm --version
- git --version
- yarn test
- npm test

branches:
only:
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
@@ -1,10 +1,11 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"requireConfigFile": false,
"sourceType": "script"
},
"env": {
Expand Down
33 changes: 11 additions & 22 deletions .github/workflows/main.yml
Expand Up @@ -33,33 +33,22 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
# Get yarn's cache dir path
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# Cache the above yarn cache dir
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ runner.os }}-${{ runner.node }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-${{ runner.node }}-
cache: 'npm'
# Print current Node.js version
- run: node --version
# Print current Yarn version
- run: yarn --version
# Print current npm version
- run: npm --version
# Print current Git version
- run: git --version
# Install node_modules
- run: yarn
- run: npm ci
# Run tests
- run: yarn test
- run: npm test
# Upload coverage artifact from Node.js LTS
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
if: matrix.os == 'ubuntu-latest' && matrix.node == '12'
with:
name: coverage
Expand All @@ -72,11 +61,11 @@ jobs:
steps:
- uses: actions/checkout@v2
# Download coverage artifact
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v2
with:
name: coverage
# Run codecov.io
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v2

release:
name: Release
Expand All @@ -86,9 +75,9 @@ jobs:
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: '12' # release using Node.js LTS
node-version: '14' # release using Node.js LTS
# Release using semantic-release.
# While this runs on all branches, it will only release latest from master
- uses: codfish/semantic-release-action@v1
Expand Down
6 changes: 3 additions & 3 deletions bin/lint-staged.js
Expand Up @@ -5,9 +5,9 @@
const fs = require('fs')

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

// Do not terminate main Listr process on SIGINT
Expand Down
10 changes: 10 additions & 0 deletions lib/figures.js
@@ -0,0 +1,10 @@
const { blue, redBright, yellow } = require('colorette')
const { figures } = require('listr2')

const { arrowRight, cross, warning } = figures

module.exports = {
info: blue(arrowRight),
error: redBright(cross),
warning: yellow(warning),
}
36 changes: 19 additions & 17 deletions lib/messages.js
@@ -1,57 +1,59 @@
'use strict'

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

const { error, info, warning } = require('./figures')

const configurationError = (opt, helpMsg, value) =>
`${chalk.redBright(`${error} Validation Error:`)}
`${redBright(`${error} Validation Error:`)}
Invalid value for '${chalk.bold(opt)}': ${chalk.bold(
Invalid value for '${bold(opt)}': ${bold(
format(value, { inlineCharacterLimit: Number.POSITIVE_INFINITY })
)}
${helpMsg}`

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

const FAILED_GET_STAGED_FILES = chalk.redBright(`${error} Failed to get staged files!`)
const FAILED_GET_STAGED_FILES = redBright(`${error} Failed to get staged files!`)

const incorrectBraces = (before, after) => `${warning} ${chalk.yellow(
`Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\``
)}
const incorrectBraces = (before, after) =>
yellow(
`${warning} Detected incorrect braces with only single value: \`${before}\`. Reformatted as: \`${after}\`
`
)

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

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

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

const DEPRECATED_GIT_ADD = `${warning} ${chalk.yellow(
`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.`
)}
const DEPRECATED_GIT_ADD = yellow(
`${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.
`
)

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

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

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

const invalidOption = (name, value, message) => `${chalk.redBright(`${error} Validation Error:`)}
const invalidOption = (name, value, message) => `${redBright(`${error} Validation Error:`)}
Invalid value for option '${chalk.bold(name)}': ${chalk.bold(value)}
Invalid value for option '${bold(name)}': ${bold(value)}
${message}
See https://github.com/okonet/lint-staged#command-line-flags`

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

Expand Down
4 changes: 2 additions & 2 deletions lib/resolveTaskFn.js
@@ -1,11 +1,11 @@
'use strict'

const { redBright, dim } = require('chalk')
const { redBright, dim } = require('colorette')
const execa = require('execa')
const debug = require('debug')('lint-staged:task')
const { parseArgsStringToArgv } = require('string-argv')
const { error, info } = require('log-symbols')

const { error, info } = require('./figures')
const { getInitialState } = require('./state')
const { TaskError } = require('./symbols')

Expand Down

0 comments on commit 32c08d3

Please sign in to comment.