Commit graph

23 commits

Author SHA1 Message Date
Ed Sanders a17be78b3d build: Update linters
Change-Id: I9b32f412e7e75918a59bdb239d3a42670177be70
2019-08-15 09:55:57 +02:00
WMDE-Fisch 7d7317da10 build: bump dependencies and make tests pass
Change-Id: I5fb80d19c7a0423648053c66fd9c2b7680f30426
2019-08-14 17:09:18 +02:00
Nicholas Ray be27746e59 Build: add package-lock file
Add package-lock file. The previous version of Node.js did not support
package-locks but v10.15.2 does.

Bug: T179229
Change-Id: I6cd0df235294dd455086ca3be569e63577a61b4f
2019-06-20 16:11:00 -06:00
Stephen Niedzielski 6d4eebe12b Hygiene: remove package-lock.json
Remove package-lock.json until a Node.js version that supports it is
possible.

Change-Id: I00d2168d8671d0f7fa2b999171e03c13bfac192a
2018-12-03 09:32:52 -07:00
Volker E f47e333ff1 build: Bring SVGO optimization to build step
Enabling SVGO automation with 'grunt-svgmin' and conservative
plugin settings to build step, among those:
- enable removeRasterImages and sortAttrs,
- disable cleanupIDs, removeDesc, removeTitle, & removeViewBox as
  described in
  https://www.mediawiki.org/wiki/Manual:Coding_conventions/SVG#Exemplified_safe_configuration
- disable removeXMLProcInst; if the SVG doesn't start with an XML
  declaration, then it's MIME type will be detected as "text/plain"
  rather than "image/svg+xml" by libmagic and, consequently, MediaWiki's
  CSSMin CSS minifier. libmagic's default database currently requires
  that SVGs contain an XML declaration:
  <https://github.com/threatstack/libmagic/blob/master/magic/Magdir/sgml#L5>.
- make use of pretty and multipass options.

Settings are stored in a JSON file to be independent of the Grunt build
process. Also updating SVG accordingly.

Bug: T185596
Change-Id: I715ad4cf2e900665e4c32c78b4c2d9d9cebf0222
2018-08-01 10:51:43 -05:00
jdlrobson 10e6e25091 Upgrade eslint-config-wikimedia
* Force arrow-parens
* Disable no-prototype-builtins for time being
* Drop unnecessary maxlen rule

Change-Id: Iceb0fe47354a5753202d2c6ad9e1a9c76791f744
2018-07-13 07:42:12 -05:00
Stephen Niedzielski 2d150f0aad Hygiene: update mw-node-qunit dependency package
mw-node-qunit has moved to a new NPM package, @wikimedia/mw-node-qunit.
There are no functional changes with this release but dependencies
should be kept up to date.

https://github.com/wikimedia/mw-node-qunit/blob/9a368a1/CHANGELOG.md#500

Bug: T197251
Change-Id: I25bfc541551cbc29812985df7fa05dc17f0338c5
2018-06-29 17:30:03 +00:00
Stephen Niedzielski 823b6af879 Hygiene: replace tap-dot reporter
The tap-dot executable crashes on some test failure outputs.[0] This is
confusing since a test failure in itself often requires debugging. The
issue is present from v1.0.1 to the latest, v2.0.0.

Instead of downgrading, replace tap-dot with the popular
tap-mocha-reporter. This change comes with a bonus: console.log is no
longer filtered out. The benefit cannot be overstated.

[0]: https://github.com/scottcorgan/tap-dot/issues/9

Change-Id: I4ce2d2816885b7c5214f5c1863be595be0d8b1aa
2018-06-27 09:16:07 -05:00
Stephen Niedzielski c2a37d75e2 Hygiene: remove doc:start script
The `doc:start` NPM script simply runs the `doc` script whenever a
change is detected. It doesn't seem especially useful for standard
development and adds an extra nodemon depedency. This patch removes the
script and nodemon.

