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

[BUG/QUESTION] since npm 9.x some files[] globs undermatch #152

Open
1 task done
43081j opened this issue Jan 6, 2023 · 4 comments
Open
1 task done

[BUG/QUESTION] since npm 9.x some files[] globs undermatch #152

43081j opened this issue Jan 6, 2023 · 4 comments
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue

Comments

@43081j
Copy link

43081j commented Jan 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Given this:

{
  "files": [
    "lib/(!test)"
  ]
}

and a tree like this:

- lib
  - main.js
  - foo.js
  - utils
    - foo-util.js
  - test
    - main_test.js
    - foo_test.js
    - utils
      - foo-util_test.js

before the hefty refactor that happened around npm 9 (in npm-packlist), that glob would result in this:

- lib
  - main.js
  - foo.js
  - utils
    - foo-util.js

After the refactor, this is the resulting packed tree:

- lib
  - main.js

meaning the glob was ignored really (since ${main} is enforceably included).

it can be solved by changing the files array to this:

{
  "files": [
    "lib/",
    "!lib/test/"
  ]
}

which im fine with, but it does mean you've introduced a breaking change which i can't see in the changelog (could be me being blind though).

can you clarify if this is a bug or intentional? and close this if it is the latter, with an explanation if you can

Expected Behavior

glob is respected

Steps To Reproduce

N/A

Environment

  • npm: 9.2.0
  • Node: 19.3.0
  • OS: MacOS
@43081j 43081j added Bug thing that needs fixing Needs Triage needs an initial review labels Jan 6, 2023
@tido64
Copy link

tido64 commented Feb 8, 2023

Furthermore, given the following rules:

  "files": [
    "/*.{gradle,js,md,podspec,rb}",
    "/android/**/*.gradle",
    "/android/app/lint.xml",
    "/android/app/src",
    "!/android/app/src/test",
    "/android/support/src",
    "/common",
    "/example/_gitignore",
    "/example/android/gradle*",
    "/example/windows/_gitignore",
    "/example/{metro,react-native}.config.js",
    "/ios",
    "/macos",
    "/plugins",
    "/schema.json",
    "/scripts/*.js",
    "/scripts/apply-config-plugins.mjs",
    "/scripts/config-plugins/**/*.mjs",
    "/windows/*.{js,props}",
    "/windows/ReactTestApp"
  ],

I am seeing it include/exclude random files (before/after):

image

/example/android/gradle* no longer matches example/android/gradle/wrapper/gradle-wrapper.jar and example/android/gradle/wrapper/gradle-wrapper.properties. Instead, it includes random files under example/ that aren't even mentioned.

@tido64
Copy link

tido64 commented Feb 8, 2023

@fritzy: Sorry for the random ping but do you happen to know who could take a look at this?

@tido64
Copy link

tido64 commented Feb 16, 2023

It also looks like the content of npm pack differs from running npm-packlist manually:

-rw-r--r--  0 0      0         145 26 okt  1985 package/example/_gitignore
-rw-r--r--  0 0      0         342 26 okt  1985 package/example/windows/_gitignore
-rwxr-xr-x  0 0      0        8188 26 okt  1985 package/example/android/gradlew
-rw-r--r--  0 0      0        2747 26 okt  1985 package/example/android/gradlew.bat
-rw-r--r--  0 0      0         616 26 okt  1985 package/example/android/build.gradle
-rw-r--r--  0 0      0         246 26 okt  1985 package/example/android/settings.gradle
-rw-r--r--  0 0      0       60756 26 okt  1985 package/example/android/gradle/wrapper/gradle-wrapper.jar
-rw-r--r--  0 0      0        5165 26 okt  1985 package/example/App.js
-rw-r--r--  0 0      0          77 26 okt  1985 package/example/babel.config.js
-rw-r--r--  0 0      0         180 26 okt  1985 package/example/index.js
-rw-r--r--  0 0      0        1315 26 okt  1985 package/example/metro.config.js
-rw-r--r--  0 0      0         458 26 okt  1985 package/example/react-native.config.js
-rw-r--r--  0 0      0         802 26 okt  1985 package/example/Example-Tests.podspec
-rw-r--r--  0 0      0         202 26 okt  1985 package/example/android/gradle/wrapper/gradle-wrapper.properties
-rw-r--r--  0 0      0        1885 26 okt  1985 package/example/android/gradle.properties

I couldn't get npm-packlist@7 to run (apparently because bin was removed), but here's the output of 6:

example/_gitignore
example/windows/_gitignore
example/android/gradlew
example/android/gradlew.bat
example/android/gradle/wrapper/gradle-wrapper.jar
example/metro.config.js
example/react-native.config.js
example/android/gradle/wrapper/gradle-wrapper.properties
example/android/gradle.properties

I still don't understand where the extra files are coming from…

@lukekarrys: Maybe you have an idea of what's going on here?

@lukekarrys lukekarrys added Priority 1 high priority issue and removed Needs Triage needs an initial review labels Feb 16, 2023
@lukekarrys
Copy link
Contributor

Possibly related to npm/cli#6164. And if not, still worth investigating both issues together I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue
Projects
None yet
Development

No branches or pull requests

3 participants