Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/apm_cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@
@click.option(
"--plugin", is_flag=True, help="Initialize as plugin author (creates plugin.json + apm.yml)"
)
@click.option(
"--marketplace", "marketplace_flag", is_flag=True,
help="Seed apm.yml with a 'marketplace:' authoring block",
)
@click.option("--verbose", "-v", is_flag=True, help="Show detailed output")
@click.pass_context
def init(ctx, project_name, yes, plugin, verbose):
def init(ctx, project_name, yes, plugin, marketplace_flag, verbose):
"""Initialize a new APM project (like npm init).

Creates a minimal apm.yml with auto-detected metadata.
With --plugin, also creates plugin.json for plugin authors.
With --marketplace, also seeds apm.yml with a marketplace authoring block.
"""
logger = CommandLogger("init", verbose=verbose)
try:
Expand Down Expand Up @@ -110,6 +115,22 @@ def init(ctx, project_name, yes, plugin, verbose):
if plugin:
_create_plugin_json(config)

# Append marketplace authoring block when requested.
if marketplace_flag:
from ..marketplace.init_template import render_marketplace_block
apm_yml_path = Path.cwd() / APM_YML_FILENAME
try:
existing = apm_yml_path.read_text(encoding="utf-8")
if not existing.endswith("\n"):
existing += "\n"
block = render_marketplace_block(owner=config.get("name"))
apm_yml_path.write_text(existing + "\n" + block, encoding="utf-8")
Comment on lines +124 to +127

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init --marketplace passes owner=config.get("name") into render_marketplace_block(), which makes the marketplace owner default to the project name (and generates https://github.com/<project> URLs). It would be safer to leave owner unset (use the template default) or derive it from git remote / a dedicated flag instead.

Copilot uses AI. Check for mistakes.
except OSError as exc:
logger.warning(
f"Failed to append marketplace block to apm.yml: {exc}",
symbol="warning",
)

logger.success("APM project initialized successfully!")

# Display created file info
Expand Down
Loading
Loading