create-awesome-python-app 0.2.8__tar.gz → 0.2.9__tar.gz

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.
Files changed (21) hide show
  1. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/PKG-INFO +1 -1
  2. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/pyproject.toml +1 -1
  3. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/src/create_awesome_python_app/__init__.py +1 -1
  4. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/src/create_awesome_python_app/cli.py +17 -1
  5. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_cli.py +104 -0
  6. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/.gitignore +0 -0
  7. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/README.md +0 -0
  8. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/assets/hero.svg +0 -0
  9. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/src/create_awesome_python_app/cache.py +0 -0
  10. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/src/create_awesome_python_app/catalog.py +0 -0
  11. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/src/create_awesome_python_app/prompt_style.py +0 -0
  12. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/conftest.py +0 -0
  13. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_cache_cmds.py +0 -0
  14. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_cache_env.py +0 -0
  15. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_catalog.py +0 -0
  16. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_catalog_fetch.py +0 -0
  17. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_catalog_resolve.py +0 -0
  18. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_cpa_templates_integration.py +0 -0
  19. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_flags.py +0 -0
  20. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_interactive.py +0 -0
  21. {create_awesome_python_app-0.2.8 → create_awesome_python_app-0.2.9}/tests/test_smoke.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: create-awesome-python-app
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: Composable scaffolding CLI for production-ready Python apps
5
5
  Project-URL: Homepage, https://github.com/Create-Python-App/create-python-app
6
6
  Project-URL: Repository, https://github.com/Create-Python-App/create-python-app
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "create-awesome-python-app"
3
- version = "0.2.8"
3
+ version = "0.2.9"
4
4
  description = "Composable scaffolding CLI for production-ready Python apps"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,3 +1,3 @@
1
1
  """Create Awesome Python App CLI."""
2
2
 
3
- __version__ = "0.2.8"
3
+ __version__ = "0.2.9"
@@ -76,10 +76,15 @@ def _expand_variadic_option(argv: list[str], option: str) -> list[str]:
76
76
 
77
77
  Typer's ``list[str]`` Option only accepts one value per flag. Commander uses
78
78
  ``--addons [extensions...]``, so users naturally write space-separated lists.
