mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
12
node_modules/detective-postcss/.travis.yml
generated
vendored
Normal file
12
node_modules/detective-postcss/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'stable'
|
||||
sudo: required
|
||||
before_install: # if "install" is overridden
|
||||
# Repo for Yarn
|
||||
- sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
|
||||
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq yarn
|
||||
cache:
|
||||
yarn: true
|
21
node_modules/detective-postcss/LICENSE
generated
vendored
Normal file
21
node_modules/detective-postcss/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Joscha Feth
|
||||
|
||||
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.
|
30
node_modules/detective-postcss/README.md
generated
vendored
Normal file
30
node_modules/detective-postcss/README.md
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
# node-detective-postcss [](https://travis-ci.org/joscha/node-detective-postcss)
|
||||
|
||||
> Find the dependencies of a CSS file (postCSS dialects)
|
||||
|
||||
Supports `@import` and [`@value ... from`](https://github.com/css-modules/postcss-icss-values).
|
||||
|
||||
`npm install --save detective-postcss`
|
||||
|
||||
It's the CSS (PostCSS dialect) counterpart to [detective](https://github.com/substack/node-detective), [detective-amd](https://github.com/mrjoelkemp/node-detective-amd), [detective-es6](https://github.com/mrjoelkemp/node-detective-es6), [detective-sass](https://github.com/mrjoelkemp/node-detective-sass), [detective-scss](https://github.com/mrjoelkemp/node-detective-scss).
|
||||
|
||||
* The AST is generated using [postcss](https://github.com/postcss/postcss) and [postcss-values-parser](https://github.com/shellscape/postcss-values-parser).
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
import fs from 'fs';
|
||||
import detective from 'detective-postcss';
|
||||
|
||||
const content = fs.readFileSync('styles.css', 'utf8');
|
||||
|
||||
// list of imported file names (ex: 'bla.css', 'foo.css', etc.)
|
||||
const dependencies = detective(content);
|
||||
|
||||
// or to also detect any url() references to images, fonts, etc.
|
||||
const allDependencies = detective(content, { url: true });
|
||||
```
|
||||
|
||||
### License
|
||||
|
||||
Apache 2.0
|
9
node_modules/detective-postcss/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/detective-postcss/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
declare function detective(src: any, options?: detective.Options): any[];
|
||||
declare namespace detective {
|
||||
interface Options {
|
||||
url: boolean;
|
||||
}
|
||||
class MalformedCssError {
|
||||
}
|
||||
}
|
||||
export = detective;
|
93
node_modules/detective-postcss/dist/index.js
generated
vendored
Normal file
93
node_modules/detective-postcss/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
var d = require("debug");
|
||||
var postcss_1 = require("postcss");
|
||||
var postCssValuesParser = require("postcss-values-parser");
|
||||
var isUrl = require("is-url");
|
||||
var debug = d('detective-postcss');
|
||||
function detective(src, options) {
|
||||
if (options === void 0) { options = { url: false }; }
|
||||
var references = [];
|
||||
var root;
|
||||
try {
|
||||
root = postcss_1.parse(src);
|
||||
}
|
||||
catch (e) {
|
||||
throw new detective.MalformedCssError();
|
||||
}
|
||||
root.walkAtRules(function (rule) {
|
||||
var file = null;
|
||||
if (isImportRule(rule)) {
|
||||
var firstNode = parseValue(rule.params).first;
|
||||
file = getValueOrUrl(firstNode);
|
||||
if (file) {
|
||||
debug("found %s of %s", '@import', file);
|
||||
}
|
||||
}
|
||||
if (isValueRule(rule)) {
|
||||
var lastNode = parseValue(rule.params).last;
|
||||
if (isFrom(lastNode.prev())) {
|
||||
file = getValueOrUrl(lastNode);
|
||||
if (file) {
|
||||
debug("found %s of %s", '@value with import', file);
|
||||
}
|
||||
}
|
||||
if (options.url && isUrlNode(lastNode)) {
|
||||
file = getValueOrUrl(lastNode);
|
||||
if (file) {
|
||||
debug("found %s of %s", 'url() with import', file);
|
||||
}
|
||||
}
|
||||
}
|
||||
file && references.push(file);
|
||||
});
|
||||
if (options.url) {
|
||||
root.walkDecls(function (decl) {
|
||||
var nodes = parseValue(decl.value).nodes;
|
||||
var files = nodes.filter(isUrlNode).map(getValueOrUrl);
|
||||
if (files) {
|
||||
files.forEach(function (file) {
|
||||
return debug("found %s of %s", 'url() with import', file);
|
||||
});
|
||||
references = references.concat(files);
|
||||
}
|
||||
});
|
||||
}
|
||||
return references;
|
||||
}
|
||||
function parseValue(value) {
|
||||
return postCssValuesParser(value).parse().first;
|
||||
}
|
||||
function getValueOrUrl(node) {
|
||||
var ret;
|
||||
if (isUrlNode(node)) {
|
||||
// ['(', 'file', ')']
|
||||
ret = node.nodes[1].value;
|
||||
}
|
||||
else {
|
||||
ret = node.value;
|
||||
}
|
||||
// is-url sometimes gets data: URLs wrong
|
||||
return !isUrl(ret) && !ret.startsWith('data:') && ret;
|
||||
}
|
||||
function isUrlNode(node) {
|
||||
return node.type === 'func' && node.value === 'url';
|
||||
}
|
||||
function isValueRule(rule) {
|
||||
return rule.name === 'value';
|
||||
}
|
||||
function isImportRule(rule) {
|
||||
return rule.name === 'import';
|
||||
}
|
||||
function isFrom(node) {
|
||||
return node.type == 'word' && node.value === 'from';
|
||||
}
|
||||
(function (detective) {
|
||||
var MalformedCssError = /** @class */ (function () {
|
||||
function MalformedCssError() {
|
||||
}
|
||||
return MalformedCssError;
|
||||
}());
|
||||
detective.MalformedCssError = MalformedCssError;
|
||||
MalformedCssError.prototype = Object.create(Error.prototype);
|
||||
})(detective || (detective = {}));
|
||||
module.exports = detective;
|
95
node_modules/detective-postcss/package.json
generated
vendored
Normal file
95
node_modules/detective-postcss/package.json
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"detective-postcss@3.0.1",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "detective-postcss@3.0.1",
|
||||
"_id": "detective-postcss@3.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-tfTS2GdpUal5NY0aCqI4dpEy8Xfr88AehYKB0iBIZvo8y2g3UsrcDnrp9PR2FbzoW7xD5Rip3NJW7eCSvtqdUw==",
|
||||
"_location": "/detective-postcss",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "detective-postcss@3.0.1",
|
||||
"name": "detective-postcss",
|
||||
"escapedName": "detective-postcss",
|
||||
"rawSpec": "3.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/precinct"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/detective-postcss/-/detective-postcss-3.0.1.tgz",
|
||||
"_spec": "3.0.1",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"author": {
|
||||
"name": "Joscha Feth",
|
||||
"email": "joscha@feth.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/joscha/node-detective-postcss/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"is-url": "^1.2.4",
|
||||
"postcss": "^7.0.2",
|
||||
"postcss-values-parser": "^1.5.0"
|
||||
},
|
||||
"description": "Detective to find dependents of CSS (PostCSS dialect)",
|
||||
"devDependencies": {
|
||||
"@types/debug": "^0.0.30",
|
||||
"@types/is-url": "^1.2.28",
|
||||
"@types/jest": "^23.3.1",
|
||||
"husky": "^0.14.3",
|
||||
"jest": "^23.4.2",
|
||||
"lint-staged": "^7.2.0",
|
||||
"prettier": "^1.14.0",
|
||||
"ts-jest": "^23.1.2",
|
||||
"typescript": "^3.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/joscha/node-detective-postcss#readme",
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": "ts-jest"
|
||||
},
|
||||
"testEnvironment": "node",
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx",
|
||||
"json",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"lint-staged": {
|
||||
"*.{ts,json,md}": [
|
||||
"prettier --write --tab-width 4 --single-quote --trailing-comma es5 \"*.ts\"",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"name": "detective-postcss",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/joscha/node-detective-postcss.git"
|
||||
},
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"prepare": "tsc --outDir dist --declaration --declarationDir dist",
|
||||
"test": "jest --ci",
|
||||
"test:watch": "jest --watch --notify"
|
||||
},
|
||||
"typings": "dist/index.d.ts",
|
||||
"version": "3.0.1"
|
||||
}
|
98
node_modules/detective-postcss/src/index.ts
generated
vendored
Normal file
98
node_modules/detective-postcss/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
import * as d from 'debug';
|
||||
import { parse, AtRule } from 'postcss';
|
||||
import * as postCssValuesParser from 'postcss-values-parser';
|
||||
import isUrl = require('is-url');
|
||||
|
||||
const debug = d('detective-postcss');
|
||||
|
||||
function detective(src, options: detective.Options = { url: false }) {
|
||||
let references = [];
|
||||
let root;
|
||||
try {
|
||||
root = parse(src);
|
||||
} catch (e) {
|
||||
throw new detective.MalformedCssError();
|
||||
}
|
||||
root.walkAtRules(rule => {
|
||||
let file = null;
|
||||
if (isImportRule(rule)) {
|
||||
const firstNode = parseValue(rule.params).first;
|
||||
file = getValueOrUrl(firstNode);
|
||||
if (file) {
|
||||
debug(`found %s of %s`, '@import', file);
|
||||
}
|
||||
}
|
||||
if (isValueRule(rule)) {
|
||||
const lastNode = parseValue(rule.params).last;
|
||||
if (isFrom(lastNode.prev())) {
|
||||
file = getValueOrUrl(lastNode);
|
||||
if (file) {
|
||||
debug(`found %s of %s`, '@value with import', file);
|
||||
}
|
||||
}
|
||||
if (options.url && isUrlNode(lastNode)) {
|
||||
file = getValueOrUrl(lastNode);
|
||||
if (file) {
|
||||
debug(`found %s of %s`, 'url() with import', file);
|
||||
}
|
||||
}
|
||||
}
|
||||
file && references.push(file);
|
||||
});
|
||||
if (options.url) {
|
||||
root.walkDecls(decl => {
|
||||
const { nodes } = parseValue(decl.value);
|
||||
const files = nodes.filter(isUrlNode).map(getValueOrUrl);
|
||||
if (files) {
|
||||
files.forEach(file =>
|
||||
debug(`found %s of %s`, 'url() with import', file)
|
||||
);
|
||||
references = references.concat(files);
|
||||
}
|
||||
});
|
||||
}
|
||||
return references;
|
||||
}
|
||||
|
||||
function parseValue(value: string) {
|
||||
return postCssValuesParser(value).parse().first;
|
||||
}
|
||||
|
||||
function getValueOrUrl(node: postCssValuesParser.Node) {
|
||||
let ret;
|
||||
if (isUrlNode(node)) {
|
||||
// ['(', 'file', ')']
|
||||
ret = node.nodes[1].value;
|
||||
} else {
|
||||
ret = node.value;
|
||||
}
|
||||
// is-url sometimes gets data: URLs wrong
|
||||
return !isUrl(ret) && !ret.startsWith('data:') && ret;
|
||||
}
|
||||
|
||||
function isUrlNode(node: postCssValuesParser.Node) {
|
||||
return node.type === 'func' && node.value === 'url';
|
||||
}
|
||||
|
||||
function isValueRule(rule: AtRule) {
|
||||
return rule.name === 'value';
|
||||
}
|
||||
|
||||
function isImportRule(rule: AtRule) {
|
||||
return rule.name === 'import';
|
||||
}
|
||||
|
||||
function isFrom(node: postCssValuesParser.Node) {
|
||||
return node.type == 'word' && node.value === 'from';
|
||||
}
|
||||
|
||||
namespace detective {
|
||||
export interface Options {
|
||||
url: boolean;
|
||||
}
|
||||
|
||||
export class MalformedCssError {}
|
||||
MalformedCssError.prototype = Object.create(Error.prototype);
|
||||
}
|
||||
|
||||
export = detective;
|
26
node_modules/detective-postcss/src/postcss-values-parser.d.ts
generated
vendored
Normal file
26
node_modules/detective-postcss/src/postcss-values-parser.d.ts
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// incomplete declarations for the postcss-values-parser
|
||||
declare module 'postcss-values-parser' {
|
||||
namespace parser {
|
||||
interface Node {
|
||||
first?: parser.Node;
|
||||
last?: parser.Node;
|
||||
prev?(): parser.Node;
|
||||
type:
|
||||
| 'atword'
|
||||
| 'colon'
|
||||
| 'comma'
|
||||
| 'comment'
|
||||
| 'func'
|
||||
| 'number'
|
||||
| 'operator'
|
||||
| 'paren'
|
||||
| 'string'
|
||||
| 'unicoderange'
|
||||
| 'word';
|
||||
value: string;
|
||||
nodes?: Node[];
|
||||
}
|
||||
}
|
||||
function parser(str: string): { parse(): parser.Node };
|
||||
export = parser;
|
||||
}
|
159
node_modules/detective-postcss/tests/index.spec.ts
generated
vendored
Normal file
159
node_modules/detective-postcss/tests/index.spec.ts
generated
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
import detective = require('../src');
|
||||
|
||||
function assert(source: string, deps: string[], options?: detective.Options) {
|
||||
expect(detective(source, options)).toEqual(deps);
|
||||
}
|
||||
|
||||
describe('node-detective-postcss', () => {
|
||||
describe('@import', () => {
|
||||
it('detects simple imports', () => {
|
||||
assert('@import "foo.css"', ['foo.css']);
|
||||
});
|
||||
|
||||
describe('url()', () => {
|
||||
it('works with url()', () => {
|
||||
assert('@import url("navigation.css");', ['navigation.css']);
|
||||
});
|
||||
|
||||
it('works with single quotes', () => {
|
||||
assert("@import url('navigation.css');", ['navigation.css']);
|
||||
});
|
||||
|
||||
it('works with no quotes', () => {
|
||||
assert('@import url(navigation.css);', ['navigation.css']);
|
||||
});
|
||||
});
|
||||
|
||||
it('detects multiple imports', () => {
|
||||
assert('@import "1.css"; @import "2.css"; @import "3.css"', [
|
||||
'1.css',
|
||||
'2.css',
|
||||
'3.css',
|
||||
]);
|
||||
});
|
||||
|
||||
it('ignores media', () => {
|
||||
assert('@import "printstyle.css" print;', ['printstyle.css']);
|
||||
});
|
||||
|
||||
it('ignores media query', () => {
|
||||
assert('@import "bar.css" (min-width: 25em);', ['bar.css']);
|
||||
});
|
||||
|
||||
it('ignores both', () => {
|
||||
assert('@import "mobstyle.css" screen and (max-width: 768px);', [
|
||||
'mobstyle.css',
|
||||
]);
|
||||
});
|
||||
|
||||
it('ignores URLs', () => {
|
||||
assert(
|
||||
"@import url('https://fonts.googleapis.com/css?family=Roboto:300,400');",
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
it('does not touch the paths', () => {
|
||||
assert('@import "../../././bla.css"', ['../../././bla.css']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('@value', () => {
|
||||
// see https://github.com/css-modules/postcss-icss-values
|
||||
it('extracts from single values', () => {
|
||||
assert("@value primary from 'colors.css';", ['colors.css']);
|
||||
});
|
||||
|
||||
it('works with url()', () => {
|
||||
assert("@value primary from url('colors.css');", ['colors.css']);
|
||||
});
|
||||
|
||||
it('extracts from multiple values', () => {
|
||||
assert("@value primary, secondary from 'colors.css';", [
|
||||
'colors.css',
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with aliases', () => {
|
||||
assert(
|
||||
"@value small as bp-small, large as bp-large from 'breakpoints.css';",
|
||||
['breakpoints.css']
|
||||
);
|
||||
});
|
||||
|
||||
it('works with grouped aliases', () => {
|
||||
assert(
|
||||
"@value (small as t-small, large as t-large) from 'typo.css';",
|
||||
['typo.css']
|
||||
);
|
||||
});
|
||||
|
||||
it('leaves simple definitions alone', () => {
|
||||
assert('@value mine: #fff;', []);
|
||||
});
|
||||
|
||||
it('leaves calculated definitions alone', () => {
|
||||
assert('@value mine: calc(1px + 4px)', []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('declarations', () => {
|
||||
it('ignores url() by default', () => {
|
||||
assert('.x { background: url(bla.png) }', []);
|
||||
});
|
||||
|
||||
it('filters out url() for direct usages', () => {
|
||||
assert('.x { background: url(bla.png) }', ['bla.png'], {
|
||||
url: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('filters out url() for deeper nested ones', () => {
|
||||
assert(
|
||||
".x { list-style: lower-roman url('../img/shape.png') outside; }",
|
||||
['../img/shape.png'],
|
||||
{ url: true }
|
||||
);
|
||||
});
|
||||
|
||||
it('finds url() in cursor definitions', () => {
|
||||
assert(
|
||||
'.x { cursor: url(cursor1.png) 4 12, auto; }',
|
||||
['cursor1.png'],
|
||||
{ url: true }
|
||||
);
|
||||
});
|
||||
|
||||
it('finds url() in @font-face', () => {
|
||||
assert(
|
||||
'@font-face { font-family: myFirstFont; src: url(sansation_light.woff); }',
|
||||
['sansation_light.woff'],
|
||||
{ url: true }
|
||||
);
|
||||
});
|
||||
|
||||
it('finds url() in @value definitions', () => {
|
||||
assert('@value x: url(bummer.png)', ['bummer.png'], { url: true });
|
||||
});
|
||||
|
||||
it('ignores base64 data: urls', () => {
|
||||
assert(
|
||||
'.x { background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}',
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
it('ignores SVG data: urls', () => {
|
||||
const css = `svg {
|
||||
-webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 32 32" width="32" height="32" xmlns="http://www.w3.org/2000/svg"><defs><mask id="mask"><rect x="0" y="0" width="32" height="32" fill="#fff"/><rect x="14" y="-10" width="40" height="20" rx="10" fill="#000"/></mask></defs><rect x="0" y="0" width="32" height="32" mask="url(#mask)"/></svg>');
|
||||
}`;
|
||||
assert(css, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('error handling', () => {
|
||||
it('works for broken CSS', () => {
|
||||
expect(() => detective('--')).toThrow(detective.MalformedCssError);
|
||||
});
|
||||
});
|
||||
});
|
3
node_modules/detective-postcss/tsconfig.json
generated
vendored
Normal file
3
node_modules/detective-postcss/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"include": ["src/**/*"]
|
||||
}
|
3738
node_modules/detective-postcss/yarn.lock
generated
vendored
Normal file
3738
node_modules/detective-postcss/yarn.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user