Open EdenPlus opened 6 years ago
Based on testing it appears that by linking your GitHub account, screeps will auto pull from the master whenever it is updated. Ways to work with this without losing many hours of work:
I have solved the issue of moving code from Screeps to GitHub, below is the code for this solution. The tested environment is RunKit in browser.
/* Start Requirements */
const Promise = require("es6-promise").Promise;
const fs = require('fs');
const express = require('express');
const app = express();
const { ScreepsAPI } = require('screeps-api');
const Octokit = require("octokit");
/* End Requirements */
/* Start ScreepsAPI stuff */
// All options are optional
const api = new ScreepsAPI({
token: '<Screeps-Token>',
protocol: 'https',
hostname: 'screeps.com',
port: 443,
path: '/' // Do no include '/api', it will be added automatically
});
// You can overwrite parameters if needed
api.auth('screeps@email.com','notMyPass',{
protocol: 'https',
hostname: 'screeps.com',
port: 443,
path: '/' // Do no include '/api', it will be added automatically
});
/* End ScreepsAPI stuff */
/* Start GitHub Stuff */
var gh = Octokit.new({
token: "<GitHub-Token>"
});
var repoowner = "EdenPlus";
var reponame = "screeps";
var branchname = "prototype";
var repo = gh.getRepo(repoowner, reponame);
var branch = repo.getBranch(branchname);
api.code.get('default').then(function (data) {
var contents = {};
for (var a in data.modules) {
contents["src/" + a] = data.modules[a];
}
var message = "Automated Update";
branch.writeMany(contents, message)
.then(function() {
console.log("Code posted");
})
.catch(function(err) {
console.log(err);
});
});
/* End GitHub Stuff */
Dropping this link here for later use. Take note that there is an easier way to update the live codebase! Screeps External Commit