Detect first-party and data dependency imports
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3537654. -->
Reported by: [balintbrews](https://www.drupal.org/user/613760)
Related to !201 !200
>>>
<h3 id="overview">Overview</h3>
<p>The <a href="https://git.drupalcode.org/project/experience_builder/-/blob/67a54b6f42233781eeefa2fe99416fa812073869/cli/src/commands/upload.ts">CLI tool's <code>upload</code> command</a> requires code component authors to manually add an <code>importedJsComponents</code> key in the <code>component.yml</code> metadata file in case first-party imports are used. The <code>download</code> command also writes that key to the metadata file. Similarly, <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/experience_builder/issues/3533458" title="Status: Closed (fixed)">#3533458: Change CodeComponentDataProvider::getRequiredXbDataLibraries() to base its logic on information provided by the front-end rather than on naive string/regex matching</a></span> introduced a new <code>dataDependencies </code>key, which <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/experience_builder/issues/3538775" title="Status: Closed (fixed)">#3538775: Handle data dependencies in CLI commands, validate CLI test fixtures against OpenAPI spec</a></span> will add manual support for.</p>
<p>These keys should not be part of the metadata file. First-party imports and data dependencies should be discovered automatically based on the code, just like we do on the code editor UI.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<ol>
<li>Reuse the same code, possibly after some refactoring if needed, as we do on the code editor UI to detect first-party imports and data dependencies in the JavaScript source of a code component.</li>
<li>Set the appropriate properties in the payload automatically.</li>
<li>Remove the <code>importedJsComponents</code> and property <code>dataDependencies</code> from <a href="https://git.drupalcode.org/project/experience_builder/-/blob/67a54b6f42233781eeefa2fe99416fa812073869/cli/src/types/Component.ts">the <code>Component</code> type (defined in <code>cli/src/types/Component.ts</code>)</a></li>
<li>Update <a href="https://git.drupalcode.org/project/experience_builder/-/blob/67a54b6f42233781eeefa2fe99416fa812073869/cli/src/commands/download.ts">the <code>download</code> command</a> so it doesn't write these properties to the metadata file.</li>
</ol>
<h3 id="ui-changes">User interface changes</h3>
<p>The <code>importedJsComponents</code> property is not exposed to code component authors.</p>
> Related issue: [Issue #3525587](https://www.drupal.org/node/3525587)
> Related issue: [Issue #3538775](https://www.drupal.org/node/3538775)
issue