Skip to content

Commit

Permalink
Merge pull request #722 from wikimedia/nvm-ci
Browse files Browse the repository at this point in the history
Use correct npm version in CI
  • Loading branch information
tstarling authored May 24, 2023
2 parents 3987b63 + c9ae40a commit 6059f35
Show file tree
Hide file tree
Showing 63 changed files with 12,354 additions and 23,532 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor/
/node_modules/
/public/assets/

/i18n/
/public/i18n/
25 changes: 13 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* eslint-disable no-undef */
module.exports = {
"extends": "wikimedia",
"globals": {
"App": false,
"appConfig": false,
"OO": false,
"L": false,
"$": false,
"QUnit": false,
"window": false,
"global": false,
"require": false
},
extends: 'wikimedia',
globals: {
App: false,
appConfig: false,
OO: false,
L: false,
$: false,
QUnit: false,
window: false,
global: false,
require: false
}
};
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
with:
php-version: ${{matrix.php}}

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install
run: |
sudo apt-get update -q
Expand Down
6 changes: 3 additions & 3 deletions .minus-x.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ignore": [
"./bin/.phpunit/phpunit-8.5-0/phpunit"
]
"ignore": [
"./bin/.phpunit/phpunit-8.5-0/phpunit"
]
}
3 changes: 3 additions & 0 deletions assets/InterfaceLangButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* The language settings dialog window.
*
* @param {Object} [config] Configuration options
* @constructor
*/
Expand All @@ -17,6 +18,7 @@ OO.inheritClass( App.InterfaceLangButton, OO.ui.ButtonWidget );

