mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Reapply publish script changes lost in VS Code 1.19 merge (#653)
* Reapply publish script changes lost in VS Code 1.19 merge
* Pick up changes from commit 0c14c3cc7f
* Add another // {{SQL CARBON EDIT}}
This commit is contained in:
@@ -6,21 +6,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const json = require('gulp-json-editor');
|
// {{SQL CARBON EDIT}}
|
||||||
const buffer = require('gulp-buffer');
|
const jeditor = require('gulp-json-editor');
|
||||||
const filter = require('gulp-filter');
|
|
||||||
const es = require('event-stream');
|
|
||||||
const util = require('./lib/util');
|
|
||||||
const remote = require('gulp-remote-src');
|
|
||||||
const zip = require('gulp-vinyl-zip');
|
|
||||||
const assign = require('object-assign');
|
|
||||||
const pkg = require('../package.json');
|
|
||||||
|
|
||||||
gulp.task('mixin', function () {
|
gulp.task('mixin', function () {
|
||||||
const repo = process.env['VSCODE_MIXIN_REPO'];
|
// {{SQL CARBON EDIT}}
|
||||||
|
const updateUrl = process.env['SQLOPS_UPDATEURL'];
|
||||||
if (!repo) {
|
if (!updateUrl) {
|
||||||
console.log('Missing VSCODE_MIXIN_REPO, skipping mixin');
|
console.log('Missing SQLOPS_UPDATEURL, skipping mixin');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,39 +24,13 @@ gulp.task('mixin', function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `https://github.com/${repo}/archive/${pkg.distro}.zip`;
|
// {{SQL CARBON EDIT}}
|
||||||
const opts = { base: url };
|
let newValues = {
|
||||||
const username = process.env['VSCODE_MIXIN_USERNAME'];
|
"updateUrl": updateUrl,
|
||||||
const password = process.env['VSCODE_MIXIN_PASSWORD'];
|
"quality": quality
|
||||||
|
};
|
||||||
|
|
||||||
if (username || password) {
|
return gulp.src('./product.json')
|
||||||
opts.auth = { user: username || '', pass: password || '' };
|
.pipe(jeditor(newValues))
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Mixing in sources from \'' + url + '\':');
|
|
||||||
|
|
||||||
let all = remote('', opts)
|
|
||||||
.pipe(zip.src())
|
|
||||||
.pipe(filter(function (f) { return !f.isDirectory(); }))
|
|
||||||
.pipe(util.rebase(1));
|
|
||||||
|
|
||||||
if (quality) {
|
|
||||||
const productJsonFilter = filter('product.json', { restore: true });
|
|
||||||
const mixin = all
|
|
||||||
.pipe(filter(['quality/' + quality + '/**']))
|
|
||||||
.pipe(util.rebase(2))
|
|
||||||
.pipe(productJsonFilter)
|
|
||||||
.pipe(buffer())
|
|
||||||
.pipe(json(o => assign({}, require('../product.json'), o)))
|
|
||||||
.pipe(productJsonFilter.restore);
|
|
||||||
|
|
||||||
all = es.merge(mixin);
|
|
||||||
}
|
|
||||||
|
|
||||||
return all
|
|
||||||
.pipe(es.mapSync(function (f) {
|
|
||||||
console.log(f.relative);
|
|
||||||
return f;
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest('.'));
|
.pipe(gulp.dest('.'));
|
||||||
});
|
});
|
||||||
@@ -14,8 +14,9 @@ import * as mime from 'mime';
|
|||||||
import * as minimist from 'minimist';
|
import * as minimist from 'minimist';
|
||||||
import { DocumentClient, NewDocument } from 'documentdb';
|
import { DocumentClient, NewDocument } from 'documentdb';
|
||||||
|
|
||||||
if (process.argv.length < 6) {
|
// {{SQL CARBON EDIT}}
|
||||||
console.error('Usage: node publish.js <product> <platform> <type> <name> <version> <commit> <is_update> <file>');
|
if (process.argv.length < 9) {
|
||||||
|
console.error('Usage: node publish.js <product_quality> <platform> <file_type> <file_name> <version> <is_update> <file> [commit_id]');
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,21 +184,10 @@ async function publish(commit: string, quality: string, platform: string, type:
|
|||||||
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2'])
|
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2'])
|
||||||
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
|
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
|
||||||
|
|
||||||
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], `${storageAccount}.blob.core.chinacloudapi.cn`)
|
// {{SQL CARBON EDIT}}
|
||||||
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
|
await assertContainer(blobService, quality);
|
||||||
|
|
||||||
// mooncake is fussy and far away, this is needed!
|
const blobExists = await doesAssetExist(blobService, quality, blobName);
|
||||||
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
assertContainer(blobService, quality),
|
|
||||||
assertContainer(mooncakeBlobService, quality)
|
|
||||||
]);
|
|
||||||
|
|
||||||
const [blobExists, moooncakeBlobExists] = await Promise.all([
|
|
||||||
doesAssetExist(blobService, quality, blobName),
|
|
||||||
doesAssetExist(mooncakeBlobService, quality, blobName)
|
|
||||||
]);
|
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
@@ -205,8 +195,23 @@ async function publish(commit: string, quality: string, platform: string, type:
|
|||||||
promises.push(uploadBlob(blobService, quality, blobName, file));
|
promises.push(uploadBlob(blobService, quality, blobName, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moooncakeBlobExists) {
|
// {{SQL CARBON EDIT}}
|
||||||
promises.push(uploadBlob(mooncakeBlobService, quality, blobName, file));
|
if (process.env['MOONCAKE_STORAGE_ACCESS_KEY']) {
|
||||||
|
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], `${storageAccount}.blob.core.chinacloudapi.cn`)
|
||||||
|
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
|
||||||
|
|
||||||
|
// mooncake is fussy and far away, this is needed!
|
||||||
|
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
|
||||||
|
|
||||||
|
await assertContainer(mooncakeBlobService, quality);
|
||||||
|
|
||||||
|
const mooncakeBlobExists = await doesAssetExist(mooncakeBlobService, quality, blobName);
|
||||||
|
|
||||||
|
if (!mooncakeBlobExists) {
|
||||||
|
promises.push(uploadBlob(mooncakeBlobService, quality, blobName, file));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Skipping Mooncake publishing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promises.length === 0) {
|
if (promises.length === 0) {
|
||||||
@@ -228,7 +233,8 @@ async function publish(commit: string, quality: string, platform: string, type:
|
|||||||
platform: platform,
|
platform: platform,
|
||||||
type: type,
|
type: type,
|
||||||
url: `${process.env['AZURE_CDN_URL']}/${quality}/${blobName}`,
|
url: `${process.env['AZURE_CDN_URL']}/${quality}/${blobName}`,
|
||||||
mooncakeUrl: `${process.env['MOONCAKE_CDN_URL']}/${quality}/${blobName}`,
|
// {{SQL CARBON EDIT}}
|
||||||
|
mooncakeUrl: process.env['MOONCAKE_CDN_URL'] ? `${process.env['MOONCAKE_CDN_URL']}/${quality}/${blobName}` : undefined,
|
||||||
hash: sha1hash,
|
hash: sha1hash,
|
||||||
sha256hash,
|
sha256hash,
|
||||||
size
|
size
|
||||||
@@ -261,8 +267,11 @@ function main(): void {
|
|||||||
boolean: ['upload-only']
|
boolean: ['upload-only']
|
||||||
});
|
});
|
||||||
|
|
||||||
const [quality, platform, type, name, version, _isUpdate, file] = opts._;
|
// {{SQL CARBON EDIT}}
|
||||||
const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
|
let [quality, platform, type, name, version, _isUpdate, file, commit] = opts._;
|
||||||
|
if (!commit) {
|
||||||
|
commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
|
||||||
|
}
|
||||||
|
|
||||||
publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(err => {
|
publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user