Skip to content
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

Fix crash during upgrade when content globs escape root of project #14896

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Nov 6, 2024

This PR fixes an issue where globs in you content configuration escape the current "root" of the project.

This can happen if you have a folder, and you need to look up in the tree (e.g.: when looking at another package in a monorepo, or in case of a Laravel project where you want to look at mail templates).

This applies a similar strategy we already implement on the Rust side.

  1. Expand braces in the globs
  2. Move static parts of the pattern to the base of the glob entry object

Given a project setup like this:

.
├── admin
│   ├── my-tailwind.config.ts
│   └── src
│       ├── abc.jpg
│       ├── index.html
│       ├── index.js
│       └── styles
│           └── input.css
├── dashboard
│   ├── src
│   │   ├── index.html
│   │   ├── index.js
│   │   ├── input.css
│   │   └── pickaday.css
│   └── tailwind.config.ts
├── package-lock.json
├── package.json
├── postcss.config.js
└── unrelated
    └── index.html

7 directories, 14 files

If you then have this config:

// admin/my-tailwind.config.ts
export default {
  content: {
    relative: true,
    files: ['./src/**/*.html', '../dashboard/src/**/*.html'],
                            //  ^^  this is the important part, which escapes
                            //      the current root of the project.
  },
  theme: {
    extend: {
      colors: {
        primary: 'red',
      },
    },
  },
}

Then before this change, running the command looks like this:
image

After this change, running the command looks like this:
image

@RobinMalfait RobinMalfait changed the title Fix crash during upgrade when content globs escape root of projeect Fix crash during upgrade when content globs escape root of project Nov 6, 2024
@RobinMalfait RobinMalfait marked this pull request as ready for review November 6, 2024 15:27
@RobinMalfait RobinMalfait requested a review from a team as a code owner November 6, 2024 15:27
@RobinMalfait RobinMalfait force-pushed the fix/crash-during-content-migration branch 2 times, most recently from dc3b046 to 29d6241 Compare November 7, 2024 09:39
@RobinMalfait RobinMalfait enabled auto-merge (squash) November 7, 2024 12:00
RobinMalfait and others added 5 commits November 7, 2024 13:05
This is an implementation similar to what we already have in Rust. The
idea is that we want to move the static parts to the `base` path. This
allows us to use `..` in the pattern and the glob would be adjusted
correctly.

Without this, globby will error if your pattern escapes the base path by
using `..` in the pattern.
@RobinMalfait RobinMalfait force-pushed the fix/crash-during-content-migration branch from f5bc8f7 to 17c7bda Compare November 7, 2024 12:05
@RobinMalfait RobinMalfait merged commit 75eeed8 into next Nov 7, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the fix/crash-during-content-migration branch November 7, 2024 12:22
thecrypticace added a commit that referenced this pull request Nov 7, 2024
This ensures our glob hoisting mechanism (see #14896) works on Windows
when performing an upgrade.

---------

Co-authored-by: Jordan Pittman <[email protected]>
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