@tailwindcss/cli 4.0.0-alpha.31 → 4.0.0-alpha.33
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 +5 -5
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
2
|
+
import ce from"mri";function Q(e,t=process.argv.slice(2)){let n=ce(t),i={_:n._};for(let[r,{type:s,alias:a,default:l=s==="boolean"?!1:null}]of Object.entries(e)){if(i[r]=l,a){let o=a.slice(1);n[o]!==void 0&&(i[r]=J(n[o],s))}{let o=r.slice(2);n[o]!==void 0&&(i[r]=J(n[o],s))}}return i}function J(e,t){switch(t){case"string":return F(e);case"boolean":return D(e);case"number":return U(e);case"boolean | string":return D(e)??F(e);case"number | string":return U(e)??F(e);case"boolean | number":return D(e)??U(e);case"boolean | number | string":return D(e)??U(e)??F(e);default:throw new Error(`Unhandled type: ${t}`)}}function D(e){if(e===!0||e===!1)return e;if(e==="true")return!0;if(e==="false")return!1}function U(e){if(typeof e=="number")return e;{let t=Number(e);if(!Number.isNaN(t))return t}}function F(e){return`${e}`}import ye from"@parcel/watcher";import{compile as be,env as c}from"@tailwindcss/node";import{clearRequireCache as Se}from"@tailwindcss/node/require-cache";import{Scanner as xe}from"@tailwindcss/oxide";import{Features as ie,transform as $e}from"lightningcss";import{existsSync as Te}from"node:fs";import P from"node:fs/promises";import T from"node:path";var B=class{#e=new Set([]);queueMacrotask(t){let n=setTimeout(t,0);return this.add(()=>{clearTimeout(n)})}add(t){return this.#e.add(t),()=>{this.#e.delete(t),t()}}async dispose(){for(let t of this.#e)await t();this.#e.clear()}};import me from"node:fs";import Z from"node:path";import{stripVTControlCharacters as he}from"node:util";import h from"picocolors";import Y from"enhanced-resolve";import pe from"node:fs";import{createRequire as fe}from"node:module";var de=fe(import.meta.url).resolve;function H(e){if(typeof globalThis.__tw_resolve=="function"){let t=globalThis.__tw_resolve(e);if(t)return t}return de(e)}var Ge=Y.ResolverFactory.createResolver({fileSystem:new Y.CachedInputFileSystem(pe,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});function X(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 G={indent:2};function v(){return`${h.italic(h.bold(h.blue("\u2248")))} tailwindcss ${h.blue(`v${ge()}`)}`}function k(e){return`${h.dim(h.blue("`"))}${h.blue(e)}${h.dim(h.blue("`"))}`}function ee(e,t=process.cwd(),{preferAbsoluteIfShorter:n=!0}={}){let i=Z.relative(t,e);return i.startsWith("..")||(i=`.${Z.sep}${i}`),n&&i.length>e.length?e:i}function j(e,t){let n=e.split(" "),i=[],r="",s=0;for(let a of n){let l=he(a).length;s+l+1>t&&(i.push(r),r="",s=0),r+=(s?" ":"")+a,s+=l+(s?1:0)}return s&&i.push(r),i}function R(e){let t=X(e);return e<=50*1e6?h.green(t):e<=300*1e6?h.blue(t):e<=1e3*1e6?h.yellow(t):h.red(t)}function _(e,t=0){return`${" ".repeat(t+G.indent)}${e}`}function b(e=""){process.stderr.write(`${e}
|
|
3
|
+
`)}function f(e=""){process.stdout.write(`${e}
|
|
4
|
+
`)}function ge(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(me.readFileSync(H("tailwindcss/package.json"),"utf-8"));return e}import I from"node:fs/promises";import we from"node:path";function M(){return new Promise((e,t)=>{let n="";process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>e(n)),process.stdin.on("error",i=>t(i))})}async function te(e,t){try{if(await I.readFile(e,"utf8")===t)return}catch{}await I.mkdir(we.dirname(e),{recursive:!0}),await I.writeFile(e,t,"utf8")}var ne=String.raw;function A(){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 se(e){let t=T.resolve(e["--cwd"]);e["--output"]&&(e["--output"]=T.resolve(t,e["--output"])),e["--input"]&&e["--input"]!=="-"&&(e["--input"]=T.resolve(t,e["--input"]),Te(e["--input"])||(b(v()),b(),b(`Specified input file ${k(ee(e["--input"]))} does not exist.`),process.exit(1)));let n=process.hrtime.bigint(),i=e["--input"]?e["--input"]==="-"?await M():await P.readFile(e["--input"],"utf-8"):ne`
|
|
5
5
|
@import 'tailwindcss';
|
|
6
|
-
`,r={css:"",optimizedCss:""};async function
|
|
6
|
+
`,r={css:"",optimizedCss:""};async function s(g,m){let w=g;if(m["--minify"]||m["--optimize"])if(g!==r.css){c.DEBUG&&console.time("[@tailwindcss/cli] Optimize CSS");let y=Ce(g,{file:m["--input"]??"input.css",minify:m["--minify"]??!1});c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Optimize CSS"),r.css=g,r.optimizedCss=y,w=y}else w=r.optimizedCss;c.DEBUG&&console.time("[@tailwindcss/cli] Write output"),m["--output"]?await te(m["--output"],w):f(w),c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Write output")}let a=e["--input"]&&e["--input"]!=="-"?T.resolve(e["--input"]):null,l=a?T.dirname(a):process.cwd(),o=a?[a]:[];async function p(g){c.DEBUG&&console.time("[@tailwindcss/cli] Setup compiler");let m=await be(g,{base:l,onDependency(C){o.push(C)}}),w=(m.root==="none"?[]:m.root===null?[{base:t,pattern:"**/*"}]:[m.root]).concat(m.globs),y=new xe({sources:w});return c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Setup compiler"),[m,y]}let[u,d]=await p(i);if(e["--watch"]){let g=await oe(re(d),async function m(w){try{if(w.length===1&&w[0]===e["--output"])return;let y=[],C="incremental",K=o;for(let x of w){if(K.includes(x)){C="full";break}y.push({file:x,extension:T.extname(x).slice(1)})}let V=process.hrtime.bigint(),z="";if(C==="full"){let x=e["--input"]?e["--input"]==="-"?await M():await P.readFile(e["--input"],"utf-8"):ne`
|
|
7
7
|
@import 'tailwindcss';
|
|
8
|
-
`;
|
|
8
|
+
`;Se(K),o=a?[a]:[],[u,d]=await p(x),c.DEBUG&&console.time("[@tailwindcss/cli] Scan for candidates");let W=d.scan();c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Scan for candidates");let ue=await oe(re(d),m);await g(),g=ue,c.DEBUG&&console.time("[@tailwindcss/cli] Build CSS"),z=u.build(W),c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Build CSS")}else if(C==="incremental"){c.DEBUG&&console.time("[@tailwindcss/cli] Scan for candidates");let x=d.scanFiles(y);if(c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Scan for candidates"),x.length<=0){let W=process.hrtime.bigint();b(`Done in ${R(W-V)}`);return}c.DEBUG&&console.time("[@tailwindcss/cli] Build CSS"),z=u.build(x),c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Build CSS")}await s(z,e);let ae=process.hrtime.bigint();b(`Done in ${R(ae-V)}`)}catch(y){y instanceof Error&&b(y.toString())}});e["--watch"]!=="always"&&process.stdin.on("end",()=>{g().then(()=>process.exit(0),()=>process.exit(1))}),process.stdin.resume()}c.DEBUG&&console.time("[@tailwindcss/cli] Scan for candidates");let S=d.scan();c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Scan for candidates"),c.DEBUG&&console.time("[@tailwindcss/cli] Build CSS");let N=u.build(S);c.DEBUG&&console.timeEnd("[@tailwindcss/cli] Build CSS"),await s(N,e);let E=process.hrtime.bigint();b(v()),b(),b(`Done in ${R(E-n)}`)}function re(e){return e.globs.flatMap(t=>t.pattern[0]==="!"?[]:t.pattern===""?[]:t.base)}async function oe(e,t){e=e.sort((l,o)=>l.length-o.length);let n=[];for(let l=0;l<e.length;++l)for(let o=0;o<l;++o)e[l].startsWith(`${e[o]}/`)&&n.push(e[l]);e=e.filter(l=>!n.includes(l));let i=new B,r=new Set,s=new B;async function a(){await s.dispose(),s.queueMacrotask(()=>{t(Array.from(r)),r.clear()})}for(let l of e){let{unsubscribe:o}=await ye.subscribe(l,async(p,u)=>{if(p){console.error(p);return}await Promise.all(u.map(async d=>{if(d.type==="delete")return;let S=null;try{S=await P.lstat(d.path)}catch{}!S?.isFile()&&!S?.isSymbolicLink()||r.add(d.path)})),await a()});i.add(o)}return async()=>{await i.dispose(),await s.dispose()}}function Ce(e,{file:t="input.css",minify:n=!1}={}){function i(r){return $e({filename:t,code:r,minify:n,sourceMap:!1,drafts:{customMedia:!0},nonStandard:{deepSelectorCombinator:!0},include:ie.Nesting,exclude:ie.LogicalProperties,targets:{safari:16<<16|1024},errorRecovery:!0}).code}return i(i(Buffer.from(e))).toString()}import $ from"picocolors";function L({invalid:e,usage:t,options:n}){let i=process.stdout.columns;if(f(v()),e&&(f(),f(`${$.dim("Invalid command:")} ${e}`)),t&&t.length>0){f(),f($.dim("Usage:"));for(let[r,s]of t.entries()){let a=s.slice(0,s.indexOf("[")),l=s.slice(s.indexOf("["));l=l.replace(/\[.*?\]/g,u=>$.dim(u));let p=j(l,i-G.indent-a.length-1);p.length>1&&r!==0&&f(),f(_(`${a}${p.shift()}`));for(let u of p)f(_(u,a.length))}}if(n){let r=0;for(let{alias:o}of Object.values(n))o&&(r=Math.max(r,o.length));let s=[],a=0;for(let[o,{alias:p}]of Object.entries(n)){let u=[p&&`${p.padStart(r)}`,p?o:" ".repeat(r+2)+o].filter(Boolean).join(", ");s.push(u),a=Math.max(a,u.length)}f(),f($.dim("Options:"));let l=8;for(let{description:o,default:p=null}of Object.values(n)){let u=s.shift(),d=l+(a-u.length),S=2,N=i-u.length-d-S-G.indent,E=j(p!==null?`${o} ${$.dim(`[default:\u202F${k(`${p}`)}]`)}`:o,N);f(_(`${$.blue(u)} ${$.dim($.gray("\xB7")).repeat(d)} ${E.shift()}`));for(let g of E)f(_(`${" ".repeat(u.length+d+S)}${g}`))}}}var q={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},O=Q({...A(),...q}),le=O._[0];le&&(L({invalid:le,usage:["tailwindcss [options]"],options:{...A(),...q}}),process.exit(1));(process.stdout.isTTY&&!O["--output"]||O["--help"])&&(L({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{...A(),...q}}),process.exit(0));se(O);
|
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.33",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"lightningcss": "^1.26.0",
|
|
30
30
|
"mri": "^1.2.0",
|
|
31
31
|
"picocolors": "^1.1.1",
|
|
32
|
-
"@tailwindcss/node": "4.0.0-alpha.
|
|
33
|
-
"tailwindcss": "4.0.0-alpha.
|
|
34
|
-
"@tailwindcss/oxide": "4.0.0-alpha.
|
|
32
|
+
"@tailwindcss/node": "4.0.0-alpha.33",
|
|
33
|
+
"tailwindcss": "4.0.0-alpha.33",
|
|
34
|
+
"@tailwindcss/oxide": "4.0.0-alpha.33"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"lint": "tsc --noEmit",
|