5
5
6
6
import fs from 'fs' ;
7
7
import path from 'path' ;
8
- import codesign from 'electron- osx-sign' ;
8
+ import { sign , SignOptions } from '@ electron/ osx-sign' ;
9
9
import { spawn } from '@malept/cross-spawn-promise' ;
10
10
11
11
const root = path . dirname ( path . dirname ( __dirname ) ) ;
12
+ const baseDir = path . dirname ( __dirname ) ;
13
+ const product = JSON . parse ( fs . readFileSync ( path . join ( root , 'product.json' ) , 'utf8' ) ) ;
14
+ const helperAppBaseName = product . nameShort ;
15
+ const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app' ;
16
+ const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app' ;
17
+ const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app' ;
12
18
13
19
function getElectronVersion ( ) : string {
14
20
const npmrc = fs . readFileSync ( path . join ( root , '.npmrc' ) , 'utf8' ) ;
15
21
const target = / ^ t a r g e t = " ( .* ) " $ / m. exec ( npmrc ) ! [ 1 ] ;
16
22
return target ;
17
23
}
18
24
25
+ function getEntitlementsForFile ( filePath : string ) : string {
26
+ if ( filePath . includes ( gpuHelperAppName ) ) {
27
+ return path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-gpu-entitlements.plist' ) ;
28
+ } else if ( filePath . includes ( rendererHelperAppName ) ) {
29
+ return path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-renderer-entitlements.plist' ) ;
30
+ } else if ( filePath . includes ( pluginHelperAppName ) ) {
31
+ return path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-plugin-entitlements.plist' ) ;
32
+ }
33
+ return path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'app-entitlements.plist' ) ;
34
+ }
35
+
19
36
async function main ( buildDir ?: string ) : Promise < void > {
20
37
const tempDir = process . env [ 'AGENT_TEMPDIRECTORY' ] ;
21
38
const arch = process . env [ 'VSCODE_ARCH' ] ;
@@ -29,60 +46,22 @@ async function main(buildDir?: string): Promise<void> {
29
46
throw new Error ( '$AGENT_TEMPDIRECTORY not set' ) ;
30
47
}
31
48
32
- const product = JSON . parse ( fs . readFileSync ( path . join ( root , 'product.json' ) , 'utf8' ) ) ;
33
- const baseDir = path . dirname ( __dirname ) ;
34
49
const appRoot = path . join ( buildDir , `VSCode-darwin-${ arch } ` ) ;
35
50
const appName = product . nameLong + '.app' ;
36
- const appFrameworkPath = path . join ( appRoot , appName , 'Contents' , 'Frameworks' ) ;
37
- const helperAppBaseName = product . nameShort ;
38
- const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app' ;
39
- const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app' ;
40
- const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app' ;
41
51
const infoPlistPath = path . resolve ( appRoot , appName , 'Contents' , 'Info.plist' ) ;
42
52
43
- const defaultOpts : codesign . SignOptions = {
53
+ const appOpts : SignOptions = {
44
54
app : path . join ( appRoot , appName ) ,
45
55
platform : 'darwin' ,
46
- entitlements : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'app-entitlements.plist' ) ,
47
- 'entitlements-inherit' : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'app-entitlements.plist' ) ,
48
- hardenedRuntime : true ,
49
- 'pre-auto-entitlements' : false ,
50
- 'pre-embed-provisioning-profile' : false ,
56
+ optionsForFile : ( filePath ) => ( {
57
+ entitlements : getEntitlementsForFile ( filePath ) ,
58
+ hardenedRuntime : true ,
59
+ } ) ,
60
+ preAutoEntitlements : false ,
61
+ preEmbedProvisioningProfile : false ,
51
62
keychain : path . join ( tempDir , 'buildagent.keychain' ) ,
52
63
version : getElectronVersion ( ) ,
53
64
identity,
54
- 'gatekeeper-assess' : false
55
- } ;
56
-
57
- const appOpts = {
58
- ...defaultOpts ,
59
- // TODO(deepak1556): Incorrectly declared type in electron-osx-sign
60
- ignore : ( filePath : string ) => {
61
- return filePath . includes ( gpuHelperAppName ) ||
62
- filePath . includes ( rendererHelperAppName ) ||
63
- filePath . includes ( pluginHelperAppName ) ;
64
- }
65
- } ;
66
-
67
- const gpuHelperOpts : codesign . SignOptions = {
68
- ...defaultOpts ,
69
- app : path . join ( appFrameworkPath , gpuHelperAppName ) ,
70
- entitlements : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-gpu-entitlements.plist' ) ,
71
- 'entitlements-inherit' : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-gpu-entitlements.plist' ) ,
72
- } ;
73
-
74
- const rendererHelperOpts : codesign . SignOptions = {
75
- ...defaultOpts ,
76
- app : path . join ( appFrameworkPath , rendererHelperAppName ) ,
77
- entitlements : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-renderer-entitlements.plist' ) ,
78
- 'entitlements-inherit' : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-renderer-entitlements.plist' ) ,
79
- } ;
80
-
81
- const pluginHelperOpts : codesign . SignOptions = {
82
- ...defaultOpts ,
83
- app : path . join ( appFrameworkPath , pluginHelperAppName ) ,
84
- entitlements : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-plugin-entitlements.plist' ) ,
85
- 'entitlements-inherit' : path . join ( baseDir , 'azure-pipelines' , 'darwin' , 'helper-plugin-entitlements.plist' ) ,
86
65
} ;
87
66
88
67
// Only overwrite plist entries for x64 and arm64 builds,
@@ -111,10 +90,7 @@ async function main(buildDir?: string): Promise<void> {
111
90
] ) ;
112
91
}
113
92
114
- await codesign . signAsync ( gpuHelperOpts ) ;
115
- await codesign . signAsync ( rendererHelperOpts ) ;
116
- await codesign . signAsync ( pluginHelperOpts ) ;
117
- await codesign . signAsync ( appOpts as any ) ;
93
+ await sign ( appOpts ) ;
118
94
}
119
95
120
96
if ( require . main === module ) {
0 commit comments