@tailwindcss/upgrade 0.0.0-insiders.d0a1bd6 → 0.0.0-insiders.d0f7f82
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 +2 -2
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -199,12 +199,12 @@ ${s.stderr}`,{prefix:"\u21B3 "}),s}finally{tr.delete(e)}},has(t){return tr.get(e
|
|
|
199
199
|
${i.stdout}
|
|
200
200
|
${i.stderr}`,{prefix:"\u21B3 "}),i}finally{tr.delete(e)}}}}var Vi=!1,Ti=new y(async e=>{do{let t=Ce(e,"package.json");try{let n=await _e.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 _e.access(Ce(e,"bun.lockb")),"bun"}catch{}try{return await _e.access(Ce(e,"bun.lock")),"bun"}catch{}try{return await _e.access(Ce(e,"pnpm-lock.yaml")),"pnpm"}catch{}try{return await _e.access(Ce(e,"yarn.lock")),"yarn"}catch{}try{return await _e.access(Ce(e,"package-lock.json")),"npm"}catch{}let r=e;if(e=rl(e),r===e)return Vi||(Vi=!0,dt("Could not detect a package manager. Please manually update `tailwindcss` to v4.")),Promise.reject("No package manager detected")}while(!0)});async function Pi(e){let t=!1,r=!1,n=!1,i=!1,o=!1,s=rr.resolve(e,"package.json"),a;try{a=JSON.parse(await ne.readFile(s,"utf-8"))}catch{}let u=await al(e);if(u){let l=await nl(u);t=!0,l&&(r=!0,n=l.didAddPostcssClient,i=l.didRemoveAutoprefixer,o=l.didRemovePostCSSImport)}if(!t&&a&&"postcss"in a){let l=await Ni(a.postcss);t=!0,l&&(await ne.writeFile(s,JSON.stringify({...a,postcss:l?.json},null,2)),r=!0,n=l.didAddPostcssClient,i=l.didRemoveAutoprefixer,o=l.didRemovePostCSSImport)}if(!t){let l=await sl(e),f=null;if(l){try{f=JSON.parse(await ne.readFile(l,"utf-8"))}catch{}if(f){let c=await Ni(f);t=!0,c&&(await ne.writeFile(l,JSON.stringify(c.json,null,2)),r=!0,n=c.didAddPostcssClient,i=c.didRemoveAutoprefixer,o=c.didRemovePostCSSImport)}}}if(!t){W("No PostCSS config found, skipping migration.",{prefix:"\u21B3 "});return}if(n){let l=Object.hasOwn(a?.dependencies??{},"tailwindcss")?"dependencies":Object.hasOwn(a?.devDependencies??{},"tailwindcss")?"devDependencies":null;if(l!==null)try{await Oe(e).add(["@tailwindcss/postcss@latest"],l),M(`Installed package: ${x("@tailwindcss/postcss")}`,{prefix:"\u21B3 "})}catch{}}if(i)try{await Oe(e).remove(["autoprefixer"]),M(`Removed package: ${x("autoprefixer")}`,{prefix:"\u21B3 "})}catch{}if(o)try{await Oe(e).remove(["postcss-import"]),M(`Removed package: ${x("postcss-import")}`,{prefix:"\u21B3 "})}catch{}r&&u&&M(`Migrated PostCSS configuration: ${x(_(u,e))}`,{prefix:"\u21B3 "})}async function nl(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(W("Migrating PostCSS configuration\u2026"),!await ul(e))return dt("The PostCSS config contains dynamic JavaScript and can not be automatically migrated.",{prefix:"\u21B3 "}),null;let s=!1,a=!1,u=!1,f=(await ne.readFile(e,"utf-8")).split(`
|
|
201
201
|
`),c=[];for(let p=0;p<f.length;p++){let m=f[p];if(t(m))s=!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):u=!0}else if(i(m)){let d=f[p+1];t(d)||c.push(m)}else c.push(m)}return await ne.writeFile(e,c.join(`
|
|
202
|
-
`)),{didAddPostcssClient:s,didRemoveAutoprefixer:a,didRemovePostCSSImport:u}}async function Ni(e){function t(f,c){return f==="tailwindcss"&>(c)}function r(f,c){return f==="postcss-import"&>(c)}function n(f,c){return f==="autoprefixer"&>(c)}function i(f,c){return f==="tailwindcss/nesting"&&(c==="postcss-nesting"||gt(c))}let o=!1,s=!1,a=!1,u=Object.entries(e.plugins||{}),l=[];for(let f=0;f<u.length;f++){let[c,p]=u[f];if(t(c,p))o=!0,l.push(["@tailwindcss/postcss",p]);else if(n(c,p))s=!0;else if(r(c,p)){let m=!1;for(let d=f+1;d<u.length;d++){let[g,h]=u[d];if(t(g,h))break;if(!i(g,h)){m=!0;break}}m?l.push([c,p]):a=!0}else if(i(c,p)){let[m,d]=u[f+1];t(m,d)||l.push([c,p])}else l.push([c,p])}return{json:{...e,plugins:Object.fromEntries(l)},didAddPostcssClient:o,didRemoveAutoprefixer:s,didRemovePostCSSImport:a}}var ol=[".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 al(e){for(let t of ol){let r=rr.resolve(e,t);try{return await ne.access(r),r}catch{}}return null}var ll=[".postcssrc",".postcssrc.json"];async function sl(e){for(let t of ll){let r=rr.resolve(e,t);try{return await ne.access(r),r}catch{}}return null}async function ul(e){let t=await ne.readFile(e,"utf-8");return t.includes("tailwindcss:")&&!(t.includes("require")||t.includes("import "))}function gt(e){return typeof e=="object"&&e!==null&&Object.keys(e).length===0}import{isGitIgnored as ml}from"globby";import dl from"path";import gl from"postcss";import{__unstable__loadDesignSystem as cl,compileAst as pl}from"@tailwindcss/node";import*as Ri from"fs";import*as _i from"fs/promises";import*as me from"path";import*as Oi from"util";import*as ht from"postcss";
|
|
202
|
+
`)),{didAddPostcssClient:s,didRemoveAutoprefixer:a,didRemovePostCSSImport:u}}async function Ni(e){function t(f,c){return f==="tailwindcss"&>(c)}function r(f,c){return f==="postcss-import"&>(c)}function n(f,c){return f==="autoprefixer"&>(c)}function i(f,c){return f==="tailwindcss/nesting"&&(c==="postcss-nesting"||gt(c))}let o=!1,s=!1,a=!1,u=Object.entries(e.plugins||{}),l=[];for(let f=0;f<u.length;f++){let[c,p]=u[f];if(t(c,p))o=!0,l.push(["@tailwindcss/postcss",p]);else if(n(c,p))s=!0;else if(r(c,p)){let m=!1;for(let d=f+1;d<u.length;d++){let[g,h]=u[d];if(t(g,h))break;if(!i(g,h)){m=!0;break}}m?l.push([c,p]):a=!0}else if(i(c,p)){let[m,d]=u[f+1];t(m,d)||l.push([c,p])}else l.push([c,p])}return{json:{...e,plugins:Object.fromEntries(l)},didAddPostcssClient:o,didRemoveAutoprefixer:s,didRemovePostCSSImport:a}}var ol=[".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 al(e){for(let t of ol){let r=rr.resolve(e,t);try{return await ne.access(r),r}catch{}}return null}var ll=[".postcssrc",".postcssrc.json"];async function sl(e){for(let t of ll){let r=rr.resolve(e,t);try{return await ne.access(r),r}catch{}}return null}async function ul(e){let t=await ne.readFile(e,"utf-8");return t.includes("tailwindcss:")&&!(t.includes("require")||t.includes("import "))}function gt(e){return typeof e=="object"&&e!==null&&Object.keys(e).length===0}import{isGitIgnored as ml}from"globby";import dl from"path";import gl from"postcss";import{__unstable__loadDesignSystem as cl,compileAst as pl}from"@tailwindcss/node";import*as Ri from"fs";import*as _i from"fs/promises";import*as me from"path";import*as Oi from"util";import*as ht from"postcss";var fl=33;function Ei(e){let t=new y(o=>({file:o.file??o.id??null,code:o.css}));function r(o){let s=o.source;if(!s)return;let a=s.input;if(a&&s.start!==void 0&&s.end!==void 0)return[t.get(a),s.start.offset,s.end.offset]}function n(o,s){if(o.type==="decl"){let a=V(o.prop,o.value,o.important);a.src=r(o),s.push(a)}else if(o.type==="rule"){let a=z(o.selector);a.src=r(o),o.each(u=>n(u,a.nodes)),s.push(a)}else if(o.type==="atrule"){let a=$(`@${o.name}`,o.params);a.src=r(o),o.each(u=>n(u,a.nodes)),s.push(a)}else if(o.type==="comment"){if(o.text.charCodeAt(0)!==fl)return;let a=et(o.text);a.src=r(o),s.push(a)}}let i=[];return e.each(o=>n(o,i)),i}var Z=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=me.resolve(process.cwd(),t);let r=await _i.readFile(t,"utf-8"),n=ht.parse(r,{from:t});return new e(n,t)}static loadSync(t){t=me.resolve(process.cwd(),t);let r=Ri.readFileSync(t,"utf-8"),n=ht.parse(r,{from:t});return new e(n,t)}static async fromString(t){let r=ht.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=me.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 qe(this,r=>r.parents))yield t}*descendants(){for(let{item:t}of qe(this,r=>r.children))yield t}layers(){let t=new Set;for(let{item:r,path:n}of qe(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 qe(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 s of o.layers)i||=s==="utilities"||s==="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:pl(Ei(this.root),{base:me.dirname(this.file),onDependency(){}})}async designSystem(){return!this.isTailwindRoot||!this.file?null:cl(this.root.toString(),{base:me.dirname(this.file)})}[Oi.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*qe(e,t,r=[]){for(let n of t(e)){let i=[...r,n];yield*qe(n.item,t,i),yield{item:n.item,path:i}}}async function Di(e){let t=await ml(),r=[],n=new y(u=>{try{if(t(u))return null}catch{return null}try{let l=Z.loadSync(u);return e.push(l),r.push(()=>i.process(l.root,{from:l.file})),l}catch{return null}}),i=gl([{postcssPlugin:"mark-import-nodes",AtRule:{import(u){let l=u.params.match(/['"](.*?)['"]/)?.[1];if(!l)return;let f=u.source?.input.file?dl.dirname(u.source.input.file):process.cwd(),c=!1;try{if(l[0]!==".")try{c=er(`./${l}`,f)}catch{}c||(c=er(l,f))}catch{if(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("//"))return;O(`Failed to resolve import: ${x(l)} in ${x(_(u.source?.input.file,f))}. Skipping.`,{prefix:"\u21B3 "});return}if(!c)return;let p=n.get(c);if(!p)return;u.raws.tailwind_destination_sheet_id=p.id;let m=u.source?.input.file?n.get(u.source.input.file):void 0,d=[];for(let g of w(u.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 u of e)u.file&&(n.set(u.file,u),r.push(()=>i.process(u.root,{from:u.file??void 0})));for(;r.length>0;)await r.shift()();let o=process.cwd();function s(u){let l=[];for(let f of u){if(!f.item.file)continue;let c=f.item.file.replace(o,""),p=f.meta.layers.join(", ");p.length>0?l.push(`${c} (layers: ${p})`):l.push(c)}return l.join(" <- ")}let a=[];for(let u of e){if(!u.file)continue;let{convertiblePaths:l,nonConvertiblePaths:f}=u.analyzeImportPaths();if(!(l.length>0&&f.length>0))continue;u.canMigrate=!1;let p=u.file.replace(o,"");for(let m of l)a.push(`- ${p} <- ${s(m)}`);for(let m of f)a.push(`- ${p} <- ${s(m)}`)}if(a.length===0){let u=new Set;for(let l of e)l.root.walkAtRules("config",()=>(l.isTailwindRoot=!0,!1)),!l.isTailwindRoot&&l.root.walkAtRules(f=>{(f.name==="tailwind"||f.name==="import"&&f.params.match(/^["']tailwindcss["']/)||f.name==="import"&&f.params.match(/^["']tailwindcss\/.*?["']$/))&&(l.isTailwindRoot=!0,u.add(l))});if(u.size<=1)return;{let l=new y(()=>new Set);for(let c of u)l.get(c).add(c);let f=!0;e:for(;f;){f=!1;for(let[c,p]of l)for(let[m,d]of l){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 N=v;l.delete(c),l.delete(m);for(let Q of p)l.get(N).add(Q);for(let Q of d)l.get(N).add(Q);f=!0;continue e}}}for(let[c,p]of l){c.isTailwindRoot=!0;for(let m of p)c!==m&&(m.isTailwindRoot=!1)}return}}{let u=`You have one or more stylesheets that are imported into a utility layer and non-utility layer.
|
|
203
203
|
`;throw u+=`We cannot convert stylesheets under these conditions. Please look at the following stylesheets:
|
|
204
204
|
`,new Error(u+a.join(`
|
|
205
205
|
`))}}import Ui from"postcss";import{format as Ii}from"prettier";function E(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=E(n,t),r}),r}function ir(e,t){e?.each?.(r=>{ir(r,t),t(r)})}var Mi={parser:"css",semi:!0,singleQuote:!0};function Li(){async function e(t){let r=[];E(t,(i,o,s)=>{i.type==="atrule"&&(i.raws.semicolon=!0),i.type==="atrule"&&i.name==="tw-bucket"?r.push(i):i.raws.tailwind_pretty&&(i.parent??=s,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,Mi));continue}i.replaceWith(Ui.parse(`${i.raws.before??""}${(await Ii(o,Mi)).trim()}`))}t.removeAll(),t.append(Ui.parse(n.map(i=>i.trim()).filter(Boolean).join(`
|
|
206
206
|
|
|
207
|
-
`)))}return{postcssPlugin:"@tailwindcss/upgrade/format-nodes",OnceExit:e}}import{normalizePath as Vl}from"@tailwindcss/node";import ge from"path";import Tl from"postcss";import{__unstable__loadDesignSystem as Hi,compile as kl}from"@tailwindcss/node";import bl from"fs/promises";import de,{dirname as Gi}from"path";import{fileURLToPath as xl}from"url";import Fi from"semver";import{readFileSync as hl}from"fs";import
|
|
207
|
+
`)))}return{postcssPlugin:"@tailwindcss/upgrade/format-nodes",OnceExit:e}}import{normalizePath as Vl}from"@tailwindcss/node";import ge from"path";import Tl from"postcss";import{__unstable__loadDesignSystem as Hi,compile as kl}from"@tailwindcss/node";import bl from"fs/promises";import de,{dirname as Gi}from"path";import{fileURLToPath as xl}from"url";import Fi from"semver";import{readFileSync as hl}from"fs";import Ld from"fs/promises";function ji(e,t){try{let r=hi(`${e}/package.json`,t);if(!r)return null;let{version:n}=JSON.parse(hl(r,"utf8"));return n}catch{return null}}function P(e){return Fi.satisfies(Ki(),`>=${e}.0.0 <${e+1}.0.0`)}function zi(e){return Fi.gte(Ki(),`${e+1}.0.0`)}var yl=new y(e=>{let t=ji("tailwindcss",e);if(!t)throw new Error("Tailwind CSS is not installed");return t});function Ki(e=process.cwd()){return yl.get(e)}var Wi=new WeakSet;function Bi(e,t,r){if(!e.theme.prefix||!t||!P(3))return r;Wi.has(e)||(e.utilities.functional("group",s=>[V("--phantom-class","group"),V("--phantom-modifier",s.modifier?.value)]),e.utilities.functional("peer",s=>[V("--phantom-class","peer"),V("--phantom-modifier",s.modifier?.value)]),Wi.add(e));let n=vl(e,t,r);if(!n)return r;let i=e.theme.prefix,o=null;try{e.theme.prefix=null;let s=r.slice(0,n.start)+n.base+r.slice(n.end),a=[...F(s,e)];a.length>0&&(o=a[0])}finally{e.theme.prefix=i}return o?e.printCandidate(o):r}function vl(e,t,r){if(!e.theme.prefix)return null;if(!t.prefix)throw new Error("Could not find the Tailwind CSS v3 `prefix` configuration inside the JavaScript config.");let i=w(r,":").pop(),o=r.length-i.length,s=o+i.length,a=!1,u=!1;return i[i.length-1]==="!"?(a=!0,i=i.slice(0,-1)):i[0]==="!"&&(a=!0,i=i.slice(1)),i[0]==="-"&&(u=!0,i=i.slice(1)),!i.startsWith(t.prefix)&&i[0]!=="["?null:(i[0]!=="["&&(i=i.slice(t.prefix.length)),u&&(i="-"+i),a&&(i+="!"),{base:i,start:o,end:s})}var wl=/([a-z]+)/;function qi(e){let t=wl.exec(e.toLocaleLowerCase());return t?t[0]:(console.warn(`The prefix "${e} can not be used with Tailwind CSS v4 and cannot be converted to a valid one automatically. We've updated it to "tw" for you.`),"tw")}var Cl=xl(import.meta.url),He=Gi(Cl),Ji=String.raw;async function Yi(e,t){try{e===null?e=await nr(t.base):de.isAbsolute(e)||(e=de.resolve(t.base,e));let r=de.relative(He,e);!r.startsWith(".")&&!de.isAbsolute(r)&&(r="./"+r);let n=await Al(e),i=n.prefix?qi(n.prefix):null,o=Ji`
|
|
208
208
|
@import 'tailwindcss' ${i?`prefix(${i})`:""};
|
|
209
209
|
@config '${r}';
|
|
210
210
|
`,[s,a]=await Promise.all([kl(o,{base:He,onDependency:()=>{}}),Hi(o,{base:He})]);return{designSystem:a,sources:s.sources,userConfig:n,newPrefix:i,configFilePath:e}}catch(r){O("Could not load the configuration file: "+r.message,{prefix:"\u21B3 "}),process.exit(1)}}async function Al(e){let[t,r]=await Promise.all([Hi(Ji`
|
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.d0f7f82",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"postcss": "^8.4.41",
|
|
33
33
|
"postcss-import": "^16.1.1",
|
|
34
34
|
"postcss-selector-parser": "^7.1.0",
|
|
35
|
-
"prettier": "3.
|
|
35
|
+
"prettier": "3.6.2",
|
|
36
36
|
"semver": "^7.7.2",
|
|
37
37
|
"tree-sitter": "^0.22.4",
|
|
38
38
|
"tree-sitter-typescript": "^0.23.2",
|
|
39
|
-
"@tailwindcss/
|
|
40
|
-
"@tailwindcss/
|
|
41
|
-
"tailwindcss": "0.0.0-insiders.
|
|
39
|
+
"@tailwindcss/oxide": "0.0.0-insiders.d0f7f82",
|
|
40
|
+
"@tailwindcss/node": "0.0.0-insiders.d0f7f82",
|
|
41
|
+
"tailwindcss": "0.0.0-insiders.d0f7f82"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/braces": "^3.0.5",
|