Skip to content

Commit

Permalink
feat: upgrade to Manifest V3 in Chrome
Browse files Browse the repository at this point in the history
BREAKING CHANGE: browser versions older than Chrome 123, Edge 123,
Firefox 115 and Opera 109 are no longer supported
  • Loading branch information
dessant committed May 28, 2024
1 parent d9ace78 commit e7b1115
Show file tree
Hide file tree
Showing 38 changed files with 14,038 additions and 15,677 deletions.
13 changes: 6 additions & 7 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[chrome]
Chrome >= 92
Edge >= 92
Opera >= 78
Chrome >= 123
Edge >= 123
Opera >= 109

[edge]
Edge >= 92
Edge >= 123

[firefox]
Firefox >= 91
FirefoxAndroid >= 91
Firefox >= 115

[opera]
Opera >= 78
Opera >= 109
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
contents: read
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: 'false'
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand All @@ -30,7 +30,7 @@ jobs:
run: sha256sum artifacts/*/*
if: startsWith(github.ref, 'refs/tags/v')
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
name: artifacts
Expand All @@ -45,14 +45,14 @@ jobs:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts/
- name: Hash artifacts
run: sha256sum artifacts/*/*
- name: Create GitHub release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/label-actions@v3
- uses: dessant/label-actions@v4
2 changes: 1 addition & 1 deletion .github/workflows/lockdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/repo-lockdown@v3
- uses: dessant/repo-lockdown@v4
with:
exclude-pr-created-before: '2023-02-03T00:00:00Z'
pr-comment: 'This project does not accept pull requests. Please use issues to report bugs or suggest new features.'
Expand Down
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/.assets/

node_modules/
/app/
/artifacts/
/dist/

/.vscode
/report.json
/report.html

/web-ext-config.js

node_modules/
/npm-debug.log

/report.json
/report.html
/.vscode

xcuserdata/

.DS_Store
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.14.2
20.12.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Supported data types:

## License

Copyright (c) 2017-2023 Armin Sebastian
Copyright (c) 2017-2024 Armin Sebastian

This software is released under the terms of the GNU General Public License v3.0.
See the [LICENSE](LICENSE) file for further information.
15 changes: 6 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('node:path');

const corejsVersion = require(path.join(
path.dirname(require.resolve('core-js')),
'package.json'
)).version;
const corejsVersion = require(
path.join(path.dirname(require.resolve('core-js')), 'package.json')
).version;

module.exports = function (api) {
api.cache(true);

const presets = [
[
'@babel/env',
Expand All @@ -24,11 +25,7 @@ module.exports = function (api) {
new RegExp(`node_modules\\${path.sep}(?!(vueton|wesa)\\${path.sep}).*`)
];

const parserOpts = {plugins: ['importAssertions']};

if (api.env('production')) {
plugins.push('lodash');
}
const parserOpts = {plugins: ['importAttributes']};

return {presets, plugins, ignore, parserOpts};
};
54 changes: 39 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const targetEnv = process.env.TARGET_ENV || 'chrome';
const isProduction = process.env.NODE_ENV === 'production';
const enableContributions =
(process.env.ENABLE_CONTRIBUTIONS || 'true') === 'true';

const mv3 = ['chrome'].includes(targetEnv);

const distDir = path.join(__dirname, 'dist', targetEnv);

function initEnv() {
Expand All @@ -45,12 +48,17 @@ function js(done) {
}

function html() {
return src(
enableContributions
? 'src/**/*.html'
: ['src/**/*.html', '!src/contribute/*.html'],
{base: '.'}
)
const htmlSrc = ['src/**/*.html'];

if (mv3) {
htmlSrc.push('!src/background/*.html');
}

if (!enableContributions) {
htmlSrc.push('!src/contribute/*.html');
}

return src(htmlSrc, {base: '.'})
.pipe(gulpif(isProduction, htmlmin({collapseWhitespace: true})))
.pipe(dest(distDir));
}
Expand All @@ -70,7 +78,10 @@ async function images(done) {
// Chrome Web Store does not correctly display optimized icons
if (isProduction && targetEnv !== 'chrome') {
await new Promise(resolve => {
src(path.join(distDir, 'src/assets/icons/app/*.png'), {base: '.'})
src(path.join(distDir, 'src/assets/icons/app/*.png'), {
base: '.',
encoding: false
})
.pipe(imagemin())
.pipe(dest('.'))
.on('error', done)
Expand All @@ -79,7 +90,10 @@ async function images(done) {
}

await new Promise(resolve => {
src('src/assets/icons/@(app|datatypes|misc)/*.@(png|svg)', {base: '.'})
src('src/assets/icons/@(app|datatypes|misc)/*.@(png|svg)', {
base: '.',
encoding: false
})
.pipe(gulpif(isProduction, imagemin()))
.pipe(dest(distDir))
.on('error', done)
Expand All @@ -88,7 +102,10 @@ async function images(done) {

if (enableContributions) {
await new Promise(resolve => {
src('node_modules/vueton/components/contribute/assets/*.@(png|svg)')
src(
'node_modules/vueton/components/contribute/assets/*.@(png|webp|svg)',
{encoding: false}
)
.pipe(gulpif(isProduction, imagemin()))
.pipe(dest(path.join(distDir, 'src/contribute/assets')))
.on('error', done)
Expand All @@ -108,7 +125,8 @@ async function fonts(done) {

await new Promise(resolve => {
src(
'node_modules/@fontsource/roboto/files/roboto-latin-@(400|500|700)-normal.woff2'
'node_modules/@fontsource/roboto/files/roboto-latin-@(400|500|700)-normal.woff2',
{encoding: false}
)
.pipe(dest(path.join(distDir, 'src/assets/fonts/files')))
.on('error', done)
Expand Down Expand Up @@ -169,22 +187,28 @@ function manifest() {
.pipe(dest(distDir));
}

function license() {
function license(done) {
let year = '2017';
const currentYear = new Date().getFullYear().toString();
if (year !== currentYear) {
year = `${year}-${currentYear}`;
}

const notice = `Clear Browsing Data
let notice = `Clear Browsing Data
Copyright (c) ${year} Armin Sebastian
`;

if (['safari', 'samsung'].includes(targetEnv)) {
writeFileSync(path.join(distDir, 'NOTICE'), notice);
done();
} else {
notice = `${notice}
This software is released under the terms of the GNU General Public License v3.0.
See the LICENSE file for further information.
`;

writeFileSync(path.join(distDir, 'NOTICE'), notice);
return src('LICENSE').pipe(dest(distDir));
writeFileSync(path.join(distDir, 'NOTICE'), notice);
return src('LICENSE').pipe(dest(distDir));
}
}

function zip(done) {
Expand Down
Loading

0 comments on commit e7b1115

Please sign in to comment.