UI5 CLI

repository·main·Indexed 19 days ago

https://github.com/ui5/cli

A modular toolchain for developing UI5-based applications, providing essential features such as development servers, project building, and dependency management. The ecosystem includes core packages such as @ui5/cli, @ui5/builder, @ui5/fs, @ui5/logger, @ui5/project, and @ui5/server.

Tokens
116.4K
Snippets
325
Records
511
Agent score
67%

What's inside UI5 CLI

  1. Overview of @ui5/cli

    main
    The @ui5/cli is the Command Line Interface for UI5. It provides tools for developers to interact with UI5 projects, including building, serving, and managing resources. Detailed documentation for all commands and configurations is hosted externally.
  2. Overview of UI5 CLI

    main

    UI5 CLI is an open and modular toolchain designed for developing applications based on the UI5 framework. It provides a suite of tools for project management, development servers, and building UI5 projects.

    Note on Versions: This repository currently contains the development state for the upcoming v5 release. For stable production use, it is highly recommended to use the latest stable version (v4).

  3. Understand the docdash documentation template

    main

    The files in this directory are based on docdash 2.0.2, a documentation template for JSDoc. However, SAP has applied specific modifications to suit the UI5 CLI documentation workflow:

    • Markdown Output: Unlike the original version which outputs HTML, this version is modified to output Markdown.
    • Streamlined Functionality: The publish.js utility has been stripped of navbar functionality and static files functionality to reduce complexity.
    • Link Adjustments: JavaScript links are configured to point to GitHub, and internal linking mechanisms have been modified.
  4. What are Processors in UI5 Builder?

    main

    Processors contain the actual logic for build steps. While tasks manage the workflow and resource collection, processors perform the specific modifications to the resources or create new resources from existing ones.

    Processors are designed to be generic. For example, a string replacer processor can be reused across different tasks to handle code replacement, versioning, dates, or copyright information by passing different configurations.

    To find all available processors, consult the API reference and search for @ui5/builder/processors/.

  5. Use Dependency Injection for UI5 CLI Modules

    main

    To ensure compatibility across UI5 CLI versions, extensions should avoid direct dependencies on @ui5/fs or @ui5/logger. Instead, use the provided log and taskUtil.resourceFactory objects injected into the extension function. This allows the CLI to provide version-appropriate implementations of these APIs.

    • Logging: Use the provided log object. It automatically includes the task or middleware name. You can create sub-loggers using log.createSubLogger("suffix").
    • Resource Creation: Use taskUtil.resourceFactory.createResource({...}) to create @ui5/fs Resource entities.
    module.exports = async function({workspace, dependencies, log, taskUtil, options}) {
      const {createResource} = taskUtil.resourceFactory;
      
      // ... inside a loop or task logic
      log.info(`Processing file...`);
      
      const newResource = createResource({
        path: "new/path/file.html",
        string: "<html>...</html>"
      });
      await workspace.write(newResource);
    };
  6. How the UI5 CLI E2E test environment works

    main

    The E2E test environment simulates realistic user scenarios by performing the following steps for each test:

    1. Fixture Setup: Copies a project from the ./fixtures/ directory to a temporary directory (./tmp).
    2. Dependency Installation: Runs npm install within the temporary directory as a child process.
    3. CLI Execution: Runs ui5 build with various configurations using the UI5 CLI executable sourced from packages/cli/bin/ui5.cjs.

    To optimize performance, Node modules are installed during the first build and reused for subsequent builds in a scenario, avoiding redundant reinstallations. Some tests simulate real-world workflows by performing multiple sequential builds with file modifications between them.

  7. Automatic generation of `sap-ui-version.json` during `ui5 build`

    main

    In UI5 CLI v5, the generateVersionInfo task runs by default during ui5 build for projects of type application. This task generates an sap-ui-version.json file in the resources/ directory.

    • Supported Build Types: default, jsdoc, and self-contained.
    • Project Types: Only runs for application projects. For other types (e.g., library), it does not run by default.
    • ui5 serve behavior: The generateVersionInfo task does not run by default during ui5 serve, but the versionInfo middleware provides an identical sap-ui-version.json output.