Overview

Code components now have data dependencies introduced in #3533458: Change CodeComponentDataProvider::getRequiredXbDataLibraries() to base its logic on information provided by the front-end rather than on naive string/regex matching. This is not yet handled in the CLI tool.

Proposed resolution

Add the new property in the typing. Make sure it's added by the scaffold command, written by the download command, and handled by the upload command.

This is an incremental change to open the possibility of manually providing data dependencies. The DX will be fixed in #3537654: Detect first-party and data dependency imports.

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.

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

balintbrews’s picture

I was thinking about backwards compatibility with the 0.x branch, and I was ready to go ahead and start different versions for the CLI to address that, but @justafish had a better idea:

We could see if in our upload command we receive a 422 error complaining about the dataDependencies property not being recognized — which would happen with the 0.x branch. In that case, we could retry the request while removing dataDependencies from the payload.

balintbrews’s picture

Assigned: Unassigned » balintbrews
Status: Active » Needs review
larowlan’s picture

Status: Needs review » Needs work

Is there any way we can write a test for this? We have the hello-world template component - can we add a test that it validates against the open api file?

https://www.npmjs.com/package/openapi-request-validator looks like what we want

That would prevent changes in Drupal breaking this in the future.

bnjmnm’s picture

Re #7 discussed this with some folks including @balintbrews / @effulgentsia / @hooroomoo and it was determined that the scenario that needs to be tested here is better implemented as an integration test, as the unit would require a degree of mocking that would limit the test's ability to catch actual problems. Currently, integration tests aren't set up at all and would significantly expand the scope of this issue. The discussion concluded that we should prioritize getting the fix in to address some of the immediate needs of other projects, and focus on integration test implementation in a separate (and likely much larger) issue.

larowlan’s picture

A simple PHPUnit test that validated hello-world/component.yml against the #/components/schemas/NewCodeComponent spec in the open API file would have caught this regression. Any objections to me adding that to this branch?

larowlan’s picture

Status: Needs work » Reviewed & tested by the community

pushed #9, openapi++

wim leers’s picture

Title: Handle data dependencies in CLI commands » Handle data dependencies in CLI commands, validate CLI test fixtures against OpenAPI spec
Issue tags: +openapi
hooroomoo’s picture

  • hooroomoo committed 42df242b on 1.x authored by bnjmnm
    Issue #3538775 by bnjmnm, hooroomoo, larowlan, balintbrews, justafish:...
hooroomoo’s picture

Assigned: balintbrews » Unassigned
Status: Reviewed & tested by the community » Fixed

I believe https://www.npmjs.com/package/@drupal/xb-cli should get a new tag now, i've notified @balintbrews

Status: Fixed » Closed (fixed)

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