### Build and Install Project (npm) Source: https://github.com/zowe/zowe-cli/blob/master/prototypes/configBuilder/Readme.md Performs a full project installation and build after moving files and installing dependencies. This ensures the project is up-to-date and ready for development or testing. ```bash npm install npm run build ``` -------------------------------- ### Plugin Configuration File Example Source: https://github.com/zowe/zowe-cli/blob/master/docs/CLI_Architecture_outdated.md An example of the '_plugins.json' file used to track installed plugins. This file stores a simple key-value pair where the key is the plugin name and the value indicates if it's enabled (true). ```json { "hypernova": true } ``` -------------------------------- ### Manage TSO Address Space: Start, Ping, Stop using Zowe CLI SDK Source: https://github.com/zowe/zowe-cli/blob/master/packages/zostso/README.md This example demonstrates the lifecycle management of a TSO address space, including starting, pinging for status, and stopping it. It uses the @zowe/imperative and @zowe/zos-tso-for-zowe-sdk packages to establish a z/OSMF session and interact with the TSO service. The process requires a z/OSMF profile and an account number. The example logs the success or failure of each operation and attempts a final ping to confirm the address space has stopped. ```typescript import { ProfileInfo } from "@zowe/imperative"; import { PingTso, StartTso, StopTso } from "@zowe/zos-tso-for-zowe-sdk"; (async () => { // Load connection info from default z/OSMF profile const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf"); const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true }); const session = ProfileInfo.createSession(zosmfMergedArgs.knownArgs); const accountNumber = "ACCT#"; const startResponse = await StartTso.start(session, accountNumber, { codePage: "285" }); const servletKey = startResponse.servletKey; if (startResponse.success) { console.log(`[${servletKey}] Started`); } else { throw new Error("Failed to start TSO address space"); } const pingResponse = await PingTso.ping(session, servletKey); if (pingResponse.success) { console.log(`[${servletKey}] Ping succeeded`); } else { throw new Error("Failed to ping TSO address space"); } const stopResponse = await StopTso.stop(session, servletKey); if (stopResponse.success) { console.log(`[${servletKey}] Stopped`); } else { throw new Error("Failed to stop TSO address space"); } try { await PingTso.ping(session, servletKey); } catch { console.log(`[${servletKey}] Ping failed`); } })().catch((err) => { console.error(err); process.exit(1); }); ``` -------------------------------- ### Build and Install Sample CLI Tool (Node.js) Source: https://github.com/zowe/zowe-cli/blob/master/packages/imperative/README.md Builds and installs sample CLI tools used for integration testing within the Imperative CLI Framework. This process involves executing a JavaScript script with specific commands. ```javascript node scripts/sampleCliTool.js build node scripts/sampleCliTool.js install ``` -------------------------------- ### REST Client GET Example Source: https://github.com/zowe/zowe-cli/wiki/Consuming-REST-APIs-using-the-REST-client Demonstrates how to use the RestClient.getExpectString method to fetch string content from a public API using a session. ```APIDOC ## GET /users ### Description Fetches string content from the `/users` endpoint of a public API. ### Method GET ### Endpoint `/users` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { Session, RestClient } from "@zowe/imperative"; // define "session" (e.g. how to connect) for non-authenticated endpoint const session = new Session({ hostname: "jsonplaceholder.typicode.com" }); // REST GET - call "/users" URI / endpoint - on fulfilled, "users" will contain text user response const users = await RestClient.getExpectString(session, "/users"); ``` ### Response #### Success Response (200) - **users** (string) - The text response from the API. #### Response Example ```json [ { "id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz", "address": { "street": "Kulas Light", "suite": "Apt. 556", "city": "Gwenborough", "zipcode": "92998-3874", "geo": { "lat": "-37.3159", "lng": "81.1496" } }, "phone": "1-770-736-8031 x56442", "website": "hildegard.org", "company": { "name": "Romaguera-Crona", "catchPhrase": "Multi-layered client-server neural-net", "bs": "harness real-time e-markets" } } ] ``` ``` -------------------------------- ### Sample TypeScript Plug-in Handler for Imperative CLI Source: https://github.com/zowe/zowe-cli/wiki/Developing-plugins Illustrates a basic plug-in handler written in TypeScript for the Imperative CLI Framework. This example demonstrates how to implement the `process` method to handle command execution, log messages, and write output to the response. ```typescript import {ICommandHandler, IHandlerParameters} from "@brightside/imperative"; export default class FooHandler implements ICommandHandler { public async process(params: IHandlerParameters): Promise { // Insert handler code // Example: // Write to log file, add a response output, build response params.response.log.debug("Invoked sample-plugin foo handler"); params.response.writeMessage("You have executed the Foo command!"); params.response.build(); } } ``` -------------------------------- ### Install Imperative CLI Framework (npm) Source: https://github.com/zowe/zowe-cli/blob/master/packages/imperative/README.md Installs the Imperative CLI Framework using npm. Supports installing the latest version or a specific Long Term Support (LTS) version. Be aware that `@latest` may include breaking changes. ```bash npm install @zowe/imperative ``` ```bash npm install @zowe/imperative@zowe-v2-lts ``` -------------------------------- ### Install Zowe CLI from Source (npm) Source: https://github.com/zowe/zowe-cli/blob/master/packages/cli/README.md Installs Zowe CLI globally from source after building. May require `sudo` on Linux/Mac or repeated attempts on Windows due to potential `EPERM` errors. ```bash npm install -g ``` -------------------------------- ### Install Zowe CLI Globally Source: https://context7.com/zowe/zowe-cli/llms.txt Installs the Zowe CLI from the npm registry globally. Requires Node.js and Cargo. Also includes steps to verify the installation and build from source. ```bash # Install from npm registry npm install -g @zowe/cli@latest # Verify installation zowe --version # Build from source git clone https://github.com/zowe/zowe-cli.git cd zowe-cli npm install npm run build cd packages/cli && npm install -g ``` -------------------------------- ### Install Zowe CLI Plugin Source: https://github.com/zowe/zowe-cli/wiki/Working-with-Team-Configuration Installs a specified Zowe CLI plugin globally. Replace '' with the actual name of the plugin you wish to install. Plugins extend Zowe CLI's capabilities. ```bash zowe plugins install @zowe/ ``` -------------------------------- ### Build Imperative CLI Framework from Source (npm) Source: https://github.com/zowe/zowe-cli/blob/master/packages/imperative/README.md Builds and installs the Imperative CLI Framework from its source code. This involves cloning the repository, installing dependencies, and running build scripts. It also includes options to build only the core packages or the entire project with test CLIs. ```bash npm install npm run build npm run test ``` ```bash npm run build:packages ``` -------------------------------- ### Example 'authOrder' Property in Profile Source: https://github.com/zowe/zowe-cli/blob/master/docs/Design_for_selecting_auth_type.md An example of how to specify the 'authOrder' property within a profile's 'properties' object. This defines the precedence of authentication methods for a REST connection. ```json { "properties": { "host": ... , "port": ... , "rejectUnauthorized": ... , "authOrder": "basic, token, cert-pem" } } ``` -------------------------------- ### Install Zowe CLI Globally (Mac/Linux) Source: https://github.com/zowe/zowe-cli/blob/master/README.md Provides the command to install the Zowe CLI globally as a root user on Mac or Linux systems. This allows all users to access the CLI without individual installations, but has implications for plugin access and potential npm errors. ```bash npm i -g @zowe/cli@latest --ignore-scripts ``` -------------------------------- ### Install Zowe CLI Dependencies and Development Tools (npm) Source: https://github.com/zowe/zowe-cli/blob/master/packages/cli/README.md Installs the necessary dependencies and development tools for Zowe CLI when first cloning from the GitHub repository. Requires NPM version 8 or newer. ```bash npm install ``` -------------------------------- ### Logging using the Logging API Source: https://github.com/zowe/zowe-cli/wiki/Configuring-Logging Examples demonstrating how to use the Zowe CLI logging API to log messages to different destinations. ```APIDOC ## Logging using the Logging API ### Log to an isolated application log file ```typescript import { Logger } from "@zowe/imperative"; const appLogger = Logger.getAppLogger(); appLogger.debug("My debug data"); ``` ### Log to an Imperative CLI Framework log file ```typescript import { Logger } from "@zowe/imperative"; const imperativeLogger = Logger.getImperativeLogger(); imperativeLogger.debug("My debug data"); ``` ### Log to a console **Important!**: Use console logging for debugging purposes only. Remove it after diagnosing the problem to avoid interleaving with JSON output. ```typescript import { Logger } from "@zowe/imperative"; const consoleLogger = Logger.getConsoleLogger(); consoleLogger.debug("My debug data"); ``` ``` -------------------------------- ### Check Prerequisites for System Tests (Bash) Source: https://github.com/zowe/zowe-cli/blob/master/README.md Lists the commands to verify the installation and accessibility of essential tools required for running Zowe CLI system tests. This includes checking Node.js, npm, and the bash shell. ```bash 1. `node --version` 2. `npm --version` 3. On Windows: `where sh` ``` -------------------------------- ### Install Terminal-Kit Dependency (npm) Source: https://github.com/zowe/zowe-cli/blob/master/prototypes/configBuilder/Readme.md Installs the 'terminal-kit' package and its development types using npm. This is essential for terminal UI functionalities within the CLI. ```bash npm install terminal-kit && npm install -D @types/terminal-kit ``` -------------------------------- ### Test Environment Setup and Cleanup in TypeScript Source: https://github.com/zowe/zowe-cli/blob/master/docs/TESTING.md Demonstrates how to use `TestEnvironment.setUp` to create a temporary environment for Zowe CLI system tests, including profile creation and accessing test properties. It also shows the necessary `TestEnvironment.cleanUp` call in an `afterAll` block to remove temporary profiles. ```typescript beforeAll(async () => { TEST_ENVIRONMENT = await TestEnvironment.setUp({ testName: "zos_jobs_submit_command", tempProfileTypes: ["zosmf"] }); // you can access test properties on the TEST_ENVIRONMENT object psJclDataSet = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14PSDataSet; // you could also set environmental variables or use in running cli scripts // for example TEST_ENVIRONMENT.env.some_key = some_value; // Retrieve properties from the profile const systemProps: TestProperties = new TestProperties(TEST_ENVIRONMENT.systemTestProperties); const defaultSystem: ITestSystemSchema = systemProps.getDefaultSystem(); // the zosmf profile is stored in defaultSystem.zosmf }); afterAll(async () => { // delete any profiles that have been created await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); ``` -------------------------------- ### Create Zosmf Profile Help (zowe cli) Source: https://github.com/zowe/zowe-cli/blob/master/packages/cli/README.md Displays help information for creating a z/OSMF profile, which is essential for Zowe CLI to communicate with mainframe systems. ```bash zowe profiles create zosmf-profile --help ``` -------------------------------- ### Install Zowe CLI Autocompletion for Bash (macOS) Source: https://github.com/zowe/zowe-cli/blob/master/autocompletion/README.md Installs Zowe autocompletion for Bash on macOS. This involves enabling bash completion if not already active, copying the script to the appropriate system directory, and starting a new bash terminal. Execute privileges are not required for files in this directory. ```shell cp zowe.bash /usr/local/etc/bash_completion.d/zowe.bash ``` -------------------------------- ### Efficient Zowe CLI Configuration with Base Profiles Source: https://github.com/zowe/zowe-cli/wiki/Working-with-Team-Configuration Demonstrates an efficient way to manage Zowe CLI configurations by utilizing base profiles. This example defines a 'my_base' profile that holds common secure properties like 'user' and 'password'. Other service profiles ('lpar1', 'lpar2') can then inherit these properties, reducing duplication and simplifying maintenance. ```json { "$schema": "./zowe.schema.json", "profiles": { "lpar1": { "properties": { "host": "example1.com" }, "profiles": { "zosmf": { "type": "zosmf", "properties": { "port": 443 } } } }, "lpar2": { "properties": { "host": "example2.com" }, "profiles": { "zosmf": { "type": "zosmf", "properties": { "port": 444 } } } }, "my_base": { "type": "base", "properties": { "rejectUnauthorized": true }, "secure": [ "user", "password" ] } }, "defaults": { "zosmf": "lpar1.zosmf", "base": "my_base" }, "plugins": [] } ``` -------------------------------- ### Accessing Zowe CLI Imperative API Source: https://github.com/zowe/zowe-cli/blob/master/docs/CLI_Architecture_outdated.md Demonstrates how to import and access the Imperative API object after initializing it with `Imperative.init()`. This example shows how to get the `appLogger` instance and use its `debug` method. ```typescript import { Imperative } from "imperative" const appLogger = Imperative.api.appLogger; appLogger.debug("My debug data"); ``` -------------------------------- ### Initialize Plugins in PMF (TypeScript) Source: https://github.com/zowe/zowe-cli/blob/master/docs/Plugin Architecture/Plugin Development.md Illustrates the process of initializing plugins within the Zowe CLI Plugin Management Framework (PMF). It shows how to read the installed plugins configuration and iterate through them. ```TypeScript export class PMF { static init() { // Initialize PMF // ... PMF.initPlugins(); } static initPlugins(): void { // Provide mechanism to read this from the home location const installedPlugins: PluginConfig = readFile('path/to/config/file'); for (const installedPlugin in installedPlugins) { // Talk about this section later. } } } ``` -------------------------------- ### List Provisioned Instances and Perform Action (TypeScript) Source: https://github.com/zowe/zowe-cli/blob/master/packages/provisioning/README.md Lists provisioned instances from the registry and performs a specified action on a matching instance. It filters instances by name and retrieves the instance ID to execute the action. ```typescript import { ProfileInfo, TextUtils } from "@zowe/imperative"; import { explainActionResponse, IProvisionedInstance, ListRegistryInstances, PerformAction, ProvisioningConstants } from "@zowe/provisioning-for-zowe-sdk"; (async () => { // Load connection info from default z/OSMF profile const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf"); const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true }); const session = ProfileInfo.createSession(zosmfMergedArgs.knownArgs); const instanceName = "myInstance"; const actionName = "myAction"; const registry = await ListRegistryInstances.listFilteredRegistry(session, ProvisioningConstants.ZOSMF_VERSION, null, instanceName); const instances: IProvisionedInstance[] = registry["scr-list"]; if (instances == null) { console.error("No instance with name " + instanceName + " was found"); } else if (instances.length === 1) { const id = instances.pop()["object-id"]; const response = await PerformAction.doProvisioningActionCommon(session, ProvisioningConstants.ZOSMF_VERSION, id, actionName); const pretty = TextUtils.explainObject(response, explainActionResponse, false); console.log(TextUtils.prettyJson(pretty)); } else if (instances.length > 1) { console.error("Multiple instances with name " + instanceName + " were found"); } })().catch((err) => { console.error(err); process.exit(1); }); ``` -------------------------------- ### Keyring Credential Management Operations Source: https://github.com/zowe/zowe-cli/blob/master/packages/secrets/src/keyring/EXTENDERS.md Provides examples of common credential management operations using the `keyring` module, including setting, getting, finding, and deleting passwords. These operations are designed to be compatible with `node-keytar`. ```typescript // Set a password with a given service and account name // Password will be stored under / await keyring.setPassword("TestService", "AccountA", "Apassword"); ``` ```typescript // Get a password, given a service and account name await keyring.getPassword("TestService", "AccountA"); ``` ```typescript // Find credentials based on a matching label await keyring.findCredentials("TestService"); ``` ```typescript // Find password that matches a service and account await keyring.findPassword("TestService/AccountA"); ``` ```typescript // Delete a credential w/ the provided service and account name await keyring.deletePassword("TestService", "AccountA"); ``` -------------------------------- ### Initialize Plugins in Zowe CLI Source: https://github.com/zowe/zowe-cli/blob/master/docs/Plugin Architecture/Plugin Development.md This TypeScript code demonstrates how the Zowe CLI's Plugin Management Framework (PMF) loads, instantiates, and initializes installed plugins. It reads plugin configurations from a JSON file, requires each plugin module, instantiates its main class, and calls its initialization method to add definitions to the CLI. Error handling for plugin loading is recommended. ```typescript import { addDefinition } from 'imperative'; export class PMF { // ... static initPlugins(): void { // Provide mechanism to read this from the home location const installedPlugins: PluginConfig = readFile('path/to/config/file'); for (const installedPlugin in installedPlugins) { // This works because plugins are installed to node_modules via npm install and // if you remember correctly, the key in PluginConfig is the name of the plugin // in node modules. const pluginModule: PluginRequire = require(installedPlugin); // Now because of typings defined in PluginRequire we know that a main class // exists inside of the require. This is why plugins have to export a class // called main. The new keyword can be used on this because of the typing // provided by the PluginConstructor. const plugin = new pluginModule.Main(); // Recall that plugin.init returns a definition that can be used to add groups // to the cli. The addDefinition function is something that we need to implement // as part of the plugin effort. addDefinition(plugin.init()); } } } ``` -------------------------------- ### Install Zowe CLI V2 LTS Plugin Source: https://github.com/zowe/zowe-cli/blob/master/docs/Using Team Configuration.md Installs a specific Zowe CLI V2 LTS plugin. Replace '' with the actual name of the plugin you wish to install. This allows for extending Zowe CLI's functionality. ```bash zowe plugins install @zowe/@zowe-v2-lts ``` -------------------------------- ### Install Zowe CLI Plugin Source: https://github.com/zowe/zowe-cli/blob/master/docs/Plugin Architecture/Plugin Management.md Installs one or more Zowe CLI plugins. Plugins can be specified as npm package names or URIs. Supports versioning similar to npm and allows specifying a registry. If no plugins are provided, it attempts to install from a 'plugin.json' file. ```commandline zowe plugins install [plugin...] [--registry ] [--isLocalURI] [--isRemoteURI] [--use ] ``` -------------------------------- ### Install Zowe CLI Core Source: https://github.com/zowe/zowe-cli/wiki/Working-with-Team-Configuration Installs or updates the core Zowe CLI package globally using npm. This is a prerequisite for using Zowe CLI functionalities. ```bash npm install -g @zowe/cli ``` -------------------------------- ### List z/OSMF Published Catalog Templates (TypeScript) Source: https://github.com/zowe/zowe-cli/blob/master/packages/provisioning/README.md Lists published software service templates from the z/OSMF service catalog. It loads connection information from a default z/OSMF profile and formats the output based on command-line arguments. ```typescript import { ProfileInfo, TextUtils } from "@zowe/imperative"; import { explainPublishedTemplatesFull, explainPublishedTemplatesSummary, ListCatalogTemplates, ProvisioningConstants } from "@zowe/provisioning-for-zowe-sdk"; (async () => { // Load connection info from default z/OSMF profile const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf"); const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true }); const session = ProfileInfo.createSession(zosmfMergedArgs.knownArgs); const templates = await ListCatalogTemplates.listCatalogCommon(session, ProvisioningConstants.ZOSMF_VERSION); let prettifiedTemplates: any = {}; if (process.argv.slice(2).includes("--all") || process.argv.slice(2).includes("-a")) { prettifiedTemplates = TextUtils.explainObject(templates, explainPublishedTemplatesFull, true); } else { prettifiedTemplates = TextUtils.explainObject(templates, explainPublishedTemplatesSummary, false); } const response = "z/OSMF Service Catalog templates\n" + TextUtils.prettyJson(prettifiedTemplates); console.log(response); })().catch((err) => { console.error(err); process.exit(1); }); ``` -------------------------------- ### Install Zowe CLI V2 LTS Source: https://github.com/zowe/zowe-cli/blob/master/docs/Using Team Configuration.md Installs the Zowe CLI V2 LTS version globally using npm. This command ensures you have the latest stable version for managing mainframe services. ```bash npm install -g @zowe/cli@zowe-v2-lts ``` -------------------------------- ### Example CLI System Test Script (Zowe CLI) Source: https://github.com/zowe/zowe-cli/blob/master/docs/PluginTESTINGGuidelines.md A sample bash script demonstrating how to execute Zowe CLI commands within a system or integration test. It uses `zowe bp-sample list directory-contents` and includes error handling. ```bash #!/bin/bash set -e # fail the script if we get a non zero exit code directory=$1 zowe bp-sample list directory-contents "$directory" ``` -------------------------------- ### Zowe CLI Configuration Example (JSON) Source: https://github.com/zowe/zowe-cli/wiki/Working-with-Team-Configuration This JSON snippet represents a Zowe CLI configuration file. It defines various profiles for different services and environments, including production and development settings. It also specifies default profiles for services like ZOSMF, CICS, DB2, TSO, SSH, and a base profile. ```json { "$schema": "./zowe.schema.json", "profiles": { "prod": { "profiles": { "zosmf": { "type": "zosmf", "properties": { "basePath": "api/v1" } }, "cics": { "type": "cics", "properties": { "basePath": "api/v1/my_cics" } }, "db2": { "type": "db2", "properties": { "basePath": "api/v1/my_db2" } } } }, "dev": { "properties": { "host": "example1.com" }, "profiles": { "zosmf": { "type": "zosmf", "properties": { "port": 443 } }, "tso": { "type": "tso", "properties": { "account": "ACCT#", "codePage": "1047", "logonProcedure": "IZUFPROC" } }, "ssh": { "type": "ssh", "properties": { "port": 22 } } }, "secure": [ "user", "password" ] }, "my_base": { "type": "base", "properties": { "host": "example1.com", "port": 443, "rejectUnauthorized": true }, "secure": [ "authToken" ] } }, "defaults": { "zosmf": "prod.zosmf", "cics": "prod.cics", "db2": "prod.db2", "tso": "dev.tso", "ssh": "dev.ssh", "base": "my_base" }, "plugins": [] } ``` -------------------------------- ### List Active Workflow Instances in z/OSMF (TypeScript) Source: https://github.com/zowe/zowe-cli/blob/master/packages/workflows/README.md This example demonstrates how to list active workflow instances in z/OSMF using the zos-workflows-for-zowe-sdk. It loads connection information from a default z/OSMF profile and uses the `ListWorkflows.getWorkflows` method to retrieve the data. ```typescript import { ProfileInfo } from "@zowe/imperative"; import { IActiveWorkflows, ListWorkflows } from "@zowe/zos-workflows-for-zowe-sdk"; (async () => { // Load connection info from default z/OSMF profile const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf"); const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true }); const session = ProfileInfo.createSession(zosmfMergedArgs.knownArgs); const response: IActiveWorkflows = await ListWorkflows.getWorkflows(session); console.log(response.workflows); })().catch((err) => { console.error(err); process.exit(1); }); ``` -------------------------------- ### Update Zowe CLI Plugin Source: https://github.com/zowe/zowe-cli/blob/master/docs/Plugin Architecture/Plugin Management.md Updates installed Zowe CLI plugins to their latest versions. For npm-installed plugins, this is equivalent to 'npm install @latest'. For other sources, it attempts to fetch the most recent available code. Plugin information in 'plugin.json' is updated accordingly. ```commandline zowe plugins update ``` -------------------------------- ### Install Zowe CLI Autocompletion for Bash (Alternative Linux) Source: https://github.com/zowe/zowe-cli/blob/master/autocompletion/README.md Installs Zowe autocompletion by sourcing the script from the user's home directory in the .bashrc file. This is an alternative if direct access to /etc/bash_completion.d is not available. The script is copied to a local directory, and then sourced. ```shell . ~/zowe_autocompletion/zowe.bash ``` -------------------------------- ### Set Up and Clean Up Test Environment with TestEnvironment.ts Source: https://github.com/zowe/zowe-cli/blob/master/docs/PluginTESTINGGuidelines.md Demonstrates how to use TestEnvironment.setUp and TestEnvironment.cleanUp to manage isolated testing environments for Zowe CLI plugins. This includes installing plugins, creating temporary profiles, and accessing system properties and the working directory. ```typescript let testEnvironment: ITestEnvironment; let myTestFile: string; describe ("my tests", =>{ // Create the unique test environment beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ installPlugin: true, // install our plugin into the test environment working directory so that we can issue plugin commands testName: "fail_command", // this influences the name of the generated directory tempTestProfiles: ["zosmf"] // create a zosmf profile from the settings in the custom_properties.yaml file }); // access any of the test properties const user = testEnvironment.systemTestProperties.zosmf.user; // access the working directory from your test environment to save temporary test-related files myTestFile = testEnvironment.workingDir +"/myTestFile.txt"; }); afterAll(async () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT); // cleans up installed plugins and created profiles but doesn't delete the directory // in case you need to reference any of the files after the tests run }); //... your tests here ... }); ``` -------------------------------- ### Initialize Global and Project User Configs in Zowe CLI Source: https://github.com/zowe/zowe-cli/blob/master/docs/How_config_files_are_merged.md Initializes empty user configuration profiles in both the global and project-level configuration files. This ensures that users are prompted for any required connection properties that lack default values. ```bash zowe config init --user-config --global-config zowe config init --user-config ``` -------------------------------- ### Perform HTTP GET Request with REST Client Source: https://github.com/zowe/zowe-cli/wiki/Consuming-REST-APIs-using-the-REST-client Demonstrates how to use the RestClient's GET verb to fetch string content from a public API. It requires importing Session and RestClient from '@zowe/imperative' and defining a session object for the connection. ```typescript import { Session, RestClient } from "@zowe/imperative"; // define "session" (e.g. how to connect) for non-authenticated endpoint const session = new Session({ hostname: "jsonplaceholder.typicode.com" }); // REST GET - call "/users" URI / endpoint - on fulfilled, "users" will contain text user response const users = await RestClient.getExpectString(session, "/users"); ```