How to use @zowe/imperative - 10 common examples

To help you get started, we’ve selected a few @zowe/imperative examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / zowe-cli-cics-deploy-plugin / __tests__ / __src__ / environment / TestEnvironment.ts View on Github external
private static async installPlugin(testEnvironment: ITestEnvironment) {
        let installScript: string = TemporaryScripts.SHEBANG;
        installScript += TemporaryScripts.ZOWE_BIN + " plugins install ../../../../\n"; // install plugin from root of project
        installScript += TemporaryScripts.ZOWE_BIN + " plugins validate @brightside/zowe-cli-cics-deploy-plugin\n";
        installScript += TemporaryScripts.ZOWE_BIN + " cdep --help\n"; // check that the plugin help is available
        const scriptPath = testEnvironment.workingDir + "/install_plugin.sh";
        IO.writeFile(scriptPath, Buffer.from(installScript));

        const output = runCliScript(scriptPath, testEnvironment, []);

        if (output.status !== 0) {
            throw new ImperativeError({
                msg: "Install of '@brightside/zowe-cli-cics-deploy-plugin' plugin failed! You should delete the script: \n'" + scriptPath + "' " +
                    "after reviewing it to check for possible errors.\n Output of the plugin install command:\n" + output.stderr.toString() +
                    output.stdout.toString()
            });
        }
        IO.deleteFile(scriptPath);
    }
github IBM / zowe-cli-cics-deploy-plugin / __tests__ / __src__ / environment / TestEnvironment.ts View on Github external
installScript += TemporaryScripts.ZOWE_BIN + " plugins install ../../../../\n"; // install plugin from root of project
        installScript += TemporaryScripts.ZOWE_BIN + " plugins validate @brightside/zowe-cli-cics-deploy-plugin\n";
        installScript += TemporaryScripts.ZOWE_BIN + " cdep --help\n"; // check that the plugin help is available
        const scriptPath = testEnvironment.workingDir + "/install_plugin.sh";
        IO.writeFile(scriptPath, Buffer.from(installScript));

        const output = runCliScript(scriptPath, testEnvironment, []);

        if (output.status !== 0) {
            throw new ImperativeError({
                msg: "Install of '@brightside/zowe-cli-cics-deploy-plugin' plugin failed! You should delete the script: \n'" + scriptPath + "' " +
                    "after reviewing it to check for possible errors.\n Output of the plugin install command:\n" + output.stderr.toString() +
                    output.stdout.toString()
            });
        }
        IO.deleteFile(scriptPath);
    }
github IBM / zowe-cli-cics-deploy-plugin / __tests__ / __src__ / environment / TestEnvironment.ts View on Github external
private static async installPlugin(testEnvironment: ITestEnvironment) {
        let installScript: string = TemporaryScripts.SHEBANG;
        installScript += TemporaryScripts.ZOWE_BIN + " plugins install ../../../../\n"; // install plugin from root of project
        installScript += TemporaryScripts.ZOWE_BIN + " plugins validate @brightside/zowe-cli-cics-deploy-plugin\n";
        installScript += TemporaryScripts.ZOWE_BIN + " cdep --help\n"; // check that the plugin help is available
        const scriptPath = testEnvironment.workingDir + "/install_plugin.sh";
        IO.writeFile(scriptPath, Buffer.from(installScript));

        const output = runCliScript(scriptPath, testEnvironment, []);

        if (output.status !== 0) {
            throw new ImperativeError({
                msg: "Install of '@brightside/zowe-cli-cics-deploy-plugin' plugin failed! You should delete the script: \n'" + scriptPath + "' " +
                    "after reviewing it to check for possible errors.\n Output of the plugin install command:\n" + output.stderr.toString() +
                    output.stdout.toString()
            });
        }
        IO.deleteFile(scriptPath);
    }
github IBM / zowe-cli-cics-deploy-plugin / __tests__ / __src__ / environment / TestEnvironment.ts View on Github external
public static async setUp(params: ISetupEnvironmentParms): Promise {
        // Validate the input parameters
        ImperativeExpect.toNotBeNullOrUndefined(params,
            `${TestEnvironment.ERROR_TAG} createTestEnv(): No parameters supplied.`);
        ImperativeExpect.keysToBeDefinedAndNonBlank(params, ["testName"],
            `${TestEnvironment.ERROR_TAG} createTestEnv(): You must supply the name of the test. ` +
            `Used to append to the data directory for ease of identification.`);

        // Get a unique test data area
        const testDirectory: string = TestEnvironment.createUniqueTestDataDir(params.testName);

        // set the env variables to be used for executing
        // scripts in the test environment
        const env: { [key: string]: string } = {};
        env[this.HOME_ENV_KEY] = testDirectory;

        const result: ITestEnvironment = {
            workingDir: testDirectory,
            systemTestProperties: null,
            env
        };
github IBM / zowe-cli-cics-deploy-plugin / __tests__ / __src__ / environment / TestEnvironment.ts View on Github external
public static async setUp(params: ISetupEnvironmentParms): Promise {
        // Validate the input parameters
        ImperativeExpect.toNotBeNullOrUndefined(params,
            `${TestEnvironment.ERROR_TAG} createTestEnv(): No parameters supplied.`);
        ImperativeExpect.keysToBeDefinedAndNonBlank(params, ["testName"],
            `${TestEnvironment.ERROR_TAG} createTestEnv(): You must supply the name of the test. ` +
            `Used to append to the data directory for ease of identification.`);

        // Get a unique test data area
        const testDirectory: string = TestEnvironment.createUniqueTestDataDir(params.testName);

        // set the env variables to be used for executing
        // scripts in the test environment
        const env: { [key: string]: string } = {};
        env[this.HOME_ENV_KEY] = testDirectory;

        const result: ITestEnvironment = {
            workingDir: testDirectory,
            systemTestProperties: null,
github IBM / zowe-cli-cics-deploy-plugin / src / api / BundleContent / AutoBundler.ts View on Github external
}
      }
    }

    // Add the NODEJSAPP to the Bundle
    this.bundle.addNodejsappDefinition(njappname, fullSS, this.portOverride);
    try {
      // Construct an info message to report that the NODEJSAPP has been created
      const msg = '    define : NODEJSAPP "' + njappname + '" with startscript "' + ss + '"';

      // log the message to the console for the uesr
      params.response.console.log(msg);

      // Also log the message for posterity
      if (params.arguments.silent === undefined) {
        const logger = Logger.getAppLogger();
        logger.debug(msg);
      }
    }
    catch (error) {
      // logging errors can be thrown in some of the mocked tests... just ignore it.
    }
  }
