@tailwindcss/cli 4.0.0-alpha.7 → 4.0.0-alpha.8
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 +6 -6
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import X from"mri";function F(t,e=process.argv.slice(2)){let
|
|
2
|
+
import X from"mri";function F(t,e=process.argv.slice(2)){let i=X(e),n={_:i._};for(let[o,{type:r,alias:p,default:f=r==="boolean"?!1:null}]of Object.entries(t)){if(n[o]=f,p){let s=p.slice(1);i[s]!==void 0&&(n[o]=K(i[s],r))}{let s=o.slice(2);i[s]!==void 0&&(n[o]=K(i[s],r))}}return n}function K(t,e){switch(e){case"string":return O(t);case"boolean":return A(t);case"number":return k(t);case"boolean | string":return A(t)??O(t);case"number | string":return k(t)??O(t);case"boolean | number":return A(t)??k(t);case"boolean | number | string":return A(t)??k(t)??O(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 k(t){if(typeof t=="number")return t;{let e=Number(t);if(!Number.isNaN(e))return e}}function O(t){return`${t}`}import it from"@parcel/watcher";import{IO as rt,Parsing as ot,scanDir as q,scanFiles as st}from"@tailwindcss/oxide";import{existsSync as lt}from"node:fs";import V from"node:fs/promises";import _ from"node:path";import pt from"postcss";import ut from"postcss-import";import{compile as E,optimizeCss as at}from"tailwindcss";import tt from"node:fs";import B from"node:path";import{stripVTControlCharacters as et}from"node:util";import d from"picocolors";import{createRequire as Z}from"node:module";var x=Z(import.meta.url).resolve;function W(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 S={indent:2};function $(){let{version:t}=JSON.parse(tt.readFileSync(x("tailwindcss/package.json"),"utf-8"));return`${d.italic(d.bold(d.blue("\u2248")))} tailwindcss ${d.blue(`v${t}`)}`}function N(t){return`${d.dim(d.blue("`"))}${d.blue(t)}${d.dim(d.blue("`"))}`}function L(t,e=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=B.relative(e,t);return n.startsWith("..")||(n=`.${B.sep}${n}`),i&&n.length>t.length?t:n}function z(t,e){let i=t.split(" "),n=[],o="",r=0;for(let p of i){let f=et(p).length;r+f+1>e&&(n.push(o),o="",r=0),o+=(r?" ":"")+p,r+=f+(r?1:0)}return r&&n.push(o),n}function I(t){let e=W(t);return t<=50*1e6?d.green(e):t<=300*1e6?d.blue(e):t<=1e3*1e6?d.yellow(e):d.red(e)}function T(t,e=0){return`${" ".repeat(e+S.indent)}${t}`}function g(t=""){process.stderr.write(`${t}
|
|
3
3
|
`)}function u(t=""){process.stdout.write(`${t}
|
|
4
|
-
`)}import R from"node:fs/promises";import
|
|
5
|
-
@import '${
|
|
6
|
-
`,t["--input"]??e),
|
|
7
|
-
@import '${
|
|
8
|
-
`,t["--input"]??e)
|
|
4
|
+
`)}import R from"node:fs/promises";import nt from"node:path";function P(){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 U(t,e){try{if(await R.readFile(t,"utf8")===e)return}catch{}await R.mkdir(nt.dirname(t),{recursive:!0}),await R.writeFile(t,e,"utf8")}var M=String.raw;function v(){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 J(t){let e=_.resolve(t["--cwd"]);t["--output"]&&(t["--output"]=_.resolve(e,t["--output"])),t["--input"]&&t["--input"]!=="-"&&(t["--input"]=_.resolve(e,t["--input"]),lt(t["--input"])||(g($()),g(),g(`Specified input file ${N(L(t["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),{candidates:n}=q({base:e}),[o,r]=await G(t["--input"]?t["--input"]==="-"?await P():await V.readFile(t["--input"],"utf-8"):M`
|
|
5
|
+
@import '${x("tailwindcss/index.css")}';
|
|
6
|
+
`,t["--input"]??e),p={css:"",optimizedCss:""};async function f(l,a){let m=l;if(a["--minify"]||a["--optimize"])if(l!==p.css){let h=at(l,{file:a["--input"]??"input.css",minify:a["--minify"]??!1});p.css=l,p.optimizedCss=h,m=h}else m=p.optimizedCss;a["--output"]?await U(a["--output"],m):u(m)}let{build:s}=E(o);await f(s(n),t);let c=process.hrtime.bigint();g($()),g(),g(`Done in ${I(c-i)}`),t["--watch"]&&(await it.subscribe(e,async(l,a)=>{if(l){console.error(l);return}try{if(a.length===1&&a[0].path===t["--output"])return;let m=[],h="incremental";for(let y of a)if((y.type==="create"||y.type==="update")&&m.push({file:y.path,extension:_.extname(y.path).slice(1)}),r.includes(y.path)){h="full";break}let C=process.hrtime.bigint(),w="";if(h==="full")n=q({base:e}).candidates,[o,r]=await G(t["--input"]?await V.readFile(t["--input"],"utf-8"):M`
|
|
7
|
+
@import '${x("tailwindcss/index.css")}';
|
|
8
|
+
`,t["--input"]??e),s=E(o).build,w=s(n);else if(h==="incremental"){let y=st(m,rt.Sequential|ot.Sequential);w=s(y)}await f(w,t);let Q=process.hrtime.bigint();g(`Done in ${I(Q-C)}`)}catch(m){m instanceof Error&&g(m.toString())}}),t["--watch"]!=="always"&&process.stdin.on("end",()=>{process.exit(0)}),process.stdin.resume())}function G(t,e){return t.includes("@import")?pt().use(ut()).process(t,{from:e}).then(i=>[i.css,[e].concat(i.messages.filter(n=>n.type==="dependency").map(n=>n.file))]):[t,[e]]}import b from"picocolors";function j({invalid:t,usage:e,options:i}){let n=process.stdout.columns;if(u($()),t&&(u(),u(`${b.dim("Invalid command:")} ${t}`)),e&&e.length>0){u(),u(b.dim("Usage:"));for(let[o,r]of e.entries()){let p=r.slice(0,r.indexOf("[")),f=r.slice(r.indexOf("["));f=f.replace(/\[.*?\]/g,l=>b.dim(l));let c=z(f,n-S.indent-p.length-1);c.length>1&&o!==0&&u(),u(T(`${p}${c.shift()}`));for(let l of c)u(T(l,p.length))}}if(i){let o=0;for(let{alias:s}of Object.values(i))s&&(o=Math.max(o,s.length));let r=[],p=0;for(let[s,{alias:c}]of Object.entries(i)){let l=[c&&`${c.padStart(o)}`,c?s:" ".repeat(o+2)+s].filter(Boolean).join(", ");r.push(l),p=Math.max(p,l.length)}u(),u(b.dim("Options:"));let f=8;for(let{description:s,default:c=null}of Object.values(i)){let l=r.shift(),a=f+(p-l.length),m=2,h=n-l.length-a-m-S.indent,C=z(c!==null?`${s} ${b.dim(`[default:\u202F${N(`${c}`)}]`)}`:s,h);u(T(`${b.blue(l)} ${b.dim(b.gray("\xB7")).repeat(a)} ${C.shift()}`));for(let w of C)u(T(`${" ".repeat(l.length+a+m)}${w}`))}}}var D={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},H=F(D),Y=H._[0];Y&&(j({invalid:Y,usage:["tailwindcss [options]"],options:{...v(),...D}}),process.exit(1));(process.stdout.isTTY&&!process.argv.slice(2).includes("-o")||H["--help"])&&(j({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{...v(),...D}}),process.exit(0));J(F(v()));
|
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.8",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"picocolors": "^1.0.0",
|
|
30
30
|
"postcss": "8.4.24",
|
|
31
31
|
"postcss-import": "^16.0.0",
|
|
32
|
-
"tailwindcss": "4.0.0-alpha.
|
|
33
|
-
"
|
|
32
|
+
"@tailwindcss/oxide": "4.0.0-alpha.8",
|
|
33
|
+
"tailwindcss": "4.0.0-alpha.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/postcss-import": "^14.0.3"
|