diff --git a/.github/workflows/create-prerelease-on-tag.yml b/.github/workflows/create-prerelease-on-tag.yml index 06cb8c7e60..0999c5ec7b 100644 --- a/.github/workflows/create-prerelease-on-tag.yml +++ b/.github/workflows/create-prerelease-on-tag.yml @@ -21,7 +21,7 @@ jobs: node-version-file: ".node-version" - name: Lint - run: npm run-script build + run: npm run-script build -- --yomitan-version ${{ github.ref_name }} shell: bash - name: Release diff --git a/.gitignore b/.gitignore index d4e5da07f7..405fead0aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dictionaries/ /playwright-report/ /playwright/.cache/ /test/playwright/__screenshots__/ +ext/manifest.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ffc76b74b1..cc08a34f75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,7 @@ Several command line arguments are available for these scripts: * `--manifest ` - Overwrites [ext/manifest.json](ext/manifest.json) with the manifest variant for the specified build target. * `--dry-run` - Runs the full build process (excluding zip building), checking that the configuration is valid. * `--dry-run-build-zip` - If `--dry-run` is also specified, zip building will also be performed in memory; no files are created. +* `--yomitan-version ` - Sets the version number in the extension manifest. Defaults to 0.0.0.0 if not set. If no arguments are specified, the command is equivalent to `build.bat --all`. diff --git a/dev/build.js b/dev/build.js index 5222c4c899..24b1e2d0f5 100644 --- a/dev/build.js +++ b/dev/build.js @@ -108,7 +108,7 @@ function getIndexOfFilePath(array, item) { return -1; } -async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip) { +async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip, yomitanVersion) { const sevenZipExes = ['7za', '7z']; // Create build directory @@ -130,6 +130,8 @@ async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, process.stdout.write(message); }; + process.stdout.write(`Version: ${yomitanVersion}...\n`); + for (const variantName of variantNames) { const variant = manifestUtil.getVariant(variantName); if (typeof variant === 'undefined' || variant.buildable === false) { continue; } @@ -148,7 +150,7 @@ async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, const fileNameSafe = path.basename(fileName); const fullFileName = path.join(buildDir, fileNameSafe); if (!dryRun) { - fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest)); + fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest).replace('$YOMITAN_VERSION', yomitanVersion)); } if (!dryRun || dryRunBuildZip) { @@ -183,11 +185,13 @@ async function main(argv) { ['manifest', null], ['dry-run', false], ['dry-run-build-zip', false], + ['yomitan-version', '0.0.0.0'], [null, []] ])); const dryRun = args.get('dry-run'); const dryRunBuildZip = args.get('dry-run-build-zip'); + const yomitanVersion = args.get('yomitan-version'); const manifestUtil = new ManifestUtil(); @@ -202,14 +206,14 @@ async function main(argv) { manifestUtil.getVariants().filter(({buildable}) => buildable !== false).map(({name}) => name) : args.get(null) ); - await build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip); + await build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip, yomitanVersion); } finally { // Restore manifest const manifestName = (!args.get('default') && args.get('manifest') !== null) ? args.get('manifest') : null; const restoreManifest = manifestUtil.getManifest(manifestName); process.stdout.write('Restoring manifest...\n'); if (!dryRun) { - fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(restoreManifest)); + fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(restoreManifest).replace('$YOMITAN_VERSION', yomitanVersion)); } } } diff --git a/dev/data/manifest-variants.json b/dev/data/manifest-variants.json index 304a3a0ef9..26d91d263e 100644 --- a/dev/data/manifest-variants.json +++ b/dev/data/manifest-variants.json @@ -2,7 +2,7 @@ "manifest": { "manifest_version": 3, "name": "Yomitan", - "version": "23.4.7.0", + "version": "$YOMITAN_VERSION", "description": "Japanese dictionary with Anki integration", "author": "TheMoeWay", "icons": { diff --git a/ext/manifest.json b/ext/manifest.json deleted file mode 100644 index 018a4a0b5b..0000000000 --- a/ext/manifest.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "manifest_version": 3, - "name": "Yomitan", - "version": "23.4.7.0", - "description": "Japanese dictionary with Anki integration", - "author": "TheMoeWay", - "icons": { - "16": "images/icon16.png", - "19": "images/icon19.png", - "32": "images/icon32.png", - "38": "images/icon38.png", - "48": "images/icon48.png", - "64": "images/icon64.png", - "128": "images/icon128.png" - }, - "action": { - "default_icon": { - "16": "images/icon16.png", - "19": "images/icon19.png", - "32": "images/icon32.png", - "38": "images/icon38.png", - "48": "images/icon48.png", - "64": "images/icon64.png", - "128": "images/icon128.png" - }, - "default_title": "Yomitan", - "default_popup": "action-popup.html" - }, - "background": { - "service_worker": "sw.js" - }, - "content_scripts": [ - { - "run_at": "document_idle", - "matches": [ - "http://*/*", - "https://*/*", - "file://*/*" - ], - "match_about_blank": true, - "all_frames": true, - "js": [ - "js/core.js", - "js/yomichan.js", - "js/app/frontend.js", - "js/app/popup.js", - "js/app/popup-factory.js", - "js/app/popup-proxy.js", - "js/app/popup-window.js", - "js/app/theme-controller.js", - "js/comm/api.js", - "js/comm/cross-frame-api.js", - "js/comm/frame-ancestry-handler.js", - "js/comm/frame-client.js", - "js/comm/frame-offset-forwarder.js", - "js/data/sandbox/string-util.js", - "js/dom/dom-text-scanner.js", - "js/dom/document-util.js", - "js/dom/text-source-element.js", - "js/dom/text-source-range.js", - "js/input/hotkey-handler.js", - "js/language/text-scanner.js", - "js/script/dynamic-loader.js", - "js/app/content-script-main.js" - ] - } - ], - "minimum_chrome_version": "96.0.0.0", - "options_ui": { - "page": "settings.html", - "open_in_tab": true - }, - "sandbox": { - "pages": [ - "template-renderer.html" - ] - }, - "permissions": [ - "storage", - "clipboardWrite", - "unlimitedStorage", - "webRequest", - "declarativeNetRequest", - "scripting" - ], - "optional_permissions": [ - "clipboardRead", - "nativeMessaging" - ], - "host_permissions": [ - "" - ], - "commands": { - "toggleTextScanning": { - "suggested_key": { - "default": "Alt+Delete" - }, - "description": "Toggle text scanning on/off" - }, - "openInfoPage": { - "description": "Open the info page" - }, - "openSettingsPage": { - "description": "Open the settings page" - }, - "openSearchPage": { - "suggested_key": { - "default": "Alt+Insert" - }, - "description": "Open the search page" - }, - "openPopupWindow": { - "description": "Open the popup window" - } - }, - "web_accessible_resources": [ - { - "resources": [ - "popup.html", - "template-renderer.html" - ], - "matches": [ - "" - ] - } - ], - "content_security_policy": { - "extension_pages": "default-src 'self'; img-src blob: 'self'; style-src 'self' 'unsafe-inline'; media-src *; connect-src *", - "sandbox": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'unsafe-inline'" - } -}