@tailwindcss/cli 4.0.0-alpha.23 → 4.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import ge from"mri";function
|
|
2
|
+
import ge from"mri";function Q(e,t=process.argv.slice(2)){let i=ge(t),n={_:i._};for(let[s,{type:r,alias:l,default:a=r==="boolean"?!1:null}]of Object.entries(e)){if(n[s]=a,l){let o=l.slice(1);i[o]!==void 0&&(n[s]=J(i[o],r))}{let o=s.slice(2);i[o]!==void 0&&(n[s]=J(i[o],r))}}return n}function J(e,t){switch(t){case"string":return k(e);case"boolean":return F(e);case"number":return R(e);case"boolean | string":return F(e)??k(e);case"number | string":return R(e)??k(e);case"boolean | number":return F(e)??R(e);case"boolean | number | string":return F(e)??R(e)??k(e);default:throw new Error(`Unhandled type: ${t}`)}}function F(e){if(e===!0||e===!1)return e;if(e==="true")return!0;if(e==="false")return!1}function R(e){if(typeof e=="number")return e;{let t=Number(e);if(!Number.isNaN(t))return t}}function k(e){return`${e}`}import Ce from"@parcel/watcher";import{compile as Fe}from"@tailwindcss/node";import{clearRequireCache as Re}from"@tailwindcss/node/require-cache";import{Scanner as oe}from"@tailwindcss/oxide";import A from"node:path";function be(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var i=e.length;if(i<=1)return e;var n="";if(i>4&&e[3]==="\\"){var s=e[2];(s==="?"||s===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),n="//")}var r=e.split(/[/\\]+/);return t!==!1&&r[r.length-1]===""&&r.pop(),n+r.join("/")}function Y(e){let t=be(e);return e.startsWith("\\\\")&&t.startsWith("/")&&!t.startsWith("//")?`/${t}`:t}var M="'",B='"';function H(){let e=new WeakSet;function t(i){let n=i.root().source?.input.file;if(!n)return;let s=i.source?.input.file;if(!s||e.has(i))return;let r=i.params[0],l=r[0]===B&&r[r.length-1]===B?B:r[0]===M&&r[r.length-1]===M?M:null;if(!l)return;let a=i.params.slice(1,-1),o="";if(a.startsWith("!")&&(a=a.slice(1),o="!"),!a.startsWith("./")&&!a.startsWith("../"))return;let p=A.posix.join(Y(A.dirname(s)),a),u=A.posix.dirname(Y(n)),f=A.posix.relative(u,p);f.startsWith(".")||(f="./"+f),i.params=l+o+f+l,e.add(i)}return{postcssPlugin:"tailwindcss-postcss-fix-relative-paths",AtRule:{source:t,plugin:t,config:t}}}import{Features as le,transform as ke}from"lightningcss";import{existsSync as Ae,readFileSync as We}from"node:fs";import L from"node:fs/promises";import b from"node:path";import Ne from"postcss";import Oe from"postcss-import";var T=class{#e=new Set([]);queueMacrotask(t){let i=setTimeout(t,0);return this.add(()=>{clearTimeout(i)})}add(t){return this.#e.add(t),()=>{this.#e.delete(t),t()}}dispose(){for(let t of this.#e)t();this.#e.clear()}};import ve from"node:fs";import ie from"node:path";import{stripVTControlCharacters as Te}from"node:util";import h from"picocolors";import X from"enhanced-resolve";import ye from"node:fs";import{createRequire as we}from"node:module";var xe=we(import.meta.url).resolve;function Z(e){if(typeof globalThis.__tw_resolve=="function"){let t=globalThis.__tw_resolve(e);if(t)return t}return xe(e)}var $e=X.ResolverFactory.createResolver({fileSystem:new X.CachedInputFileSystem(ye,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});function ee(e,t){if(typeof globalThis.__tw_resolve=="function"){let i=globalThis.__tw_resolve(e,t);if(i)return i}return $e.resolveSync({},t,e)}function te(e){let t=typeof e=="number"?BigInt(e):e;return t<1000n?`${t}ns`:(t/=1000n,t<1000n?`${t}\xB5s`:(t/=1000n,t<1000n?`${t}ms`:(t/=1000n,t<60n?`${t}s`:(t/=60n,t<60n?`${t}m`:(t/=60n,t<24n?`${t}h`:(t/=24n,`${t}d`))))))}var W={indent:2};function _(){return`${h.italic(h.bold(h.blue("\u2248")))} tailwindcss ${h.blue(`v${_e()}`)}`}function N(e){return`${h.dim(h.blue("`"))}${h.blue(e)}${h.dim(h.blue("`"))}`}function ne(e,t=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=ie.relative(t,e);return n.startsWith("..")||(n=`.${ie.sep}${n}`),i&&n.length>e.length?e:n}function q(e,t){let i=e.split(" "),n=[],s="",r=0;for(let l of i){let a=Te(l).length;r+a+1>t&&(n.push(s),s="",r=0),s+=(r?" ":"")+l,r+=a+(r?1:0)}return r&&n.push(s),n}function O(e){let t=te(e);return e<=50*1e6?h.green(t):e<=300*1e6?h.blue(t):e<=1e3*1e6?h.yellow(t):h.red(t)}function S(e,t=0){return`${" ".repeat(t+W.indent)}${e}`}function g(e=""){process.stderr.write(`${e}
|
|
3
3
|
`)}function d(e=""){process.stdout.write(`${e}
|
|
4
|
-
`)}function _e(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(ve.readFileSync(
|
|
4
|
+
`)}function _e(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(ve.readFileSync(Z("tailwindcss/package.json"),"utf-8"));return e}import K from"node:fs/promises";import Se from"node:path";function re(){return new Promise((e,t)=>{let i="";process.stdin.on("data",n=>{i+=n}),process.stdin.on("end",()=>e(i)),process.stdin.on("error",n=>t(n))})}async function se(e,t){try{if(await K.readFile(e,"utf8")===t)return}catch{}await K.mkdir(Se.dirname(e),{recursive:!0}),await K.writeFile(e,t,"utf8")}var ae=String.raw;function P(){return{"--input":{type:"string",description:"Input file",alias:"-i"},"--output":{type:"string",description:"Output file",alias:"-o"},"--watch":{type:"boolean | string",description:"Watch for changes and rebuild as needed",alias:"-w"},"--minify":{type:"boolean",description:"Optimize and minify the output",alias:"-m"},"--optimize":{type:"boolean",description:"Optimize the output without minifying"},"--cwd":{type:"string",description:"The current working directory",default:"."}}}async function ce(e){let t=b.resolve(e["--cwd"]);e["--output"]&&(e["--output"]=b.resolve(t,e["--output"])),e["--input"]&&e["--input"]!=="-"&&(e["--input"]=b.resolve(t,e["--input"]),Ae(e["--input"])||(g(_()),g(),g(`Specified input file ${N(ne(e["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),[n,s]=await fe(e["--input"]?e["--input"]==="-"?await re():await L.readFile(e["--input"],"utf-8"):ae`
|
|
5
5
|
@import 'tailwindcss';
|
|
6
|
-
`,e["--input"]??t),r={css:"",optimizedCss:""};async function l(c,m){let w=c;if(m["--minify"]||m["--optimize"])if(c!==r.css){let x=Pe(c,{file:m["--input"]??"input.css",minify:m["--minify"]??!1});r.css=c,r.optimizedCss=x,w=x}else w=r.optimizedCss;m["--output"]?await
|
|
6
|
+
`,e["--input"]??t),r={css:"",optimizedCss:""};async function l(c,m){let w=c;if(m["--minify"]||m["--optimize"])if(c!==r.css){let x=Pe(c,{file:m["--input"]??"input.css",minify:m["--minify"]??!1});r.css=c,r.optimizedCss=x,w=x}else w=r.optimizedCss;m["--output"]?await se(m["--output"],w):d(w)}let a=e["--input"]&&e["--input"]!=="-"?e["--input"]:process.cwd(),o=b.dirname(b.resolve(a)),p=s.slice();function u(c){return Fe(c,{base:o,onDependency(m){p.push(m)}})}let f=await u(n),y=new oe({detectSources:{base:t},sources:f.globs.map(({origin:c,pattern:m})=>({base:c?b.dirname(b.resolve(o,c)):o,pattern:m}))});if(e["--watch"]){let c=await pe(ue(t,y),async function m(w){try{if(w.length===1&&w[0]===e["--output"])return;let x=[],D="incremental",E=p;for(let $ of w){if(E.includes($)){D="full";break}x.push({file:$,extension:b.extname($).slice(1)})}let G=process.hrtime.bigint(),j="";if(D==="full"){c(),[n,s]=await fe(e["--input"]?await L.readFile(e["--input"],"utf-8"):ae`
|
|
7
7
|
@import 'tailwindcss';
|
|
8
|
-
`,e["--input"]??t),Re(
|
|
8
|
+
`,e["--input"]??t),Re(E),p=s.slice(),f=await u(n),y=new oe({detectSources:{base:t},sources:f.globs.map(({origin:C,pattern:he})=>({base:C?b.dirname(b.resolve(o,C)):o,pattern:he}))});let $=y.scan();c=await pe(ue(t,y),m),j=f.build($)}else if(D==="incremental"){let $=y.scanFiles(x);if($.length<=0){let C=process.hrtime.bigint();g(`Done in ${O(C-G)}`);return}j=f.build($)}await l(j,e);let me=process.hrtime.bigint();g(`Done in ${O(me-G)}`)}catch(x){x instanceof Error&&g(x.toString())}});e["--watch"]!=="always"&&process.stdin.on("end",()=>{c(),process.exit(0)}),process.stdin.resume()}await l(f.build(y.scan()),e);let z=process.hrtime.bigint();g(_()),g(),g(`Done in ${O(z-i)}`)}function ue(e,t){return[e].concat(t.globs.flatMap(i=>i.pattern[0]==="!"?[]:i.base.startsWith(e)?[]:i.base))}async function pe(e,t){let i=new T,n=new Set,s=new T;function r(){s.dispose(),s.queueMacrotask(()=>{t(Array.from(n)),n.clear()})}for(let l of e){let{unsubscribe:a}=await Ce.subscribe(l,async(o,p)=>{if(o){console.error(o);return}await Promise.all(p.map(async u=>{u.type==="delete"||(await L.lstat(u.path)).isDirectory()||n.add(u.path)})),r()});i.add(a)}return()=>{i.dispose(),s.dispose()}}function fe(e,t){return e.includes("@import")?Ne().use(Oe({resolve(i,n){let s=ee(i,n);if(!s)throw new Error(`Could not resolve ${i} from ${n}`);return s},load(i){return We(i,"utf-8")}})).use(H()).process(e,{from:t}).then(i=>[i.css,[t].concat(i.messages.filter(n=>n.type==="dependency").map(n=>n.file))]):[e,[t]]}function Pe(e,{file:t="input.css",minify:i=!1}={}){return ke({filename:t,code:Buffer.from(e),minify:i,sourceMap:!1,drafts:{customMedia:!0},nonStandard:{deepSelectorCombinator:!0},include:le.Nesting,exclude:le.LogicalProperties,targets:{safari:16<<16|1024},errorRecovery:!0}).code.toString()}import v from"picocolors";function U({invalid:e,usage:t,options:i}){let n=process.stdout.columns;if(d(_()),e&&(d(),d(`${v.dim("Invalid command:")} ${e}`)),t&&t.length>0){d(),d(v.dim("Usage:"));for(let[s,r]of t.entries()){let l=r.slice(0,r.indexOf("[")),a=r.slice(r.indexOf("["));a=a.replace(/\[.*?\]/g,u=>v.dim(u));let p=q(a,n-W.indent-l.length-1);p.length>1&&s!==0&&d(),d(S(`${l}${p.shift()}`));for(let u of p)d(S(u,l.length))}}if(i){let s=0;for(let{alias:o}of Object.values(i))o&&(s=Math.max(s,o.length));let r=[],l=0;for(let[o,{alias:p}]of Object.entries(i)){let u=[p&&`${p.padStart(s)}`,p?o:" ".repeat(s+2)+o].filter(Boolean).join(", ");r.push(u),l=Math.max(l,u.length)}d(),d(v.dim("Options:"));let a=8;for(let{description:o,default:p=null}of Object.values(i)){let u=r.shift(),f=a+(l-u.length),y=2,z=n-u.length-f-y-W.indent,c=q(p!==null?`${o} ${v.dim(`[default:\u202F${N(`${p}`)}]`)}`:o,z);d(S(`${v.blue(u)} ${v.dim(v.gray("\xB7")).repeat(f)} ${c.shift()}`));for(let m of c)d(S(`${" ".repeat(u.length+f+y)}${m}`))}}}var V={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},I=Q({...P(),...V}),de=I._[0];de&&(U({invalid:de,usage:["tailwindcss [options]"],options:{...P(),...V}}),process.exit(1));(process.stdout.isTTY&&!I["--output"]||I["--help"])&&(U({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{...P(),...V}}),process.exit(0));ce(I);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/cli",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.24",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"picocolors": "^1.0.1",
|
|
32
32
|
"postcss-import": "^16.1.0",
|
|
33
33
|
"postcss": "^8.4.41",
|
|
34
|
-
"@tailwindcss/
|
|
35
|
-
"@tailwindcss/
|
|
36
|
-
"tailwindcss": "4.0.0-alpha.
|
|
34
|
+
"@tailwindcss/node": "4.0.0-alpha.24",
|
|
35
|
+
"@tailwindcss/oxide": "4.0.0-alpha.24",
|
|
36
|
+
"tailwindcss": "4.0.0-alpha.24"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/postcss-import": "^14.0.3",
|