From 2fe64623ab2201ad21cb31137dde5260cfdc4beb Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Thu, 17 Aug 2023 18:53:12 +0200
Subject: [PATCH] enh(desktop): Prepare a config-test.js (for G1-test) when
 building the web archive (gulp webBuild)

---
 gulpfile.js           | 16 ++++++--
 www/js/config-test.js | 88 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+), 3 deletions(-)
 create mode 100644 www/js/config-test.js

diff --git a/gulpfile.js b/gulpfile.js
index 54afdd4c..a53352c2 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -422,6 +422,11 @@ function webCopyFiles() {
       .pipe(htmlmin())
       .pipe(gulp.dest(targetPath + '/api')),
 
+    // Copy config-test.js
+    gulp.src('./www/js/config*.js')
+      .pipe(debug(debugOptions))
+      .pipe(gulp.dest(targetPath)),
+
     // Copy fonts
     gulp.src('./www/fonts/**/*.*')
       .pipe(debug(debugOptions))
@@ -561,7 +566,7 @@ function webUglify() {
     log(colors.green('Minify JS and CSS files...'));
 
     const indexFilter = filter('**/index.html', {restore: true});
-    const jsFilter = filter(["**/*.js", '!**/config.js'], {restore: true});
+    const jsFilter = filter(["**/*.js", '!**/config.js', '!**/config-test.js'], {restore: true});
     const cssFilter = filter("**/*.css", {restore: true});
 
     // Process index.html
@@ -619,7 +624,7 @@ function webApiUglify() {
   const targetPath = './dist/web/www';
   const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
 
-  const jsFilter = filter(["**/*.js", '!**/config.js'], {restore: true});
+  const jsFilter = filter(["**/*.js", '!**/config.js', '!**/config-test.js'], {restore: true});
   const cssFilter = filter("**/*.css", {restore: true});
   const indexFilter = filter('**/index.html', {restore: true});
 
@@ -640,7 +645,7 @@ function webApiUglify() {
 
       // Process CSS
       .pipe(cssFilter)
-      .pipe(csso())               // Minify any CSS sources
+      .pipe(csso()) // Minify any CSS sources
       .pipe(cssFilter.restore)
 
       .pipe(indexFilter)
@@ -652,6 +657,7 @@ function webApiUglify() {
       .pipe(replace("dist_js", "../dist_js"))
       .pipe(replace("dist_css", "../dist_css"))
       .pipe(replace("config.js", "../config.js"))
+      .pipe(replace("config-test.js", "../config-test.js"))
       .pipe(indexFilter.restore)
 
       .pipe(sourcemaps.write('maps'))
@@ -669,6 +675,7 @@ function webApiUglify() {
       .pipe(replace("dist_js", "../dist_js"))
       .pipe(replace("dist_css", "../dist_css"))
       .pipe(replace("config.js", "../config.js"))
+      .pipe(replace("config-test.js", "../config-test.js"))
       .pipe(indexFilter.restore)
 
       .pipe(gulp.dest(targetPath));
@@ -707,6 +714,9 @@ function webCleanUnusedFiles(done) {
 
       // Unused maps/config.js.map
       gulp.src(targetPath + '/maps/config.js.map', {read: false, allowEmpty: true})
+        .pipe(debug(debugOptions))
+        .pipe(clean()),
+      gulp.src(targetPath + '/maps/config-test.js.map', {read: false, allowEmpty: true})
         .pipe(debug(debugOptions))
         .pipe(clean())
     )
diff --git a/www/js/config-test.js b/www/js/config-test.js
new file mode 100644
index 00000000..8576b66a
--- /dev/null
+++ b/www/js/config-test.js
@@ -0,0 +1,88 @@
+/******
+* !! WARNING: This is a generated file !!
+*
+* PLEASE DO NOT MODIFY DIRECTLY
+*
+* => Changes should be done on file 'app/config.json'.
+******/
+
+angular.module("cesium.config", [])
+
+.constant("csConfig", {
+	"cacheTimeMs": 300000,
+	"demo": false,
+	"readonly": false,
+	"fallbackLanguage": "en",
+	"rememberMe": true,
+	"showUDHistory": true,
+	"timeout": 30000,
+	"timeWarningExpireMembership": 5184000,
+	"timeWarningExpire": 7776000,
+	"minPeerCountAtStartup": 2,
+	"useLocalStorage": true,
+	"useRelative": false,
+	"expertMode": true,
+	"decimalCount": 2,
+	"httpsMode": false,
+	"shareBaseUrl": "https://g1-test.cesium.app",
+	"helptip": {
+		"enable": false,
+		"installDocUrl": {
+			"fr-FR": "https://duniter.fr/wiki/doc/installer/",
+			"en": "https://duniter.org/wiki/doc/install/"
+		}
+	},
+	"node": {
+		"host": "g1-test.duniter.org",
+		"port": 443
+	},
+	"fallbackNodes": [
+		{
+			"host": "gt.moul.re",
+			"port": 10902
+		},
+		{
+			"host": "g1-test.duniter.org",
+			"port": 443
+		}
+	],
+	"developers": [
+		{
+			"name": "Benoit Lavenier",
+			"pubkey": "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"
+		},
+		{
+			"name": "Cédric Moreau",
+			"pubkey": "2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ"
+		},
+		{
+			"name": "Kapis",
+			"pubkey": "24jaf8XhYZyDyUb7hMcy5qsanaHBC11AwPefcCQRBQNA"
+		},
+		{
+			"name": "Matograine",
+			"pubkey": "CmFKubyqbmJWbhyH2eEPVSSs4H4NeXGDfrETzEnRFtPd"
+		}
+	],
+	"plugins": {
+		"es": {
+			"enable": false,
+			"askEnable": false,
+			"useRemoteStorage": false,
+			"host": "g1-test.data.e-is.pro",
+			"port": 443,
+			"notifications": {
+				"txSent": true,
+				"txReceived": true,
+				"certSent": true,
+				"certReceived": true
+			},
+			"defaultCountry": "France"
+		}
+	},
+	"version": "1.7.7",
+	"build": "2023-08-17T13:11:36.358Z",
+	"newIssueUrl": "https://git.duniter.org/clients/cesium-grp/cesium/issues/new"
+})
+
+;
\ No newline at end of file
-- 
GitLab