Skip to content

Adds configuration file update tool to CLI #783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

MattStypa
Copy link
Contributor

Summery

Users can now easily update their v0 configuration file to v1 configuration format using the update command.

Screen Shot 2019-03-18 at 9 36 49 PM

What else is in this?

  • I have added the container property to the theme in the default configuration stub.
  • Updated CLI commands to use consistent color scheme.
  • Updated CLI commands to show paths in a nicer way.
  • Changed the testing of the CLI commands. Tests will no longer fail if the configuration file exists.

What is NOT in this

The output is very verbose. In the future I want to:

  • Ommit configuration that is equal to the default.
  • Collapse colors and spacing like we currently do in the default configuration stub; if possible.

@adamwathan
Copy link
Member

Haha sick! Man I was working on something like this the last two days, wish I had known you were looking at it too... I'll pull this down and play with it today or tomorrow, there was a bunch of stuff I wasn't sure how to solve that I'm curious if you were able to fix.

The main messy points for me were preserving any third-party plugins and dealing with any weird structuring, like splitting things out into extra variables or god forbid files.

@MattStypa
Copy link
Contributor Author

It's possible that I missed something. This stuff is not easy. In a nutshell, I use real require to pull the configuration object in, which should resolve any "magic", users might have used. I briefly hijack the require method to swap old Tailwind dependencies like the default config and the container plugin with stand-ins.

@adamwathan
Copy link
Member

I just tried to run it against the default config from 0.7.4 but am getting this result:

image

Here's the repo I was hacking around in in case you're curious, still a mess but whatever.

https://github.com/adamwathan/upgrade-config

@MattStypa
Copy link
Contributor Author

MattStypa commented Mar 19, 2019

Can you share your tailwind.js file? I pulled the one from https://github.com/adamwathan/upgrade-config but I am getting a different issue.

Screen Shot 2019-03-19 at 10 13 29 AM

I assumed that all properties are required. The transform is very lenient and the validation rules can be relaxed quite a bit.

This could also be related to the Node version.

@MattStypa
Copy link
Contributor Author

I removed backgroundPosition from the validator. This resolved the issue I was having. I am still unable to replicate the problem @adamwathan had.

Can you think of any other properties that may not be present in the config file users will try to update?

@adamwathan
Copy link
Member

This is the file I was trying to update:

https://unpkg.com/[email protected]/defaultConfig.stub.js

Technically every key in the config file is optional although my current repo doesn't handle that gracefully either.

@MattStypa
Copy link
Contributor Author

MattStypa commented Mar 19, 2019

Ok. I replicated the issue.

This is caused by requiring a missing module.

  plugins: [
    require('./plugins/container')({
      // center: true,
      // padding: '1rem',
    }),
  ],

My guess is that you simply copied a stub over instead of using the init command. init should have replaced require('./plugins/container') with require('tailwindcss/plugins/container')

This configuration file probably does not work for building either.

I will refine this PR to handle missing keys in a more graceful way.

@adamwathan
Copy link
Member

Ah yeah good catch, my mistake. That said that kind of points to the more challenging issue I was trying to solve yesterday, where someone may have third party plugin references:

plugins: [
  require('some-third-party-plugin')({ ... }),
]

The only way I could think to handle it is by treating the upgrade process more like string replacement than actual manipulation of the config object, since I'd want to preserve those require statements in the new config file. Tricky shit :/ I think the ultimate approach would to do it with babel but I don't know if I really want to go down that road, hah...

@MattStypa
Copy link
Contributor Author

There might be a way to leverage what I am already doing for the container plugin. I think I can replace the external dependencies with placeholders and then swap them back in when generating the new config file.

Do you have any real-life examples of external plugins?

@MattStypa
Copy link
Contributor Author

I am going to close this PR for now for a few reasons

  1. It does not even work for external plugins
  2. There are some issues that are very hard to solve
  3. There are some minor CLI enhancements that don't need to be blocked for the reasons above

@MattStypa MattStypa closed this Mar 20, 2019
@adamwathan
Copy link
Member

I'll put together a little demo project today that includes some third party plugins and multiple different config files as test inputs and we can keep hacking on this. I've decided I'm going to push the final v1.0 release back a few more weeks so we can really polish the docs before opening the floodgates so we have a bit of time 👍

thecrypticace pushed a commit that referenced this pull request May 19, 2025
Here is everything you need to know about this update. Please take a
good look at what changed and the test results before merging this pull
request.

### What changed?




