void/build/darwin/create-universal-app.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2024-09-11 02:37:36 +00:00
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2025-03-01 02:01:53 +00:00
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
2024-09-11 02:37:36 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2025-03-01 02:01:53 +00:00
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const minimatch_1 = __importDefault(require("minimatch"));
2024-09-11 02:37:36 +00:00
const vscode_universal_bundler_1 = require("vscode-universal-bundler");
2025-03-01 02:01:53 +00:00
const root = path_1.default.dirname(path_1.default.dirname(__dirname));
2024-09-11 02:37:36 +00:00
async function main(buildDir) {
const arch = process.env['VSCODE_ARCH'];
if (!buildDir) {
throw new Error('Build dir not provided');
}
2025-03-01 02:01:53 +00:00
const product = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'product.json'), 'utf8'));
2024-09-11 02:37:36 +00:00
const appName = product.nameLong + '.app';
2025-03-01 02:01:53 +00:00
const x64AppPath = path_1.default.join(buildDir, 'VSCode-darwin-x64', appName);
const arm64AppPath = path_1.default.join(buildDir, 'VSCode-darwin-arm64', appName);
const asarRelativePath = path_1.default.join('Contents', 'Resources', 'app', 'node_modules.asar');
const outAppPath = path_1.default.join(buildDir, `VSCode-darwin-${arch}`, appName);
const productJsonPath = path_1.default.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');
2024-09-11 02:37:36 +00:00
const filesToSkip = [
'**/CodeResources',
'**/Credits.rtf',
2025-03-01 02:01:53 +00:00
// TODO: Should we consider expanding this to other files in this area?
'**/node_modules/@parcel/node-addon-api/nothing.target.mk'
2024-09-11 02:37:36 +00:00
];
await (0, vscode_universal_bundler_1.makeUniversalApp)({
x64AppPath,
arm64AppPath,
2024-09-24 04:46:08 +00:00
asarPath: asarRelativePath,
2024-09-11 02:37:36 +00:00
outAppPath,
force: true,
2024-09-24 04:46:08 +00:00
mergeASARs: true,
2024-09-11 02:37:36 +00:00
x64ArchFiles: '*/kerberos.node',
filesToSkipComparison: (file) => {
for (const expected of filesToSkip) {
2025-03-01 02:01:53 +00:00
if ((0, minimatch_1.default)(file, expected)) {
2024-09-11 02:37:36 +00:00
return true;
}
}
return false;
}
});
2025-03-01 02:01:53 +00:00
const productJson = JSON.parse(fs_1.default.readFileSync(productJsonPath, 'utf8'));
2024-09-11 02:37:36 +00:00
Object.assign(productJson, {
darwinUniversalAssetId: 'darwin-universal'
});
2025-03-01 02:01:53 +00:00
fs_1.default.writeFileSync(productJsonPath, JSON.stringify(productJson, null, '\t'));
2024-09-11 02:37:36 +00:00
}
if (require.main === module) {
main(process.argv[2]).catch(err => {
console.error(err);
process.exit(1);
});
}
//# sourceMappingURL=create-universal-app.js.map