1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Prettier and tslint

This commit is contained in:
DJ1TJOO 2021-03-12 12:44:40 +01:00
parent d1ec4a5a88
commit d8c0e32c88
7 changed files with 63 additions and 48 deletions

View File

@ -6,7 +6,7 @@ const url = require("url");
const childProcess = require("child_process"); const childProcess = require("child_process");
const { ipcMain, shell } = require("electron"); const { ipcMain, shell } = require("electron");
const fs = require("fs"); const fs = require("fs");
const steam = require('./steam'); const steam = require("./steam");
const isDev = process.argv.indexOf("--dev") >= 0; const isDev = process.argv.indexOf("--dev") >= 0;
const isLocal = process.argv.indexOf("--local") >= 0; const isLocal = process.argv.indexOf("--local") >= 0;

View File

@ -1,5 +1,5 @@
const fs = require('fs'); const fs = require("fs");
const path = require('path'); const path = require("path");
const { ipcMain } = require("electron"); const { ipcMain } = require("electron");
let greenworks = null; let greenworks = null;
@ -14,7 +14,7 @@ try {
// throw err; // throw err;
} }
function init (isDev) { function init(isDev) {
if (!greenworks) { if (!greenworks) {
return; return;
} }
@ -34,7 +34,7 @@ function init (isDev) {
initialized = true; initialized = true;
} }
function listen () { function listen() {
ipcMain.handle("steam:is-initialized", isInitialized); ipcMain.handle("steam:is-initialized", isInitialized);
if (!greenworks || !initialized) { if (!greenworks || !initialized) {
@ -55,7 +55,7 @@ function isInitialized(event) {
function getAchievementNames(event) { function getAchievementNames(event) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
const achievements = greenworks.getAchievementNames() const achievements = greenworks.getAchievementNames();
resolve(achievements); resolve(achievements);
} catch (err) { } catch (err) {
reject(err); reject(err);
@ -65,23 +65,35 @@ function getAchievementNames(event) {
function getAchievement(event, id) { function getAchievement(event, id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
greenworks.getAchievement(id, () => resolve(), err => reject(err)) greenworks.getAchievement(
id,
() => resolve(),
err => reject(err)
);
}); });
} }
function activateAchievement(event, id) { function activateAchievement(event, id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
greenworks.activateAchievement(id, (is_achieved) => resolve(is_achieved), err => reject(err)) greenworks.activateAchievement(
id,
is_achieved => resolve(is_achieved),
err => reject(err)
);
}); });
} }
function deactivateAchievement(event, id) { function deactivateAchievement(event, id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
greenworks.clearAchievement(id, () => resolve(), err => reject(err)) greenworks.clearAchievement(
id,
() => resolve(),
err => reject(err)
);
}); });
} }
module.exports = { module.exports = {
init, init,
listen listen,
}; };

View File

@ -4,7 +4,7 @@ const { readFileSync, readdirSync, writeFileSync } = require("fs");
const suffixToScale = { const suffixToScale = {
lq: "0.25", lq: "0.25",
mq: "0.5", mq: "0.5",
hq: "0.75" hq: "0.75",
}; };
function convert(srcDir) { function convert(srcDir) {
@ -65,7 +65,7 @@ function convert(srcDir) {
x: xy[0], x: xy[0],
y: xy[1], y: xy[1],
w: size[0], w: size[0],
h: size[1] h: size[1],
}, },
// Whether image was rotated // Whether image was rotated
@ -75,21 +75,21 @@ function convert(srcDir) {
// How is the image trimmed // How is the image trimmed
spriteSourceSize: { spriteSourceSize: {
x: offset[0], x: offset[0],
y: (orig[1] - size[1]) - offset[1], y: orig[1] - size[1] - offset[1],
w: size[0], w: size[0],
h: size[1] h: size[1],
}, },
sourceSize: { sourceSize: {
w: orig[0], w: orig[0],
h: orig[1] h: orig[1],
} },
} };
} }
// Simple object that will hold other metadata // Simple object that will hold other metadata
current = { current = {
name: line name: line,
}; };
} else { } else {
// Read and set current image metadata // Read and set current image metadata
@ -108,14 +108,14 @@ function convert(srcDir) {
format: srcMeta.format, format: srcMeta.format,
size: { size: {
w: atlasSize[0], w: atlasSize[0],
h: atlasSize[1] h: atlasSize[1],
}, },
scale: atlasScale.toString() scale: atlasScale.toString(),
} },
}); });
writeFileSync(atlas.replace(".atlas", ".json"), result, { writeFileSync(atlas.replace(".atlas", ".json"), result, {
encoding: "utf-8" encoding: "utf-8",
}); });
} }
} }

View File

@ -29,7 +29,7 @@ module.exports = {
try { try {
return execSync("git describe --tag --exact-match").toString("ascii"); return execSync("git describe --tag --exact-match").toString("ascii");
} catch (e) { } catch (e) {
throw new Error('Current git HEAD is not a version tag'); throw new Error("Current git HEAD is not a version tag");
} }
}, },

View File

