Skip to content

feat: Implement Project and Workspace Initialization Commands #66

@drlucaa

Description

@drlucaa

To improve the onboarding experience for same, we need to provide a set of CLI commands that automate the creation of configuration files. Currently, users must manually create same.yaml or same.work.yaml.

This feature will introduce:

  1. same init: For initializing individual projects.
  2. same work init: For initializing a new monorepo workspace.
  3. same work add: For registering projects into an existing workspace.

The implementation must strictly adhere to the project's Clean Architecture rules, ensuring logic remains in the Core Domain while filesystem operations are handled by Adapters.

Goals

  • Provide a guided setup for new users.
  • Enable automatic discovery of workspaces during project initialization.
  • Ensure all configuration generated is deterministic and adheres to the latest schema version ("1").
  • Maintain architectural integrity by separating template logic from I/O.

Functional Requirements

same init

  • Standalone Mode: If no workspace is detected, create a same.yaml with sample tasks (build, test).
  • Workspace Mode: If a same.work.yaml is found in parent directories, require a --project name flag to ensure proper namespacing.
  • Auto-Registration: If run within a workspace, automatically append the project path to the projects list in same.work.yaml if missing.

same work Subcommands

  • init: Create a same.work.yaml in the current directory with default globs like packages/*.
  • add <path>: Resolve the relative path from the workspace root and add it to the projects array in the workspace config.

Acceptance Criteria

Architectural Constraints

  • Logic for YAML templates and validation must reside in internal/core/domain.
  • Filesystem writing must be implemented as an adapter in internal/adapters/fs.
  • CLI subcommands must be added to cli/cmd/same/commands/.

Behavior & Verification

  • Command fails with a structured error if the target file (same.yaml or same.work.yaml) already exists.
  • All generated files must pass a validation check by the existing ConfigLoader.
  • Verification commands succeed:
  • nix develop -c gofumpt -w ./cli
  • nix develop -c golangci-lint run ./cli/...
  • nix develop -c go test -race ./cli/....

Documentation

  • Update docs/configuration/same-yaml.mdx and docs/configuration/workspaces.mdx to reflect the new initialization workflow.
  • Add CLI reference documentation for init and work commands in docs/cli/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions