2022-10-21 21:17:30 +03:00
|
|
|
/*---------------------------------------------------------------------------------------------
|
|
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
import * as fs from 'fs';
|
2022-10-21 21:17:30 +03:00
|
|
|
import * as debug from 'debug';
|
|
|
|
import * as extract from 'extract-zip';
|
|
|
|
import * as path from 'path';
|
|
|
|
import { downloadArtifact } from '@electron/get';
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
const root = path.dirname(path.dirname(__dirname));
|
|
|
|
|
2022-10-21 21:17:30 +03:00
|
|
|
const d = debug('explorer-appx-fetcher');
|
|
|
|
|
|
|
|
export async function downloadExplorerAppx(outDir: string, quality: string = 'stable', targetArch: string = 'x64'): Promise<void> {
|
|
|
|
const fileNamePrefix = quality === 'insider' ? 'code_insiders' : 'code';
|
|
|
|
const fileName = `${fileNamePrefix}_explorer_${targetArch}.zip`;
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
if (await fs.existsSync(path.resolve(outDir, 'resources.pri'))) {
|
2022-10-21 21:17:30 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
if (!await fs.existsSync(outDir)) {
|
|
|
|
await fs.mkdirSync(outDir, { recursive: true });
|
2022-10-21 21:17:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
d(`downloading ${fileName}`);
|
|
|
|
const artifact = await downloadArtifact({
|
|
|
|
isGeneric: true,
|
|
|
|
version: '3.0.4',
|
|
|
|
artifactName: fileName,
|
|
|
|
unsafelyDisableChecksums: true,
|
|
|
|
mirrorOptions: {
|
|
|
|
mirror: 'https://github.com/microsoft/vscode-explorer-command/releases/download/',
|
|
|
|
customDir: '3.0.4',
|
|
|
|
customFilename: fileName
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
d(`unpacking from ${fileName}`);
|
2023-04-02 10:35:39 +03:00
|
|
|
await extract(artifact, { dir: fs.realpathSync(outDir) });
|
2022-10-21 21:17:30 +03:00
|
|
|
}
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
async function main(outputDir?: string): Promise<void> {
|
2023-10-16 14:28:09 +03:00
|
|
|
const arch = process.env['VSCODE_ARCH'];
|
2022-10-21 21:17:30 +03:00
|
|
|
|
|
|
|
if (!outputDir) {
|
|
|
|
throw new Error('Required build env not set');
|
|
|
|
}
|
|
|
|
|
2023-04-02 10:35:39 +03:00
|
|
|
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8'));
|
2022-10-21 21:17:30 +03:00
|
|
|
await downloadExplorerAppx(outputDir, (product as any).quality, arch);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (require.main === module) {
|
2023-04-02 10:35:39 +03:00
|
|
|
main(process.argv[2]).catch(err => {
|
2022-10-21 21:17:30 +03:00
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
});
|
|
|
|
}
|