#### ✳️ semver (7.7.1 → 7.7.2) ·
[Repo](https://github.com/npm/node-semver) ·
[Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)



<details>
<summary>Release Notes</summary>
<h4><a
href="https://github.com/npm/node-semver/releases/tag/v7.7.2">7.7.2</a></h4>

<blockquote><h2 dir="auto">
<a
href="https://bounce.depfu.com/github.com/npm/node-semver/compare/v7.7.1...v7.7.2">7.7.2</a>
(2025-05-12)</h2>
<h3 dir="auto">Bug Fixes</h3>
<ul dir="auto">
<li>
<a
href="https://bounce.depfu.com/github.com/npm/node-semver/commit/fcafb61ed566ff8ccf24818dd94b76738f037aa4"><code
class="notranslate">fcafb61</code></a> <a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/780">#780</a>
add missing <code class="notranslate">'use strict'</code> directives (<a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/780">#780</a>)
(<a href="https://bounce.depfu.com/github.com/Fdawgs">@Fdawgs</a>)</li>
<li>
<a
href="https://bounce.depfu.com/github.com/npm/node-semver/commit/c99f336fa3bdff465652f9041eab2127d2f52eb2"><code
class="notranslate">c99f336</code></a> <a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/781">#781</a>
prerelease identifier starting with digits (<a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/781">#781</a>)
(<a
href="https://bounce.depfu.com/github.com/mbtools">@mbtools</a>)</li>
</ul>
<h3 dir="auto">Chores</h3>
<ul dir="auto">
<li>
<a
href="https://bounce.depfu.com/github.com/npm/node-semver/commit/c760403b935d3ad35f83e9bbe5ebe1badef2fc71"><code
class="notranslate">c760403</code></a> <a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/784">#784</a>
template-oss-apply for workflow permissions (<a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/784">#784</a>)
(<a
href="https://bounce.depfu.com/github.com/wraithgar">@wraithgar</a>)</li>
<li>
<a
href="https://bounce.depfu.com/github.com/npm/node-semver/commit/2677f2a88334b0e728dbfe9ad9f5f57458437c87"><code
class="notranslate">2677f2a</code></a> <a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/778">#778</a>
bump @npmcli/template-oss from 4.23.6 to 4.24.3 (<a
href="https://bounce.depfu.com/github.com/npm/node-semver/pull/778">#778</a>)
(<a
href="https://bounce.depfu.com/github.com/dependabot">@dependabot</a>[bot],
<a
href="https://bounce.depfu.com/github.com/npm-cli-bot">@npm-cli-bot</a>)</li>
</ul></blockquote>
<p><em>Does any of this look wrong? <a
href="https://depfu.com/packages/npm/semver/feedback">Please let us
know.</a></em></p>
</details>

<details>
<summary>Commits</summary>
<p><a
href="https://github.com/npm/node-semver/compare/30c438bb46c74f319aa8783f96d233ebf5f4a90d...281055e7716ef0415a8826972471331989ede58c">See
the full diff on Github</a>. The new version differs by 6 commits:</p>
<ul>
<li><a
href="https://github.com/npm/node-semver/commit/281055e7716ef0415a8826972471331989ede58c"><code>chore:
release 7.7.2 (#783)</code></a></li>
<li><a
href="https://github.com/npm/node-semver/commit/fcafb61ed566ff8ccf24818dd94b76738f037aa4"><code>fix:
add missing `&#39;use strict&#39;` directives (#780)</code></a></li>
<li><a
href="https://github.com/npm/node-semver/commit/c760403b935d3ad35f83e9bbe5ebe1badef2fc71"><code>chore:
template-oss-apply for workflow permissions (#784)</code></a></li>
<li><a
href="https://github.com/npm/node-semver/commit/c99f336fa3bdff465652f9041eab2127d2f52eb2"><code>fix:
prerelease identifier starting with digits (#781)</code></a></li>
<li><a
href="https://github.com/npm/node-semver/commit/2677f2a88334b0e728dbfe9ad9f5f57458437c87"><code>chore:
bump @npmcli/template-oss from 4.23.6 to 4.24.3 (#778)</code></a></li>
<li><a
href="https://github.com/npm/node-semver/commit/0b98655dbc1a9eb79370ed80f557be98d1c06587"><code>chore:
bump @npmcli/template-oss from 4.23.4 to 4.23.6 (#760)</code></a></li>
</ul>
</details>












---
![Depfu
Status](https://depfu.com/badges/edd6acd35d74c8d41cbb540c30442adf/stats.svg)

[Depfu](https://depfu.com) will automatically keep this PR
conflict-free, as long as you don't add any commits to this branch
yourself. You can also trigger a rebase manually by commenting with
`@depfu rebase`.

<details><summary>All Depfu comment commands</summary>
<blockquote><dl>
<dt>@​depfu rebase</dt><dd>Rebases against your default branch and
redoes this update</dd>
<dt>@​depfu recreate</dt><dd>Recreates this PR, overwriting any edits
that you've made to it</dd>
<dt>@​depfu merge</dt><dd>Merges this PR once your tests are passing and
conflicts are resolved</dd>
<dt>@​depfu cancel merge</dt><dd>Cancels automatic merging of this
PR</dd>
<dt>@​depfu close</dt><dd>Closes this PR and deletes the branch</dd>
<dt>@​depfu reopen</dt><dd>Restores the branch and reopens this PR (if
it's closed)</dd>
<dt>@​depfu pause</dt><dd>Ignores all future updates for this dependency
and closes this PR</dd>
<dt>@​depfu pause [minor|major]</dt><dd>Ignores all future minor/major
updates for this dependency and closes this PR</dd>
<dt>@​depfu resume</dt><dd>Future versions of this dependency will
create PRs again (leaves this PR as is)</dd>
</dl></blockquote>
</details>

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants