@tailwindcss/upgrade 0.0.0-insiders.2f6679a → 0.0.0-insiders.3386049
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 +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -193,7 +193,7 @@ ${l.stderr}`,{prefix:"\u21B3 "}),l}finally{Zt.delete(e)}},has(t){return Zt.get(e
|
|
|
193
193
|
${i.stdout}
|
|
194
194
|
${i.stderr}`,{prefix:"\u21B3 "}),i}finally{Zt.delete(e)}}}}var $i=!1,Ti=new y(async e=>{do{let t=ve(e,"package.json");try{let n=await Ne.readFile(t,"utf-8"),i=JSON.parse(n);if(i.packageManager){if(i.packageManager.includes("bun"))return"bun";if(i.packageManager.includes("yarn"))return"yarn";if(i.packageManager.includes("pnpm"))return"pnpm";if(i.packageManager.includes("npm"))return"npm"}}catch{}try{return await Ne.access(ve(e,"bun.lockb")),"bun"}catch{}try{return await Ne.access(ve(e,"bun.lock")),"bun"}catch{}try{return await Ne.access(ve(e,"pnpm-lock.yaml")),"pnpm"}catch{}try{return await Ne.access(ve(e,"yarn.lock")),"yarn"}catch{}try{return await Ne.access(ve(e,"package-lock.json")),"npm"}catch{}let r=e;if(e=Wa(e),r===e)return $i||($i=!0,ft("Could not detect a package manager. Please manually update `tailwindcss` to v4.")),Promise.reject("No package manager detected")}while(!0)});async function Ni(e){let t=!1,r=!1,n=!1,i=!1,o=!1,l=Xt.resolve(e,"package.json"),a;try{a=JSON.parse(await te.readFile(l,"utf-8"))}catch{}let s=await Ja(e);if(s){let u=await qa(s);t=!0,u&&(r=!0,n=u.didAddPostcssClient,i=u.didRemoveAutoprefixer,o=u.didRemovePostCSSImport)}if(!t&&a&&"postcss"in a){let u=await Vi(a.postcss);t=!0,u&&(await te.writeFile(l,JSON.stringify({...a,postcss:u?.json},null,2)),r=!0,n=u.didAddPostcssClient,i=u.didRemoveAutoprefixer,o=u.didRemovePostCSSImport)}if(!t){let u=await Ya(e),f=null;if(u){try{f=JSON.parse(await te.readFile(u,"utf-8"))}catch{}if(f){let c=await Vi(f);t=!0,c&&(await te.writeFile(u,JSON.stringify(c.json,null,2)),r=!0,n=c.didAddPostcssClient,i=c.didRemoveAutoprefixer,o=c.didRemovePostCSSImport)}}}if(!t){K("No PostCSS config found, skipping migration.",{prefix:"\u21B3 "});return}if(n){let u=Object.hasOwn(a?.dependencies??{},"tailwindcss")?"dependencies":Object.hasOwn(a?.devDependencies??{},"tailwindcss")?"devDependencies":null;if(u!==null)try{await Pe(e).add(["@tailwindcss/postcss@latest"],u),j(`Installed package: ${x("@tailwindcss/postcss")}`,{prefix:"\u21B3 "})}catch{}}if(i)try{await Pe(e).remove(["autoprefixer"]),j(`Removed package: ${x("autoprefixer")}`,{prefix:"\u21B3 "})}catch{}if(o)try{await Pe(e).remove(["postcss-import"]),j(`Removed package: ${x("postcss-import")}`,{prefix:"\u21B3 "})}catch{}r&&s&&j(`Migrated PostCSS configuration: ${x(R(s,e))}`,{prefix:"\u21B3 "})}async function qa(e){function t(p){return/['"]?tailwindcss['"]?\: ?\{\}/.test(p)}function r(p){return/['"]?postcss-import['"]?\: ?\{\}/.test(p)}function n(p){return/['"]?autoprefixer['"]?\: ?\{\}/.test(p)}function i(p){return/['"]tailwindcss\/nesting['"]\: ?(\{\}|['"]postcss-nesting['"])/.test(p)}if(K("Migrating PostCSS configuration\u2026"),!await Qa(e))return ft("The PostCSS config contains dynamic JavaScript and can not be automatically migrated.",{prefix:"\u21B3 "}),null;let l=!1,a=!1,s=!1,f=(await te.readFile(e,"utf-8")).split(`
|
|
195
195
|
`),c=[];for(let p=0;p<f.length;p++){let m=f[p];if(t(m))l=!0,c.push(m.replace("tailwindcss:","'@tailwindcss/postcss':"));else if(n(m))a=!0;else if(r(m)){let d=!1;for(let g=p+1;g<f.length;g++){let h=f[g];if(t(h))break;if(!i(h)){d=!0;break}}d?c.push(m):s=!0}else if(i(m)){let d=f[p+1];t(d)||c.push(m)}else c.push(m)}return await te.writeFile(e,c.join(`
|
|
196
|
-
`)),{didAddPostcssClient:l,didRemoveAutoprefixer:a,didRemovePostCSSImport:s}}async function Vi(e){function t(f,c){return f==="tailwindcss"&&ct(c)}function r(f,c){return f==="postcss-import"&&ct(c)}function n(f,c){return f==="autoprefixer"&&ct(c)}function i(f,c){return f==="tailwindcss/nesting"&&(c==="postcss-nesting"||ct(c))}let o=!1,l=!1,a=!1,s=Object.entries(e.plugins||{}),u=[];for(let f=0;f<s.length;f++){let[c,p]=s[f];if(t(c,p))o=!0,u.push(["@tailwindcss/postcss",p]);else if(n(c,p))l=!0;else if(r(c,p)){let m=!1;for(let d=f+1;d<s.length;d++){let[g,h]=s[d];if(t(g,h))break;if(!i(g,h)){m=!0;break}}m?u.push([c,p]):a=!0}else if(i(c,p)){let[m,d]=s[f+1];t(m,d)||u.push([c,p])}else u.push([c,p])}return{json:{...e,plugins:Object.fromEntries(u)},didAddPostcssClient:o,didRemoveAutoprefixer:l,didRemovePostCSSImport:a}}var Ha=[".postcssrc.js",".postcssrc.mjs",".postcssrc.cjs",".postcssrc.ts",".postcssrc.mts",".postcssrc.cts","postcss.config.js","postcss.config.mjs","postcss.config.cjs","postcss.config.ts","postcss.config.mts","postcss.config.cts"];async function Ja(e){for(let t of Ha){let r=Xt.resolve(e,t);try{return await te.access(r),r}catch{}}return null}var Ga=[".postcssrc",".postcssrc.json"];async function Ya(e){for(let t of Ga){let r=Xt.resolve(e,t);try{return await te.access(r),r}catch{}}return null}async function Qa(e){let t=await te.readFile(e,"utf-8");return t.includes("tailwindcss:")&&!(t.includes("require")||t.includes("import "))}function ct(e){return typeof e=="object"&&e!==null&&Object.keys(e).length===0}import{isGitIgnored as tl}from"globby";import rl from"node:path";import il from"postcss";import{__unstable__loadDesignSystem as Xa,compileAst as el}from"@tailwindcss/node";import*as Ri from"node:fs";import*as Ei from"node:fs/promises";import*as ue from"node:path";import*as _i from"node:util";import*as pt from"postcss";import Hm,{Input as Jm}from"postcss";var Za=33;function Pi(e){let t=new y(o=>({file:o.file??o.id??null,code:o.css}));function r(o){let l=o.source;if(!l)return;let a=l.input;if(a&&l.start!==void 0&&l.end!==void 0)return[t.get(a),l.start.offset,l.end.offset]}function n(o,l){if(o.type==="decl"){let a=V(o.prop,o.value,o.important);a.src=r(o),l.push(a)}else if(o.type==="rule"){let a=F(o.selector);a.src=r(o),o.each(s=>n(s,a.nodes)),l.push(a)}else if(o.type==="atrule"){let a=$(`@${o.name}`,o.params);a.src=r(o),o.each(s=>n(s,a.nodes)),l.push(a)}else if(o.type==="comment"){if(o.text.charCodeAt(0)!==Za)return;let a=Ye(o.text);a.src=r(o),l.push(a)}}let i=[];return e.each(o=>n(o,i)),i}var G=class e{id;root;isTailwindRoot=!1;linkedConfigPath=null;file=null;parents=new Set;children=new Set;canMigrate=!0;extension=null;static async load(t){t=ue.resolve(process.cwd(),t);let r=await Ei.readFile(t,"utf-8"),n=pt.parse(r,{from:t});return new e(n,t)}static loadSync(t){t=ue.resolve(process.cwd(),t);let r=Ri.readFileSync(t,"utf-8"),n=pt.parse(r,{from:t});return new e(n,t)}static async fromString(t){let r=pt.parse(t);return new e(r)}static async fromRoot(t,r){return new e(t,r)}constructor(t,r){this.id=Math.random().toString(36).slice(2),this.root=t,this.file=r??null,r&&(this.extension=ue.extname(r))}get importRules(){let t=new Set;return this.root.walkAtRules("import",r=>{t.add(r)}),t}get isEmpty(){return this.root.toString().trim()===""}*ancestors(){for(let{item:t}of ze(this,r=>r.parents))yield t}*descendants(){for(let{item:t}of ze(this,r=>r.children))yield t}layers(){let t=new Set;for(let{item:r,path:n}of ze(this,i=>i.parents))if(!(r.parents.size>0))for(let{meta:i}of n)for(let o of i.layers)t.add(o);return t}*pathsToRoot(){for(let{item:t,path:r}of ze(this,n=>n.parents))t.parents.size>0||(yield r)}analyzeImportPaths(){let t=[],r=[];for(let n of this.pathsToRoot()){let i=!1;for(let{meta:o}of n)for(let l of o.layers)i||=l==="utilities"||l==="components";i?t.push(n):r.push(n)}return{convertiblePaths:t,nonConvertiblePaths:r}}containsRule(t){let r=!1;if(this.root.walk(n=>{if(t(n))return r=!0,!1}),r)return!0;for(let n of this.children)if(n.item.containsRule(t))return!0;return!1}async compiler(){return!this.isTailwindRoot||!this.file?null:el(Pi(this.root),{base:ue.dirname(this.file),onDependency(){}})}async designSystem(){return!this.isTailwindRoot||!this.file?null:Xa(this.root.toString(),{base:ue.dirname(this.file)})}[_i.inspect.custom](){return{...this,root:this.root.toString(),layers:Array.from(this.layers()),parents:Array.from(this.parents,t=>t.item.id),children:Array.from(this.children,t=>t.item.id),parentsMeta:Array.from(this.parents,t=>t.meta),childrenMeta:Array.from(this.children,t=>t.meta)}}};function*ze(e,t,r=[]){for(let n of t(e)){let i=[...r,n];yield*ze(n.item,t,i),yield{item:n.item,path:i}}}async function Oi(e){let t=await tl(),r=[],n=new y(s=>{if(t(s))return null;try{let u=G.loadSync(s);return e.push(u),r.push(()=>i.process(u.root,{from:u.file})),u}catch{return null}}),i=il([{postcssPlugin:"mark-import-nodes",AtRule:{import(s){let u=s.params.match(/['"](
|
|
196
|
+
`)),{didAddPostcssClient:l,didRemoveAutoprefixer:a,didRemovePostCSSImport:s}}async function Vi(e){function t(f,c){return f==="tailwindcss"&&ct(c)}function r(f,c){return f==="postcss-import"&&ct(c)}function n(f,c){return f==="autoprefixer"&&ct(c)}function i(f,c){return f==="tailwindcss/nesting"&&(c==="postcss-nesting"||ct(c))}let o=!1,l=!1,a=!1,s=Object.entries(e.plugins||{}),u=[];for(let f=0;f<s.length;f++){let[c,p]=s[f];if(t(c,p))o=!0,u.push(["@tailwindcss/postcss",p]);else if(n(c,p))l=!0;else if(r(c,p)){let m=!1;for(let d=f+1;d<s.length;d++){let[g,h]=s[d];if(t(g,h))break;if(!i(g,h)){m=!0;break}}m?u.push([c,p]):a=!0}else if(i(c,p)){let[m,d]=s[f+1];t(m,d)||u.push([c,p])}else u.push([c,p])}return{json:{...e,plugins:Object.fromEntries(u)},didAddPostcssClient:o,didRemoveAutoprefixer:l,didRemovePostCSSImport:a}}var Ha=[".postcssrc.js",".postcssrc.mjs",".postcssrc.cjs",".postcssrc.ts",".postcssrc.mts",".postcssrc.cts","postcss.config.js","postcss.config.mjs","postcss.config.cjs","postcss.config.ts","postcss.config.mts","postcss.config.cts"];async function Ja(e){for(let t of Ha){let r=Xt.resolve(e,t);try{return await te.access(r),r}catch{}}return null}var Ga=[".postcssrc",".postcssrc.json"];async function Ya(e){for(let t of Ga){let r=Xt.resolve(e,t);try{return await te.access(r),r}catch{}}return null}async function Qa(e){let t=await te.readFile(e,"utf-8");return t.includes("tailwindcss:")&&!(t.includes("require")||t.includes("import "))}function ct(e){return typeof e=="object"&&e!==null&&Object.keys(e).length===0}import{isGitIgnored as tl}from"globby";import rl from"node:path";import il from"postcss";import{__unstable__loadDesignSystem as Xa,compileAst as el}from"@tailwindcss/node";import*as Ri from"node:fs";import*as Ei from"node:fs/promises";import*as ue from"node:path";import*as _i from"node:util";import*as pt from"postcss";import Hm,{Input as Jm}from"postcss";var Za=33;function Pi(e){let t=new y(o=>({file:o.file??o.id??null,code:o.css}));function r(o){let l=o.source;if(!l)return;let a=l.input;if(a&&l.start!==void 0&&l.end!==void 0)return[t.get(a),l.start.offset,l.end.offset]}function n(o,l){if(o.type==="decl"){let a=V(o.prop,o.value,o.important);a.src=r(o),l.push(a)}else if(o.type==="rule"){let a=F(o.selector);a.src=r(o),o.each(s=>n(s,a.nodes)),l.push(a)}else if(o.type==="atrule"){let a=$(`@${o.name}`,o.params);a.src=r(o),o.each(s=>n(s,a.nodes)),l.push(a)}else if(o.type==="comment"){if(o.text.charCodeAt(0)!==Za)return;let a=Ye(o.text);a.src=r(o),l.push(a)}}let i=[];return e.each(o=>n(o,i)),i}var G=class e{id;root;isTailwindRoot=!1;linkedConfigPath=null;file=null;parents=new Set;children=new Set;canMigrate=!0;extension=null;static async load(t){t=ue.resolve(process.cwd(),t);let r=await Ei.readFile(t,"utf-8"),n=pt.parse(r,{from:t});return new e(n,t)}static loadSync(t){t=ue.resolve(process.cwd(),t);let r=Ri.readFileSync(t,"utf-8"),n=pt.parse(r,{from:t});return new e(n,t)}static async fromString(t){let r=pt.parse(t);return new e(r)}static async fromRoot(t,r){return new e(t,r)}constructor(t,r){this.id=Math.random().toString(36).slice(2),this.root=t,this.file=r??null,r&&(this.extension=ue.extname(r))}get importRules(){let t=new Set;return this.root.walkAtRules("import",r=>{t.add(r)}),t}get isEmpty(){return this.root.toString().trim()===""}*ancestors(){for(let{item:t}of ze(this,r=>r.parents))yield t}*descendants(){for(let{item:t}of ze(this,r=>r.children))yield t}layers(){let t=new Set;for(let{item:r,path:n}of ze(this,i=>i.parents))if(!(r.parents.size>0))for(let{meta:i}of n)for(let o of i.layers)t.add(o);return t}*pathsToRoot(){for(let{item:t,path:r}of ze(this,n=>n.parents))t.parents.size>0||(yield r)}analyzeImportPaths(){let t=[],r=[];for(let n of this.pathsToRoot()){let i=!1;for(let{meta:o}of n)for(let l of o.layers)i||=l==="utilities"||l==="components";i?t.push(n):r.push(n)}return{convertiblePaths:t,nonConvertiblePaths:r}}containsRule(t){let r=!1;if(this.root.walk(n=>{if(t(n))return r=!0,!1}),r)return!0;for(let n of this.children)if(n.item.containsRule(t))return!0;return!1}async compiler(){return!this.isTailwindRoot||!this.file?null:el(Pi(this.root),{base:ue.dirname(this.file),onDependency(){}})}async designSystem(){return!this.isTailwindRoot||!this.file?null:Xa(this.root.toString(),{base:ue.dirname(this.file)})}[_i.inspect.custom](){return{...this,root:this.root.toString(),layers:Array.from(this.layers()),parents:Array.from(this.parents,t=>t.item.id),children:Array.from(this.children,t=>t.item.id),parentsMeta:Array.from(this.parents,t=>t.meta),childrenMeta:Array.from(this.children,t=>t.meta)}}};function*ze(e,t,r=[]){for(let n of t(e)){let i=[...r,n];yield*ze(n.item,t,i),yield{item:n.item,path:i}}}async function Oi(e){let t=await tl(),r=[],n=new y(s=>{if(t(s))return null;try{let u=G.loadSync(s);return e.push(u),r.push(()=>i.process(u.root,{from:u.file})),u}catch{return null}}),i=il([{postcssPlugin:"mark-import-nodes",AtRule:{import(s){let u=s.params.match(/['"](.*?)['"]/)?.[1];if(!u)return;let f=s.source?.input.file?rl.dirname(s.source.input.file):process.cwd(),c=!1;try{if(u[0]!==".")try{c=Qt(`./${u}`,f)}catch{}c||(c=Qt(u,f))}catch{if(u.startsWith("http://")||u.startsWith("https://")||u.startsWith("//"))return;E(`Failed to resolve import: ${x(u)} in ${x(R(s.source?.input.file,f))}. Skipping.`,{prefix:"\u21B3 "});return}if(!c)return;let p=n.get(c);if(!p)return;s.raws.tailwind_destination_sheet_id=p.id;let m=s.source?.input.file?n.get(s.source.input.file):void 0,d=[];for(let g of w(s.params," "))g.startsWith("layer(")&&g.endsWith(")")&&d.push(g.slice(6,-1).trim());if(m){let g={layers:d};p.parents.add({item:m,meta:g}),m.children.add({item:p,meta:g})}}}}]);for(let s of e)s.file&&(n.set(s.file,s),r.push(()=>i.process(s.root,{from:s.file??void 0})));for(;r.length>0;)await r.shift()();let o=process.cwd();function l(s){let u=[];for(let f of s){if(!f.item.file)continue;let c=f.item.file.replace(o,""),p=f.meta.layers.join(", ");p.length>0?u.push(`${c} (layers: ${p})`):u.push(c)}return u.join(" <- ")}let a=[];for(let s of e){if(!s.file)continue;let{convertiblePaths:u,nonConvertiblePaths:f}=s.analyzeImportPaths();if(!(u.length>0&&f.length>0))continue;s.canMigrate=!1;let p=s.file.replace(o,"");for(let m of u)a.push(`- ${p} <- ${l(m)}`);for(let m of f)a.push(`- ${p} <- ${l(m)}`)}if(a.length===0){let s=new Set;for(let u of e)u.root.walkAtRules("config",()=>(u.isTailwindRoot=!0,!1)),!u.isTailwindRoot&&u.root.walkAtRules(f=>{(f.name==="tailwind"||f.name==="import"&&f.params.match(/^["']tailwindcss["']/)||f.name==="import"&&f.params.match(/^["']tailwindcss\/.*?["']$/))&&(u.isTailwindRoot=!0,s.add(u))});if(s.size<=1)return;{let u=new y(()=>new Set);for(let c of s)u.get(c).add(c);let f=!0;e:for(;f;){f=!1;for(let[c,p]of u)for(let[m,d]of u){if(c===m)continue;let g=[c].concat(Array.from(c.ancestors()).reverse()),h=[m].concat(Array.from(m.ancestors()).reverse());for(let v of g)for(let A of h){if(v!==A)continue;let T=v;u.delete(c),u.delete(m);for(let J of p)u.get(T).add(J);for(let J of d)u.get(T).add(J);f=!0;continue e}}}for(let[c,p]of u){c.isTailwindRoot=!0;for(let m of p)c!==m&&(m.isTailwindRoot=!1)}return}}{let s=`You have one or more stylesheets that are imported into a utility layer and non-utility layer.
|
|
197
197
|
`;throw s+=`We cannot convert stylesheets under these conditions. Please look at the following stylesheets:
|
|
198
198
|
`,new Error(s+a.join(`
|
|
199
199
|
`))}}import Di from"postcss";import{format as Ii}from"prettier";function N(e,t){let r;return e.each?.((n,i)=>{let o=t(n,i,e)??0;if(o===2)return r=!1,r;if(o!==1)return r=N(n,t),r}),r}function er(e,t){e?.each?.(r=>{er(r,t),t(r)})}var ji={parser:"css",semi:!0,singleQuote:!0};function Mi(){async function e(t){let r=[];N(t,(i,o,l)=>{i.type==="atrule"&&(i.raws.semicolon=!0),i.type==="atrule"&&i.name==="tw-bucket"?r.push(i):i.raws.tailwind_pretty&&(i.parent??=l,r.unshift(i))});let n=[];for(let i of r){let o=i.type==="atrule"&&i.name==="tw-bucket"?i.toString().trim().replace(/@tw-bucket(.*?){([\s\S]*)}/,"$2"):i.toString();if(i.type==="atrule"&&i.name==="tw-bucket"&&i.params==="user"){n.push(o);continue}if(i.type==="atrule"&&i.name==="tw-bucket"){n.push(await Ii(o,ji));continue}i.replaceWith(Di.parse(`${i.raws.before??""}${(await Ii(o,ji)).trim()}`))}t.removeAll(),t.append(Di.parse(n.map(i=>i.trim()).filter(Boolean).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/upgrade",
|
|
3
|
-
"version": "0.0.0-insiders.
|
|
3
|
+
"version": "0.0.0-insiders.3386049",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"semver": "^7.7.1",
|
|
37
37
|
"tree-sitter": "^0.22.4",
|
|
38
38
|
"tree-sitter-typescript": "^0.23.2",
|
|
39
|
-
"@tailwindcss/node": "0.0.0-insiders.
|
|
40
|
-
"tailwindcss": "0.0.0-insiders.
|
|
41
|
-
"@tailwindcss/oxide": "0.0.0-insiders.
|
|
39
|
+
"@tailwindcss/node": "0.0.0-insiders.3386049",
|
|
40
|
+
"tailwindcss": "0.0.0-insiders.3386049",
|
|
41
|
+
"@tailwindcss/oxide": "0.0.0-insiders.3386049"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/braces": "^3.0.5",
|