Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/upload-sourcemaps.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 es from 'event-stream';
8
import Vinyl from 'vinyl';
9
import vfs from 'vinyl-fs';
10
import * as util from '../lib/util.ts';
11
import { getProductionDependencies } from '../lib/dependencies.ts';
12
import { ClientAssertionCredential } from '@azure/identity';
13
import Stream from 'stream';
14
import azure from 'gulp-azure-storage';
15
16
const root = path.dirname(path.dirname(import.meta.dirname));
17
const commit = process.env['BUILD_SOURCEVERSION'];
18
const credential = new ClientAssertionCredential(process.env['AZURE_TENANT_ID']!, process.env['AZURE_CLIENT_ID']!, () => Promise.resolve(process.env['AZURE_ID_TOKEN']!));
19
20
// optionally allow to pass in explicit base/maps to upload
21
const [, , base, maps] = process.argv;
22
23
function src(base: string, maps = `${base}/**/*.map`) {
24
return vfs.src(maps, { base })
25
.pipe(es.mapSync((f: Vinyl) => {
26
f.path = `${f.base}/core/${f.relative}`;
27
return f;
28
}));
29
}
30
31
function main(): Promise<void> {
32
const sources: Stream[] = [];
33
34
// vscode client maps (default)
35
if (!base) {
36
const vs = src('out-vscode-min'); // client source-maps only
37
sources.push(vs);
38
39
const productionDependencies = getProductionDependencies(root);
40
const productionDependenciesSrc = productionDependencies.map((d: string) => path.relative(root, d)).map((d: string) => `./${d}/**/*.map`);
41
const nodeModules = vfs.src(productionDependenciesSrc, { base: '.' })
42
.pipe(util.cleanNodeModules(path.join(root, 'build', '.moduleignore')))
43
.pipe(util.cleanNodeModules(path.join(root, 'build', `.moduleignore.${process.platform}`)));
44
sources.push(nodeModules);
45
46
const extensionsOut = vfs.src(['.build/extensions/**/*.js.map', '!**/node_modules/**'], { base: '.build' });
47
sources.push(extensionsOut);
48
}
49
50
// specific client base/maps
51
else {
52
sources.push(src(base, maps));
53
}
54
55
return new Promise((c, e) => {
56
es.merge(...sources)
57
.pipe(es.through(function (data: Vinyl) {
58
console.log('Uploading Sourcemap', data.relative); // debug
59
this.emit('data', data);
60
}))
61
.pipe(azure.upload({
62
account: process.env.AZURE_STORAGE_ACCOUNT,
63
credential,
64
container: '$web',
65
prefix: `sourcemaps/${commit}/`
66
}))
67
.on('end', () => c())
68
.on('error', (err) => e(err));
69
});
70
}
71
72
main().catch(err => {
73
console.error(err);
74
process.exit(1);
75
});
76
77
78