-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yarn_v1: Automated Yarn version detector
In order to simplify user interface some logic is added to automatically distinguish between supported Yarn versions. Addresses: #624 Signed-off-by: Alexey Ovchinnikov <[email protected]>
- Loading branch information
1 parent
4739b4b
commit ceb2583
Showing
9 changed files
with
250 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from cachi2.core.config import get_config | ||
from cachi2.core.models.input import Request | ||
from cachi2.core.models.output import RequestOutput | ||
from cachi2.core.package_managers.yarn.main import fetch_yarn_source as fetch_yarnberry_source | ||
from cachi2.core.package_managers.yarn_classic.main import MissingLockfile, NotV1Lockfile | ||
from cachi2.core.package_managers.yarn_classic.main import ( | ||
fetch_yarn_source as fetch_yarn_classic_source, | ||
) | ||
from cachi2.core.utils import merge_outputs | ||
|
||
|
||
def fetch_yarn_source(request: Request) -> RequestOutput: | ||
"""Fetch yarn source.""" | ||
# Packages could be a mixture of yarn v1 and v2 (at least this is how it | ||
# looks now). To preserve this behavior each request is split into individual | ||
# packages which are assessed one by one. | ||
fetched_packages = [] | ||
for package in request.packages: | ||
new_request = request.model_copy(update={"packages": [package]}) | ||
try: | ||
fetched_packages.append(fetch_yarn_classic_source(new_request)) | ||
except (MissingLockfile, NotV1Lockfile) as e: | ||
# It is assumed that if a package is not v1 then it is probably v2. | ||
if get_config().allow_yarnberry_processing: | ||
fetched_packages.append(fetch_yarnberry_source(new_request)) | ||
else: | ||
raise e | ||
return merge_outputs(fetched_packages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.