You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2019/07/24 13:44:20 UTC
[sling-whiteboard] 01/04: Improve install script
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 7a12dfebbbe01a8aeedc3a32ff37bbb33f55a3af
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Jul 24 14:05:34 2019 +0200
Improve install script
---
serverless-microsling/install | 21 +++++++++++++++------
serverless-microsling/microsling.js | 14 +++++++++++++-
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/serverless-microsling/install b/serverless-microsling/install
index a9ec57a..cc7a6ae 100755
--- a/serverless-microsling/install
+++ b/serverless-microsling/install
@@ -1,11 +1,20 @@
#!/bin/bash
-echo installing the microsling code using 'wsk'...
+function fatal() {
+ echo $* >&2
+ exit 1
+}
-# TODO check for npm install
+export ACTION=microsling
+export ZIP=openwhisk_action.zip
+export ACTION_FILES="package.json node_modules *.js foo"
-zip -r openwhisk_action.zip package.json node_modules *.js \
-&& wsk action update microsling openwhisk_action.zip \
---web true --kind nodejs:10
+[[ -d node_modules ]] || fatal "node_modules folder not found, please run 'npm install'"
-echo "Microsling is available at at $(wsk -i action get microsling --url | grep http)"
\ No newline at end of file
+echo Preparing $ZIP ... \
+&& zip -r $ZIP $ACTION_FILES > /dev/null \
+&& echo "$ZIP: $(du -h $ZIP | cut -f1)" \
+&& echo "Updating action '$ACTION...'" \
+&& wsk action update $ACTION $ZIP --web true --kind nodejs:10
+
+echo "Microsling is available at at $(wsk -i action get $ACTION --url | grep http)"
\ No newline at end of file
diff --git a/serverless-microsling/microsling.js b/serverless-microsling/microsling.js
index 2a3df46..c928a1f 100644
--- a/serverless-microsling/microsling.js
+++ b/serverless-microsling/microsling.js
@@ -1,7 +1,19 @@
function main (params) {
+ const result = {
+ body: `${params.__ow_path}`,
+ };
+
return new Promise(function (resolve, reject) {
- return resolve({ body:"Ce texte-ci\n"});
+ return resolve(result);
})
}
+if (require.main === module) {
+ const result = main({
+ __ow_path: process.argv[2],
+ __ow_method: 'get',
+ });
+ console.log(result);
+}
+
module.exports.main = main
\ No newline at end of file