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