Change-Id: Ib679f6d83bd10f0b8d1572c07080fba7f8d6a701
2018-06-20 09:36:53 -05:00
Stephen Niedzielski 95047ba360 Fix: code coverage
Replace Istanbul with nyc, Istanbul's CLI. nyc appears to have some
bugs that this patch works around:

  - When all files in the project are considered, not just those
    imported via tests, the coverage rates and line numbers vary between
    runs. This patch disables the `all` option for now and points to the
    bug:
    https://github.com/istanbuljs/nyc/issues/537#issuecomment-390814662.

  - Source map line numbers appear to be incorrect except when `all` is
    enabled and working correctly (see previous bullet).

  - `sourceMap` must be disabled to avoid ENAMETOOLONG errors when nyc
    tries to include them as encoded strings. The patch disables the
    setting and points to: https://github.com/istanbuljs/nyc/issues/847.
    Using babel-plugin-istanbul and source-map-support appears to have
    no effect (the former in tests/node-qunit/run.js and .babelrc).

  - CI fails with
    `Error: EACCES: permission denied, mkdir '/nonexistent'`. Specify
    `SPAWN_WRAP_SHIM_ROOT` instead of constructing a subdirectory from a
    nonexistent home directory.

Bug: T196952
Bug: T193519
Change-Id: Idf2e3accd4a6277cbef91c1156fcd206c9e7d882
2018-06-19 18:10:02 -05:00
Stephen Niedzielski fe2c3b23ee Hygiene: replace call to rm with clean-webpack-plugin
The invocation of `rm -rf resources/dist` in package.json
(`check-built-assets`) is replaced with clean-webpack-plugin.
The benefit of this change is that calling `npm run build` now works the
same as the `check-built-assets` script.

Bug: T193522
Change-Id: I64f048855ddceb7159279671b2174a7937e169ff
2018-06-18 09:09:28 -05:00
James D. Forrester a678df93a0 build: Bump lint devDependencies to lastest
grunt                          1.0.1  →    1.0.2
 grunt-contrib-watch            1.0.0  →    1.0.1
 grunt-stylelint                0.9.0  →   0.10.0
 nodemon                       1.11.0  →   1.17.3
 stylelint                      8.2.0  →    9.2.0
 stylelint-config-wikimedia     0.4.2  →    0.4.3

Avoid old (very up) upstream's security issue from nodemon.

Change-Id: I3dcf94746b4383baeae4fe6e2bf95c5da5b87db1
2018-05-01 10:35:23 -05:00
joakin 3c63686da7 Chore: Upgrade mw-node-qunit to 4.0.0
* https://github.com/joakin/mw-node-qunit/blob/master/CHANGELOG.md#400
  * Rely on the CLI runner from qunit
  * Fix testing require and global mediaWiki not asserting anything

The test numbers is not reported by test, instead of by assertion like
it was before because the official qunit tap reporter does that. But the
numbers are correct.

Change-Id: I38d4b5007902ecbef2e2007966fafc4bb88703f6
2018-04-17 09:21:47 -05:00
joakin 4e639b09d4 Update mw-node-qunit to 3.1.0
* 3.1.0
  * Added CONTRIBUTING.md
  * Update jsdom from 11.3.0 to 11.7.0
  * Upgrade jQuery from 3.2.1 to 3.3.1
  * Update QUnit from 2.4.1 to 2.6.0
  * Update prettier, fix formatting glob

* Commits https://github.com/joakin/mw-node-qunit/compare/v3.0.0...v3.1.0
* Changelog https://github.com/joakin/mw-node-qunit/blob/master/CHANGELOG.md#310

Change-Id: I16d4e4f86f59f9a2f441c915a31d1f0617b40c82
2018-04-09 11:58:04 +02:00
Stephen Niedzielski 5872c8376d Fix: JSDoc Node.js file copy bug
Upgrade JSDoc from v3.4.3 to 3.5.5:
- v3.5.0 JSDoc can parse any JavaScript that is supported by Babel
  compiler.
- v3.5.1 fixes an incompatibility bug in Node.js < v5.10.0
- v3.5.5 fixes an incompatibility bug in Node.js v8.5.0

