Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/cci_yml_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
David Glick committed Apr 8, 2021
2 parents 759112d + 886dc92 commit 03a2809
Show file tree
Hide file tree
Showing 41 changed files with 4,161 additions and 1,965 deletions.
14 changes: 10 additions & 4 deletions cumulusci/cli/cci.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict
from cumulusci.core.dependencies.resolvers import get_static_dependencies
from urllib.parse import urlparse

import code
Expand Down Expand Up @@ -732,11 +733,16 @@ def project_info(runtime):
name="dependencies",
help="Displays the current dependencies for the project. If the dependencies section has references to other github repositories, the repositories are inspected and a static list of dependencies is created",
)
@click.option(
"--resolution-strategy",
help="The resolution strategy to use. Defaults to production.",
default="production",
)
@pass_runtime(require_keychain=True)
def project_dependencies(runtime):
dependencies = runtime.project_config.get_static_dependencies()
for line in runtime.project_config.pretty_dependencies(dependencies):
click.echo(line)
def project_dependencies(runtime, resolution_strategy):
dependencies = get_static_dependencies(runtime.project_config, resolution_strategy)
for line in dependencies:
click.echo(f"{line}")


# Commands for group: service
Expand Down
31 changes: 27 additions & 4 deletions cumulusci/cli/tests/test_cci.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from cumulusci.core.dependencies.dependencies import PackageNamespaceVersionDependency
from datetime import date
from datetime import datetime
from datetime import timedelta
Expand Down Expand Up @@ -863,15 +864,37 @@ def test_project_info__outside_project(self):
with self.assertRaises(NotInProject):
run_click_command(cci.project_info, runtime=runtime)

def test_project_dependencies(self):
@mock.patch("cumulusci.cli.cci.get_static_dependencies")
def test_project_dependencies(self, get_static_dependencies):
out = []
runtime = mock.Mock()
runtime.project_config.pretty_dependencies.return_value = ["test:"]
runtime.project_config.project__dependencies = [
{"namespace": "npe01", "version": "3.16"},
{"namespace": "npsp", "version": "3.193"},
]
get_static_dependencies.return_value = [
PackageNamespaceVersionDependency(namespace="npe01", version="3.16"),
PackageNamespaceVersionDependency(namespace="npsp", version="3.193"),
]

with mock.patch("click.echo", out.append):
run_click_command(cci.project_dependencies, runtime=runtime)
run_click_command(
cci.project_dependencies,
runtime=runtime,
resolution_strategy="production",
)

self.assertEqual("test:", "".join(out))
self.assertEqual(
out,
[
str(
PackageNamespaceVersionDependency(namespace="npe01", version="3.16")
),
str(
PackageNamespaceVersionDependency(namespace="npsp", version="3.193")
),
],
)

@mock.patch("cumulusci.cli.cci.CliTable")
def test_service_list(self, cli_tbl):
Expand Down
31 changes: 18 additions & 13 deletions cumulusci/core/config/OrgConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,27 +489,32 @@ def is_advanced_currency_management_enabled(self):
return False

def resolve_04t_dependencies(self, dependencies):
"""Look up 04t SubscriberPackageVersion ids for 1gp project dependencies"""
"""Look up 04t SubscriberPackageVersion ids for 1GP project dependencies"""
from cumulusci.core.dependencies.dependencies import (
PackageNamespaceVersionDependency,
PackageVersionIdDependency,
)

# Circular dependency.

new_dependencies = []
for dependency in dependencies:
dependency = {**dependency}

if "namespace" in dependency:
if isinstance(dependency, PackageNamespaceVersionDependency):
# get the SubscriberPackageVersion id
key = f"{dependency['namespace']}@{dependency['version']}"
key = f"{dependency.namespace}@{dependency.version}"
version_info = self.installed_packages.get(key)
if version_info:
dependency["version_id"] = version_info[0].id
new_dependencies.append(
PackageVersionIdDependency(
version_id=version_info[0].id,
package_name=dependency.package_name,
)
)
else:
raise DependencyResolutionError(
f"Could not find 04t id for package {key} in org {self.name}"
)
else:
new_dependencies.append(dependency)

# recurse
if "dependencies" in dependency:
dependency["dependencies"] = self.resolve_04t_dependencies(
dependency["dependencies"]
)

new_dependencies.append(dependency)
return new_dependencies
Loading

0 comments on commit 03a2809

Please sign in to comment.