From 2a6af16ea5b06d911260a04f96bb3cec0e0985b4 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 26 Aug 2020 20:52:15 +0200 Subject: [PATCH] #35 Changed manifests to template system Including a template file and replacing of variables in buildscripts --- gulpfile.js | 15 +++++- package-lock.json | 69 ++++++++++++++++++++-------- package.json | 3 +- src/manifests/chrome.manifest.json | 52 ++++++++------------- src/manifests/firefox.manifest.json | 44 ++++++------------ src/manifests/manifest.template.json | 20 ++++++++ src/manifests/opera.manifest.json | 46 +++++++------------ 7 files changed, 137 insertions(+), 112 deletions(-) create mode 100644 src/manifests/manifest.template.json diff --git a/gulpfile.js b/gulpfile.js index a3340f6..585f54a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,7 @@ const browserify = require('browserify'); const babelify = require('babelify'); const source = require('vinyl-source-stream'); const buffer = require('vinyl-buffer'); +const fs = require('fs'); const $ = gulpLoadPlugins() @@ -128,8 +129,20 @@ gulp.task('images', () => { }) gulp.task('manifests', () => { - return gulp.src(`${src.manifests}/**/*.json`) + const templateFile = `${src.manifests}/manifest.template.json`; + + let template = JSON.parse(fs.readFileSync(templateFile)) + + return gulp.src(`${src.manifests}/**/!(*.template).json`) .pipe($.plumber()) + .pipe($.replace('$name', template.name)) + .pipe($.replace('$shortName', template.short_name)) + .pipe($.replace('$version', template.version)) + .pipe($.replace('$semanticVersion', template.version_name)) + .pipe($.replace('$description', template.description)) + .pipe($.replace('$author', template.author)) + .pipe($.replace('$developer', template.developer)) + .pipe($.replace('$homepageURL', template.homepage_url)) .pipe($.size({ showFiles: true, })) diff --git a/package-lock.json b/package-lock.json index c6f7314..4de1306 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2099,6 +2099,12 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, + "binaryextensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binaryextensions/-/binaryextensions-2.3.0.tgz", + "integrity": "sha512-nAihlQsYGyc5Bwq6+EsubvANYGExeJKHDO3RjnvwU042fawQTQfM3Kxn7IHUXQOz4bzfwsGYYHGSvXyW4zOGLg==", + "dev": true + }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -3886,6 +3892,12 @@ "safer-buffer": "^2.1.0" } }, + "editions": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz", + "integrity": "sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==", + "dev": true + }, "electron-to-chromium": { "version": "1.3.545", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.545.tgz", @@ -5200,18 +5212,6 @@ "vinyl-sourcemaps-apply": "^0.2.0" } }, - "gulp-better-rollup": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/gulp-better-rollup/-/gulp-better-rollup-4.0.1.tgz", - "integrity": "sha512-oUGrMd+p9umBPoIPYVDxFT4EwCzywh3o8q++eswJyAxrRgYCEM6OOGGxJLG+AmzzjEoiq0cc/ndgF5SH2qW3Fg==", - "dev": true, - "requires": { - "lodash.camelcase": "^4.3.0", - "plugin-error": "^1.0.1", - "vinyl": "^2.1.0", - "vinyl-sourcemaps-apply": "^0.2.1" - } - }, "gulp-if": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/gulp-if/-/gulp-if-3.0.0.tgz", @@ -5495,6 +5495,17 @@ "integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==", "dev": true }, + "gulp-replace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz", + "integrity": "sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==", + "dev": true, + "requires": { + "istextorbinary": "2.2.1", + "readable-stream": "^2.0.1", + "replacestream": "^4.0.0" + } + }, "gulp-sass": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-4.1.0.tgz", @@ -6582,6 +6593,17 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, + "istextorbinary": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz", + "integrity": "sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==", + "dev": true, + "requires": { + "binaryextensions": "2", + "editions": "^1.3.3", + "textextensions": "2" + } + }, "isurl": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", @@ -6849,12 +6871,6 @@ "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, - "lodash.camelcase": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", - "dev": true - }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -9022,6 +9038,17 @@ "remove-trailing-separator": "^1.1.0" } }, + "replacestream": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/replacestream/-/replacestream-4.0.3.tgz", + "integrity": "sha512-AC0FiLS352pBBiZhd4VXB1Ab/lh0lEgpP+GGvZqbQh8a5cmXVoTe5EX/YeTFArnp4SRGTHh1qCHu9lGs1qG8sA==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.3", + "object-assign": "^4.0.1", + "readable-stream": "^2.0.2" + } + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -10213,6 +10240,12 @@ } } }, + "textextensions": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.6.0.tgz", + "integrity": "sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", diff --git a/package.json b/package.json index e7731d5..9141354 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "gulp-plumber": "^1.2.1", "gulp-postcss": "^8.0.0", "gulp-rename": "^2.0.0", + "gulp-replace": "^1.0.0", "gulp-sass": "^4.1.0", "gulp-size": "^3.0.0", "gulp-sourcemaps": "^2.6.5", @@ -50,4 +51,4 @@ "url": "https://github.com/Serraniel/EnhancedAniwatch/issues" }, "homepage": "https://github.com/Serraniel/EnhancedAniwatch#readme" -} \ No newline at end of file +} diff --git a/src/manifests/chrome.manifest.json b/src/manifests/chrome.manifest.json index 77398f1..0dbfdb7 100644 --- a/src/manifests/chrome.manifest.json +++ b/src/manifests/chrome.manifest.json @@ -1,33 +1,19 @@ - { - "name": "Enhanced Aniwatch", - "short_name": "Enhanced Ani", - "version": "0.1.0.0", - "version_name": "0.1 Beta", - "description": "Enhanced Aniwatch is a slim extension which provides several UI improvments for https://aniwatch.me.", - "manifest_version": 2, - "author": "Serraniel", - "homepage_url": "https://github.com/Serraniel/EnhancedAniwatch", - "content_scripts": [{ - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "utils/colors.js", - "utils/helpers.js", - "utils/aniwatchCore.js" - ], - "run_at": "document_start" - }, - { - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "enhancements/quickSearch.js", - "enhancements/animeRequests.js", - "enhancements/lists.js" - ], - "run_at": "document_end" - } - ] - } \ No newline at end of file +{ + "name": "$name", + "short_name": "$shortName", + "version": "$version", + "version_name": "$semanticVersion", + "description": "$description", + "manifest_version": 2, + "author": "$author", + "homepage_url": "$homepageURL", + "content_scripts": [{ + "matches": [ + "*://aniwatch.me/*" + ], + "js": [ + "javascript/app.min.js" + ], + "run_at": "document_start" + }] +} \ No newline at end of file diff --git a/src/manifests/firefox.manifest.json b/src/manifests/firefox.manifest.json index 16bbaf0..2b77d08 100644 --- a/src/manifests/firefox.manifest.json +++ b/src/manifests/firefox.manifest.json @@ -1,33 +1,19 @@ { - "name": "Enhanced Aniwatch", - "short_name": "Enhanced Ani", - "version": "0.1.0.0", - "description": "Enhanced Aniwatch is a slim extension which provides several UI improvments for https://aniwatch.me.", + "name": "$name", + "short_name": "$shortName", + "version": "$version", + "description": "$description", "manifest_version": 2, - "author": "Serraniel", - "developer": "Serraniel and contributors", - "homepage_url": "https://github.com/Serraniel/EnhancedAniwatch", + "author": "$author", + "developer": "$developer", + "homepage_url": "$homepageURL", "content_scripts": [{ - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "utils/colors.js", - "utils/helpers.js", - "utils/aniwatchCore.js" - ], - "run_at": "document_start" - }, - { - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "enhancements/quickSearch.js", - "enhancements/animeRequests.js", - "enhancements/lists.js" - ], - "run_at": "document_end" - } - ] + "matches": [ + "*://aniwatch.me/*" + ], + "js": [ + "javascript/app.min.js" + ], + "run_at": "document_start" + }] } \ No newline at end of file diff --git a/src/manifests/manifest.template.json b/src/manifests/manifest.template.json new file mode 100644 index 0000000..2db78ac --- /dev/null +++ b/src/manifests/manifest.template.json @@ -0,0 +1,20 @@ +{ + "name": "Enhanced Aniwatch", + "short_name": "Enhanced Ani", + "version": "0.1.0.0", + "version_name": "0.1 Beta", + "description": "Enhanced Aniwatch is a slim extension which provides several UI improvments for https://aniwatch.me.", + "manifest_version": 2, + "author": "Serraniel", + "developer": "Serraniel and contributors", + "homepage_url": "https://github.com/Serraniel/EnhancedAniwatch", + "content_scripts": [{ + "matches": [ + "*://aniwatch.me/*" + ], + "js": [ + "javascript/app.min.js" + ], + "run_at": "document_start" + }] +} \ No newline at end of file diff --git a/src/manifests/opera.manifest.json b/src/manifests/opera.manifest.json index 7bccac1..39aee19 100644 --- a/src/manifests/opera.manifest.json +++ b/src/manifests/opera.manifest.json @@ -1,34 +1,20 @@ { - "name": "Enhanced Aniwatch", - "short_name": "Enhanced Ani", - "version": "0.1.0.0", - "version_name": "0.1 Beta", - "description": "Enhanced Aniwatch is a slim extension which provides several UI improvments for https://aniwatch.me.", + "name": "$name", + "short_name": "$shortName", + "version": "$version", + "version_name": "$semanticVersion", + "description": "$description", "manifest_version": 2, - "author": "Serraniel", - "developer": "Serraniel and contributors", - "homepage_url": "https://github.com/Serraniel/EnhancedAniwatch", + "author": "$author", + "developer": "$developer", + "homepage_url": "$homepageURL", "content_scripts": [{ - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "utils/colors.js", - "utils/helpers.js", - "utils/aniwatchCore.js" - ], - "run_at": "document_start" - }, - { - "matches": [ - "*://aniwatch.me/*" - ], - "js": [ - "enhancements/quickSearch.js", - "enhancements/animeRequests.js", - "enhancements/lists.js" - ], - "run_at": "document_end" - } - ] + "matches": [ + "*://aniwatch.me/*" + ], + "js": [ + "javascript/app.min.js" + ], + "run_at": "document_start" + }] } \ No newline at end of file