From 4a1fbb03684666a671b71fbb9a4b9a9b3289278e Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Sat, 10 Apr 2021 19:46:17 +0530 Subject: [PATCH 1/9] integrate web-ext --- .gitignore | 1 + package.json | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c40289d..22d830e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ jspm_packages .DS_Store dist package +web-ext-profile diff --git a/package.json b/package.json index 32517a0..2b6890e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "build": "grunt build", "package": "grunt package", "serve": "grunt serve", - "test": "grunt test" + "test": "grunt test", + "web-ext:firefox": "web-ext run --target firefox-desktop" }, "devDependencies": { "eslint-config-standard": "^14.1.1", @@ -26,7 +27,19 @@ "grunt-contrib-compress": "^1.6.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-watch": "^1.1.0", + "grunt-eslint": "^23.0.0", "load-grunt-config": "^3.0.1", - "grunt-eslint": "^23.0.0" + "web-ext": "^6.0.0" + }, + "webExt": { + "sourceDir": "dist/firefox", + "run": { + "profileCreateIfMissing": true, + "keepProfileChanges": true, + "firefoxProfile": "./web-ext-profile/firefox", + "startUrl": [ + "github.com/williambelle" + ] + } } } From 27ab81f7800e4ab8a6dd5510f6c8e78938a3e42d Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Wed, 14 Apr 2021 22:34:41 +0530 Subject: [PATCH 2/9] eliminate grunt-eslint ( alias : grunt test ) migrate the `grunt test` task to package.json. `npm test` is the new alternative command. this is the first ( and easiest ) step to eliminating `grunt` as a dependency for the project. --- grunt/aliases.yml | 4 ---- grunt/eslint.js | 8 -------- package.json | 3 +-- 3 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 grunt/eslint.js diff --git a/grunt/aliases.yml b/grunt/aliases.yml index 54b9991..5beb4b5 100644 --- a/grunt/aliases.yml +++ b/grunt/aliases.yml @@ -1,8 +1,4 @@ -test: - - 'eslint' - build: - - 'test' - 'copy:buildChrome' - 'copy:buildFirefox' diff --git a/grunt/eslint.js b/grunt/eslint.js deleted file mode 100644 index 3d9be92..0000000 --- a/grunt/eslint.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - options: { - configFile: '.eslintrc.json' - }, - target: ['**/*.js', '!node_modules/**/*.js', '!dist/**/*.js'] -}; diff --git a/package.json b/package.json index 2b6890e..bbf77d9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build": "grunt build", "package": "grunt package", "serve": "grunt serve", - "test": "grunt test", + "test": "eslint src", "web-ext:firefox": "web-ext run --target firefox-desktop" }, "devDependencies": { @@ -27,7 +27,6 @@ "grunt-contrib-compress": "^1.6.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-watch": "^1.1.0", - "grunt-eslint": "^23.0.0", "load-grunt-config": "^3.0.1", "web-ext": "^6.0.0" }, From 642391a64a7ca0e9eb1fa7a25e13498aeb88fc2c Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Wed, 14 Apr 2021 22:50:36 +0530 Subject: [PATCH 3/9] merge separate manifest.json files There were 2 divergences in the `manifest.json` files : - `"applications"` block in the firefox manifest which specified the minimum supported version of the extension in the browser - different icon sizes in the default `manifest.json` This divergence seemed trivial to be maintained separately. Merging and running the extension from the merged `manifest.json` file did not throw any major errors in the running of the extension on Firefox as well as Chromium. It does not seem sensible to maintain 2 separate `manifest.json` files for the extension unless there are other chromium-based browsers who use the `"applications"` block specifically for something else or some other browser that accepts only one icon in the manifest. --- src/manifest.firefox.json | 32 -------------------------------- src/manifest.json | 7 +++++++ 2 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 src/manifest.firefox.json diff --git a/src/manifest.firefox.json b/src/manifest.firefox.json deleted file mode 100644 index 70ea8c8..0000000 --- a/src/manifest.firefox.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "GitHub Contribution Color Graph", - "description": "Change colors of contribution graph in GitHub", - "manifest_version": 2, - "version": "1.7.2", - - "applications": { - "gecko": { - "strict_min_version": "57.0", - "id": "github-contribution-color-graph@example.com" - } - }, - - "content_scripts": [{ - "js": [ "js/contentscript.js" ], - "matches": [ "https://github.com/*" ], - "run_at": "document_end" - }], - - "options_ui": { - "page": "options.html", - "open_in_tab": true - }, - - "permissions": [ - "storage" - ], - - "icons": { - "48": "images/icon-48.png" - } -} diff --git a/src/manifest.json b/src/manifest.json index a4e7d28..53d8e82 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -4,6 +4,13 @@ "manifest_version": 2, "version": "1.7.2", + "applications": { + "gecko": { + "strict_min_version": "57.0", + "id": "github-contribution-color-graph@example.com" + } + }, + "content_scripts": [{ "js": [ "js/contentscript.js" ], "matches": [ "https://github.com/*" ], From 406b9cc7f2afac9f9fb7a154b4a77ff827caf00c Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:06:30 +0530 Subject: [PATCH 4/9] eliminate grunt-copy ( alias : grunt build ) Now that the only minor divergence in the source code have been merged, the `src` directory can be used as the single source of truth for both source code as well as distribution code. There is nothing that needs to be compiled or transpiled that would require a separate dedicated distribution directory. --- .gitignore | 1 - CONTRIBUTING.md | 18 ++++++------------ grunt/aliases.yml | 6 ------ grunt/copy.js | 35 ----------------------------------- package.json | 4 +--- 5 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 grunt/copy.js diff --git a/.gitignore b/.gitignore index 22d830e..373f491 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,5 @@ jspm_packages .node_repl_history .DS_Store -dist package web-ext-profile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a976ec0..bc3cc1e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,15 +20,9 @@ Test npm t ``` -Build +Serve ----- -```bash -npm run build -``` - -or - ```bash npm run serve ``` @@ -43,7 +37,7 @@ Chrome: 1. Open Tools -> Extensions 2. Check the "Developer Mode" option (if not already) 3. Select "Load unpacked extension" -4. Navigate to the project `github-contribution-color-graph/dist/chrome` and click select +4. Navigate to the project `github-contribution-color-graph/src` and click select Firefox: @@ -51,21 +45,21 @@ Firefox: 2. Click "Debug Add-ons" 3. Check the "Enable add-on debugging" option (if not already) 4. Select "Load Temporary Add-on" -5. Navigate to the project `github-contribution-color-graph/dist/firefox` and click open +5. Navigate to the project `github-contribution-color-graph/src` and click open Opera: 1. View -> Show Extensions 2. Click on "Developer Mode" button (if not already) 3. Click on "Load Unpacked Extension..." -4. Navigate to the project `github-contribution-color-graph/dist/chrome` and click select - +4. Navigate to the project `github-contribution-color-graph/src` and click select + Edge Chromium: 1. `...` -> Extensions 2. Click on "Developer Mode" button (if not already) 3. Click on "Load Unpacked" -4. Navigate to the project `github-contribution-color-graph/dist/chrome` and click select +4. Navigate to the project `github-contribution-color-graph/src` and click select Package ------- diff --git a/grunt/aliases.yml b/grunt/aliases.yml index 5beb4b5..ac48486 100644 --- a/grunt/aliases.yml +++ b/grunt/aliases.yml @@ -1,13 +1,7 @@ -build: - - 'copy:buildChrome' - - 'copy:buildFirefox' - package: - - 'build' - 'compress' serve: - - 'build' - 'watch' default: diff --git a/grunt/copy.js b/grunt/copy.js deleted file mode 100644 index 9e268e9..0000000 --- a/grunt/copy.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -module.exports = function (grunt, options) { - return { - buildChrome: { - files: [{ - expand: true, - cwd: 'src/', - src: ['js/**', 'css/**', 'images/**', '*.html', 'manifest.json'], - dest: 'dist/chrome/', - nonull: true - }] - }, - buildFirefox: { - files: [{ - expand: true, - cwd: 'src/', - src: ['js/**', 'css/**', 'images/**', '*.html'], - dest: 'dist/firefox/', - nonull: true - }, { - expand: true, - cwd: 'src/', - src: ['manifest.firefox.json'], - dest: 'dist/firefox/', - nonull: true, - rename: function (destBase, destPath) { - return destBase + destPath.replace( - 'manifest.firefox.json', 'manifest.json' - ); - } - }] - } - }; -}; diff --git a/package.json b/package.json index bbf77d9..af8e409 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "node": ">=10" }, "scripts": { - "build": "grunt build", "package": "grunt package", "serve": "grunt serve", "test": "eslint src", @@ -25,13 +24,12 @@ "eslint-plugin-standard": "^4.0.1", "grunt": "^1.1.0", "grunt-contrib-compress": "^1.6.0", - "grunt-contrib-copy": "^1.0.0", "grunt-contrib-watch": "^1.1.0", "load-grunt-config": "^3.0.1", "web-ext": "^6.0.0" }, "webExt": { - "sourceDir": "dist/firefox", + "sourceDir": "src", "run": { "profileCreateIfMissing": true, "keepProfileChanges": true, From 610139b25299a4fc91f90fdcdd62ecf7bf46034f Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:18:50 +0530 Subject: [PATCH 5/9] eliminate grunt-watch ( alias : grunt serve ) because web-ext run already watches, live reloads and also serves the web extension to the desired browser described by `npm run -- serve:firefox` or `npm run -- serve:chromium` --- CONTRIBUTING.md | 32 +++++++++++++------------------- grunt/aliases.yml | 6 ------ grunt/watch.js | 14 -------------- package.json | 8 ++++---- 4 files changed, 17 insertions(+), 43 deletions(-) delete mode 100644 grunt/watch.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc3cc1e..5a50bf0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,33 +20,27 @@ Test npm t ``` -Serve ------ - -```bash -npm run serve -``` - -to update source continuously. - Run --- Chrome: -1. Open Tools -> Extensions -2. Check the "Developer Mode" option (if not already) -3. Select "Load unpacked extension" -4. Navigate to the project `github-contribution-color-graph/src` and click select +```bash +npm run -- serve:chromium +``` + +This will open a new chromium browser window with a temporary profile +and the web extension already loaded. Firefox: -1. Open Tools -> Add-ons -2. Click "Debug Add-ons" -3. Check the "Enable add-on debugging" option (if not already) -4. Select "Load Temporary Add-on" -5. Navigate to the project `github-contribution-color-graph/src` and click open - +```bash +npm run -- serve:firefox +``` + +This will open a new firefox browser window with a temporary profile +and the web extension already loaded. + Opera: 1. View -> Show Extensions diff --git a/grunt/aliases.yml b/grunt/aliases.yml index ac48486..64d4d70 100644 --- a/grunt/aliases.yml +++ b/grunt/aliases.yml @@ -1,8 +1,2 @@ package: - 'compress' - -serve: - - 'watch' - -default: - - 'serve' diff --git a/grunt/watch.js b/grunt/watch.js deleted file mode 100644 index deb3b86..0000000 --- a/grunt/watch.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - build: { - files: [ - 'src/**/*', - 'test/**/*' - ], - tasks: ['build'] - }, - options: { - livereload: true - } -}; diff --git a/package.json b/package.json index af8e409..adc0b90 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ }, "scripts": { "package": "grunt package", - "serve": "grunt serve", - "test": "eslint src", - "web-ext:firefox": "web-ext run --target firefox-desktop" + "serve:firefox": "web-ext run --target firefox-desktop", + "serve:chromium": "web-ext run --target chromium", + "test": "eslint src" }, "devDependencies": { "eslint-config-standard": "^14.1.1", @@ -24,7 +24,6 @@ "eslint-plugin-standard": "^4.0.1", "grunt": "^1.1.0", "grunt-contrib-compress": "^1.6.0", - "grunt-contrib-watch": "^1.1.0", "load-grunt-config": "^3.0.1", "web-ext": "^6.0.0" }, @@ -34,6 +33,7 @@ "profileCreateIfMissing": true, "keepProfileChanges": true, "firefoxProfile": "./web-ext-profile/firefox", + "chromiumProfile": "./web-ext-profile/chromium", "startUrl": [ "github.com/williambelle" ] From bdd38b7755261099aa0e173a6cfa5ac76c309559 Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:50:06 +0530 Subject: [PATCH 6/9] eliminate grunt-compress ( alias : grunt package ) `npm` has a built-in `pack` command that can compress the repository ( or specific `files` in the repository ) and generate a tarball. Additionally, it also adds some default files like the README, LICENSE and CHANGELOG for posterity. The output tarball is also aptly named in the format `-.tgz` reference : https://stackoverflow.com/a/55220535 While the tarball can be generated by running the `npm pack` command, for sake of backward-compatibility of existing `npm` scripts, it has been assigned to the `package` script replacing the `grunt package` alias. --- .gitignore | 1 - CONTRIBUTING.md | 5 +++++ grunt/aliases.yml | 2 -- grunt/compress.js | 28 ---------------------------- package.json | 4 ++-- 5 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 grunt/aliases.yml delete mode 100644 grunt/compress.js diff --git a/.gitignore b/.gitignore index 373f491..42cfbbb 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,4 @@ jspm_packages .node_repl_history .DS_Store -package web-ext-profile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a50bf0..9142971 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,6 +62,11 @@ Package npm run package ``` +Note : The `package` script is maintained for backward-compatibility. +The web extension can now be packaged with the built-in `npm pack` +command which generates a neat tarball with the required files. Usage +of the `npm pack` command is encouraged over `npm run -- package`. + License ------- diff --git a/grunt/aliases.yml b/grunt/aliases.yml deleted file mode 100644 index 64d4d70..0000000 --- a/grunt/aliases.yml +++ /dev/null @@ -1,2 +0,0 @@ -package: - - 'compress' diff --git a/grunt/compress.js b/grunt/compress.js deleted file mode 100644 index d02054e..0000000 --- a/grunt/compress.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -module.exports = function (grunt, options) { - return { - chrome: { - options: { - archive: 'package/chrome-v' + options.package.version + '.zip' - }, - files: [{ - src: '**/*', - cwd: 'dist/chrome/', - dest: '', - expand: true - }] - }, - firefox: { - options: { - archive: 'package/firefox-v' + options.package.version + '.zip' - }, - files: [{ - src: '**/*', - cwd: 'dist/firefox/', - dest: '', - expand: true - }] - } - }; -}; diff --git a/package.json b/package.json index adc0b90..72b712f 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,9 @@ "engines": { "node": ">=10" }, + "files": [ "src" ], "scripts": { - "package": "grunt package", + "package": "npm pack", "serve:firefox": "web-ext run --target firefox-desktop", "serve:chromium": "web-ext run --target chromium", "test": "eslint src" @@ -23,7 +24,6 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "grunt": "^1.1.0", - "grunt-contrib-compress": "^1.6.0", "load-grunt-config": "^3.0.1", "web-ext": "^6.0.0" }, From 6378be485f2f2a207ea430e7f7f0c776d643caaa Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Thu, 15 Apr 2021 00:02:22 +0530 Subject: [PATCH 7/9] eliminate grunt remove all remaining traces of grunt from the project --- gruntfile.js | 5 ----- package.json | 2 -- 2 files changed, 7 deletions(-) delete mode 100644 gruntfile.js diff --git a/gruntfile.js b/gruntfile.js deleted file mode 100644 index f6dface..0000000 --- a/gruntfile.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (grunt) { - require('load-grunt-config')(grunt); -}; diff --git a/package.json b/package.json index 72b712f..cf664a8 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,6 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", - "grunt": "^1.1.0", - "load-grunt-config": "^3.0.1", "web-ext": "^6.0.0" }, "webExt": { From f87a86b12931fd53cf6a429ee247fa374d247d83 Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Thu, 15 Apr 2021 00:06:23 +0530 Subject: [PATCH 8/9] lint != test `a0bc2c0` blindly migrated the `grunt` alias `test` without looking at the script's semantics. --- CONTRIBUTING.md | 7 ------- package.json | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9142971..8eca953 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,13 +13,6 @@ Setup npm i ``` -Test ----- - -```bash -npm t -``` - Run --- diff --git a/package.json b/package.json index cf664a8..c841b78 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "package": "npm pack", "serve:firefox": "web-ext run --target firefox-desktop", "serve:chromium": "web-ext run --target chromium", - "test": "eslint src" + "lint": "eslint src" }, "devDependencies": { "eslint-config-standard": "^14.1.1", From 114d7ad0f478a98047d1d94d8fa32f919b8b2fb1 Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Thu, 15 Apr 2021 02:05:59 +0530 Subject: [PATCH 9/9] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 821f172..d2591f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +### unreleased + - replace [`grunt`](https://gruntjs.com) with [`web-ext`](https://extensionworkshop.com) + ### v1.7.2 / 2020-10-30 - Fix contribution graph and progress bar colors (new GitHub CSS variables)