This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

7
node_modules/sass-graph/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2014 Michael Mifsud
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.

122
node_modules/sass-graph/bin/sassgraph generated vendored Normal file
View File

@@ -0,0 +1,122 @@
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var command, directory, file;
var yargs = require('yargs')
.usage('Usage: $0 <command> [options] <dir> [file]')
// .demand(1)
.command('ancestors', 'Output the ancestors')
.command('descendents', 'Output the descendents')
.example('$0 ancestors -I src src/ src/_footer.scss', 'outputs the ancestors of src/_footer.scss')
.option('I', {
alias: 'load-path',
default: [process.cwd()],
describe: 'Add directories to the sass load path',
type: 'array',
})
.option('e', {
alias: 'extensions',
default: ['scss', 'sass'],
describe: 'File extensions to include in the graph',
type: 'array',
})
.option('f', {
alias: 'follow',
default: false,
describe: 'Follow symbolic links',
type: 'bool',
})
.option('j', {
alias: 'json',
default: false,
describe: 'Output the index in json',
type: 'bool',
})
.version()
.alias('v', 'version')
.help('h')
.alias('h', 'help');
var argv = yargs.argv;
if (argv._.length === 0) {
yargs.showHelp();
process.exit(1);
}
if (['ancestors', 'descendents'].indexOf(argv._[0]) !== -1) {
command = argv._.shift();
}
if (argv._.length && path.extname(argv._[0]) === '') {
directory = argv._.shift();
}
if (argv._.length && path.extname(argv._[0])) {
file = argv._.shift();
}
try {
if (!directory) {
throw new Error('Missing directory');
}
if (!command && !argv.json) {
throw new Error('Missing command');
}
if (!file && (command === 'ancestors' || command === 'descendents')) {
throw new Error(command + ' command requires a file');
}
var loadPaths = argv.loadPath;
if(process.env.SASS_PATH) {
loadPaths = loadPaths.concat(process.env.SASS_PATH.split(/:/).map(function(f) {
return path.resolve(f);
}));
}
var graph = require('../').parseDir(directory, {
extensions: argv.extensions,
loadPaths: loadPaths,
follow: argv.follow,
});
if(argv.json) {
console.log(JSON.stringify(graph.index, null, 4));
process.exit(0);
}
if (command === 'ancestors') {
graph.visitAncestors(path.resolve(file), function(f) {
console.log(f);
});
}
if (command === 'descendents') {
graph.visitDescendents(path.resolve(file), function(f) {
console.log(f);
});
}
} catch(e) {
if (e.code === 'ENOENT') {
console.error('Error: no such file or directory "' + e.path + '"');
}
else {
console.log('Error: ' + e.message);
}
// console.log(e.stack);
process.exit(1);
}

41
node_modules/sass-graph/package.json generated vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "sass-graph",
"version": "4.0.1",
"description": "Parse sass files and extract a graph of imports",
"license": "MIT",
"repository": "xzyfer/sass-graph",
"author": "xzyfer",
"main": "sass-graph.js",
"directories": {
"bin": "./bin"
},
"scripts": {
"test": "nyc mocha",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"keywords": [
"sass",
"graph"
],
"dependencies": {
"glob": "^7.0.0",
"lodash": "^4.17.11",
"scss-tokenizer": "^0.4.3",
"yargs": "^17.2.1"
},
"devDependencies": {
"assert": "^1.3.0",
"chai": "^4.1.2",
"coveralls": "^3.0.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0"
},
"engines": {
"node": ">=12"
},
"files": [
"bin",
"parse-imports.js",
"sass-graph.js"
]
}

64
node_modules/sass-graph/parse-imports.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
var tokenizer = require('scss-tokenizer');
function parseImports(content, isIndentedSyntax) {
var tokens = tokenizer.tokenize(content);
var results = [];
var tmp = '';
var inImport = false;
var inParen = false;
var prevToken = tokens[0];
var i, token;
for (i = 1; i < tokens.length; i++) {
token = tokens[i];
if (inImport && !inParen && token[0] === 'string') {
results.push(token[1]);
}
else if (token[1] === 'import' && prevToken[1] === '@') {
if (inImport && !isIndentedSyntax) {
throw new Error('Encountered invalid @import syntax.');
}
inImport = true;
}
else if (inImport && !inParen && (token[0] === 'ident' || token[0] === '/')) {
tmp += token[1];
}
else if (inImport && !inParen && (token[0] === 'space' || token[0] === 'newline')) {
if (tmp !== '') {
results.push(tmp);
tmp = '';
if (isIndentedSyntax) {
inImport = false;
}
}
}
else if (inImport && token[0] === ';') {
inImport = false;
if (tmp !== '') {
results.push(tmp);
tmp = '';
}
}
else if (inImport && token[0] === '(') {
inParen = true;
tmp = '';
}
else if (inParen && token[0] === ')') {
inParen = false;
}
prevToken = token;
}
if (tmp !== '') {
results.push(tmp);
}
return results;
}
module.exports = parseImports;

