From 744b04edc65f939ad874623044ae4ba445a4faf6 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Sun, 19 Dec 2021 13:06:41 -0800
Subject: [PATCH] add demos to deploy script

- include analytics in deployed demos
---
 scripts/deploy.js                      | 28 +++++++++++++++++++++-----
 src/examples/alpha-orbitals/index.html |  1 +
 src/examples/lighting/index.html       |  1 +
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/scripts/deploy.js b/scripts/deploy.js
index 5fde259a0..652a2abd7 100644
--- a/scripts/deploy.js
+++ b/scripts/deploy.js
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -39,6 +39,24 @@ function copyViewer() {
     addAnalytics(path.resolve(viewerDeployPath, 'index.html'));
 }
 
+function copyDemos() {
+    console.log('\n###', 'copy demos files');
+    const lightingBuildPath = path.resolve(buildDir, '../build/examples/lighting/');
+    const lightingDeployPath = path.resolve(localPath, 'demos/lighting/');
+    fse.copySync(lightingBuildPath, lightingDeployPath, { overwrite: true });
+    addAnalytics(path.resolve(lightingDeployPath, 'index.html'));
+
+    const orbitalsBuildPath = path.resolve(buildDir, '../build/examples/alpha-orbitals/');
+    const orbitalsDeployPath = path.resolve(localPath, 'demos/alpha-orbitals/');
+    fse.copySync(orbitalsBuildPath, orbitalsDeployPath, { overwrite: true });
+    addAnalytics(path.resolve(orbitalsDeployPath, 'index.html'));
+}
+
+function copyFiles() {
+    copyViewer();
+    copyDemos();
+}
+
 if (!fs.existsSync(localPath)) {
     console.log('\n###', 'create localPath');
     fs.mkdirSync(localPath, { recursive: true });
@@ -52,9 +70,9 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
         .outputHandler(log)
         .clone(remoteUrl, localPath)
         .fetch(['--all'])
-        .exec(copyViewer)
+        .exec(copyFiles)
         .add(['-A'])
-        .commit('updated viewer')
+        .commit('updated viewer & demos')
         .push();
 } else {
     console.log('\n###', 'update repository');
@@ -62,8 +80,8 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
         .outputHandler(log)
         .fetch(['--all'])
         .reset(['--hard', 'origin/master'])
-        .exec(copyViewer)
+        .exec(copyFiles)
         .add(['-A'])
-        .commit('updated viewer')
+        .commit('updated viewer & demos')
         .push();
 }
\ No newline at end of file
diff --git a/src/examples/alpha-orbitals/index.html b/src/examples/alpha-orbitals/index.html
index 57d0b90e0..ee7cb754b 100644
--- a/src/examples/alpha-orbitals/index.html
+++ b/src/examples/alpha-orbitals/index.html
@@ -57,5 +57,6 @@
         <script>
             AlphaOrbitalsExample.init('app')
         </script>
+        <!-- __MOLSTAR_ANALYTICS__ -->
     </body>
 </html>
\ No newline at end of file
diff --git a/src/examples/lighting/index.html b/src/examples/lighting/index.html
index 2be99e14e..c96606aa9 100644
--- a/src/examples/lighting/index.html
+++ b/src/examples/lighting/index.html
@@ -84,5 +84,6 @@
                 $('controls').appendChild(h);
             }
         </script>
+        <!-- __MOLSTAR_ANALYTICS__ -->
     </body>
 </html>
\ No newline at end of file
-- 
GitLab