-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cli): UTExportedTypeDeclarations support for file associations #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: coderabbit_full_base_featcli_utexportedtypedeclarations_support_for_file_associations_pr12
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri-cli": minor:feat | ||
| "@tauri-apps/cli": minor:feat | ||
| --- | ||
|
|
||
| Added support to defining the content type of the declared file association on macOS (maps to LSItemContentTypes property). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri-cli": minor:feat | ||
| "@tauri-apps/cli": minor:feat | ||
| --- | ||
|
|
||
| Added support to defining the metadata for custom types declared in `tauri.conf.json > bundle > fileAssociations > exportedType` via the `UTExportedTypeDeclarations` Info.plist property. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "tauri-utils": minor:feat | ||
| --- | ||
|
|
||
| Added `FileAssociation::exported_type` and `FileAssociation::content_types` for better support to defining custom types on macOS. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -268,29 +268,89 @@ fn create_info_plist( | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(associations) = settings.file_associations() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let exported_associations = associations | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter_map(|association| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association.exported_type.as_ref().map(|exported_type| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut dict = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTTypeIdentifier".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| exported_type.identifier.clone().into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(description) = &association.description { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert("UTTypeDescription".into(), description.clone().into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(content_types) = &association.content_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTTypeConformsTo".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(content_types.iter().map(|s| s.clone().into()).collect()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut specification = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| specification.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "public.filename-extension".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|s| s.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(mime_type) = &association.mime_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| specification.insert("public.mime-type".into(), mime_type.clone().into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert("UTTypeTagSpecification".into(), specification.into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Dictionary(dict) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect::<Vec<_>>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if !exported_associations.is_empty() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "UTExportedTypeDeclarations".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(exported_associations), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| plist.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleDocumentTypes".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| associations | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|association| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut dict = plist::Dictionary::new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeExtensions".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|ext| ext.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if association.ext.is_empty() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeExtensions".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .ext | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|ext| ext.to_string().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+328
to
+339
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inverted condition inserts an empty array when The condition 🐛 Proposed fix- if association.ext.is_empty() {
+ if association.content_types.is_none() && !association.ext.is_empty() {
dict.insert(
"CFBundleTypeExtensions".into(),
plist::Value::Array(
association
.ext
.iter()
.map(|ext| ext.to_string().into())
.collect(),
),
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(content_types) = &association.content_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "LSItemContentTypes".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plist::Value::Array(content_types.iter().map(|s| s.to_string().into()).collect()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| dict.insert( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "CFBundleTypeName".into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| association | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .as_ref() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .unwrap_or(&association.ext[0].0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .expect("File association must have a name") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .to_string() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .into(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
348
to
356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, check the exact code at the mentioned lines
echo "=== Code at lines 348-356 ==="
sed -n '345,360p' crates/tauri-bundler/src/bundle/macos/app.rs
echo -e "\n=== File size check ==="
wc -l crates/tauri-bundler/src/bundle/macos/app.rsRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 632 🏁 Script executed: #!/bin/bash
# Find FileAssociation struct definition
echo "=== Searching for FileAssociation struct ==="
rg -n "struct FileAssociation" --type rust -A 10Repository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 1417 🏁 Script executed: #!/bin/bash
# Search for validation of file associations
echo "=== Searching for file_associations validation ==="
rg -n "file_associations" --type rust -B 3 -A 3 | head -100Repository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 7702 🏁 Script executed: #!/bin/bash
# Check for any validation or deserialization logic
echo "=== Searching for validation or required patterns ==="
rg -n "FileAssociation.*name|name.*required|validate.*file.*assoc" --type rust -iRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 717 🏁 Script executed: #!/bin/bash
# Search for where FileAssociation.name gets defaulted
echo "=== Searching for default name logic ==="
rg -n "ext\[0\]|FileAssociation.*default" --type rust -B 3 -A 3Repository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 1070 🏁 Script executed: #!/bin/bash
# Check the full FileAssociation struct definition
echo "=== Full FileAssociation struct ==="
sed -n '1177,1210p' crates/tauri-utils/src/config.rsRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 2035 🏁 Script executed: #!/bin/bash
# Look for post-processing or validation of FileAssociation
echo "=== Search for processing of file associations ==="
rg -n "association\.name|for.*association" --type rust crates/tauri-bundler/src/bundle/macos/app.rs -B 2 -A 2Repository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 145 🏁 Script executed: #!/bin/bash
# Check git history for this specific code section to see if it changed
echo "=== Git log for the app.rs file ==="
git log --oneline -n 20 crates/tauri-bundler/src/bundle/macos/app.rsRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 149 🏁 Script executed: #!/bin/bash
# Let's search more broadly in the macos app.rs file for how associations are handled
echo "=== Full context around line 348 in macos/app.rs ==="
sed -n '265,285p' crates/tauri-bundler/src/bundle/macos/app.rsRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 947 🏁 Script executed: #!/bin/bash
# Search for where the default to ext[0] might be applied
echo "=== Searching for ext field access with name ==="
rg -n "\.ext\[|ext\.get|\.name.*=|name.*=.*ext" --type rust -B 2 -A 2 | head -80Repository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 6179 🏁 Script executed: #!/bin/bash
# Check the entire block where associations are processed
echo "=== Full association processing in macos/app.rs ==="
sed -n '270,360p' crates/tauri-bundler/src/bundle/macos/app.rsRepository: agentic-review-benchmarks/tauri-combined-coderabbit Length of output: 3069 The The 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong source for
UTTypeConformsTo— usesassociation.content_typesinstead ofexported_type.conforms_to.According to the
ExportedFileAssociationstruct definition,conforms_tois the field meant to populateUTTypeConformsTo. The current code incorrectly usesassociation.content_types, which is intended forLSItemContentTypesinCFBundleDocumentTypes.🐛 Proposed fix
🤖 Prompt for AI Agents