130
node_modules/sass-graph/readme.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# Sass Graph
Parses Sass files in a directory and exposes a graph of dependencies
[![Build Status](https://travis-ci.org/xzyfer/sass-graph.svg?branch=master)](https://travis-ci.org/xzyfer/sass-graph)
[![Coverage Status](https://coveralls.io/repos/github/xzyfer/sass-graph/badge.svg?branch=master)](https://coveralls.io/github/xzyfer/sass-graph?branch=master)
[![npm version](https://badge.fury.io/js/sass-graph.svg)](http://badge.fury.io/js/sass-graph)
[![Dependency Status](https://david-dm.org/xzyfer/sass-graph.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph)
[![devDependency Status](https://david-dm.org/xzyfer/sass-graph/dev-status.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph#info=devDependencies)
## Install
Install with [npm](https://npmjs.org/package/sass-graph)
```
npm install --save-dev sass-graph
```
## Usage
Usage as a Node library:
```js
var sassGraph = require('./sass-graph');
```
Usage as a command line tool:
The command line tool will parse a graph and then either display ancestors, descendents or both.
```
$ ./bin/sassgraph --help
Usage: bin/sassgraph <command> [options] <dir> [file]
Commands:
ancestors Output the ancestors
descendents Output the descendents
Options:
-I, --load-path Add directories to the sass load path
-e, --extensions File extensions to include in the graph
-j, --json Output the index in json
-h, --help Show help
-v, --version Show version number
Examples:
./bin/sassgraph descendents test/fixtures test/fixtures/a.scss
/path/to/test/fixtures/b.scss
/path/to/test/fixtures/_c.scss
```
## API
#### parseDir
Parses a directory and builds a dependency graph of all requested file extensions.
#### parseFile
Parses a file and builds its dependency graph.
## Options
#### loadPaths
Type: `Array`
Default: `[process.cwd]`
Directories to use when resolved `@import` directives.
#### extensions
Type: `Array`
Default: `['scss', 'sass']`
File types to be parsed.
#### follow
Type: `Boolean`
Default: `false`
Follow symbolic links.
#### exclude
Type: `RegExp`
Default: `undefined`
Exclude files matching regular expression.
## Example
```js
var sassGraph = require('./sass-graph');
console.log(sassGraph.parseDir('test/fixtures'));
//{ index: {,
// '/path/to/test/fixtures/a.scss': {
// imports: ['b.scss'],
// importedBy: [],
// },
// '/path/to/test/fixtures/b.scss': {
// imports: ['_c.scss'],
// importedBy: ['a.scss'],
// },
// '/path/to/test/fixtures/_c.scss': {
// imports: [],
// importedBy: ['b/scss'],
// },
//}}
```
## Running Mocha tests
You can run the tests by executing the following commands:
```
npm install
npm test
```
## Authors
Sass graph was originally written by [Lachlan Donald](http://lachlan.me).
It is now maintained by [Michael Mifsud](http://twitter.com/xzyfer).
## License
MIT

171
node_modules/sass-graph/sass-graph.js generated vendored Normal file
View File

@@ -0,0 +1,171 @@
'use strict';
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var glob = require('glob');
var parseImports = require('./parse-imports');
// resolve a sass module to a path
function resolveSassPath(sassPath, loadPaths, extensions) {
// trim sass file extensions
var re = new RegExp('(\.('+extensions.join('|')+'))$', 'i');
var sassPathName = sassPath.replace(re, '');
// check all load paths
var i, j, length = loadPaths.length, scssPath, partialPath;
for (i = 0; i < length; i++) {
for (j = 0; j < extensions.length; j++) {
scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);
try {
if (fs.lstatSync(scssPath).isFile()) {
return scssPath;
}
} catch (e) {}
}
// special case for _partials
for (j = 0; j < extensions.length; j++) {
scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);
partialPath = path.join(path.dirname(scssPath), '_' + path.basename(scssPath));
try {
if (fs.lstatSync(partialPath).isFile()) {
return partialPath;
}
} catch (e) {}
}
}
// File to import not found or unreadable so we assume this is a custom import
return false;
}
function Graph(options, dir) {
this.dir = dir;
this.extensions = options.extensions || [];
this.exclude = options.exclude instanceof RegExp ? options.exclude : null;
this.index = {};
this.follow = options.follow || false;
this.loadPaths = _(options.loadPaths).map(function(p) {
return path.resolve(p);
}).value();
if (dir) {
var graph = this;
_.each(glob.sync(dir+'/**/*.@('+this.extensions.join('|')+')', { dot: true, nodir: true, follow: this.follow }), function(file) {
try {
graph.addFile(path.resolve(file));
} catch (e) {}
});
}
}
// add a sass file to the graph
Graph.prototype.addFile = function(filepath, parent) {
if (this.exclude !== null && this.exclude.test(filepath)) return;
var entry = this.index[filepath] = this.index[filepath] || {
imports: [],
importedBy: [],
modified: fs.statSync(filepath).mtime
};
var resolvedParent;
var isIndentedSyntax = path.extname(filepath) === '.sass';
var imports = parseImports(fs.readFileSync(filepath, 'utf-8'), isIndentedSyntax);
var cwd = path.dirname(filepath);
var i, length = imports.length, loadPaths, resolved;
for (i = 0; i < length; i++) {
loadPaths = _([cwd, this.dir]).concat(this.loadPaths).filter().uniq().value();
resolved = resolveSassPath(imports[i], loadPaths, this.extensions);
if (!resolved) continue;
// check exclcude regex
if (this.exclude !== null && this.exclude.test(resolved)) continue;
// recurse into dependencies if not already enumerated
if (!_.includes(entry.imports, resolved)) {
entry.imports.push(resolved);
this.addFile(fs.realpathSync(resolved), filepath);
}
}
// add link back to parent
if (parent) {
resolvedParent = _(parent).intersection(this.loadPaths).value();
if (resolvedParent) {
resolvedParent = parent.substr(parent.indexOf(resolvedParent));
} else {
resolvedParent = parent;
}
// check exclcude regex
if (!(this.exclude !== null && this.exclude.test(resolvedParent))) {
entry.importedBy.push(resolvedParent);
}
}
};
// visits all files that are ancestors of the provided file
Graph.prototype.visitAncestors = function(filepath, callback) {
this.visit(filepath, callback, function(err, node) {
if (err || !node) return [];
return node.importedBy;
});
};
// visits all files that are descendents of the provided file
Graph.prototype.visitDescendents = function(filepath, callback) {
this.visit(filepath, callback, function(err, node) {
if (err || !node) return [];
return node.imports;
});
};
// a generic visitor that uses an edgeCallback to find the edges to traverse for a node
Graph.prototype.visit = function(filepath, callback, edgeCallback, visited) {
filepath = fs.realpathSync(filepath);
var visited = visited || [];
if (!this.index.hasOwnProperty(filepath)) {
edgeCallback('Graph doesn\'t contain ' + filepath, null);
}
var edges = edgeCallback(null, this.index[filepath]);
var i, length = edges.length;
for (i = 0; i < length; i++) {
if (!_.includes(visited, edges[i])) {
visited.push(edges[i]);
callback(edges[i], this.index[edges[i]]);
this.visit(edges[i], callback, edgeCallback, visited);
}
}
};
function processOptions(options) {
return Object.assign({
loadPaths: [process.cwd()],
extensions: ['scss', 'sass'],
}, options);
}
module.exports.parseFile = function(filepath, options) {
if (fs.lstatSync(filepath).isFile()) {
filepath = path.resolve(filepath);
options = processOptions(options);
var graph = new Graph(options);
graph.addFile(filepath);
return graph;
}
// throws
};
module.exports.parseDir = function(dirpath, options) {
if (fs.lstatSync(dirpath).isDirectory()) {
dirpath = path.resolve(dirpath);
options = processOptions(options);
var graph = new Graph(options, dirpath);
return graph;
}
// throws
};