@ -24,7 +24,7 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
const currentTag = buildutils.getTag(); const currentTag = buildutils.getTag();
const octokit = new Octokit({ const octokit = new Octokit({
auth: process.env.SHAPEZ_CLI_GITHUB_TOKEN auth: process.env.SHAPEZ_CLI_GITHUB_TOKEN,
}); });
const createdRelease = await octokit.request("POST /repos/{owner}/{repo}/releases", { const createdRelease = await octokit.request("POST /repos/{owner}/{repo}/releases", {
@ -32,10 +32,12 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
repo: "shapez.io", repo: "shapez.io",
tag_name: currentTag, tag_name: currentTag,
name: currentTag, name: currentTag,
draft: true draft: true,
}); });
const { data: { id, upload_url } } = createdRelease; const {
data: { id, upload_url },
} = createdRelease;
console.log(`Created release ${id} for tag ${currentTag}`); console.log(`Created release ${id} for tag ${currentTag}`);
const dmgContents = fs.readFileSync(dmgPath); const dmgContents = fs.readFileSync(dmgPath);
@ -46,21 +48,23 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
method: "POST", method: "POST",
url: upload_url, url: upload_url,
headers: { headers: {
"content-type": "application/x-apple-diskimage" "content-type": "application/x-apple-diskimage",
}, },
name: dmgName, name: dmgName,
data: dmgContents data: dmgContents,
}); });
cb(); cb();
}); });
gulp.task("standalone.uploadRelease.darwin64", gulp.task(
"standalone.uploadRelease.darwin64",
gulp.series( gulp.series(
"standalone.uploadRelease.darwin64.cleanup", "standalone.uploadRelease.darwin64.cleanup",
"standalone.uploadRelease.darwin64.compress", "standalone.uploadRelease.darwin64.compress",
"standalone.uploadRelease.darwin64.upload" "standalone.uploadRelease.darwin64.upload"
)); )
);
} }
module.exports = { gulptasksReleaseUploader }; module.exports = { gulptasksReleaseUploader };

View File

@ -14,7 +14,7 @@ function gulptasksStandalone($, gulp) {
{ {
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"), tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"),
suffix: "", suffix: "",
taskPrefix: "" taskPrefix: "",
}, },
{ {
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"), tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"),
@ -27,8 +27,7 @@ function gulptasksStandalone($, gulp) {
const tempDestBuildDir = path.join(tempDestDir, "built"); const tempDestBuildDir = path.join(tempDestDir, "built");
gulp.task(taskPrefix + "standalone.prepare.cleanup", () => { gulp.task(taskPrefix + "standalone.prepare.cleanup", () => {
return gulp.src(tempDestDir, { read: false, allowEmpty: true }) return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
.pipe($.clean({ force: true }));
}); });
gulp.task(taskPrefix + "standalone.prepare.copyPrefab", () => { gulp.task(taskPrefix + "standalone.prepare.copyPrefab", () => {
@ -42,18 +41,21 @@ function gulptasksStandalone($, gulp) {
// https://github.com/gulpjs/gulp/issues/1427 // https://github.com/gulpjs/gulp/issues/1427
// path.join(electronBaseDir, "node_modules", "**", "*"), // path.join(electronBaseDir, "node_modules", "**", "*"),
]; ];
return gulp.src(requiredFiles, { base: electronBaseDir }) return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir));
.pipe(gulp.dest(tempDestBuildDir));
}); });
gulp.task(taskPrefix + "standalone.prepare.writePackageJson", cb => { gulp.task(taskPrefix + "standalone.prepare.writePackageJson", cb => {
const packageJsonString = JSON.stringify({ const packageJsonString = JSON.stringify(
scripts: { {
start: pj.scripts.start scripts: {
start: pj.scripts.start,
},
devDependencies: pj.devDependencies,
optionalDependencies: pj.optionalDependencies,
}, },
devDependencies: pj.devDependencies, null,
optionalDependencies: pj.optionalDependencies 4
}, null, 4); );
fs.writeFileSync(path.join(tempDestBuildDir, "package.json"), packageJsonString); fs.writeFileSync(path.join(tempDestBuildDir, "package.json"), packageJsonString);
@ -79,8 +81,7 @@ function gulptasksStandalone($, gulp) {
}); });
gulp.task(taskPrefix + "standalone.prepare.copyGamefiles", () => { gulp.task(taskPrefix + "standalone.prepare.copyGamefiles", () => {
return gulp.src("../build/**/*.*", { base: "../build" }) return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir));
.pipe(gulp.dest(tempDestBuildDir));
}); });
gulp.task(taskPrefix + "standalone.killRunningInstances", cb => { gulp.task(taskPrefix + "standalone.killRunningInstances", cb => {
@ -175,9 +176,7 @@ function gulptasksStandalone($, gulp) {
); );
} }
gulp.task(taskPrefix + "standalone.package.prod.win64", cb => gulp.task(taskPrefix + "standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb));
packageStandalone("win32", "x64", cb)
);
gulp.task(taskPrefix + "standalone.package.prod.linux64", cb => gulp.task(taskPrefix + "standalone.package.prod.linux64", cb =>
packageStandalone("linux", "x64", cb) packageStandalone("linux", "x64", cb)
); );

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["ES2018","WebWorker"] "lib": ["ES2018", "WebWorker"]
}, },
"exclude": [], "exclude": [],
"extends": "../tsconfig", "extends": "../tsconfig",