@@ -48,15 +48,15 @@ test(
4848
4949 // Re-running the upgrade should result in an error
5050 return expect ( ( ) => {
51- return exec ( 'pnpm exec upgrade' , { } , { ignoreStdErr : true } ) . catch ( ( e ) => {
51+ return exec ( 'pnpm exec upgrade --force ' , { } , { ignoreStdErr : true } ) . catch ( ( e ) => {
5252 // Replacing the current version with a hardcoded `v4` to make it stable
5353 // when we release new minor/patch versions.
5454 return Promise . reject (
5555 stripNpmWarnings ( stripVTControlCharacters ( e . message . replace ( / \d + \. \d + \. \d + / g, '4.0.0' ) ) ) ,
5656 )
5757 } )
5858 } ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
59- "Command failed: pnpm exec upgrade
59+ "Command failed: pnpm exec upgrade --force
6060 ≈ tailwindcss v4.0.0
6161
6262 │ ↳ Upgrading from Tailwind CSS \`v4.0.0\`
@@ -75,184 +75,184 @@ test(
7575 } ,
7676)
7777
78- test (
79- 'upgrades half-upgraded v3 project to v4 (bun)' ,
80- {
81- fs : {
82- 'package.json' : json `
83- {
84- "dependencies" : {
85- "tailwindcss" : "^3" ,
86- "@tailwindcss/upgrade" : "workspace:^"
87- },
88- "devDependencies" : {
89- "@tailwindcss/cli" : "workspace:^" ,
90- "bun" : "^1.0.0"
91- }
92- }
93- ` ,
94- 'tailwind.config.js' : js `
95- /** @type {import('tailwindcss').Config} */
96- module .exports = {
97- content : ['./src/**/*.{html,js}' ],
98- }
99- ` ,
100- 'src/index.html' : html `
101- <div class= "!flex" > Hello Wor ld</div>
102- ` ,
103- 'src/input.css' : css `
104- @tailwind base;
105- @tailwind components;
106- @tailwind utilities;
107- ` ,
108- } ,
109- } ,
110- async ( { exec, expect } ) => {
111- // Use `bun` to install dependencies
112- await exec ( 'rm ./pnpm-lock.yaml' )
113- try {
114- await exec ( 'npm rebuild bun' ) // Run postinstall of bun
115- await exec ( 'npx bun install' , { } , { ignoreStdErr : true } )
116- } catch ( e ) {
117- // When preparing for a release, the version in `package.json` will point
118- // to a non-existent version because it's not published yet.
119- // TODO: Find a better approach to handle this and actually test it even
120- // on release branches. Note: the pnpm version _does_ work because of
121- // overrides in the package.json file.
122- if ( `${ e } ` . includes ( 'No version matching' ) ) return
123- throw e
124- }
125-
126- // Ensure we are in a git repo
127- await exec ( 'git init' )
128- await exec ( 'git add --all' )
129- await exec ( 'git commit -m "before migration" --allow-empty' )
130-
131- // Fully upgrade to v4
132- await exec ( 'bun x @tailwindcss/upgrade' )
133-
134- // Undo all changes to the current repo. This will bring the repo back to a
135- // v3 state, but the `node_modules` will now have v4 installed.
136- await exec ( 'git reset --hard' )
137- await exec ( 'git clean -df' )
138-
139- // Re-running the upgrade should result in an error
140- return expect ( ( ) => {
141- return exec ( 'bun x @tailwindcss/upgrade' , { } , { ignoreStdErr : true } ) . catch ( ( e ) => {
142- // Replacing the current version with a hardcoded `v4` to make it stable
143- // when we release new minor/patch versions.
144- return Promise . reject (
145- stripNpmWarnings ( stripVTControlCharacters ( e . message . replace ( / \d + \. \d + \. \d + / g, '4.0.0' ) ) ) ,
146- )
147- } )
148- } ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
149- "Command failed: bun x @tailwindcss/upgrade
150- ≈ tailwindcss v4.0.0
151-
152- │ ↳ Upgrading from Tailwind CSS \`v4.0.0\`
153-
154- │ ↳ Version mismatch
155- │
156- │ \`\`\`diff
157- │ - "tailwindcss": "^3" (expected version in \`package.json\`)
158- │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`)
159- │ \`\`\`
160- │
161- │ Make sure to run \`bun install\` and try again.
162-
163- "
164- ` )
165- } ,
166- )
167-
168- test (
169- 'upgrades half-upgraded v3 project to v4 (npm)' ,
170- {
171- fs : {
172- 'package.json' : json `
173- {
174- "dependencies" : {
175- "tailwindcss" : "^3" ,
176- "@tailwindcss/upgrade" : "workspace:^"
177- },
178- "devDependencies" : {
179- "@tailwindcss/cli" : "workspace:^"
180- }
181- }
182- ` ,
183- 'tailwind.config.js' : js `
184- /** @type {import('tailwindcss').Config} */
185- module .exports = {
186- content : ['./src/**/*.{html,js}' ],
187- }
188- ` ,
189- 'src/index.html' : html `
190- <div class= "!flex" > Hello Wor ld</div>
191- ` ,
192- 'src/input.css' : css `
193- @tailwind base;
194- @tailwind components;
195- @tailwind utilities;
196- ` ,
197- } ,
198- } ,
199- async ( { exec, expect } ) => {
200- // Use `npm` to install dependencies
201- await exec ( 'rm ./pnpm-lock.yaml' )
202- await exec ( 'rm -rf ./node_modules' )
203- try {
204- await exec ( 'npm install' , { } , { ignoreStdErr : true } )
205- } catch ( e ) {
206- // When preparing for a release, the version in `package.json` will point
207- // to a non-existent version because it's not published yet.
208- // TODO: Find a better approach to handle this and actually test it even
209- // on release branches. Note: the pnpm version _does_ work because of
210- // overrides in the package.json file.
211- if ( `${ e } ` . includes ( 'npm error code ETARGET' ) ) return
212- throw e
213- }
214-
215- // Ensure we are in a git repo
216- await exec ( 'git init' )
217- await exec ( 'git add --all' )
218- await exec ( 'git commit -m "before migration" --allow-empty' )
219-
220- // Fully upgrade to v4
221- await exec ( 'npx @tailwindcss/upgrade' )
222-
223- // Undo all changes to the current repo. This will bring the repo back to a
224- // v3 state, but the `node_modules` will now have v4 installed.
225- await exec ( 'git reset --hard' )
226- await exec ( 'git clean -df' )
227-
228- // Re-running the upgrade should result in an error
229- return expect ( ( ) => {
230- return exec ( 'npx @tailwindcss/upgrade' , { } , { ignoreStdErr : true } ) . catch ( ( e ) => {
231- // Replacing the current version with a hardcoded `v4` to make it stable
232- // when we release new minor/patch versions.
233- return Promise . reject (
234- stripNpmWarnings ( stripVTControlCharacters ( e . message . replace ( / \d + \. \d + \. \d + / g, '4.0.0' ) ) ) ,
235- )
236- } )
237- } ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
238- "Command failed: npx @tailwindcss/upgrade
239- ≈ tailwindcss v4.0.0
240-
241- │ ↳ Upgrading from Tailwind CSS \`v4.0.0\`
242-
243- │ ↳ Version mismatch
244- │
245- │ \`\`\`diff
246- │ - "tailwindcss": "^3" (expected version in \`package.json\`)
247- │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`)
248- │ \`\`\`
249- │
250- │ Make sure to run \`npm install\` and try again.
251-
252- "
253- ` )
254- } ,
255- )
78+ // test(
79+ // 'upgrades half-upgraded v3 project to v4 (bun)',
80+ // {
81+ // fs: {
82+ // 'package.json': json`
83+ // {
84+ // "dependencies": {
85+ // "tailwindcss": "^3",
86+ // "@tailwindcss/upgrade": "workspace:^"
87+ // },
88+ // "devDependencies": {
89+ // "@tailwindcss/cli": "workspace:^",
90+ // "bun": "^1.0.0"
91+ // }
92+ // }
93+ // `,
94+ // 'tailwind.config.js': js`
95+ // [>* @type {import('tailwindcss').Config } <]
96+ // module.exports = {
97+ // content: ['./src/**/*.{html,js}'],
98+ // }
99+ // `,
100+ // 'src/index.html': html`
101+ // <div class="!flex">Hello World</div>
102+ // `,
103+ // 'src/input.css': css`
104+ // @tailwind base;
105+ // @tailwind components;
106+ // @tailwind utilities;
107+ // `,
108+ // },
109+ // },
110+ // async ({ exec, expect }) => {
111+ // // Use `bun` to install dependencies
112+ // await exec('rm ./pnpm-lock.yaml')
113+ // try {
114+ // await exec('npm rebuild bun') // Run postinstall of bun
115+ // await exec('npx bun install', {}, { ignoreStdErr: true })
116+ // } catch (e) {
117+ // // When preparing for a release, the version in `package.json` will point
118+ // // to a non-existent version because it's not published yet.
119+ // // TODO: Find a better approach to handle this and actually test it even
120+ // // on release branches. Note: the pnpm version _does_ work because of
121+ // // overrides in the package.json file.
122+ // if (`${e}`.includes('No version matching')) return
123+ // throw e
124+ // }
125+ //
126+ // // Ensure we are in a git repo
127+ // await exec('git init')
128+ // await exec('git add --all')
129+ // await exec('git commit -m "before migration" --allow-empty')
130+ //
131+ // // Fully upgrade to v4
132+ // await exec('bun x @tailwindcss/upgrade')
133+ //
134+ // // Undo all changes to the current repo. This will bring the repo back to a
135+ // // v3 state, but the `node_modules` will now have v4 installed.
136+ // await exec('git reset --hard')
137+ // await exec('git clean -df')
138+ //
139+ // // Re-running the upgrade should result in an error
140+ // return expect(() => {
141+ // return exec('bun x @tailwindcss/upgrade', {}, { ignoreStdErr: true }).catch((e) => {
142+ // // Replacing the current version with a hardcoded `v4` to make it stable
143+ // // when we release new minor/patch versions.
144+ // return Promise.reject(
145+ // stripNpmWarnings(stripVTControlCharacters(e.message.replace(/\d+\.\d+\.\d+/g, '4.0.0'))),
146+ // )
147+ // })
148+ // }).rejects.toThrowErrorMatchingInlineSnapshot(`
149+ // "Command failed: bun x @tailwindcss/upgrade
150+ // ≈ tailwindcss v4.0.0
151+ //
152+ // │ ↳ Upgrading from Tailwind CSS \`v4.0.0\`
153+ //
154+ // │ ↳ Version mismatch
155+ // │
156+ // │ \`\`\`diff
157+ // │ - "tailwindcss": "^3" (expected version in \`package.json\`)
158+ // │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`)
159+ // │ \`\`\`
160+ // │
161+ // │ Make sure to run \`bun install\` and try again.
162+ //
163+ // "
164+ // `)
165+ // },
166+ // )
167+ //
168+ // test(
169+ // 'upgrades half-upgraded v3 project to v4 (npm)',
170+ // {
171+ // fs: {
172+ // 'package.json': json`
173+ // {
174+ // "dependencies": {
175+ // "tailwindcss": "^3",
176+ // "@tailwindcss/upgrade": "workspace:^"
177+ // },
178+ // "devDependencies": {
179+ // "@tailwindcss/cli": "workspace:^"
180+ // }
181+ // }
182+ // `,
183+ // 'tailwind.config.js': js`
184+ // [>* @type {import('tailwindcss').Config } <]
185+ // module.exports = {
186+ // content: ['./src/**/*.{html,js}'],
187+ // }
188+ // `,
189+ // 'src/index.html': html`
190+ // <div class="!flex">Hello World</div>
191+ // `,
192+ // 'src/input.css': css`
193+ // @tailwind base;
194+ // @tailwind components;
195+ // @tailwind utilities;
196+ // `,
197+ // },
198+ // },
199+ // async ({ exec, expect }) => {
200+ // // Use `npm` to install dependencies
201+ // await exec('rm ./pnpm-lock.yaml')
202+ // await exec('rm -rf ./node_modules')
203+ // try {
204+ // await exec('npm install', {}, { ignoreStdErr: true })
205+ // } catch (e) {
206+ // // When preparing for a release, the version in `package.json` will point
207+ // // to a non-existent version because it's not published yet.
208+ // // TODO: Find a better approach to handle this and actually test it even
209+ // // on release branches. Note: the pnpm version _does_ work because of
210+ // // overrides in the package.json file.
211+ // if (`${e}`.includes('npm error code ETARGET')) return
212+ // throw e
213+ // }
214+ //
215+ // // Ensure we are in a git repo
216+ // await exec('git init')
217+ // await exec('git add --all')
218+ // await exec('git commit -m "before migration" --allow-empty')
219+ //
220+ // // Fully upgrade to v4
221+ // await exec('npx @tailwindcss/upgrade')
222+ //
223+ // // Undo all changes to the current repo. This will bring the repo back to a
224+ // // v3 state, but the `node_modules` will now have v4 installed.
225+ // await exec('git reset --hard')
226+ // await exec('git clean -df')
227+ //
228+ // // Re-running the upgrade should result in an error
229+ // return expect(() => {
230+ // return exec('npx @tailwindcss/upgrade', {}, { ignoreStdErr: true }).catch((e) => {
231+ // // Replacing the current version with a hardcoded `v4` to make it stable
232+ // // when we release new minor/patch versions.
233+ // return Promise.reject(
234+ // stripNpmWarnings(stripVTControlCharacters(e.message.replace(/\d+\.\d+\.\d+/g, '4.0.0'))),
235+ // )
236+ // })
237+ // }).rejects.toThrowErrorMatchingInlineSnapshot(`
238+ // "Command failed: npx @tailwindcss/upgrade
239+ // ≈ tailwindcss v4.0.0
240+ //
241+ // │ ↳ Upgrading from Tailwind CSS \`v4.0.0\`
242+ //
243+ // │ ↳ Version mismatch
244+ // │
245+ // │ \`\`\`diff
246+ // │ - "tailwindcss": "^3" (expected version in \`package.json\`)
247+ // │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`)
248+ // │ \`\`\`
249+ // │
250+ // │ Make sure to run \`npm install\` and try again.
251+ //
252+ // "
253+ // `)
254+ // },
255+ // )
256256
257257function stripNpmWarnings ( input : string ) {
258258 return input . replace ( / n p m w a r n .* ?\n / g, '' )
0 commit comments