|
1 | 1 | TAILWIND_CONFIG_PATH = Rails.root.join("config/tailwind.config.js") |
2 | 2 | APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb") |
| 3 | +POSTCSS_CONFIG_PATH = Rails.root.join("config/postcss.config.js") |
3 | 4 |
|
4 | | -if TAILWIND_CONFIG_PATH.exist? |
5 | | - if File.read(TAILWIND_CONFIG_PATH).match?(/defaultTheme/) |
6 | | - say "Removing references to 'defaultTheme' from #{TAILWIND_CONFIG_PATH}" |
7 | | - gsub_file TAILWIND_CONFIG_PATH.to_s, /^(.*defaultTheme)/, "// \\1" |
8 | | - end |
| 5 | +unless TAILWIND_CONFIG_PATH.exist? |
| 6 | + say "Default tailwind.config.js is missing!", :red |
| 7 | + abort |
| 8 | +end |
9 | 9 |
|
10 | | - if system("npx --version") |
11 | | - say "Running the upstream Tailwind CSS upgrader" |
12 | | - command = Shellwords.join(["npx", "@tailwindcss/upgrade@next", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) |
13 | | - success = run(command, abort_on_failure: false) |
14 | | - unless success |
15 | | - say "The upgrade tool failed!", :red |
16 | | - say %( You probably need to update your configuration. Please read the error messages,) |
17 | | - say %( and check the Tailwind CSS upgrade guide at https://tailwindcss.com/docs/upgrade-guide.) |
18 | | - abort |
19 | | - end |
20 | | - else |
21 | | - say "Could not run the Tailwind upgrade tool. Please see https://tailwindcss.com/docs/upgrade-guide for manual instructions.", :red |
| 10 | +if File.read(TAILWIND_CONFIG_PATH).match?(/defaultTheme/) |
| 11 | + say "Removing references to 'defaultTheme' from #{TAILWIND_CONFIG_PATH}" |
| 12 | + gsub_file TAILWIND_CONFIG_PATH.to_s, /^(.*defaultTheme)/, "// \\1" |
| 13 | +end |
| 14 | + |
| 15 | +if POSTCSS_CONFIG_PATH.exist? |
| 16 | + say "Moving PostCSS configuration to application root directory" |
| 17 | + FileUtils.mv(POSTCSS_CONFIG_PATH, Rails.root, verbose: true) || abort |
| 18 | +end |
| 19 | + |
| 20 | +if system("npx --version") |
| 21 | + say "Running the upstream Tailwind CSS upgrader" |
| 22 | + command = Shellwords.join(["npx", "@tailwindcss/upgrade@next", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) |
| 23 | + success = run(command, abort_on_failure: false) |
| 24 | + unless success |
| 25 | + say "The upgrade tool failed!", :red |
| 26 | + say %( You probably need to update your configuration. Please read the error messages,) |
| 27 | + say %( and check the Tailwind CSS upgrade guide at https://tailwindcss.com/docs/upgrade-guide.) |
22 | 28 | abort |
23 | 29 | end |
24 | 30 | else |
25 | | - say "Default tailwind.config.js is missing!", :red |
| 31 | + say "Could not run the Tailwind upgrade tool. Please see https://tailwindcss.com/docs/upgrade-guide for manual instructions.", :red |
26 | 32 | abort |
27 | 33 | end |
28 | 34 |
|
|
0 commit comments