Skip to content

feat: write dependencies of imported component to workspace.jsonc or package.json#9682

Merged
zkochan merged 17 commits intoteambit:masterfrom
zkochan:write-deps
Apr 25, 2025
Merged

feat: write dependencies of imported component to workspace.jsonc or package.json#9682
zkochan merged 17 commits intoteambit:masterfrom
zkochan:write-deps

Conversation

@zkochan
Copy link
Member

@zkochan zkochan commented Apr 23, 2025

Proposed Changes

@zkochan zkochan marked this pull request as ready for review April 24, 2025 16:51
@zkochan zkochan requested a review from Copilot April 24, 2025 16:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new feature to write workspace component dependencies to either workspace.jsonc or package.json. Key changes include:

  • Adding new methods in the workspace to write dependencies to the specified target.
  • Updating import and dependency commands to recognize and handle a new writeDeps flag.
  • Adjusting dependency resolution and merging logic to support the new dependency-writing feature.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scopes/workspace/workspace/workspace.ts New functions for writing dependencies to workspace.jsonc or package.json have been introduced.
scopes/workspace/install/install.main.runtime.ts Refactored internal calls to use workspace methods for dependency policy retrieval and updated the variant policies update method signature.
scopes/workspace/config-merger/config-merger.main.runtime.ts Updated to use the new semver helper for comparing ranges instead of an internal function.
scopes/scope/importer/import.cmd.ts, scopes/scope/importer/import-components.ts Added support for the new writeDeps flag in component import commands.
scopes/pkg/modules/semver-helper/* Extended semver helper exports with a new helper function for comparing version ranges.
scopes/dependencies/* Expanded dependency resolver types, updated merging logic, and added a new DependenciesWriteCmd command along with accompanying tests and helper changes.
Comments suppressed due to low confidence (2)

scopes/workspace/install/install.main.runtime.ts:1058

  • [nitpick] Consider renaming the parameter 'updateVariantPolicies' to 'updatedVariants' for clarity, as the function internally retrieves the current variant patterns.
private async _updateVariantsPolicies(updateVariantPolicies: string[]) {

scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts:1507

  • [nitpick] Consider adding an inline comment here to clarify the merging logic why a dependency with a greater version range (according to a naive comparison) replaces an existing one.
if (isRange1GreaterThanRange2Naively(dep.currentRange, mergedDeps[dep.name].currentRange)) {

@zkochan zkochan enabled auto-merge (squash) April 25, 2025 14:32
@zkochan zkochan merged commit 62a4c48 into teambit:master Apr 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants