From 916d718d4cf83bd5b42130fa4c9c3e4b623e717c Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 8 Mar 2020 15:17:29 +0800 Subject: [PATCH] build: simplify versioning process --- package.json | 4 ++-- scripts/version.js | 29 ----------------------------- src/manifest.json | 29 ++++++----------------------- webpack.config.js | 7 +++++++ 4 files changed, 15 insertions(+), 54 deletions(-) delete mode 100644 scripts/version.js diff --git a/package.json b/package.json index a42ff30..876d61d 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { "name": "gitako", "version": "1.0.1", - "description": "The missing part of GitHub.", + "description": "Awesome GitHub file tree.", "repository": "https://github.com/EnixCoda/Gitako", "author": "EnixCoda", "license": "MIT", "private": true, + "homepage": "https://github.com/EnixCoda/Gitako", "scripts": { "start": "VERSION=dev-v$(node scripts/get-version.js) webpack --watch", "debug-firefox": "web-ext run -s dist", "analyse-bundle": "ANALYSE= NODE_ENV=production webpack", "build": "VERSION=v$(node scripts/get-version.js) NODE_ENV=production webpack", - "postversion": "node scripts/version.js", "roll": "make release" }, "dependencies": { diff --git a/scripts/version.js b/scripts/version.js deleted file mode 100644 index 11dad2f..0000000 --- a/scripts/version.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * copy version from package.json to manifest.json - * also remove old git tag for the version - */ - -const fs = require('fs') -const path = require('path') -const cp = require('child_process') - -const rootPath = path.resolve(__dirname, '../') -const manifestPath = path.resolve(rootPath, 'src/manifest.json') - -const manifest = require(manifestPath) -const version = require('./get-version') - -manifest.version = version -fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '), 'utf-8') - -const exec = command => - new Promise((resolve, reject) => - cp.exec(command, (error, stdout, stderr) => - error ? reject(error) : resolve(stdout || stderr), - ), - ) - -exec(`git tag -d v${version}`) - .then(() => exec(`git add src/manifest.json && git commit --amend --no-edit`)) - .then(() => exec(`git tag v${version}`)) - .catch(console.error) diff --git a/src/manifest.json b/src/manifest.json index 2cb0533..aefade9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,34 +1,17 @@ { "manifest_version": 2, - "name": "Gitako - Github file tree", - "version": "1.0.1", - "description": "The missing part of GitHub.", - "author": "EnixCoda", + "name": "Gitako", "icons": { "64": "icons/Gitako-64.png", "128": "icons/Gitako-128.png", "256": "icons/Gitako-256.png" }, - "homepage_url": "https://github.com/EnixCoda/Gitako", - "permissions": [ - "storage", - "*://*.github.com/*", - "*://*.sentry.io/*" - ], - "web_accessible_resources": [ - "icons/vscode/*", - "content.css" - ], + "permissions": ["storage", "*://*.github.com/*", "*://*.sentry.io/*"], + "web_accessible_resources": ["icons/vscode/*", "content.css"], "content_scripts": [ { - "matches": [ - "https://github.com/*" - ], - "js": [ - "firefox-shim.js", - "browser-polyfill.js", - "content.js" - ] + "matches": ["https://github.com/*"], + "js": ["firefox-shim.js", "browser-polyfill.js", "content.js"] } ] -} \ No newline at end of file +} diff --git a/webpack.config.js b/webpack.config.js index 34a2eab..6ac42db 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,6 +14,13 @@ const plugins = [ { from: './src/manifest.json', to: 'manifest.json', + transform(content) { + const { version, description, author, homepage: homepage_url } = require('./package.json') + const manifest = JSON.parse(content) + return JSON.stringify( + Object.assign(manifest, { version, description, author, homepage_url }), + ) + }, }, { from: './src/assets/icons/*',