@tailwindcss/cli 4.0.0-alpha.21 → 4.0.0-alpha.23
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
|
|
2
|
+
import ge from"mri";function J(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]=G(i[o],r))}{let o=s.slice(2);i[o]!==void 0&&(n[s]=G(i[o],r))}}return n}function G(e,t){switch(t){case"string":return R(e);case"boolean":return C(e);case"number":return F(e);case"boolean | string":return C(e)??R(e);case"number | string":return F(e)??R(e);case"boolean | number":return C(e)??F(e);case"boolean | number | string":return C(e)??F(e)??R(e);default:throw new Error(`Unhandled type: ${t}`)}}function C(e){if(e===!0||e===!1)return e;if(e==="true")return!0;if(e==="false")return!1}function F(e){if(typeof e=="number")return e;{let t=Number(e);if(!Number.isNaN(t))return t}}function R(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 se}from"@tailwindcss/oxide";import k 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 Q(e){let t=be(e);return e.startsWith("\\\\")&&t.startsWith("/")&&!t.startsWith("//")?`/${t}`:t}var j="'",D='"';function Y(){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]===D&&r[r.length-1]===D?D:r[0]===j&&r[r.length-1]===j?j: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=k.posix.join(Q(k.dirname(s)),a),u=k.posix.dirname(Q(n)),f=k.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 oe,transform as ke}from"lightningcss";import{existsSync as Ae,readFileSync as We}from"node:fs";import K from"node:fs/promises";import g 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 te from"node:path";import{stripVTControlCharacters as Te}from"node:util";import h from"picocolors";import H from"enhanced-resolve";import ye from"node:fs";import{createRequire as we}from"node:module";var xe=we(import.meta.url).resolve;function X(e){if(typeof globalThis.__tw_resolve=="function"){let t=globalThis.__tw_resolve(e);if(t)return t}return xe(e)}var $e=H.ResolverFactory.createResolver({fileSystem:new H.CachedInputFileSystem(ye,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});function Z(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 ee(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 A={indent:2};function _(){return`${h.italic(h.bold(h.blue("\u2248")))} tailwindcss ${h.blue(`v${_e()}`)}`}function W(e){return`${h.dim(h.blue("`"))}${h.blue(e)}${h.dim(h.blue("`"))}`}function ie(e,t=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=te.relative(t,e);return n.startsWith("..")||(n=`.${te.sep}${n}`),i&&n.length>e.length?e:n}function M(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 B(e){let t=ee(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+A.indent)}${e}`}function y(e=""){process.stderr.write(`${e}
|
|
3
3
|
`)}function d(e=""){process.stdout.write(`${e}
|
|
4
|
-
`)}function
|
|
4
|
+
`)}function _e(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(ve.readFileSync(X("tailwindcss/package.json"),"utf-8"));return e}import q from"node:fs/promises";import Se from"node:path";function ne(){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 re(e,t){try{if(await q.readFile(e,"utf8")===t)return}catch{}await q.mkdir(Se.dirname(e),{recursive:!0}),await q.writeFile(e,t,"utf8")}var le=String.raw;function N(){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 fe(e){let t=g.resolve(e["--cwd"]);e["--output"]&&(e["--output"]=g.resolve(t,e["--output"])),e["--input"]&&e["--input"]!=="-"&&(e["--input"]=g.resolve(t,e["--input"]),Ae(e["--input"])||(y(_()),y(),y(`Specified input file ${W(ie(e["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),[n,s]=await pe(e["--input"]?e["--input"]==="-"?await ne():await K.readFile(e["--input"],"utf-8"):le`
|
|
5
5
|
@import 'tailwindcss';
|
|
6
|
-
`,e["--input"]??t),r={css:"",optimizedCss:""};async function l(c,
|
|
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 re(m["--output"],w):d(w)}let a=e["--input"]&&e["--input"]!=="-"?e["--input"]:process.cwd(),o=g.dirname(g.resolve(a)),p=s.slice();function u(c){return Fe(c,{base:o,onDependency(m){p.push(m)}})}let f=await u(n),b=new se({detectSources:{base:t},sources:f.globs.map(({origin:c,pattern:m})=>({base:c?g.dirname(g.resolve(o,c)):o,pattern:m}))});if(e["--watch"]){let c=await ue(ae(t,b),async function m(w){try{if(w.length===1&&w[0]===e["--output"])return;let x=[],I="incremental",V=p;for(let $ of w){if(V.includes($)){I="full";break}x.push({file:$,extension:g.extname($).slice(1)})}let de=process.hrtime.bigint(),z="";if(I==="full"){c(),[n,s]=await pe(e["--input"]?await K.readFile(e["--input"],"utf-8"):le`
|
|
7
7
|
@import 'tailwindcss';
|
|
8
|
-
`,e["--input"]??t),
|
|
8
|
+
`,e["--input"]??t),Re(V),p=s.slice(),f=await u(n),b=new se({detectSources:{base:t},sources:f.globs.map(({origin:E,pattern:he})=>({base:E?g.dirname(g.resolve(o,E)):o,pattern:he}))});let $=b.scan();c=await ue(ae(t,b),m),z=f.build($)}else if(I==="incremental"){let $=b.scanFiles(x);if($.length<=0)return;z=f.build($)}await l(z,e);let me=process.hrtime.bigint();y(`Done in ${B(me-de)}`)}catch(x){x instanceof Error&&y(x.toString())}});e["--watch"]!=="always"&&process.stdin.on("end",()=>{c(),process.exit(0)}),process.stdin.resume()}await l(f.build(b.scan()),e);let P=process.hrtime.bigint();y(_()),y(),y(`Done in ${B(P-i)}`)}function ae(e,t){return[e].concat(t.globs.flatMap(i=>i.pattern[0]==="!"?[]:i.base.startsWith(e)?[]:i.base))}async function ue(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 K.lstat(u.path)).isDirectory()||n.add(u.path)})),r()});i.add(a)}return()=>{i.dispose(),s.dispose()}}function pe(e,t){return e.includes("@import")?Ne().use(Oe({resolve(i,n){let s=Z(i,n);if(!s)throw new Error(`Could not resolve ${i} from ${n}`);return s},load(i){return We(i,"utf-8")}})).use(Y()).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:oe.Nesting,exclude:oe.LogicalProperties,targets:{safari:16<<16|1024},errorRecovery:!0}).code.toString()}import v from"picocolors";function L({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=M(a,n-A.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),b=2,P=n-u.length-f-b-A.indent,c=M(p!==null?`${o} ${v.dim(`[default:\u202F${W(`${p}`)}]`)}`:o,P);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+b)}${m}`))}}}var U={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},O=J({...N(),...U}),ce=O._[0];ce&&(L({invalid:ce,usage:["tailwindcss [options]"],options:{...N(),...U}}),process.exit(1));(process.stdout.isTTY&&!O["--output"]||O["--help"])&&(L({usage:["tailwindcss [--input input.css] [--output output.css] [--watch] [options\u2026]"],options:{...N(),...U}}),process.exit(0));fe(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.23",
|
|
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/oxide": "4.0.0-alpha.23",
|
|
35
|
+
"@tailwindcss/node": "4.0.0-alpha.23",
|
|
36
|
+
"tailwindcss": "4.0.0-alpha.23"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/postcss-import": "^14.0.3",
|