MCPcopy
hub / github.com/desktop/desktop / packageApp

Function packageApp

script/build.ts:132–242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 })
131
132function packageApp() {
133 // not sure if this is needed anywhere, so I'm just going to inline it here
134 // for now and see what the future brings...
135 const toPackagePlatform = (platform: NodeJS.Platform) => {
136 if (platform === 'win32' || platform === 'darwin' || platform === 'linux') {
137 return platform
138 }
139 throw new Error(
140 `Unable to convert to platform for electron-packager: '${process.platform}`
141 )
142 }
143
144 const toPackageArch = (targetArch: string | undefined): OfficialArch => {
145 if (targetArch === undefined) {
146 targetArch = os.arch()
147 }
148
149 if (targetArch === 'arm64' || targetArch === 'x64') {
150 return targetArch
151 }
152
153 throw new Error(
154 `Building Desktop for architecture '${targetArch}' is not supported`
155 )
156 }
157
158 // get notarization deets, unless we're not going to publish this
159 const osxNotarize = isPublishableBuild ? getNotarizationOptions() : undefined
160
161 if (
162 isPublishableBuild &&
163 isGitHubActions() &&
164 process.platform === 'darwin' &&
165 osxNotarize === undefined
166 ) {
167 // we can't publish a mac build without these
168 throw new Error(
169 'Unable to retreive appleId and/or appleIdPassword to notarize macOS build'
170 )
171 }
172
173 const iconPath = getIconDirectory()
174 const assetsCarPath = join(iconPath, 'Assets.car')
175 assert(
176 existsSync(assetsCarPath),
177 `Unable to find Assets.car at ${assetsCarPath}`
178 )
179
180 return packager({
181 name: getExecutableName(),
182 platform: toPackagePlatform(process.platform),
183 arch: toPackageArch(process.env.TARGET_ARCH),
184 asar: false, // TODO: Probably wanna enable this down the road.
185 out: getDistRoot(),
186 icon: join(iconPath, 'icon-logo'),
187 extraResource: [assetsCarPath],
188 dir: outRoot,
189 overwrite: true,

Callers 1

build.tsFile · 0.85

Calls 10

isGitHubActionsFunction · 0.90
getIconDirectoryFunction · 0.90
getExecutableNameFunction · 0.90
getDistRootFunction · 0.90
getBundleIDFunction · 0.90
getCompanyNameFunction · 0.90
getProductNameFunction · 0.90
getNotarizationOptionsFunction · 0.85
toPackagePlatformFunction · 0.85
toPackageArchFunction · 0.85

Tested by

no test coverage detected