@tailwindcss/upgrade 4.0.0-alpha.25
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/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/index.mjs +6 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Tailwind Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://tailwindcss.com" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
|
|
6
|
+
<img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
A utility-first CSS framework for rapidly building custom user interfaces.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci.yml?branch=next" alt="Build Status"></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
|
18
|
+
<a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
|
19
|
+
<a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
For full documentation, visit [tailwindcss.com](https://tailwindcss.com).
|
|
27
|
+
|
|
28
|
+
## Community
|
|
29
|
+
|
|
30
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
31
|
+
|
|
32
|
+
[Discuss Tailwind CSS on GitHub](https://github.com/tailwindcss/tailwindcss/discussions)
|
|
33
|
+
|
|
34
|
+
For chatting with others using the framework:
|
|
35
|
+
|
|
36
|
+
[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
|
|
37
|
+
|
|
38
|
+
## Contributing
|
|
39
|
+
|
|
40
|
+
If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindcss/tailwindcss/blob/next/.github/CONTRIBUTING.md) **before submitting a pull request**.
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{globby as he}from"globby";import ye from"node:path";import d from"picocolors";import ie from"node:fs";import ve from"node:path";import{stripVTControlCharacters as ne}from"node:util";import g from"picocolors";import K from"enhanced-resolve";import ee from"node:fs";import{createRequire as te}from"node:module";var re=te(import.meta.url).resolve;function I(e){if(typeof globalThis.__tw_resolve=="function"){let r=globalThis.__tw_resolve(e);if(r)return r}return re(e)}var Se=K.ResolverFactory.createResolver({fileSystem:new K.CachedInputFileSystem(ee,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});var A={indent:2};function T(){return`${g.italic(g.bold(g.blue("\u2248")))} tailwindcss ${g.blue(`v${se()}`)}`}function _(e){return`${g.dim(g.blue("`"))}${g.blue(e)}${g.dim(g.blue("`"))}`}function w(e,r){let t=e.split(" "),s=[],o="",i=0;for(let p of t){let n=ne(p).length;i+n+1>r&&(s.push(o),o="",i=0),o+=(i?" ":"")+p,i+=n+(i?1:0)}return i&&s.push(o),s}function S(e,r=0){return`${" ".repeat(r+A.indent)}${e}`}function L(e,r=x){w(e,process.stderr.columns-3).map(t=>r(`${g.green("\u2502")} ${t}`)),r()}function N(e,r=x){w(e,process.stderr.columns-3).map(t=>r(`${g.blue("\u2502")} ${t}`)),r()}function F(e,r=x){w(e,process.stderr.columns-3).map(t=>r(`${g.red("\u2502")} ${t}`)),r()}function x(e=""){process.stderr.write(`${e}
|
|
3
|
+
`)}function f(e=""){process.stdout.write(`${e}
|
|
4
|
+
`)}function se(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(ie.readFileSync(I("tailwindcss/package.json"),"utf-8"));return e}function j({invalid:e,usage:r,options:t}){let s=process.stdout.columns;if(f(T()),e&&(f(),f(`${d.dim("Invalid command:")} ${e}`)),r&&r.length>0){f(),f(d.dim("Usage:"));for(let[o,i]of r.entries()){let p=i.slice(0,i.indexOf("[")),n=i.slice(i.indexOf("["));n=n.replace(/\[.*?\]/g,u=>d.dim(u));let l=w(n,s-A.indent-p.length-1);l.length>1&&o!==0&&f(),f(S(`${p}${l.shift()}`));for(let u of l)f(S(u,p.length))}}if(t){let o=0;for(let{alias:a}of Object.values(t))a&&(o=Math.max(o,a.length));let i=[],p=0;for(let[a,{alias:l}]of Object.entries(t)){let u=[l&&`${l.padStart(o)}`,l?a:" ".repeat(o+2)+a].filter(Boolean).join(", ");i.push(u),p=Math.max(p,u.length)}f(),f(d.dim("Options:"));let n=8;for(let{description:a,default:l=null}of Object.values(t)){let u=i.shift(),m=n+(p-u.length),y=2,b=s-u.length-m-y-A.indent,h=w(l!==null?`${a} ${d.dim(`[default:\u202F${_(`${l}`)}]`)}`:a,b);f(S(`${d.blue(u)} ${d.dim(d.gray("\xB7")).repeat(m)} ${h.shift()}`));for(let P of h)f(S(`${" ".repeat(u.length+m+y)}${P}`))}}}import H from"node:fs/promises";import ue from"node:path";import me from"postcss";import{parse as ae}from"postcss";import{format as oe}from"prettier";function c(e,r){let t;return e.each?.(s=>{let o=r(s)??0;if(o===2)return t=!1,t;if(o!==1)return t=c(s,r),t}),t}function U(e,r){e?.each?.(t=>{U(t,r),r(t)})}function M(){async function e(r){let t=[];c(r,s=>{if(s.raws.tailwind_pretty)return t.push(s),1}),await Promise.all(t.map(async s=>{s.replaceWith(ae(await oe(s.toString(),{parser:"css",semi:!0})))}))}return{postcssPlugin:"@tailwindcss/upgrade/format-nodes",OnceExit:e}}var k=new Uint8Array(256);function $(e,r){let t=0,s=[],o=0,i=e.length,p=r.charCodeAt(0);for(let n=0;n<i;n++){let a=e.charCodeAt(n);if(t===0&&a===p){s.push(e.slice(o,n)),o=n+1;continue}switch(a){case 92:n+=1;break;case 39:case 34:for(;++n<i;){let l=e.charCodeAt(n);if(l===92){n+=1;continue}if(l===a)break}break;case 40:k[t]=41,t++;break;case 91:k[t]=93,t++;break;case 123:k[t]=125,t++;break;case 93:case 125:case 41:t>0&&a===k[t-1]&&t--;break}}return s.push(e.slice(o)),s}function Y(){function e(r){let t=r.params.split(/(\s+)/),s=t[t.length-1]==="!important"||t[t.length-1]==="#{!important}";s&&t.pop();let o=t.map(i=>{if(i.trim()==="")return i;let p=$(i,":"),n=p.pop();return s&&n[0]!=="!"&&n[n.length-1]!=="!"&&(n+="!"),n[0]==="!"&&(n=`${n.slice(1)}!`),[...p,n].join(":")});r.params=o.join("").trim()}return{postcssPlugin:"@tailwindcss/upgrade/migrate-at-apply",OnceExit(r){r.walkAtRules("apply",e)}}}import"postcss";import v from"postcss-selector-parser";function V(){function e(r){if(r.params!=="utilities"&&r.params!=="components")return;let t=r.clone();c(r,i=>{if(i.type!=="rule")return;let p=$(i.selector,",");if(p.length>1){let n=[];for(let a of p){let l=i.clone({selector:a});n.push(l)}i.replaceWith(n)}return 1});let s=new Set;c(r,i=>{if(i.type==="rule")return v(p=>{p.each(n=>{c(n,a=>{if(a.type==="pseudo"&&a.value===":not")return 1;a.type==="class"&&s.add(a.value)})})}).processSync(i.selector,{updateSelector:!1}),1}),c(t,i=>{i.type==="rule"&&v(p=>{p.each(n=>{c(n,a=>{if(a.type==="pseudo"&&a.value===":not")return 1;if(a.type==="class"&&s.has(a.value))return i.remove(),2}),i.selector=n.toString()})}).processSync(i.selector,{updateSelector:!1})});let o=[t];for(let i of s){let p=r.clone();o.push(p),c(p,n=>{if(n.type!=="rule")return;let a=!1;if(v(l=>{l.each(u=>{c(u,m=>{if(m.type==="pseudo"&&m.value===":not")return 1;if(m.type==="class"&&m.value===i){a=!0;let y=u.atPosition(m.source.start.line,m.source.start.column),b=y.parent,h=(y.parent?.index(y)??0)-1;for(;h>=0&&b.at(h)?.type!=="combinator";){let P=b.at(h+1),Z=b.at(h);b.at(h+1).replaceWith(Z),b.at(h).replaceWith(P),h--}y.replaceWith(v.nesting())}})}),n.selector=l.toString()}).processSync(n.selector),!a){let l=[n],u=n.parent?.index(n)??null;if(u!==null)for(let m=u-1;m>=0&&n.parent?.nodes.at(m)?.type!=="rule";m--)n.parent?.nodes.at(m)?.type==="comment"&&l.push(n.parent?.nodes.at(m));for(let m of l)m.remove()}return 1}),p.name="utility",p.params=i,p.raws.tailwind_pretty=!0,p.raws.before+=`
|
|
5
|
+
|
|
6
|
+
`}for(let i=o.length-1;i>=0;i--){let p=o[i];U(p,n=>{if(p===t&&n.type==="comment"){let a=!1;for(let l of o)if(l!==t&&(c(l,u=>{if(u.type==="comment"&&u.source?.start?.offset===n.source?.start?.offset)return n.remove(),a=!0,2}),a))return 1}if((n.type==="rule"||n.type==="atrule")&&n.nodes?.length===0)n.remove();else if(n.type==="rule"&&n.selector==="&"){let a=n.parent,l=!1;for(;a;){if(a.type==="rule"){l=!0;break}a=a.parent}l||n.replaceWith(n.nodes)}}),p.nodes?.length===0&&o.splice(i,1)}r.replaceWith(o)}return{postcssPlugin:"@tailwindcss/upgrade/migrate-at-layer-utilities",OnceExit:r=>{r.walkAtRules("layer",e);{let t=new Map;c(r,s=>{if(s.type==="atrule"&&s.name==="utility"){let o=t.get(s.params);o?(o.append(s.nodes),s.remove()):t.set(s.params,s)}})}}}}import{AtRule as pe}from"postcss";function G(){function e(r){let t="",s=[],o=[];r.each(i=>{if(i.type==="atrule"){if(i.name==="theme"||i.name==="utility"){s.length>0&&o.push([t,s.splice(0)]);return}if(i.name==="tailwind"&&i.params==="base"||i.name==="import"&&i.params.match(/^["']tailwindcss\/base["']/)){s.length>0&&o.push([t,s.splice(0)]),t="base";return}if(i.name==="tailwind"&&i.params==="components"||i.name==="import"&&i.params.match(/^["']tailwindcss\/components["']/)){s.length>0&&o.push([t,s.splice(0)]),t="components";return}if(i.name==="tailwind"&&i.params==="utilities"||i.name==="import"&&i.params.match(/^["']tailwindcss\/utilities["']/)){s.length>0&&o.push([t,s.splice(0)]),t="utilities";return}if(i.name==="layer"){s.length>0&&o.push([t,s.splice(0)]);return}if(i.name==="import"){i.params.includes("layer(")||(i.params+=` layer(${t})`),s.length>0&&o.push([t,s.splice(0)]);return}}t!==""&&s.push(i)!==1&&i.remove()}),s.length>0&&o.push([t,s.splice(0)]);for(let[i,p]of o){let n=new pe({name:"layer",params:i,nodes:p,raws:{tailwind_pretty:!0}});p[0].replaceWith(n)}}return{postcssPlugin:"@tailwindcss/upgrade/migrate-missing-layers",OnceExit:e}}import{AtRule as R}from"postcss";var W=["theme","base","components","utilities"];function Q(){function e(r){let t=null,s=null,o=null,i=null,p=null,n=null,a=[];r.walkAtRules(l=>{l.name==="tailwind"&&l.params==="base"||l.name==="import"&&l.params.match(/^["']tailwindcss\/base["']$/)?(a.push("base"),t=l,l.remove()):l.name==="tailwind"&&l.params==="utilities"||l.name==="import"&&l.params.match(/^["']tailwindcss\/utilities["']$/)?(a.push("utilities"),s=l,l.remove()):(l.name==="tailwind"&&l.params==="components"||l.name==="tailwind"&&l.params==="screens"||l.name==="tailwind"&&l.params==="variants"||l.name==="import"&&l.params.match(/^["']tailwindcss\/components["']$/))&&l.remove()}),t!==null&&s!==null?o||r.prepend(new R({name:"import",params:"'tailwindcss'"})):s!==null?i||r.prepend(new R({name:"import",params:"'tailwindcss/utilities' layer(utilities)"})):t!==null&&(p||r.prepend(new R({name:"import",params:"'tailwindcss/preflight' layer(base)"})),n||r.prepend(new R({name:"import",params:"'tailwindcss/theme' layer(theme)"})));{let l=a.toSorted((u,m)=>W.indexOf(u)-W.indexOf(m));if(a.some((u,m)=>u!==l[m])){let u=W.toSorted((m,y)=>a.indexOf(m)-a.indexOf(y));r.prepend({name:"layer",params:u.join(", ")})}}}return{postcssPlugin:"@tailwindcss/upgrade/migrate-tailwind-directives",OnceExit:e}}async function fe(e,r){return me().use(Y()).use(V()).use(G()).use(Q()).use(M()).process(e,{from:r}).then(t=>t.css)}async function q(e){let r=ue.resolve(process.cwd(),e),t=await H.readFile(r,"utf-8");await H.writeFile(r,await fe(t,r))}import ce from"mri";function z(e,r=process.argv.slice(2)){let t=ce(r),s={_:t._};for(let[o,{type:i,alias:p,default:n=i==="boolean"?!1:null}]of Object.entries(e)){if(s[o]=n,p){let a=p.slice(1);t[a]!==void 0&&(s[o]=J(t[a],i))}{let a=o.slice(2);t[a]!==void 0&&(s[o]=J(t[a],i))}}return s}function J(e,r){switch(r){case"string":return O(e);case"boolean":return C(e);case"number":return E(e);case"boolean | string":return C(e)??O(e);case"number | string":return E(e)??O(e);case"boolean | number":return C(e)??E(e);case"boolean | number | string":return C(e)??E(e)??O(e);default:throw new Error(`Unhandled type: ${r}`)}}function C(e){if(e===!0||e===!1)return e;if(e==="true")return!0;if(e==="false")return!1}function E(e){if(typeof e=="number")return e;{let r=Number(e);if(!Number.isNaN(r))return r}}function O(e){return`${e}`}import{execSync as ge}from"node:child_process";function B(){try{return ge("git status --porcelain",{encoding:"utf-8"}).trim()!==""}catch(e){return!e?.toString?.().includes("not a git repository")}}var X={"--help":{type:"boolean",description:"Display usage information",alias:"-h"},"--force":{type:"boolean",description:"Force the migration",alias:"-f"},"--version":{type:"boolean",description:"Display the version number",alias:"-v"}},D=z(X);D["--help"]&&(j({usage:["npx @tailwindcss/upgrade"],options:X}),process.exit(0));async function de(){x(T()),x(),D["--force"]||B()&&(F("Git directory is not clean. Please stash or commit your changes before migrating."),N(`You may use the ${_("--force")} flag to silence this warning and perform the migration.`),process.exit(1));let e=D._.map(r=>ye.resolve(process.cwd(),r));e.length===0&&(N("No files provided. Searching for CSS files in the current directory and its subdirectories\u2026"),e=await he(["**/*.css"],{absolute:!0,gitignore:!0})),e=e.filter(r=>r.endsWith(".css")),await Promise.allSettled(e.map(r=>q(r))),B()?L("Migration complete. Verify the changes and commit them to your repository."):L("Migration complete. No changes were made to your repository.")}de().then(()=>process.exit(0)).catch(e=>{console.error(e),process.exit(1)});
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tailwindcss/upgrade",
|
|
3
|
+
"version": "4.0.0-alpha.25",
|
|
4
|
+
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/tailwindlabs/tailwindcss.git",
|
|
9
|
+
"directory": "packages/@tailwindcss-cli"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/tailwindlabs/tailwindcss/issues",
|
|
12
|
+
"homepage": "https://tailwindcss.com",
|
|
13
|
+
"bin": "./dist/index.mjs",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"provenance": true,
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"enhanced-resolve": "^5.17.1",
|
|
26
|
+
"globby": "^14.0.2",
|
|
27
|
+
"mri": "^1.2.0",
|
|
28
|
+
"picocolors": "^1.0.1",
|
|
29
|
+
"postcss": "^8.4.41",
|
|
30
|
+
"postcss-import": "^16.1.0",
|
|
31
|
+
"postcss-selector-parser": "^6.1.2",
|
|
32
|
+
"prettier": "^3.3.3",
|
|
33
|
+
"tailwindcss": "4.0.0-alpha.25"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.14.8",
|
|
37
|
+
"@types/postcss-import": "^14.0.3",
|
|
38
|
+
"dedent": "1.5.3"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"lint": "tsc --noEmit",
|
|
42
|
+
"build": "tsup-node",
|
|
43
|
+
"dev": "pnpm run build -- --watch"
|
|
44
|
+
}
|
|
45
|
+
}
|