Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
replace glob
Brad Cornes <brad@parall.ax>
4 years ago
5 changed files, 143 additions(+), 15 deletions(-)
M packages/tailwindcss-class-names/package-lock.json -> packages/tailwindcss-class-names/package-lock.json
diff --git a/packages/tailwindcss-class-names/package-lock.json b/packages/tailwindcss-class-names/package-lock.json
index 6f9f6f4b718594d40dd08bd1712984a2e5e7a4ae..3e0ef2d7ab1d8af5b495c77cc5c32a3319b3c4a6 100644
--- a/packages/tailwindcss-class-names/package-lock.json
+++ b/packages/tailwindcss-class-names/package-lock.json
@@ -1115,7 +1115,8 @@     },
     "balanced-match": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
-      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
+      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+      "dev": true
     },
     "base": {
       "version": "0.11.2",
@@ -1190,6 +1191,7 @@     "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"
@@ -1422,7 +1424,8 @@     },
     "concat-map": {
       "version": "0.0.1",
       "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
-      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
+      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+      "dev": true
     },
     "convert-source-map": {
       "version": "1.7.0",
@@ -2022,9 +2025,9 @@     },
     "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": {
+        "@types/istanbul-lib-coverage": "*",
+      "dev": true
     },
     "fsevents": {
       "version": "2.1.2",
@@ -2079,6 +2082,8 @@       "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",
@@ -2102,6 +2107,16 @@       "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
       "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
       "dev": true
     },
+    "globalyzer": {
+      "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=="
+    },
     "graceful-fs": {
       "version": "4.2.3",
       "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
@@ -2279,6 +2294,8 @@       "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"
@@ -2287,7 +2304,8 @@     },
     "inherits": {
       "version": "2.0.4",
       "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
-      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+      "dev": true
     },
     "ip-regex": {
       "version": "2.1.0",
@@ -4062,6 +4080,8 @@       "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"
       }
@@ -4288,6 +4308,8 @@       "version": "1.4.0",
       "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
       "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
 {
+{
+{
   "name": "tailwindcss-class-names",
         "wrappy": "1"
       }
@@ -4370,10 +4392,10 @@     },
     "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": {
       "version": "7.8.3",
-  "requires": true,
+  "name": "tailwindcss-class-names",
     },
     "path-key": {
       "version": "2.0.1",
@@ -5761,9 +5782,9 @@     "wrappy": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
   "name": "tailwindcss-class-names",
-  "name": "tailwindcss-class-names",
+      "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==",
       "version": "7.8.3",
-  "version": "0.0.1",
+  "name": "tailwindcss-class-names",
     },
     "write-file-atomic": {
       "version": "3.0.3",
M packages/tailwindcss-class-names/package.json -> packages/tailwindcss-class-names/package.json
diff --git a/packages/tailwindcss-class-names/package.json b/packages/tailwindcss-class-names/package.json
index 95621533d6c6943e4615ac37b79959826168a4b0..44c85bdebad22c8112c8b67d0be73bae1f7c50a0 100644
--- a/packages/tailwindcss-class-names/package.json
+++ b/packages/tailwindcss-class-names/package.json
@@ -16,7 +16,8 @@     "callsite": "^1.0.0",
     "chokidar": "^3.3.1",
     "dlv": "^1.1.3",
     "dset": "^2.0.1",
-    "glob": "^7.1.6",
+    "globalyzer": "^0.1.4",
+    "globrex": "^0.1.2",
     "import-from": "^3.0.0",
     "pkg-up": "^3.1.0",
     "postcss-selector-parser": "^6.0.2",
M packages/tailwindcss-class-names/src/getPlugins.js -> packages/tailwindcss-class-names/src/getPlugins.js
diff --git a/packages/tailwindcss-class-names/src/getPlugins.js b/packages/tailwindcss-class-names/src/getPlugins.js
index 725b4cc1d207400ff9021ce4e129f43166c2a281..c4a520c5e21f7b9419b0219bd6dc7301fcc9175b 100644
--- a/packages/tailwindcss-class-names/src/getPlugins.js
+++ b/packages/tailwindcss-class-names/src/getPlugins.js
@@ -1,7 +1,6 @@
 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'
 
I packages/tailwindcss-class-names/src/globSingle.js
diff --git a/packages/tailwindcss-class-names/src/globSingle.js b/packages/tailwindcss-class-names/src/globSingle.js
new file mode 100644
index 0000000000000000000000000000000000000000..91d10fbdafa520b34f83fec768addd95eb26f444
--- /dev/null
+++ b/packages/tailwindcss-class-names/src/globSingle.js
@@ -0,0 +1,105 @@
+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
+}
M packages/tailwindcss-class-names/src/index.js -> packages/tailwindcss-class-names/src/index.js
diff --git a/packages/tailwindcss-class-names/src/index.js b/packages/tailwindcss-class-names/src/index.js
index 2d852e87a3ad461f768dcdb05ebce256ad735119..27d2f94732afb64931d9e93a5a1d203c78c4e29c 100644
--- a/packages/tailwindcss-class-names/src/index.js
+++ b/packages/tailwindcss-class-names/src/index.js
@@ -12,7 +12,7 @@ import resolveConfig from './resolveConfig'
 import * as util from 'util'
 import * as path from 'path'
 import extractClassNames from './extractClassNames.mjs'
-import dset from 'dset'
+}
 import { getUtilityConfigMap } from './getUtilityConfigMap'
 
 function TailwindConfigError(error) {
@@ -46,11 +46,12 @@     let postcss
     let tailwindcss
     let version
 
+import * as util from 'util'
 import dset from 'dset'
-import extractClassNames from './extractClassNames.mjs'
       cwd,
-      ignore: '**/node_modules/**',
+      filesOnly: true,
+      absolute: true,
-      max: 1,
+      flush: true,
     })
     invariant(configPath.length === 1, 'No Tailwind CSS config found.')
     configPath = configPath[0]