From f072389751673263e0ed6bff704bb3e7bdff49ae Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Mon, 9 Dec 2024 08:22:01 -0800 Subject: [PATCH 1/2] move .js and .css files out of the root Move twinkle.js, morebits.js, CSS files, etc. out of the root. The root directory should be config files and readmes only. Wikimedia also does this. JS files are always all placed in a directory called /modules/ (or sometimes a subdirectory with a different name, the other name escpaes me at the moment). But never in the root. Fixes #2078 To test: - npm start - perl deploy.pl Maybe: - put the old modules in a subdirectory? modules/menuItems/*.js or something? --- .github/labels.yml | 10 +++++----- DEVELOPER.md | 14 +++++++------- README.md | 6 +++--- jest.config.js | 2 -- morebits.css => modules/morebits.css | 0 morebits.js => modules/morebits.js | 0 .../twinkle-pagestyles.css | 0 twinkle.css => modules/twinkle.css | 0 twinkle.js => modules/twinkle.js | 0 scripts/deploy.pl | 10 +++++----- scripts/dev-server.js | 4 ++-- tests/jest.setup.js | 4 ++-- 12 files changed, 24 insertions(+), 26 deletions(-) rename morebits.css => modules/morebits.css (100%) rename morebits.js => modules/morebits.js (100%) rename twinkle-pagestyles.css => modules/twinkle-pagestyles.css (100%) rename twinkle.css => modules/twinkle.css (100%) rename twinkle.js => modules/twinkle.js (100%) diff --git a/.github/labels.yml b/.github/labels.yml index 467336f60..a202f7df1 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -1,10 +1,10 @@ "Module: twinkle": - - twinkle.js - - twinkle.css - - twinkle-pagestyles.css + - modules/twinkle.js + - modules/twinkle.css + - modules/twinkle-pagestyles.css "Module: morebits": - - morebits.js - - morebits.css + - modules/morebits.js + - modules/morebits.css "Module: arv": - modules/twinklearv.js "Module: batch": diff --git a/DEVELOPER.md b/DEVELOPER.md index cfc3334ab..a8e528b15 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -23,13 +23,13 @@ After the files are synced, ensure that [MediaWiki:Gadgets-definition][] contain Each Twinkle module and dependency lives on the wiki as a separate file. The list of modules and what pages they should be on are as follows: -- `twinkle.js` → [MediaWiki:Gadget-Twinkle.js][] -- `twinkle.css` → [MediaWiki:Gadget-Twinkle.css][] -- `twinkle-pagestyles.css` → [MediaWiki:Gadget-Twinkle-pagestyles.css][] -- `morebits.js` → [MediaWiki:Gadget-morebits.js][] -- `morebits.css` → [MediaWiki:Gadget-morebits.css][] -- `select2.min.js` → [MediaWiki:Gadget-select2.min.js][] -- `select2.min.css` → [MediaWiki:Gadget-select2.min.css][] +- `modules/twinkle.js` → [MediaWiki:Gadget-Twinkle.js][] +- `modules/twinkle.css` → [MediaWiki:Gadget-Twinkle.css][] +- `modules/twinkle-pagestyles.css` → [MediaWiki:Gadget-Twinkle-pagestyles.css][] +- `modules/morebits.js` → [MediaWiki:Gadget-morebits.js][] +- `modules/morebits.css` → [MediaWiki:Gadget-morebits.css][] +- `lib/select2.min.js` → [MediaWiki:Gadget-select2.min.js][] +- `lib/select2.min.css` → [MediaWiki:Gadget-select2.min.css][] - `modules/twinklearv.js` → [MediaWiki:Gadget-twinklearv.js][] - `modules/twinklebatchdelete.js` → [MediaWiki:Gadget-twinklebatchdelete.js][] - `modules/twinklebatchprotect.js` → [MediaWiki:Gadget-twinklebatchprotect.js][] diff --git a/README.md b/README.md index ac4bee33b..ae0f2b8e8 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ If you'd like to start contributing, awesome! Check out [CONTRIBUTING.md](CONTR ## Layout of this repository -* `morebits.js`: The central library used by Twinkle and many other scripts. Contains code to interact with the MediaWiki API, display forms and dialogs, generate status logs, and do various other useful things. The vast majority of code in here is not Twinkle-specific; see docs ([1](https://wikimedia-gadgets.github.io/twinkle/Morebits.html) and [2](https://github.com/wikimedia-gadgets/twinkle/wiki/morebits)) -* `twinkle.js`: General Twinkle-specific code, mostly related to preferences and exposing Twinkle in the UI. Significantly, it contains the default set of preferences of Twinkle. -* `modules`: Contains the individual Twinkle modules. Descriptions for these can be found in header comments or in the [Twinkle documentation][]. The module `twinkleconfig.js` powers the [Twinkle preferences panel][WP:TWPREFS]. +* `modules/morebits.js`: The central library used by Twinkle and many other scripts. Contains code to interact with the MediaWiki API, display forms and dialogs, generate status logs, and do various other useful things. The vast majority of code in here is not Twinkle-specific; see docs ([1](https://wikimedia-gadgets.github.io/twinkle/Morebits.html) and [2](https://github.com/wikimedia-gadgets/twinkle/wiki/morebits)) +* `modules/twinkle.js`: General Twinkle-specific code, mostly related to preferences and exposing Twinkle in the UI. Significantly, it contains the default set of preferences of Twinkle. +* `modules/*.js`: Contains the individual Twinkle modules. Descriptions for these can be found in header comments or in the [Twinkle documentation][]. The module `twinkleconfig.js` powers the [Twinkle preferences panel][WP:TWPREFS]. [select2][] is added under the [MIT license][select2license]. diff --git a/jest.config.js b/jest.config.js index 0e87029f2..6e0b48380 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,8 +5,6 @@ module.exports = { testEnvironment: 'jsdom', setupFilesAfterEnv: ['mock-mediawiki', '/tests/jest.setup.js'], collectCoverageFrom: [ - 'morebits.js', - 'twinkle.js', 'modules/**/*.{js,jsx,ts,tsx}' ] }; diff --git a/morebits.css b/modules/morebits.css similarity index 100% rename from morebits.css rename to modules/morebits.css diff --git a/morebits.js b/modules/morebits.js similarity index 100% rename from morebits.js rename to modules/morebits.js diff --git a/twinkle-pagestyles.css b/modules/twinkle-pagestyles.css similarity index 100% rename from twinkle-pagestyles.css rename to modules/twinkle-pagestyles.css diff --git a/twinkle.css b/modules/twinkle.css similarity index 100% rename from twinkle.css rename to modules/twinkle.css diff --git a/twinkle.js b/modules/twinkle.js similarity index 100% rename from twinkle.js rename to modules/twinkle.js diff --git a/scripts/deploy.pl b/scripts/deploy.pl index 81f64c134..97539debb 100644 --- a/scripts/deploy.pl +++ b/scripts/deploy.pl @@ -452,11 +452,11 @@ sub usage { ## compiler. Rather, they are used by the --all option to simplify bulk ## updating all files. __DATA__ -twinkle.js - twinkle.css - twinkle-pagestyles.css - morebits.js - morebits.css +modules/twinkle.js + modules/twinkle.css + modules/twinkle-pagestyles.css + modules/morebits.js + modules/morebits.css lib/select2.min.js lib/select2.min.css modules/twinklearv.js diff --git a/scripts/dev-server.js b/scripts/dev-server.js index 71489954a..9b2aea5b0 100644 --- a/scripts/dev-server.js +++ b/scripts/dev-server.js @@ -14,8 +14,8 @@ async function readFiles(filePaths) { } const server = http.createServer(async (request, response) => { const moduleFiles = (await fs.readdir('./modules')).filter(f => f.endsWith('.js')); - const jsFiles = ['morebits.js', 'twinkle.js'].concat(moduleFiles.map(f => 'modules/' + f)); - const cssFiles = ['morebits.css', 'twinkle.css']; + const jsFiles = moduleFiles.map(f => 'modules/' + f); + const cssFiles = ['modules/morebits.css', 'modules/twinkle.css']; let jsCode = `mw.loader.using(['jquery.ui', 'ext.gadget.select2']).then(function () {\n`; diff --git a/tests/jest.setup.js b/tests/jest.setup.js index b3d3c7790..94a3023a1 100644 --- a/tests/jest.setup.js +++ b/tests/jest.setup.js @@ -4,8 +4,8 @@ mw.config.set({ wgUserGroups: ['interface-admin', 'sysop', '*', 'user', 'autoconfirmed'], }); -require('../morebits.js'); -require('../twinkle.js'); +require('../modules/morebits.js'); +require('../modules/twinkle.js'); require('../modules/twinklewarn.js'); require('../modules/twinklexfd.js'); global.Morebits = window.Morebits; From 74a00031a1f1120879b689bbd8584c989923db3a Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Mon, 9 Dec 2024 08:26:43 -0800 Subject: [PATCH 2/2] remove /* global morebits.js */ --- modules/morebits.js | 1 - modules/twinkle.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/modules/morebits.js b/modules/morebits.js index 206cfec32..a4a59804b 100644 --- a/modules/morebits.js +++ b/modules/morebits.js @@ -6106,7 +6106,6 @@ Morebits.wikitext.Page = Morebits.wikitext.page; */ if (typeof arguments === 'undefined') { // typeof is here for a reason... - /* global Morebits */ window.SimpleWindow = Morebits.simpleWindow; window.QuickForm = Morebits.quickForm; window.Wikipedia = Morebits.wiki; diff --git a/modules/twinkle.js b/modules/twinkle.js index 4e5a4e48b..73446f002 100644 --- a/modules/twinkle.js +++ b/modules/twinkle.js @@ -15,8 +15,6 @@ */ // -/* global Morebits */ - (function() { // Check if account is experienced enough to use Twinkle