Skip to content

feat: Support single-canister project definitions#11

Merged
rikonor merged 57 commits intomainfrom
or-single-canister
Jun 16, 2025
Merged

feat: Support single-canister project definitions#11
rikonor merged 57 commits intomainfrom
or-single-canister

Conversation

@rikonor
Copy link
Copy Markdown
Contributor

@rikonor rikonor commented Jun 6, 2025

Summary:

This PR enhances the project manifest (icp.yaml) to support a simplified configuration for single-canister projects. Previously, only a canisters list was supported. Now, a project with a single canister can be defined directly using a top-level canister key, improving developer experience for simpler projects. The existing canisters key for multi-canister projects remains fully supported.

Detailed Changes:

  • Flexible Project Manifest (lib/icp-project/src/model.rs):

    • The RawProjectManifest struct was modified to use #[serde(flatten)] on an Option<RawCanistersField>. This allows serde to deserialize from either a canister key (for a single canister) or a canisters key (for multiple canisters) at the top level of icp.yaml.
    • The ProjectManifest::load function was updated to handle this Option. If neither canister nor canisters is present in the manifest, it now correctly falls back to the default behavior of searching for canisters with the canisters/* glob pattern.
  • Unified Build Logic (bin/icp-cli/src/commands/build.rs):

    • The build command's execution logic was updated to normalize the canister configuration. It now uses a match statement to handle both the single-canister (CanistersField::Canister) and multi-canister (CanistersField::Canisters) variants, creating a unified list of canisters to be built.
    • This ensures that the downstream build process can iterate over a consistent data structure, regardless of how the canisters are defined in the manifest.

Configuration Examples:

This change makes both of the following icp.yaml formats valid:

Single-Canister Project (New):

canister:
  name: my-canister
  build:
    adapter:
      type: script
      command: echo "building my canister"

Multi-Canister Project (Existing):

canisters:
  - canisters/*

This PR description was generated by Roo.

rikonor added 30 commits May 29, 2025 12:17
@rikonor rikonor requested a review from a team as a code owner June 6, 2025 23:47
@rikonor rikonor requested review from a user, adamspofford-dfinity and raymondk June 6, 2025 23:53
Comment thread bin/icp-cli/src/commands/build.rs Outdated
Comment thread lib/icp-canister/src/model.rs Outdated
Comment thread lib/icp-project/src/model.rs
Comment thread lib/icp-project/src/model.rs
Comment thread lib/icp-project/src/model.rs Outdated
Comment thread lib/icp-project/src/model.rs Outdated
@rikonor rikonor force-pushed the or-single-canister branch from 4e693e7 to 0101cba Compare June 12, 2025 14:19
@rikonor rikonor force-pushed the or-single-canister branch from bcc0a63 to ac8776d Compare June 12, 2025 19:17
@rikonor rikonor force-pushed the or-single-canister branch from ac8776d to 1eb02f7 Compare June 13, 2025 15:30
@rikonor rikonor force-pushed the or-single-canister branch from 1eb02f7 to e03ffd9 Compare June 13, 2025 17:06
@rikonor rikonor force-pushed the or-adapters branch 2 times, most recently from 2d66a9b to fbbbd14 Compare June 13, 2025 19:38
Base automatically changed from or-adapters to main June 16, 2025 14:33
@rikonor rikonor merged commit 48db907 into main Jun 16, 2025
11 checks passed
@rikonor rikonor deleted the or-single-canister branch June 16, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant