You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/11/03 19:06:30 UTC

[GitHub] mrutkows closed pull request #25: bug fixes, updated templates, php support

mrutkows closed pull request #25: bug fixes, updated templates, php support
URL: https://github.com/apache/incubator-openwhisk-vscode/pull/25
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.gitignore b/.gitignore
index d6cee56..bc2fef9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 node_modules
 *.vsix
-out
\ No newline at end of file
+out
+package-lock.json
\ No newline at end of file
diff --git a/.vscodeignore b/.vscodeignore
index d726f57..2bd6dba 100644
--- a/.vscodeignore
+++ b/.vscodeignore
@@ -4,3 +4,4 @@ static-src/test/**
 .gitignore
 jsconfig.json
 vsc-extension-quickstart.md
+RELEASE-README.md
\ No newline at end of file
diff --git a/README.md b/README.md
index 7bc28aa..81c5331 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ This is a prototype extension for Visual Studio Code https://code.visualstudio.c
 
 Download and run the installer for your platform from the [Downloads Section](#downloads).
 
-[![Build Status](https://travis-ci.org/openwhisk/openwhisk-vscode.svg?branch=master)](https://travis-ci.org/openwhisk/openwhisk-vscode) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/openwhisk/openwhisk-vscode/blob/master/LICENSE)
+[![Build Status](https://travis-ci.org/openwhisk/openwhisk-vscode.svg?branch=master)](https://travis-ci.org/openwhisk/openwhisk-vscode) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/openwhisk/openwhisk-vscode/blob/master/LICENSE)
 
 Preview of VS Code OpenWhisk extension here:
 
diff --git a/RELEASE-README.md b/RELEASE-README.md
new file mode 100644
index 0000000..589c6f3
--- /dev/null
+++ b/RELEASE-README.md
@@ -0,0 +1,18 @@
+# Packaging the VSCode extension for release
+
+All based on information here: https://code.visualstudio.com/docs/extensions/publish-extension
+
+## Packaging a VS Code extension for local distribution.
+
+1. cd into the project root directory (this is the one that contains `package.json`)
+2. Update the `version` value in `package.json` (this can be manual or using `npm version`)
+3. Run the command `vsce package` - this compiles the .vsix file for release, which can be installed into vscode.  This file can be uploaded into the "Releases" section on github
+
+----
+
+## Packaging for remote distribution in windows marketplace:
+
+1. cd into the project root directory (this is the one that contains `package.json`)
+2. Update the `version` value in `package.json` (this can be manual or using `npm version`)
+3. Run the command `vsce publish` - This compiles the extension and publishes to the windows marketplace in one step. ***This requires an account with sufficient priveleges
+
diff --git a/package.json b/package.json
index aa1f979..847d942 100644
--- a/package.json
+++ b/package.json
@@ -1,198 +1,223 @@
 {
-  "name": "openwhisk",
-  "displayName": "OpenWhisk",
-  "description": "A VSCode extension for OpenWhisk",
-  "version": "0.0.5",
-  "publisher": "IBM",
-  "engines": {
-    "vscode": "^0.10.10"
-  },
-  "categories": [
-    "Languages",
-    "Other"
-  ],
-  "activationEvents": [
-    "*"
-  ],
-  "repository": {
-    "type": "git",
-    "url": "https://github.com/openwhisk/openwhisk-vscode.git"
-  },
-  "author": {
-    "name": "Andrew Trice",
-    "email": "amtrice@us.ibm.com"
-  },
-  "contributors": [
-    {
-      "name": "Jeff Sloyer",
-      "email": "jbsloyer@us.ibm.com"
-    }
-  ],
-  "icon": "github-assets/logo.png",
-  "galleryBanner": {
-    "color": "#CFB69A",
-    "theme": "light"
-  },
-  "main": "./static-src/extension",
-  "contributes": {
-		"commands": [{
+	"name": "openwhisk",
+	"displayName": "OpenWhisk",
+	"description": "A VSCode extension for OpenWhisk",
+	"version": "0.0.6",
+	"publisher": "IBM",
+	"engines": {
+		"vscode": "^0.10.10"
+	},
+	"categories": [
+		"Languages",
+		"Other"
+	],
+	"activationEvents": [
+		"*"
+	],
+	"repository": {
+		"type": "git",
+		"url": "https://github.com/openwhisk/openwhisk-vscode.git"
+	},
+	"author": {
+		"name": "Andrew Trice",
+		"email": "amtrice@us.ibm.com"
+	},
+	"contributors": [
+		{
+			"name": "Jeff Sloyer",
+			"email": "jbsloyer@us.ibm.com"
+		}
+	],
+	"icon": "github-assets/logo.png",
+	"galleryBanner": {
+		"color": "#CFB69A",
+		"theme": "light"
+	},
+	"main": "./static-src/extension",
+	"contributes": {
+		"commands": [
+			{
 				"command": "extension.wsk.list",
 				"title": "wsk list"
-			}, {
+			},
+			{
 				"command": "extension.wsk.help",
 				"title": "wsk"
-			}, {
+			},
+			{
 				"command": "extension.wsk.help",
 				"title": "wsk help"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action",
 				"title": "wsk action"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.list",
 				"title": "wsk action list"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.invoke",
 				"title": "wsk action invoke"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.debug",
 				"title": "wsk action debug"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.create",
 				"title": "wsk action create"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.sequence.create",
 				"title": "wsk sequence create"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.update",
 				"title": "wsk action update"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.delete",
 				"title": "wsk action delete"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.get",
 				"title": "wsk action get"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.init",
 				"title": "wsk action init"
-			}, {
+			},
+			{
 				"command": "extension.wsk.action.rest",
 				"title": "wsk action REST"
 			},
-
-
 			{
 				"command": "extension.wsk.util.bluemix",
 				"title": "wsk bluemix"
-			}, {
+			},
+			{
 				"command": "extension.wsk.util.docs",
 				"title": "wsk docs"
 			},
-
-
 			{
 				"command": "extension.wsk.property.get",
 				"title": "wsk property get"
-			}, {
+			},
+			{
 				"command": "extension.wsk.property.set",
 				"title": "wsk property set"
-			}, {
+			},
+			{
 				"command": "extension.wsk.property.unset",
 				"title": "wsk property unset"
 			},
-
-
 			{
 				"command": "extension.wsk.trigger",
 				"title": "wsk trigger"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.list",
 				"title": "wsk trigger list"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.create",
 				"title": "wsk trigger create"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.update",
 				"title": "wsk trigger update"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.delete",
 				"title": "wsk trigger delete"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.get",
 				"title": "wsk trigger get"
-			}, {
+			},
+			{
 				"command": "extension.wsk.trigger.fire",
 				"title": "wsk trigger fire"
 			},
-
-
 			{
 				"command": "extension.wsk.rule",
 				"title": "wsk rule"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.list",
 				"title": "wsk rule list"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.create",
 				"title": "wsk rule create"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.update",
 				"title": "wsk rule update"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.delete",
 				"title": "wsk rule delete"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.enable",
 				"title": "wsk rule enable"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.disable",
 				"title": "wsk rule disable"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.status",
 				"title": "wsk rule status"
-			}, {
+			},
+			{
 				"command": "extension.wsk.rule.get",
 				"title": "wsk rule get"
 			},
-
-
 			{
 				"command": "extension.wsk.activation",
 				"title": "wsk activation"
-			}, {
+			},
+			{
 				"command": "extension.wsk.activation.list",
 				"title": "wsk activation list"
-			}, {
+			},
+			{
 				"command": "extension.wsk.activation.get",
 				"title": "wsk activation get"
-			}, {
+			},
+			{
 				"command": "extension.wsk.activation.logs",
 				"title": "wsk activation logs"
-			}, {
+			},
+			{
 				"command": "extension.wsk.activation.result",
 				"title": "wsk activation result"
 			}
 		]
 	},
-  "scripts": {
-    "postinstall": "rm -rf ./node_modules/openwhisk/test/"
-  },
-  "devDependencies": {
-    "gulp": "^3.9.1",
-    "gulp-vinyl-zip": "^1.2.2",
-    "vscode": "^0.11.0"
-  },
-  "dependencies": {
-    "open": "0.0.5",
-    "openwhisk": "https://github.com/triceam/openwhisk-client-js/tarball/master",
-    "request-promise": "^3.0.0"
-  },
-  "keywords": [
-    "IBM",
-    "openwhisk"
-  ],
-  "bugs": {
-    "url": "https://github.com/openwhisk/openwhisk-vscode/issues"
-  },
-  "license": "MIT",
-  "homepage": "https://github.com/openwhisk/openwhisk-vscode/blob/master/README.md"
+	"scripts": {
+		"postinstall": "rm -rf ./node_modules/openwhisk/test/"
+	},
+	"devDependencies": {
+		"gulp": "^3.9.1",
+		"gulp-vinyl-zip": "^1.2.2",
+		"vscode": "^0.11.0"
+	},
+	"dependencies": {
+		"open": "0.0.5",
+		"openwhisk": "https://github.com/triceam/openwhisk-client-js/tarball/master",
+		"request-promise": "^3.0.0"
+	},
+	"keywords": [
+		"IBM",
+		"openwhisk"
+	],
+	"bugs": {
+		"url": "https://github.com/openwhisk/openwhisk-vscode/issues"
+	},
+	"license": "MIT",
+	"homepage": "https://github.com/openwhisk/openwhisk-vscode/blob/master/README.md"
 }
diff --git a/static-src/commands/util.js b/static-src/commands/util.js
index 8dd0480..44b5402 100644
--- a/static-src/commands/util.js
+++ b/static-src/commands/util.js
@@ -92,6 +92,9 @@ function printOpenWhiskError(error) {
             log.appendLine(error.error.logs[x]);
         }
     }
+    else if (error.error.error) {
+        log.appendLine(error.error.error);
+    }
 }
 
 function parseParametersString(parameterString) {
diff --git a/static-src/commands/wsk.action.js b/static-src/commands/wsk.action.js
index f680046..1d9ecdc 100644
--- a/static-src/commands/wsk.action.js
+++ b/static-src/commands/wsk.action.js
@@ -35,6 +35,7 @@ var context
 //supported OpenWhisk file formats
 var NODE = 'JavaScript',
     NODE6 = 'JavaScript 6',
+    PHP = 'PHP',
     PYTHON = 'Python',
     SWIFT = 'Swift';
 
@@ -349,10 +350,24 @@ function createAction(params) {
         };
 
         var swiftExt = '.swift';
+        var pyExt = '.py';
+        var phpExt = '.php';
         var lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(swiftExt);
         if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - swiftExt.length) {
-            //it's a swift file, handle it differently
             options.action = { exec: { kind: 'swift:3', code: options.action }}
+        } else {
+
+            lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(pyExt);
+            if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - pyExt.length) {
+                options.action = { exec: { kind: 'python:3', code: options.action }}
+            }else {
+                lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(phpExt);
+                if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - phpExt.length) {
+                    options.action = { exec: { kind: 'php:7.1', code: options.action }}
+                }else {
+                    options.action = { exec: { kind: 'nodejs:6', code: options.action }}
+                }
+            }
         }
 
         ow.actions.create(options)
@@ -408,10 +423,24 @@ function updateAction(params) {
                 };
 
                 var swiftExt = '.swift';
+                var pyExt = '.py';
+                var phpExt = '.php';
                 var lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(swiftExt);
                 if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - swiftExt.length) {
-                    //it's a swift file, handle it differently
                     options.action = { exec: { kind: 'swift:3', code: options.action }}
+                } else {
+
+                    lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(pyExt);
+                    if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - pyExt.length) {
+                        options.action = { exec: { kind: 'python:3', code: options.action }}
+                    }else {
+                        lastIndex = vscode.window.activeTextEditor.document.uri.fsPath.lastIndexOf(phpExt);
+                        if (lastIndex == vscode.window.activeTextEditor.document.uri.fsPath.length - phpExt.length) {
+                            options.action = { exec: { kind: 'php:7.1', code: options.action }}
+                        }else {
+                            options.action = { exec: { kind: 'nodejs:6', code: options.action }}
+                        }
+                    }
                 }
 
                 ow.actions.update(options)
@@ -476,7 +505,7 @@ function createSequenceAction(params) {
 
                             var options = {
                                 actionName: action,
-                                action: { exec: { kind: 'nodejs', code: pipeCode },
+                                action: { exec: { kind: 'nodejs:6', code: pipeCode },
                                 parameters:[{
                                         'key': '_actions',
                                         'value': sequenceActions
@@ -674,7 +703,7 @@ function initAction(params) {
         return;
     }
 
-    vscode.window.showQuickPick( [NODE, PYTHON, SWIFT], {placeHolder:'Select the type of action:'}).then( function (action) {
+    vscode.window.showQuickPick( [NODE, PHP, PYTHON, SWIFT], {placeHolder:'Select the type of action:'}).then( function (action) {
 
         if (action == undefined) {
             return;
@@ -707,6 +736,8 @@ function initAction(params) {
             var fileExt = '';
             if (action == NODE || action == NODE6) {
                 fileExt += '.js'
+            } else if (action == PHP) {
+                fileExt += '.php'
             } else if (action == PYTHON) {
                 fileExt += '.py'
             } else {
diff --git a/static-src/templates/javascript.template b/static-src/templates/javascript.template
index fff1cb3..b215cff 100644
--- a/static-src/templates/javascript.template
+++ b/static-src/templates/javascript.template
@@ -1,26 +1,12 @@
 /**
   *
-  * main() will be invoked when you Run This Action.
-  * 
-  * @param Whisk actions accept a single parameter,
-  *        which must be a JSON object.
+  * main() will be invoked when you Run This Action
   *
-  * In this case, the params variable will look like:
-  *     { "message": "xxxx" }
+  * @param Cloud Functions actions accept a single parameter, which must be a JSON object.
   *
-  * @return The return value must also be JSON.
-  *         It will be the output of this action.
-  *         You can also return whisk.asyn(), and 
-  *         later call whisk.done() for asynchronus operations
+  * @return The output of this action, which must be a JSON object.
   *
   */
-
-var request = require('request');
-
-function main(args) {
-    var url = 'https://httpbin.org/get';
-    request.get(url, function(error, response, body) {
-        whisk.done({response: body});
-    });
-    return whisk.async();
-}
\ No newline at end of file
+function main(params) {
+	return { message: 'Hello World' };
+}
diff --git a/static-src/templates/javascript6.template b/static-src/templates/javascript6.template
index fff1cb3..b215cff 100644
--- a/static-src/templates/javascript6.template
+++ b/static-src/templates/javascript6.template
@@ -1,26 +1,12 @@
 /**
   *
-  * main() will be invoked when you Run This Action.
-  * 
-  * @param Whisk actions accept a single parameter,
-  *        which must be a JSON object.
+  * main() will be invoked when you Run This Action
   *
-  * In this case, the params variable will look like:
-  *     { "message": "xxxx" }
+  * @param Cloud Functions actions accept a single parameter, which must be a JSON object.
   *
-  * @return The return value must also be JSON.
-  *         It will be the output of this action.
-  *         You can also return whisk.asyn(), and 
-  *         later call whisk.done() for asynchronus operations
+  * @return The output of this action, which must be a JSON object.
   *
   */
-
-var request = require('request');
-
-function main(args) {
-    var url = 'https://httpbin.org/get';
-    request.get(url, function(error, response, body) {
-        whisk.done({response: body});
-    });
-    return whisk.async();
-}
\ No newline at end of file
+function main(params) {
+	return { message: 'Hello World' };
+}
diff --git a/static-src/templates/php.template b/static-src/templates/php.template
new file mode 100644
index 0000000..dfeaccb
--- /dev/null
+++ b/static-src/templates/php.template
@@ -0,0 +1,17 @@
+<?php
+/**
+  *
+  * main() will be invoked when you Run This Action
+  *
+  * @param Cloud Functions actions accept a single parameter, which must be a JSON object.
+  *
+  * @return The output of this action, which must be a JSON object.
+  *
+  */
+function main(array $args) : array
+{
+    $name = $args["message"] ?? "stranger";
+    $greeting = "Hello $name!";
+    echo $greeting;
+    return ["greeting" => $greeting];
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services