Skip to content

Commit

Permalink
feat: web extension version upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroerta committed Nov 15, 2021
1 parent 8c0558d commit 266a9f6
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 13 deletions.
21 changes: 16 additions & 5 deletions devtool/public/manifest.firefox.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_name__",
"version": "0.3.1",
"version": "0.3.2",
"description": "__MSG_description__",
"short_name": "morfeo",
"author": "Mauro Erta",
Expand All @@ -13,7 +13,9 @@
"128": "img/icon-128.png"
},
"background": {
"scripts": ["background.bundle.js"]
"scripts": [
"background.bundle.js"
]
},
"browser_action": {
"default_icon": {
Expand All @@ -32,11 +34,20 @@
"devtools_page": "devtool.html",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["contentScript.bundle.js"],
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"contentScript.bundle.js"
],
"run_at": "document_start",
"all_frames": false
}
],
"permissions": ["clipboardWrite", "tabs", "<all_urls>"]
"permissions": [
"clipboardWrite",
"tabs",
"<all_urls>"
]
}
23 changes: 17 additions & 6 deletions devtool/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "__MSG_name__",
"version": "0.3.1",
"version": "0.3.2",
"description": "__MSG_description__",
"author": "Mauro Erta",
"devtools_page": "devtool.html",
Expand All @@ -23,17 +23,28 @@
}
},
"externally_connectable": {
"ids": ["*"]
"ids": [
"*"
]
},
"permissions": ["activeTab", "clipboardWrite"],
"permissions": [
"activeTab",
"clipboardWrite"
],
"background": {
"service_worker": "background.bundle.js"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"exclude_globs": ["https://www.google*"],
"js": ["contentScript.bundle.js"],
"matches": [
"<all_urls>"
],
"exclude_globs": [
"https://www.google*"
],
"js": [
"contentScript.bundle.js"
],
"run_at": "document_start",
"all_frames": true
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"publish": "npm run reset && npx lerna publish from-package --yes --no-verify-access",
"version": "npx lerna version patch --no-push --no-git-tag-version --conventional-commits",
"version:minor": "npx lerna version minor --no-push --no-git-tag-version --conventional-commits",
"postversion": "ts-node scripts/version.ts",
"postversion:minor": "npm run postversion"
"version:devtool": "ts-node scripts/version-devtool.ts",
"postversion": "ts-node scripts/version.ts && npm run version:devtool",
"postversion:minor": "npm run postversion -- minor"
},
"dependencies": {
"react": "^17.0.2",
Expand Down
56 changes: 56 additions & 0 deletions scripts/version-devtool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as fs from 'fs';
import * as path from 'path';

const args = process.argv.slice(2);
const [VERSION_TYPE] = args;

const DEVTOOL_PUBLIC_PATH = path.join(__dirname, '../devtool', 'public');

const DEVTOOL_MANIFEST_PATH = path.join(DEVTOOL_PUBLIC_PATH, 'manifest.json');
const MOZILLA_DEVTOOL_MANIFEST_PATH = path.join(
DEVTOOL_PUBLIC_PATH,
'manifest.firefox.json',
);

const devtoolManifest = JSON.parse(
fs.readFileSync(DEVTOOL_MANIFEST_PATH, { encoding: 'utf8' }),
);

const mozillaDevtoolManifest = JSON.parse(
fs.readFileSync(MOZILLA_DEVTOOL_MANIFEST_PATH, { encoding: 'utf8' }),
);

const currentVersion = devtoolManifest.version as string;

let [major = 0, minor = 0, patch = 0] = currentVersion
.split('.')
.map((number: string) => {
const parsed = Number.parseInt(number);
return Number.isNaN(parsed) ? 0 : parsed;
});

if (VERSION_TYPE === 'major') {
major += 1;
minor = 0;
patch = 0;
} else if (VERSION_TYPE === 'minor') {
minor += 1;
patch = 0;
} else {
patch += 1;
}

const newVersion = [major, minor, patch].join('.');

devtoolManifest.version = newVersion;
mozillaDevtoolManifest.version = newVersion;

fs.writeFileSync(
DEVTOOL_MANIFEST_PATH,
JSON.stringify(devtoolManifest, undefined, 2) + '\n',
);

fs.writeFileSync(
MOZILLA_DEVTOOL_MANIFEST_PATH,
JSON.stringify(mozillaDevtoolManifest, undefined, 2) + '\n',
);

0 comments on commit 266a9f6

Please sign in to comment.