allow direct upload of release to TD cloud
This commit is contained in:
Родитель
e2eddb1b32
Коммит
48dc58d44d
9
Jakefile
9
Jakefile
|
@ -386,7 +386,7 @@ desc('upload current build to the cloud')
|
|||
task('upload', [], { async : true }, function() {
|
||||
var task = this;
|
||||
var upload = function (buildVersion) {
|
||||
var uploadKey = process.env.TD_UPLOAD_KEY;
|
||||
var uploadKey = process.env.TD_UPLOAD_KEY || "direct";
|
||||
console.log("[I] uploading v" + buildVersion)
|
||||
jake.exec([ 'node build/client.js tdupload ' + uploadKey + ' ' + buildVersion ],
|
||||
{ printStdout: true, printStderr: true },
|
||||
|
@ -394,12 +394,7 @@ task('upload', [], { async : true }, function() {
|
|||
|
||||
};
|
||||
if (!process.env.TRAVIS) {
|
||||
if (process.env.TD_UPLOAD_KEY && process.env.TD_UPLOAD_USER) {
|
||||
upload(process.env.TD_UPLOAD_USER);
|
||||
} else {
|
||||
console.log("[I] not in travis, skipping upload");
|
||||
task.complete();
|
||||
}
|
||||
upload(process.env.TD_UPLOAD_USER || process.env.USERNAME);
|
||||
} else {
|
||||
assert(process.env.TRAVIS_BUILD_NUMBER, "missing travis build number");
|
||||
assert(process.env.TD_UPLOAD_KEY, "missing touchdevelop upload key");
|
||||
|
|
|
@ -42,7 +42,7 @@ var reqNo = 0
|
|||
http.globalAgent.maxSockets = 15;
|
||||
https.globalAgent.maxSockets = 15;
|
||||
|
||||
function tdevGet(uri:string, f:(a:string)=>void, numRetries = 5, body = null)
|
||||
function tdevGet(uri:string, f:(a:string)=>void, numRetries = 5, body = null, contentType = null)
|
||||
{
|
||||
var currReq = reqNo++;
|
||||
var isDone = false
|
||||
|
@ -83,6 +83,9 @@ function tdevGet(uri:string, f:(a:string)=>void, numRetries = 5, body = null)
|
|||
purl.method = "POST"
|
||||
purl.headers = { 'content-type': 'application/json; charset=utf8' }
|
||||
}
|
||||
if (contentType) {
|
||||
purl.headers = { 'content-type': contentType }
|
||||
}
|
||||
if (!/^http:/.test(uri)) {
|
||||
var req = https.request(purl, handle);
|
||||
} else {
|
||||
|
@ -3454,6 +3457,20 @@ function tdupload(args:string[])
|
|||
|
||||
console.log("releaseid:" + lbl)
|
||||
|
||||
if (key == "direct") {
|
||||
var atokF = "access_token.txt"
|
||||
if (!fs.existsSync(atokF)) {
|
||||
console.warn("Access token not found.");
|
||||
console.log("Open the following link in your browser:");
|
||||
console.log(" https://www.touchdevelop.com/oauth/dialog?client_id=upload&response_type=token");
|
||||
console.log("Log in with your admin credentials, and save the access token in a text file with the following name.");
|
||||
console.log(" ./" + atokF)
|
||||
console.log("The token will be valid for up to one year. Do not share or check in the access token --- it identifies you personally.");
|
||||
return
|
||||
}
|
||||
var td_tok = "?access_token=" + fs.readFileSync(atokF, "utf8").replace(/\s/g, "").replace(/^#access_token=/, "")
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
args = [
|
||||
"build/main.js",
|
||||
|
@ -3500,6 +3517,11 @@ function tdupload(args:string[])
|
|||
contentType: mime,
|
||||
content: content,
|
||||
})
|
||||
} else if (td_tok) {
|
||||
var url = "https://www.touchdevelop.com/app/" + lbl + "/" + fileName + td_tok
|
||||
tdevGet(url, (resp) => {
|
||||
console.log(fileName + ": " + resp)
|
||||
}, 1, data, mime)
|
||||
} else {
|
||||
var url = "https://tdupload.azurewebsites.net/upload?access_token=" + key
|
||||
url += "&path=" + lbl + "/" + encodeURIComponent(fileName)
|
||||
|
|
Загрузка…
Ссылка в новой задаче