3 Star 0 Fork 1

mirrors_microsoft/azuredatastudio-debug

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 6.13 KB
一键复制 编辑 原始数据 按行查看 历史
chgagnon 提交于 2021-08-24 15:01 . Remove duplicate gulp task
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
const gulp = require('gulp');
const path = require('path');
const ts = require('gulp-typescript');
const log = require('gulp-util').log;
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const tslint = require('gulp-tslint');
const nls = require('vscode-nls-dev');
const del = require('del');
const fs = require('fs');
const vsce = require('vsce');
const es = require('event-stream');
const minimist = require('minimist');
const translationProjectName = 'azuredatastudio-extensions';
const translationExtensionName = 'sqlops-debug';
const defaultLanguages = [
{ id: 'zh-tw', folderName: 'cht', transifexId: 'zh-hant' },
{ id: 'zh-cn', folderName: 'chs', transifexId: 'zh-hans' },
{ id: 'ja', folderName: 'jpn' },
{ id: 'ko', folderName: 'kor' },
{ id: 'de', folderName: 'deu' },
{ id: 'fr', folderName: 'fra' },
{ id: 'es', folderName: 'esn' },
{ id: 'ru', folderName: 'rus' },
{ id: 'it', folderName: 'ita' },
// These language-pack languages are included for VS but excluded from the vscode package
{ id: 'cs', folderName: 'csy' },
{ id: 'tr', folderName: 'trk' },
{ id: 'pt-br', folderName: 'ptb', transifexId: 'pt-BR' },
{ id: 'pl', folderName: 'plk' }
];
const watchedSources = [
'src/**/*',
'test/**/*'
];
const scripts = [
'src/terminateProcess.sh'
];
const lintSources = [
'src'
].map(tsFolder => tsFolder + '/**/*.ts');
const tsProject = ts.createProject('tsconfig.json', { typescript });
function doBuild(buildNls, failOnError) {
return () => {
let gotError = false;
const tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.once('error', () => {
gotError = true;
});
return tsResult.js
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(buildNls ? nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n', 'out') : es.through())
.pipe(buildNls ? nls.bundleMetaDataFiles('ms-vscode.node-debug2', 'out') : es.through())
.pipe(buildNls ? nls.bundleLanguageFiles() : es.through())
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '..' })) // .. to compensate for TS returning paths from 'out'
.pipe(gulp.dest('out'))
.once('error', () => {
gotError = true;
})
.once('finish', () => {
if (failOnError && gotError) {
process.exit(1);
}
});
};
}
gulp.task('clean', function() {
return del(['out/**', 'package.nls.*.json', 'azuredatastudio-debug-*.vsix']);
});
gulp.task('copy-scripts', () => {
return gulp
.src(scripts, { base: '.' })
.pipe(gulp.dest('out'));
});
gulp.task('_dev-build', gulp.series('copy-scripts', doBuild(false, false)));
gulp.task('_build', gulp.series('copy-scripts', doBuild(true, true)));
gulp.task('build', gulp.series('clean', '_build'));
gulp.task('watch', gulp.series('clean', '_dev-build', () => {
log('Watching build sources...');
return gulp.watch(watchedSources, gulp.series('_dev-build'));
}));
gulp.task('tslint', () => {
return gulp.src(lintSources, { base: '.' })
.pipe(tslint({
formatter: 'verbose'
}))
.pipe(tslint.report());
});
function verifyNotALinkedModule(modulePath) {
return new Promise((resolve, reject) => {
fs.lstat(modulePath, (err, stat) => {
if (stat.isSymbolicLink()) {
reject(new Error('Symbolic link found: ' + modulePath));
} else {
resolve();
}
});
});
}
function verifyNoLinkedModules() {
return new Promise((resolve, reject) => {
fs.readdir('./node_modules', (err, files) => {
Promise.all(files.map(file => {
const modulePath = path.join('.', 'node_modules', file);
return verifyNotALinkedModule(modulePath);
})).then(resolve, reject);
});
});
}
gulp.task('verify-no-linked-modules', cb => verifyNoLinkedModules().then(() => cb, cb));
gulp.task('vsce-publish', () => {
return vsce.publish();
});
gulp.task('vsce-package', () => {
const cliOptions = minimist(process.argv.slice(2));
const packageOptions = {
packagePath: cliOptions.packagePath
};
return vsce.createVSIX(packageOptions);
});
gulp.task('add-i18n', () => {
return gulp.src(['package.nls.json'])
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
.pipe(gulp.dest('.'));
});
gulp.task('publish', gulp.series('build', 'add-i18n', 'vsce-publish'));
gulp.task('package', gulp.series('build', 'add-i18n', 'vsce-package'));
gulp.task('translations-export', gulp.series('_build', () => {
return gulp.src(['package.nls.json', 'out/nls.metadata.header.json', 'out/nls.metadata.json'])
.pipe(nls.createXlfFiles(translationProjectName, translationExtensionName))
.pipe(gulp.dest(path.join('..', 'vscode-translations-export')));
}));
gulp.task('translations-import', (done) => {
const options = minimist(process.argv.slice(2), {
string: 'location',
default: {
location: '../vscode-translations-import'
}
});
return es.merge(defaultLanguages.map(language => {
let id = language.transifexId || language.id;
console.log(path.join(options.location, id, 'vscode-extensions', `${translationExtensionName}.xlf`));
return gulp.src(path.join(options.location, id, 'vscode-extensions', `${translationExtensionName}.xlf`))
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest(path.join('./i18n', language.folderName)));
})).on('end', () => done());
});
gulp.task('i18n-import', () => {
return es.merge(defaultLanguages.map(language => {
return gulp.src(`../${translationExtensionName}-localization/${language.folderName}/**/*.xlf`)
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest(path.join('./i18n', language.folderName)));
}));
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_microsoft/azuredatastudio-debug.git
git@gitee.com:mirrors_microsoft/azuredatastudio-debug.git
mirrors_microsoft
azuredatastudio-debug
azuredatastudio-debug
main

搜索帮助