Update ftp deployment, fix minor bugs in savegame serialization

This commit is contained in:
tobspr 2020-05-18 19:47:40 +02:00
parent a42b625aa5
commit 2c659482c4
4 changed files with 65 additions and 72 deletions

View File

@ -6,6 +6,27 @@ const buildUtils = require("./buildutils");
function gulptasksFTP($, gulp, buildFolder) { function gulptasksFTP($, gulp, buildFolder) {
const commitHash = buildUtils.getRevision(); const commitHash = buildUtils.getRevision();
const additionalFolder = path.join(__dirname, "additional_build_files");
const additionalFiles = [
path.join(additionalFolder, "*"),
path.join(additionalFolder, "*.*"),
path.join(additionalFolder, ".*"),
];
const credentials = {
staging: {
host: process.env.SHAPEZ_CLI_SERVER_HOST,
user: process.env.SHAPEZ_CLI_STAGING_FTP_USER,
pass: process.env.SHAPEZ_CLI_STAGING_FTP_PW,
},
prod: {
host: process.env.SHAPEZ_CLI_SERVER_HOST,
user: process.env.SHAPEZ_CLI_LIVE_FTP_USER,
pass: process.env.SHAPEZ_CLI_LIVE_FTP_PW,
},
};
// Write the "commit.txt" file // Write the "commit.txt" file
gulp.task("ftp.writeVersion", () => { gulp.task("ftp.writeVersion", () => {
fs.writeFileSync( fs.writeFileSync(
@ -22,13 +43,6 @@ function gulptasksFTP($, gulp, buildFolder) {
); );
}); });
// Copies additional files (like .htaccess) which should be deployed when running
// on the ftp server
// gulp.task("ftp.copyServerFiles", () => {
// return gulp.src(["../ftp_upload/*.*", "../ftp_upload/.*", "../ftp_upload/*"])
// .pipe(gulp.dest(buildFolder));
// });
const gameSrcGlobs = [ const gameSrcGlobs = [
path.join(buildFolder, "**/*.*"), path.join(buildFolder, "**/*.*"),
path.join(buildFolder, "**/.*"), path.join(buildFolder, "**/.*"),
@ -36,67 +50,47 @@ function gulptasksFTP($, gulp, buildFolder) {
path.join(buildFolder, "!**/index.html"), path.join(buildFolder, "!**/index.html"),
]; ];
gulp.task("ftp.upload.staging.game", () => { for (const deployEnv of ["prod", "staging"]) {
return gulp const deployCredentials = credentials[deployEnv];
.src(gameSrcGlobs, { base: buildFolder })
.pipe( gulp.task(`ftp.upload.${deployEnv}.game`, () => {
$.rename(pth => { return gulp
pth.dirname = path.join("v", commitHash, pth.dirname); .src(gameSrcGlobs, { base: buildFolder })
.pipe(
$.rename(pth => {
pth.dirname = path.join("v", commitHash, pth.dirname);
})
)
.pipe($.sftp(deployCredentials));
});
gulp.task(`ftp.upload.${deployEnv}.indexHtml`, () => {
return gulp
.src([path.join(buildFolder, "index.html"), path.join(buildFolder, "version.json")], {
base: buildFolder,
}) })
) .pipe($.sftp(deployCredentials));
.pipe( });
gulp.task(`ftp.upload.${deployEnv}.additionalFiles`, () => {
return gulp.src(additionalFiles, { base: additionalFolder }).pipe(
$.sftp({ $.sftp({
host: process.env.SHAPEZ_CLI_SERVER_HOST, host: process.env.SHAPEZ_CLI_SERVER_HOST,
user: process.env.SHAPEZ_CLI_STAGING_FTP_USER, user: process.env.SHAPEZ_CLI_STAGING_FTP_USER,
pass: process.env.SHAPEZ_CLI_STAGING_FTP_PW, pass: process.env.SHAPEZ_CLI_STAGING_FTP_PW,
}) })
); );
}); });
gulp.task("ftp.upload.staging.indexHtml", () => { gulp.task(`ftp.upload.${deployEnv}`, cb => {
return gulp.src(path.join(buildFolder, "index.html"), { base: buildFolder }).pipe( $.sequence(
$.sftp({ "ftp.writeVersion",
host: process.env.SHAPEZ_CLI_SERVER_HOST, `ftp.upload.${deployEnv}.game`,
user: process.env.SHAPEZ_CLI_STAGING_FTP_USER, `ftp.upload.${deployEnv}.indexHtml`,
pass: process.env.SHAPEZ_CLI_STAGING_FTP_PW, `ftp.upload.${deployEnv}.additionalFiles`
}) )(cb);
); });
}); }
gulp.task("ftp.upload.staging", cb => {
$.sequence("ftp.writeVersion", "ftp.upload.staging.game", "ftp.upload.staging.indexHtml")(cb);
});
gulp.task("ftp.upload.prod.game", () => {
return gulp
.src(gameSrcGlobs, { base: buildFolder })
.pipe(
$.rename(pth => {
pth.dirname = path.join("v", commitHash, pth.dirname);
})
)
.pipe(
$.sftp({
host: process.env.SHAPEZ_CLI_SERVER_HOST,
user: process.env.SHAPEZ_CLI_LIVE_FTP_USER,
pass: process.env.SHAPEZ_CLI_LIVE_FTP_PW,
})
);
});
gulp.task("ftp.upload.prod.indexHtml", () => {
return gulp.src(path.join(buildFolder, "index.html"), { base: buildFolder }).pipe(
$.sftp({
host: process.env.SHAPEZ_CLI_SERVER_HOST,
user: process.env.SHAPEZ_CLI_LIVE_FTP_USER,
pass: process.env.SHAPEZ_CLI_LIVE_FTP_PW,
})
);
});
gulp.task("ftp.upload.prod", cb => {
$.sequence("ftp.writeVersion", "ftp.upload.prod.game", "ftp.upload.prod.indexHtml")(cb);
});
} }
module.exports = { module.exports = {

View File

@ -71,20 +71,19 @@ export const globalConfig = {
debug: { debug: {
/* dev:start */ /* dev:start */
// fastGameEnter: true, fastGameEnter: true,
noArtificialDelays: true, noArtificialDelays: true,
// disableSavegameWrite: true, // disableSavegameWrite: true,
showEntityBounds: false, // showEntityBounds: true,
showAcceptorEjectors: false, // showAcceptorEjectors: true,
usePlainShapeIds: true,
disableMusic: true, disableMusic: true,
doNotRenderStatics: false, // doNotRenderStatics: true,
disableZoomLimits: false, // disableZoomLimits: true,
// showChunkBorders: true, // showChunkBorders: true,
rewardsInstant: false, // rewardsInstant: true,
allBuildingsUnlocked: true, // allBuildingsUnlocked: true,
upgradesNoCost: true, // upgradesNoCost: true,
disableUnlockDialog: true, // disableUnlockDialog: true,
// disableLogicTicks: true, // disableLogicTicks: true,
// testClipping: true, // testClipping: true,
// framePausesBetweenTicks: 40, // framePausesBetweenTicks: 40,

View File

@ -79,7 +79,7 @@ export class UndergroundBeltComponent extends Component {
} }
// Notice: We assume that for all items the travel distance is the same // Notice: We assume that for all items the travel distance is the same
const maxItemsInTunnel = (1 + travelDistance) / globalConfig.itemSpacingOnBelts; const maxItemsInTunnel = (2 + travelDistance) / globalConfig.itemSpacingOnBelts;
if (this.pendingItems.length >= maxItemsInTunnel) { if (this.pendingItems.length >= maxItemsInTunnel) {
// Simulate a real belt which gets full at some point // Simulate a real belt which gets full at some point
return false; return false;

View File

@ -36,7 +36,7 @@ export class HubGoals extends BasicSerializableObject {
} }
// Compute gained rewards // Compute gained rewards
for (let i = 0; i < this.level; ++i) { for (let i = 0; i < this.level - 1; ++i) {
if (i < tutorialGoals.length) { if (i < tutorialGoals.length) {
const reward = tutorialGoals[i].reward; const reward = tutorialGoals[i].reward;
this.gainedRewards[reward] = (this.gainedRewards[reward] || 0) + 1; this.gainedRewards[reward] = (this.gainedRewards[reward] || 0) + 1;