github IBM / zowe-cli-cics-deploy-plugin / src / api / BundleContent / AutoBundler.ts View on Github external
}
    else {
      // If we get here then we've not found a package.json file. it remains possible
      // that sufficient command line parameters have been set to allow a NODEJSAPP
      // to be created. If so, process them.
      if (this.startscriptOverride !== undefined ||
          this.nodejsappOverride   !== undefined ||
          this.portOverride        !== undefined ) {
        this.bundle.addNodejsappDefinition(this.nodejsappOverride, this.startscriptOverride, this.portOverride);
        try {
          const msg = 'define : NODEJSAPP "' + this.nodejsappOverride + '" with startscript "' + this.startscriptOverride + '"';
          params.response.console.log(msg);

          // Also log the message for posterity
          if (params.arguments.silent === undefined) {
            const logger = Logger.getAppLogger();
            logger.debug(msg);
          }
        }
        catch (error) {
          // logging errors can be thrown in some of the mocked tests... just ignore it.
        }
      }
    }
  }
github IBM / zowe-cli-cics-deploy-plugin / gulp / GenerateDoc.ts View on Github external
const doc: ITaskFunction = async () => {
    process.env.FORCE_COLOR = "0";

    // Get all command definitions
    const myConfig = ImperativeConfig.instance;
    // myConfig.callerLocation = __dirname;
    myConfig.loadedConfig = require("../src/imperative");

    myConfig.loadedConfig.commandModuleGlobs = ["src/cli/*/*.definition!(.d).*s"];


    // Need to set this for the internal caller location so that the commandModuleGlobs finds the commands
    process.mainModule.filename = __dirname + "/../package.json";

    await Imperative.init(myConfig.loadedConfig);
    const loadedDefinitions = Imperative.fullCommandTree;
    clearRequire.all(); // in case the code has changed, reload any code

    let totalCommands = 0;
    let markdownContent = "# Zowe CLI cics-deploy plugin command reference\n\n";

    markdownContent += "{{tableOfContents}}\n\n";
    let tableOfContentsText = "### Table of Contents\n";

    const tabIndent = "\t";
    let oldCommandName = "";

    function getGroupHelp(definition: any, indentLevel: number = 0) {
        let commandNameSummary = definition.name;
        if (definition.aliases.length > 0 &&
            !(definition.aliases[0].trim().length === 0 && definition.aliases.length === 1)) {
            commandNameSummary += " | " + definition.aliases.join(" | ");
github IBM / zowe-cli-cics-deploy-plugin / gulp / GenerateDoc.ts View on Github external
const doc: ITaskFunction = async () => {
    process.env.FORCE_COLOR = "0";

    // Get all command definitions
    const myConfig = ImperativeConfig.instance;
    // myConfig.callerLocation = __dirname;
    myConfig.loadedConfig = require("../src/imperative");

    myConfig.loadedConfig.commandModuleGlobs = ["src/cli/*/*.definition!(.d).*s"];


    // Need to set this for the internal caller location so that the commandModuleGlobs finds the commands
    process.mainModule.filename = __dirname + "/../package.json";

    await Imperative.init(myConfig.loadedConfig);
    const loadedDefinitions = Imperative.fullCommandTree;
    clearRequire.all(); // in case the code has changed, reload any code

    let totalCommands = 0;
    let markdownContent = "# Zowe CLI cics-deploy plugin command reference\n\n";

    markdownContent += "{{tableOfContents}}\n\n";
    let tableOfContentsText = "### Table of Contents\n";

    const tabIndent = "\t";
    let oldCommandName = "";

    function getGroupHelp(definition: any, indentLevel: number = 0) {
        let commandNameSummary = definition.name;
        if (definition.aliases.length > 0 &&
            !(definition.aliases[0].trim().length === 0 && definition.aliases.length === 1)) {
github IBM / zowe-cli-cics-deploy-plugin / gulp / GenerateDoc.ts View on Github external
const doc: ITaskFunction = async () => {
    process.env.FORCE_COLOR = "0";

    // Get all command definitions
    const myConfig = ImperativeConfig.instance;
    // myConfig.callerLocation = __dirname;
    myConfig.loadedConfig = require("../src/imperative");

    myConfig.loadedConfig.commandModuleGlobs = ["src/cli/*/*.definition!(.d).*s"];


    // Need to set this for the internal caller location so that the commandModuleGlobs finds the commands
    process.mainModule.filename = __dirname + "/../package.json";

    await Imperative.init(myConfig.loadedConfig);
    const loadedDefinitions = Imperative.fullCommandTree;
    clearRequire.all(); // in case the code has changed, reload any code

    let totalCommands = 0;
    let markdownContent = "# Zowe CLI cics-deploy plugin command reference\n\n";