Merge pull request #15 from Microsoft/users/roniga/tasklib
Users/roniga/tasklib
This commit is contained in:
Коммит
47222bba8a
|
@ -79,4 +79,5 @@ local.properties
|
||||||
## Application Specific
|
## Application Specific
|
||||||
_build
|
_build
|
||||||
_package
|
_package
|
||||||
tests/Tools/target
|
tests/Tools/target
|
||||||
|
_temp
|
86
gulpfile.js
86
gulpfile.js
|
@ -7,18 +7,22 @@ var istanbul = require("gulp-istanbul");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var shell = require('shelljs')
|
var shell = require('shelljs')
|
||||||
var gutil = require('gulp-util');
|
var gutil = require('gulp-util');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
var buildDirectory = "_build";
|
var buildDirectory = "_build";
|
||||||
var packageDirectory = "_package";
|
var packageDirectory = "_package";
|
||||||
var sourcePaths = {
|
var sourcePaths = {
|
||||||
typescriptFiles: "src/**/*.ts",
|
typescriptFiles: "src/**/*.ts",
|
||||||
copyFiles: ["src/*.json", "src/*.md", "src/Images/*", "src/Tasks/**/*.json", "src/Tasks/**/*.md", "src/Tasks/**/*.png", "src/Tasks/**/*.svg"]
|
copyFiles: ["src/*.json", "src/*.md", "src/Images/*", "src/Tasks/**/*.json", "src/Tasks/**/*.md", "src/Tasks/**/*.png", "src/Tasks/**/*.svg"],
|
||||||
|
tasksPath: "src/Tasks"
|
||||||
};
|
};
|
||||||
var testPaths = {
|
var testPaths = {
|
||||||
typescriptFiles: "tests/**/*.ts",
|
typescriptFiles: "tests/**/*.ts",
|
||||||
compiledJSFiles: buildDirectory + "/**/*Tests*.js"
|
compiledJSFiles: buildDirectory + "/**/*Tests*.js"
|
||||||
};
|
};
|
||||||
var manifestFile = "vss-extension.json";
|
var manifestFile = "vss-extension.json";
|
||||||
|
var tempPath = path.join(__dirname, '_temp');
|
||||||
|
var tempNodeModules = path.join(tempPath, 'node_modules');
|
||||||
|
|
||||||
var jsCoverageDir = path.join(buildDirectory, "codecoverage");
|
var jsCoverageDir = path.join(buildDirectory, "codecoverage");
|
||||||
|
|
||||||
|
@ -30,15 +34,19 @@ var compilation = tsb.create({
|
||||||
verbose: false
|
verbose: false
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("compile", ["lint"], function() {
|
gulp.task("compile", ["lint"], function () {
|
||||||
return gulp.src([sourcePaths.typescriptFiles, testPaths.typescriptFiles], { base: "." })
|
return gulp.src([sourcePaths.typescriptFiles, testPaths.typescriptFiles], { base: "." })
|
||||||
.pipe(compilation())
|
.pipe(compilation())
|
||||||
.pipe(gulp.dest(buildDirectory))
|
.pipe(gulp.dest(buildDirectory))
|
||||||
.pipe(istanbul({includeUntested: true}))
|
.pipe(istanbul({ includeUntested: true }))
|
||||||
.pipe(istanbul.hookRequire());
|
.pipe(istanbul.hookRequire());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("build", ["compile"], function() {
|
gulp.task("build", ["compile", "gettasklib"], function() {
|
||||||
|
fs.readdirSync(sourcePaths.tasksPath).filter(function (file) {
|
||||||
|
return fs.statSync(path.join(sourcePaths.tasksPath, file)).isDirectory();
|
||||||
|
}).forEach(copyTaskLib);
|
||||||
|
|
||||||
return gulp.src(sourcePaths.copyFiles, { base: "." })
|
return gulp.src(sourcePaths.copyFiles, { base: "." })
|
||||||
.pipe(gulp.dest(buildDirectory));
|
.pipe(gulp.dest(buildDirectory));
|
||||||
});
|
});
|
||||||
|
@ -50,7 +58,7 @@ gulp.task("lint", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("clean", function(done) {
|
gulp.task("clean", function(done) {
|
||||||
return rimraf(buildDirectory, function() {
|
return rimraf([buildDirectory, packageDirectory, tempPath], function() {
|
||||||
// rimraf deletes the directory asynchronously
|
// rimraf deletes the directory asynchronously
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -86,30 +94,28 @@ gulp.task("watch", function() {
|
||||||
|
|
||||||
gulp.task("default", ["build"]);
|
gulp.task("default", ["build"]);
|
||||||
|
|
||||||
|
gulp.task("gettasklib", function (cb) {
|
||||||
|
getLatestTaskLib(cb);
|
||||||
|
});
|
||||||
|
|
||||||
var createPackage = function (cb) {
|
var createPackage = function (cb) {
|
||||||
var srcBuildDirectory = buildDirectory + "/src";
|
runMavenAndGenerateVsix(cb);
|
||||||
runMaven(function () {
|
|
||||||
createVsix(manifestFile, srcBuildDirectory, packageDirectory, cb);
|
|
||||||
}, function (err) {
|
|
||||||
cb(new gutil.PluginError({
|
|
||||||
plugin: "package",
|
|
||||||
message: err
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var runMaven = function(successcb, failcb) {
|
var runMavenAndGenerateVsix = function(cb) {
|
||||||
var mavenPath = shell.which('mvn');
|
var mavenPath = shell.which('mvn');
|
||||||
if (!mavenPath) {
|
if (!mavenPath) {
|
||||||
failcb('mvn.exe needs to be in the path. Could not find.');
|
cb(createError('mvn.exe needs to be in the path. Could not find.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shell.exec("mvn package", {silent:true}, function(code, output) {
|
shell.exec("mvn package", {silent:true}, function(code, output) {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
failcb(output);
|
cb(createError(output));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
successcb();
|
var srcBuildDirectory = buildDirectory + "/src";
|
||||||
|
createVsix(manifestFile, srcBuildDirectory, packageDirectory, cb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -117,13 +123,47 @@ var runMaven = function(successcb, failcb) {
|
||||||
var createVsix = function(manifestFile, srcBuildDirectory, packageDirectory, cb) {
|
var createVsix = function(manifestFile, srcBuildDirectory, packageDirectory, cb) {
|
||||||
shell.exec("tfx extension create --manifest-globs " + manifestFile + " --root " + srcBuildDirectory + " --output-path " + packageDirectory, {silent:true}, function(code, output) {
|
shell.exec("tfx extension create --manifest-globs " + manifestFile + " --root " + srcBuildDirectory + " --output-path " + packageDirectory, {silent:true}, function(code, output) {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
cb(new gutil.PluginError({
|
cb(createError(output));
|
||||||
plugin: "package",
|
|
||||||
message: output
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var getLatestTaskLib = function(cb) {
|
||||||
|
gutil.log('Getting latest vso-task-lib');
|
||||||
|
shell.mkdir('-p', path.join(tempPath, 'node_modules'));
|
||||||
|
shell.cp("-f", "package.json", tempPath);
|
||||||
|
shell.pushd(tempPath);
|
||||||
|
|
||||||
|
var npmPath = shell.which('npm');
|
||||||
|
if (!npmPath) {
|
||||||
|
cb(createError('npm not found. ensure npm 3 or greater is installed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmdline = '"' + npmPath + '" install --production';
|
||||||
|
shell.exec(cmdline, { silent: true }, function (code, output) {
|
||||||
|
shell.popd();
|
||||||
|
if (code !== 0) {
|
||||||
|
cb(createError('npm failed to install vso-task-lib. Output : ' + output));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var createError = function (err) {
|
||||||
|
return new gutil.PluginError({
|
||||||
|
plugin: "package",
|
||||||
|
message: err
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var copyTaskLib = function(taskName) {
|
||||||
|
var targetPath = path.join(buildDirectory, "src", "Tasks", taskName);
|
||||||
|
shell.mkdir('-p', targetPath);
|
||||||
|
shell.cp('-rf', path.join(tempPath, 'node_modules'), targetPath);
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.4.1",
|
"chai": "^3.4.1",
|
||||||
|
"fs": "^0.0.2",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-istanbul": "^0.10.3",
|
"gulp-istanbul": "^0.10.3",
|
||||||
"gulp-mocha": "^2.1.3",
|
"gulp-mocha": "^2.1.3",
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -18,6 +18,7 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<build.profile.id>dev</build.profile.id>
|
<build.profile.id>dev</build.profile.id>
|
||||||
<skip.jacoco.check>true</skip.jacoco.check>
|
<skip.jacoco.check>true</skip.jacoco.check>
|
||||||
|
<skip.unittests>true</skip.unittests>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
<build.profile.id>ci</build.profile.id>
|
<build.profile.id>ci</build.profile.id>
|
||||||
<!-- All tests are run. -->
|
<!-- All tests are run. -->
|
||||||
<skip.jacoco.check>false</skip.jacoco.check>
|
<skip.jacoco.check>false</skip.jacoco.check>
|
||||||
|
<skip.unittests>false</skip.unittests>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
|
|
|
@ -54,9 +54,11 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*UnitTests.java</include>
|
<include>**/*UnitTests.java</include>
|
||||||
|
<include>**/*PlatformTests.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<reportsDirectory>../../_build/testReports/vmOpsTool</reportsDirectory>
|
<reportsDirectory>../../_build/testReports/vmOpsTool</reportsDirectory>
|
||||||
<testClassesDirectory>../../_build/tests/tools/vmOpsTool</testClassesDirectory>
|
<testClassesDirectory>../../_build/tests/tools/vmOpsTool</testClassesDirectory>
|
||||||
|
<skipTests>${skip.unittests}</skipTests>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>2.16</version>
|
<version>2.16</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*PlatformTests.java</include>
|
<include>**/*PlatformTests.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<reportsDirectory>../../_build/testReports/vmOpsTool</reportsDirectory>
|
<reportsDirectory>../../_build/testReports/vmOpsTool</reportsDirectory>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче