Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/darwin/create-universal-app.ts
3520 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(__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
// TODO: Should we consider expanding this to other files in this area?
33
'**/node_modules/@parcel/node-addon-api/nothing.target.mk',
34
];
35
36
await makeUniversalApp({
37
x64AppPath,
38
arm64AppPath,
39
asarPath: asarRelativePath,
40
outAppPath,
41
force: true,
42
mergeASARs: true,
43
x64ArchFiles: '{*/kerberos.node,**/extensions/microsoft-authentication/dist/libmsalruntime.dylib,**/extensions/microsoft-authentication/dist/msal-node-runtime.node}',
44
filesToSkipComparison: (file: string) => {
45
for (const expected of filesToSkip) {
46
if (minimatch(file, expected)) {
47
return true;
48
}
49
}
50
return false;
51
}
52
});
53
54
const productJson = JSON.parse(fs.readFileSync(productJsonPath, 'utf8'));
55
Object.assign(productJson, {
56
darwinUniversalAssetId: 'darwin-universal'
57
});
58
fs.writeFileSync(productJsonPath, JSON.stringify(productJson, null, '\t'));
59
}
60
61
if (require.main === module) {
62
main(process.argv[2]).catch(err => {
63
console.error(err);
64
process.exit(1);
65
});
66
}
67
68