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

[New] add --entrypoints-legacy CLI command #156

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

ljharb
Copy link
Contributor

@ljharb ljharb commented Feb 27, 2024

Note that the snapshots here are incorrect - despite these changes working as expected on the actual project/version in question, it's not working when i run the tests locally.

Closes #153.

Copy link

changeset-bot bot commented Feb 27, 2024

🦋 Changeset detected

Latest commit: ab6cd95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@arethetypeswrong/cli Minor
@arethetypeswrong/core Minor
@arethetypeswrong/history Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

@arethetypeswrong/core always receives or fetches an npm tarball as an input. Isn’t using packlist/arborist redundant with that input? Can we just use all files it can see in the Package object?

packages/core/src/checkPackage.ts Outdated Show resolved Hide resolved
@ljharb
Copy link
Contributor Author

ljharb commented Feb 27, 2024

ah, hmm, i suppose that's true - i was assuming it runs in-situ, but i guess the pack option takes care of that?

I'll refactor to just look at the files, and that should remove the need for path as well as the added deps.

@ljharb
Copy link
Contributor Author

ljharb commented Feb 27, 2024

thanks, that's much simpler. the snapshot still isn't matching the actual behavior of the built cli, tho.

@andrewbranch
Copy link
Collaborator

I checked this out locally, ran tests, and got a new snapshot:

❯ git diff --staged
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
added: packages/cli/test/snapshots/eslint-module-utils@2.8.1.tgz --entrypoints-legacy --ignore-rules=cjs-only-exports-default.md
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@ packages/cli/test/snapshots/eslint-module-utils@2.8.1.tgz --entrypoints-legacy --ignore-rules=cjs-only-exports-default.md:4 @
# eslint-module-utils@2.8.1.tgz --entrypoints-legacy --ignore-rules=cjs-only-exports-default

```
$ attw eslint-module-utils@2.8.1.tgz --entrypoints-legacy --ignore-rules=cjs-only-exports-default


eslint-module-utils v2.8.1

Build tools:
- typescript@next

 (ignoring rules: 'cjs-only-exports-default')

 No problems found 🌟


┌─────────────────────────────────────────┬────────┬───────────────────┬───────────────────┬─────────┐
│                                         │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/declaredScope.js"  │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/hash.js"           │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/ignore.js"         │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/module-require.js" │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/ModuleCache.js"    │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/moduleVisitor.js"  │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/parse.js"          │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/pkgDir.js"         │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/pkgUp.js"          │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/readPkgUp.js"      │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/resolve.js"        │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/unambiguous.js"    │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
├─────────────────────────────────────────┼────────┼───────────────────┼───────────────────┼─────────┤
│ "eslint-module-utils/visit.js"          │ 🟢     │ 🟢 (CJS)          │ 🟢 (CJS)          │ 🟢      │
└─────────────────────────────────────────┴────────┴───────────────────┴───────────────────┴─────────┘


```

Exit code: 0
\ No newline at end of file

I think this looks right? What are you getting?

@ljharb
Copy link
Contributor Author

ljharb commented Feb 27, 2024

That's totally right! what i get is what's in this PR :-/

@ljharb
Copy link
Contributor Author

ljharb commented Feb 27, 2024

I was able to effectively start from scratch and get the md to update, but the json snapshot data still doesn't look right.

Copy link
Collaborator

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Almost ready to go; if you wouldn’t mind adding something to the CLI README too, that would be great. Thanks!

packages/core/src/internal/getEntrypointInfo.ts Outdated Show resolved Hide resolved
if (proxies.length === 0) {
if (options?.entrypointsLegacy) {
return fs.listFiles()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it was an existing bug that there are early returns in here; I don’t see why either “proxy directories” or these files shouldn’t interact with--include-entrypoints and --exclude-entrypoints. I can rearrange all this in a different PR though if you don’t want to touch it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh I'm not actually sure what "proxy directories" is for, it seems to always be empty in my experience - as for include/exclude, i guess it does make sense to explicitly exclude things from the legacy list, but i'm not sure what the point would be for include - what would you include that's not already there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably nothing, but maybe files that have non-standard/non-JS file extensions

@andrewbranch
Copy link
Collaborator

the json snapshot data still doesn't look right

The JSON snapshot is running the core library with default options; only the CLI test is getting the entrypointsLegacy option.

@ljharb
Copy link
Contributor Author

ljharb commented Feb 27, 2024

Updated except for #156 (comment)

I'm happy to expand the functionality, in this PR, so that --exclude-entrypoints can be used in concert with --entrypoints-legacy - but it should probably be an error to use --entrypoints or --include-entrypoints with it, since there's nothing that can possibly be included that's not already in the file list?

@andrewbranch andrewbranch marked this pull request as ready for review February 27, 2024 18:02
@andrewbranch andrewbranch merged commit 29d5811 into arethetypeswrong:main Feb 27, 2024
1 check passed
@andrewbranch
Copy link
Collaborator

Thanks @ljharb!

@ljharb ljharb deleted the legacy branch February 27, 2024 22:00
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.

confusing resolution failure
2 participants