Prior to this change, object shorthand caused the following errors:

  jsdoc -c jsdoc.json
  fs.js:1979
    binding.copyFile(src, dest, flags);
            ^

  Error: EISDIR: illegal operation on a directory, copyfile '/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/static/fonts/OpenSans-Bold-webfont.eot' -> 'doc/autogenerated/fonts'
      at Object.fs.copyFileSync (fs.js:1979:11)
      at /home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/publish.js:471:12
      at Array.forEach (<anonymous>)
      at Object.exports.publish (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/templates/default/publish.js:468:17)
      at Object.module.exports.cli.generateDocs (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:430:39)
      at Object.module.exports.cli.processParseResults (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:383:20)
      at module.exports.cli.main (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:227:14)
      at Object.module.exports.cli.runCommand (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/cli.js:180:5)
      at /home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/jsdoc.js:103:9
      at Object.<anonymous> (/home/stephen/dev/wmf/vagrant2/mediawiki/extensions/Popups/node_modules/jsdoc/jsdoc.js:104:3)
      at Module._compile (module.js:662:30)
      at Object.Module._extensions..js (module.js:673:10)
      at Module.load (module.js:575:32)
      at tryModuleLoad (module.js:515:12)
      at Function.Module._load (module.js:507:3)
      at Function.Module.runMain (module.js:703:10)

https://github.com/jsdoc3/jsdoc/releases/tag/3.5.0
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.1
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.2
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.3
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.4
https://github.com/jsdoc3/jsdoc/releases/tag/3.5.5

Bug: T165036
Change-Id: Ic7a22b6992d45fa0ea3d011a9ad5200d7cc73b80
2018-03-20 09:24:06 -05:00
Stephen Niedzielski 3c3f162226 Fix: pin package versions to patch revision
CI doesn't use a version of NPM that reads package-lock files which
seems to break some build product diff checks.

Bug: T165036
Change-Id: I29383c1a5c1f7f102fe458ac778adc3bf264c9fd
2018-03-20 09:22:43 -05:00
Stephen Niedzielski e5df865d51 Hygiene: enable Babel transpilation
Enable the Babel transpiler so that ES6 template literals,
destructuring, and arrow functions can be used in production.
"last n versions" syntax was not used so that builds are more
reproducible.

Bug: T165036
Change-Id: I553b6d14cc368c7b4366f68d13038c3d505f5429
2018-03-20 07:59:14 -05:00
Stephen Niedzielski d35286a064 Update: upgrade to Webpack 4 & improve output size
Upgrade from Webpack v2.0.12 to v4.1.1. There have been many changes to
Webpack... Noticeable in the bundle size is that a number of files are
now inlined and generally minification is improved.

Changes related to the upgrade include:

- Remove unsupported UglifyJS options which link back to T188081. These
  appear to have been anticipatory but never acted on and it isn't clear
  whether they even worked or not.
- Pass the -p plag for production optimizations; pass the -d flag since
  production doesn't support watching.
- NamedModulesPlugin is now on by default but only in development mode
  so no change was made.
- Webpack command line client now must be installed separated and
  appears in package.json as webpack-cli.

