1.4.1: Directory Structure Creation

This commit is contained in:
VinnyNC 2025-09-28 22:58:47 -04:00
parent 25d622ec58
commit bed4240acb
360 changed files with 111598 additions and 0 deletions

34
node_modules/csso-cli/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,34 @@
## 3.0.0 (October 22, 2019)
- Stop support Node.js prior `8.0`
- Updated dependencies and fixed known security issues (#15)
- Fixed `--usage` option that didn't actually work
- Fixed source map generation inconsistency across Node.js versions
## 2.0.2 (December 28, 2018)
- Fixed one more issue with paths in source maps on Windows platform
## 2.0.1 (December 26, 2018)
- Fixed source map paths when perform on Windows platform (path should be in unix format)
## 2.0.0 (December 11, 2018)
- Use relative paths to files in generated source map (#7)
- Removed setting output file with no option label, i.e. `--output` is required
- Renamed options
- `--restructure-off``--no-restructure`
- `--map``--source-map`
- `--input-map``--input-source-map`
## 1.1.0 (September 10, 2017)
- Bumped `CSSO` to `3.2.0`
- Added `--watch` option to run CLI in watch mode (@rijkvanzanten, #4)
- Added `--declaration-list` option to take input as a declaration list (@amarcu5, #8)
- Added `--force-media-merge` option to force `@media` rules merge (see [forceMediaMerge](https://github.com/css/csso#compressast-options) option for details) (@lahmatiy)
## 1.0.0 (March 13, 2017)
- Initial release as standalone package

19
node_modules/csso-cli/LICENSE generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (C) 2017-2019 by Roman Dvornov
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.

196
node_modules/csso-cli/README.md generated vendored Normal file
View file

@ -0,0 +1,196 @@
[![NPM version](https://img.shields.io/npm/v/csso-cli.svg)](https://www.npmjs.com/package/csso-cli)
[![Build Status](https://travis-ci.org/css/csso-cli.svg?branch=master)](https://travis-ci.org/css/csso-cli)
[![Twitter](https://img.shields.io/badge/Twitter-@cssoptimizer-blue.svg)](https://twitter.com/cssoptimizer)
Command line interface for [CSSO](https://github.com/css/csso).
<!-- MarkdownTOC -->
- [Install](#install)
- [Usage](#usage)
- [Source maps](#source-maps)
- [Usage data](#usage-data)
- [Debugging](#debugging)
- [Related projects](#related-projects)
- [License](#license)
<!-- /MarkdownTOC -->
## Install
```
npm install -g csso-cli
```
## Usage
```
csso [input] [options]
Options:
--comments <value> Comments to keep: exclamation (default), first-exclamation or none
--debug [level] Output intermediate state of CSS during a compression
-d, --declaration-list Treat input as a declaration list
--force-media-merge Enable unsafe merge of @media rules
-h, --help Output usage information
-i, --input <filename> Input file
--input-source-map <source> Input source map: none, auto (default) or <filename>
--no-restructure Disable structural optimisations
-o, --output <filename> Output file (result outputs to stdout if not set)
-s, --source-map <destination> Generate source map: none (default), inline, file or <filename>
--stat Output statistics in stderr
-u, --usage <filename> Usage data file
-v, --version Output version
--watch Watch source file for changes
```
Some examples:
```
> csso in.css
...output result in stdout...
> csso in.css --output out.css
> echo '.test { color: #ff0000; }' | csso
.test{color:red}
> cat source1.css source2.css | csso | gzip -9 -c > production.css.gz
```
### Source maps
Source map doesn't generate by default. To generate map use `--map` CLI option, that can be:
- `none` (default) don't generate source map
- `inline` add source map into result CSS (via `/*# sourceMappingURL=application/json;base64,... */`)
- `file` write source map into file with same name as output file, but with `.map` extension (in this case `--output` option is required)
- any other values treat as filename for generated source map
Examples:
```
> csso my.css --map inline
> csso my.css --output my.min.css --map file
> csso my.css --output my.min.css --map maps/my.min.map
```
Use `--input-source-map` option to specify input source map if needed. Possible values for option:
- `auto` (default) - attempt to fetch input source map by follow steps:
- try to fetch inline map from input
- try to fetch source map filename from input and read its content
- (when `--input` is specified) check file with same name as input file but with `.map` extension exists and read its content
- `none` - don't use input source map; actually it's using to disable `auto`-fetching
- any other values treat as filename for input source map
Generally you shouldn't care about the input source map since defaults behaviour (`auto`) covers most use cases.
> NOTE: Input source map is using only if output source map is generating.
### Usage data
`CSSO` can use data about how `CSS` is using for better compression. File with this data (`JSON` format) can be set using `--usage` option. Read more about [Usage data](https://github.com/css/csso#usage-data) in [CSSO](https://github.com/css/csso) repository.
### Debugging
All debug information outputs to `stderr`.
To get brief info about compression use `--stat` option.
```
> echo '.test { color: #ff0000 }' | csso --stat >/dev/null
File: <stdin>
Original: 25 bytes
Compressed: 16 bytes (64.00%)
Saving: 9 bytes (36.00%)
Time: 12 ms
Memory: 0.346 MB
```
To get details about compression steps use `--debug` option.
```
> echo '.test { color: green; color: #ff0000 } .foo { color: red }' | csso --debug
## parsing done in 10 ms
Compress block #1
(0.002ms) convertToInternal
(0.000ms) clean
(0.001ms) compress
(0.002ms) prepare
(0.000ms) initialRejoinRuleset
(0.000ms) rejoinAtrule
(0.000ms) disjoin
(0.000ms) buildMaps
(0.000ms) markShorthands
(0.000ms) processShorthand
(0.001ms) restructBlock
(0.000ms) rejoinRuleset
(0.000ms) restructRuleset
## compressing done in 9 ms
.foo,.test{color:red}
```
More details are providing when `--debug` option has a number greater than `1`:
```
> echo '.test { color: green; color: #ff0000 } .foo { color: red }' | csso --debug 2
## parsing done in 8 ms
Compress block #1
(0.000ms) clean
.test{color:green;color:#ff0000}.foo{color:red}
(0.001ms) compress
.test{color:green;color:red}.foo{color:red}
...
(0.002ms) restructBlock
.test{color:red}.foo{color:red}
(0.001ms) rejoinRuleset
.foo,.test{color:red}
## compressing done in 13 ms
.foo,.test{color:red}
```
Using `--debug` option adds stack trace to CSS parse error output. That can help to find out problem in parser.
```
> echo '.a { color }' | csso --debug
Parse error <stdin>: Colon is expected
1 |.a { color }
------------------^
2 |
/usr/local/lib/node_modules/csso/lib/cli.js:243
throw e;
^
Error: Colon is expected
at parseError (/usr/local/lib/node_modules/csso/lib/parser/index.js:54:17)
at eat (/usr/local/lib/node_modules/csso/lib/parser/index.js:88:5)
at getDeclaration (/usr/local/lib/node_modules/csso/lib/parser/index.js:394:5)
at getBlock (/usr/local/lib/node_modules/csso/lib/parser/index.js:380:27)
...
```
## Related projects
- [CSSO](https://github.com/css/csso) CSS minifier itself
- Gulp: [gulp-csso](https://github.com/ben-eb/gulp-csso)
- Grunt: [grunt-csso](https://github.com/t32k/grunt-csso)
- Broccoli: [broccoli-csso](https://github.com/sindresorhus/broccoli-csso)
- PostCSS: [postcss-csso](https://github.com/lahmatiy/postcss-csso)
- Webpack: [csso-loader](https://github.com/sandark7/csso-loader)
## License
MIT

16
node_modules/csso-cli/bin/csso generated vendored Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env node
var cli = require('../index.js');
try {
cli.run();
} catch (e) {
// output user frendly message if cli error
if (cli.isCliError(e)) {
console.error(e.message || e);
process.exit(2);
}
// otherwise re-throw exception
throw e;
}

392
node_modules/csso-cli/index.js generated vendored Normal file
View file

@ -0,0 +1,392 @@
var fs = require('fs');
var path = require('path');
var cli = require('clap');
var csso = require('csso');
var SourceMapConsumer = require('source-map').SourceMapConsumer;
function unixPathname(pathname) {
return pathname.replace(/\\/g, '/');
}
function readFromStream(stream, minify) {
var buffer = [];
stream
.setEncoding('utf8')
.on('data', function(chunk) {
buffer.push(chunk);
})
.on('end', function() {
minify(buffer.join(''));
});
}
function showStat(filename, source, result, inputMap, map, time, mem) {
function fmt(size) {
return String(size).split('').reverse().reduce(function(size, digit, idx) {
if (idx && idx % 3 === 0) {
size = ' ' + size;
}
return digit + size;
}, '');
}
map = map || 0;
result -= map;
console.error('Source: ', filename === '<stdin>' ? filename : path.relative(process.cwd(), filename));
if (inputMap) {
console.error('Map source:', inputMap);
}
console.error('Original: ', fmt(source), 'bytes');
console.error('Compressed:', fmt(result), 'bytes', '(' + (100 * result / source).toFixed(2) + '%)');
console.error('Saving: ', fmt(source - result), 'bytes', '(' + (100 * (source - result) / source).toFixed(2) + '%)');
if (map) {
console.error('Source map:', fmt(map), 'bytes', '(' + (100 * map / (result + map)).toFixed(2) + '% of total)');
console.error('Total: ', fmt(map + result), 'bytes');
}
console.error('Time: ', time, 'ms');
console.error('Memory: ', (mem / (1024 * 1024)).toFixed(3), 'MB');
}
function showParseError(source, filename, details, message) {
function processLines(start, end) {
return lines.slice(start, end).map(function(line, idx) {
var num = String(start + idx + 1);
while (num.length < maxNumLength) {
num = ' ' + num;
}
return num + ' |' + line;
}).join('\n');
}
var lines = source.split(/\n|\r\n?|\f/);
var column = details.column;
var line = details.line;
var startLine = Math.max(1, line - 2);
var endLine = Math.min(line + 2, lines.length + 1);
var maxNumLength = Math.max(4, String(endLine).length) + 1;
console.error('\nParse error ' + filename + ': ' + message);
console.error(processLines(startLine - 1, line));
console.error(new Array(column + maxNumLength + 2).join('-') + '^');
console.error(processLines(line, endLine));
console.error();
}
function debugLevel(level) {
// level is undefined when no param -> 1
return isNaN(level) ? 1 : Math.max(Number(level), 0);
}
function resolveSourceMap(source, inputMap, outputMap, inputFile, outputFile) {
var inputMapContent = null;
var inputMapFile = null;
var outputMapFile = null;
switch (outputMap) {
case 'none':
// don't generate source map
outputMap = false;
inputMap = 'none';
break;
case 'inline':
// nothing to do
break;
case 'file':
if (!outputFile) {
console.error('Output filename should be specified when `--source-map file` is used');
process.exit(2);
}
outputMapFile = outputFile + '.map';
break;
default:
// process filename
if (outputMap) {
// check path is reachable
if (!fs.existsSync(path.dirname(outputMap))) {
console.error('Directory for map file should exists:', path.dirname(path.resolve(outputMap)));
process.exit(2);
}
// resolve to absolute path
outputMapFile = path.resolve(process.cwd(), outputMap);
}
}
switch (inputMap) {
case 'none':
// nothing to do
break;
case 'auto':
if (outputMap) {
// try fetch source map from source
var inputMapComment = source.match(/\/\*# sourceMappingURL=(\S+)\s*\*\/\s*$/);
if (inputFile === '<stdin>') {
inputFile = false;
}
if (inputMapComment) {
// if comment found value is filename or base64-encoded source map
inputMapComment = inputMapComment[1];
if (inputMapComment.substr(0, 5) === 'data:') {
// decode source map content from comment
inputMapContent = Buffer.from(inputMapComment.substr(inputMapComment.indexOf('base64,') + 7), 'base64').toString();
} else {
// value is filename resolve it as absolute path
if (inputFile) {
inputMapFile = path.resolve(path.dirname(inputFile), inputMapComment);
}
}
} else {
// comment doesn't found - look up file with `.map` extension nearby input file
if (inputFile && fs.existsSync(inputFile + '.map')) {
inputMapFile = inputFile + '.map';
}
}
}
break;
default:
if (inputMap) {
inputMapFile = inputMap;
}
}
// source map placed in external file
if (inputMapFile) {
inputMapContent = fs.readFileSync(inputMapFile, 'utf8');
}
return {
input: inputMapContent,
inputFile: inputMapFile || (inputMapContent ? '<inline>' : false),
output: outputMap,
outputFile: outputMapFile
};
}
function processCommentsOption(value) {
switch (value) {
case 'exclamation':
case 'first-exclamation':
case 'none':
return value;
}
console.error('Wrong value for `comments` option: %s', value);
process.exit(2);
}
function processOptions(options, args) {
var inputFile = options.input || args[0];
var outputFile = options.output;
var usageFile = options.usage;
var usageData = false;
var sourceMap = options.sourceMap;
var inputSourceMap = options.inputSourceMap;
var declarationList = options.declarationList;
var restructure = Boolean(options.restructure);
var forceMediaMerge = Boolean(options.forceMediaMerge);
var comments = processCommentsOption(options.comments);
var debug = options.debug;
var statistics = options.stat;
var watch = options.watch;
if (process.stdin.isTTY && !inputFile && !outputFile) {
return null;
}
if (!inputFile) {
inputFile = '<stdin>';
} else {
inputFile = path.resolve(process.cwd(), inputFile);
}
if (outputFile) {
outputFile = path.resolve(process.cwd(), outputFile);
}
if (usageFile) {
if (!fs.existsSync(usageFile)) {
console.error('Usage data file doesn\'t found (%s)', usageFile);
process.exit(2);
}
usageData = fs.readFileSync(usageFile, 'utf-8');
try {
usageData = JSON.parse(usageData);
} catch (e) {
console.error('Usage data parse error (%s)', usageFile);
process.exit(2);
}
}
return {
inputFile: inputFile,
outputFile: outputFile,
usageData: usageData,
sourceMap: sourceMap,
inputSourceMap: inputSourceMap,
declarationList: declarationList,
restructure: restructure,
forceMediaMerge: forceMediaMerge,
comments: comments,
statistics: statistics,
debug: debug,
watch: watch
};
}
function minifyStream(options) {
var inputStream = options.inputFile !== '<stdin>'
? fs.createReadStream(options.inputFile)
: process.stdin;
readFromStream(inputStream, function(source) {
var time = process.hrtime();
var mem = process.memoryUsage().heapUsed;
var relInputFilename = path.relative(process.cwd(), options.inputFile);
var sourceMap = resolveSourceMap(
source,
options.inputSourceMap,
options.sourceMap,
options.inputFile,
options.outputFile
);
var sourceMapAnnotation = '';
var result;
// main action
try {
var minifyFunc = options.declarationList ? csso.minifyBlock : csso.minify;
result = minifyFunc(source, {
filename: unixPathname(relInputFilename),
sourceMap: Boolean(sourceMap.output),
usage: options.usageData,
restructure: options.restructure,
forceMediaMerge: options.forceMediaMerge,
comments: options.comments,
debug: options.debug
});
// for backward capability minify returns a string
if (typeof result === 'string') {
result = {
css: result,
map: null
};
}
} catch (e) {
if (e.parseError) {
showParseError(source, options.inputFile, e.parseError, e.message);
if (!options.debug) {
process.exit(2);
}
}
throw e;
}
if (sourceMap.output && result.map) {
// apply input map
if (sourceMap.input) {
result.map.applySourceMap(
new SourceMapConsumer(sourceMap.input),
unixPathname(relInputFilename)
);
}
// add source map to result
if (sourceMap.outputFile) {
// write source map to file
fs.writeFileSync(sourceMap.outputFile, result.map.toString(), 'utf-8');
sourceMapAnnotation = '\n' +
'/*# sourceMappingURL=' +
unixPathname(path.relative(options.outputFile ? path.dirname(options.outputFile) : process.cwd(), sourceMap.outputFile)) +
' */';
} else {
// inline source map
sourceMapAnnotation = '\n' +
'/*# sourceMappingURL=data:application/json;base64,' +
Buffer.from(result.map.toString()).toString('base64') +
' */';
}
result.css += sourceMapAnnotation;
}
// output result
if (options.outputFile) {
fs.writeFileSync(options.outputFile, result.css, 'utf-8');
} else {
console.log(result.css);
}
// output statistics
if (options.statistics) {
var timeDiff = process.hrtime(time);
showStat(
relInputFilename,
source.length,
result.css.length,
sourceMap.inputFile,
sourceMapAnnotation.length,
parseInt(timeDiff[0] * 1e3 + timeDiff[1] / 1e6, 10),
process.memoryUsage().heapUsed - mem
);
}
});
}
var command = cli.create('csso', '[input]')
.version(require('csso/package.json').version)
.option('-i, --input <filename>', 'Input file')
.option('-o, --output <filename>', 'Output file (result outputs to stdout if not set)')
.option('-s, --source-map <destination>', 'Generate source map: none (default), inline, file or <filename>', 'none')
.option('-u, --usage <filename>', 'Usage data file')
.option('--input-source-map <source>', 'Input source map: none, auto (default) or <filename>', 'auto')
.option('-d, --declaration-list', 'Treat input as a declaration list')
.option('--no-restructure', 'Disable structural optimisations')
.option('--force-media-merge', 'Enable unsafe merge of @media rules')
.option('--comments <value>', 'Comments to keep: exclamation (default), first-exclamation or none', 'exclamation')
.option('--stat', 'Output statistics in stderr')
.option('--debug [level]', 'Output intermediate state of CSS during a compression', debugLevel, 0)
.option('--watch', 'Watch source file for changes')
.action(function(args) {
var options = processOptions(this.values, args);
if (options === null) {
this.showHelp();
return;
}
minifyStream(options);
// enable watch mode only when input is a file
if (options.watch && options.inputFile !== '<stdin>') {
// NOTE: require chokidar here to keep down start up time when --watch doesn't use
// (yep, chokidar adds a penalty ~0.2-0.3s on its init)
require('chokidar').watch(options.inputFile).on('change', function() {
minifyStream(options);
});
}
});
module.exports = {
run: command.run.bind(command),
isCliError: function(err) {
return err instanceof cli.Error;
}
};

43
node_modules/csso-cli/package.json generated vendored Normal file
View file

@ -0,0 +1,43 @@
{
"name": "csso-cli",
"version": "3.0.0",
"description": "Command line interface for CSSO",
"repository": "css/csso-cli",
"license": "MIT",
"author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
"keywords": [
"cli",
"css",
"minifier",
"minify",
"compress",
"optimisation"
],
"bin": {
"csso": "./bin/csso"
},
"main": "./index",
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"test": "mocha --reporter dot",
"codestyle": "eslint bin/* test index.js",
"codestyle-and-test": "npm run codestyle && npm test",
"travis": "npm run codestyle-and-test"
},
"dependencies": {
"chokidar": "^3.0.0",
"clap": "^1.0.9",
"csso": "^4.0.1",
"source-map": "^0.6.1"
},
"devDependencies": {
"eslint": "^5.11.0",
"mocha": "^5.2.0"
},
"files": [
"bin",
"index.js"
]
}