CoSpace Documentation

website·Indexed 31 days ago

https://aruniverse.github.io/cospace/

A monorepo tool designed to separate concerns within a codebase. Documentation includes getting started guides, CLI usage commands such as init, and an overview of how the tool manages monolithic codebases.

Tokens
1.2K
Snippets
6
Records
13
Agent score
75%

What's inside CoSpace

  1. Overview of the Smart Hotels IoT System

    Smart Hotels is a modular IoT solution designed for commercial hotel implementation to enhance guest experience and staff efficiency. The system allows hotels to customize their deployment by selecting specific IoT devices and peripherals based on price and functionality requirements. The architecture consists of a central server, a database, and individual Raspberry Pi controllers for each room.
  2. Overview of CoSpace for cross-monorepo linking

    CoSpace is a CLI tool that allows developers to link packages from multiple different (mono)repos together, eliminating the need to manually run npm link for shared packages across separate repositories. It functions as a wrapper around pnpm workspaces and the lage monorepo task runner, enabling users to manage dependencies and run commands across these linked repositories as if they were part of a single massive monorepo.
  3. Smart Hotels System Architecture and Data Flow

    The system operates using a coordinated flow between the server and room-level hardware:

    1. A request is initiated (via the iOS app).
    2. The server verifies room information against the database.
    3. The server passes the request to the specific Raspberry Pi assigned to that room.
    4. The Raspberry Pi runs a Python script to interpret JSON objects and trigger the corresponding physical peripherals in the room.
  4. Evaluate CoSpace for multi-repo dependency management

    CoSpace provides a way to link multiple mono-repositories using different package managers without manual linking.

    Advantages:

    • Simplifies linking multiple repositories that use different package managers.
    • Eliminates the need for manual linking commands like npm link, yarn link, or pnpm link.
    • Allows developers to ignore semver versioning, which is particularly useful for pre-release versions.
    • Helps verify that dependencies are configured correctly.

    Limitations:

    • Lockfiles are not automatically updated when a package's dependencies change. Users must manually update the lockfile outside of the CoSpace or perform a purge and re-installation.
  5. Smart Hotels User and Management Interfaces

    The system provides two primary interfaces:

    • iOS Application: The guest-facing interface used to control room devices and make service requests. It dynamically adapts its UI based on the specific devices available in the guest's assigned room.
    • Management Application: A web-based application for hotel staff to monitor guest information, view user requests by room, and track the status of operations (e.g., marking requests as 'in progress' or 'completed').
  6. Link repositories to a CoSpace workspace

    After initializing a CoSpace, follow these steps to link your repositories and set up the environment:

    1. Clone the target repositories into the repos subdirectory of your CoSpace project.
    2. Configure pnpm-workspace.yaml to define which packages should be included in the CoSpace.
    3. Update cospace.code-workspace to include the repositories in your VS Code multi-root workspace.
    4. Run the override command to link packages together.
    5. Install dependencies using pnpm.
    6. Build the packages using your monorepo task runner (lage is used by default, but turborepo is also supported).
    cd my-cospace
    pnpm exec cospace override
    pnpm install
    pnpm build
  7. Link an SDK across different teams using CoSpace

    CoSpace can be used to bridge the gap between different team repositories. For example, a Product team can use CoSpace to link an SDK maintained by a Platform team directly into their application repository for development and testing.
  8. Smart Hotels Technical Stack

    The Smart Hotels project is built using the following technologies:

    • Languages/Frameworks: Python, Vue JS
    • Infrastructure: Docker, AWS
    • Database: PostgreSQL
    • Hardware: Raspberry Pi
    • Client: iOS Application
  9. Recursively remove all node_modules in a CoSpace

    Use the purge command to recursively delete all node_modules directories throughout the CoSpace project to perform a clean slate of dependencies.
    npx cospace@latest purge
  10. Initialize a new CoSpace project

    Use the init command to set up a new CoSpace in a specific directory. This command generates all necessary configuration files. If no directory is specified, it defaults to the current working directory.
    npx cospace@latest init <dir>
  11. Force local package versions using override

    The override command automatically updates the pnpm.overrides section in the CoSpace's package.json. It configures the project to ignore semantic versioning (semver) and always use the local package version ("workspace:*") from the workspace. This is particularly useful when managing pre-release versions or mismatched major versions within a workspace.
    npx cospace@latest override