OpenWhisk- How to upload package actions? - ibm-cloud

I am new to OpenWhisk. I am currently using AWS Lambda(node.js) to generate custom tokens. Lambda has an option to upload the Zip file as a package. Does OpenWhisk have a similar option? I couldn't find any doc related to such an option.

OpenWhisk now (24th October 2016) supports uploading a zip file with your Node.js source files and NPM modules to run as an Action.
This documentation page has details on how to use this feature.
$ wsk action create packageAction --kind nodejs:6 action.zip

Related

Use Artifactory Rest API to get most recent (non-maven) file

I'm trying to use the Artifactory Rest API to retrieve the latest published version of a file. The file in question is a simple zip of a bunch of YAML files used for configuration. I can upload and download these files in TeamCity using File Specs, however I can't find any reference of this functionality in the Rest API docs (or indeed, any way to do almost anything that isn't an action on a maven repository)
As you are already using the file specs, you can make use of the same file spec and use the Artifactory query language (AQL) to get the list of files. You can refer to example 2 here in this list.
You can define and use a custom Repository Layout. This way, in order to download the latest version of the file, you can use the [RELEASE] placeholder. The actual latest version will be automatically resolved by the extracted version value based on the layout.
See also:
How to create simple versioning custom layout in Artifactory
How to find the latest artifact version based on layout?

workspace.fs is not available in vscode API to read the file

I wanted to use vscode.workspace api to deal with file operations instead of node fs module as shown in the following Git Repo. But i am not able to access fs inside workspace.
You may need to run npm install #types/vscode to ensure you have the latest types for vscode. This resolved our problem when trying to use vscode.workspace.fs.

How do you use/reference libraries in IBM Bluemix OpenWhisk?

As of today, in the IBM Bluemix docs for the IBM Bluemix OpenWhisk service I could not find any clues as to how to use libraries.
How am I missing the obvious that all apps invariably require a library and therefore why isn't that at least mentioned in the OpenWhisk docs?
If libraries are called something else or the concept doesn't apply in the usual way (such as maybe Libraries need to be converted into "OpenWhisk Packages"?), the OpenWhisk docs should SAY SOMETHING about the word/term/concept "libraries".
You can use webpack to bundle all your dependencies and create the final .js file you'll use as your OpenWhisk action.
See this example:
These are all the actions before webpack build: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/tree/dev/actions
Invoking webpack: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/blob/dev/package.json webpack --config webpack.config.js
Here is another more simpler example: https://github.com/IBM-Bluemix/openwhisk-webpack
To cover another language for anyone who finds this question…
For Swift, OpenWhisk comes with the Kitura-net, SwiftyJSON & swift-watson-sdk packages (Swift term for libraries) built in.
If you want to include any other packages then you have to either build your own Docker container for your action or concatenate all the Swift source files that are in the packages together with your action file to create a single .swift file for upload with wsk action update. I've used cat to do this:
cat lib/Redis/Redis*.swift actions/_common.swift actions/counts.swift > build/counts.swift
which creates a single build/counts.swift containing Kitura-Redis, some common code and my counts action.

How to "pack" an Ember CLI component?

I'm using ember-cli and I made a custom component using ember-cli syntax & naming conventions. This is a highly reusable component and I'd like to know what is the better way to put it all into a "package" so it's easy to integrate into other projects.
My component use a .js file for the Ember.Component subclass along with a .hbs file for the template and yet another couple of .js files for the necessary Ember.View subclasses. Right now, every file is in its respective folder along with the files for the rest of my project.
How can I isolate the files related to the component and package them for reuse? In Ruby on Rails I use gems for this matter, and in jQuery I used to write plugins by extending $.fn in a single file.
Take advantage of Ember CLI addon system. It's been designed for cases like this one. The process should be easy if you are familiar with Ember CLI already. As Ember CLI addon system's been reworked in the recent past and it's API was changing it's possible that older articles or guides on this topic became out of sync.
The most comprehensive and kept in sync guide on this topic is kristianmandrup's gist Converting libraries to Ember CLI addons.
There is also an Addons tutorials section on the official Ember CLI site.

GoogleTV Closure Library Getting Started

I've been trying to figure out how to use the google closure library for d-pad navigation for my web app. I cannot for the life of me get closure to work. I'm following google's guide here https://developers.google.com/tv/web/lib/closure/gettingstarted
The guide asks to checkout from their SVN repo, but I'm just using the downloaded zip of the library from github. The guide asks to perform the following command
gtv-ui-lib/closure-library/closure/bin/build/depswriter.py \
--root_with_prefix="gtv-ui-lib/source ../../../../gtv-ui-lib/source" \
--output_file=tv-deps.js
to create a deps.js file. Can somebody explain to me how to execute this command? Is it supposed to be in a python command prompt or something else? When I copy and paste their exact html and javascript page code and use the premade deps.js file for the guide, my page doesn't function with keyboard navigation, so I'm assuming the deps.js file is my problem because everything else is exactly from the guide.
You will need to have python installed on your development machine and make sure that it is added to your path environment. The closure depswriter can be executed by using python from the command line (if you are using *nix then you can just invoke the file from the cli). Try:
python WHERE-YOU-UNZIPPED-THE-ZIP-PATH/gtv-ui-lib/closure-library/closure/bin/build/depswriter.py \
--root_with_prefix="gtv-ui-lib/source ../../../../gtv-ui-lib/source" \
--output_file=tv-deps.js
I would also recommend checking out the source from the SVN repo and not using the github zip file. The SVN repo is the most upto date and the github is a mirror that can sometimes fall behind. To ensure you have the latest version of the code do install the SVN tools and checkout from the specified repo.