Fix security vulnerabilities (#850)
This commit is contained in:
Родитель
020085cfb3
Коммит
5fd423ca7b
240
gulpfile.js
240
gulpfile.js
|
@ -2,9 +2,9 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
|
||||
const gulp = require("gulp");
|
||||
const log = require('fancy-log');
|
||||
const istanbul = require('gulp-istanbul');
|
||||
const isparta = require('isparta');
|
||||
const log = require("fancy-log");
|
||||
const istanbul = require("gulp-istanbul");
|
||||
const isparta = require("isparta");
|
||||
const sourcemaps = require("gulp-sourcemaps");
|
||||
const path = require("path");
|
||||
const preprocess = require("gulp-preprocess");
|
||||
|
@ -17,37 +17,37 @@ const minimist = require("minimist");
|
|||
const os = require("os");
|
||||
const fs = require("fs");
|
||||
const Q = require("q");
|
||||
const es = require('event-stream');
|
||||
const remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
|
||||
const execSync = require('child_process').execSync;
|
||||
const nls = require('vscode-nls-dev');
|
||||
const es = require("event-stream");
|
||||
const remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");
|
||||
const execSync = require("child_process").execSync;
|
||||
const nls = require("vscode-nls-dev");
|
||||
|
||||
const copyright = GulpExtras.checkCopyright;
|
||||
const imports = GulpExtras.checkImports;
|
||||
const executeCommand = GulpExtras.executeCommand;
|
||||
|
||||
const transifexApiHostname = 'www.transifex.com'
|
||||
const transifexApiName = 'api';
|
||||
const transifexApiHostname = "www.transifex.com"
|
||||
const transifexApiName = "api";
|
||||
const transifexApiToken = process.env.TRANSIFEX_API_TOKEN;
|
||||
const transifexProjectName = 'vscode-extensions';
|
||||
const transifexExtensionName = 'vscode-react-native';
|
||||
const transifexProjectName = "vscode-extensions";
|
||||
const transifexExtensionName = "vscode-react-native";
|
||||
|
||||
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' },
|
||||
{ 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' }
|
||||
{ id: "cs", folderName: "csy" },
|
||||
{ id: "tr", folderName: "trk" },
|
||||
{ id: "pt-br", folderName: "ptb", transifexId: "pt_BR" },
|
||||
{ id: "pl", folderName: "plk" }
|
||||
];
|
||||
|
||||
var srcPath = "src";
|
||||
|
@ -67,17 +67,27 @@ var options = minimist(process.argv.slice(2), knownOptions);
|
|||
|
||||
var tsProject = ts.createProject("tsconfig.json");
|
||||
|
||||
// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
|
||||
// We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to
|
||||
// be an issue on Windows platforms)
|
||||
gulp.task("build", ["check-imports", "check-copyright"], build);
|
||||
gulp.task("check-imports", function () {
|
||||
return tsProject.src()
|
||||
.pipe(imports());
|
||||
});
|
||||
|
||||
gulp.task("quick-build", build);
|
||||
gulp.task("check-copyright", function () {
|
||||
return gulp.src([
|
||||
"**/*.ts",
|
||||
"**/*.js",
|
||||
"!**/*.d.ts",
|
||||
"!coverage/**",
|
||||
"!node_modules/**",
|
||||
"!test/**/*.js",
|
||||
"!SampleApplication/**",
|
||||
"!test/resources/sampleReactNative022Project/**/*.js"
|
||||
])
|
||||
.pipe(copyright());
|
||||
});
|
||||
|
||||
// Configuring build task
|
||||
var failOnError = true;
|
||||
var buildNls = true;
|
||||
function build(callback) {
|
||||
|
||||
function build(failOnError, buildNls) {
|
||||
var tsProject = ts.createProject("tsconfig.json");
|
||||
var isProd = options.env === "production";
|
||||
var preprocessorContext = isProd ? { PROD: true } : { DEBUG: true };
|
||||
|
@ -86,49 +96,62 @@ function build(callback) {
|
|||
var tsResult = tsProject.src()
|
||||
.pipe(preprocess({ context: preprocessorContext })) //To set environment variables in-line
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(tsProject())
|
||||
.on("error", function (e) {
|
||||
callback(e);
|
||||
});
|
||||
|
||||
.pipe(tsProject());
|
||||
|
||||
return tsResult.js
|
||||
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
|
||||
.pipe(buildNls ? nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n', '.') : es.through())
|
||||
.pipe(buildNls ? nls.bundleMetaDataFiles('vsmobile.vscode-react-native', '.') : es.through())
|
||||
.pipe(buildNls ? nls.createAdditionalLanguageFiles(defaultLanguages, "i18n", ".") : es.through())
|
||||
.pipe(buildNls ? nls.bundleMetaDataFiles("vsmobile.vscode-react-native", ".") : es.through())
|
||||
.pipe(buildNls ? nls.bundleLanguageFiles() : es.through())
|
||||
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '.' }))
|
||||
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "." }))
|
||||
.pipe(gulp.dest(function (file) {
|
||||
return file.cwd;
|
||||
}))
|
||||
.once('error', () => {
|
||||
.once("error", () => {
|
||||
gotError = true;
|
||||
})
|
||||
.once('finish', () => {
|
||||
.once("finish", () => {
|
||||
if (failOnError && gotError) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task("watch", ["build"], function (cb) {
|
||||
// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
|
||||
// We should also make sure that we always generate urls in all the path properties (We shouldn"t have \\s. This seems to
|
||||
// be an issue on Windows platforms)
|
||||
gulp.task("build", gulp.series("check-imports", "check-copyright", function (done) {
|
||||
build(true, true);
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.task("build-dev", gulp.series("check-imports", "check-copyright", function (done) {
|
||||
build(false, false);
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.task("quick-build", build);
|
||||
|
||||
gulp.task("watch", gulp.series("build", function () {
|
||||
log("Watching build sources...");
|
||||
return gulp.watch(sources, ["build"]);
|
||||
});
|
||||
return gulp.watch(sources, gulp.series("build"));
|
||||
}));
|
||||
|
||||
gulp.task("default", function (callback) {
|
||||
runSequence("clean", "build", "tslint", callback);
|
||||
gulp.task("clean", function () {
|
||||
var del = require("del");
|
||||
var pathsToDelete = [
|
||||
"src/**/*.js",
|
||||
"src/**/*.js.map",
|
||||
"test/**/*.js",
|
||||
"test/**/*.js.map",
|
||||
"out/",
|
||||
"!test/resources/sampleReactNative022Project/**/*.js",
|
||||
".vscode-test/",
|
||||
"nls.*.json"
|
||||
]
|
||||
return del(pathsToDelete, { force: true });
|
||||
});
|
||||
|
||||
var lintSources = [
|
||||
srcPath,
|
||||
testPath
|
||||
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
|
||||
lintSources = lintSources.concat([
|
||||
"!src/typings/**",
|
||||
"!test/resources/sampleReactNative022Project/**"
|
||||
]);
|
||||
|
||||
var libtslint = require("tslint");
|
||||
var tslint = require("gulp-tslint");
|
||||
gulp.task("tslint", function () {
|
||||
|
@ -141,6 +164,17 @@ gulp.task("tslint", function () {
|
|||
.pipe(tslint.report());
|
||||
});
|
||||
|
||||
gulp.task("default", gulp.series("clean", "build", "tslint"));
|
||||
|
||||
var lintSources = [
|
||||
srcPath,
|
||||
testPath
|
||||
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
|
||||
lintSources = lintSources.concat([
|
||||
"!src/typings/**",
|
||||
"!test/resources/sampleReactNative022Project/**"
|
||||
]);
|
||||
|
||||
function test() {
|
||||
// Check if arguments were passed
|
||||
if (options.pattern) {
|
||||
|
@ -158,9 +192,9 @@ function test() {
|
|||
}));
|
||||
}
|
||||
|
||||
gulp.task("test", ["build", "tslint"], test);
|
||||
gulp.task("test", gulp.series("build", "tslint", test));
|
||||
|
||||
gulp.task('coverage:instrument', function () {
|
||||
gulp.task("coverage:instrument", function () {
|
||||
return gulp.src(["src/**/*.js", "!test/**"])
|
||||
.pipe(istanbul({
|
||||
// Use the isparta instrumenter (code coverage for ES6)
|
||||
|
@ -171,69 +205,33 @@ gulp.task('coverage:instrument', function () {
|
|||
.pipe(istanbul.hookRequire());
|
||||
});
|
||||
|
||||
gulp.task('coverage:report', function (done) {
|
||||
gulp.task("coverage:report", function (done) {
|
||||
return gulp.src(
|
||||
["src/**/*.js", "!test/**"],
|
||||
{ read: false }
|
||||
)
|
||||
.pipe(istanbul.writeReports({
|
||||
reporters: ['json', 'text-summary']
|
||||
reporters: ["json", "text-summary"]
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('coverage:remap', function () {
|
||||
return gulp.src('coverage/coverage-final.json')
|
||||
gulp.task("coverage:remap", function () {
|
||||
return gulp.src("coverage/coverage-final.json")
|
||||
.pipe(remapIstanbul({
|
||||
reports: {
|
||||
'json': 'coverage/coverage.json',
|
||||
'html': 'coverage/html-report'
|
||||
"json": "coverage/coverage.json",
|
||||
"html": "coverage/html-report"
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task("test:coverage", function (done) {
|
||||
runSequence("quick-build", 'coverage:instrument',
|
||||
"test-no-build", 'coverage:report', 'coverage:remap', done);
|
||||
});
|
||||
|
||||
gulp.task("test-no-build", test);
|
||||
|
||||
gulp.task("check-imports", function (cb) {
|
||||
return tsProject.src()
|
||||
.pipe(imports());
|
||||
});
|
||||
gulp.task("test:coverage", gulp.series("quick-build", "coverage:instrument", "test-no-build", "coverage:report", "coverage:remap"));
|
||||
|
||||
gulp.task("check-copyright", function (cb) {
|
||||
return gulp.src([
|
||||
"**/*.ts",
|
||||
"**/*.js",
|
||||
"!**/*.d.ts",
|
||||
"!coverage/**",
|
||||
"!node_modules/**",
|
||||
"!test/**/*.js",
|
||||
"!SampleApplication/**",
|
||||
"!test/resources/sampleReactNative022Project/**/*.js"
|
||||
])
|
||||
.pipe(copyright());
|
||||
});
|
||||
|
||||
gulp.task("watch-build-test", ["build", "build-test"], function () {
|
||||
return gulp.watch(sources, ["build", "build-test"]);
|
||||
});
|
||||
|
||||
gulp.task("clean", function () {
|
||||
var del = require("del");
|
||||
var pathsToDelete = [
|
||||
"src/**/*.js",
|
||||
"src/**/*.js.map",
|
||||
"test/**/*.js",
|
||||
"test/**/*.js.map",
|
||||
"out/",
|
||||
"!test/resources/sampleReactNative022Project/**/*.js",
|
||||
".vscode-test/"
|
||||
]
|
||||
return del(pathsToDelete, { force: true });
|
||||
});
|
||||
gulp.task("watch-build-test", gulp.series("build", "test", function () {
|
||||
return gulp.watch(sources, gulp.series("build", "test"));
|
||||
}));
|
||||
|
||||
gulp.task("package", function (callback) {
|
||||
var command = path.join(__dirname, "node_modules", ".bin", "vsce");
|
||||
|
@ -241,7 +239,7 @@ gulp.task("package", function (callback) {
|
|||
executeCommand(command, args, callback);
|
||||
});
|
||||
|
||||
gulp.task("release", ["build"], function () {
|
||||
gulp.task("release", gulp.series("build", function () {
|
||||
var licenseFiles = ["LICENSE.txt", "ThirdPartyNotices.txt"];
|
||||
var backupFolder = path.resolve(path.join(os.tmpdir(), "vscode-react-native"));
|
||||
if (!fs.existsSync(backupFolder)) {
|
||||
|
@ -273,31 +271,31 @@ gulp.task("release", ["build"], function () {
|
|||
fs.writeFileSync(path.join(__dirname, fileName), fs.readFileSync(path.join(backupFolder, fileName)));
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
// Creates package.i18n.json files for all languages to {workspaceRoot}/i18n folder
|
||||
gulp.task('add-i18n', function () {
|
||||
return gulp.src(['package.nls.json'])
|
||||
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
|
||||
.pipe(gulp.dest('.'));
|
||||
gulp.task("add-i18n", function () {
|
||||
return gulp.src(["package.nls.json"])
|
||||
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
|
||||
// Gathers all strings to Transifex readable .xliff file for translating and pushes them to Transifex
|
||||
gulp.task('transifex-push', ['build'], function () {
|
||||
return gulp.src(['package.nls.json', 'nls.metadata.header.json','nls.metadata.json'])
|
||||
gulp.task("transifex-push", gulp.series("build", function () {
|
||||
return gulp.src(["package.nls.json", "nls.metadata.header.json","nls.metadata.json"])
|
||||
.pipe(nls.createXlfFiles(transifexProjectName, transifexExtensionName))
|
||||
.pipe(nls.pushXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken));
|
||||
});
|
||||
}));
|
||||
|
||||
// Creates Transifex readable .xliff file and saves it locally
|
||||
gulp.task('transifex-push-test', ['build'], function() {
|
||||
return gulp.src(['package.nls.json', 'nls.metadata.header.json','nls.metadata.json'])
|
||||
gulp.task("transifex-push-test", gulp.series("build", function() {
|
||||
return gulp.src(["package.nls.json", "nls.metadata.header.json","nls.metadata.json"])
|
||||
.pipe(nls.createXlfFiles(transifexProjectName, transifexExtensionName))
|
||||
.pipe(gulp.dest(path.join('..', `${transifexExtensionName}-push-test`)));
|
||||
});
|
||||
.pipe(gulp.dest(path.join("..", `${transifexExtensionName}-push-test`)));
|
||||
}));
|
||||
|
||||
// Gets the files with localized strings from Transifex
|
||||
gulp.task('transifex-pull', function () {
|
||||
gulp.task("transifex-pull", function () {
|
||||
return es.merge(defaultLanguages.map(function(language) {
|
||||
return nls.pullXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken, language, [{ name: transifexExtensionName, project: transifexProjectName }]).
|
||||
pipe(gulp.dest(`../${transifexExtensionName}-localization/${language.folderName}`));
|
||||
|
@ -305,10 +303,10 @@ gulp.task('transifex-pull', function () {
|
|||
});
|
||||
|
||||
// Imports localization from raw localized Transifex strings to VS Code .i18n.json files
|
||||
gulp.task('i18n-import', function() {
|
||||
gulp.task("i18n-import", function() {
|
||||
return es.merge(defaultLanguages.map(function(language) {
|
||||
return gulp.src(`../${transifexExtensionName}-localization/${language.folderName}/**/*.xlf`)
|
||||
.pipe(nls.prepareJsonFiles())
|
||||
.pipe(gulp.dest(path.join('./i18n', language.folderName)));
|
||||
.pipe(gulp.dest(path.join("./i18n", language.folderName)));
|
||||
}));
|
||||
});
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
12
package.json
12
package.json
|
@ -541,11 +541,11 @@
|
|||
"del": "^2.2.0",
|
||||
"event-stream": "3.3.4",
|
||||
"fancy-log": "^1.3.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-install": "^1.1.0",
|
||||
"gulp-istanbul": "^1.1.2",
|
||||
"gulp-mocha": "^3.0.1",
|
||||
"gulp-preprocess": "^2.0.0",
|
||||
"gulp-mocha": "^6.0.0",
|
||||
"gulp-preprocess": "^3.0.1",
|
||||
"gulp-sequence": "1.0.0",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-tslint": "^8.1.2",
|
||||
|
@ -554,8 +554,8 @@
|
|||
"jest": "^22.1.4",
|
||||
"jest-cli": "^22.1.4",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^3.2.0",
|
||||
"mocha-teamcity-reporter": "^1.0.0",
|
||||
"mocha": "^4.1.0",
|
||||
"mocha-teamcity-reporter": "^2.5.1",
|
||||
"mock-fs": "^4.4.1",
|
||||
"plugin-error": "^1.0.1",
|
||||
"remap-istanbul": "^0.9.5",
|
||||
|
@ -572,7 +572,7 @@
|
|||
"tslint-microsoft-contrib": "^5.0.2",
|
||||
"typescript": "^2.8.3",
|
||||
"vsce": "^1.3.0",
|
||||
"vscode": "^1.1.22",
|
||||
"vscode": "^1.1.24",
|
||||
"vscode-nls-dev": "3.2.2"
|
||||
},
|
||||
"extensionDependencies": [
|
||||
|
|
Загрузка…
Ссылка в новой задаче