@tailwindcss/cli 4.0.0-alpha.2 → 4.0.0-alpha.21
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 +7 -7
- package/package.json +21 -9
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
`)}function
|
|
4
|
-
`)}
|
|
5
|
-
@import '
|
|
6
|
-
`,
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import he from"mri";function G(e,t=process.argv.slice(2)){let i=he(t),n={_:i._};for(let[o,{type:r,alias:l,default:a=r==="boolean"?!1:null}]of Object.entries(e)){if(n[o]=a,l){let s=l.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(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 Se from"@parcel/watcher";import{compile as Ce}from"@tailwindcss/node";import{clearRequireCache as Fe}from"@tailwindcss/node/require-cache";import{Scanner as re}from"@tailwindcss/oxide";import k from"node:path";function ge(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 o=e[2];(o==="?"||o===".")&&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 J(e){let t=ge(e);return e.startsWith("\\\\")&&t.startsWith("/")&&!t.startsWith("//")?`/${t}`:t}var j="'",D='"';function Q(){let e=new WeakSet;function t(i){let n=i.root().source?.input.file;if(!n)return;let o=i.source?.input.file;if(!o||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),s="";if(a.startsWith("!")&&(a=a.slice(1),s="!"),!a.startsWith("./")&&!a.startsWith("../"))return;let p=k.posix.join(J(k.dirname(o)),a),u=k.posix.dirname(J(n)),f=k.posix.relative(u,p);f.startsWith(".")||(f="./"+f),i.params=l+s+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 Re}from"lightningcss";import{existsSync as ke,readFileSync as Ae}from"node:fs";import K from"node:fs/promises";import v from"node:path";import We from"postcss";import Ne 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 $e from"node:fs";import ee from"node:path";import{stripVTControlCharacters as ve}from"node:util";import m from"picocolors";import Y from"enhanced-resolve";import be from"node:fs";import{createRequire as ye}from"node:module";var we=ye(import.meta.url).resolve;function H(e){if(typeof globalThis.__tw_resolve=="function"){let t=globalThis.__tw_resolve(e);if(t)return t}return we(e)}var xe=Y.ResolverFactory.createResolver({fileSystem:new Y.CachedInputFileSystem(be,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});function X(e,t){if(typeof globalThis.__tw_resolve=="function"){let i=globalThis.__tw_resolve(e,t);if(i)return i}return xe.resolveSync({},t,e)}function Z(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`${m.italic(m.bold(m.blue("\u2248")))} tailwindcss ${m.blue(`v${Te()}`)}`}function W(e){return`${m.dim(m.blue("`"))}${m.blue(e)}${m.dim(m.blue("`"))}`}function te(e,t=process.cwd(),{preferAbsoluteIfShorter:i=!0}={}){let n=ee.relative(t,e);return n.startsWith("..")||(n=`.${ee.sep}${n}`),i&&n.length>e.length?e:n}function M(e,t){let i=e.split(" "),n=[],o="",r=0;for(let l of i){let a=ve(l).length;r+a+1>t&&(n.push(o),o="",r=0),o+=(r?" ":"")+l,r+=a+(r?1:0)}return r&&n.push(o),n}function B(e){let t=Z(e);return e<=50*1e6?m.green(t):e<=300*1e6?m.blue(t):e<=1e3*1e6?m.yellow(t):m.red(t)}function S(e,t=0){return`${" ".repeat(t+A.indent)}${e}`}function b(e=""){process.stderr.write(`${e}
|
|
3
|
+
`)}function d(e=""){process.stdout.write(`${e}
|
|
4
|
+
`)}function Te(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse($e.readFileSync(H("tailwindcss/package.json"),"utf-8"));return e}import q from"node:fs/promises";import _e from"node:path";function ie(){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 ne(e,t){try{if(await q.readFile(e,"utf8")===t)return}catch{}await q.mkdir(_e.dirname(e),{recursive:!0}),await q.writeFile(e,t,"utf8")}var se=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 pe(e){let t=v.resolve(e["--cwd"]);e["--output"]&&(e["--output"]=v.resolve(t,e["--output"])),e["--input"]&&e["--input"]!=="-"&&(e["--input"]=v.resolve(t,e["--input"]),ke(e["--input"])||(b(_()),b(),b(`Specified input file ${W(te(e["--input"]))} does not exist.`),process.exit(1)));let i=process.hrtime.bigint(),[n,o]=await ue(e["--input"]?e["--input"]==="-"?await ie():await K.readFile(e["--input"],"utf-8"):se`
|
|
5
|
+
@import 'tailwindcss';
|
|
6
|
+
`,e["--input"]??t),r={css:"",optimizedCss:""};async function l(c,h){let y=c;if(h["--minify"]||h["--optimize"])if(c!==r.css){let w=Oe(c,{file:h["--input"]??"input.css",minify:h["--minify"]??!1});r.css=c,r.optimizedCss=w,y=w}else y=r.optimizedCss;h["--output"]?await ne(h["--output"],y):d(y)}let a=e["--input"]&&e["--input"]!=="-"?e["--input"]:process.cwd(),s=v.dirname(v.resolve(a)),p=o.slice();function u(c){return Ce(c,{base:s,onDependency(h){p.push(h)}})}let f=await u(n),g=new re({detectSources:{base:t},sources:f.globs.map(c=>({base:s,pattern:c}))});if(e["--watch"]){let c=await ae(le(t,g),async function h(y){try{if(y.length===1&&y[0]===e["--output"])return;let w=[],I="incremental",V=p;for(let x of y){if(V.includes(x)){I="full";break}w.push({file:x,extension:v.extname(x).slice(1)})}let ce=process.hrtime.bigint(),z="";if(I==="full"){c(),[n,o]=await ue(e["--input"]?await K.readFile(e["--input"],"utf-8"):se`
|
|
7
|
+
@import 'tailwindcss';
|
|
8
|
+
`,e["--input"]??t),Fe(V),p=o.slice(),f=await u(n),g=new re({detectSources:{base:t},sources:f.globs.map(me=>({base:s,pattern:me}))});let x=g.scan();c=await ae(le(t,g),h),z=f.build(x)}else if(I==="incremental"){let x=g.scanFiles(w);if(x.length<=0)return;z=f.build(x)}await l(z,e);let de=process.hrtime.bigint();b(`Done in ${B(de-ce)}`)}catch(w){w instanceof Error&&b(w.toString())}});e["--watch"]!=="always"&&process.stdin.on("end",()=>{c(),process.exit(0)}),process.stdin.resume()}await l(f.build(g.scan()),e);let P=process.hrtime.bigint();b(_()),b(),b(`Done in ${B(P-i)}`)}function le(e,t){return[e].concat(t.globs.flatMap(i=>i.pattern[0]==="!"?[]:i.base.startsWith(e)?[]:i.base))}async function ae(e,t){let i=new T,n=new Set,o=new T;function r(){o.dispose(),o.queueMacrotask(()=>{t(Array.from(n)),n.clear()})}for(let l of e){let{unsubscribe:a}=await Se.subscribe(l,async(s,p)=>{if(s){console.error(s);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(),o.dispose()}}function ue(e,t){return e.includes("@import")?We().use(Ne({resolve(i,n){let o=X(i,n);if(!o)throw new Error(`Could not resolve ${i} from ${n}`);return o},load(i){return Ae(i,"utf-8")}})).use(Q()).process(e,{from:t}).then(i=>[i.css,[t].concat(i.messages.filter(n=>n.type==="dependency").map(n=>n.file))]):[e,[t]]}function Oe(e,{file:t="input.css",minify:i=!1}={}){return Re({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 $ from"picocolors";function L({invalid:e,usage:t,options:i}){let n=process.stdout.columns;if(d(_()),e&&(d(),d(`${$.dim("Invalid command:")} ${e}`)),t&&t.length>0){d(),d($.dim("Usage:"));for(let[o,r]of t.entries()){let l=r.slice(0,r.indexOf("[")),a=r.slice(r.indexOf("["));a=a.replace(/\[.*?\]/g,u=>$.dim(u));let p=M(a,n-A.indent-l.length-1);p.length>1&&o!==0&&d(),d(S(`${l}${p.shift()}`));for(let u of p)d(S(u,l.length))}}if(i){let o=0;for(let{alias:s}of Object.values(i))s&&(o=Math.max(o,s.length));let r=[],l=0;for(let[s,{alias:p}]of Object.entries(i)){let u=[p&&`${p.padStart(o)}`,p?s:" ".repeat(o+2)+s].filter(Boolean).join(", ");r.push(u),l=Math.max(l,u.length)}d(),d($.dim("Options:"));let a=8;for(let{description:s,default:p=null}of Object.values(i)){let u=r.shift(),f=a+(l-u.length),g=2,P=n-u.length-f-g-A.indent,c=M(p!==null?`${s} ${$.dim(`[default:\u202F${W(`${p}`)}]`)}`:s,P);d(S(`${$.blue(u)} ${$.dim($.gray("\xB7")).repeat(f)} ${c.shift()}`));for(let h of c)d(S(`${" ".repeat(u.length+f+g)}${h}`))}}}var U={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}},O=G({...N(),...U}),fe=O._[0];fe&&(L({invalid:fe,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));pe(O);
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/cli",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.21",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository":
|
|
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,29 @@
|
|
|
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
|
+
"enhanced-resolve": "^5.17.1",
|
|
29
|
+
"lightningcss": "^1.26.0",
|
|
20
30
|
"mri": "^1.2.0",
|
|
21
|
-
"picocolors": "^1.0.
|
|
22
|
-
"postcss": "
|
|
23
|
-
"postcss
|
|
24
|
-
"tailwindcss": "4.0.0-alpha.
|
|
25
|
-
"@tailwindcss/oxide": "4.0.0-alpha.
|
|
31
|
+
"picocolors": "^1.0.1",
|
|
32
|
+
"postcss-import": "^16.1.0",
|
|
33
|
+
"postcss": "^8.4.41",
|
|
34
|
+
"@tailwindcss/node": "4.0.0-alpha.21",
|
|
35
|
+
"@tailwindcss/oxide": "4.0.0-alpha.21",
|
|
36
|
+
"tailwindcss": "4.0.0-alpha.21"
|
|
26
37
|
},
|
|
27
38
|
"devDependencies": {
|
|
28
|
-
"@types/postcss-import": "^14.0.3"
|
|
39
|
+
"@types/postcss-import": "^14.0.3",
|
|
40
|
+
"internal-postcss-fix-relative-paths": "0.0.0"
|
|
29
41
|
},
|
|
30
42
|
"scripts": {
|
|
31
43
|
"lint": "tsc --noEmit",
|
|
32
|
-
"build": "tsup-node
|
|
44
|
+
"build": "tsup-node",
|
|
33
45
|
"dev": "pnpm run build -- --watch"
|
|
34
46
|
}
|
|
35
47
|
}
|