From 031aa10b4b31b33605f7b74ffcf006484724bc0e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2020 21:07:40 -0400 Subject: [PATCH 01/97] Update dependency prettier to ~2.1.0 (#337) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0588ea6..390a175 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "4.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", - "prettier": "~2.0.0", + "prettier": "~2.1.0", "sugarss": "^2.0.0", "uuid": "^8.0.0" }, From 77d2c1d1f297f30c64e28ce59aea5996c1a362b6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 31 Aug 2020 21:30:13 -0400 Subject: [PATCH 02/97] Clean up 'use strict' usage --- test/.eslintrc.yaml | 2 -- test/base.js | 1 + test/cli.js | 1 + test/config.js | 1 + test/dir.js | 1 + test/error.js | 1 + test/ext.js | 1 + test/fixtures/_bad-plugin.js | 1 + test/glob.js | 1 + test/helpers/clean.js | 2 +- test/helpers/cli.js | 1 + test/helpers/env.js | 1 + test/helpers/read.js | 1 + test/helpers/tmp.js | 1 + test/map.js | 1 + test/misc.js | 1 + test/parser.js | 1 + test/replace.js | 1 + test/stdin.js | 1 + test/stdout.js | 1 + test/stringifier.js | 1 + test/syntax.js | 1 + test/use.js | 1 + test/watch.js | 1 + 24 files changed, 23 insertions(+), 3 deletions(-) delete mode 100644 test/.eslintrc.yaml diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml deleted file mode 100644 index add5a78..0000000 --- a/test/.eslintrc.yaml +++ /dev/null @@ -1,2 +0,0 @@ -parserOptions: - sourceType: module diff --git a/test/base.js b/test/base.js index 1bef3e3..32eff27 100644 --- a/test/base.js +++ b/test/base.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/cli.js b/test/cli.js index d2e449c..0cdc7dc 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/config.js b/test/config.js index 774e2f5..b8b3de5 100644 --- a/test/config.js +++ b/test/config.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/dir.js b/test/dir.js index 51c0b6e..ec4e60e 100644 --- a/test/dir.js +++ b/test/dir.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/error.js b/test/error.js index e53ce05..4dace3c 100644 --- a/test/error.js +++ b/test/error.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const tmp = require('./helpers/tmp.js') diff --git a/test/ext.js b/test/ext.js index 3f6e883..7016782 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/fixtures/_bad-plugin.js b/test/fixtures/_bad-plugin.js index 2911e95..7a4ffeb 100644 --- a/test/fixtures/_bad-plugin.js +++ b/test/fixtures/_bad-plugin.js @@ -1 +1,2 @@ +'use strict' throw new Error('This fails') diff --git a/test/glob.js b/test/glob.js index 574cebb..e60b75a 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/helpers/clean.js b/test/helpers/clean.js index 526bedf..cabfc72 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,4 +1,4 @@ -'use strict' // eslint-disable-line +'use strict' const fs = require('fs-extra') Promise.all([ diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 7512439..64b9154 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,3 +1,4 @@ +'use strict' const path = require('path') const { exec } = require('child_process') diff --git a/test/helpers/env.js b/test/helpers/env.js index 2fad200..b389370 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,3 +1,4 @@ +'use strict' const fs = require('fs-extra') const path = require('path') const globby = require('globby') diff --git a/test/helpers/read.js b/test/helpers/read.js index 3122ee1..88b6421 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,3 +1,4 @@ +'use strict' const { readFile } = require('fs-extra') module.exports = function (path) { diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index f084dea..a23fa35 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,3 +1,4 @@ +'use strict' const path = require('path') const { v4: uuid } = require('uuid') diff --git a/test/map.js b/test/map.js index ac64a78..04f90fd 100644 --- a/test/map.js +++ b/test/map.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/misc.js b/test/misc.js index 29a736c..9240e32 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/parser.js b/test/parser.js index 4c56abb..1ac9805 100644 --- a/test/parser.js +++ b/test/parser.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/replace.js b/test/replace.js index 5b48ad4..f2712a2 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stdin.js b/test/stdin.js index 867145c..8709a94 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stdout.js b/test/stdout.js index 9b26ad4..8bd5d7b 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stringifier.js b/test/stringifier.js index 4256c79..db3ef28 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/syntax.js b/test/syntax.js index 4658d69..c4295f9 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/use.js b/test/use.js index 07901f6..25400f6 100644 --- a/test/use.js +++ b/test/use.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/watch.js b/test/watch.js index 6012bf7..b5bce40 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') From 1c3ebba359cc4702c2094b1a28ef5a678e930dc6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 1 Sep 2020 10:40:13 -0400 Subject: [PATCH 03/97] Upgrade eslint & eslint-config-problems (#339) Closes #326 Closes #338 --- lib/depGraph.js | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/depGraph.js b/lib/depGraph.js index 783d76e..ace18be 100644 --- a/lib/depGraph.js +++ b/lib/depGraph.js @@ -1,6 +1,6 @@ 'use strict' const path = require('path') -const DepGraph = require('dependency-graph').DepGraph +const { DepGraph } = require('dependency-graph') const graph = new DepGraph() diff --git a/package.json b/package.json index 390a175..12c5763 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "devDependencies": { "ava": "^3.1.0", "coveralls": "^3.0.0", - "eslint": "^6.8.0", - "eslint-config-problems": "4.0.0", + "eslint": "^7.8.0", + "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", "prettier": "~2.1.0", From 66b6055d3cf8b1960b4e83131d06f1f382940e16 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2020 12:47:41 -0400 Subject: [PATCH 04/97] Update dependency yargs to v16 (#340) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12c5763..7a9487a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^6.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^15.0.2" + "yargs": "^16.0.0" }, "devDependencies": { "ava": "^3.1.0", From a4998fafdf40e58c299565676ac26137219592d5 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 21 Sep 2020 12:48:10 -0400 Subject: [PATCH 05/97] Support postcss v8 (#349) * Support postcss v8 Fixes #344 Closes #348, closes #345, closes #343. * Don't promote global installs --- README.md | 2 +- package.json | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 50bade6..71db6e6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@

Install

```bash -npm i -g|-D postcss-cli +npm i -D postcss postcss-cli ```

Usage

diff --git a/package.json b/package.json index 7a9487a..0237360 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,8 @@ "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", - "postcss": "^7.0.0", - "postcss-load-config": "^2.0.0", - "postcss-reporter": "^6.0.0", + "postcss-load-config": "^2.1.1", + "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^16.0.0" @@ -37,11 +36,15 @@ "eslint": "^7.8.0", "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", + "postcss": "^8.0.4", "postcss-import": "^12.0.0", "prettier": "~2.1.0", - "sugarss": "^2.0.0", + "sugarss": "^3.0.0", "uuid": "^8.0.0" }, + "peerDependencies": { + "postcss": "^8.0.0" + }, "files": [ "bin", "index.js", From ed69076bea45df66dcde8f317af3e886f5706f1c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 21 Sep 2020 13:06:59 -0400 Subject: [PATCH 06/97] Remove obsolete failing test Fixes #123 --- test/error.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/error.js b/test/error.js index 4dace3c..38b972b 100644 --- a/test/error.js +++ b/test/error.js @@ -28,19 +28,6 @@ test('--map && writing to stdout', (t) => { }) }) -test.failing('invalid --config', (t) => { - return cli([ - 'test/fixtures/*.css', - '-c', - 'test/postcss.config.js', - '-d', - tmp(), - ]).then(({ error, code }) => { - t.is(code, 1, 'expected non-zero error code') - t.regex(error.toString(), /ENOENT: no such file or directory/) - }) -}) - test('plugin not found', (t) => { return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( ({ error, code }) => { From 9e03d5c001a68027d569bf8c10fe3e448a40851d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 21 Sep 2020 13:53:28 -0400 Subject: [PATCH 07/97] 8.0.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e0ce1..eba276a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 8.0.0 / 2020-09-21 + +- **BREAKING:** Support postcss v8 ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) +- **BREAKING:** postcss is now a `peerDependency`, you must install it seperately ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) +- Upgrade dependencies ([#340](https://github.com/postcss/postcss-cli/pull/340)) + # 7.1.2 / 2020-08-31 - Make `--version` machine-readable ([#334](https://github.com/postcss/postcss-cli/issues/334), [#335](https://github.com/postcss/postcss-cli/pull/335)) diff --git a/package.json b/package.json index 0237360..75a7200 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "7.1.2", + "version": "8.0.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 8aa4f6e8c9f963e3e8cac19c8d2f80133be6595c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2020 11:18:39 -0400 Subject: [PATCH 08/97] Update dependency postcss-load-config to v3 (#351) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75a7200..db5b53a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", - "postcss-load-config": "^2.1.1", + "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From 8ef4c1fc2b7bcbc754f1a8f276578d7f6ec1aa39 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 8 Oct 2020 18:20:04 -0400 Subject: [PATCH 09/97] Add tests for DependencyGraph (#354) * Make depGraph testable * Add tests for DependencyGraph --- index.js | 3 ++- lib/DependencyGraph.js | 24 ++++++++++++++++++++++++ lib/DependencyGraph.test.js | 20 ++++++++++++++++++++ lib/depGraph.js | 22 ---------------------- package.json | 3 ++- 5 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 lib/DependencyGraph.js create mode 100644 lib/DependencyGraph.test.js delete mode 100644 lib/depGraph.js diff --git a/index.js b/index.js index 187b9bc..aeccc51 100644 --- a/index.js +++ b/index.js @@ -15,8 +15,9 @@ const postcssrc = require('postcss-load-config') const reporter = require('postcss-reporter/lib/formatter')() const argv = require('./lib/args') -const depGraph = require('./lib/depGraph') +const createDependencyGraph = require('./lib/DependencyGraph') const getMapfile = require('./lib/getMapfile') +const depGraph = createDependencyGraph() let input = argv._ const { dir, output } = argv diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js new file mode 100644 index 0000000..03fae2e --- /dev/null +++ b/lib/DependencyGraph.js @@ -0,0 +1,24 @@ +'use strict' +const path = require('path') +const { DepGraph } = require('dependency-graph') + +module.exports = function () { + const graph = new DepGraph() + return { + add(message) { + message.parent = path.resolve(message.parent) + message.file = path.resolve(message.file) + + graph.addNode(message.parent) + graph.addNode(message.file) + graph.addDependency(message.parent, message.file) + return message + }, + dependantsOf(node) { + node = path.resolve(node) + + if (graph.hasNode(node)) return graph.dependantsOf(node) + return [] + }, + } +} diff --git a/lib/DependencyGraph.test.js b/lib/DependencyGraph.test.js new file mode 100644 index 0000000..a0235ba --- /dev/null +++ b/lib/DependencyGraph.test.js @@ -0,0 +1,20 @@ +'use strict' +const test = require('ava') +const path = require('path') +const createDependencyGraph = require('./DependencyGraph.js') + +function resolveArray(arr) { + return arr.map((p) => path.resolve(p)) +} + +test('tracks dependencies', (t) => { + const graph = createDependencyGraph() + graph.add({ file: 'aa', parent: 'a' }) + graph.add({ file: 'bb', parent: 'b' }) + graph.add({ file: 'ab', parent: 'a' }) + graph.add({ file: 'ab', parent: 'b' }) + t.deepEqual(graph.dependantsOf('aa'), resolveArray(['a'])) + t.deepEqual(graph.dependantsOf('bb'), resolveArray(['b'])) + t.deepEqual(graph.dependantsOf('ab'), resolveArray(['a', 'b'])) + t.deepEqual(graph.dependantsOf('nonexistent'), []) +}) diff --git a/lib/depGraph.js b/lib/depGraph.js deleted file mode 100644 index ace18be..0000000 --- a/lib/depGraph.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' -const path = require('path') -const { DepGraph } = require('dependency-graph') - -const graph = new DepGraph() - -exports.add = (message) => { - message.parent = path.resolve(message.parent) - message.file = path.resolve(message.file) - - graph.addNode(message.parent) - graph.addNode(message.file) - graph.addDependency(message.parent, message.file) - return message -} - -exports.dependantsOf = (node) => { - node = path.resolve(node) - - if (graph.hasNode(node)) return graph.dependantsOf(node) - return [] -} diff --git a/package.json b/package.json index db5b53a..859470b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "files": [ "bin", "index.js", - "lib" + "lib", + "!*.test.js" ], "keywords": [ "cli", From c94c1885a97f30627ba31c386fce0d8eed483a71 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 8 Oct 2020 18:23:20 -0400 Subject: [PATCH 10/97] 8.1.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba276a..3b5ff99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.1.0 / 2020-10-08 + +- Add support for `postcss.config.cjs` files ([#351](https://github.com/postcss/postcss-cli/pull/351)) + # 8.0.0 / 2020-09-21 - **BREAKING:** Support postcss v8 ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) diff --git a/package.json b/package.json index 859470b..5f55fed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.0.0", + "version": "8.1.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From c634575b3d838037a908cad3830ef3ebddc861b8 Mon Sep 17 00:00:00 2001 From: Matthias Christen Date: Tue, 20 Oct 2020 16:29:52 +0200 Subject: [PATCH 11/97] Use 'slash' on input files before globbing to support absolute paths with backslashes on Windows (#355) --- index.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index aeccc51..edc7a3f 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const stdin = require('get-stdin') const read = require('read-cache') const chalk = require('chalk') const globber = require('globby') +const slash = require('slash') const chokidar = require('chokidar') const postcss = require('postcss') @@ -57,7 +58,7 @@ Promise.resolve() } if (input && input.length) { - return globber(input, { dot: argv.includeDotfiles }) + return globber(input.map(slash), { dot: argv.includeDotfiles }) } if (argv.replace || argv.dir) { diff --git a/package.json b/package.json index 5f55fed..7ababaa 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", + "slash": "^3.0.0", "yargs": "^16.0.0" }, "devDependencies": { From e279de81cb48a008070fea20f9db2e6db2feb675 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 29 Oct 2020 18:41:19 -0400 Subject: [PATCH 12/97] 8.2.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5ff99..c74cd37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.2.0 / 2020-10-29 + +- Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) + # 8.1.0 / 2020-10-08 - Add support for `postcss.config.cjs` files ([#351](https://github.com/postcss/postcss-cli/pull/351)) diff --git a/package.json b/package.json index 7ababaa..88a0b34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.1.0", + "version": "8.2.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From b19fbdc07718dfad6d8cd501219be6bb2705960b Mon Sep 17 00:00:00 2001 From: Timmo Verlaan Date: Tue, 17 Nov 2020 01:42:58 +0100 Subject: [PATCH 13/97] Exit watch process on EOF / Ctrl-D (#358) --- index.js | 5 +++++ test/watch.js | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index edc7a3f..47a6e5a 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,11 @@ let configFile if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) +if (argv.watch) { + process.stdin.on('end', () => process.exit(0)) + process.stdin.resume() +} + Promise.resolve() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { diff --git a/test/watch.js b/test/watch.js index b5bce40..4a51a11 100644 --- a/test/watch.js +++ b/test/watch.js @@ -3,11 +3,12 @@ const test = require('ava') const fs = require('fs-extra') const path = require('path') -const { exec } = require('child_process') +const { exec, spawn } = require('child_process') const chokidar = require('chokidar') const ENV = require('./helpers/env.js') const read = require('./helpers/read.js') +const tmp = require('./helpers/tmp.js') // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb @@ -285,3 +286,19 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) + +testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { + t.plan(1) + + const cp = spawn( + `./bin/postcss test/fixtures/a.css -o ${tmp()} -w --no-map`, + { shell: true } + ) + + cp.on('error', t.end) + cp.on('exit', (code) => { + t.is(code, 0) + t.end() + }) + cp.stdin.end() +}) From 1e7bf403f352caf67b45d48870e29900e6b9aa9e Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 17 Nov 2020 10:15:10 -0500 Subject: [PATCH 14/97] 8.3.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c74cd37..47faac6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.3.0 / 2020-11-17 + +- Exit on EOF/`^D` ([#358](https://github.com/postcss/postcss-cli/pull/358)) + # 8.2.0 / 2020-10-29 - Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) diff --git a/package.json b/package.json index 88a0b34..2c68a8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.2.0", + "version": "8.3.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 453aaec22c02064693ec8ee4d704a33ead27b97a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2020 14:49:18 -0500 Subject: [PATCH 15/97] Update dependency prettier to ~2.2.0 (#359) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c68a8f..d4415db 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^12.0.0", - "prettier": "~2.1.0", + "prettier": "~2.2.0", "sugarss": "^3.0.0", "uuid": "^8.0.0" }, From 4b9b66d5338b925ec6b52e2fd4bb1e5901038fbc Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 3 Dec 2020 12:54:07 -0500 Subject: [PATCH 16/97] Cast to string before passing input globs to slash If a number is passed as a positional argument, yargs interprets it as a JS Number, and slash tries to call .replace() on it, which fails. This ensures slash only gets strings passed to it. Refs https://github.com/postcss/postcss-cli/issues/360#issuecomment-738157557 --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 47a6e5a..0bab158 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,10 @@ Promise.resolve() } if (input && input.length) { - return globber(input.map(slash), { dot: argv.includeDotfiles }) + return globber( + input.map((i) => slash(String(i))), + { dot: argv.includeDotfiles } + ) } if (argv.replace || argv.dir) { From 96b6521da8b8fb0349a853e432be4e4e272da4a2 Mon Sep 17 00:00:00 2001 From: Kim Hallberg Date: Tue, 8 Dec 2020 16:56:45 +0100 Subject: [PATCH 17/97] Error when using unsupported PostCSS version (fix #361) (#362) --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 0bab158..ce117bb 100644 --- a/index.js +++ b/index.js @@ -56,6 +56,11 @@ if (argv.watch) { process.stdin.resume() } +/* istanbul ignore next */ +if (parseInt(postcss().version) < 8) { + error('Please install PostCSS 8 or above') +} + Promise.resolve() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { From f25d3de608f9e1990b3d6bc2edf2d6c008f7c8fb Mon Sep 17 00:00:00 2001 From: Kim Hallberg Date: Thu, 10 Dec 2020 20:55:48 +0100 Subject: [PATCH 18/97] Fix PostCSS CLI logo not loading (#363) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71db6e6..f96eab4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![chat][chat]][chat-url]
- + From 35545bdb384d0e75ffa4385de960968f4a6cd28d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Sat, 12 Dec 2020 09:56:19 -0500 Subject: [PATCH 19/97] 8.3.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47faac6..186942c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 8.3.1 / 2020-12-12 + +- Ensure paths are not interpreted as numbers ([#360](https://github.com/postcss/postcss-cli/issues/360)) +- Better errors for incorrect postcss version ([#361](https://github.com/postcss/postcss-cli/issues/361), [#362](https://github.com/postcss/postcss-cli/pull/362)) + # 8.3.0 / 2020-11-17 - Exit on EOF/`^D` ([#358](https://github.com/postcss/postcss-cli/pull/358)) diff --git a/package.json b/package.json index d4415db..b5b90e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.3.0", + "version": "8.3.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 947665b58c079e0813becc67702f4749a92cb628 Mon Sep 17 00:00:00 2001 From: Shashikant Yadav Date: Tue, 19 Jan 2021 02:38:55 +0530 Subject: [PATCH 20/97] Fix grammatical mistake in README.md (#367) Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f96eab4..3f267bc 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Note that you **can not** set the `from` or `to` options for postcss in the conf ### Context -For more advanced usage it's recommend to to use a function in `postcss.config.js`, this gives you access to the CLI context to dynamically apply options and plugins **per file** +For more advanced usage, it's recommended to use a function in `postcss.config.js`; this gives you access to the CLI context to dynamically apply options and plugins **per file** | Name | Type | Default | Description | | :-------: | :--------: | :--------------------------------: | :------------------- | From 60b476de3eb4e79b6cd443ce6a400d96310f77a2 Mon Sep 17 00:00:00 2001 From: Ludovico Fischer <43557+ludofischer@users.noreply.github.com> Date: Mon, 18 Jan 2021 22:20:26 +0100 Subject: [PATCH 21/97] refactor: replace chalk with colorette (#365) Since postcss and postcss-reporter use colorette, getting rid of chalk in this package saves about 100KB when doing a `yarn install`. --- index.js | 10 +++++----- lib/args.js | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ce117bb..66ef2af 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const path = require('path') const prettyHrtime = require('pretty-hrtime') const stdin = require('get-stdin') const read = require('read-cache') -const chalk = require('chalk') +const { bold, dim, red, cyan, green } = require('colorette') const globber = require('globby') const slash = require('slash') const chokidar = require('chokidar') @@ -106,7 +106,7 @@ Promise.resolve() .then((results) => { if (argv.watch) { const printMessage = () => - printVerbose(chalk.dim('\nWaiting for file changes...')) + printVerbose(dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, @@ -197,7 +197,7 @@ function css(css, file) { const time = process.hrtime() - printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`) + printVerbose(cyan(`Processing ${bold(relativePath)}...`)) return rc(ctx, argv.config) .then((config) => { @@ -245,7 +245,7 @@ function css(css, file) { return Promise.all(tasks).then(() => { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( - chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}` + green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`) ) const messages = result.warnings() @@ -288,7 +288,7 @@ function error(err) { if (argv.verbose) console.error() if (typeof err === 'string') { - console.error(chalk.red(err)) + console.error(red(err)) } else if (err.name === 'CssSyntaxError') { console.error(err.toString()) } else { diff --git a/lib/args.js b/lib/args.js index b027bb4..8b2dbf2 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,5 +1,5 @@ 'use strict' -const chalk = require('chalk') +const { bold, red } = require('colorette') const logo = ` /|\\ @@ -15,7 +15,7 @@ const logo = ` module.exports = require('yargs') .usage( - `${chalk.bold.red(logo)} + `${bold(red(logo))} Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] diff --git a/package.json b/package.json index b5b90e8..37222af 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "test": "nyc ava -v" }, "dependencies": { - "chalk": "^4.0.0", "chokidar": "^3.3.0", + "colorette": "^1.2.1", "dependency-graph": "^0.9.0", "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", From ab73f3652351a4a7f470aca185badc0a7af4e355 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 10 May 2021 15:18:57 -0400 Subject: [PATCH 22/97] chore(deps): update dependency prettier to ~2.3.0 (#380) * chore(deps): update dependency prettier to ~2.3.0 * prettier Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- lib/args.js | 6 ++---- package.json | 2 +- test/watch.js | 21 +++++++++------------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/args.js b/lib/args.js index 8b2dbf2..b2cd258 100644 --- a/lib/args.js +++ b/lib/args.js @@ -94,8 +94,7 @@ Usage: }, }) .option('base', { - desc: - 'Mirror the directory structure relative to this path in the output directory, for use with --dir', + desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir', type: 'string', implies: 'dir', }) @@ -105,8 +104,7 @@ Usage: type: 'boolean', }) .option('poll', { - desc: - 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', + desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', implies: 'watch', }) .option('config', { diff --git a/package.json b/package.json index 37222af..bab04ca 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^12.0.0", - "prettier": "~2.2.0", + "prettier": "~2.3.0", "sugarss": "^3.0.0", "uuid": "^8.0.0" }, diff --git a/test/watch.js b/test/watch.js index 4a51a11..a2377a8 100644 --- a/test/watch.js +++ b/test/watch.js @@ -64,10 +64,9 @@ testCb('--watch works', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -145,10 +144,9 @@ testCb('--watch postcss.config.js', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -216,10 +214,9 @@ testCb('--watch dependencies', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { From ee7d27a3445fc2919aa574ca22f96ed46fe3eeee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 18:34:20 -0400 Subject: [PATCH 23/97] Update dependency sugarss to v4 (#384) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bab04ca..bdc92ba 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss": "^8.0.4", "postcss-import": "^12.0.0", "prettier": "~2.3.0", - "sugarss": "^3.0.0", + "sugarss": "^4.0.0", "uuid": "^8.0.0" }, "peerDependencies": { From f0e262ed484436a669d81b66424ef6017058950c Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 15 Jun 2021 00:56:42 +0100 Subject: [PATCH 24/97] Add support for `dir-dependency` messages (#383) * Add support for `dir-dependency` messages * Fix DependencyGraph test * update `if` statement for consistency * Deduplicate recompile files using a set * Add dependency tests --- index.js | 31 ++++++- lib/DependencyGraph.js | 15 +++- test/watch.js | 195 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 66ef2af..945611a 100644 --- a/index.js +++ b/index.js @@ -123,13 +123,17 @@ Promise.resolve() if (input.includes(file)) recompile.push(file) + const dependants = depGraph + .dependantsOf(file) + .concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf)) + recompile = recompile.concat( - depGraph.dependantsOf(file).filter((file) => input.includes(file)) + dependants.filter((file) => input.includes(file)) ) if (!recompile.length) recompile = input - return files(recompile) + return files([...new Set(recompile)]) .then((results) => watcher.add(dependencies(results))) .then(printMessage) .catch(error) @@ -271,9 +275,17 @@ function dependencies(results) { if (result.messages <= 0) return result.messages - .filter((msg) => (msg.type === 'dependency' ? msg : '')) + .filter((msg) => + msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '' + ) .map(depGraph.add) - .forEach((dependency) => messages.push(dependency.file)) + .forEach((dependency) => { + if (dependency.type === 'dir-dependency') { + messages.push(dependency.dir) + } else { + messages.push(dependency.file) + } + }) }) return messages @@ -298,3 +310,14 @@ function error(err) { if (argv.watch) return process.exit(1) } + +// Input: '/imports/components/button.css' +// Output: ['/imports/components', '/imports', '/'] +function getAncestorDirs(fileOrDir) { + const { root } = path.parse(fileOrDir) + if (fileOrDir === root) { + return [] + } + const parentDir = path.dirname(fileOrDir) + return [parentDir, ...getAncestorDirs(parentDir)] +} diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js index 03fae2e..c293cda 100644 --- a/lib/DependencyGraph.js +++ b/lib/DependencyGraph.js @@ -7,11 +7,18 @@ module.exports = function () { return { add(message) { message.parent = path.resolve(message.parent) - message.file = path.resolve(message.file) - graph.addNode(message.parent) - graph.addNode(message.file) - graph.addDependency(message.parent, message.file) + + if (message.type === 'dir-dependency') { + message.dir = path.resolve(message.dir) + graph.addNode(message.dir) + graph.addDependency(message.parent, message.dir) + } else { + message.file = path.resolve(message.file) + graph.addNode(message.file) + graph.addDependency(message.parent, message.file) + } + return message }, dependantsOf(node) { diff --git a/test/watch.js b/test/watch.js index a2377a8..5d2fdfe 100644 --- a/test/watch.js +++ b/test/watch.js @@ -299,3 +299,198 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { }) cp.stdin.end() }) + +testCb('--watch watches dependencies', (t) => { + let cp + + t.plan(2) + + ENV('', ['s.css', 'a.css', 'b.css']).then((dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + const file = '${path.resolve(dir, 'a.css')}' + result.messages.push({ + plugin: 'test', + type: 'dependency', + file, + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync(file, 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + // Assert, then change the source file + if (p === 'output.css') { + isEqual(p, 'test/fixtures/a.css') + .then(() => read('test/fixtures/b.css')) + .then((css) => fs.writeFile(path.join(dir, 'a.css'), css)) + .catch(done) + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + isEqual(p, 'test/fixtures/b.css') + .then(() => done()) + .catch(done) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + // Using exec() and quoting "*.css" to test watch's glob handling: + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + // Helper functions: + function isEqual(p, expected) { + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + }) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) +}) + +testCb('--watch watches directory dependencies', (t) => { + let cp + + t.plan(2) + + ENV('', ['s.css', 'base/level-1/b.css', 'base/level-1/level-2/a.css']).then( + (dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + result.messages.push({ + plugin: 'test', + type: 'dir-dependency', + dir: '${path.resolve(dir, 'base')}', + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync('${path.resolve( + dir, + 'base/level-1/level-2/a.css' + )}', 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + // Assert, then change the source file + if (p === 'output.css') { + isEqual(p, 'test/fixtures/base/level-1/level-2/a.css') + .then(() => read('test/fixtures/base/level-1/b.css')) + .then((css) => + fs.writeFile( + path.join(dir, 'base/level-1/level-2/a.css'), + css + ) + ) + .catch(done) + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + isEqual(p, 'test/fixtures/base/level-1/b.css') + .then(() => done()) + .catch(done) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + // Using exec() and quoting "*.css" to test watch's glob handling: + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + // Helper functions: + function isEqual(p, expected) { + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + } + ) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) +}) From 9a4ad25f3380a7b6e0e84ed6a95ae499ecefa4c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:04:19 -0400 Subject: [PATCH 25/97] Update dependency postcss-import to v14 (#364) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bdc92ba..dcc83ab 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", "postcss": "^8.0.4", - "postcss-import": "^12.0.0", + "postcss-import": "^14.0.0", "prettier": "~2.3.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" From 4be419d4dab07b8982b4bdc04456c02880dbf667 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:05:05 -0400 Subject: [PATCH 26/97] Update dependency dependency-graph to ^0.11.0 (#368) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcc83ab..c566987 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chokidar": "^3.3.0", "colorette": "^1.2.1", - "dependency-graph": "^0.9.0", + "dependency-graph": "^0.11.0", "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", From 71f7d29c9eb384c4cb7f3dc17d26462b39e74a66 Mon Sep 17 00:00:00 2001 From: Christoph Geschwind Date: Thu, 23 Sep 2021 15:48:06 +0200 Subject: [PATCH 27/97] Add support for glob matching when watching dir-dependency (#391) This extends #383 to pass glob information on to chokidar, with the intention of reducing outputs when unrelated files are modified --- index.js | 6 +- .../base/level-1/level-2/unrelated.md | 1 + test/watch.js | 117 ++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/base/level-1/level-2/unrelated.md diff --git a/index.js b/index.js index 945611a..21704bb 100644 --- a/index.js +++ b/index.js @@ -281,7 +281,11 @@ function dependencies(results) { .map(depGraph.add) .forEach((dependency) => { if (dependency.type === 'dir-dependency') { - messages.push(dependency.dir) + messages.push( + dependency.glob + ? path.join(dependency.dir, dependency.glob) + : dependency.dir + ) } else { messages.push(dependency.file) } diff --git a/test/fixtures/base/level-1/level-2/unrelated.md b/test/fixtures/base/level-1/level-2/unrelated.md new file mode 100644 index 0000000..e48c0e0 --- /dev/null +++ b/test/fixtures/base/level-1/level-2/unrelated.md @@ -0,0 +1 @@ +Editing this file should not trigger a rebuild. diff --git a/test/watch.js b/test/watch.js index 5d2fdfe..decff9d 100644 --- a/test/watch.js +++ b/test/watch.js @@ -494,3 +494,120 @@ testCb('--watch watches directory dependencies', (t) => { // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) + +testCb( + '--watch applies glob on dir-dependency (and excludes non matching files)', + (t) => { + let cp + let modifying = null // one of "unrelated.md", "a.css" + + t.plan(1) + + ENV('', [ + 's.css', + 'base/level-1/b.css', + 'base/level-1/level-2/a.css', + 'base/level-1/level-2/unrelated.md', + ]).then((dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + result.messages.push({ + plugin: 'test', + type: 'dir-dependency', + dir: '${path.resolve(dir, 'base')}', + glob: '**/*.css', + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync('${path.resolve( + dir, + 'base/level-1/level-2/a.css' + )}', 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + if (p === 'output.css') { + // Modify unwatched file, shouldn't trigger output + modifyUnwatched() + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + // Assert that change to output.css happened only after modifying the watched a.css + t.is( + modifying, + 'a.css', + `Unexpected change to ${p} after modifying ${modifying}` + ) + done() + } else if (p === 'base/level-1/level-2/unrelated.md') { + // Modify watched file next, should trigger output + setTimeout(modifyWatched, 250) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + function modifyUnwatched() { + modifying = 'unrelated.md' + fs.writeFile( + path.join(dir, 'base/level-1/level-2/unrelated.md'), + 'Some modification' + ).catch(done) + } + + function modifyWatched() { + modifying = 'a.css' + fs.writeFile( + path.join(dir, 'base/level-1/level-2/a.css'), + 'a { color: hotpink }' + ).catch(done) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + }) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) + } +) From 19d1711c43f775036353e654ddc7916b156a8e4c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 23 Sep 2021 10:32:12 -0400 Subject: [PATCH 28/97] BREAKING: Officially remove config watching support Was already broken due to dependency upgrade, make it official --- test/watch.js | 80 --------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/test/watch.js b/test/watch.js index decff9d..3bc8368 100644 --- a/test/watch.js +++ b/test/watch.js @@ -83,86 +83,6 @@ testCb('--watch works', (t) => { setTimeout(() => t.end('test timeout'), 50000) }) -testCb('--watch postcss.config.js', (t) => { - let cp - - t.plan(2) - - ENV('module.exports = {}', ['import.css', 'a.css']) - .then((dir) => { - // Init watcher: - const watcher = chokidar.watch('.', { - cwd: dir, - ignoreInitial: true, - awaitWriteFinish: true, - }) - - // On the first output: - watcher.on('add', (p) => { - // Assert, then change the source file - if (p === 'output.css') { - read(path.join(dir, p)) - .then((css) => { - t.is(css, '@import "./a.css";\n') - - return fs.writeFile( - path.join(dir, 'postcss.config.js'), - `module.exports = { - plugins: [ - require('postcss-import')() - ] - }` - ) - }) - .catch(done) - } - }) - - // When the change is picked up: - watcher.on('change', (p) => { - if (p === 'output.css') { - isEqual(p, 'test/fixtures/a.css') - .then(() => done()) - .catch(done) - } - }) - - // Start postcss-cli: - watcher.on('ready', () => { - cp = exec( - `node ${path.resolve( - 'bin/postcss' - )} import.css -o output.css -w --no-map`, - { cwd: dir } - ) - - cp.on('error', t.end) - cp.on('exit', (code) => { - if (code) t.end(code) - }) - }) - - // Helper functions: - function isEqual(p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) - ) - } - - function done(err) { - try { - cp.kill() - } catch {} - - t.end(err) - } - }) - .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) -}) - testCb('--watch dependencies', (t) => { let cp From 5c1939db2d625058cf190585caa41e88a692885d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 23 Sep 2021 10:54:20 -0400 Subject: [PATCH 29/97] Add GitHub Actions CI (#394) * Add GitHub Actions CI; remove broken TravisCI * Remove old Greenkeeper badge --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ .travis.yml | 14 -------------- README.md | 5 ++--- 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..92c23af --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Node.js CI +on: + push: + branches: master + pull_request: + +jobs: + test: + strategy: + matrix: + node: [10.x, 12.x, 14.x, 16.x] + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - run: git config --global core.autocrlf input + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run ci + - run: nyc report --reporter=text-lcov | coveralls + continue-on-error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 410129e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: node_js -git: - autocrlf: input -os: - - linux - - windows -node_js: - - node - - 12 - - 10 -script: - - npm run ci -after_success: - - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' diff --git a/README.md b/README.md index 3f267bc..9dc9a2d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ [![npm][npm]][npm-url] [![node][node]][node-url] -[![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-cli.svg)](https://greenkeeper.io/) [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![chat][chat]][chat-url] @@ -142,8 +141,8 @@ module.exports = (ctx) => ({ [npm-url]: https://npmjs.com/package/postcss-cli [node]: https://img.shields.io/node/v/postcss-cli.svg [node-url]: https://nodejs.org/ -[tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg -[tests-url]: https://travis-ci.org/postcss/postcss-cli +[tests]: https://img.shields.io/github/workflow/status/postcss/postcss-cli/Node.js%20CI/master +[tests-url]: https://github.com/postcss/postcss-cli/actions?query=branch%3Amaster [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg [cover-url]: https://coveralls.io/github/postcss/postcss-cli [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg From afc06494943b856f063b92754784fc87ae216e60 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 23 Sep 2021 19:39:32 -0400 Subject: [PATCH 30/97] BREAKING: Drop Node 10 support --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92c23af..5538d98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [10.x, 12.x, 14.x, 16.x] + node: [12.x, 14.x, 16.x] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index c566987..ad1166d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "main": "index.js", "engines": { - "node": ">=10" + "node": ">=12" }, "bin": { "postcss": "./bin/postcss" From faf0f417e6a4de7a5c2a054dbe7bb7878a049c47 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:43:07 -0400 Subject: [PATCH 31/97] Update dependency prettier to ~2.4.0 (#397) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad1166d..46f3459 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.3.0", + "prettier": "~2.4.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From 9903e9e840b3e3822e6e1ec6c2bd3041b061bebd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:46:20 -0400 Subject: [PATCH 32/97] Update actions/setup-node action to v2 (#398) * Update actions/setup-node action to v2 * Edit Node version format Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5538d98..e0cb97d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,14 +8,14 @@ jobs: test: strategy: matrix: - node: [12.x, 14.x, 16.x] + node: [12, 14, 16] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - run: npm install From 261aca2b29150c495bd152534cb58bacaf8ee399 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:47:37 -0400 Subject: [PATCH 33/97] Update dependency fs-extra to v10 (#381) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46f3459..e10eaa6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "chokidar": "^3.3.0", "colorette": "^1.2.1", "dependency-graph": "^0.11.0", - "fs-extra": "^9.0.0", + "fs-extra": "^10.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", "postcss-load-config": "^3.0.0", From 793dca664f6d9d1b0fb5f03c7060281e611b1cd0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 20:08:30 -0400 Subject: [PATCH 34/97] Update dependency yargs to v17 (#382) * Update dependency yargs to v17 * Fix coercion * Add tests for coersion Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- lib/args.js | 12 ++++++------ package.json | 2 +- test/ext.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/args.js b/lib/args.js index b2cd258..e25dd0d 100644 --- a/lib/args.js +++ b/lib/args.js @@ -13,7 +13,7 @@ const logo = ` //_____||___*_________*___||_____// ` -module.exports = require('yargs') +const { argv } = require('yargs') .usage( `${bold(red(logo))} Usage: @@ -88,10 +88,6 @@ Usage: desc: 'Override the output file extension; for use with --dir', type: 'string', implies: 'dir', - coerce(ext) { - if (ext.indexOf('.') !== 0) return `.${ext}` - return ext - }, }) .option('base', { desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir', @@ -126,4 +122,8 @@ If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. For more details, please see https://github.com/postcss/postcss-cli` - ).argv + ) + +if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` + +module.exports = argv diff --git a/package.json b/package.json index e10eaa6..292af0d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "slash": "^3.0.0", - "yargs": "^16.0.0" + "yargs": "^17.0.0" }, "devDependencies": { "ava": "^3.1.0", diff --git a/test/ext.js b/test/ext.js index 7016782..c646630 100644 --- a/test/ext.js +++ b/test/ext.js @@ -23,3 +23,20 @@ test('--ext works', async (t) => { t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) }) + +test('--ext works with no leading dot', async (t) => { + const dir = tmp() + + const { error, stderr } = await cli([ + 'test/fixtures/a.sss', + '--parser', + 'sugarss', + '-d', + dir, + '--ext', + 'css', + ]) + t.falsy(error, stderr) + + t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) +}) From cd5d5df47fd988cbde7dfa7ad8063e3b111b2910 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 20:09:27 -0400 Subject: [PATCH 35/97] Update dependency colorette to v2 (#400) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 292af0d..a235e25 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chokidar": "^3.3.0", - "colorette": "^1.2.1", + "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^8.0.0", From 10f2603c8ffd24b19c62037e8f27ab97e46afcd2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Fri, 24 Sep 2021 08:27:47 -0400 Subject: [PATCH 36/97] Port to ESM (#401) * Port to ESM * Port tests to ESM * Remove broken coveralls * Remove old nyc cleanup --- .eslintrc.yaml | 2 + .github/workflows/ci.yml | 2 - bin/postcss | 3 -- index.js | 90 ++++++++++++++++++++---------------- lib/DependencyGraph.js | 7 ++- lib/DependencyGraph.test.js | 7 ++- lib/args.js | 8 ++-- lib/getMapfile.js | 5 +- lib/getMapfile.test.js | 27 +++++++++++ package.json | 10 ++-- test/base.js | 11 ++--- test/cli.js | 9 ++-- test/config.js | 11 ++--- test/dir.js | 11 ++--- test/error.js | 13 +++--- test/ext.js | 11 ++--- test/fixtures/_bad-plugin.js | 1 - test/glob.js | 11 ++--- test/helpers/clean.js | 4 +- test/helpers/cli.js | 9 ++-- test/helpers/env.js | 13 +++--- test/helpers/read.js | 7 ++- test/helpers/tmp.js | 7 ++- test/map.js | 38 ++------------- test/misc.js | 5 +- test/parser.js | 9 ++-- test/replace.js | 13 +++--- test/stdin.js | 15 +++--- test/stdout.js | 13 +++--- test/stringifier.js | 9 ++-- test/syntax.js | 9 ++-- test/use.js | 9 ++-- test/watch.js | 44 ++++++++---------- 33 files changed, 210 insertions(+), 233 deletions(-) delete mode 100755 bin/postcss mode change 100644 => 100755 index.js create mode 100644 lib/getMapfile.test.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0473b0f..d838ba7 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,5 +1,7 @@ env: node: true +parserOptions: + sourceType: module extends: problems rules: no-console: off diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0cb97d..04cd7e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,5 +20,3 @@ jobs: node-version: ${{ matrix.node }} - run: npm install - run: npm run ci - - run: nyc report --reporter=text-lcov | coveralls - continue-on-error: true diff --git a/bin/postcss b/bin/postcss deleted file mode 100755 index d40abef..0000000 --- a/bin/postcss +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env node - -require('../') diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 21704bb..da83943 --- a/index.js +++ b/index.js @@ -1,23 +1,25 @@ -'use strict' - -const fs = require('fs-extra') -const path = require('path') - -const prettyHrtime = require('pretty-hrtime') -const stdin = require('get-stdin') -const read = require('read-cache') -const { bold, dim, red, cyan, green } = require('colorette') -const globber = require('globby') -const slash = require('slash') -const chokidar = require('chokidar') - -const postcss = require('postcss') -const postcssrc = require('postcss-load-config') -const reporter = require('postcss-reporter/lib/formatter')() - -const argv = require('./lib/args') -const createDependencyGraph = require('./lib/DependencyGraph') -const getMapfile = require('./lib/getMapfile') +#!/usr/bin/env node + +import fs from 'fs-extra' +import path from 'path' + +import prettyHrtime from 'pretty-hrtime' +import stdin from 'get-stdin' +import read from 'read-cache' +import { bold, dim, red, cyan, green } from 'colorette' +import globber from 'globby' +import slash from 'slash' +import chokidar from 'chokidar' + +import postcss from 'postcss' +import postcssrc from 'postcss-load-config' +import postcssReporter from 'postcss-reporter/lib/formatter.js' + +import argv from './lib/args.js' +import createDependencyGraph from './lib/DependencyGraph.js' +import getMapfile from './lib/getMapfile.js' + +const reporter = postcssReporter() const depGraph = createDependencyGraph() let input = argv._ @@ -25,25 +27,33 @@ const { dir, output } = argv if (argv.map) argv.map = { inline: false } -const cliConfig = { - options: { - map: argv.map !== undefined ? argv.map : { inline: true }, - parser: argv.parser ? require(argv.parser) : undefined, - syntax: argv.syntax ? require(argv.syntax) : undefined, - stringifier: argv.stringifier ? require(argv.stringifier) : undefined, - }, - plugins: argv.use - ? argv.use.map((plugin) => { - try { - return require(plugin)() - } catch (e) { - const msg = e.message || `Cannot find module '${plugin}'` - let prefix = msg.includes(plugin) ? '' : ` (${plugin})` - if (e.name && e.name !== 'Error') prefix += `: ${e.name}` - return error(`Plugin Error${prefix}: ${msg}'`) - } - }) - : [], +let cliConfig + +async function buildCliConfig() { + cliConfig = { + options: { + map: argv.map !== undefined ? argv.map : { inline: true }, + parser: argv.parser ? await import(argv.parser) : undefined, + syntax: argv.syntax ? await import(argv.syntax) : undefined, + stringifier: argv.stringifier + ? await import(argv.stringifier) + : undefined, + }, + plugins: argv.use + ? await Promise.all( + argv.use.map(async (plugin) => { + try { + return (await import(plugin)).default() + } catch (e) { + const msg = e.message || `Cannot find module '${plugin}'` + let prefix = msg.includes(plugin) ? '' : ` (${plugin})` + if (e.name && e.name !== 'Error') prefix += `: ${e.name}` + return error(`Plugin Error${prefix}: ${msg}'`) + } + }) + ) + : [], + } } let configFile @@ -61,7 +71,7 @@ if (parseInt(postcss().version) < 8) { error('Please install PostCSS 8 or above') } -Promise.resolve() +buildCliConfig() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { error('Cannot write to stdout in watch mode') diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js index c293cda..efb7ac3 100644 --- a/lib/DependencyGraph.js +++ b/lib/DependencyGraph.js @@ -1,8 +1,7 @@ -'use strict' -const path = require('path') -const { DepGraph } = require('dependency-graph') +import path from 'path' +import { DepGraph } from 'dependency-graph' -module.exports = function () { +export default function createDependencyGraph() { const graph = new DepGraph() return { add(message) { diff --git a/lib/DependencyGraph.test.js b/lib/DependencyGraph.test.js index a0235ba..d54393c 100644 --- a/lib/DependencyGraph.test.js +++ b/lib/DependencyGraph.test.js @@ -1,7 +1,6 @@ -'use strict' -const test = require('ava') -const path = require('path') -const createDependencyGraph = require('./DependencyGraph.js') +import test from 'ava' +import path from 'path' +import createDependencyGraph from './DependencyGraph.js' function resolveArray(arr) { return arr.map((p) => path.resolve(p)) diff --git a/lib/args.js b/lib/args.js index e25dd0d..fb38937 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,5 +1,5 @@ -'use strict' -const { bold, red } = require('colorette') +import yargs from 'yargs' +import { bold, red } from 'colorette' const logo = ` /|\\ @@ -13,7 +13,7 @@ const logo = ` //_____||___*_________*___||_____// ` -const { argv } = require('yargs') +const { argv } = yargs(process.argv.slice(2)) .usage( `${bold(red(logo))} Usage: @@ -126,4 +126,4 @@ For more details, please see https://github.com/postcss/postcss-cli` if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` -module.exports = argv +export default argv diff --git a/lib/getMapfile.js b/lib/getMapfile.js index 346fea7..e4d0c93 100644 --- a/lib/getMapfile.js +++ b/lib/getMapfile.js @@ -1,6 +1,5 @@ -'use strict' -const path = require('path') -module.exports = function getMapfile(options) { +import path from 'path' +export default function getMapfile(options) { if (options.map && typeof options.map.annotation === 'string') { return `${path.dirname(options.to)}/${options.map.annotation}` } diff --git a/lib/getMapfile.test.js b/lib/getMapfile.test.js new file mode 100644 index 0000000..becc460 --- /dev/null +++ b/lib/getMapfile.test.js @@ -0,0 +1,27 @@ +import test from 'ava' +import getMapfile from './getMapfile.js' + +test('mapFile path is properly resolved', async (t) => { + const paths = [ + { + input: { to: '/foo/bar.css/baz/index.css' }, + want: '/foo/bar.css/baz/index.css.map', + }, + { + input: { to: '/foo/bar.sss/baz/index.sss' }, + want: '/foo/bar.sss/baz/index.sss.map', + }, + { + input: { to: '/foo/bar.css/baz/bar.css' }, + want: '/foo/bar.css/baz/bar.css.map', + }, + { + input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, + want: '/foo/bar.css/baz/foo.map', + }, + ] + + for (const p of paths) { + t.is(getMapfile(p.input), p.want) + } +}) diff --git a/package.json b/package.json index a235e25..d06f1f3 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,20 @@ "name": "postcss-cli", "version": "8.3.1", "description": "CLI for PostCSS", - "main": "index.js", + "type": "module", "engines": { "node": ">=12" }, "bin": { - "postcss": "./bin/postcss" + "postcss": "./index.js" }, "scripts": { - "ci": "eslint . && nyc ava -v && npm run prettier -- --list-different", + "ci": "eslint . && c8 ava -v && npm run prettier -- --list-different", "clean": "node test/helpers/clean.js", "prettier": "prettier --single-quote --no-semi \"**/*.{js,md}\"", "format": "npm run prettier -- --write && eslint . --fix", "pretest": "npm run clean && npm run format", - "test": "nyc ava -v" + "test": "c8 ava -v" }, "dependencies": { "chokidar": "^3.3.0", @@ -33,10 +33,10 @@ }, "devDependencies": { "ava": "^3.1.0", + "c8": "^7.9.0", "coveralls": "^3.0.0", "eslint": "^7.8.0", "eslint-config-problems": "5.0.0", - "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", "prettier": "~2.4.0", diff --git a/test/base.js b/test/base.js index 32eff27..496ca14 100644 --- a/test/base.js +++ b/test/base.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--base --dir works', async (t) => { const dir = tmp() diff --git a/test/cli.js b/test/cli.js index 0cdc7dc..3adab9b 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('works with defaults', async (t) => { const output = tmp('output.css') diff --git a/test/config.js b/test/config.js index b8b3de5..a4eb8c6 100644 --- a/test/config.js +++ b/test/config.js @@ -1,11 +1,10 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const ENV = require('./helpers/env.js') +import ENV from './helpers/env.js' -const cli = require('./helpers/cli.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import read from './helpers/read.js' test('supports common config', async (t) => { const env = `module.exports = { diff --git a/test/dir.js b/test/dir.js index ec4e60e..695f198 100644 --- a/test/dir.js +++ b/test/dir.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--dir works', async (t) => { const dir = tmp() diff --git a/test/error.js b/test/error.js index 38b972b..9901f47 100644 --- a/test/error.js +++ b/test/error.js @@ -1,8 +1,7 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const tmp = require('./helpers/tmp.js') -const cli = require('./helpers/cli.js') +import tmp from './helpers/tmp.js' +import cli from './helpers/cli.js' test('multiple input files && --output', (t) => { return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => { @@ -34,7 +33,7 @@ test('plugin not found', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Plugin Error: Cannot find module 'postcss-plugin'/ + /Plugin Error: Cannot find package 'postcss-plugin'/ ) } ) @@ -44,12 +43,12 @@ test('plugin throws on require', (t) => { return cli([ 'test/fixtures/a.css', '-u', - './test/fixtures/_bad-plugin', + './test/fixtures/_bad-plugin.js', '-o', tmp(), ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(error.toString(), /Plugin Error \(.*bad-plugin\): This fails/) + t.regex(error.toString(), /Plugin Error \(.*bad-plugin.js\): This fails/) }) }) diff --git a/test/ext.js b/test/ext.js index c646630..329f2c4 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,11 +1,10 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') +import fs from 'fs-extra' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' test('--ext works', async (t) => { const dir = tmp() diff --git a/test/fixtures/_bad-plugin.js b/test/fixtures/_bad-plugin.js index 7a4ffeb..2911e95 100644 --- a/test/fixtures/_bad-plugin.js +++ b/test/fixtures/_bad-plugin.js @@ -1,2 +1 @@ -'use strict' throw new Error('This fails') diff --git a/test/glob.js b/test/glob.js index e60b75a..33917ad 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('works with glob patterns', async (t) => { const output = tmp() diff --git a/test/helpers/clean.js b/test/helpers/clean.js index cabfc72..73bb191 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,10 +1,8 @@ -'use strict' -const fs = require('fs-extra') +import fs from 'fs-extra' Promise.all([ fs.emptyDir('./test/fixtures/.tmp/'), fs.remove('./coverage'), - fs.remove('./.nyc_output'), ]).catch((err) => { console.error(err) process.exit(1) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 64b9154..565d3ff 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,11 +1,10 @@ -'use strict' -const path = require('path') -const { exec } = require('child_process') +import path from 'path' +import { exec } from 'child_process' -module.exports = function (args, cwd) { +export default function (args, cwd) { return new Promise((resolve) => { exec( - `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, + `node ${path.resolve('index.js')} ${args.join(' ')}`, { cwd }, (error, stdout, stderr) => { resolve({ diff --git a/test/helpers/env.js b/test/helpers/env.js index b389370..e6f48c2 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,11 +1,10 @@ -'use strict' -const fs = require('fs-extra') -const path = require('path') -const globby = require('globby') +import fs from 'fs-extra' +import path from 'path' +import globby from 'globby' -const tmp = require('./tmp.js') +import tmp from './tmp.js' -module.exports = function (config, fixtures) { +export default function (config, fixtures) { fixtures = fixtures || '**/*' const dir = tmp() @@ -15,6 +14,6 @@ module.exports = function (config, fixtures) { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) }), - fs.outputFile(path.join(dir, 'postcss.config.js'), config), + fs.outputFile(path.join(dir, 'postcss.config.cjs'), config), ]).then(() => dir) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 88b6421..1dbe451 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,8 +1,7 @@ -'use strict' -const { readFile } = require('fs-extra') +import fs from 'fs-extra' -module.exports = function (path) { - return readFile(path, 'utf8').then( +export default function (path) { + return fs.readFile(path, 'utf8').then( (content) => content.replace(/\r\n/g, '\n') // normalize line endings on Windows ) } diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index a23fa35..bfa1369 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,8 +1,7 @@ -'use strict' -const path = require('path') -const { v4: uuid } = require('uuid') +import path from 'path' +import { v4 as uuid } from 'uuid' -module.exports = function (ext) { +export default function (ext) { ext = ext || '' return path.join('test/fixtures/.tmp', uuid(), ext) diff --git a/test/map.js b/test/map.js index 04f90fd..4783010 100644 --- a/test/map.js +++ b/test/map.js @@ -1,12 +1,9 @@ -'use strict' -const test = require('ava') -const fs = require('fs-extra') +import test from 'ava' +import fs from 'fs-extra' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') - -const getMapfile = require('../lib/getMapfile') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('inline maps are generated by default', async (t) => { const output = tmp('output.css') @@ -56,28 +53,3 @@ test('--no-map disables internal sourcemaps', async (t) => { t.notRegex(await read(output), /\/*# sourceMappingURL=/) }) - -test('mapFile path is property resolved', async (t) => { - const paths = [ - { - input: { to: '/foo/bar.css/baz/index.css' }, - want: '/foo/bar.css/baz/index.css.map', - }, - { - input: { to: '/foo/bar.sss/baz/index.sss' }, - want: '/foo/bar.sss/baz/index.sss.map', - }, - { - input: { to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/bar.css.map', - }, - { - input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/foo.map', - }, - ] - - for (const p of paths) { - t.is(getMapfile(p.input), p.want) - } -}) diff --git a/test/misc.js b/test/misc.js index 9240e32..812b6d0 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,7 +1,6 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') +import cli from './helpers/cli.js' test('--help', async (t) => { const help = await cli(['--help']) diff --git a/test/parser.js b/test/parser.js index 1ac9805..689d9b7 100644 --- a/test/parser.js +++ b/test/parser.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--parser works', async (t) => { const output = tmp('output.css') diff --git a/test/replace.js b/test/replace.js index f2712a2..dd24b98 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,12 +1,11 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') +import fs from 'fs-extra' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--replace works', async (t) => { const dir = tmp() diff --git a/test/stdin.js b/test/stdin.js index 8709a94..9fb0679 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,18 +1,17 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec } = require('child_process') +import fs from 'fs-extra' +import path from 'path' +import { exec } from 'child_process' -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test.cb('reads from stdin', (t) => { const output = tmp('output.css') const cp = exec( - `node ${path.resolve('bin/postcss')} -o ${output} --no-map`, + `node ${path.resolve('index.js')} -o ${output} --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stdout.js b/test/stdout.js index 8bd5d7b..68b6b4b 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,16 +1,15 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec } = require('child_process') +import fs from 'fs-extra' +import path from 'path' +import { exec } from 'child_process' -const read = require('./helpers/read.js') +import read from './helpers/read.js' test.cb('writes to stdout', (t) => { const cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} --parser sugarss -u postcss-import --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stringifier.js b/test/stringifier.js index db3ef28..69adaff 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--stringifier works', async (t) => { const output = tmp('output.sss') diff --git a/test/syntax.js b/test/syntax.js index c4295f9..b17e1fd 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--syntax works', async (t) => { const output = tmp('output.sss') diff --git a/test/use.js b/test/use.js index 25400f6..c35d6cd 100644 --- a/test/use.js +++ b/test/use.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--use works', async (t) => { const output = tmp('i.css') diff --git a/test/watch.js b/test/watch.js index 3bc8368..b38b81d 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,14 +1,13 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec, spawn } = require('child_process') -const chokidar = require('chokidar') +import fs from 'fs-extra' +import path from 'path' +import { exec, spawn } from 'child_process' +import chokidar from 'chokidar' -const ENV = require('./helpers/env.js') -const read = require('./helpers/read.js') -const tmp = require('./helpers/tmp.js') +import ENV from './helpers/env.js' +import read from './helpers/read.js' +import tmp from './helpers/tmp.js' // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb @@ -51,9 +50,7 @@ testCb('--watch works', (t) => { watcher.on('ready', () => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( - `node ${path.resolve( - 'bin/postcss' - )} "*.css" -o output.css --no-map -w`, + `node ${path.resolve('index.js')} "*.css" -o output.css --no-map -w`, { cwd: dir } ) cp.on('error', t.end) @@ -121,7 +118,7 @@ testCb('--watch dependencies', (t) => { watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} import.css -o output.css -u postcss-import -w --no-map`, { cwd: dir } ) @@ -172,7 +169,7 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { let killed = false const cp = exec( - `node ${path.resolve('bin/postcss')} a.css -o output.css -w --no-map`, + `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, { cwd: dir } ) cp.on('error', t.end) @@ -207,10 +204,9 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.plan(1) - const cp = spawn( - `./bin/postcss test/fixtures/a.css -o ${tmp()} -w --no-map`, - { shell: true } - ) + const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, { + shell: true, + }) cp.on('error', t.end) cp.on('exit', (code) => { @@ -227,7 +223,7 @@ testCb('--watch watches dependencies', (t) => { ENV('', ['s.css', 'a.css', 'b.css']).then((dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -281,7 +277,7 @@ testCb('--watch watches dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) @@ -321,7 +317,7 @@ testCb('--watch watches directory dependencies', (t) => { ENV('', ['s.css', 'base/level-1/b.css', 'base/level-1/level-2/a.css']).then( (dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -382,7 +378,7 @@ testCb('--watch watches directory dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) @@ -430,7 +426,7 @@ testCb( 'base/level-1/level-2/unrelated.md', ]).then((dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -490,7 +486,7 @@ testCb( watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) From a864c5bd3c530c35a801b4e178fe0c1aef202dfa Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 24 Sep 2021 09:26:28 -0400 Subject: [PATCH 37/97] Remove broken logo printing --- lib/args.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/args.js b/lib/args.js index fb38937..35f0e83 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,22 +1,8 @@ import yargs from 'yargs' -import { bold, red } from 'colorette' - -const logo = ` - /|\\ - // // - // // - //___*___*___// - //--*---------*--// - /|| * * ||/ - // ||* *|| // - // || * * || // - //_____||___*_________*___||_____// -` const { argv } = yargs(process.argv.slice(2)) .usage( - `${bold(red(logo))} -Usage: + `Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] From c9258b19610b8bce441487d01f20bb280d35c93f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:27:42 -0400 Subject: [PATCH 38/97] Update dependency get-stdin to v9 (#376) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d06f1f3..27a1859 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", - "get-stdin": "^8.0.0", + "get-stdin": "^9.0.0", "globby": "^11.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", From 9d770031cebe41921e252a5b5ad9d1d490b833b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:28:31 -0400 Subject: [PATCH 39/97] Update dependency slash to v4 (#377) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27a1859..1b98b11 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "slash": "^3.0.0", + "slash": "^4.0.0", "yargs": "^17.0.0" }, "devDependencies": { From ace2a31e173688f096c8c3ba0383e7493f22d913 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:32:56 -0400 Subject: [PATCH 40/97] Update dependency globby to v12 (#386) * Update dependency globby to v12 * Use named imports Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- index.js | 4 ++-- package.json | 2 +- test/helpers/env.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index da83943..5e3528e 100755 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' import { bold, dim, red, cyan, green } from 'colorette' -import globber from 'globby' +import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' @@ -78,7 +78,7 @@ buildCliConfig() } if (input && input.length) { - return globber( + return globby( input.map((i) => slash(String(i))), { dot: argv.includeDotfiles } ) diff --git a/package.json b/package.json index 1b98b11..c679738 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", - "globby": "^11.0.0", + "globby": "^12.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", diff --git a/test/helpers/env.js b/test/helpers/env.js index e6f48c2..7ec542e 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,6 +1,6 @@ import fs from 'fs-extra' import path from 'path' -import globby from 'globby' +import { globby } from 'globby' import tmp from './tmp.js' From 201205ce210f2d05ab6caf094e574b3319ec38cf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Fri, 24 Sep 2021 10:01:02 -0400 Subject: [PATCH 41/97] Run watch tests on Linux CI (#396) --- test/watch.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/watch.js b/test/watch.js index b38b81d..8d47ec7 100644 --- a/test/watch.js +++ b/test/watch.js @@ -9,8 +9,9 @@ import ENV from './helpers/env.js' import read from './helpers/read.js' import tmp from './helpers/tmp.js' -// XXX: All the tests in this file are skipped on the CI; too flacky there -const testCb = process.env.CI ? test.cb.skip : test.cb +// XXX: All the tests in this file are skipped on the Windows CI; too flacky there +const testCb = + process.env.CI && process.platform === 'win32' ? test.cb.skip : test.cb testCb('--watch works', (t) => { let cp From b90bd7f2e3ec08db50157d11fe83e24f068b9abf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 24 Sep 2021 12:38:50 -0400 Subject: [PATCH 42/97] 9.0.0 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 186942c..922fa07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 9.0.0 / 2021-09-24 + +- **BREAKING:** Require Node.js v12+ +- **BREAKING:** Must specify full file path, including `.js` extension, when loading local plugins with `--use` ([#401](https://github.com/postcss/postcss-cli/pull/401)) +- **BREAKING:** Officially remove support for watching postcss config (was already broken in previous releases) +- Add support for `dir-dependency` messages ([#383](https://github.com/postcss/postcss-cli/pull/383), [#391](https://github.com/postcss/postcss-cli/pull/391)) +- Update deps + # 8.3.1 / 2020-12-12 - Ensure paths are not interpreted as numbers ([#360](https://github.com/postcss/postcss-cli/issues/360)) diff --git a/package.json b/package.json index c679738..8b424f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.3.1", + "version": "9.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 96a7dc67f1ea8f26f1be0261e273dc1c8b925728 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:26:22 -0400 Subject: [PATCH 43/97] Remove bin/ from `files` in package.json h/t https://github.com/postcss/postcss-cli/issues/403#issuecomment-928207662 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 8b424f2..7eaaad8 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "postcss": "^8.0.0" }, "files": [ - "bin", "index.js", "lib", "!*.test.js" From 49db8224ce9eed7b18a76814e912c0cb5469278f Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:35:23 -0400 Subject: [PATCH 44/97] Use nanocolors --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5e3528e..76310dd 100755 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ import path from 'path' import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' -import { bold, dim, red, cyan, green } from 'colorette' +import { bold, dim, red, cyan, green } from 'nanocolors' import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' diff --git a/package.json b/package.json index 7eaaad8..1b011a2 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ }, "dependencies": { "chokidar": "^3.3.0", - "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", "globby": "^12.0.0", + "nanocolors": "^0.2.11", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", From 31436423d83f77965442dcf1c421a5d90a56dfc3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:35:01 -0400 Subject: [PATCH 45/97] Actually exit when writing to stdout in watch mode --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 76310dd..45959ac 100755 --- a/index.js +++ b/index.js @@ -75,6 +75,8 @@ buildCliConfig() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { error('Cannot write to stdout in watch mode') + // Need to explicitly exit here, since error() doesn't exit in watch mode + process.exit(1) } if (input && input.length) { From 392c4f51f6ed11d5fdb857e486005ab29b09b41c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:42:17 -0400 Subject: [PATCH 46/97] 9.0.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 922fa07..6c60b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 9.0.1 / 2021-09-28 + +- Actually exit with error when attempting to stdout in watch mode +- Remove `bin/` from `files` in package.json + # 9.0.0 / 2021-09-24 - **BREAKING:** Require Node.js v12+ diff --git a/package.json b/package.json index 1b011a2..da94c28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.0", + "version": "9.0.1", "description": "CLI for PostCSS", "type": "module", "engines": { From 66b7c80cba7b9b638dc7c1019929bb07dd569670 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:44:25 -0400 Subject: [PATCH 47/97] Exclude test files from npm package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da94c28..b8d8a1f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "files": [ "index.js", "lib", - "!*.test.js" + "!**/*.test.js" ], "keywords": [ "cli", From ecf2bee0c74d4d2ad20b955d173d3f7dd6ad7460 Mon Sep 17 00:00:00 2001 From: Ludovico Fischer <43557+ludofischer@users.noreply.github.com> Date: Thu, 4 Nov 2021 23:54:16 +0100 Subject: [PATCH 48/97] chore: use picocolors for colored terminal output (#409) Replace deprecated nanocolors with picocolors. --- index.js | 12 +++++++----- package.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 45959ac..a5286f7 100755 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ import path from 'path' import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' -import { bold, dim, red, cyan, green } from 'nanocolors' +import pc from 'picocolors' import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' @@ -118,7 +118,7 @@ buildCliConfig() .then((results) => { if (argv.watch) { const printMessage = () => - printVerbose(dim('\nWaiting for file changes...')) + printVerbose(pc.dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, @@ -213,7 +213,7 @@ function css(css, file) { const time = process.hrtime() - printVerbose(cyan(`Processing ${bold(relativePath)}...`)) + printVerbose(pc.cyan(`Processing ${pc.bold(relativePath)}...`)) return rc(ctx, argv.config) .then((config) => { @@ -261,7 +261,9 @@ function css(css, file) { return Promise.all(tasks).then(() => { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( - green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`) + pc.green( + `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}` + ) ) const messages = result.warnings() @@ -316,7 +318,7 @@ function error(err) { if (argv.verbose) console.error() if (typeof err === 'string') { - console.error(red(err)) + console.error(pc.red(err)) } else if (err.name === 'CssSyntaxError') { console.error(err.toString()) } else { diff --git a/package.json b/package.json index b8d8a1f..14e5f8c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", "globby": "^12.0.0", - "nanocolors": "^0.2.11", + "picocolors": "^1.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", From 538b6f52442fba732190fff93ab8d977be3b667a Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 4 Nov 2021 18:58:19 -0400 Subject: [PATCH 49/97] 9.0.2 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c60b58..0c21c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 9.0.2 / 2021-11-04 + +- Switch to picocolors ([#409](https://github.com/postcss/postcss-cli/pull/409)) +- Remove test files from npm package + # 9.0.1 / 2021-09-28 - Actually exit with error when attempting to stdout in watch mode diff --git a/package.json b/package.json index 14e5f8c..d8eef3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.1", + "version": "9.0.2", "description": "CLI for PostCSS", "type": "module", "engines": { From 018496898dc26281fc336738d96dd2c444db1655 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Nov 2021 12:47:03 -0500 Subject: [PATCH 50/97] Update eslint & eslint-config-problems (#413) * Update dependency eslint-config-problems to v6 * Bump eslint version Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8eef3b..70325b5 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "ava": "^3.1.0", "c8": "^7.9.0", "coveralls": "^3.0.0", - "eslint": "^7.8.0", - "eslint-config-problems": "5.0.0", + "eslint": "^8.2.0", + "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", "prettier": "~2.4.0", From 6256aa711fa2c691a47d5b16528d6b88926a09d9 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:09:48 -0500 Subject: [PATCH 51/97] Refactor watch tests (#416) --- test/watch.js | 109 ++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 61 deletions(-) diff --git a/test/watch.js b/test/watch.js index 8d47ec7..af69eb4 100644 --- a/test/watch.js +++ b/test/watch.js @@ -76,9 +76,6 @@ testCb('--watch works', (t) => { } }) .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb('--watch dependencies', (t) => { @@ -145,62 +142,61 @@ testCb('--watch dependencies', (t) => { } }) .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) -testCb("--watch doesn't exit on CssSyntaxError", (t) => { - t.plan(0) +// Doesn't work on CI for some reason +;(process.env.CI ? test.cb.skip : test.cb)( + "--watch doesn't exit on CssSyntaxError", + (t) => { + t.plan(0) - ENV('', ['a.css']) - .then((dir) => { - // Init watcher: - const watcher = chokidar.watch('.', { - cwd: dir, - ignoreInitial: true, - awaitWriteFinish: true, - }) - watcher.on('add', (p) => { - if (p === 'output.css') { - // Change to invalid CSS - fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) - } - }) + ENV('', ['a.css']) + .then((dir) => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + watcher.on('add', (p) => { + if (p === 'output.css') { + // Change to invalid CSS + fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) + } + }) - let killed = false - const cp = exec( - `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, - { cwd: dir } - ) - cp.on('error', t.end) - cp.stderr.on('data', (chunk) => { - // When error message is printed, kill the process after a timeout - if (~chunk.indexOf('Unclosed block')) { - setTimeout(() => { - killed = true + let killed = false + const cp = exec( + `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.stderr.on('data', (chunk) => { + // When error message is printed, kill the process after a timeout + if (~chunk.indexOf('Unclosed block')) { + setTimeout(() => { + killed = true + cp.kill() + }, 1000) + } + }) + cp.on('exit', (code) => { + if (!killed) + return t.end(`Should not exit (exited with code ${code})`) + done() + }) + + function done(err) { + try { cp.kill() - }, 1000) + } catch {} + + t.end(err) } }) - cp.on('exit', (code) => { - if (!killed) return t.end(`Should not exit (exited with code ${code})`) - done() - }) - - function done(err) { - try { - cp.kill() - } catch {} - - t.end(err) - } - }) - .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) -}) + .catch(t.end) + } +) testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.plan(1) @@ -305,9 +301,6 @@ testCb('--watch watches dependencies', (t) => { }) .catch(t.end) }) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb('--watch watches directory dependencies', (t) => { @@ -407,9 +400,6 @@ testCb('--watch watches directory dependencies', (t) => { .catch(t.end) } ) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb( @@ -523,8 +513,5 @@ testCb( }) .catch(t.end) }) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) } ) From c7cc0bb55eb2fd1f3280967cb669f6ac414a068b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:18:28 -0500 Subject: [PATCH 52/97] Update dependency prettier to ~2.5.0 (#414) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70325b5..8e1bb4d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.4.0", + "prettier": "~2.5.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From b06fa800bbcf1875aa89b4fcd8afbde5677e6638 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 10 Dec 2021 13:46:36 -0700 Subject: [PATCH 53/97] feat: only save files if they are unchanged (#417) Closes #320 --- index.js | 11 +++++++++-- test/fixtures/unchanged-input.css | 3 +++ test/fixtures/unchanged-output.css | 5 +++++ test/unchanged.js | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/unchanged-input.css create mode 100644 test/fixtures/unchanged-output.css create mode 100644 test/unchanged.js diff --git a/index.js b/index.js index a5286f7..615638c 100755 --- a/index.js +++ b/index.js @@ -250,11 +250,11 @@ function css(css, file) { const tasks = [] if (options.to) { - tasks.push(fs.outputFile(options.to, result.css)) + tasks.push(outputFile(options.to, result.css)) if (result.map) { const mapfile = getMapfile(options) - tasks.push(fs.outputFile(mapfile, result.map.toString())) + tasks.push(outputFile(mapfile, result.map.toString())) } } else process.stdout.write(result.css, 'utf8') @@ -278,6 +278,13 @@ function css(css, file) { .catch((err) => { throw err }) + + async function outputFile(file, string) { + const fileExists = await fs.pathExists(file) + const currentValue = fileExists ? await fs.readFile(file, 'utf8') : null + if (currentValue === string) return + return fs.outputFile(file, string) + } } function dependencies(results) { diff --git a/test/fixtures/unchanged-input.css b/test/fixtures/unchanged-input.css new file mode 100644 index 0000000..60f1eab --- /dev/null +++ b/test/fixtures/unchanged-input.css @@ -0,0 +1,3 @@ +body { + color: red; +} diff --git a/test/fixtures/unchanged-output.css b/test/fixtures/unchanged-output.css new file mode 100644 index 0000000..6521159 --- /dev/null +++ b/test/fixtures/unchanged-output.css @@ -0,0 +1,5 @@ +body { + color: red; +} + +/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInVuY2hhbmdlZC1pbnB1dC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEiLCJmaWxlIjoidW5jaGFuZ2VkLW91dHB1dC5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJib2R5IHtcbiAgY29sb3I6IHJlZDtcbn1cbiJdfQ== */ \ No newline at end of file diff --git a/test/unchanged.js b/test/unchanged.js new file mode 100644 index 0000000..4598530 --- /dev/null +++ b/test/unchanged.js @@ -0,0 +1,17 @@ +import fs from 'fs-extra' +import test from 'ava' + +import cli from './helpers/cli.js' + +test('files are not saved if the contents are the same', async (t) => { + const input = 'test/fixtures/unchanged-input.css' + const output = 'test/fixtures/unchanged-output.css' + const intialStat = await fs.stat(output) + + const { error, stderr } = await cli([input, '-o', output]) + + t.falsy(error, stderr) + + const finalStat = await fs.stat(output) + t.is(finalStat.mtimeMs, intialStat.mtimeMs) +}) From c9f69057ddefd4595faa14b847d57f148211ce62 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 10 Dec 2021 15:49:39 -0500 Subject: [PATCH 54/97] 9.1.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c21c2a..d63af2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 9.1.0 / 2021-12-10 + +- Don't write to files if they're unchanged ([#320](https://github.com/postcss/postcss-cli/issues/320), [#417](https://github.com/postcss/postcss-cli/pull/417)) + # 9.0.2 / 2021-11-04 - Switch to picocolors ([#409](https://github.com/postcss/postcss-cli/pull/409)) diff --git a/package.json b/package.json index 8e1bb4d..141c899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.2", + "version": "9.1.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 07369934ed260e096d7b3b20ffe9babffdb03db8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 14:24:49 -0500 Subject: [PATCH 55/97] Update dependency globby to v13 (#427) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 141c899..8ebcbcb 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", - "globby": "^12.0.0", + "globby": "^13.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", From 62d9505a2315e60007a80665ee7e54581fd91bf7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Feb 2022 10:34:56 -0500 Subject: [PATCH 56/97] Update actions/setup-node action to v3 (#429) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04cd7e1..41328fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - run: npm install From 006288238ac1cb4941b681045067682c30881fa9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:47:09 -0500 Subject: [PATCH 57/97] Update actions/checkout action to v3 (#430) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41328fb..d814851 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v3 with: From 82548cac9e385a4e3cb817fe6a67924c60710a66 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 16 Mar 2022 10:58:26 -0400 Subject: [PATCH 58/97] Update dependency prettier to ~2.6.0 (#431) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ebcbcb..8055e1b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.5.0", + "prettier": "~2.6.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From eb45758928b6146e91c9ec86a00dd6235c357cf2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:39:52 -0400 Subject: [PATCH 59/97] BREAKING: Drop Node 12 support (#438) --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d814851..45349ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [12, 14, 16] + node: [14, 16, 18] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index 8055e1b..e82cd9f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "type": "module", "engines": { - "node": ">=12" + "node": ">=14" }, "bin": { "postcss": "./index.js" From e1751d05e674d135b5f97db7bc666cc855525d3c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:42:33 -0400 Subject: [PATCH 60/97] Update dependency prettier to ~2.7.0 (#436) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e82cd9f..b55467c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.6.0", + "prettier": "~2.7.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From 7a8d21e99bbd94b0e684a5d9b0ece30951b7f0be Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:47:07 -0400 Subject: [PATCH 61/97] Update dependency postcss-load-config to v4 (#437) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b55467c..920100e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "get-stdin": "^9.0.0", "globby": "^13.0.0", "picocolors": "^1.0.0", - "postcss-load-config": "^3.0.0", + "postcss-load-config": "^4.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From a1e547e697a4eaae795a9666ea9220aad1a3b1d3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:32:08 -0400 Subject: [PATCH 62/97] Fix watch test --- test/watch.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/watch.js b/test/watch.js index af69eb4..4cd5391 100644 --- a/test/watch.js +++ b/test/watch.js @@ -167,7 +167,9 @@ testCb('--watch dependencies', (t) => { let killed = false const cp = exec( - `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, + `node ${path.resolve( + 'index.js' + )} a.css -o output.css -u postcss-import -w --no-map`, { cwd: dir } ) cp.on('error', t.end) From d7794767d4e9c85e53f0a9c48f444410ab4c7c7d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:39:56 -0400 Subject: [PATCH 63/97] Add tests for ESM config --- test/config.js | 25 +++++++++++++++++++++++++ test/helpers/env.js | 5 ++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/config.js b/test/config.js index a4eb8c6..d75449c 100644 --- a/test/config.js +++ b/test/config.js @@ -28,6 +28,31 @@ test('supports common config', async (t) => { ) }) +test('supports ESM config', async (t) => { + const env = `import postcssImport from 'postcss-import' + export default function () { + return { + plugins: [ + postcssImport() + ] + } + }` + + const dir = await ENV(env, ['a.css'], 'mjs') + + const { error, stderr } = await cli( + ['a.css', '-o', 'output.css', '--no-map'], + dir + ) + + t.falsy(error, stderr) + + t.is( + await read(path.join(dir, 'output.css')), + await read('test/fixtures/a.css') + ) +}) + test("doesn't error on empty config", async (t) => { const env = `module.exports = {}` diff --git a/test/helpers/env.js b/test/helpers/env.js index 7ec542e..dfdba26 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -4,8 +4,7 @@ import { globby } from 'globby' import tmp from './tmp.js' -export default function (config, fixtures) { - fixtures = fixtures || '**/*' +export default function (config, fixtures = '**/*', extension = 'cjs') { const dir = tmp() return Promise.all([ @@ -14,6 +13,6 @@ export default function (config, fixtures) { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) }), - fs.outputFile(path.join(dir, 'postcss.config.cjs'), config), + fs.outputFile(path.join(dir, `postcss.config.${extension}`), config), ]).then(() => dir) } From e5419b5dd587f81a78acbc0f68b33efe150d9ef3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:43:25 -0400 Subject: [PATCH 64/97] 10.0.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d63af2b..f2f8d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 10.0.0 / 2022-06-29 + +- **BREAKING:** Drop Node 12 support ([#438](https://github.com/postcss/postcss-cli/pull/438)) +- Add support for ESM config files ([#437](https://github.com/postcss/postcss-cli/pull/437)) + # 9.1.0 / 2021-12-10 - Don't write to files if they're unchanged ([#320](https://github.com/postcss/postcss-cli/issues/320), [#417](https://github.com/postcss/postcss-cli/pull/417)) diff --git a/package.json b/package.json index 920100e..5874d62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.1.0", + "version": "10.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 7bf54afe1e3576498de55ca9af94ad1c080891f7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:28:06 -0400 Subject: [PATCH 65/97] Update dependency uuid to v9 (#440) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5874d62..2d31b78 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "postcss-import": "^14.0.0", "prettier": "~2.7.0", "sugarss": "^4.0.0", - "uuid": "^8.0.0" + "uuid": "^9.0.0" }, "peerDependencies": { "postcss": "^8.0.0" From e1b551ef05d050c517b983f6c794fda55110b9fe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:28:34 -0400 Subject: [PATCH 66/97] Update dependency postcss-import to v15 (#439) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d31b78..412137e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint": "^8.2.0", "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", - "postcss-import": "^14.0.0", + "postcss-import": "^15.0.0", "prettier": "~2.7.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" From dcdef56d3603a4fb5b62d266888c0a57719ea99a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:37:05 -0400 Subject: [PATCH 67/97] Update dependency slash to v5 (#442) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 412137e..861fdde 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "slash": "^4.0.0", + "slash": "^5.0.0", "yargs": "^17.0.0" }, "devDependencies": { From 9fdc954cfa897b41164f299855250fa3055b061f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:56:34 -0400 Subject: [PATCH 68/97] Update dependency eslint-config-problems to v7 (#443) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 861fdde..a753961 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "c8": "^7.9.0", "coveralls": "^3.0.0", "eslint": "^8.2.0", - "eslint-config-problems": "6.0.0", + "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", "prettier": "~2.7.0", From 1cd25c283606be3137b355b944e5dd4b4e2191b0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 11:22:03 -0500 Subject: [PATCH 69/97] Update dependency prettier to ~2.8.0 (#445) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a753961..7bbfc19 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~2.7.0", + "prettier": "~2.8.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From e939a68a039b17d49d286c853df908227875d51d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 20:05:13 -0500 Subject: [PATCH 70/97] Update dependency fs-extra to v11 (#447) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7bbfc19..c39207c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chokidar": "^3.3.0", "dependency-graph": "^0.11.0", - "fs-extra": "^10.0.0", + "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", "globby": "^13.0.0", "picocolors": "^1.0.0", From 83771bda43d200b5229e1db558e936680cbc378d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiago=20Brand=C3=A3o?= <194487+0xradical@users.noreply.github.com> Date: Tue, 29 Nov 2022 17:49:15 -0300 Subject: [PATCH 71/97] Allow non-TTY stdin watch mode (#448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The presence of stdin doesn't necessarily mean there's an allocated tty. This breaks watch mode in non-TTY stdin contexts (e.g. docker, foreman, etc). A simple process.stdin.isTTY check would theoretically be enough but unfortunately, subprocesses don't have the same API, which are used extensively to test via calls to `spawn`. A simple solution is to inject an env var dependency where we tell the process that it's indeed a TTY-allocated process and so, watch mode with exit handling is good to go. Co-authored-by: Thiago Brandão <194487+thiagobrandam@users.noreply.github.com> --- index.js | 8 +++++++- test/watch.js | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 615638c..da052ce 100755 --- a/index.js +++ b/index.js @@ -61,7 +61,13 @@ let configFile if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) -if (argv.watch) { +let { isTTY } = process.stdin + +if (process.env.FORCE_IS_TTY === 'true') { + isTTY = true +} + +if (argv.watch && isTTY) { process.stdin.on('end', () => process.exit(0)) process.stdin.resume() } diff --git a/test/watch.js b/test/watch.js index 4cd5391..625df1b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -205,6 +205,10 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, { shell: true, + env: { + ...process.env, + FORCE_IS_TTY: true, + }, }) cp.on('error', t.end) @@ -212,6 +216,7 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.is(code, 0) t.end() }) + cp.stdin.end() }) From a3574b1f67e4d8c1a78b6b72b501354f545c34d2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 29 Nov 2022 15:54:57 -0500 Subject: [PATCH 72/97] 10.1.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2f8d32..7c46faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 10.1.0 / 2022-11-29 + +- Allow running `--watch` mode in non-TTY contexts, like Docker ([#448](https://github.com/postcss/postcss-cli/pull/448)) +- Update dependencies + # 10.0.0 / 2022-06-29 - **BREAKING:** Drop Node 12 support ([#438](https://github.com/postcss/postcss-cli/pull/438)) diff --git a/package.json b/package.json index c39207c..1fc3037 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "10.0.0", + "version": "10.1.0", "description": "CLI for PostCSS", "type": "module", "engines": { From fad7e1abb159a1941f3fbd667b45f3eeb8101f82 Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Thu, 4 May 2023 22:07:23 +0900 Subject: [PATCH 73/97] Fix CHANGELOG typos (#450) --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c46faa..47c9bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ # 8.2.0 / 2020-10-29 -- Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) +- Allow backslashes in paths for better Windows experience ([#355](https://github.com/postcss/postcss-cli/pull/355)) # 8.1.0 / 2020-10-08 @@ -76,7 +76,7 @@ # 6.1.3 / 2019-07-08 -- Fix external sorcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) +- Fix external sourcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) # 6.1.2 / 2019-02-22 @@ -331,4 +331,4 @@ Migration guide: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-t # 0.1.0 / 2015-03-11 -- initial implementaion +- initial implementation From c3f9c3f4baf25f5b76f75bbdc8c765a7af1caf6c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:38:17 -0400 Subject: [PATCH 74/97] Update dependency c8 to v8 (#453) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fc3037..bb7e8d7 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^7.9.0", + "c8": "^8.0.0", "coveralls": "^3.0.0", "eslint": "^8.2.0", "eslint-config-problems": "7.0.1", From d8b2e2af37166e467a29ffd73a81a28954642fa4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Jul 2023 20:53:50 -0400 Subject: [PATCH 75/97] Update dependency prettier to v3 (#454) * Update dependency prettier to v3 * Run prettier --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ryan Zimmerman --- index.js | 24 +++++++++---------- lib/args.js | 10 ++++---- package.json | 2 +- test/base.js | 4 ++-- test/config.js | 16 ++++++------- test/error.js | 10 ++++---- test/glob.js | 6 ++--- test/helpers/cli.js | 2 +- test/helpers/read.js | 2 +- test/misc.js | 2 +- test/stdin.js | 2 +- test/stdout.js | 4 ++-- test/watch.js | 56 ++++++++++++++++++++++---------------------- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/index.js b/index.js index da052ce..f77bf04 100755 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ async function buildCliConfig() { if (e.name && e.name !== 'Error') prefix += `: ${e.name}` return error(`Plugin Error${prefix}: ${msg}'`) } - }) + }), ) : [], } @@ -88,13 +88,13 @@ buildCliConfig() if (input && input.length) { return globby( input.map((i) => slash(String(i))), - { dot: argv.includeDotfiles } + { dot: argv.includeDotfiles }, ) } if (argv.replace || argv.dir) { error( - 'Input Error: Cannot use --dir or --replace when reading from stdin' + 'Input Error: Cannot use --dir or --replace when reading from stdin', ) } @@ -111,7 +111,7 @@ buildCliConfig() if (i.length > 1 && !argv.dir && !argv.replace) { error( - 'Input Error: Must use --dir or --replace with multiple input files' + 'Input Error: Must use --dir or --replace with multiple input files', ) } @@ -146,7 +146,7 @@ buildCliConfig() .concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf)) recompile = recompile.concat( - dependants.filter((file) => input.includes(file)) + dependants.filter((file) => input.includes(file)), ) if (!recompile.length) recompile = input @@ -171,7 +171,7 @@ function rc(ctx, path) { .then((rc) => { if (rc.options.from || rc.options.to) { error( - 'Config Error: Can not set from or to options in config file, use CLI arguments instead' + 'Config Error: Can not set from or to options in config file, use CLI arguments instead', ) } configFile = rc.file @@ -195,7 +195,7 @@ function files(files) { } return read(file).then((content) => css(content, file)) - }) + }), ) } @@ -246,7 +246,7 @@ function css(css, file) { if (!options.to && config.options.map && !config.options.map.inline) { error( - 'Output Error: Cannot output external sourcemaps when writing to STDOUT' + 'Output Error: Cannot output external sourcemaps when writing to STDOUT', ) } @@ -268,8 +268,8 @@ function css(css, file) { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( pc.green( - `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}` - ) + `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}`, + ), ) const messages = result.warnings() @@ -303,7 +303,7 @@ function dependencies(results) { result.messages .filter((msg) => - msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '' + msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '', ) .map(depGraph.add) .forEach((dependency) => { @@ -311,7 +311,7 @@ function dependencies(results) { messages.push( dependency.glob ? path.join(dependency.dir, dependency.glob) - : dependency.dir + : dependency.dir, ) } else { messages.push(dependency.file) diff --git a/lib/args.js b/lib/args.js index 35f0e83..12d14fa 100644 --- a/lib/args.js +++ b/lib/args.js @@ -7,11 +7,11 @@ const { argv } = yargs(process.argv.slice(2)) $0 ... [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] - $0 ... [OPTIONS] --replace` + $0 ... [OPTIONS] --replace`, ) .group( ['o', 'd', 'r', 'map', 'no-map', 'watch', 'verbose', 'env'], - 'Basic options:' + 'Basic options:', ) .option('o', { alias: 'output', @@ -50,7 +50,7 @@ const { argv } = yargs(process.argv.slice(2)) }) .group( ['u', 'parser', 'stringifier', 'syntax'], - 'Options for use without a config file:' + 'Options for use without a config file:', ) .option('u', { alias: 'use', @@ -98,7 +98,7 @@ const { argv } = yargs(process.argv.slice(2)) .example('$0 src/**/*.css --base src --dir build', 'Glob Pattern & output') .example( 'cat input.css | $0 -u autoprefixer > output.css', - 'Piping input & output' + 'Piping input & output', ) .epilog( `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. @@ -107,7 +107,7 @@ If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. -For more details, please see https://github.com/postcss/postcss-cli` +For more details, please see https://github.com/postcss/postcss-cli`, ) if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` diff --git a/package.json b/package.json index bb7e8d7..190bf99 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~2.8.0", + "prettier": "~3.0.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, diff --git a/test/base.js b/test/base.js index 496ca14..a0f965c 100644 --- a/test/base.js +++ b/test/base.js @@ -21,11 +21,11 @@ test('--base --dir works', async (t) => { t.is( await read(path.join(dir, 'level-1/level-2/a.css')), - await read('test/fixtures/base/level-1/level-2/a.css') + await read('test/fixtures/base/level-1/level-2/a.css'), ) t.is( await read(path.join(dir, 'level-1/b.css')), - await read('test/fixtures/base/level-1/b.css') + await read('test/fixtures/base/level-1/b.css'), ) }) diff --git a/test/config.js b/test/config.js index d75449c..b1d7c2c 100644 --- a/test/config.js +++ b/test/config.js @@ -17,14 +17,14 @@ test('supports common config', async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -42,14 +42,14 @@ test('supports ESM config', async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -60,14 +60,14 @@ test("doesn't error on empty config", async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -82,7 +82,7 @@ test('errors if `to` is set', async (t) => { t.regex( stderr, - /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + /Config Error: Can not set from or to options in config file, use CLI arguments instead/, ) }) @@ -97,6 +97,6 @@ test('errors if `from` is set', async (t) => { t.regex( stderr, - /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + /Config Error: Can not set from or to options in config file, use CLI arguments instead/, ) }) diff --git a/test/error.js b/test/error.js index 9901f47..5ff67ef 100644 --- a/test/error.js +++ b/test/error.js @@ -22,7 +22,7 @@ test('--map && writing to stdout', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Output Error: Cannot output external sourcemaps when writing to STDOUT/ + /Output Error: Cannot output external sourcemaps when writing to STDOUT/, ) }) }) @@ -33,9 +33,9 @@ test('plugin not found', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Plugin Error: Cannot find package 'postcss-plugin'/ + /Plugin Error: Cannot find package 'postcss-plugin'/, ) - } + }, ) }) @@ -58,8 +58,8 @@ test('CssSyntaxError', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/ + /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/, ) - } + }, ) }) diff --git a/test/glob.js b/test/glob.js index 33917ad..863fc39 100644 --- a/test/glob.js +++ b/test/glob.js @@ -19,14 +19,14 @@ test('works with glob patterns', async (t) => { t.is( await read(path.join(output, 'a.css')), - await read('test/fixtures/glob/a.css') + await read('test/fixtures/glob/a.css'), ) t.is( await read(path.join(output, 'b.css')), - await read('test/fixtures/glob/b.css') + await read('test/fixtures/glob/b.css'), ) t.is( await read(path.join(output, 's.css')), - await read('test/fixtures/glob/s.css') + await read('test/fixtures/glob/s.css'), ) }) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 565d3ff..838d5a6 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -13,7 +13,7 @@ export default function (args, cwd) { stdout, stderr, }) - } + }, ) }) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 1dbe451..e9939aa 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -2,6 +2,6 @@ import fs from 'fs-extra' export default function (path) { return fs.readFile(path, 'utf8').then( - (content) => content.replace(/\r\n/g, '\n') // normalize line endings on Windows + (content) => content.replace(/\r\n/g, '\n'), // normalize line endings on Windows ) } diff --git a/test/misc.js b/test/misc.js index 812b6d0..09bde3f 100644 --- a/test/misc.js +++ b/test/misc.js @@ -17,6 +17,6 @@ test('--version', async (t) => { t.truthy( version.stdout.length > 5, - 'expected --version to output version info' + 'expected --version to output version info', ) }) diff --git a/test/stdin.js b/test/stdin.js index 9fb0679..a682436 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -21,7 +21,7 @@ test.cb('reads from stdin', (t) => { t.end() }) .catch(t.end) - } + }, ) fs.createReadStream('test/fixtures/a.css').pipe(cp.stdin) diff --git a/test/stdout.js b/test/stdout.js index 68b6b4b..260180f 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -9,7 +9,7 @@ import read from './helpers/read.js' test.cb('writes to stdout', (t) => { const cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} --parser sugarss -u postcss-import --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) @@ -20,7 +20,7 @@ test.cb('writes to stdout', (t) => { t.end() }) .catch(t.end) - } + }, ) fs.createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) diff --git a/test/watch.js b/test/watch.js index 625df1b..357174a 100644 --- a/test/watch.js +++ b/test/watch.js @@ -52,7 +52,7 @@ testCb('--watch works', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve('index.js')} "*.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -63,7 +63,7 @@ testCb('--watch works', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -116,9 +116,9 @@ testCb('--watch dependencies', (t) => { watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} import.css -o output.css -u postcss-import -w --no-map`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) @@ -130,7 +130,7 @@ testCb('--watch dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -168,9 +168,9 @@ testCb('--watch dependencies', (t) => { let killed = false const cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} a.css -o output.css -u postcss-import -w --no-map`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.stderr.on('data', (chunk) => { @@ -197,7 +197,7 @@ testCb('--watch dependencies', (t) => { } }) .catch(t.end) - } + }, ) testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { @@ -246,7 +246,7 @@ testCb('--watch watches dependencies', (t) => { } ] } - ` + `, ) .then(() => { // Init watcher: @@ -281,9 +281,9 @@ testCb('--watch watches dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -294,7 +294,7 @@ testCb('--watch watches dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -333,13 +333,13 @@ testCb('--watch watches directory dependencies', (t) => { root.nodes = [] root.append(fs.readFileSync('${path.resolve( dir, - 'base/level-1/level-2/a.css' + 'base/level-1/level-2/a.css', )}', 'utf8')) return root } ] } - ` + `, ) .then(() => { // Init watcher: @@ -358,8 +358,8 @@ testCb('--watch watches directory dependencies', (t) => { .then((css) => fs.writeFile( path.join(dir, 'base/level-1/level-2/a.css'), - css - ) + css, + ), ) .catch(done) } @@ -379,9 +379,9 @@ testCb('--watch watches directory dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -392,7 +392,7 @@ testCb('--watch watches directory dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -405,7 +405,7 @@ testCb('--watch watches directory dependencies', (t) => { } }) .catch(t.end) - } + }, ) }) @@ -440,13 +440,13 @@ testCb( root.nodes = [] root.append(fs.readFileSync('${path.resolve( dir, - 'base/level-1/level-2/a.css' + 'base/level-1/level-2/a.css', )}', 'utf8')) return root } ] } - ` + `, ) .then(() => { // Init watcher: @@ -471,7 +471,7 @@ testCb( t.is( modifying, 'a.css', - `Unexpected change to ${p} after modifying ${modifying}` + `Unexpected change to ${p} after modifying ${modifying}`, ) done() } else if (p === 'base/level-1/level-2/unrelated.md') { @@ -484,9 +484,9 @@ testCb( watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -498,7 +498,7 @@ testCb( modifying = 'unrelated.md' fs.writeFile( path.join(dir, 'base/level-1/level-2/unrelated.md'), - 'Some modification' + 'Some modification', ).catch(done) } @@ -506,7 +506,7 @@ testCb( modifying = 'a.css' fs.writeFile( path.join(dir, 'base/level-1/level-2/a.css'), - 'a { color: hotpink }' + 'a { color: hotpink }', ).catch(done) } @@ -520,5 +520,5 @@ testCb( }) .catch(t.end) }) - } + }, ) From c41052a7c0dbeff2947a52b3e80305a4b2405d42 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:13:39 -0400 Subject: [PATCH 76/97] Update actions/checkout action to v4 (#456) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45349ef..f6e2bcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v3 with: From 922c022856a839e286a3f9851e2c0b32621acb81 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:54:06 -0400 Subject: [PATCH 77/97] Update actions/setup-node action to v4 (#458) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6e2bcf..580b5f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: npm install From 3b47a48a509ad65c5a3f6000acf0d407dfa6886b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:00:36 -0500 Subject: [PATCH 78/97] Update dependency prettier to ~3.1.0 (#460) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 190bf99..e98404e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~3.0.0", + "prettier": "~3.1.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 5f728e5882c51d23ea16466991e75791826d31b9 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 5 Dec 2023 15:52:14 -0500 Subject: [PATCH 79/97] BREAKING: Require Node.js v18+ (#464) --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 580b5f0..a7a22ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [14, 16, 18] + node: [18, 20] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index e98404e..c40d153 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "type": "module", "engines": { - "node": ">=14" + "node": ">=18" }, "bin": { "postcss": "./index.js" From ba1866d9496281c570e6972ea64559edd396671c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:23 -0500 Subject: [PATCH 80/97] Update dependency eslint-config-problems to v8 (#451) * Update dependency eslint-config-problems to v8 * Bump eslint peerDependency --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ryan Zimmerman --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c40d153..8aa6302 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "ava": "^3.1.0", "c8": "^8.0.0", "coveralls": "^3.0.0", - "eslint": "^8.2.0", - "eslint-config-problems": "7.0.1", + "eslint": "^8.55.0", + "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^15.0.0", "prettier": "~3.1.0", From 91ad9e430e7719368e145701042d870c5065c408 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:37 -0500 Subject: [PATCH 81/97] Update dependency globby to v14 (#459) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8aa6302..9f05759 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", - "globby": "^13.0.0", + "globby": "^14.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^4.0.0", "postcss-reporter": "^7.0.0", From e235bfdc49867d5f3b7895e3ea01344efbe7d653 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:51 -0500 Subject: [PATCH 82/97] Update dependency postcss-load-config to v5 (#462) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f05759..424b2ba 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "get-stdin": "^9.0.0", "globby": "^14.0.0", "picocolors": "^1.0.0", - "postcss-load-config": "^4.0.0", + "postcss-load-config": "^5.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From ac801f1f91e22fc36a25af5fc2c36266d3f0c75d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 5 Dec 2023 16:03:23 -0500 Subject: [PATCH 83/97] 11.0.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c9bf6..1b1e31c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 11.0.0 / 2023-12-05 + +- **BREAKING:** Require Node.js v18+ ([#464](https://github.com/postcss/postcss-cli/pull/464)) +- Upgrade to [`postcss-load-config@5`](https://github.com/postcss/postcss-load-config/blob/main/CHANGELOG.md#50-2023-11-20) for improved ESM & TS config support ([#461](https://github.com/postcss/postcss-cli/issues/461), [#462](https://github.com/postcss/postcss-cli/pull/462)) + # 10.1.0 / 2022-11-29 - Allow running `--watch` mode in non-TTY contexts, like Docker ([#448](https://github.com/postcss/postcss-cli/pull/448)) diff --git a/package.json b/package.json index 424b2ba..7ae796a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "10.1.0", + "version": "11.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 278377fa4bda8b2c76c4ee893988eb6f748dda1e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:16:10 -0500 Subject: [PATCH 84/97] Update dependency dependency-graph to v1 (#465) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ae796a..5b90766 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chokidar": "^3.3.0", - "dependency-graph": "^0.11.0", + "dependency-graph": "^1.0.0", "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", "globby": "^14.0.0", From 9854cead1bae73cd3b29ca342a77882c61775e35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:13:03 -0500 Subject: [PATCH 85/97] Update dependency postcss-import to v16 (#468) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b90766..242bb24 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", - "postcss-import": "^15.0.0", + "postcss-import": "^16.0.0", "prettier": "~3.1.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" From ea71afd7d44a1cc2f1a0e31cb2e5aba3db23d1c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:13:20 -0500 Subject: [PATCH 86/97] Update dependency c8 to v9 (#469) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 242bb24..82473b4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^8.0.0", + "c8": "^9.0.0", "coveralls": "^3.0.0", "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", From 4c5a69c6a725d8b6a2d9c1fd35474e8d8273f9b9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:33:18 -0500 Subject: [PATCH 87/97] Update dependency prettier to ~3.2.0 (#470) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82473b4..d7db6f6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.1.0", + "prettier": "~3.2.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 528af4c30beffcce0653eb7046a6f331a0fd5ffd Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jan 2024 20:49:02 +0100 Subject: [PATCH 88/97] Adding link to PostCSS (#472) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9dc9a2d..a390e3e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@

PostCSS CLI

+PostCSS CLI is a command line interface for [PostCSS](https://postcss.org/) +

Install

```bash From 0f52be713e121c7e4476b380ce7bab9529890b7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:49:29 -0400 Subject: [PATCH 89/97] Update dependency prettier to ~3.3.0 (#477) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d7db6f6..0664ed3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.2.0", + "prettier": "~3.3.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 5f9f92af5f070313fc710a62db0c58705fb891eb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:33:45 -0500 Subject: [PATCH 90/97] Update dependency prettier to ~3.4.0 (#484) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0664ed3..41599f6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.3.0", + "prettier": "~3.4.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From b5d8f0ed6e25e7e0f0662e9aed3bfd7def9e6573 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Wed, 12 Mar 2025 19:09:20 +0200 Subject: [PATCH 91/97] feat: replace globby with tinyglobby and remove get-stdin in favor of builtin stream.consumers.text (#489) --- index.js | 8 ++++---- package.json | 3 +-- test/helpers/env.js | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index f77bf04..266c912 100755 --- a/index.js +++ b/index.js @@ -4,10 +4,10 @@ import fs from 'fs-extra' import path from 'path' import prettyHrtime from 'pretty-hrtime' -import stdin from 'get-stdin' +import { text } from 'stream/consumers' import read from 'read-cache' import pc from 'picocolors' -import { globby } from 'globby' +import { glob } from 'tinyglobby' import slash from 'slash' import chokidar from 'chokidar' @@ -86,7 +86,7 @@ buildCliConfig() } if (input && input.length) { - return globby( + return glob( input.map((i) => slash(String(i))), { dot: argv.includeDotfiles }, ) @@ -188,7 +188,7 @@ function files(files) { return Promise.all( files.map((file) => { if (file === 'stdin') { - return stdin().then((content) => { + return text(process.stdin).then((content) => { if (!content) return error('Input Error: Did not receive any STDIN') return css(content, 'stdin') }) diff --git a/package.json b/package.json index 41599f6..92d07ea 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,13 @@ "chokidar": "^3.3.0", "dependency-graph": "^1.0.0", "fs-extra": "^11.0.0", - "get-stdin": "^9.0.0", - "globby": "^14.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^5.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "slash": "^5.0.0", + "tinyglobby": "^0.2.12", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/test/helpers/env.js b/test/helpers/env.js index dfdba26..017df87 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,6 +1,6 @@ import fs from 'fs-extra' import path from 'path' -import { globby } from 'globby' +import { glob } from 'tinyglobby' import tmp from './tmp.js' @@ -8,7 +8,7 @@ export default function (config, fixtures = '**/*', extension = 'cjs') { const dir = tmp() return Promise.all([ - globby(fixtures, { cwd: 'test/fixtures' }).then((list) => { + glob(fixtures, { cwd: 'test/fixtures' }).then((list) => { return list.map((item) => { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) From bfad16da0dad084a0961efb1cf44b626fac3a2e0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:10:53 -0400 Subject: [PATCH 92/97] Update dependency c8 to v10 (#480) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92d07ea..d95f104 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^9.0.0", + "c8": "^10.0.0", "coveralls": "^3.0.0", "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", From bd416f5b326562a228202b1b6b23495ffcffa8ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:13:11 -0400 Subject: [PATCH 93/97] Update dependency uuid to v11 (#482) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d95f104..d3c71e8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss-import": "^16.0.0", "prettier": "~3.4.0", "sugarss": "^4.0.0", - "uuid": "^9.0.0" + "uuid": "^11.0.0" }, "peerDependencies": { "postcss": "^8.0.0" From 1363a6549a622a27b4a5d8e55c65d406aae94cbd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:14:38 -0400 Subject: [PATCH 94/97] Update dependency prettier to ~3.5.0 (#488) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3c71e8..d62916a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.4.0", + "prettier": "~3.5.0", "sugarss": "^4.0.0", "uuid": "^11.0.0" }, From 733ef42fa6b596139787c721ecfbc2b50d915fae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:17:04 -0400 Subject: [PATCH 95/97] chore(deps): update dependency sugarss to v5 (#483) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d62916a..86f0ecf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "postcss": "^8.0.4", "postcss-import": "^16.0.0", "prettier": "~3.5.0", - "sugarss": "^4.0.0", + "sugarss": "^5.0.0", "uuid": "^11.0.0" }, "peerDependencies": { From 0dc4eba537acf36af7747753027c99d768644820 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Mar 2025 13:28:07 -0400 Subject: [PATCH 96/97] Use eslint v9 + flat config (#490) --- .eslintrc.yaml | 7 ------- eslint.config.js | 16 ++++++++++++++++ package.json | 5 +++-- 3 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 .eslintrc.yaml create mode 100644 eslint.config.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml deleted file mode 100644 index d838ba7..0000000 --- a/.eslintrc.yaml +++ /dev/null @@ -1,7 +0,0 @@ -env: - node: true -parserOptions: - sourceType: module -extends: problems -rules: - no-console: off diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..26e500f --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,16 @@ +import problems from 'eslint-config-problems' +import globals from 'globals' + +export default [ + problems, + { + languageOptions: { + globals: { + ...globals.node, + }, + }, + rules: { + 'no-console': 'off', + }, + }, +] diff --git a/package.json b/package.json index 86f0ecf..ff99339 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,9 @@ "ava": "^3.1.0", "c8": "^10.0.0", "coveralls": "^3.0.0", - "eslint": "^8.55.0", - "eslint-config-problems": "8.0.0", + "eslint": "^9.22.0", + "eslint-config-problems": "9.0.0", + "globals": "^16.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", "prettier": "~3.5.0", From 7bea18069b334b0d537d5c772ce20b1637c7e5d6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Mar 2025 13:38:50 -0400 Subject: [PATCH 97/97] 11.0.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b1e31c..4fed6ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 11.0.1 / 2025-03-12 + +- Update and minimize dependencies + # 11.0.0 / 2023-12-05 - **BREAKING:** Require Node.js v18+ ([#464](https://github.com/postcss/postcss-cli/pull/464)) diff --git a/package.json b/package.json index ff99339..dcb8866 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "11.0.0", + "version": "11.0.1", "description": "CLI for PostCSS", "type": "module", "engines": {