From 3c46c6d95fb49a9e27aa0a756add6f9adf97c77a Mon Sep 17 00:00:00 2001
From: Benoit Rospars <benoit.rospars@inria.fr>
Date: Wed, 22 Feb 2023 10:23:39 +0100
Subject: [PATCH] Issue #74 : script to fetch preview files

---
 .gitignore   | 1 +
 README.md    | 7 ++++++-
 package.json | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 35da243e..a169ab3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ dist
 dist-ssr
 *.local
 dist_electron
+.env
 
 # Editor directories and files
 .vscode/*
diff --git a/README.md b/README.md
index b1a22ef0..8ebf4462 100644
--- a/README.md
+++ b/README.md
@@ -19,5 +19,10 @@ run run wdio
 
 # Run linter
 npm run lint
+```
 
-```
\ No newline at end of file
+### Setup preview
+
+1. Create a `.env` containing the Gitlab url and access token to fetch the preview files : `GITLAB_URL`, `GITLAB_TOKEN`
+2. Run `npm run updatePreview`
+3. Build or run the app in dev using above scripts
\ No newline at end of file
diff --git a/package.json b/package.json
index 6bcbc225..f7dc1567 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,8 @@
     "test": "vitest",
     "coverage": "vitest --coverage",
     "wdio": "wdio run ./wdio.conf.ts",
-    "lint": "npx eslint ./src ./test ./electron/* --ext .ts,.vue,.js"
+    "lint": "npx eslint ./src ./test ./electron/* --ext .ts,.vue,.js",
+    "updatePreview": "export $(grep -v '^#' .env | xargs) && curl --location --output public/preview.zip --header \"PRIVATE-TOKEN: $GITLAB_TOKEN\" $GITLAB_URL"
   },
   "dependencies": {
     "@vue-flow/additional-components": "^1.3.3",
-- 
GitLab