Skip to content

feat: Customizations files#574

Draft
adamspofford-dfinity wants to merge 1 commit into
spofford/app-bundlefrom
spofford/app-bundle-customize
Draft

feat: Customizations files#574
adamspofford-dfinity wants to merge 1 commit into
spofford/app-bundlefrom
spofford/app-bundle-customize

Conversation

@adamspofford-dfinity
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for project-level customization prompts driven by an icp_customize.yaml file, and ensures this customization manifest is preserved when projects are bundled so deployments can keep the same interactive customization behavior.

Changes:

  • Introduces operations::customize to load icp_customize.yaml, prompt for values, and substitute them into Candid init args.
  • Updates deploy to apply customization-derived init args with defined precedence relative to CLI --args/--args-file and manifest init_args.
  • Updates bundle to include icp_customize.yaml at the archive root and adds a regression test for this behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/icp-cli/tests/bundle_tests.rs Adds test asserting icp_customize.yaml is bundled verbatim at archive root.
crates/icp-cli/src/operations/mod.rs Registers the new customize operations module.
crates/icp-cli/src/operations/customize.rs Implements customize manifest parsing, interactive prompting, and init-args field substitution with unit tests.
crates/icp-cli/src/operations/bundle.rs Reads and appends icp_customize.yaml into the bundle archive and adds an error variant.
crates/icp-cli/src/commands/deploy.rs Collects customization overrides pre-build and applies them between CLI args and manifest init args.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +230 to +238
let customize_path = project_dir.join(CUSTOMIZE_FILE);
let customize_bytes = match fs::read(&customize_path) {
Ok(bytes) => Some(bytes),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,
Err(source) => {
return Err(BundleError::ReadCustomize {
path: customize_path,
source,
});
Comment on lines +124 to +131
// Collect interactive init arg customizations before the build so the user
// fills in all prompts upfront, uninterrupted by build output.
let customize_overrides: Arc<HashMap<String, IDLArgs>> = {
let project = ctx.project.load().await.map_err(|e| anyhow!(e))?;
let customize_path = project.dir.join(customize::CUSTOMIZE_FILE);
match customize::load_customize_manifest(&project.dir).map_err(|e| anyhow!(e))? {
None => Arc::new(HashMap::new()),
Some(manifest) => {
Comment on lines +110 to +111
#[snafu(transparent)]
Substitute { source: SubstituteError },
Comment on lines +129 to +148
if let Some(rest) = s.strip_prefix('.') {
let fields = if rest.is_empty() {
vec![]
} else {
rest.split('.').map(str::to_string).collect()
};
return Ok(FieldPath {
arg_index: 0,
fields,
});
}
let mut iter = s.split('.');
let first = iter.next().expect("split always yields at least one part");
let arg_index = first
.parse::<usize>()
.map_err(|_| ParseFieldPathError::InvalidIndex {
path_str: s.to_string(),
})?;
let fields = iter.map(str::to_string).collect();
Ok(FieldPath { arg_index, fields })
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.

2 participants