Skip to content

Add auto-bootstrap in apm install when no apm.yml exists #14

@danielmeppiel

Description

@danielmeppiel

Summary

Enable apm install <package> to automatically create a minimal apm.yml when none exists, matching npm's behavior where npm install <package> works in any directory.

Current Behavior

$ apm install danielmeppiel/design-guidelines
Error: No apm.yml found. Run 'apm init' first.

Target Behavior

$ apm install danielmeppiel/design-guidelines
✨ Created apm.yml
✓ Added danielmeppiel/design-guidelines to apm.yml
✓ Installed danielmeppiel/design-guidelines

# apm.yml is now created with minimal config + the installed package

Implementation Requirements

Logic Flow

def install(ctx, packages, ...):
    apm_yml_exists = Path('apm.yml').exists()
    
    # NEW: Auto-bootstrap when packages specified but no apm.yml
    if not apm_yml_exists and packages:
        _create_minimal_apm_yml()  # Reuse from issue #13
        _rich_success("Created apm.yml", symbol="sparkles")
    
    # Error only when NO apm.yml AND NO packages
    if not apm_yml_exists and not packages:
        _rich_error("No apm.yml found")
        _rich_info("💡 Run 'apm init' to create one, or:")
        _rich_info("   apm install <org/repo> to auto-create + install")
        sys.exit(1)
    
    # Continue with existing install logic...

Integration with Issue #13

  • Reuse the minimal apm.yml generator from apm init refactor
  • Same auto-detection logic for project metadata
  • Consistent output format

Scenarios

Scenario 1: No apm.yml, WITH packages

cd existing-repo
apm install myorg/standards myorg/chatmodes
# ✨ Creates minimal apm.yml
# ✓ Adds both packages to dependencies
# ✓ Installs both packages

Scenario 2: No apm.yml, NO packages

cd existing-repo
apm install
# ❌ Error with helpful message pointing to:
#    - apm init (create empty manifest)
#    - apm install <package> (create + install)

Scenario 3: Has apm.yml (existing behavior preserved)

cd project-with-apm-yml
apm install                  # Install existing deps
apm install myorg/new-pkg    # Add to apm.yml + install

Acceptance Criteria

  • apm install org/pkg in directory without apm.yml creates minimal manifest
  • Auto-created apm.yml includes the specified package in dependencies
  • Success message clearly indicates apm.yml was created
  • apm install without packages and without apm.yml shows helpful error
  • Error message suggests both apm init and apm install <package> options
  • Existing behavior preserved when apm.yml already exists
  • Tests cover all scenarios (with/without manifest, with/without packages)
  • Integration with minimal init generator from issue Refactor apm init to minimal-only mode (breaking change) #13

Dependencies

Related

Part of npm-parity redesign for brownfield adoption

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions