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

Update globby to v7.1.1 #6639

Closed
wants to merge 20 commits into from
Closed

Update globby to v7.1.1 #6639

wants to merge 20 commits into from

Conversation

fisker
Copy link
Member

@fisker fisker commented Oct 12, 2019

with globby v7.1.1, we support dot pattern and expandDirectories now.

fixes: #6085

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • (If the change is user-facing) I’ve added my changes to the CHANGELOG.unreleased.md file following the template.
  • I’ve read the contributing guidelines.

Try the playground for this PR

lydell
lydell previously approved these changes Oct 12, 2019
@alexander-akait
Copy link
Member

alexander-akait commented Oct 14, 2019

Added expandDirectories option which is on by default. The nodir option is now also true by default. This means that by default it will now only return file paths, not directory paths. cf55e5c

Looks like breaking changem try to use . pattern

@lydell
Copy link
Member

lydell commented Oct 14, 2019

Sounds like we need to add some tests, then.

@fisker

This comment has been minimized.

src/cli/util.js Outdated Show resolved Hide resolved
@brodybits brodybits mentioned this pull request Oct 27, 2019
Copy link
Contributor

@brodybits brodybits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my questions & comment

scripts/run-external-tests.js Outdated Show resolved Hide resolved
src/cli/util.js Outdated Show resolved Hide resolved
src/common/load-plugins.js Show resolved Hide resolved
src/cli/util.js Outdated Show resolved Hide resolved
@brodybits
Copy link
Contributor

I have a few more questions:

  • Any explanation for the small loss of code coverage?
  • Could this resolve support dot pattern for CLI #6085?
  • Should we consider using globby@10 if we do not support install from GitHub on Node.js 6?

@fisker
Copy link
Member Author

fisker commented Oct 28, 2019

I was trying to make tests the another day, then I got distracted by #6665 .

Those options are really confusing me, as I understand,

nodir means donot list dirname , since we are looking for file we should use default true

expandDirectories also means that?

@brodybits
Copy link
Contributor

I think part of the confusion is how much globby has changed over quite a few major versions. I think we should try to research and understand this carefully before making any more adjustments. I do think we should also avoid using any options not really needed.

I am now really thinking we should consider using the latest rather than trying to deal with the old, unsupported package versions.

Unfortunately I don't have much time to look into this right now.

@brodybits
Copy link
Contributor

I tried raising RFC PR #6748 to try globby@10 update for discussion, seems to be mostly working with a few TODO items. I think that nodir setting is not needed in some newer versions of globby, removing it does not cause any failures. I am also thinking that expandDirectories should not be an issue since Prettier only works with files. But I may prove to be mistaken here.

@fisker
Copy link
Member Author

fisker commented Oct 30, 2019

closing in favor of #6748

@fisker fisker closed this Oct 30, 2019
@brodybits
Copy link
Contributor

closing in favor of #6748

Any ideas how we can resolve the TODO items in PR #6748?

@fisker fisker reopened this Nov 1, 2019
@fisker fisker changed the title Update globby to v7.1.1 Support dot pattern and expandDirectories with globby@7.1.1 Nov 1, 2019
@fisker
Copy link
Member Author

fisker commented Nov 1, 2019

@lydell @evilebottnawi @brodybits

I reopened this, and add dot pattern and expandDirectories tests.

This will not breaking anything, but support prettier . and prettier src, we can safely add this to v1.19


expect.addSnapshotSerializer(require("../path-serializer"));

// TODO: move `multiple-patterns` tests into this one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we would want to do this in the future?

I would only favor combining tests if they have the exact same output and can help reduce the number of snapshots we have to maintain.

Assuming there would be a good reason to do this, I would really favor adding this comment to tests_integration/__tests__/multiple-patterns.js as well to avoid losing track of this TODO item.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all tests are multiple-patterns , name to patterns should be more reasonable

@fisker
Copy link
Member Author