/**
* Handles mouse click events.
*
* @protected
* @param {jQuery.Event} e Mouse click event
* @fires click
Expand All @@ -33,6 +35,7 @@ App.InterfaceLangButton.prototype.onClick = function ( e ) {

/**
* Called when the user selects a language in the ULS.
*
* @param {string} language The code of the selected language.
*/
App.InterfaceLangButton.prototype.onUlsSelect = function ( language ) {
Expand Down
9 changes: 7 additions & 2 deletions assets/LanguageDialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* The language settings dialog window.
*
* @param {Object} [config] Configuration options
* @constructor
*/
Expand All @@ -17,6 +18,7 @@ App.LanguageDialog.static.size = 'medium';

/**
* Set the height to a reasonable maximum.
*
* @return {number} Body height.
*/
App.LanguageDialog.prototype.getBodyHeight = function () {
Expand All @@ -26,6 +28,7 @@ App.LanguageDialog.prototype.getBodyHeight = function () {

/**
* Called each time the window is opened.
*
* @param {Object} [data] Dialog opening data
* @param {jQuery|string|Function|null} [data.title] Dialog title.
* @param {Object[]} [data.actions] List of configuration options for each action.
Expand Down Expand Up @@ -98,15 +101,17 @@ App.LanguageDialog.prototype.initialize = function () {
/**
* Get the required top offset (in pixels) for a ULS menu.
* Should be bound to the button element in question.
* @HACK: ULS doesn't know its position relative to the button because of OOUI.
* @return {int}
* HACK: ULS doesn't know its position relative to the button because of OOUI.
*
* @return {number}
*/
App.LanguageDialog.prototype.calculateUlsTop = function () {
return $( this ).offset().top - ( $( this ).outerHeight() / 2 );
};

/**
* Handle actions.
*
* @param {string} [action] Symbolic name of action
* @return {OO.ui.Process} Action process
*/
Expand Down
6 changes: 4 additions & 2 deletions assets/SearchWidget.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jsdoc/check-tag-names */
/**
* SVG file search widget.
*
Expand All @@ -17,6 +18,7 @@ OO.mixinClass( App.SearchWidget, OO.ui.mixin.LookupElement );
/**
* Get a new request object of the current lookup query value.
* Note that the default result count limit of the API is 10.
*
* @link https://www.mediawiki.org/wiki/API:Search
*
* @protected
Expand All @@ -27,7 +29,7 @@ App.SearchWidget.prototype.getLookupRequest = function () {
var val = this.getValue();
if ( val.indexOf( 'File:' ) !== -1 ) {
// Strip any 'File:' prefix, including if a URL has been supplied.
val = val.substring( val.indexOf( 'File:' ) + 'File:'.length );
val = val.slice( Math.max( 0, val.indexOf( 'File:' ) + 'File:'.length ) );
}
return $.ajax( {
url: appConfig.wikiUrl,
Expand Down Expand Up @@ -74,7 +76,7 @@ App.SearchWidget.prototype.getLookupMenuOptionsFromData = function ( data ) {
i, svgFilename;
for ( i = 0; i < data.length; i++ ) {
// Strip 'File:' prefix.
svgFilename = String( data[ i ].title ).substring( 'File:'.length );
svgFilename = String( data[ i ].title ).slice( 'File:'.length );
items.push( new OO.ui.MenuOptionWidget( {
data: svgFilename,
label: svgFilename
Expand Down
2 changes: 2 additions & 0 deletions assets/UlsTagMultiselectWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* The preferred languages input widget.
*
* @param {Object} [config] Configuration options
* @constructor
*/
Expand Down Expand Up @@ -33,6 +34,7 @@ OO.inheritClass( App.UlsTagMultiselectWidget, OO.ui.TagMultiselectWidget );

/**
* Select handler for the ULS popup.
*
* @param {string} language The code of the selected language.
*/
App.UlsTagMultiselectWidget.prototype.onUlsSelect = function ( language ) {
Expand Down
1 change: 1 addition & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $( function () {

/**
* Helper function for getting values out of the 'svgtranslate' cookie.
*
* @param {string} key The key to get, either 'interfaceLang' or 'preferredLangs'.
* @param {*} defaultVal The default value to use if none is set in the cookie.
* @return {*}
Expand Down
18 changes: 11 additions & 7 deletions assets/js/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ App.Model.prototype.getSourceTranslation = function ( nodeId ) {

/**
* Set a single target translation string for the current target language.
*
* @param {string} filename
* @param {string} nodeId
* @param {string} translation
Expand Down Expand Up @@ -137,18 +138,18 @@ App.Model.prototype.setTargetTranslation = function ( filename, nodeId, translat
// Save the new translation.
this.translations[ nodeId ][ this.targetLang ].text = translation;
// Also save to local storage if it differs from the original translation.
Object.keys( this.translations ).forEach( function ( nodeId ) {
Object.keys( this.translations ).forEach( function ( nId ) {
var origTrans, currentTrans;
currentTrans = model.translations[ nodeId ][ model.targetLang ] !== undefined ?
model.translations[ nodeId ][ model.targetLang ].text :
currentTrans = model.translations[ nId ][ model.targetLang ] !== undefined ?
model.translations[ nId ][ model.targetLang ].text :
'';
origTrans = model.originalTranslations[ nodeId ][ model.targetLang ] !== undefined ?
model.originalTranslations[ nodeId ][ model.targetLang ].text :
origTrans = model.originalTranslations[ nId ][ model.targetLang ] !== undefined ?
model.originalTranslations[ nId ][ model.targetLang ].text :
'';
if ( currentTrans !== origTrans ) {
changedTranslations[ nodeId ] = model.translations[ nodeId ][ model.targetLang ].text;
changedTranslations[ nId ] = model.translations[ nId ][ model.targetLang ].text;
} else {
delete changedTranslations[ nodeId ];
delete changedTranslations[ nId ];
}
} );
if ( changedTranslations ) {
Expand All @@ -166,6 +167,7 @@ App.Model.prototype.getTargetTranslation = function ( nodeId ) {

/**
* Load model values from LocalStorage.
*
* @param {string} filename
* @return {boolean} Whether translation changes were loaded.
*/
Expand Down Expand Up @@ -196,6 +198,7 @@ App.Model.prototype.loadFromLocalStorage = function ( filename ) {

/**
* Get a value from our LocalStorage item.
*
* @protected
* @param {string} key
* @return {*}
Expand All @@ -214,6 +217,7 @@ App.Model.prototype.getLocalStorageValue = function ( key ) {

/**
* Set a value in our LocalStorage item.
*
* @protected
* @param {string} key
* @param {*} val
Expand Down
Loading

0 comments on commit 6059f35

Please sign in to comment.