Skip to content

Commit

Permalink
feat(App): Add manifest v3 for chrome + Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
bamdadfr committed Mar 20, 2024
1 parent bf37548 commit 1250cc0
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 83 deletions.
5 changes: 3 additions & 2 deletions bin/prepare.sh → bin/increment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ function update_json() {
}

path='package.json'

update_json

path='src/manifest.json'
path='src/manifest-chrome.json'
update_json

path='src/manifest-firefox.json'
update_json
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
"email": "[email protected]"
},
"scripts": {
"build": "pnpm clean && pnpm build:webpack && pnpm build:ext",
"build": "pnpm dev:clean && pnpm build:clean && pnpm build:chrome && pnpm build:firefox",
"build:clean": "rimraf packages",
"build:ext": "web-ext build --source-dir dist",
"build:prepare": "./bin/prepare.sh",
"build:webpack": "NODE_ENV=production webpack",
"clean": "pnpm dev:clean && pnpm build:clean",
"dev": "pnpm dev:chrome",
"dev:chrome": "pnpm dev:clean && concurrently 'pnpm dev:webpack' 'wait-on dist/manifest.json && pnpm dev:ext:chrome'",
"build:increment": "build/increment.sh",
"build:chrome": "pnpm build:chrome:webpack && pnpm build:chrome:package",
"build:chrome:package": "web-ext build --source-dir dist/chrome --filename chrome.zip",
"build:chrome:webpack": "NODE_ENV=production pnpm webpack:chrome",
"build:firefox": "pnpm build:firefox:webpack && pnpm build:firefox:package",
"build:firefox:package": "web-ext build --source-dir dist/firefox --filename firefox.zip",
"build:firefox:webpack": "NODE_ENV=production pnpm webpack:firefox",
"dev:clean": "rimraf dist",
"dev:ext:chrome": "web-ext run -t chromium",
"dev:ext:firefox": "web-ext run",
"dev:firefox": "pnpm dev:clean && concurrently 'pnpm dev:webpack' 'wait-on dist/manifest.json && pnpm dev:ext:firefox'",
"dev:webpack": "webpack",
"dev:chrome": "pnpm dev:clean && pnpm dev:chrome:watch",
"dev:chrome:run": "web-ext run --source-dir dist/chrome -t chromium",
"dev:chrome:watch": "concurrently 'pnpm webpack:chrome' 'wait-on dist/chrome/manifest.json && pnpm dev:chrome:run'",
"dev:firefox": "pnpm dev:clean && pnpm dev:firefox:watch",
"dev:firefox:run": "web-ext run --source-dir dist/firefox",
"dev:firefox:watch": "concurrently 'pnpm webpack:firefox' 'wait-on dist/firefox/manifest.json && pnpm dev:firefox:run'",
"lint": "eslint src --ext .js --fix",
"package:reinstall": "rimraf node_modules && pnpm",
"package:sort": "npx sort-package-json",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watchAll"
"test:watch": "jest --watchAll",
"webpack:chrome": "webpack --env chrome",
"webpack:firefox": "webpack --env firefox"
},
"dependencies": {
"speed-to-percentage": "^1.2.1",
Expand Down
79 changes: 48 additions & 31 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
/* eslint-disable no-template-curly-in-string */

module.exports = {
'plugins': [
plugins: [
['@semantic-release/commit-analyzer'],
['@semantic-release/release-notes-generator'],
['@semantic-release/changelog', {
changelogFile: 'CHANGELOG.md',
}],
['@semantic-release/exec', {
prepareCmd: 'yarn build:prepare ${nextRelease.version} && yarn build',
}],
['semantic-release-firefox-add-on', {
extensionId: '{891ed2be-6ca9-47d1-9466-1595afa33b80}',
targetXpi: 'bandcamp-plus--extension-${nextRelease.version}.xpi',
artifactsDir: 'packages',
channel: 'listed',
}],
['semantic-release-chrome', {
extensionId: 'hggjmjobahhmbmnfndhdgidchhhhjkad',
asset: 'bandcamp-plus--extension-${nextRelease.version}.zip',
}],
['@semantic-release/github', {
assets: [
'packages/bandcamp-plus--extension-${nextRelease.version}.xpi',
'bandcamp-plus--extension-${nextRelease.version}.zip',
],
}],
['@semantic-release/git', {
assets: [
'CHANGELOG.md',
'package.json',
'src/manifest.json',
],
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
}],
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md',
},
],
[
'@semantic-release/exec',
{
prepareCmd: 'pnpm build:increment ${nextRelease.version} && pnpm build',
},
],
[
'semantic-release-firefox-add-on',
{
extensionId: '{891ed2be-6ca9-47d1-9466-1595afa33b80}',
targetXpi: 'bandcamp-plus--extension-${nextRelease.version}.xpi',
sourceDir: 'dist/firefox',
artifactsDir: 'packages',
channel: 'listed',
},
],
[
'semantic-release-chrome',
{
extensionId: 'hggjmjobahhmbmnfndhdgidchhhhjkad',
asset: 'bandcamp-plus--extension-${nextRelease.version}.zip',
distFolder: 'dist/chrome',
},
],
[
'@semantic-release/github',
{
assets: [
'packages/bandcamp-plus--extension-${nextRelease.version}.xpi',
'bandcamp-plus--extension-${nextRelease.version}.zip',
],
},
],
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md', 'package.json', 'src/manifest-*.json'],
message:
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
],
};
36 changes: 36 additions & 0 deletions src/manifest-chrome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Bandcamp+",
"short_name": "bandcamp-plus",
"description": "Add multiple features to bandcamp.com",
"version": "3.2.4",
"manifest_version": 2,
"icons": {
"512": "assets/bandcamp-plus-icon.png"
},
"action": {
"default_title": "Bandcamp+",
"default_icon": {
"512": "assets/bandcamp-plus-icon.png"
}
},
"content_scripts": [
{
"matches": [
"*://*.bandcamp.com/*"
],
"js": [
"scripts/content.js"
],
"css": [
"assets/content.css"
],
"run_at": "document_start",
"all_frames": false
}
],
"background": {
"scripts": [
"scripts/background.js"
]
}
}
File renamed without changes.
87 changes: 49 additions & 38 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,61 @@
const CopyPlugin = require('copy-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const path = require('path');

// eslint-disable-next-line no-console
console.log('Production mode is: ', isProduction);

module.exports = {
watch: !isProduction,
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? false : 'inline-source-map',
entry: {
'scripts/content': './src/app/content.ts',
'scripts/background': './src/app/background.ts',
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
'publicPath': '',
},
node: false,
plugins: [
new CopyPlugin({
patterns: [
module.exports = (env) => {
const getBrowserFlavour = () => {
if (env.chrome === true) {
return 'chrome';
} else if (env.firefox === true) {
return 'firefox';
}
};

return {
watch: !isProduction,
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? false : 'inline-source-map',
entry: {
'scripts/content': './src/app/content.ts',
'scripts/background': './src/app/background.ts',
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
path: path.resolve(__dirname, `dist/${getBrowserFlavour()}`),
},
node: false,
plugins: [
new CopyPlugin({
patterns: [
{
from: `./src/manifest-${getBrowserFlavour()}.json`,
to: 'manifest.json',
},
{
from: './src/assets',
to: 'assets',
},
],
}),
],
module: {
rules: [
{
from: './src/manifest.json',
to: 'manifest.json',
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
from: './src/assets',
to: 'assets',
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
}),
],
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
},
};
};

0 comments on commit 1250cc0

Please sign in to comment.