Overview

The CLI tool needs to be able to download code components into a local codebase. This means fetching their data from the /api/v0/config/js_component endpoint, and writing it to files.

→ See: #3525571: [Meta] CLI tool for code components

Proposed resolution

  1. Implement this command using the implementation as a reference from the POC: https://github.com/lauriii/experience-builder-cli/blob/main/src/commands.... Use @clack/prompts.
  2. Read the location for your local directory for components from an environment variable or .env file established in #3525579: Implement client credentials flow in CLI, centralize managing config.
  3. Component format:
    my-component/
      ├── component.yml     # Component metadata and configuration
      ├── index.jsx         # React component source
      ├── index.css         # Optional CSS
    

    The component.yml file can match the shape of the data the /api/v0/config/js_component endpoint works with — excluding the JS and CSS source/compiled code.

  4. Allow users to select components interactively or passed as a CLI argument. Make sure there is an option to select all.
  5. Create the directories and files for all selected components.
  6. Override any directories locally with matching names to a component that's downloaded.
  7. Download the CSS source from the global asset library (/api/v0/config/xb_asset_library/global), create it as global.css in the local folder for components. Override it any time any component is downloaded.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

balintbrews created an issue. See original summary.

hooroomoo made their first commit to this issue’s fork.

hooroomoo’s picture

Assigned: Unassigned » hooroomoo
Status: Postponed » Active

hooroomoo’s picture

This is pretty much ready for a review. It still needs #3525572: Implement OAuth2 authentication for API endpoints related to code components to get in though since this MR has changes from there.

hooroomoo changed the visibility of the branch 3525583-cli-command-to to hidden.

hooroomoo’s picture

Status: Active » Needs review

This is ready for an initial review for the /cli changes.

Note: it is built on top of an older version of #3525572: Implement OAuth2 authentication for API endpoints related to code components.

hooroomoo credited lauriii.

hooroomoo’s picture

crediting @lauriii for the PoC this MR is based off of

hooroomoo’s picture

Assigned: hooroomoo » Unassigned
hooroomoo’s picture

hooroomoo’s picture

Assigned: Unassigned » balintbrews

balintbrews’s picture

Assigned: balintbrews » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.