Skip to content

Commit dcf3dbb

Browse files
committed
feat: LSTypeIsPackage for file associations
Closes #995
1 parent 090150c commit dcf3dbb

27 files changed

+438
-171
lines changed

docs/Options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ macOS and NSIS only. Array of option objects.
147147
| **name** | <a name="FileAssociation-name"></a>The name. e.g. `PNG`.
148148
| description | <a name="FileAssociation-description"></a>*windows-only.* The description.
149149
| icon | <a name="FileAssociation-icon"></a>The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon.
150-
| role | <a name="FileAssociation-role"></a>*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
150+
| role | <a name="FileAssociation-role"></a>*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`.
151+
| isPackage | <a name="FileAssociation-isPackage"></a>*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`.
151152

152153
<a name="LinuxBuildOptions"></a>
153154
### `.build.linux`

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"chromium-pickle-js": "^0.2.0",
6767
"cli-cursor": "^1.0.2",
6868
"cuint": "^0.2.2",
69-
"debug": "2.4.5",
69+
"debug": "2.5.1",
7070
"electron-download-tf": "3.1.0",
7171
"electron-macos-sign": "^1.3.4",
7272
"fs-extra-p": "^3.0.3",
@@ -97,10 +97,10 @@
9797
},
9898
"devDependencies": {
9999
"@develar/semantic-release": "^6.3.26",
100-
"@types/electron": "^1.4.29",
100+
"@types/electron": "^1.4.30",
101101
"@types/ini": "^1.3.29",
102-
"@types/jest": "^16.0.1",
103-
"@types/js-yaml": "^3.5.28",
102+
"@types/jest": "^16.0.2",
103+
"@types/js-yaml": "^3.5.29",
104104
"@types/source-map-support": "^0.2.28",
105105
"babel-plugin-array-includes": "^2.0.3",
106106
"babel-plugin-transform-async-to-module-method": "^6.16.0",
@@ -110,10 +110,8 @@
110110
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
111111
"decompress-zip": "^0.3.0",
112112
"depcheck": "^0.6.7",
113-
"diff": "^3.1.0",
114113
"jest-cli": "^18.0.0",
115114
"jest-environment-node-debug": "^0.0.2",
116-
"json8": "^0.9.2",
117115
"path-sort": "^0.1.0",
118116
"ts-babel": "^1.2.2",
119117
"tslint": "^4.1.1",

src/metadata.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,14 @@ export interface FileAssociation {
278278
readonly icon?: string
279279

280280
/*
281-
*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
281+
*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`.
282282
*/
283283
readonly role?: string
284+
285+
/*
286+
*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`.
287+
*/
288+
readonly isPackage?: boolean
284289
}
285290

286291
/*

src/packager/mac.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,17 @@ export async function createApp(packager: PlatformPackager<any>, appOutDir: stri
111111
await copyFile(customIcon, path.join(resourcesPath, iconFile))
112112
}
113113

114-
// todo rename electron.icns
115-
return <any>{
114+
const result = <any>{
116115
CFBundleTypeExtensions: extensions,
117116
CFBundleTypeName: fileAssociation.name,
118117
CFBundleTypeRole: fileAssociation.role || "Editor",
119118
CFBundleTypeIconFile: iconFile
120119
}
120+
121+
if (fileAssociation.isPackage) {
122+
result.LSTypeIsPackage = true
123+
}
124+
return result
121125
})
122126
}
123127

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
exports[`test cli 1`] = `
2+
Object {
3+
"draft": undefined,
4+
"extraMetadata": undefined,
5+
"prerelease": undefined,
6+
"publish": undefined,
7+
"targets": Map {
8+
Platform {
9+
"buildConfigurationKey": "mac",
10+
"name": "mac",
11+
"nodeName": "darwin",
12+
} => Map {
13+
1 => Array [],
14+
},
15+
},
16+
}
17+
`;
18+
19+
exports[`test cli 2`] = `
20+
Object {
21+
"draft": undefined,
22+
"extraMetadata": undefined,
23+
"prerelease": undefined,
24+
"publish": undefined,
25+
"targets": Map {
26+
Platform {
27+
"buildConfigurationKey": "mac",
28+
"name": "mac",
29+
"nodeName": "darwin",
30+
} => Map {
31+
1 => Array [
32+
"dir",
33+
],
34+
},
35+
},
36+
}
37+
`;
38+
39+
exports[`test cli 3`] = `
40+
Object {
41+
"draft": undefined,
42+
"extraMetadata": undefined,
43+
"prerelease": undefined,
44+
"publish": undefined,
45+
"targets": Map {
46+
Platform {
47+
"buildConfigurationKey": "linux",
48+
"name": "linux",
49+
"nodeName": "linux",
50+
} => Map {
51+
1 => Array [
52+
"dir",
53+
],
54+
},
55+
},
56+
}
57+
`;
58+
59+
exports[`test cli 4`] = `
60+
Object {
61+
"draft": undefined,
62+
"extraMetadata": undefined,
63+
"prerelease": undefined,
64+
"publish": undefined,
65+
"targets": Map {
66+
Platform {
67+
"buildConfigurationKey": "linux",
68+
"name": "linux",
69+
"nodeName": "linux",
70+
} => Map {
71+
1 => Array [],
72+
},
73+
},
74+
}
75+
`;
76+
77+
exports[`test cli 5`] = `
78+
Object {
79+
"draft": undefined,
80+
"extraMetadata": undefined,
81+
"prerelease": undefined,
82+
"publish": undefined,
83+
"targets": Map {
84+
Platform {
85+
"buildConfigurationKey": "win",
86+
"name": "windows",
87+
"nodeName": "win32",
88+
} => Map {
89+
1 => Array [],
90+
},
91+
},
92+
}
93+
`;
94+
95+
exports[`test cli 6`] = `
96+
Object {
97+
"draft": undefined,
98+
"extraMetadata": undefined,
99+
"prerelease": undefined,
100+
"publish": undefined,
101+
"targets": Map {
102+
Platform {
103+
"buildConfigurationKey": "mac",
104+
"name": "mac",
105+
"nodeName": "darwin",
106+
} => Map {
107+
1 => Array [],
108+
},
109+
Platform {
110+
"buildConfigurationKey": "linux",
111+
"name": "linux",
112+
"nodeName": "linux",
113+
} => Map {
114+
1 => Array [],
115+
},
116+
Platform {
117+
"buildConfigurationKey": "win",
118+
"name": "windows",
119+
"nodeName": "win32",
120+
} => Map {
121+
1 => Array [],
122+
},
123+
},
124+
}
125+
`;
126+
127+
exports[`test cli 7`] = `
128+
Object {
129+
"draft": undefined,
130+
"extraMetadata": undefined,
131+
"prerelease": undefined,
132+
"publish": undefined,
133+
"targets": Map {
134+
Platform {
135+
"buildConfigurationKey": "linux",
136+
"name": "linux",
137+
"nodeName": "linux",
138+
} => Map {
139+
0 => Array [
140+
"tar.gz",
141+
],
142+
},
143+
},
144+
}
145+
`;
146+
147+
exports[`test cli 8`] = `
148+
Object {
149+
"draft": undefined,
150+
"extraMetadata": undefined,
151+
"prerelease": undefined,
152+
"publish": undefined,
153+
"targets": Map {
154+
Platform {
155+
"buildConfigurationKey": "linux",
156+
"name": "linux",
157+
"nodeName": "linux",
158+
} => Map {
159+
1 => Array [
160+
"tar.gz",
161+
],
162+
},
163+
},
164+
}
165+
`;
166+
167+
exports[`test cli 9`] = `
168+
Object {
169+
"draft": undefined,
170+
"extraMetadata": undefined,
171+
"prerelease": undefined,
172+
"publish": undefined,
173+
"targets": Map {
174+
Platform {
175+
"buildConfigurationKey": "linux",
176+
"name": "linux",
177+
"nodeName": "linux",
178+
} => Map {
179+
1 => Array [
180+
"tar.gz",
181+
],
182+
},
183+
},
184+
}
185+
`;
186+
187+
exports[`test cli 10`] = `
188+
Object {
189+
"draft": undefined,
190+
"extraMetadata": undefined,
191+
"prerelease": undefined,
192+
"publish": undefined,
193+
"targets": Map {
194+
Platform {
195+
"buildConfigurationKey": "win",
196+
"name": "windows",
197+
"nodeName": "win32",
198+
} => Map {
199+
1 => Array [
200+
"tar.gz",
201+
],
202+
},
203+
},
204+
}
205+
`;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
exports[`test repo slug from APPVEYOR 1`] = `
2+
Object {
3+
"auth": null,
4+
"browsetemplate": "https://{domain}/{user}/{project}{/tree/committish}",
5+
"bugstemplate": "https://{domain}/{user}/{project}/issues",
6+
"committish": null,
7+
"default": "shortcut",
8+
"docstemplate": "https://{domain}/{user}/{project}{/tree/committish}#readme",
9+
"domain": "github.com",
10+
"filetemplate": "https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}",
11+
"gittemplate": "git://{auth@}{domain}/{user}/{project}.git{#committish}",
12+
"httpstemplate": "git+https://{auth@}{domain}/{user}/{project}.git{#committish}",
13+
"pathmatch": /^[\\/]([^\\/]+)[\\/]([^\\/]+?)(?:[.]git)?$/,
14+
"pathtemplate": "{user}/{project}{#committish}",
15+
"project": "travis-build",
16+
"protocols": Array [
17+
"git",
18+
"http",
19+
"git+ssh",
20+
"git+https",
21+
"ssh",
22+
"https",
23+
],
24+
"protocols_re": /^(git|http|git\\+ssh|git\\+https|ssh|https):$/,
25+
"shortcuttemplate": "{type}:{user}/{project}{#committish}",
26+
"sshtemplate": "git@{domain}:{user}/{project}.git{#committish}",
27+
"sshurltemplate": "git+ssh://git@{domain}/{user}/{project}.git{#committish}",
28+
"treepath": "tree",
29+
"type": "github",
30+
"user": "travis-ci",
31+
}
32+
`;
33+
34+
exports[`test repo slug from TRAVIS_REPO_SLUG 1`] = `
35+
Object {
36+
"auth": null,
37+
"browsetemplate": "https://{domain}/{user}/{project}{/tree/committish}",
38+
"bugstemplate": "https://{domain}/{user}/{project}/issues",
39+
"committish": null,
40+
"default": "shortcut",
41+
"docstemplate": "https://{domain}/{user}/{project}{/tree/committish}#readme",
42+
"domain": "github.com",
43+
"filetemplate": "https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}",
44+
"gittemplate": "git://{auth@}{domain}/{user}/{project}.git{#committish}",
45+
"httpstemplate": "git+https://{auth@}{domain}/{user}/{project}.git{#committish}",
46+
"pathmatch": /^[\\/]([^\\/]+)[\\/]([^\\/]+?)(?:[.]git)?$/,
47+
"pathtemplate": "{user}/{project}{#committish}",
48+
"project": "travis-build",
49+
"protocols": Array [
50+
"git",
51+
"http",
52+
"git+ssh",
53+
"git+https",
54+
"ssh",
55+
"https",
56+
],
57+
"protocols_re": /^(git|http|git\\+ssh|git\\+https|ssh|https):$/,
58+
"shortcuttemplate": "{type}:{user}/{project}{#committish}",
59+
"sshtemplate": "git@{domain}:{user}/{project}.git{#committish}",
60+
"sshurltemplate": "git+ssh://git@{domain}/{user}/{project}.git{#committish}",
61+
"treepath": "tree",
62+
"type": "github",
63+
"user": "travis-ci",
64+
}
65+
`;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
exports[`test extra metadata 1`] = `
2+
Object {
3+
"author": "Foo Bar <foo@example.com>",
4+
"build": Object {
5+
"appId": "org.electron-builder.testApp",
6+
"compression": "store",
7+
"electronVersion": "1.4.12",
8+
"iconUrl": "https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico",
9+
"linux": Object {
10+
"category": "Development",
11+
"packageCategory": "devel",
12+
},
13+
"mac": Object {
14+
"category": "your.app.category.type",
15+
},
16+
"npmRebuild": false,
17+
},
18+
"description": "Test Application (test quite \" #378)",
19+
"foo": Object {
20+
"bar": 12,
21+
"existingProp": 22,
22+
},
23+
"homepage": "http://foo.example.com",
24+
"license": "MIT",
25+
"name": "TestApp",
26+
"private": true,
27+
"productName": "Test App ß/W",
28+
"version": "1.1.0",
29+
}
30+
`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exports[`test link 1`] = `
2+
Object {
3+
"link": "index.js",
4+
}
5+
`;

0 commit comments

Comments
 (0)