-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mario Majcica
committed
Mar 20, 2018
1 parent
4abd391
commit 704cb6d
Showing
42 changed files
with
2,769 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# default behavior to automatically normalize line endings | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,7 @@ | ||
# Created by https://www.gitignore.io/api/node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
dist | ||
node_modules/ | ||
*.vsix | ||
_build/ | ||
_packages/ | ||
_test-results/ | ||
.vscode | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Mario Majcica | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,138 +1,34 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var del = require('del'); | ||
var eslint = require('gulp-eslint'); | ||
var gulp = require('gulp'); | ||
var istanbul = require('gulp-istanbul'); | ||
var mocha = require('gulp-mocha'); | ||
var plumber = require('gulp-plumber'); | ||
var shell = require('shelljs'); | ||
var spawn = require('child_process').spawn; | ||
var gutil = require('gulp-util'); | ||
|
||
var copyNodeModulesToTasks = function (done) { | ||
fs.readdirSync('src').forEach(function (file) { | ||
var filePath = path.join('dist', 'src', file); | ||
if (fs.statSync(filePath).isDirectory()) { | ||
try { | ||
if (fs.statSync(path.join(filePath, 'task.json')).isFile()) { | ||
shell.cp('-rf', 'dist/node_modules', filePath); | ||
} | ||
} catch (e) { | ||
/* swallow error: not a task directory */ | ||
} | ||
} | ||
}); | ||
done(); | ||
}; | ||
|
||
var executeCommand = function (cmd, dir, done) { | ||
gutil.log('Running command: ' + cmd); | ||
var pwd = shell.pwd(); | ||
if (undefined !== dir) { | ||
gutil.log(' Working directory: ' + dir); | ||
shell.cd(dir); | ||
} | ||
shell.exec(cmd, {silent: true}, function (code, stdout, stderr) { | ||
gutil.log(' stdout: ' + stdout); | ||
if (code !== 0) { | ||
gutil.log('Command failed: ' + cmd + '\nManually execute to debug'); | ||
gutil.log(' stderr: ' + stderr); | ||
} | ||
shell.cd(pwd); | ||
done(); | ||
}); | ||
}; | ||
|
||
var createVsixPackage = function (done) { | ||
if (!shell.which('tfx')) { | ||
gutil.log('Packaging requires tfx cli. Please install with `npm install tfx-cli -g`.'); | ||
done(); | ||
return; | ||
} | ||
var packagingCmd = 'tfx extension create --manifest-globs vss-extension.json --root dist/src --output-path dist'; | ||
executeCommand(packagingCmd, shell.pwd(), done); | ||
}; | ||
|
||
var getNodeDependencies = function (done) { | ||
gutil.log('Copy package.json to dist directory'); | ||
shell.mkdir('-p', 'dist/node_modules'); | ||
shell.cp('-f', 'package.json', 'dist'); | ||
|
||
gutil.log('Fetch node modules to package with tasks'); | ||
var npmPath = shell.which('npm'); | ||
var npmInstallCommand = '"' + npmPath + '" install --production'; | ||
executeCommand(npmInstallCommand, 'dist', done); | ||
}; | ||
|
||
// Tasks | ||
gulp.task('clean', function (done) { | ||
del('dist').then(function () { | ||
done(); | ||
}); | ||
}); | ||
|
||
gulp.task('lint', ['clean'], function () { | ||
return gulp.src('**/*.js') | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()); | ||
}); | ||
|
||
gulp.task('build', ['lint'], function () { | ||
return gulp.src('src/**/*', {base: '.'}) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
gulp.task('pre-test', ['build'], function () { | ||
return gulp.src('src/**/*.js') | ||
.pipe(istanbul({includeUntested: true})) | ||
.pipe(istanbul.hookRequire()); | ||
}); | ||
|
||
gulp.task('test', ['mocha-test']); | ||
|
||
gulp.task('mocha-test', ['pre-test'], function (done) { | ||
var mochaErr; | ||
|
||
gulp.src('test/**/*.js') | ||
.pipe(plumber()) | ||
.pipe(mocha({reporter: 'spec'})) | ||
.on('error', function (err) { | ||
mochaErr = err; | ||
}) | ||
.pipe(istanbul.writeReports()) | ||
.on('end', function () { | ||
done(mochaErr); | ||
}); | ||
var debug = require('gulp-debug'); | ||
var del = require('del'); | ||
var merge = require('merge-stream'); | ||
var path = require('path'); | ||
var shell = require('shelljs'); | ||
var minimist = require('minimist'); | ||
|
||
var _buildRoot = path.join(__dirname, '_build'); | ||
var _packagesRoot = path.join(__dirname, '_packages'); | ||
|
||
gulp.task('default', ['build']); | ||
|
||
gulp.task('build', ['clean'], function () { | ||
var extension = gulp.src(['README.md', 'LICENSE.txt', 'images/**/*', '!images/**/*.pdn', 'vss-extension.json'], { base: '.' }) | ||
.pipe(debug({title: 'extension:'})) | ||
.pipe(gulp.dest(_buildRoot)); | ||
var task = gulp.src('task/**/*', { base: '.' }) | ||
.pipe(debug({title: 'task:'})) | ||
.pipe(gulp.dest(_buildRoot)); | ||
|
||
return merge(extension, task); | ||
}); | ||
|
||
gulp.task('pester-test', ['pre-test'], function (done) { | ||
// Runs powershell unit tests based on pester | ||
var pester = spawn('powershell.exe', ['-Command', 'Invoke-Pester -EnableExit -Path test'], {stdio: 'inherit'}); | ||
pester.on('exit', function (code) { | ||
if (code === 0) { | ||
done(); | ||
} else { | ||
done('Pester tests failed!'); | ||
} | ||
}); | ||
|
||
pester.on('error', function () { | ||
// We may be in a non-windows machine or powershell.exe is not in path. Skip pester tests. | ||
done(); | ||
}); | ||
gulp.task('clean', function() { | ||
return del([_buildRoot]); | ||
}); | ||
|
||
gulp.task('default', ['test']); | ||
|
||
gulp.task('package', ['test'], function (done) { | ||
getNodeDependencies(function () { | ||
// TODO We need a per task dependency copy | ||
copyNodeModulesToTasks(function () { | ||
createVsixPackage(done); | ||
}); | ||
}); | ||
}); | ||
gulp.task('package', ['build'], function() { | ||
var args = minimist(process.argv.slice(2), {}) | ||
|
||
shell.exec('tfx extension create --root "' + _buildRoot + '" --output-path "' + _packagesRoot +'"') | ||
}); |
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.