@@ -39,6 +39,10 @@ async function validateFlatOpts (opts: FlatOptions): Promise<ValidatedFlatOption
39
39
install = '/Applications' ;
40
40
}
41
41
42
+ if ( typeof opts . scripts === 'string' && opts . platform === 'mas' ) {
43
+ debugWarn ( 'Mac App Store packages cannot have `scripts`, ignoring option.' ) ;
44
+ }
45
+
42
46
return {
43
47
...opts ,
44
48
pkg,
@@ -49,27 +53,44 @@ async function validateFlatOpts (opts: FlatOptions): Promise<ValidatedFlatOption
49
53
50
54
/**
51
55
* This function returns a promise flattening the application.
52
- * @function
53
- * @param {Object } opts - Options.
54
- * @returns {Promise } Promise.
56
+ * @param opts - Options for building the .pkg archive
55
57
*/
56
58
async function buildApplicationPkg ( opts : ValidatedFlatOptions , identity : Identity ) {
57
- const componentPkgPath = path . join ( path . dirname ( opts . app ) , path . basename ( opts . app , '.app' ) + '-component.pkg' ) ;
58
- const pkgbuildArgs = [ '--install-location' , opts . install , '--component' , opts . app , componentPkgPath ] ;
59
- if ( opts . scripts ) {
60
- pkgbuildArgs . unshift ( '--scripts' , opts . scripts ) ;
61
- }
62
- debugLog ( 'Building component package... ' + opts . app ) ;
63
- await execFileAsync ( 'pkgbuild' , pkgbuildArgs ) ;
59
+ if ( opts . platform === 'mas' ) {
60
+ const args = [ '--component' , opts . app , opts . install , '--sign' , identity . name , opts . pkg ] ;
61
+ if ( opts . keychain ) {
62
+ args . unshift ( '--keychain' , opts . keychain ) ;
63
+ }
64
64
65
- const args = [ '--package' , componentPkgPath , opts . install , '--sign' , identity . name , opts . pkg ] ;
66
- if ( opts . keychain ) {
67
- args . unshift ( '--keychain' , opts . keychain ) ;
68
- }
65
+ debugLog ( 'Flattening Mac App Store package... ' + opts . app ) ;
66
+ await execFileAsync ( 'productbuild' , args ) ;
67
+ } else {
68
+ const componentPkgPath = path . join (
69
+ path . dirname ( opts . app ) ,
70
+ path . basename ( opts . app , '.app' ) + '-component.pkg'
71
+ ) ;
72
+ const pkgbuildArgs = [
73
+ '--install-location' ,
74
+ opts . install ,
75
+ '--component' ,
76
+ opts . app ,
77
+ componentPkgPath
78
+ ] ;
79
+ if ( opts . scripts ) {
80
+ pkgbuildArgs . unshift ( '--scripts' , opts . scripts ) ;
81
+ }
82
+ debugLog ( 'Building component package... ' + opts . app ) ;
83
+ await execFileAsync ( 'pkgbuild' , pkgbuildArgs ) ;
84
+
85
+ const args = [ '--package' , componentPkgPath , opts . install , '--sign' , identity . name , opts . pkg ] ;
86
+ if ( opts . keychain ) {
87
+ args . unshift ( '--keychain' , opts . keychain ) ;
88
+ }
69
89
70
- debugLog ( 'Flattening... ' + opts . app ) ;
71
- await execFileAsync ( 'productbuild' , args ) ;
72
- await execFileAsync ( 'rm' , [ componentPkgPath ] ) ;
90
+ debugLog ( 'Flattening OS X Installer package... ' + opts . app ) ;
91
+ await execFileAsync ( 'productbuild' , args ) ;
92
+ await execFileAsync ( 'rm' , [ componentPkgPath ] ) ;
93
+ }
73
94
}
74
95
75
96
/**
@@ -105,7 +126,10 @@ export async function buildPkg (_opts: FlatOptions) {
105
126
debugLog (
106
127
'Finding `Developer ID Application` certificate for distribution outside the Mac App Store...'
107
128
) ;
108
- identities = await findIdentities ( validatedOptions . keychain || null , 'Developer ID Installer:' ) ;
129
+ identities = await findIdentities (
130
+ validatedOptions . keychain || null ,
131
+ 'Developer ID Installer:'
132
+ ) ;
109
133
}
110
134
}
111
135
0 commit comments