pjkm.cli.commands.project¶
Project lifecycle commands — init, add, update, upgrade, link, preview.
Functions¶
|
Initialize a new project from a template. |
|
Add package groups to an existing project. |
|
Re-render templates on an existing project. |
|
Upgrade dependencies for applied groups to their latest defined versions. |
|
Link/refresh tool configuration from group definitions. |
|
Preview what a project would look like without creating anything. |
Module Contents¶
- pjkm.cli.commands.project.init(name=typer.Argument(help='Project name'), archetype=typer.Option('', '--archetype', '-a', help='Project archetype: single-package, service, poly-repo, script-tool'), group=typer.Option([], '--group', '-g', help='Package groups to include (repeatable)'), recipe_name=typer.Option('', '--recipe', '-r', help='Use a named recipe (overrides --archetype and --group)'), directory=typer.Option('', '--dir', '-d', help='Target directory (project will be created as a subdirectory)'), dry_run=typer.Option(False, '--dry-run', help='Show what would be done without making changes'), author=typer.Option('', '--author', help='Author name (overrides defaults)'), email=typer.Option('', '--email', help='Author email (overrides defaults)'))[source]¶
Initialize a new project from a template.
Options not provided on the command line are filled from defaults. Set defaults in ~/.pjkmrc.yaml or ./.pjkmrc.yaml. Use –recipe for a pre-configured archetype + groups combo.
- pjkm.cli.commands.project.add(group=typer.Option(..., '--group', '-g', help='Package group(s) to add (repeatable)'), directory=typer.Option('', '--dir', '-d', help='Project directory containing pyproject.toml (default: cwd)'))[source]¶
Add package groups to an existing project.
Reads the existing pyproject.toml, resolves the requested groups (including transitive dependencies), merges new dependencies and tool config, renders scaffolded files, and updates [tool.pjkm.groups].
- pjkm.cli.commands.project.update(directory=typer.Option('', '--dir', '-d', help='Project directory to update (default: current directory)'), dry_run=typer.Option(False, '--dry-run', help='Show what would be done without making changes'))[source]¶
Re-render templates on an existing project.
Reads [tool.pjkm] from pyproject.toml to find the archetype and applied groups, then re-renders the base and archetype templates. Useful after updating pjkm to pick up new CI workflows, gitignore improvements, etc.
If .copier-answers.yml exists, uses Copier’s update mechanism. Otherwise, falls back to re-rendering with overwrite.
- pjkm.cli.commands.project.upgrade(group=typer.Option([], '--group', '-g', help='Specific group(s) to upgrade (default: all applied groups)'), directory=typer.Option('', '--dir', '-d', help='Project directory (default: cwd)'), latest=typer.Option(False, '--latest', help="Remove version pins and use latest (e.g. 'pkg' instead of 'pkg>=1.0')"), refresh_tools=typer.Option(False, '--refresh-tools', help='Re-apply tool config from group definitions (overwrites customizations)'), dry_run=typer.Option(False, '--dry-run', help='Show what would change without modifying files'), install=typer.Option(True, '--install/--no-install', help='Run `pdm install` after upgrading (default: yes)'))[source]¶
Upgrade dependencies for applied groups to their latest defined versions.
Reads [tool.pjkm.groups] from pyproject.toml, loads the current group definitions, and replaces dependency version pins with the latest from the group YAML files. Optionally re-applies tool config sections.
Examples
pjkm upgrade # upgrade all group deps pjkm upgrade -g logging -g testing # upgrade specific groups pjkm upgrade –latest # strip version pins entirely pjkm upgrade –refresh-tools # also re-apply [tool.*] config pjkm upgrade –dry-run # preview changes
- pjkm.cli.commands.project.link_tool(tool_name=typer.Argument(help='Tool to configure (e.g. ruff, pyright, pytest)'), directory=typer.Option('', '--dir', '-d', help='Project directory (default: cwd)'), dry_run=typer.Option(False, '--dry-run', help='Preview changes without writing'))[source]¶
Link/refresh tool configuration from group definitions.
Reads the applied groups and re-applies their [tool.*] config sections to pyproject.toml. Useful after updating pjkm or group definitions to pick up new recommended settings.
Examples
pjkm link ruff # refresh [tool.ruff.*] config from groups pjkm link pytest # refresh [tool.pytest.*] config pjkm link pyright # refresh [tool.pyright] config
- pjkm.cli.commands.project.preview(archetype=typer.Argument('', help='Project archetype (optional when --recipe is given)'), group=typer.Option([], '--group', '-g', help='Package groups to preview (repeatable)'), recipe_name=typer.Option('', '--recipe', '-r', help='Use a named recipe instead of specifying groups'))[source]¶
Preview what a project would look like without creating anything.
Shows the full file tree, dependencies, tool config, and workflows that would be generated. Great for trying different combinations before committing to pjkm init.
Examples
pjkm preview service -g api -g database -g docker pjkm preview –recipe python-lib pjkm preview –recipe fastapi-service