feat: Customizations files#574
Draft
adamspofford-dfinity wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
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::customizeto loadicp_customize.yaml, prompt for values, and substitute them into Candid init args. - Updates
deployto apply customization-derived init args with defined precedence relative to CLI--args/--args-fileand manifestinit_args. - Updates
bundleto includeicp_customize.yamlat 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 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.