Module init

Module init 

Source
Expand description

Init command implementation.

This module implements the workspace init command which initializes a workspace for changeset-based version management.

§What

Provides the init command that:

  • Detects workspace structure (single package or monorepo)
  • Collects configuration through interactive prompts or CLI flags
  • Generates repo.config.format file
  • Creates necessary directory structure (.changesets, .changesets/history, .workspace-backups)
  • Sets up .gitignore entries
  • Creates example changeset file with documentation

§How

The command flow:

  1. Validates the target directory is a Node.js project
  2. Detects if it’s a monorepo or single package
  3. Checks for existing configuration
  4. Collects configuration via prompts or flags
  5. Generates configuration file
  6. Creates directory structure
  7. Updates .gitignore
  8. Creates example changeset
  9. Outputs success message

§Why

Initialization must be robust to handle various project structures, provide helpful defaults, and ensure proper setup for the changeset workflow. Clear output and documentation help users understand the setup.

Functions§

execute_init
Execute the init command.