Page MenuHomePhabricator

npm stylelint is broken due to dir-glob dependency upgrade
Closed, ResolvedPublic

Description

Example:

10:25:24 Running "stylelint:src" (stylelint) task
10:25:24 Warning: Path must be a string. Received undefined Use --force to continue.
10:25:24 
10:25:24 Aborted due to warnings.

And

Error: Error: getaddrinfo ENOTFOUND localhostw localhostw:80

Upstream related material:

Event Timeline

Addshore triaged this task as Unbreak Now! priority.Jan 9 2019, 9:44 AM

Mentioned in SAL (#wikimedia-operations) [2019-01-09T09:44:11Z] <hashar> Some CI npm jobs get broken due to a faulty node module. https://phabricator.wikimedia.org/T213249

Repro:

$ cd mediawiki/extensions/ContentTranslation
$ npm install
$ npm test
$ ./node_modules/.bin/grunt stylelint:src; echo "Exit code: $?"
Running "stylelint:src" (stylelint) task
Warning: Path must be a string. Received undefined Use --force to continue.

Aborted due to warnings.
Exit code: 3
$

The repository installs:

$ npm list|grep stylelint
├─┬ grunt-stylelint@0.10.1
├─┬ stylelint@9.2.0
└── stylelint-config-wikimedia@0.4.3

grunt-stylelint is latest version which got published 4 months ago.
stylelint latest is 9.9.0 but we have 9.2.0
stylelint-config-wikimedia is from 3 months ago

So I guess we want to find a repository which triggered the npm job and compare the console output of a successful build and the one of a failing build.

https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/ContentTranslation/+/483063/ is a good example.

OK https://integration.wikimedia.org/ci/job/mwgate-npm-node-6-docker/68967/console
FAIL https://integration.wikimedia.org/ci/job/mwgate-npm-node-6-docker/68988/console

To do the diff:

cd /tmp
curl https://integration.wikimedia.org/ci/job/mwgate-npm-node-6-docker/68967/consoleText > OK
curl https://integration.wikimedia.org/ci/job/mwgate-npm-node-6-docker/68988/consoleText > BAD
colordiff -u OK BAD | less -R
@@ -281,8 +281,7 @@
 │ ├─┬ globby@8.0.1 
 │ │ ├─┬ array-union@1.0.2 
 │ │ │ └── array-uniq@1.0.3 
-│ │ ├─┬ dir-glob@2.0.0 
-│ │ │ ├── arrify@1.0.1 
+│ │ ├─┬ dir-glob@2.2.0 
 │ │ │ └─┬ path-type@3.0.0 
 │ │ │   └── pify@3.0.0 
 │ │ ├─┬ fast-glob@2.2.6 
@@ -425,6 +424,7 @@
 │ │ │   └── array-find-index@1.0.2 
 │ │ ├── minimist@1.2.0 
 │ │ ├─┬ minimist-options@3.0.2 
+│ │ │ ├── arrify@1.0.1 
 │ │ │ └── is-plain-obj@1.1.0 
 │ │ ├─┬ normalize-package-data@2.4.0 
 │ │ │ ├── hosted-git-info@2.7.1 
@@ -621,38 +621,56 @@
 >> 299 files lint free.
 
 Running "stylelint:src" (stylelint) task
->> Linted 106 files without errors
+Warning: Path must be a string. Received undefined^G Use --force to continue.
 
-Running "banana:ContentTranslation" (banana) task
->> 395 messages checked.
+Aborted due to warnings.
 
-Done.

Or with word diff (wdiff):

$ wdiff OK BAD | colordiff | less -R
...
+ npm install --no-progress
/src
...
├─┬ stylelint@9.2.0 
│ ├─┬ globby@8.0.1 
│ │ ├─┬ [-dir-glob@2.0.0 
│ │ │ ├── arrify@1.0.1-] {+dir-glob@2.2.0+} 

The issue is that stylelint brings in dir-glob@2.2.0 when previously it got dir-glob@2.0.0

https://www.npmjs.com/package/dir-glob 2.2.0 got released an hour ago.

Note the github repository https://github.com/kevva/dir-glob . Recent changes:

https://github.com/kevva/dir-glob/commits/master

Filled Upstream at https://github.com/kevva/dir-glob/issues/10

globby v0.8.1 ( https://github.com/sindresorhus/globby/blob/v8.0.1/package.json ) has:

package.json
{
    "dependencies": {
        "dir-glob": "^2.0.0",
    }
}

Which previously matched 2.0.0 and now matches 2.2.0.

hashar renamed this task from stylelint is broken on master to npm stylelint is broken due to dir-glob dependency upgrade.Jan 9 2019, 10:18 AM

And a bug got filled for globby https://github.com/sindresorhus/globby/issues/98


I have no idea how we can pin dir-glob. Given stylelint is used accross hundred of repositories, we might be able to apply a fix but it is going to take a while (I think we can use our LibraryUpgrader for that).

Should be fixed by globby@0.8.2 which pin a previous version of dir-glob. PR is https://github.com/sindresorhus/globby/pull/99

Gotta wait for npm registry to catch up and then the issue should be fixed.