Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ typings/webparts

# Configs that contain sensitive information
TDSDeployConfig.json

#ftp config
ftpconfig.json
106 changes: 106 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

let build = require('web-library-build');
let gulp = require('gulp');
let configFile = "./ftpconfig.json";
let fs = require('fs');

/** @todo: disable lint config. */
build.tslint.setConfig({ lintConfig: require('./tslint.json') });
Expand All @@ -25,6 +27,110 @@ if (isProduction || isNuke) {
});
}

gulp.task('install-deploy', function(cb) {
let prompt = require('gulp-prompt');

gulp.src('index.html')
.pipe(prompt.prompt([{
type: 'input',
name: 'host',
message: 'Please enter hostname (ftp.example.com)'
},
{
type: 'input',
name: 'user',
message: 'Please enter username (exampleusername)'
},
{
type: 'input',
name: 'password',
message: 'Please enter password (examplepassword)'
},
{
type: 'input',
name: 'deployurl',
message: 'Enter deploy URL (http://example.com/website-subfolder/)'
},
{
type: 'input',
name: 'deploybasepath',
message: 'Please deployment base path (/wwwroot/base/path/website-subfolder/)'
},
{
type: 'input',
name: 'secureconnection',
message: 'Secure connection? (Type true or false)',
choices: ["true", "false"]
},
{
type: 'input',
name: 'idletimeout',
message: 'Enter Idle timeout in milleseconds(1000)'
}], function(res) {
let ftpdata = {
"host": res.host,
"user": res.user,
"password": res.password,
"deployurl": res.deployurl,
"deploybasepath": res.deploybasepath,
"secureconnection": res.secureconnection,
"idletimeout": res.idletimeout
};
fs.writeFileSync(configFile, JSON.stringify(ftpdata));
cb();
}));
});

gulp.task('deploy', ['bundle'], function(cb) {
let ftp = require('vinyl-ftp');
let git = require('git-rev');
let debug = require('gulp-debug');
let gutil = require('gulp-util');
let os = require('os');
let currentBranch;
let json;
let data;
let uploadPath;

try {
json = fs.readFileSync(configFile, 'utf8');
data = JSON.parse(json);

git.branch(function(branch) {
currentBranch = os.hostname().split('.')[0] + '-' + branch.replace('/', '-');
let ftpConnection = ftp.create({
host: data.host,
user: data.user,
pass: data.password,
parallel: 10,
secure: (data.secureconnection == "true") ? true : false,
idleTimeout: data.idletimeout
});
let globs = [
'./index.html',
'./dist/**/*'
];
if (process.env.masterBuildLink || isProduction) {
currentBranch = 'master';
}
let uploadPath = data.deploybasepath + currentBranch;
let stream = gulp.src( globs, { base: '.', buffer: false })
.pipe(debug({ title: 'Copying file to server' }))
.pipe(ftpConnection.dest(uploadPath))
.on('error', function(er) {
console.log(er);
})
.on("end", function() {
gutil.log( data.deployurl + currentBranch + '/' );
cb();
});
});
}
catch(err) {
gutil.log("Please run gulp install-deploy before deploying");
}
});

/** @todo: Enable css modules when ready. */
// build.sass.setConfig({ useCSSModules: true });

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"git-rev": "0.2.1",
"gulp": "~3.9.1",
"gulp-debug": "2.1.2",
"gulp-prompt": "^0.2.0",
"gulp-util": "3.0.7",
"gutil": "1.6.4",
"highlight.js": "9.4.0",
Expand Down