@@ -3,7 +3,7 @@ import util from 'util';
3
3
import codesign from 'node-codesign' ;
4
4
import { notarize as nodeNotarize } from 'electron-notarize' ;
5
5
import Config from './config' ;
6
- import { createTarball } from './tarball' ;
6
+ import { createTarball , TarballFile } from './tarball' ;
7
7
8
8
/**
9
9
* Notarizes the zipped mongosh. Will send the tarball to Apple and poll apple
@@ -29,31 +29,29 @@ const notarize = (bundleId: string, artifact: string, user: string, password: st
29
29
* @param {string } executable - The mongosh executable.
30
30
* @param {string } identity - The apple developer identity.
31
31
*/
32
- const sign = ( executable : string , identity : string ) => {
33
- return new Promise ( ( resolve , reject ) => {
34
- codesign ( { identity : identity , appPath : executable } , ( err , paths ) => {
35
- if ( err ) {
36
- reject ( err ) ;
37
- } else {
38
- resolve ( err ) ;
39
- }
40
- } ) ;
32
+ const sign = ( executable : string , identity : string , entitlementsFile : string ) => {
33
+ return util . promisify ( codesign ) ( {
34
+ identity : identity ,
35
+ appPath : executable ,
36
+ entitlements : entitlementsFile ,
41
37
} ) ;
42
38
} ;
43
39
44
- const publish = async ( executable : string , artifact : string , platform : string , config : Config ) => {
45
- console . log ( 'mongosh: removing unsigned tarball:' , artifact ) ;
46
- await util . promisify ( fs . unlink ) ( artifact ) ;
40
+ const macOSSignAndNotarize = async (
41
+ executable : string ,
42
+ config : Config ,
43
+ runCreateTarball : ( ) => Promise < TarballFile > ) : Promise < TarballFile > => {
44
+
47
45
console . log ( 'mongosh: signing:' , executable ) ;
48
- await sign ( executable , config . appleAppIdentity ) .
49
- catch ( ( e ) => { console . error ( e ) ; throw e ; } ) ;
46
+ await sign ( executable , config . appleAppIdentity , config . entitlementsFile ) ;
50
47
console . log ( 'mongosh: notarizing and creating tarball:' , executable ) ;
51
- await createTarball ( executable , config . outputDir , platform , config . version , config . rootDir ) ;
48
+ const artifact = await runCreateTarball ( ) ;
52
49
await notarize (
53
50
config . bundleId ,
54
- artifact ,
51
+ artifact . path ,
55
52
config . appleUser ,
56
- config . applePassword ) . catch ( ( e ) => { console . error ( e ) ; throw e ; } ) ;
53
+ config . applePassword ) ;
54
+ return artifact ;
57
55
} ;
58
56
59
- export default publish ;
57
+ export default macOSSignAndNotarize ;
0 commit comments