79
+
80
+ When ``project_directory`` comes *after* options and no positional was seen
81
+ yet, peel the final trailing token at EOS back as the directory so that
82
+ ``--addons a --addons b /tmp/app`` does not treat ``/tmp/app`` as an addon.
79
83
  """
80
84
  out: list[str] = []
81
85
  i = 0
82
86
  prefix = option + "="
87
+ saw_positional = False
83
88
  while i < len(argv):
84
89
  arg = argv[i]
85
90
  if arg == option:
@@ -88,17 +93,26 @@ def _expand_variadic_option(argv: list[str], option: str) -> list[str]:
88
93
  while i < len(argv) and not argv[i].startswith("-"):
89
94
  values.append(argv[i])
90
95
  i += 1
96
+ ended_at_eos = i >= len(argv)
97
+ trailing: str | None = None
98
+ if ended_at_eos and not saw_positional and len(values) >= 2:
99
+ trailing = values.pop()
91
100
  if not values:
92
101
  out.append(option)
93
102
  else:
94
103
  for value in values:
95
104
  out.extend([option, value])
105
+ if trailing is not None:
106
+ out.append(trailing)
107
+ saw_positional = True
96
108
  continue
97
109
  if arg.startswith(prefix):
98
110
  value = arg[len(prefix) :]
99
111
  out.extend([option, value] if value else [option])
100
112
  i += 1
101
113
  continue
114
+ if i > 0 and not arg.startswith("-"):
115
+ saw_positional = True
102
116
  out.append(arg)
103
117
  i += 1
104
118
  return out
@@ -106,7 +120,9 @@ def _expand_variadic_option(argv: list[str], option: str) -> list[str]:
106
120
 
107
121
  def _preprocess_cli_argv(argv: list[str] | None = None) -> list[str]:
108
122
  """Apply argv rewrites needed before Typer parses the CLI."""
109
- out = _preprocess_fixture_argv(argv)
123
+ raw = list(sys.argv if argv is None else argv)
124
+ # Pass an explicit list so fixture preprocess does not mutate sys.argv early.
125
+ out = _preprocess_fixture_argv(raw)
110
126
  out = _expand_variadic_option(out, "--addons")
111
127
  out = _expand_variadic_option(out, "--extend")
112
128
  if argv is None:
@@ -320,6 +320,59 @@ def test_expand_variadic_addons_and_extend() -> None:
320
320
  ]
321
321
 
322
322
 
323
+ def test_expand_preserves_trailing_project_directory() -> None:
324
+ """Repeated ``--addons`` with directory last must not swallow the path."""
325
+ from create_awesome_python_app.cli import _preprocess_cli_argv
326
+
327
+ assert _preprocess_cli_argv(
328
+ [
329
+ "cpa",
330
+ "--addons",
331
+ "github-setup",
332
+ "--addons",
333
+ "fastapi-docker",
334
+ "/tmp/app",
335
+ ]
336
+ ) == [
337
+ "cpa",
338
+ "--addons",
339
+ "github-setup",
340
+ "--addons",
341
+ "fastapi-docker",
342
+ "/tmp/app",
343
+ ]
344
+ # CI-shaped argv: flags between last addon and directory.
345
+ assert (
346
+ _preprocess_cli_argv(
347
+ [
348
+ "cpa",
349
+ "--template",
350
+ "fastapi-starter",
351
+ "--addons",
352
+ "fastapi-docker",
353
+ "--addons",
354
+ "github-setup",
355
+ "--no-interactive",
356
+ "--no-install",
357
+ "--force",
358
+ "/tmp/app",
359
+ ]
360
+ )[-1]
361
+ == "/tmp/app"
362
+ )
363
+ # Space-separated addons with directory last (no prior positional).
364
+ assert _preprocess_cli_argv(
365
+ ["cpa", "--addons", "fastapi-docker", "github-setup", "/tmp/app"]
366
+ ) == [
367
+ "cpa",
368
+ "--addons",
369
+ "fastapi-docker",
370
+ "--addons",
371
+ "github-setup",
372
+ "/tmp/app",
373
+ ]
374
+
375
+
323
376
  def test_space_separated_addons_after_project_directory(
324
377
  tmp_path: Path, monkeypatch
325
378
  ) -> None:
@@ -373,6 +426,57 @@ def test_space_separated_addons_after_project_directory(
373
426
  assert any("github-setup" in a for a in addons)
374
427
 
375
428
 
429
+ def test_repeated_addons_with_directory_last(tmp_path: Path, monkeypatch) -> None:
430
+ """``--addons a --addons b <dir>`` must keep ``<dir>`` as project_directory."""
431
+ from create_awesome_python_app.cli import _preprocess_cli_argv
432
+
433
+ tpl = tmp_path / "tpl"
434
+ tpl.mkdir()
435
+ target = tmp_path / "app"
436
+ captured: dict[str, object] = {}
437
+
438
+ async def fake_check_for_latest_version(_package_name):
439
+ return None
440
+
441
+ async def fake_create_python_app(project_directory, options, *_args, **_kwargs):
442
+ captured["project_directory"] = project_directory
443
+ captured["options"] = options
444
+
445
+ monkeypatch.setattr(
446
+ "create_awesome_python_app.cli.check_for_latest_version",
447
+ fake_check_for_latest_version,
448
+ )
449
+ monkeypatch.setattr(
450
+ "create_awesome_python_app.cli.create_python_app",
451
+ fake_create_python_app,
452
+ )
453
+
454
+ argv = _preprocess_cli_argv(
455
+ [
456
+ "cpa",
457
+ "--template",
458
+ f"file://{tpl}",
459
+ "--addons",
460
+ "fastapi-docker",
461
+ "--addons",
462
+ "github-setup",
463
+ "--no-install",
464
+ "--no-interactive",
465
+ str(target),
466
+ ]
467
+ )
468
+ result = runner.invoke(app, argv[1:])
469
+ text = (result.stdout or "") + (result.stderr or "")
470
+ assert result.exit_code == 0, text
471
+ assert captured["project_directory"] == str(target)
472
+ options = captured["options"]
473
+ assert isinstance(options, dict)
474
+ addons = options["addons"]
475
+ assert isinstance(addons, list)
476
+ assert len(addons) == 2
477
+ assert not any(str(target) in a for a in addons)
478
+
479
+
376
480
  def test_preprocess_fixture_argv_bare_and_with_dir() -> None:
377
481
  from create_awesome_python_app.cli import _FIXTURE_AUTO, _preprocess_fixture_argv
378
482