Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/darwin/create-universal-app.ts
5221 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import path from 'path';
7
import fs from 'fs';
8
import minimatch from 'minimatch';
9
import { makeUniversalApp } from 'vscode-universal-bundler';
10
11
const root = path.dirname(path.dirname(import.meta.dirname));
12
13
async function main(buildDir?: string) {
14
const arch = process.env['VSCODE_ARCH'];
15
16
if (!buildDir) {
17
throw new Error('Build dir not provided');
18
}
19
20
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8'));
21
const appName = product.nameLong + '.app';
22
const x64AppPath = path.join(buildDir, 'VSCode-darwin-x64', appName);
23
const arm64AppPath = path.join(buildDir, 'VSCode-darwin-arm64', appName);
24
const asarRelativePath = path.join('Contents', 'Resources', 'app', 'node_modules.asar');
25
const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName);
26
const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');
27
28
const filesToSkip = [
29
'**/CodeResources',
30
'**/Credits.rtf',
31
'**/policies/{*.mobileconfig,**/*.plist}',
32
];
33
34
await makeUniversalApp({
35
x64AppPath,
36
arm64AppPath,
37
asarPath: asarRelativePath,
38
outAppPath,
39
force: true,
40
mergeASARs: true,
41
x64ArchFiles: '{*/kerberos.node,**/extensions/microsoft-authentication/dist/libmsalruntime.dylib,**/extensions/microsoft-authentication/dist/msal-node-runtime.node}',
42
filesToSkipComparison: (file: string) => {
43
for (const expected of filesToSkip) {
44
if (minimatch(file, expected)) {
45
return true;
46
}
47
}
48
return false;
49
}
50
});
51
52
const productJson = JSON.parse(fs.readFileSync(productJsonPath, 'utf8'));
53
Object.assign(productJson, {
54
darwinUniversalAssetId: 'darwin-universal'
55
});
56
fs.writeFileSync(productJsonPath, JSON.stringify(productJson, null, '\t'));
57
}
58
59
if (import.meta.main) {
60
main(process.argv[2]).catch(err => {
61
console.error(err);
62
process.exit(1);
63
});
64
}
65
66