fisker commented Nov 1, 2019

@lydell

If I understand currectly, what do you want is
prettier . --write
prettier dir/ --write
prettier . --list
prettier dir/ --list
not print UndefinedParserError

and
prettier **/* --write
prettier dir/**/* --write
prettier **/* --list
prettier dir/**/* --list

print UndefinedParserError (currently behavior)

is that currect?

@lydell
Copy link
Member

lydell commented Nov 1, 2019

Yes, that’s correct!

@fisker
Copy link
Member Author

fisker commented Nov 1, 2019

  1. prettier dir1 dir2
  2. prettier dir1 dir2/**/*
  3. prettier non-exists-dir dir2/**/*
  4. prettier . dir2/**/*

Can you explain to me, what those 4 should be?

@lydell
Copy link
Member

lydell commented Nov 1, 2019

  1. prettier dir1 dir2 – prettify all files with supported extensions inside dir1 and dir2.
  2. prettier dir1 dir2/**/* – prettify all files with supported extensions inside dir1 as well as all files matched by the dir2/**/* glob. If any of the latter files have unknown extensions – log an error for them.
  3. prettier non-exists-dir dir2/**/* – log an error that non-exists-dir resulted in 0 files and prettify all files matched by the dir2/**/* glob. If any of the latter files have unknown extensions – log an error for them.
  4. prettier . dir2/**/* – prettify all files with supported extensions in . and all files matched by the dir2/**/* glob. If any of the latter files have unknown extensions – log an error for them.

I basically want the same behavior as eslint.

@fisker
Copy link
Member Author

fisker commented Nov 1, 2019

just to clearify not supported extensions, because parser can be override by config.

@lydell
Copy link
Member

lydell commented Nov 1, 2019

For every file we go through, try to resolve the final config to use for that file like we already do. If parser is missing, throw an error if the file came from a full path or glob, and ignore the file if it came from a folder pattern. If a pattern (item in process.argv) results in 0 files (non-existent folder, empty folder, folder with no supported files, glob that does not match anything, non-existent file), warn about it resulting in 0 files.

@brodybits
Copy link
Contributor

For every file we go through, try to resolve the final config to use for that file like we already do.
[...]

Shouldn't this already be covered by the test suite?

If not, I think we should add the missing tests.

@fisker fisker changed the title Support dot pattern and expandDirectories with globby@7.1.1 Update globby to v7.1.1 Nov 1, 2019
@fisker
Copy link
Member Author

fisker commented Nov 1, 2019

I've disabled all the behavior changes, it's only package upgrade now.

@alexander-akait
Copy link
Member

Also don't forget what plugins can add own extensions and it should be tested also (when we implement . support)

@@ -407,11 +407,13 @@ function eachFilename(context, patterns, callback) {
patterns = patterns.concat(["!**/node_modules/**", "!./node_modules/**"]);
}
patterns = patterns.concat(["!**/.{git,svn,hg}/**", "!./.{git,svn,hg}/**"]);
patterns = patterns.filter(pattern => pattern !== ".");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comment here why we do this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fisker fisker mentioned this pull request Jan 29, 2020
4 tasks
@alexander-akait
Copy link
Member

@fisker please fix conflicts and let's do it for next

@prettier/core please review

# Conflicts:
#	package.json
#	yarn.lock
@fisker fisker changed the base branch from master to next January 29, 2020 13:54
@fisker
Copy link
Member Author

fisker commented Jan 29, 2020

Rebased & CI passed.

@fisker
Copy link
Member Author

fisker commented Feb 4, 2020

What are we going to do with this one?

@alexander-akait
Copy link
Member

@fisker If we can't update globby to latest we need merge this branch

@fisker
Copy link
Member Author

fisker commented Feb 16, 2020

Closing in favor of #6776

@fisker fisker closed this Feb 16, 2020
@fisker fisker deleted the update-globby branch April 21, 2020 07:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants