diff --git a/packages/tailwindcss-class-names/package-lock.json b/packages/tailwindcss-class-names/package-lock.json index 3e0ef2d7ab1d8af5b495c77cc5c32a3319b3c4a6..6f9f6f4b718594d40dd08bd1712984a2e5e7a4ae 100644 --- a/packages/tailwindcss-class-names/package-lock.json +++ b/packages/tailwindcss-class-names/package-lock.json @@ -1115,8 +1115,7 @@ }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "version": "7.8.3", + "integrity": "sha512-Eu3dysBzSAO1lD7cylZd/CVKdZZ1/43SF35iYBNV1Lvvn2Undp3Grwsv8PrzvbLhqwRzDd4zxrY4gsiHc+wygQ==", "name": "tailwindcss-class-names", }, "base": { @@ -1192,7 +1191,6 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1425,9 +1423,8 @@ }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "version": "7.8.3", "name": "tailwindcss-class-names", + "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", }, "convert-source-map": { "version": "1.7.0", @@ -2027,10 +2024,8 @@ }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", "name": "tailwindcss-class-names", - "dependencies": { - "dev": true + "@types/yargs": { }, "fsevents": { "version": "2.1.2", @@ -2085,8 +2080,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", { -{ -{ "name": "tailwindcss-class-names", "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -2111,17 +2104,6 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, "@babel/helper-validator-identifier": { -{ - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.4.tgz", - "integrity": "sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==" - }, - "globrex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", - "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==" - }, - "@babel/helper-validator-identifier": { "version": "7.8.3", "version": "4.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", @@ -2299,8 +2281,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", { -{ -{ "name": "tailwindcss-class-names", "once": "^1.3.0", "wrappy": "1" @@ -2309,9 +2289,8 @@ }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "version": "7.8.3", "name": "tailwindcss-class-names", + "version": "15.0.4", }, "ip-regex": { "version": "2.1.0", @@ -4086,8 +4065,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", { -{ -{ "name": "tailwindcss-class-names", "brace-expansion": "^1.1.7" } @@ -4314,8 +4291,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", { -{ -{ "name": "tailwindcss-class-names", "wrappy": "1" } @@ -4398,10 +4373,8 @@ }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", -{ + "integrity": "sha512-Eu3dysBzSAO1lD7cylZd/CVKdZZ1/43SF35iYBNV1Lvvn2Undp3Grwsv8PrzvbLhqwRzDd4zxrY4gsiHc+wygQ==", "dependencies": { - "@babel/helper-simple-access": { - "dev": true }, "path-key": { "version": "2.0.1", @@ -5789,8 +5762,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "name": "tailwindcss-class-names", - "@types/babel__core": { - "dev": true + "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==", }, "write-file-atomic": { "version": "3.0.3", diff --git a/packages/tailwindcss-class-names/package.json b/packages/tailwindcss-class-names/package.json index 44c85bdebad22c8112c8b67d0be73bae1f7c50a0..95621533d6c6943e4615ac37b79959826168a4b0 100644 --- a/packages/tailwindcss-class-names/package.json +++ b/packages/tailwindcss-class-names/package.json @@ -16,8 +16,7 @@ "callsite": "^1.0.0", "chokidar": "^3.3.1", "dlv": "^1.1.3", "dset": "^2.0.1", - "globalyzer": "^0.1.4", - "globrex": "^0.1.2", + "glob": "^7.1.6", "import-from": "^3.0.0", "pkg-up": "^3.1.0", "postcss-selector-parser": "^6.0.2", diff --git a/packages/tailwindcss-class-names/src/getPlugins.js b/packages/tailwindcss-class-names/src/getPlugins.js index c4a520c5e21f7b9419b0219bd6dc7301fcc9175b..725b4cc1d207400ff9021ce4e129f43166c2a281 100644 --- a/packages/tailwindcss-class-names/src/getPlugins.js +++ b/packages/tailwindcss-class-names/src/getPlugins.js @@ -1,6 +1,7 @@ import * as path from 'path' import stackTrace from 'stack-trace' import pkgUp from 'pkg-up' +import { glob } from './glob' import { isObject } from './isObject' import importFrom from 'import-from' diff --git a/packages/tailwindcss-class-names/src/globSingle.js b/packages/tailwindcss-class-names/src/globSingle.js deleted file mode 100644 index 91d10fbdafa520b34f83fec768addd95eb26f444..0000000000000000000000000000000000000000 --- a/packages/tailwindcss-class-names/src/globSingle.js +++ /dev/null @@ -1,105 +0,0 @@ -const fs = require('fs') -const globrex = require('globrex') -const { promisify } = require('util') -const globalyzer = require('globalyzer') -const { join, resolve, relative } = require('path') -const isHidden = /(^|[\\\/])\.[^\\\/\.]/g -const readdir = promisify(fs.readdir) -const stat = promisify(fs.stat) -let CACHE = {} - -async function walk(output, prefix, lexer, opts, dirname = '', level = 0) { - if (output.length === 1) return - const rgx = lexer.segments[level] - const dir = join(opts.cwd, prefix, dirname) - const files = await readdir(dir) - const { dot, filesOnly } = opts - - let i = 0, - len = files.length, - file - let fullpath, relpath, stats, isMatch - - for (; i < len; i++) { - file = files[i] - if (file === 'node_modules') continue - fullpath = join(dir, file) - relpath = dirname ? join(dirname, file) : file - if (!dot && isHidden.test(relpath)) continue - isMatch = lexer.regex.test(relpath) - - if ((stats = CACHE[relpath]) === void 0) { - CACHE[relpath] = stats = fs.lstatSync(fullpath) - } - - if (!stats.isDirectory()) { - if (isMatch) { - output.push(relative(opts.cwd, fullpath)) - return - } - continue - } - - if (rgx && !rgx.test(file)) continue - if (!filesOnly && isMatch) { - output.push(join(prefix, relpath)) - return - } - - await walk( - output, - prefix, - lexer, - opts, - relpath, - rgx && rgx.toString() !== lexer.globstar && ++level - ) - } -} - -/** - * Find files using bash-like globbing. - * All paths are normalized compared to node-glob. - * @param {String} str Glob string - * @param {String} [options.cwd='.'] Current working directory - * @param {Boolean} [options.dot=false] Include dotfile matches - * @param {Boolean} [options.absolute=false] Return absolute paths - * @param {Boolean} [options.filesOnly=false] Do not include folders if true - * @param {Boolean} [options.flush=false] Reset cache object - * @returns {Array} array containing matching files - */ -export async function globSingle(str, opts = {}) { - if (!str) return [] - - let glob = globalyzer(str) - - opts.cwd = opts.cwd || '.' - - if (!glob.isGlob) { - try { - let resolved = resolve(opts.cwd, str) - let dirent = await stat(resolved) - if (opts.filesOnly && !dirent.isFile()) return [] - - return opts.absolute ? [resolved] : [str] - } catch (err) { - if (err.code != 'ENOENT') throw err - - return [] - } - } - - if (opts.flush) CACHE = {} - - let matches = [] - const { path } = globrex(glob.glob, { - filepath: true, - globstar: true, - extended: true, - }) - - path.globstar = path.globstar.toString() - await walk(matches, glob.base, path, opts, '.', 0) - - return opts.absolute ? matches.map((x) => resolve(opts.cwd, x)) : matches -} diff --git a/packages/tailwindcss-class-names/src/index.js b/packages/tailwindcss-class-names/src/index.js index 27d2f94732afb64931d9e93a5a1d203c78c4e29c..2d852e87a3ad461f768dcdb05ebce256ad735119 100644 --- a/packages/tailwindcss-class-names/src/index.js +++ b/packages/tailwindcss-class-names/src/index.js @@ -12,6 +12,7 @@ import resolveConfig from './resolveConfig' import * as util from 'util' import * as path from 'path' import extractClassNames from './extractClassNames.mjs' +import Hook from './hook.mjs' import dset from 'dset' import { getUtilityConfigMap } from './getUtilityConfigMap' @@ -46,14 +47,13 @@ let postcss let tailwindcss let version -import dset from 'dset' import extractClassNames from './extractClassNames.mjs' -import dset from 'dset' import Hook from './hook.mjs' +import importFrom from 'import-from' import dset from 'dset' -import dlv from 'dlv' +import Hook from './hook.mjs' - absolute: true, + ignore: '**/node_modules/**', - flush: true, + max: 1, }) invariant(configPath.length === 1, 'No Tailwind CSS config found.') configPath = configPath[0]