Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/win32/explorer-dll-fetcher.ts
5313 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
import fs from 'fs';
6
import debug from 'debug';
7
import path from 'path';
8
import { downloadArtifact } from '@electron/get';
9
import productJson from '../../product.json' with { type: 'json' };
10
11
interface ProductConfiguration {
12
quality?: string;
13
[key: string]: unknown;
14
}
15
16
const product: ProductConfiguration = productJson;
17
18
const d = debug('explorer-dll-fetcher');
19
20
export async function downloadExplorerDll(outDir: string, quality: string = 'stable', targetArch: string = 'x64'): Promise<void> {
21
const fileNamePrefix = quality === 'insider' ? 'code_insider' : 'code';
22
const fileName = `${fileNamePrefix}_explorer_command_${targetArch}.dll`;
23
24
if (!await fs.existsSync(outDir)) {
25
await fs.mkdirSync(outDir, { recursive: true });
26
}
27
28
// Read and parse checksums file
29
const checksumsFilePath = path.join(path.dirname(import.meta.dirname), 'checksums', 'explorer-dll.txt');
30
const checksumsContent = fs.readFileSync(checksumsFilePath, 'utf8');
31
const checksums: Record<string, string> = {};
32
33
checksumsContent.split('\n').forEach(line => {
34
const trimmedLine = line.trim();
35
if (trimmedLine) {
36
const [checksum, filename] = trimmedLine.split(/\s+/);
37
if (checksum && filename) {
38
checksums[filename] = checksum;
39
}
40
}
41
});
42
43
d(`downloading ${fileName}`);
44
const artifact = await downloadArtifact({
45
isGeneric: true,
46
version: 'v8.0.0-398351',
47
artifactName: fileName,
48
checksums,
49
mirrorOptions: {
50
mirror: 'https://github.com/microsoft/vscode-explorer-command/releases/download/',
51
customDir: 'v8.0.0-398351',
52
customFilename: fileName
53
}
54
});
55
56
d(`moving ${artifact} to ${outDir}`);
57
await fs.copyFileSync(artifact, path.join(outDir, fileName));
58
}
59
60
async function main(outputDir?: string): Promise<void> {
61
const arch = process.env['VSCODE_ARCH'];
62
63
if (!outputDir) {
64
throw new Error('Required build env not set');
65
}
66
67
await downloadExplorerDll(outputDir, product.quality, arch);
68
}
69
70
if (import.meta.main) {
71
main(process.argv[2]).catch(err => {
72
console.error(err);
73
process.exit(1);
74
});
75
}
76
77