From 2778ddea12e2dd8b3df8cfa260f2157b35016b5a Mon Sep 17 00:00:00 2001 From: Damien Debin Date: Wed, 15 Oct 2025 11:38:34 +0200 Subject: [PATCH] feat: adds compatibility `yargs` `^18.0.0`, drop compatibility for node <20 --- .github/workflows/node.js.yml | 6 +++--- .github/workflows/npm-publish.yml | 6 +++--- README.md | 3 +-- package.json | 4 ++-- yaml-sort.js | 5 +++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index e4b0cf1..2f7d53c 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [12, 14, 16, 18, 20, 22] + node-version: [20, 22, 24] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 73979d3..a764cc2 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-node@v4 with: node-version: latest @@ -23,8 +23,8 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v6 with: node-version: latest registry-url: https://registry.npmjs.org/ diff --git a/README.md b/README.md index e612599..b194a45 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Options: --indent, --id Indentation width (in spaces) [number] [default: 2] -e, --encoding Input encoding [choices: "ascii", "utf8", "utf16le"] [default: "utf8"] -q, --quotingStyle Strings will be quoted using this quoting style [choices: "single", "double"] [default: "single"] - -f, --forceQuotes Force quotes for all scalar values [boolean] [default: false] + -f, --forceQuotes Force quotes around all strings [boolean] -w, --lineWidth Wrap line width (-1 for unlimited width) [number] [default: 80] -h, --help Show help [boolean] --version Show version number [boolean] @@ -35,6 +35,5 @@ Examples: yaml-sort --input config.yml Sorts alphabetically and overwrites the file config.yml yaml-sort --input config.yml --lineWidth 100 --stdout Sorts the file config.yml and output result to STDOUT wrapped to 100 columns yaml-sort --input config.yml --indent 4 --output sorted.yml Indents with 4 spaces and outputs result to file sorted.yml - yaml-sort --input config.yml --forceQuotes --quotingStyle double Forces double quotes for all scalar values cat config.yml | yaml-sort Sorts alphabetically from STDIN ``` \ No newline at end of file diff --git a/package.json b/package.json index 6d9dfa9..8100a32 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/ddebin/yaml-sort#readme", "dependencies": { "js-yaml": "^4.0.0", - "yargs": "^17.0.0" + "yargs": "^18.0.0" }, "devDependencies": { "standard": "^17.0.0", @@ -39,6 +39,6 @@ "tape-spawn": "^1.4.2" }, "engines": { - "node": ">=12" + "node": ">=20" } } diff --git a/yaml-sort.js b/yaml-sort.js index e87f3d0..ba40c3d 100755 --- a/yaml-sort.js +++ b/yaml-sort.js @@ -5,8 +5,9 @@ const fs = require('fs') const yaml = require('js-yaml') const yargs = require('yargs') +const { hideBin } = require('yargs/helpers') -const argv = yargs +const argv = yargs(hideBin(process.argv)) .usage('Usage: $0 [options]') .example([ ['$0 --input config.yml', @@ -79,7 +80,7 @@ const argv = yargs .alias('h', 'help') .version() .wrap(null) - .argv + .parse() let success = true