From d87d49ce610167f6aa061a983d10dc61eb4573fc Mon Sep 17 00:00:00 2001 From: MaysWind Date: Wed, 21 Nov 2018 20:46:21 +0800 Subject: [PATCH] add version and git commit hash in AriaNg settings page --- gulpfile.js | 4 +++- package-lock.json | 22 ++++++++++++++++++++++ package.json | 1 + src/index.html | 3 ++- src/langs/zh_Hans.txt | 1 + src/langs/zh_Hant.txt | 1 + src/scripts/config/buildConfiguration.js | 8 ++++++++ src/scripts/config/defaultLanguage.js | 1 + src/scripts/controllers/main.js | 4 +++- src/scripts/controllers/settings-ariang.js | 4 +++- src/views/settings-ariang.html | 6 ++++++ 11 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/scripts/config/buildConfiguration.js diff --git a/gulpfile.js b/gulpfile.js index 428f0d2..a17485e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var gulpLoadPlugins = require('gulp-load-plugins'); var browserSync = require('browser-sync'); var del = require('del'); var fs = require('fs'); +var git = require('git-rev-sync'); var $ = gulpLoadPlugins(); var reload = browserSync.reload; @@ -54,6 +55,8 @@ gulp.task('prepare-scripts', function () { return gulp.src([ 'src/scripts/**/*.js' ]).pipe($.plumber()) + .pipe($.injectVersion({replace: '${ARIANG_VERSION}'})) + .pipe($.replace(/\${ARIANG_BUILD_COMMIT}/g, git.short())) .pipe(gulp.dest('.tmp/scripts')) .pipe(reload({stream: true})); }); @@ -70,7 +73,6 @@ gulp.task('prepare-html', ['prepare-styles', 'prepare-scripts', 'prepare-views'] return gulp.src([ 'src/*.html' ]).pipe($.useref({searchPath: ['.tmp', 'src', '.']})) - .pipe($.injectVersion()) .pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, ''))) .pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, ''))) .pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'}))) diff --git a/package-lock.json b/package-lock.json index cea89dc..64f12b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3986,6 +3986,17 @@ "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "dev": true }, + "git-rev-sync": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-1.12.0.tgz", + "integrity": "sha1-RGhAbH5sO6TPRYeZnhrbKNnRr1U=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "graceful-fs": "4.1.11", + "shelljs": "0.7.7" + } + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -9656,6 +9667,17 @@ "jsonify": "~0.0.0" } }, + "shelljs": { + "version": "0.7.7", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", + "integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=", + "dev": true, + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + }, "sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", diff --git a/package.json b/package.json index 6957ef0..cd420b4 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "del": "^3.0.0", "eslint-config-angular": "^0.5.0", "eslint-plugin-angular": "^3.3.0", + "git-rev-sync": "^1.12.0", "gulp": "^3.9.1", "gulp-angular-templatecache": "^2.2.1", "gulp-autoprefixer": "^5.0.0", diff --git a/src/index.html b/src/index.html index 65094ff..b080c31 100644 --- a/src/index.html +++ b/src/index.html @@ -50,7 +50,7 @@