https://github.com/webpack/webpack/releases/tag/v2.2.0
https://github.com/webpack/webpack/releases/tag/v2.2.1
https://github.com/webpack/webpack/releases/tag/v2.3.0
https://github.com/webpack/webpack/releases/tag/v2.3.1
https://github.com/webpack/webpack/releases/tag/v2.3.2
https://github.com/webpack/webpack/releases/tag/v2.3.3
https://github.com/webpack/webpack/releases/tag/v2.4.0
https://github.com/webpack/webpack/releases/tag/v2.4.1
https://github.com/webpack/webpack/releases/tag/v2.5.0
https://github.com/webpack/webpack/releases/tag/v2.5.1
https://github.com/webpack/webpack/releases/tag/v2.6.0
https://github.com/webpack/webpack/releases/tag/v2.6.1
https://github.com/webpack/webpack/releases/tag/v3.0.0
https://github.com/webpack/webpack/releases/tag/v3.1.0
https://github.com/webpack/webpack/releases/tag/v3.2.0
https://github.com/webpack/webpack/releases/tag/v3.3.0
https://github.com/webpack/webpack/releases/tag/v3.4.0
https://github.com/webpack/webpack/releases/tag/v3.4.1
https://github.com/webpack/webpack/releases/tag/v3.5.0
https://github.com/webpack/webpack/releases/tag/v3.5.1
https://github.com/webpack/webpack/releases/tag/v3.5.2
https://github.com/webpack/webpack/releases/tag/v3.5.3
https://github.com/webpack/webpack/releases/tag/v3.5.4
https://github.com/webpack/webpack/releases/tag/v3.5.5
https://github.com/webpack/webpack/releases/tag/v3.5.6
https://github.com/webpack/webpack/releases/tag/v3.6.0
https://github.com/webpack/webpack/releases/tag/v3.7.0
https://github.com/webpack/webpack/releases/tag/v3.7.1
https://github.com/webpack/webpack/releases/tag/v3.8.0
https://github.com/webpack/webpack/releases/tag/v3.8.1
https://github.com/webpack/webpack/releases/tag/v3.9.0
https://github.com/webpack/webpack/releases/tag/v3.9.1
https://github.com/webpack/webpack/releases/tag/v3.10.0
https://github.com/webpack/webpack/releases/tag/v3.11.0
https://github.com/webpack/webpack/releases/tag/v4.0.0
https://medium.com/webpack/webpack-4-released-today-6cdb994702d4
https://github.com/webpack/webpack/releases/tag/v4.0.1
https://github.com/webpack/webpack/releases/tag/v4.1.0
https://github.com/webpack/webpack/releases/tag/v4.1.1

Bug: T165036
Change-Id: Ic146e680d368fee7ee207b484460ce94f8bd7283
2018-03-20 07:55:37 -05:00
Stephen Niedzielski 4eb9c0efa8 Hygiene: move SVG string to file
- Add SVG Inline Loader for Webpack. This allows SVG files to be
  imported.

- Update the Webpack and test configurations to use the new loader.

- Scope the ESLint rules down to just JavaScript files so that linting
  isn't attempted on the SVG.

Bug: T165036
Change-Id: I00bccff4c3167975c19d577be6343dcaca7ddb2d
2018-03-14 12:04:28 -07:00
Jan Drewniak 1e946a379d Custom page preview for disambiguation pages
Creating a different page preview for disambiguation pages.

This patch:
- modifies the Preview model to accept a new 'type' property
- modifies the Restbase Gateway to pass the 'type' prop to the Preview model
- creates a new template to accept both generic/disambig previews
- modifies the renderer to render the new template
- generates icons for new template through resource loader
- adds new i18n strings
- modifies event-logging "preview seen" event to send new "disambiguation" previewType
- updates event logging schema version
- adds tests for Preview model and renderer for new preview type
- does way too much? yes, yes it does.

Bug: T168392
Change-Id: Idc936cc3eabbdd99a3d98f43c66b4cdbb7d24917
2018-03-14 11:24:26 -07:00
Jan Drewniak f4d04b95b6 Updating mw-node-qunit to v3
Fixes tests for sinon v4, which is a dependency of mw-node-qunit v3.

Bug: T180255
Change-Id: I8c7b703f81140e06546aa954f98b8766f5225ff5
2018-02-08 12:20:52 +01:00
Stephen Niedzielski 7da20008c0 Hygiene: add bundlesize test
This patch adds a production build output gzipped file size check to the
test script so that any future changes may only introduce known size
differences. Note:

• The initial limit was taken from the present gzipped file size rounded
  up to the 10th of a kibibyte.

• JEDEC notation is used. bundlesize internally uses Bytes utility which
  only supports base 2 units.

  https://github.com/visionmedia/bytes.js

Bug: T176211
Change-Id: Ie95f388673b0b982b105fef9a2917513a3307060
2018-01-30 20:04:06 +00:00
Stephen Niedzielski af942bd1dc Hygiene: add package-lock file
Add NPM package-lock file, a new feature of NPMv5.

http://blog.npmjs.org/post/161081169345/v500

Change-Id: I10507ff4e1f09b224b0b52909392bfb9f5005cde
2018-01-19 19:05:24 +00:00