@tailwindcss/cli 4.0.0-alpha.19 → 4.0.0-alpha.20
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 +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import ct from"mri";function E(t,e=process.argv.slice(2)){let i=ct(e),n={_:i._};for(let[s,{type:r,alias:a,default:u=r==="boolean"?!1:null}]of Object.entries(t)){if(n[s]=u,a){let o=a.slice(1);i[o]!==void 0&&(n[s]=V(i[o],r))}{let o=s.slice(2);i[o]!==void 0&&(n[s]=V(i[o],r))}}return n}function V(t,e){switch(e){case"string":return F(t);case"boolean":return A(t);case"number":return W(t);case"boolean | string":return A(t)??F(t);case"number | string":return W(t)??F(t);case"boolean | number":return A(t)??W(t);case"boolean | number | string":return A(t)??W(t)??F(t);default:throw new Error(`Unhandled type: ${e}`)}}function A(t){if(t===!0||t===!1)return t;if(t==="true")return!0;if(t==="false")return!1}function W(t){if(typeof t=="number")return t;{let e=Number(t);if(!Number.isNaN(e))return e}}function F(t){return`${t}`}import yt from"@parcel/watcher";import{Scanner as tt}from"@tailwindcss/oxide";import O from"node:path";function dt(t,e){if(typeof t!="string")throw new TypeError("expected path to be a string");if(t==="\\"||t==="/")return"/";var i=t.length;if(i<=1)return t;var n="";if(i>4&&t[3]==="\\"){var s=t[2];(s==="?"||s===".")&&t.slice(0,2)==="\\\\"&&(t=t.slice(2),n="//")}var r=t.split(/[/\\]+/);return e!==!1&&r[r.length-1]===""&&r.pop(),n+r.join("/")}function G(t){let e=dt(t);return t.startsWith("\\\\")&&e.startsWith("/")&&!e.startsWith("//")?`/${e}`:e}var I="'",D='"';function J(){let t=new WeakSet;function e(i){let n=i.root().source?.input.file;if(!n)return;let s=i.source?.input.file;if(!s||t.has(i))return;let r=i.params[0],a=r[0]===D&&r[r.length-1]===D?D:r[0]===I&&r[r.length-1]===I?I:null;if(!a)return;let u=i.params.slice(1,-1),o="";if(u.startsWith("!")&&(u=u.slice(1),o="!"),!u.startsWith("./")&&!u.startsWith("../"))return;let p=O.posix.join(G(O.dirname(s)),u),l=O.posix.dirname(G(n)),f=O.posix.relative(l,p);f.startsWith(".")||(f="./"+f),i.params=a+o+f+a,t.add(i)}return{postcssPlugin:"tailwindcss-postcss-fix-relative-paths",AtRule:{source:e,plugin:e}}}import{Features as et,transform as wt}from"lightningcss";import{existsSync as xt}from"node:fs";import K from"node:fs/promises";import $ from"node:path";import{pathToFileURL as $t}from"node:url";import Tt from"postcss";import vt from"postcss-import";import*as ot from"tailwindcss";var T=class{#t=new Set([]);queueMacrotask(e){let i=setTimeout(e,0);return this.add(()=>{clearTimeout(i)})}add(e){return this.#t.add(e),()=>{this.#t.delete(e),e()}}dispose(){for(let e of this.#t)e();this.#t.clear()}};import ht from"node:fs";import Y from"node:path";import{stripVTControlCharacters as gt}from"node:util";import g from"picocolors";import{createRequire as mt}from"node:module";var v=mt(import.meta.url).resolve;function Q(t){let e=typeof t=="number"?BigInt(t):t;return e<1000n?`${e}ns`:(e/=1000n,e<1000n?`${e}\xB5s`:(e/=1000n,e<1000n?`${e}ms`:(e/=1000n,e<60n?`${e}s`:(e/=60n,e<60n?`${e}m`:(e/=60n,e<24n?`${e}h`:(e/=24n,`${e}d`))))))}var R={indent:2};function S(){let{version:t}=JSON.parse(ht.readFileSync(v("tailwindcss/package.json"),"utf-8"));return`${g.italic(g.bold(g.blue("\u2248")))} tailwindcss ${g.blue(`v${t}`)}`}function N(t){return`${g.dim(g.blue("`"))}${g.blue(t)}${g.dim(g.blue("`"))}`}function H(t,e=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=Y.relative(e,t);return n.startsWith("..")||(n=`.${Y.sep}${n}`),i&&n.length>t.length?t:n}function M(t,e){let i=t.split(" "),n=[],s="",r=0;for(let a of i){let u=gt(a).length;r+u+1>e&&(n.push(s),s="",r=0),s+=(r?" ":"")+a,r+=u+(r?1:0)}return r&&n.push(s),n}function B(t){let e=Q(t);return t<=50*1e6?g.green(e):t<=300*1e6?g.blue(e):t<=1e3*1e6?g.yellow(e):g.red(e)}function C(t,e=0){return`${" ".repeat(e+R.indent)}${t}`}function b(t=""){process.stderr.write(`${t}
|
|
3
3
|
`)}function m(t=""){process.stdout.write(`${t}
|
|
4
|
-
`)}import L from"node:fs/promises";import
|
|
4
|
+
`)}import L from"node:fs/promises";import bt from"node:path";function X(){return new Promise((t,e)=>{let i="";process.stdin.on("data",n=>{i+=n}),process.stdin.on("end",()=>t(i)),process.stdin.on("error",n=>e(n))})}async function Z(t,e){try{if(await L.readFile(t,"utf8")===e)return}catch{}await L.mkdir(bt.dirname(t),{recursive:!0}),await L.writeFile(t,e,"utf8")}var it=String.raw;function _(){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 lt(t){let e=$.resolve(t["--cwd"]);t["--output"]&&(t["--output"]=$.resolve(e,t["--output"])),t["--input"]&&t["--input"]!=="-"&&(t["--input"]=$.resolve(e,t["--input"]),xt(t["--input"])||(b(S()),b(),b(`Specified input file ${N(H(t["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),[n,s]=await st(t["--input"]?t["--input"]==="-"?await X():await K.readFile(t["--input"],"utf-8"):it`
|
|
5
5
|
@import '${v("tailwindcss/index.css")}';
|
|
6
|
-
`,t["--input"]??e),r={css:"",optimizedCss:""};async function a(h,d){let c=h;if(d["--minify"]||d["--optimize"])if(h!==r.css){let y=
|
|
6
|
+
`,t["--input"]??e),r={css:"",optimizedCss:""};async function a(h,d){let c=h;if(d["--minify"]||d["--optimize"])if(h!==r.css){let y=St(h,{file:d["--input"]??"input.css",minify:d["--minify"]??!1});r.css=h,r.optimizedCss=y,c=y}else c=r.optimizedCss;d["--output"]?await Z(d["--output"],c):m(c)}let u=t["--input"]&&t["--input"]!=="-"?t["--input"]:process.cwd(),o=$.dirname($.resolve(u));function p(h){return ot.compile(h,{loadPlugin:async d=>d[0]==="."?import($t($.resolve(o,d)).href).then(c=>c.default??c):import(d).then(c=>c.default??c)})}let l=await p(n),f=new tt({detectSources:{base:e},sources:l.globs.map(h=>({base:o,pattern:h}))});if(t["--watch"]){let h=await rt(nt(e,f),async function d(c){try{if(c.length===1&&c[0]===t["--output"])return;let y=[],P="incremental";for(let w of c){if(s.includes(w)){P="full";break}y.push({file:w,extension:$.extname(w).slice(1)})}let ut=process.hrtime.bigint(),j="";if(P==="full"){h(),[n,s]=await st(t["--input"]?await K.readFile(t["--input"],"utf-8"):it`
|
|
7
7
|
@import '${v("tailwindcss/index.css")}';
|
|
8
|
-
`,t["--input"]??e),l=await p(n),f=tt({base:e,sources:l.globs.map(
|
|
8
|
+
`,t["--input"]??e),l=await p(n),f=new tt({detectSources:{base:e},sources:l.globs.map(ft=>({base:o,pattern:ft}))});let w=f.scan();h=await rt(nt(e,f),d),j=l.build(w)}else if(P==="incremental"){let w=f.scanFiles(y);if(w.length<=0)return;j=l.build(w)}await a(j,t);let pt=process.hrtime.bigint();b(`Done in ${B(pt-ut)}`)}catch(y){y instanceof Error&&b(y.toString())}});t["--watch"]!=="always"&&process.stdin.on("end",()=>{h(),process.exit(0)}),process.stdin.resume()}await a(l.build(f.scan()),t);let k=process.hrtime.bigint();b(S()),b(),b(`Done in ${B(k-i)}`)}function nt(t,e){return[t].concat(e.globs.flatMap(i=>i.pattern[0]==="!"?[]:i.base.startsWith(t)?[]:i.base))}async function rt(t,e){let i=new T,n=new Set,s=new T;function r(){s.dispose(),s.queueMacrotask(()=>{e(Array.from(n)),n.clear()})}for(let a of t){let{unsubscribe:u}=await yt.subscribe(a,async(o,p)=>{if(o){console.error(o);return}await Promise.all(p.map(async l=>{l.type==="delete"||(await K.lstat(l.path)).isDirectory()||n.add(l.path)})),r()});i.add(u)}return()=>{i.dispose(),s.dispose()}}function st(t,e){return t.includes("@import")?Tt().use(vt()).use(J()).process(t,{from:e}).then(i=>[i.css,[e].concat(i.messages.filter(n=>n.type==="dependency").map(n=>n.file))]):[t,[e]]}function St(t,{file:e="input.css",minify:i=!1}={}){return wt({filename:e,code:Buffer.from(t),minify:i,sourceMap:!1,drafts:{customMedia:!0},nonStandard:{deepSelectorCombinator:!0},include:et.Nesting,exclude:et.LogicalProperties,targets:{safari:16<<16|1024},errorRecovery:!0}).code.toString()}import x from"picocolors";function U({invalid:t,usage:e,options:i}){let n=process.stdout.columns;if(m(S()),t&&(m(),m(`${x.dim("Invalid command:")} ${t}`)),e&&e.length>0){m(),m(x.dim("Usage:"));for(let[s,r]of e.entries()){let a=r.slice(0,r.indexOf("[")),u=r.slice(r.indexOf("["));u=u.replace(/\[.*?\]/g,l=>x.dim(l));let p=M(u,n-R.indent-a.length-1);p.length>1&&s!==0&&m(),m(C(`${a}${p.shift()}`));for(let l of p)m(C(l,a.length))}}if(i){let s=0;for(let{alias:o}of Object.values(i))o&&(s=Math.max(s,o.length));let r=[],a=0;for(let[o,{alias:p}]of Object.entries(i)){let l=[p&&`${p.padStart(s)}`,p?o:" ".repeat(s+2)+o].filter(Boolean).join(", ");r.push(l),a=Math.max(a,l.length)}m(),m(x.dim("Options:"));let u=8;for(let{description:o,default:p=null}of Object.values(i)){let l=r.shift(),f=u+(a-l.length),k=2,h=n-l.length-f-k-R.indent,d=M(p!==null?`${o} ${x.dim(`[default:\u202F${N(`${p}`)}]`)}`:o,h);m(C(`${x.blue(l)} ${x.dim(x.gray("\xB7")).repeat(f)} ${d.shift()}`));for(let c of d)m(C(`${" ".repeat(l.length+f+k)}${c}`))}}}var q={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},z=E({..._(),...q}),at=z._[0];at&&(U({invalid:at,usage:["tailwindcss [options]"],options:{..._(),...q}}),process.exit(1));(process.stdout.isTTY&&!z["--output"]||z["--help"])&&(U({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{..._(),...q}}),process.exit(0));lt(z);
|
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.20",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"picocolors": "^1.0.1",
|
|
31
31
|
"postcss": "^8.4.41",
|
|
32
32
|
"postcss-import": "^16.1.0",
|
|
33
|
-
"tailwindcss": "4.0.0-alpha.
|
|
34
|
-
"
|
|
33
|
+
"@tailwindcss/oxide": "4.0.0-alpha.20",
|
|
34
|
+
"tailwindcss": "4.0.0-alpha.20"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/postcss-import": "^14.0.3",
|