cumulusci-plus 5.0.24__py3-none-any.whl → 5.0.25__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cumulusci-plus might be problematic. Click here for more details.

cumulusci/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "5.0.24"
1
+ __version__ = "5.0.25"
cumulusci/cli/task.py CHANGED
@@ -2,6 +2,7 @@ import json
2
2
  from pathlib import Path
3
3
 
4
4
  import click
5
+ from dotenv import load_dotenv
5
6
  from rich.console import Console
6
7
  from rst2ansi import rst2ansi
7
8
 
@@ -126,6 +127,10 @@ class RunTaskCommand(click.MultiCommand):
126
127
  "help": "Drops into the Python debugger at task completion.",
127
128
  "is_flag": True,
128
129
  },
130
+ "loadenv": {
131
+ "help": "Loads environment variables from the .env file.",
132
+ "is_flag": True,
133
+ },
129
134
  }
130
135
 
131
136
  def list_commands(self, ctx):
@@ -151,6 +156,17 @@ class RunTaskCommand(click.MultiCommand):
151
156
 
152
157
  def run_task(*args, **kwargs):
153
158
  """Callback function that executes when the command fires."""
159
+ # Load environment variables FIRST, before any task processing
160
+ if kwargs.get("loadenv", None):
161
+ # Load .env file from the project root directory
162
+ env_path = (
163
+ Path(runtime.project_config.repo_root) / ".env"
164
+ if runtime.project_config
165
+ else None
166
+ )
167
+ if env_path:
168
+ load_dotenv(env_path)
169
+
154
170
  org, org_config = runtime.get_org(
155
171
  kwargs.pop("org", None), fail_if_missing=False
156
172
  )
@@ -168,6 +184,7 @@ class RunTaskCommand(click.MultiCommand):
168
184
  task_config.config["options"].update(options)
169
185
 
170
186
  try:
187
+
171
188
  task = task_class(
172
189
  task_config.project_config, task_config, org_config=org_config
173
190
  )
@@ -1,6 +1,8 @@
1
1
  import contextlib
2
2
  import io
3
3
  import json
4
+ import tempfile
5
+ from pathlib import Path
4
6
  from unittest.mock import Mock, patch
5
7
 
6
8
  import click
@@ -126,10 +128,10 @@ def test_format_help(runtime):
126
128
 
127
129
  def test_get_default_command_options():
128
130
  opts = task.RunTaskCommand()._get_default_command_options(is_salesforce_task=False)
129
- assert len(opts) == 4
131
+ assert len(opts) == 5
130
132
 
131
133
  opts = task.RunTaskCommand()._get_default_command_options(is_salesforce_task=True)
132
- assert len(opts) == 5
134
+ assert len(opts) == 6
133
135
  assert any([o.name == "org" for o in opts])
134
136
 
135
137
 
@@ -264,3 +266,87 @@ class SetTrace(Exception):
264
266
  class DummyDerivedTask(DummyTask):
265
267
  def _run_task(self):
266
268
  click.echo(f"<{self.__class__}>\n\tcolor: {self.options['color']}")
