Skip to content

Commit fa630a7

Browse files
committed
fix(extensions): omit config hint when no scaffolding fails
Show the generic configuration hint only alongside an actual scaffolding failure. Cover undeclared, empty, and missing-template configurations through the CLI. Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
1 parent e210504 commit fa630a7

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

‎src/specify_cli/extensions/command_add.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,6 @@ def extension_add(
348348
"Verify the extension manifest and template files."
349349
)
350350

351-
# Only warn when configuration is actually unresolved. Scaffolding that
352-
# deployed or preserved every template has already answered this, and an
353-
# extension without provides.config has nothing to configure; the blanket
354-
# warning contradicted the output directly above it.
355-
if failed or not (deployed or skipped):
356351
console.print("\n[yellow]⚠[/yellow] Configuration may be required")
357352
console.print(f" Check: {config_home}/")
358353

‎tests/specify_cli/extensions/test_command_add.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,35 @@
4040
class TestExtensionAddCLI:
4141
"""CLI tests for ``specify extension add``."""
4242

43+
@pytest.mark.parametrize(
44+
("config", "warns"),
45+
[
46+
pytest.param({}, False, id="undeclared"),
47+
pytest.param({"config": []}, False, id="empty"),
48+
pytest.param(
49+
{"config": [{"name": "test-ext-config.yml", "template": "missing.yml"}]},
50+
True,
51+
id="missing-template",
52+
),
53+
],
54+
)
55+
def test_add_dev_warns_only_when_config_scaffolding_fails(
56+
self, extension_dir, project_dir, valid_manifest_data, config, warns
57+
):
58+
valid_manifest_data["provides"].update(config)
59+
(extension_dir / "extension.yml").write_text(
60+
yaml.safe_dump(valid_manifest_data), encoding="utf-8"
61+
)
62+
63+
with patch.object(Path, "cwd", return_value=project_dir):
64+
result = CliRunner().invoke(app, ["extension", "add", "--dev", str(extension_dir)])
65+
66+
assert result.exit_code == 0, result.output
67+
output = strip_ansi(result.output)
68+
assert "Extension installed successfully" in output
69+
assert ("Configuration may be required" in output) == warns, output
70+
assert ("Config templates not scaffolded" in output) == warns, output
71+
4372
@pytest.mark.parametrize("command", [
4473
pytest.param(["speckit.test-ext.hello"], id="list"),
4574
pytest.param({"name": "speckit.test-ext.hello"}, id="mapping"),
@@ -722,6 +751,7 @@ def fake_install_from_zip(
722751
patch("specify_cli.authentication.http.open_url", return_value=FakeResponse(_MINIMAL_ZIP_BYTES)), \
723752
patch("specify_cli.extensions._commands._safe_open_download_zip", side_effect=_open_test_download_zip), \
724753
patch.object(ExtensionManager, "install_from_zip", fake_install_from_zip), \
754+
patch.object(ExtensionManager, "scaffold_config", return_value=([], [], ["test-ext-config.yml"])), \
725755
patch.object(ExtensionRegistry, "get", return_value={}):
726756
result = runner.invoke(
727757
app,

0 commit comments

Comments
 (0)