feat(CLI Tool): Push components as external metadata when the Headless SDK is present

#3591912

AI Disclosure: yes used Claude

canvas push: support pushing components as type: external with their metadata when the Headless SDK is present

  • SDK detection: when @drupal-canvas/headless is in the project's dependencies or devDependencies, every discovered component is pushed as type: external.
  • Explicit opt-in: a type: external in a component's component.yml is honored the same way, with or without the SDK. The YAML file is never mutated — type is set on the API payload only.
  • Entry-less discovery: framework single-file components (.vue, .astro, .svelte) and other entry-less externals are discovered instead of being dropped as "missing JS entry".
  • Reconciliation: existing externals are updated rather than recreated; the CLI never deletes an external the headless app owns. A local/remote component type mismatch is rejected at planning time with an
    actionable message, instead of surfacing a confusing server error ("External code components cannot contain JavaScript or CSS").
  • Default behavior is unchanged: no SDK and no type → components push as react with compiled JS/CSS.

Testing instructions

  • build the CLI: npm run --workspace=@drupal-canvas/cli build
  • In a project with @drupal-canvas/headless installed, run canvas push; confirm components arrive in Drupal as type: external with no JS/CSS.
  • In a project without the SDK, run canvas push; confirm components push unchanged as react with compiled code.
  • Push a react component whose machine name already exists on the server as external; confirm the CLI reports a clear "type cannot be changed" failure and sends no update.
Edited by Harumi Jang

Merge request reports

Loading