Skip to content

Commit

Permalink
feat(mac): add LSHandlerRank
Browse files Browse the repository at this point in the history
Close #4614
  • Loading branch information
mifi authored Apr 29, 2020
1 parent 82d6602 commit 5129266
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,11 @@
"default": "Editor",
"description": "*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Corresponds to `CFBundleTypeRole`.",
"type": "string"
},
"rank": {
"default": "Default",
"description": "*macOS-only* The app’s rank with respect to the type. The value can be `Owner`, `Default`, `Alternate`, or `None`. Corresponds to `LSHandlerRank`.",
"type": "string"
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/electron/electronMac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name || extensions[0],
CFBundleTypeRole: fileAssociation.role || "Editor",
LSHandlerRank: fileAssociation.rank || "Default",
CFBundleTypeIconFile: iconFile
} as any

Expand Down
6 changes: 6 additions & 0 deletions packages/app-builder-lib/src/options/FileAssociation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ export interface FileAssociation {
* *macOS-only* Whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file. Corresponds to `LSTypeIsPackage`.
*/
readonly isPackage?: boolean

/**
* *macOS-only* The app’s rank with respect to the type. The value can be `Owner`, `Default`, `Alternate`, or `None`. Corresponds to `LSHandlerRank`.
* @default Default
*/
readonly rank?: string
}
3 changes: 3 additions & 0 deletions test/snapshots/mac/macPackagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Object {
"CFBundleTypeIconFile": "foo.icns",
"CFBundleTypeName": "Foo",
"CFBundleTypeRole": "Viewer",
"LSHandlerRank": "Default",
},
Object {
"CFBundleTypeExtensions": Array [
Expand All @@ -77,6 +78,7 @@ Object {
"CFBundleTypeIconFile": "Test App ßW.icns",
"CFBundleTypeName": "Boo",
"CFBundleTypeRole": "Shell",
"LSHandlerRank": "Owner",
"LSTypeIsPackage": true,
},
Object {
Expand All @@ -86,6 +88,7 @@ Object {
"CFBundleTypeIconFile": "someFoo.icns",
"CFBundleTypeName": "Bar",
"CFBundleTypeRole": "Shell",
"LSHandlerRank": "Default",
},
],
"CFBundleExecutable": "Test App ßW",
Expand Down
2 changes: 2 additions & 0 deletions test/src/mac/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ test.ifMac("one-package", app({
ext: "boo",
name: "Boo",
role: "Shell",
rank: "Owner",
isPackage: true,
},
{
ext: "bar",
name: "Bar",
role: "Shell",
rank: "Default",
// If I specify `fileAssociations.icon` as `build/foo.icns` will it know to use `build/foo.ico` for Windows?
icon: "someFoo.ico"
},
Expand Down

0 comments on commit 5129266

Please sign in to comment.