bug fixes, updated templates, php support (#25) * bug fixes (it works again), php support, updated language templates for latest versions * added release notes, cleaned up repo
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 @@ .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 @@ Download and run the installer for your platform from the [Downloads Section](#downloads). -[](https://travis-ci.org/openwhisk/openwhisk-vscode) [](https://raw.githubusercontent.com/openwhisk/openwhisk-vscode/blob/master/LICENSE) +[](https://travis-ci.org/openwhisk/openwhisk-vscode) [](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 @@ 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 @@ //supported OpenWhisk file formats var NODE = 'JavaScript', NODE6 = 'JavaScript 6', + PHP = 'PHP', PYTHON = 'Python', SWIFT = 'Swift'; @@ -349,10 +350,24 @@ }; 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 @@ }; 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 @@ 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 @@ 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 @@ 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]; +}