diff --git a/devtool/public/manifest.firefox.json b/devtool/public/manifest.firefox.json index f967c3c4..4d351f91 100644 --- a/devtool/public/manifest.firefox.json +++ b/devtool/public/manifest.firefox.json @@ -1,6 +1,6 @@ { "name": "__MSG_name__", - "version": "0.3.1", + "version": "0.3.2", "description": "__MSG_description__", "short_name": "morfeo", "author": "Mauro Erta", @@ -13,7 +13,9 @@ "128": "img/icon-128.png" }, "background": { - "scripts": ["background.bundle.js"] + "scripts": [ + "background.bundle.js" + ] }, "browser_action": { "default_icon": { @@ -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", ""] + "permissions": [ + "clipboardWrite", + "tabs", + "" + ] } diff --git a/devtool/public/manifest.json b/devtool/public/manifest.json index 3f206a67..596f58d4 100644 --- a/devtool/public/manifest.json +++ b/devtool/public/manifest.json @@ -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", @@ -23,17 +23,28 @@ } }, "externally_connectable": { - "ids": ["*"] + "ids": [ + "*" + ] }, - "permissions": ["activeTab", "clipboardWrite"], + "permissions": [ + "activeTab", + "clipboardWrite" + ], "background": { "service_worker": "background.bundle.js" }, "content_scripts": [ { - "matches": [""], - "exclude_globs": ["https://www.google*"], - "js": ["contentScript.bundle.js"], + "matches": [ + "" + ], + "exclude_globs": [ + "https://www.google*" + ], + "js": [ + "contentScript.bundle.js" + ], "run_at": "document_start", "all_frames": true } diff --git a/package.json b/package.json index 97f7084f..87eb3b31 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/version-devtool.ts b/scripts/version-devtool.ts new file mode 100644 index 00000000..594796da --- /dev/null +++ b/scripts/version-devtool.ts @@ -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', +);