summaryrefslogtreecommitdiff
path: root/node_modules/postcss-cli
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 16:27:06 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 16:27:06 +0800
commit2db6defc0b555d93d2363ba6c6dfa19df7dc7c11 (patch)
treea92c596973b150bbd1723b55facf38e0ab6258d8 /node_modules/postcss-cli
parent6dce4e2e8ed35a26af389b7ab388113381350444 (diff)
update
Diffstat (limited to 'node_modules/postcss-cli')
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/LICENSE22
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/README.md12
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/index.js4
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/lib/formatter.js95
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/lib/reporter.js101
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/lib/util.js19
-rw-r--r--node_modules/postcss-cli/node_modules/postcss-reporter/package.json31
-rw-r--r--node_modules/postcss-cli/node_modules/slash/index.d.ts23
-rw-r--r--node_modules/postcss-cli/node_modules/slash/index.js9
-rw-r--r--node_modules/postcss-cli/node_modules/slash/license9
-rw-r--r--node_modules/postcss-cli/node_modules/slash/package.json39
-rw-r--r--node_modules/postcss-cli/node_modules/slash/readme.md36
12 files changed, 400 insertions, 0 deletions
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/LICENSE b/node_modules/postcss-cli/node_modules/postcss-reporter/LICENSE
new file mode 100644
index 00000000..6d347c06
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 David Clark
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/README.md b/node_modules/postcss-cli/node_modules/postcss-reporter/README.md
new file mode 100644
index 00000000..ca6c43b9
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/README.md
@@ -0,0 +1,12 @@
+# postcss-reporter
+
+A PostCSS plugin to `console.log()` the messages (warnings, etc.) registered by other PostCSS plugins.
+
+---
+
+**SEEKING A NEW MAINTAINER!** Interested in contributing to the ecosystem of PostCSS and Stylelint? Please open an issue if you'd like to take over maintenance of this package.
+
+---
+
+## Docs
+Read **[full docs](https://github.com/postcss/postcss-reporter#readme)** on GitHub.
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/index.js b/node_modules/postcss-cli/node_modules/postcss-reporter/index.js
new file mode 100644
index 00000000..01116aa4
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/index.js
@@ -0,0 +1,4 @@
+var reporter = require('./lib/reporter');
+
+module.exports = reporter;
+module.exports.postcss = true;
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/lib/formatter.js b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/formatter.js
new file mode 100644
index 00000000..7358cc61
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/formatter.js
@@ -0,0 +1,95 @@
+var pico = require('picocolors');
+var path = require('path');
+var firstBy = require('thenby');
+var util = require('./util');
+
+var supportsLargeCharset =
+ process.platform !== 'win32' ||
+ process.env.CI ||
+ process.env.TERM === 'xterm-256color';
+var warningSymbol = supportsLargeCharset ? '⚠' : '!!';
+
+function createSortFunction(positionless, sortByPosition) {
+ var positionValue = 0
+
+ if (positionless === 'any') { positionValue = 1; }
+ if (positionless === 'first') { positionValue = 2; }
+ if (positionless === 'last') { positionValue = 0; }
+
+ var sortFunction = firstBy((m) => {
+ if (!m.line) return 1;
+ return positionValue;
+ })
+
+ if (sortByPosition) {
+ sortFunction = sortFunction.thenBy('line').thenBy('column');
+ }
+
+ return sortFunction;
+}
+
+module.exports = function (opts) {
+ var options = opts || {};
+ var sortByPosition =
+ typeof options.sortByPosition !== 'undefined'
+ ? options.sortByPosition
+ : true;
+ var positionless = options.positionless || 'first';
+
+ var sortFunction = createSortFunction(positionless, sortByPosition);
+
+ return function (input) {
+ var messages = input.messages.filter(function (message) {
+ return typeof message.text === 'string';
+ });
+ var source = input.source;
+
+ if (!messages.length) return '';
+
+ var orderedMessages = messages.sort(sortFunction);
+
+ var output = '\n';
+
+ if (source) {
+ output += pico.bold(pico.underline(logFrom(source))) + '\n';
+ }
+
+ orderedMessages.forEach(function (w) {
+ output += messageToString(w) + '\n';
+ });
+
+ return output;
+
+ function messageToString(message) {
+ var location = util.getLocation(message);
+ var str = '';
+
+ if (location.line) {
+ str += pico.bold(location.line);
+ }
+
+ if (location.column) {
+ str += pico.bold(':' + location.column);
+ }
+
+ if (location.line || location.column) {
+ str += '\t';
+ }
+
+ if (!options.noIcon && message.type === 'warning') {
+ str += pico.yellow(warningSymbol + ' ');
+ }
+
+ str += message.text;
+ if (!options.noPlugin) {
+ str += pico.yellow(' [' + message.plugin + ']');
+ }
+ return str;
+ }
+
+ function logFrom(fromValue) {
+ if (fromValue.charAt(0) === '<') return fromValue;
+ return path.relative(process.cwd(), fromValue).split(path.sep).join('/');
+ }
+ };
+};
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/lib/reporter.js b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/reporter.js
new file mode 100644
index 00000000..71872a97
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/reporter.js
@@ -0,0 +1,101 @@
+var defaultFormatter = require('./formatter');
+var pico = require('picocolors');
+var util = require('./util');
+
+module.exports = function (opts = {}) {
+ var formatter =
+ opts.formatter ||
+ defaultFormatter({
+ noIcon: opts.noIcon,
+ noPlugin: opts.noPlugin,
+ });
+
+ var pluginFilter;
+ if (!opts.plugins) {
+ // Every plugin
+ pluginFilter = function () {
+ return true;
+ };
+ } else if (
+ opts.plugins.every(function (plugin) {
+ return plugin[0] === '!';
+ })
+ ) {
+ // Deny list
+ pluginFilter = function (message) {
+ return opts.plugins.indexOf('!' + message.plugin) === -1;
+ };
+ } else {
+ // Allow list
+ pluginFilter = function (message) {
+ return opts.plugins.indexOf(message.plugin) !== -1;
+ };
+ }
+
+ var messageFilter = opts.filter || ((message) => message.type === 'warning');
+
+ return {
+ postcssPlugin: 'postcss-reporter',
+ OnceExit(css, { result }) {
+ var messagesToLog = result.messages
+ .filter(pluginFilter)
+ .filter(messageFilter);
+
+ var resultSource = !result.root.source
+ ? ''
+ : result.root.source.input.file || result.root.source.input.id;
+
+ var sourceGroupedMessages = messagesToLog.reduce((grouped, message) => {
+ const key = util.getLocation(message).file || resultSource;
+
+ if (!grouped.hasOwnProperty(key)) {
+ grouped[key] = [];
+ }
+
+ grouped[key].push(message);
+
+ return grouped;
+ }, {});
+
+ var report = '';
+ for (const source in sourceGroupedMessages) {
+ if (sourceGroupedMessages.hasOwnProperty(source)) {
+ report += formatter({
+ messages: sourceGroupedMessages[source],
+ source: source,
+ });
+ }
+ }
+
+ if (opts.clearReportedMessages) {
+ result.messages = result.messages.filter(message => !messagesToLog.includes(message));
+ }
+
+ if (opts.clearAllMessages) {
+ var messagesToClear = result.messages.filter(pluginFilter);
+ result.messages = result.messages.filter(message => !messagesToClear.includes(message));
+ }
+
+ if (!report) return;
+
+ console.log(report);
+
+ if (opts.throwError && shouldThrowError()) {
+ throw new Error(
+ pico.red(
+ pico.bold('\n** postcss-reporter: warnings or errors were found **')
+ )
+ );
+ }
+
+ function shouldThrowError() {
+ return (
+ messagesToLog.length &&
+ messagesToLog.some((message) => {
+ return message.type === 'warning' || message.type === 'error';
+ })
+ );
+ }
+ },
+ };
+};
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/lib/util.js b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/util.js
new file mode 100644
index 00000000..094b3acc
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/lib/util.js
@@ -0,0 +1,19 @@
+exports.getLocation = function (message) {
+ var messageNode = message.node;
+
+ var location = {
+ line: message.line,
+ column: message.column,
+ };
+
+ var messageInput = messageNode && messageNode.source && messageNode.source.input;
+
+ if (!messageInput) return location;
+
+ var originLocation =
+ messageInput.origin && messageInput.origin(message.line, message.column);
+ if (originLocation) return originLocation;
+
+ location.file = messageInput.file || messageInput.id;
+ return location;
+};
diff --git a/node_modules/postcss-cli/node_modules/postcss-reporter/package.json b/node_modules/postcss-cli/node_modules/postcss-reporter/package.json
new file mode 100644
index 00000000..15a9867c
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/postcss-reporter/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "postcss-reporter",
+ "version": "7.0.5",
+ "description": "Log PostCSS messages in the console",
+ "main": "index.js",
+ "files": [
+ "index.js",
+ "lib"
+ ],
+ "engines": {
+ "node": ">=10"
+ },
+ "repository": "postcss/postcss-reporter",
+ "author": {
+ "name": "David Clark",
+ "email": "david.dave.clark@gmail.com",
+ "url": "https://davidtheclark.com"
+ },
+ "license": "MIT",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ "peerDependencies": {
+ "postcss": "^8.1.0"
+ },
+ "dependencies": {
+ "picocolors": "^1.0.0",
+ "thenby": "^1.3.4"
+ }
+}
diff --git a/node_modules/postcss-cli/node_modules/slash/index.d.ts b/node_modules/postcss-cli/node_modules/slash/index.d.ts
new file mode 100644
index 00000000..692c7fda
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/slash/index.d.ts
@@ -0,0 +1,23 @@
+/**
+Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar`.
+
+[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths.
+
+@param path - A Windows backslash path.
+@returns A path with forward slashes.
+
+@example
+```
+import path from 'node:path';
+import slash from 'slash';
+
+const string = path.join('foo', 'bar');
+// Unix => foo/bar
+// Windows => foo\\bar
+
+slash(string);
+// Unix => foo/bar
+// Windows => foo/bar
+```
+*/
+export default function slash(path: string): string;
diff --git a/node_modules/postcss-cli/node_modules/slash/index.js b/node_modules/postcss-cli/node_modules/slash/index.js
new file mode 100644
index 00000000..1b7ee1ed
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/slash/index.js
@@ -0,0 +1,9 @@
+export default function slash(path) {
+ const isExtendedLengthPath = path.startsWith('\\\\?\\');
+
+ if (isExtendedLengthPath) {
+ return path;
+ }
+
+ return path.replace(/\\/g, '/');
+}
diff --git a/node_modules/postcss-cli/node_modules/slash/license b/node_modules/postcss-cli/node_modules/slash/license
new file mode 100644
index 00000000..fa7ceba3
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/slash/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/postcss-cli/node_modules/slash/package.json b/node_modules/postcss-cli/node_modules/slash/package.json
new file mode 100644
index 00000000..a0f507c9
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/slash/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "slash",
+ "version": "5.1.0",
+ "description": "Convert Windows backslash paths to slash paths",
+ "license": "MIT",
+ "repository": "sindresorhus/slash",
+ "funding": "https://github.com/sponsors/sindresorhus",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "https://sindresorhus.com"
+ },
+ "type": "module",
+ "exports": "./index.js",
+ "types": "./index.d.ts",
+ "engines": {
+ "node": ">=14.16"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "path",
+ "seperator",
+ "slash",
+ "backslash",
+ "windows",
+ "convert"
+ ],
+ "devDependencies": {
+ "ava": "^5.2.0",
+ "tsd": "^0.28.1",
+ "xo": "^0.54.2"
+ }
+}
diff --git a/node_modules/postcss-cli/node_modules/slash/readme.md b/node_modules/postcss-cli/node_modules/slash/readme.md
new file mode 100644
index 00000000..42f74f90
--- /dev/null
+++ b/node_modules/postcss-cli/node_modules/slash/readme.md
@@ -0,0 +1,36 @@
+# slash
+
+> Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar`
+
+[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths.
+
+This was created since the `path` methods in Node.js outputs `\\` paths on Windows.
+
+## Install
+
+```sh
+npm install slash
+```
+
+## Usage
+
+```js
+import path from 'node:path';
+import slash from 'slash';
+
+const string = path.join('foo', 'bar');
+// Unix => foo/bar
+// Windows => foo\\bar
+
+slash(string);
+// Unix => foo/bar
+// Windows => foo/bar
+```
+
+## API
+
+### slash(path)
+
+Type: `string`
+
+Accepts a Windows backslash path and returns a path with forward slashes.