forked from fossasia/yaydoc
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
1 parent
034e03b
commit dc18c38
Showing
12 changed files
with
226 additions
and
12 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules/ | ||
temp/ | ||
.idea/ | ||
.env | ||
npm-debug.log |
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
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,37 @@ | ||
var crypter = require("../util/crypter.js") | ||
var spawn = require('child_process').spawn; | ||
|
||
exports.deployPages = function (socket, data) { | ||
var donePercent = 0; | ||
var repoName = data.gitURL.split("/")[4].split(".")[0]; | ||
var webUI = "true"; | ||
var username = data.username | ||
var oauthToken = crypter.decrypt(data.encryptedToken) | ||
const args = [ | ||
"-e", data.email, | ||
"-i", data.uniqueId, | ||
"-w", webUI, | ||
"-n", username, | ||
"-o", oauthToken, | ||
"-r", repoName | ||
]; | ||
var process = spawn("./publish_docs.sh", args); | ||
|
||
process.stdout.on('data', function (data) { | ||
console.log(data.toString()); | ||
socket.emit('deploy-logs', {donePercent: donePercent, data: data.toString()}); | ||
donePercent += 18; | ||
}); | ||
|
||
process.stderr.on('data', function (data) { | ||
console.log(data.toString()); | ||
socket.emit('err-logs', data.toString()); | ||
}); | ||
|
||
process.on('exit', function (code) { | ||
console.log('child process exited with code ' + code); | ||
if (code === 0) { | ||
socket.emit('deploy-success', {pagesURL: "https://" + data.username + ".github.io/" + repoName}); | ||
} | ||
}); | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const crypto = require('crypto'); | ||
|
||
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters) | ||
const IV_LENGTH = 16; // For AES, this is always 16 | ||
|
||
function encrypt(text) { | ||
let iv = crypto.randomBytes(IV_LENGTH); | ||
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv); | ||
let encrypted = cipher.update(text); | ||
|
||
encrypted = Buffer.concat([encrypted, cipher.final()]); | ||
|
||
return iv.toString('hex') + ':' + encrypted.toString('hex'); | ||
} | ||
|
||
function decrypt(text) { | ||
let textParts = text.split(':'); | ||
let iv = new Buffer(textParts.shift(), 'hex'); | ||
let encryptedText = new Buffer(textParts.join(':'), 'hex'); | ||
let decipher = crypto.createDecipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv); | ||
let decrypted = decipher.update(encryptedText); | ||
|
||
decrypted = Buffer.concat([decrypted, decipher.final()]); | ||
|
||
return decrypted.toString(); | ||
} | ||
|
||
exports.encrypt = encrypt | ||
|
||
exports.decrypt = decrypt |
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,32 @@ | ||
extends layout | ||
|
||
block content | ||
script(src="/socket.io/socket.io.js") | ||
script. | ||
var socket = io(); | ||
socket.emit('deploy', { | ||
'email': "#{email}", | ||
'gitURL': "#{gitURL}", | ||
'uniqueId': "#{uniqueId}", | ||
'encryptedToken': "#{token}", | ||
'username': "#{username}" | ||
}) | ||
|
||
socket.on('deploy-logs', function (data) { | ||
$('#messages').append($('<li>').text(data.data)); | ||
$("#progress").css("width", data.donePercent + "%"); | ||
}) | ||
|
||
socket.on('deploy-success', function(data) { | ||
$("#progress").css("width", "100%"); | ||
$("#main-content").append('<br><center><a class="btn btn-default" href="'+ data.pagesURL +'" target="_blank">GH-PAGES</a></center>') | ||
}) | ||
|
||
.container | ||
.col-md-6.col-md-offset-3#main-content | ||
.progress | ||
#progress.progress-bar(role='progressbar', aria-valuenow='0', aria-valuemin='0', aria-valuemax='100', style='width:0%') | ||
span.sr-only | ||
.logs.pre-scrollable | ||
h4(style='text-align: center; padding-top: 5px; color: #ffffff') Console Output | ||
ul#messages |
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