Skip to content

Plugin package file structure

1000TurquoisePogs edited this page Aug 3, 2020 · 5 revisions

A Zowe plugin can be loaded from a filesystem accessible to the Zowe App Server, or dynamically at runtime. When accessed from a filesystem, there are important considerations for both the developer and the end-user as to where files must be placed for proper build, packaging, and operation.

Root files & directories

At the root of an plugin's directory, the following content is found

pluginDefinition.json

This file describes a Plugin to the App server. A Plugin is the unit of extensibility for the App server, where an App is a Plugin of type Application, the most common and visible to the end-user. A definition file will tell the server whether the App has server-side Dataservices, client-side web content, or both. The attributes of this file and how it is found by the server are described in the Plugin Definition article.

Dev & Source content

Standardized structure of source code is not required for Zowe plugins, but can help you make use of Zowe development utilities, and aid with demonstration or documentation.
The following directories should not be seen on a deployed server, since the directories are not read by the server but are used to build content that is.

nodeServer

When an plugin has Dataservices of the type "router", these are interpreted by the App Server by attaching them as ExpressJS routers. It is strongly suggested that these be written in Typescript, as it leads to more well-structured code than Javascript. Use of Typescript results in build steps as the pre-transpilation Typescript content is not to be consumed by NodeJS. Therefore, within nodeServer, you should keep your server-side source code. At runtime, the server loads router dataservices from the lib directory.

webClient

When an plugin has the webContent attribute in its Definition, it is an App and the server will serve static content for a client. It is strongly suggested that Apps be written in Typescript (above) and packaged via Webpack in order to optimize loading of the App to the user. Use of Typescript and Webpack both result in build steps as the pre-transpilation Typescript and the pre-webpack content are not to be consumed by the browser. Therefore, the source code should be separated from the served content by placing source code within webClient.

Runtime content

At runtime, a different set of directories are used by the server & client rather than those described for use in the dev environment.

lib

The lib directory is where router or service-type Dataservices are loaded by use in the App Server. If the JS files that are loaded from the lib directory require NodeJS modules which are not provided by the server base (modules zlux-server-framework requires are added to NODE_PATH at runtime), then these modules must either be included in lib/node_modules for local directory lookup or be found on the NODE_PATH environment variable. nodeServer/node_modules is not automatically accessed at runtime as it is a dev & build directory.

web

The web directory is where the server will serve static content for an App that has included the webContent attribute in its Definition. Typically this directory contains the output of a webpack build. Anything put in this folder can be accessed by a client, so only put content here that is intended to be consumed by clients.

Default user configuration

Configuration Dataservice default settings for users can be packaged within a plugin.
This is done by putting content within the /config/storageDefaults folder, and more on that subject can be found here

App-to-App Communication

App-to-App communication behaviors can be statically defined or dynamically created at runtime. Static definitions help as a form of documentation and to be able to depend upon them, so it is recommended that these be packaged with a plugin if you wish other's to be able to use App-to-App communication on your App.
This page describes the subject in more detail.
In summary, App-to-App Actions and Recognizers can be stored within an App's /config/actions and /config/recognizers folders, respectively, where the filenames much match the identifiers of Apps.

Documentation

In order for Zowe servers to pick up documentation to present to UIs, they must be in a uniform place.

The /doc folder of any Plugin can contain at its root any READMEs or documents that an administrator or developer may care about when working with a Plugin for the first time.

The /doc/swagger folder on the other hand, will be used to store .yaml extension Swagger 2.0 files that document the APIs of a Plugin's dataservices if they exist.

Other folders may exist, such as /doc/ui to document help behavior that may be shown in a UI, but is not implemented at this time.