@tailwindcss/cli 4.0.0-alpha.2 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +6 -6
  2. package/package.json +19 -9
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import X from"mri";function N(t,e=process.argv.slice(2)){let i=X(e),n={_:i._};for(let[o,{type:r,alias:p,default:c=r==="boolean"?!1:null}]of Object.entries(t)){if(n[o]=c,p){let s=p.slice(1);i[s]!==void 0&&(n[o]=E(i[s],r))}{let s=o.slice(2);i[s]!==void 0&&(n[o]=E(i[s],r))}}return n}function E(t,e){switch(e){case"string":return S(t);case"boolean":return T(t);case"number":return A(t);case"boolean | string":return T(t)??S(t);case"number | string":return A(t)??S(t);case"boolean | number":return T(t)??A(t);case"boolean | number | string":return T(t)??A(t)??S(t);default:throw new Error(`Unhandled type: ${e}`)}}function T(t){if(t===!0||t===!1)return t;if(t==="true")return!0;if(t==="false")return!1}function A(t){if(typeof t=="number")return t;{let e=Number(t);if(!Number.isNaN(e))return e}}function S(t){return`${t}`}import rt from"@parcel/watcher";import{IO as ot,Parsing as st,clearCache as lt,scanDir as L,scanFiles as pt}from"@tailwindcss/oxide";import{existsSync as ut}from"node:fs";import U from"node:fs/promises";import O from"node:path";import at from"postcss";import ft from"postcss-import";import{compile as M,optimizeCss as V}from"tailwindcss";import P from"node:path";import f from"picocolors";import{version as Z}from"tailwindcss/package.json";function K(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 k={indent:2};function b(){return`${f.italic(f.bold(f.blue("\u2248")))} tailwindcss ${f.blue(`v${Z}`)}`}function C(t){return`${f.dim(f.blue("`"))}${f.blue(t)}${f.dim(f.blue("`"))}`}function W(t,e=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=P.relative(e,t);return n.startsWith("..")||(n=`.${P.sep}${n}`),i&&n.length>t.length?t:n}function F(t,e){let i=t.split(" "),n=[],o="",r=0;for(let p of i){let c=et(p).length;r+c+1>e&&(n.push(o),o="",r=0),o+=(r?" ":"")+p,r+=c+(r?1:0)}return r&&n.push(o),n}var tt=/((?:\x9B|\x1B\[)[0-?]*[ -\/]*[@-~])/g;function et(t){return t.replace(tt,"")}function I(t){let e=K(t);return t<=50*1e6?f.green(e):t<=300*1e6?f.blue(e):t<=1e3*1e6?f.yellow(e):f.red(e)}function y(t,e=0){return`${" ".repeat(e+k.indent)}${t}`}function m(t=""){process.stderr.write(`${t}
3
- `)}function u(t=""){process.stdout.write(`${t}
4
- `)}import{createRequire as nt}from"node:module";var v=nt(import.meta.url).resolve;import R from"node:fs/promises";import it from"node:path";function q(){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 B(t,e){try{if(await R.readFile(t,"utf8")===e)return}catch{}await R.mkdir(it.dirname(t),{recursive:!0}),await R.writeFile(t,e,"utf8")}var z=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:"Minify the output",alias:"-m"},"--cwd":{type:"string",description:"The current working directory",default:"."}}}async function Y(t){let e=O.resolve(t["--cwd"]);t["--output"]&&(t["--output"]=O.resolve(e,t["--output"])),t["--input"]&&t["--input"]!=="-"&&(t["--input"]=O.resolve(e,t["--input"]),ut(t["--input"])||(m(b()),m(),m(`Specified input file ${C(W(t["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),{candidates:n}=L({base:e}),[o,r]=await G(t["--input"]?t["--input"]==="-"?await q():await U.readFile(t["--input"],"utf-8"):z`
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
+ `)}function m(t=""){process.stdout.write(`${t}
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),p=V(M(o,n),{file:t["--input"]??"input.css",minify:t["--minify"]});t["--output"]?await B(t["--output"],p):u(p);let c=process.hrtime.bigint();m(b()),m(),m(`Done in ${I(c-i)}`),t["--watch"]&&(await rt.subscribe(e,async(s,a)=>{if(s){console.error(s);return}try{if(a.length===1&&a[0].path===t["--output"])return;let l=[],g="incremental";for(let d of a)if((d.type==="create"||d.type==="update")&&l.push({file:d.path,extension:O.extname(d.path).slice(1)}),r.includes(d.path)){g="full";break}let w=process.hrtime.bigint();if(g==="full")lt(),n=L({base:e}).candidates;else if(g==="incremental"){let d=new Set(n);for(let Q of pt(l,ot.Sequential|st.Sequential))d.add(Q);n=Array.from(d)}g==="full"&&([o,r]=await G(t["--input"]?await U.readFile(t["--input"],"utf-8"):z`
7
- @import '${v("tailwindcss/index.css")}';
8
- `,t["--input"]??e));let x=V(M(o,n),{file:t["--input"]??"input.css",minify:t["--minify"]});t["--output"]?await B(t["--output"],x):u(x);let $=process.hrtime.bigint();m(`Done in ${I($-w)}`)}catch(l){l instanceof Error&&m(l.toString())}}),t["--watch"]!=="always"&&process.stdin.on("end",()=>{process.exit(0)}),process.stdin.resume())}function G(t,e){return t.includes("@import")?at().use(ft()).process(t,{from:e}).then(i=>[i.css,i.messages.filter(n=>n.type==="postcss-import").map(n=>n.file)]):[t,[]]}import h from"picocolors";function D({invalid:t,usage:e,options:i}){let n=process.stdout.columns;if(u(b()),t&&(u(),u(`${h.dim("Invalid command:")} ${t}`)),e&&e.length>0){u(),u(h.dim("Usage:"));for(let[o,r]of e.entries()){let p=r.slice(0,r.indexOf("[")),c=r.slice(r.indexOf("["));c=c.replace(/\[.*?\]/g,l=>h.dim(l));let a=F(c,n-k.indent-p.length-1);a.length>1&&o!==0&&u(),u(y(`${p}${a.shift()}`));for(let l of a)u(y(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:a}]of Object.entries(i)){let l=[a&&`${a.padStart(o)}`,a?s:" ".repeat(o+2)+s].filter(Boolean).join(", ");r.push(l),p=Math.max(p,l.length)}u(),u(h.dim("Options:"));let c=8;for(let{description:s,default:a=null}of Object.values(i)){let l=r.shift(),g=c+(p-l.length),w=2,x=n-l.length-g-w-k.indent,$=F(a!==null?`${s} ${h.dim(`[default:\u202F${C(`${a}`)}]`)}`:s,x);u(y(`${h.blue(l)} ${h.dim(h.gray("\xB7")).repeat(g)} ${$.shift()}`));for(let d of $)u(y(`${" ".repeat(l.length+g+w)}${d}`))}}}var j={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},J=N(j),H=J._[0];H&&(D({invalid:H,usage:["tailwindcss [options]"],options:{..._(),...j}}),process.exit(1));(process.stdout.isTTY&&!process.argv.slice(2).includes("-o")||J["--help"])&&(D({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{..._(),...j}}),process.exit(0));Y(N(_()));
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
+ @import '${v("tailwindcss/index.css")}';
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,9 +1,13 @@
1
1
  {
2
2
  "name": "@tailwindcss/cli",
3
- "version": "4.0.0-alpha.2",
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
- "repository": "https://github.com/tailwindlabs/tailwindcss.git",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/tailwindlabs/tailwindcss.git",
9
+ "directory": "packages/@tailwindcss-cli"
10
+ },
7
11
  "bugs": "https://github.com/tailwindlabs/tailwindcss/issues",
8
12
  "homepage": "https://tailwindcss.com",
9
13
  "bin": {
@@ -15,21 +19,27 @@
15
19
  "files": [
16
20
  "dist"
17
21
  ],
22
+ "publishConfig": {
23
+ "provenance": true,
24
+ "access": "public"
25
+ },
18
26
  "dependencies": {
19
27
  "@parcel/watcher": "^2.4.1",
28
+ "lightningcss": "^1.26.0",
20
29
  "mri": "^1.2.0",
21
- "picocolors": "^1.0.0",
22
- "postcss": "8.4.24",
23
- "postcss-import": "^16.0.0",
24
- "tailwindcss": "4.0.0-alpha.2",
25
- "@tailwindcss/oxide": "4.0.0-alpha.2"
30
+ "picocolors": "^1.0.1",
31
+ "postcss": "^8.4.41",
32
+ "postcss-import": "^16.1.0",
33
+ "@tailwindcss/oxide": "4.0.0-alpha.20",
34
+ "tailwindcss": "4.0.0-alpha.20"
26
35
  },
27
36
  "devDependencies": {
28
- "@types/postcss-import": "^14.0.3"
37
+ "@types/postcss-import": "^14.0.3",
38
+ "internal-postcss-fix-relative-paths": "0.0.0"
29
39
  },
30
40
  "scripts": {
31
41
  "lint": "tsc --noEmit",
32
- "build": "tsup-node ./src/index.ts --format esm --minify --clean",
42
+ "build": "tsup-node",
33
43
  "dev": "pnpm run build -- --watch"
34
44
  }
35
45
  }