269
+
270
+
271
+ @patch("cumulusci.cli.task.load_dotenv")
272
+ def test_task_run__loadenv_with_project_root(load_dotenv, runtime):
273
+ """Test that loadenv loads .env file from project root when project exists."""
274
+ DummyTask._run_task = Mock()
275
+
276
+ # Create a temporary directory for the test
277
+ with tempfile.TemporaryDirectory() as temp_dir:
278
+ runtime.project_config._repo_info = {"root": temp_dir}
279
+
280
+ multi_cmd = task.RunTaskCommand()
281
+ with click.Context(multi_cmd, obj=runtime) as ctx:
282
+ cmd = multi_cmd.get_command(ctx, "dummy-task")
283
+ cmd.callback(runtime, "dummy-task", color="blue", loadenv=True)
284
+
285
+ # Verify load_dotenv was called with the correct path
286
+ expected_path = Path(temp_dir) / ".env"
287
+ load_dotenv.assert_called_once_with(expected_path)
288
+ DummyTask._run_task.assert_called_once()
289
+
290
+
291
+ @patch("cumulusci.cli.task.load_dotenv")
292
+ def test_task_run__loadenv_false(load_dotenv, runtime):
293
+ """Test that loadenv does not call load_dotenv when loadenv=False."""
294
+ DummyTask._run_task = Mock()
295
+
296
+ multi_cmd = task.RunTaskCommand()
297
+ with click.Context(multi_cmd, obj=runtime) as ctx:
298
+ cmd = multi_cmd.get_command(ctx, "dummy-task")
299
+ cmd.callback(runtime, "dummy-task", color="blue", loadenv=False)
300
+
301
+ # Verify load_dotenv was not called
302
+ load_dotenv.assert_not_called()
303
+ DummyTask._run_task.assert_called_once()
304
+
305
+
306
+ @patch("cumulusci.cli.task.load_dotenv")
307
+ def test_task_run__loadenv_not_provided(load_dotenv, runtime):
308
+ """Test that loadenv does not call load_dotenv when loadenv is not provided."""
309
+ DummyTask._run_task = Mock()
310
+
311
+ multi_cmd = task.RunTaskCommand()
312
+ with click.Context(multi_cmd, obj=runtime) as ctx:
313
+ cmd = multi_cmd.get_command(ctx, "dummy-task")
314
+ cmd.callback(runtime, "dummy-task", color="blue")
315
+
316
+ # Verify load_dotenv was not called
317
+ load_dotenv.assert_not_called()
318
+ DummyTask._run_task.assert_called_once()
319
+
320
+
321
+ @patch("cumulusci.cli.task.load_dotenv")
322
+ def test_task_run__loadenv_none_value(load_dotenv, runtime):
323
+ """Test that loadenv does not call load_dotenv when loadenv=None."""
324
+ DummyTask._run_task = Mock()
325
+
326
+ multi_cmd = task.RunTaskCommand()
327
+ with click.Context(multi_cmd, obj=runtime) as ctx:
328
+ cmd = multi_cmd.get_command(ctx, "dummy-task")
329
+ cmd.callback(runtime, "dummy-task", color="blue", loadenv=None)
330
+
331
+ # Verify load_dotenv was not called
332
+ load_dotenv.assert_not_called()
333
+ DummyTask._run_task.assert_called_once()
334
+
335
+
336
+ def test_get_default_command_options_includes_loadenv():
337
+ """Test that the loadenv option is included in default command options."""
338
+ opts = task.RunTaskCommand()._get_default_command_options(is_salesforce_task=False)
339
+
340
+ # Should have 5 global options including loadenv
341
+ assert len(opts) == 5
342
+
343
+ # Find the loadenv option
344
+ loadenv_opt = None
345
+ for opt in opts:
346
+ if hasattr(opt, "name") and opt.name == "loadenv":
347
+ loadenv_opt = opt
348
+ break
349
+
350
+ assert loadenv_opt is not None
351
+ assert loadenv_opt.is_flag is True
352
+ assert "Loads environment variables from the .env file" in loadenv_opt.help
cumulusci/cumulusci.yml CHANGED
@@ -795,6 +795,10 @@ tasks:
795
795
  description: Load Custom Settings specified in a YAML file to the target org
796
796
  class_path: cumulusci.tasks.salesforce.LoadCustomSettings
797
797
  group: "Data Operations"
798
+ sfdmu:
799
+ description: Execute SFDmu data migration with namespace injection support
800
+ class_path: cumulusci.tasks.sfdmu.sfdmu.SfdmuTask
801
+ group: "Data Operations"
798
802
  remove_metadata_xml_elements:
799
803
  description: Remove specified XML elements from one or more metadata files
800
804
  class_path: cumulusci.tasks.metadata.modify.RemoveElementsXPath
@@ -842,6 +846,14 @@ tasks:
842
846
  options:
843
847
  package_name: $project_config.project__package__name
844
848
  fail_on_error: False
849
+ update_named_credential:
850
+ class_path: cumulusci.tasks.salesforce.update_named_credential.UpdateNamedCredential
851
+ description: Update named credential parameters
852
+ group: Metadata Transformations
853
+ update_external_credential:
854
+ class_path: cumulusci.tasks.salesforce.update_external_credential.UpdateExternalCredential
855
+ description: Update external credential parameters
856
+ group: Metadata Transformations
845
857
 
846
858
  flows:
847
859
  ci_beta: