Web: publish web files.txt (#140163)

* build: publish web files.txt

* fix cdn
This commit is contained in:
João Moreno 2022-01-05 17:31:08 +00:00 committed by GitHub
parent e3b2098f06
commit 44452718b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 26 deletions

View file

@ -6,6 +6,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const es = require("event-stream");
const Vinyl = require("vinyl");
const vfs = require("vinyl-fs");
const util = require("../lib/util");
const filter = require("gulp-filter");
@ -15,25 +16,41 @@ const azure = require('gulp-azure-storage');
const root = path.dirname(path.dirname(__dirname));
const commit = util.getVersion(root);
const credential = new identity_1.ClientSecretCredential(process.env['AZURE_TENANT_ID'], process.env['AZURE_CLIENT_ID'], process.env['AZURE_CLIENT_SECRET']);
function main() {
return new Promise((c, e) => {
async function main() {
const files = [];
const options = {
account: process.env.AZURE_STORAGE_ACCOUNT,
credential,
container: process.env.VSCODE_QUALITY,
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
};
await new Promise((c, e) => {
vfs.src('**', { cwd: '../vscode-web', base: '../vscode-web', dot: true })
.pipe(filter(f => !f.isDirectory()))
.pipe(gzip({ append: false }))
.pipe(es.through(function (data) {
console.log('Uploading CDN file:', data.relative); // debug
console.log('Uploading:', data.relative); // debug
files.push(data.relative);
this.emit('data', data);
}))
.pipe(azure.upload({
account: process.env.AZURE_STORAGE_ACCOUNT,
credential,
container: process.env.VSCODE_QUALITY,
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
}))
.pipe(azure.upload(options))
.on('end', () => c())
.on('error', (err) => e(err));
});
await new Promise((c, e) => {
const listing = new Vinyl({
path: 'files.txt',
contents: Buffer.from(files.join('\n')),
stat: { mode: 0o666 }
});
console.log(`Uploading: files.txt (${files.length} files)`); // debug
es.readArray([listing])
.pipe(gzip({ append: false }))
.pipe(azure.upload(options))
.on('end', () => c())
.on('error', (err) => e(err));
});

View file

@ -19,25 +19,44 @@ const root = path.dirname(path.dirname(__dirname));
const commit = util.getVersion(root);
const credential = new ClientSecretCredential(process.env['AZURE_TENANT_ID']!, process.env['AZURE_CLIENT_ID']!, process.env['AZURE_CLIENT_SECRET']!);
function main(): Promise<void> {
return new Promise((c, e) => {
async function main(): Promise<void> {
const files: string[] = [];
const options = {
account: process.env.AZURE_STORAGE_ACCOUNT,
credential,
container: process.env.VSCODE_QUALITY,
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
};
await new Promise<void>((c, e) => {
vfs.src('**', { cwd: '../vscode-web', base: '../vscode-web', dot: true })
.pipe(filter(f => !f.isDirectory()))
.pipe(gzip({ append: false }))
.pipe(es.through(function (data: Vinyl) {
console.log('Uploading CDN file:', data.relative); // debug
console.log('Uploading:', data.relative); // debug
files.push(data.relative);
this.emit('data', data);
}))
.pipe(azure.upload({
account: process.env.AZURE_STORAGE_ACCOUNT,
credential,
container: process.env.VSCODE_QUALITY,
prefix: commit + '/',
contentSettings: {
contentEncoding: 'gzip',
cacheControl: 'max-age=31536000, public'
}
}))
.pipe(azure.upload(options))
.on('end', () => c())
.on('error', (err: any) => e(err));
});
await new Promise<void>((c, e) => {
const listing = new Vinyl({
path: 'files.txt',
contents: Buffer.from(files.join('\n')),
stat: { mode: 0o666 } as any
});
console.log(`Uploading: files.txt (${files.length} files)`); // debug
es.readArray([listing])
.pipe(gzip({ append: false }))
.pipe(azure.upload(options))
.on('end', () => c())
.on('error', (err: any) => e(err));
});