Skip to content

Commit

Permalink
feat: LSTypeIsPackage for file associations
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Dec 21, 2016
1 parent 0ce1a3c commit 0165657
Show file tree
Hide file tree
Showing 27 changed files with 509 additions and 176 deletions.
3 changes: 2 additions & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ macOS and NSIS only. Array of option objects.
| **name** | <a name="FileAssociation-name"></a>The name. e.g. `PNG`.
| description | <a name="FileAssociation-description"></a>*windows-only.* The description.
| 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.
| 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`.
| 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`.
| 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`.

<a name="LinuxBuildOptions"></a>
### `.build.linux`
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"chromium-pickle-js": "^0.2.0",
"cli-cursor": "^1.0.2",
"cuint": "^0.2.2",
"debug": "2.4.5",
"debug": "2.5.1",
"electron-download-tf": "3.1.0",
"electron-macos-sign": "^1.3.4",
"fs-extra-p": "^3.0.3",
Expand Down Expand Up @@ -97,10 +97,10 @@
},
"devDependencies": {
"@develar/semantic-release": "^6.3.26",
"@types/electron": "^1.4.29",
"@types/electron": "^1.4.30",
"@types/ini": "^1.3.29",
"@types/jest": "^16.0.1",
"@types/js-yaml": "^3.5.28",
"@types/jest": "^16.0.2",
"@types/js-yaml": "^3.5.29",
"@types/source-map-support": "^0.2.28",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-async-to-module-method": "^6.16.0",
Expand All @@ -110,10 +110,8 @@
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
"decompress-zip": "^0.3.0",
"depcheck": "^0.6.7",
"diff": "^3.1.0",
"jest-cli": "^18.0.0",
"jest-environment-node-debug": "^0.0.2",
"json8": "^0.9.2",
"path-sort": "^0.1.0",
"ts-babel": "^1.2.2",
"tslint": "^4.1.1",
Expand Down
7 changes: 6 additions & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,14 @@ export interface FileAssociation {
readonly icon?: string

/*
*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
*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`.
*/
readonly role?: string

/*
*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
}

/*
Expand Down
8 changes: 6 additions & 2 deletions src/packager/mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ export async function createApp(packager: PlatformPackager<any>, appOutDir: stri
await copyFile(customIcon, path.join(resourcesPath, iconFile))
}

// todo rename electron.icns
return <any>{
const result = <any>{
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name,
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: iconFile
}

if (fileAssociation.isPackage) {
result.LSTypeIsPackage = true
}
return result
})
}

Expand Down
281 changes: 281 additions & 0 deletions test/out/__snapshots__/BuildTest.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
exports[`test cli 1`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 2`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [
"dir",
],
},
},
}
`;

exports[`test cli 3`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [
"dir",
],
},
},
}
`;

exports[`test cli 4`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [
"dir",
],
},
},
}
`;

exports[`test cli 5`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
1 => Array [
"dir",
],
},
},
}
`;

exports[`test cli 6`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 7`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 8`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 9`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "win",
"name": "windows",
"nodeName": "win32",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 10`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "mac",
"name": "mac",
"nodeName": "darwin",
} => Map {
1 => Array [],
},
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
1 => Array [],
},
Platform {
"buildConfigurationKey": "win",
"name": "windows",
"nodeName": "win32",
} => Map {
1 => Array [],
},
},
}
`;

exports[`test cli 11`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
0 => Array [
"tar.gz",
],
},
},
}
`;

exports[`test cli 12`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
1 => Array [
"tar.gz",
],
},
},
}
`;

exports[`test cli 13`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "linux",
"name": "linux",
"nodeName": "linux",
} => Map {
1 => Array [
"tar.gz",
],
},
},
}
`;

exports[`test cli 14`] = `
Object {
"draft": undefined,
"extraMetadata": undefined,
"prerelease": undefined,
"publish": undefined,
"targets": Map {
Platform {
"buildConfigurationKey": "win",
"name": "windows",
"nodeName": "win32",
} => Map {
1 => Array [
"tar.gz",
],
},
},
}
`;
Loading

0 comments on commit 0165657

Please sign in to comment.