mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Formated
This commit is contained in:
parent
f789dcc80e
commit
db215dc5b3
@ -11,14 +11,14 @@ const isLocal = process.argv.indexOf("--local") >= 0;
|
||||
|
||||
const roamingFolder =
|
||||
process.env.APPDATA ||
|
||||
(process.platform == "darwin" ?
|
||||
process.env.HOME + "/Library/Preferences" :
|
||||
process.env.HOME + "/.local/share");
|
||||
(process.platform == "darwin"
|
||||
? process.env.HOME + "/Library/Preferences"
|
||||
: process.env.HOME + "/.local/share");
|
||||
let storePath = path.join(roamingFolder, "shapez.io", "saves");
|
||||
let modsPath = path.join(roamingFolder, "shapez.io", "mods");
|
||||
|
||||
if (!fs.existsSync(storePath))
|
||||
// No try-catch by design
|
||||
// No try-catch by design
|
||||
fs.mkdirSync(storePath, { recursive: true });
|
||||
|
||||
if (!fs.existsSync(modsPath)) fs.mkdirSync(modsPath);
|
||||
@ -157,21 +157,19 @@ ipcMain.on("exit-app", (event, flag) => {
|
||||
function performFsJob(job) {
|
||||
let parent = storePath;
|
||||
|
||||
if (job.mods)
|
||||
let parent = modsPath;
|
||||
if (job.mods) parent = modsPath;
|
||||
|
||||
const fname = path.join(parent, job.filename);
|
||||
const relative = path.relative(parent, fname);
|
||||
|
||||
//If not a child of parent
|
||||
if(!relative && !relative.startsWith('..') && !path.isAbsolute(relative))
|
||||
if (!relative && !relative.startsWith("..") && !path.isAbsolute(relative))
|
||||
return {
|
||||
error: "Cannot get above parent folder"
|
||||
}
|
||||
error: "Cannot get above parent folder",
|
||||
};
|
||||
|
||||
switch (job.type) {
|
||||
case "readDir":
|
||||
{
|
||||
case "readDir": {
|
||||
let contents = "";
|
||||
try {
|
||||
contents = fs.readdirSync(fname, { encoding: "utf8" });
|
||||
@ -185,8 +183,7 @@ function performFsJob(job) {
|
||||
data: contents,
|
||||
};
|
||||
}
|
||||
case "read":
|
||||
{
|
||||
case "read": {
|
||||
if (!fs.existsSync(fname)) {
|
||||
return {
|
||||
// Special FILE_NOT_FOUND error code
|
||||
@ -208,8 +205,7 @@ function performFsJob(job) {
|
||||
data: contents,
|
||||
};
|
||||
}
|
||||
case "write":
|
||||
{
|
||||
case "write": {
|
||||
try {
|
||||
fs.writeFileSync(fname, job.contents);
|
||||
} catch (ex) {
|
||||
@ -224,8 +220,7 @@ function performFsJob(job) {
|
||||
};
|
||||
}
|
||||
|
||||
case "delete":
|
||||
{
|
||||
case "delete": {
|
||||
try {
|
||||
fs.unlinkSync(fname);
|
||||
} catch (ex) {
|
||||
|
@ -4,7 +4,7 @@ const { readFileSync, readdirSync, writeFileSync } = require("fs");
|
||||
const suffixToScale = {
|
||||
lq: "0.25",
|
||||
mq: "0.5",
|
||||
hq: "0.75"
|
||||
hq: "0.75",
|
||||
};
|
||||
|
||||
function convert(srcDir) {
|
||||
@ -65,7 +65,7 @@ function convert(srcDir) {
|
||||
x: xy[0],
|
||||
y: xy[1],
|
||||
w: size[0],
|
||||
h: size[1]
|
||||
h: size[1],
|
||||
},
|
||||
|
||||
// Whether image was rotated
|
||||
@ -75,21 +75,21 @@ function convert(srcDir) {
|
||||
// How is the image trimmed
|
||||
spriteSourceSize: {
|
||||
x: offset[0],
|
||||
y: (orig[1] - size[1]) - offset[1],
|
||||
y: orig[1] - size[1] - offset[1],
|
||||
w: size[0],
|
||||
h: size[1]
|
||||
h: size[1],
|
||||
},
|
||||
|
||||
sourceSize: {
|
||||
w: orig[0],
|
||||
h: orig[1]
|
||||
}
|
||||
}
|
||||
h: orig[1],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Simple object that will hold other metadata
|
||||
current = {
|
||||
name: line
|
||||
name: line,
|
||||
};
|
||||
} else {
|
||||
// Read and set current image metadata
|
||||
@ -108,14 +108,14 @@ function convert(srcDir) {
|
||||
format: srcMeta.format,
|
||||
size: {
|
||||
w: atlasSize[0],
|
||||
h: atlasSize[1]
|
||||
h: atlasSize[1],
|
||||
},
|
||||
scale: atlasScale.toString(),
|
||||
},
|
||||
scale: atlasScale.toString()
|
||||
}
|
||||
});
|
||||
|
||||
writeFileSync(atlas.replace(".atlas", ".json"), result, {
|
||||
encoding: "utf-8"
|
||||
encoding: "utf-8",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ module.exports = {
|
||||
try {
|
||||
return execSync("git describe --tag --exact-match").toString("ascii");
|
||||
} catch (e) {
|
||||
throw new Error('Current git HEAD is not a version tag');
|
||||
throw new Error("Current git HEAD is not a version tag");
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -6,7 +6,6 @@ function requireUncached(module) {
|
||||
}
|
||||
|
||||
function gulptasksJS($, gulp, buildFolder, browserSync) {
|
||||
|
||||
//// DEV
|
||||
|
||||
gulp.task("js.dev.watch", () => {
|
||||
|
@ -24,7 +24,7 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
|
||||
const currentTag = buildutils.getTag();
|
||||
|
||||
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", {
|
||||
@ -32,10 +32,12 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
|
||||
repo: "shapez.io",
|
||||
tag_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}`);
|
||||
|
||||
const dmgContents = fs.readFileSync(dmgPath);
|
||||
@ -46,21 +48,23 @@ function gulptasksReleaseUploader($, gulp, buildFolder) {
|
||||
method: "POST",
|
||||
url: upload_url,
|
||||
headers: {
|
||||
"content-type": "application/x-apple-diskimage"
|
||||
"content-type": "application/x-apple-diskimage",
|
||||
},
|
||||
name: dmgName,
|
||||
data: dmgContents
|
||||
data: dmgContents,
|
||||
});
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task("standalone.uploadRelease.darwin64",
|
||||
gulp.task(
|
||||
"standalone.uploadRelease.darwin64",
|
||||
gulp.series(
|
||||
"standalone.uploadRelease.darwin64.cleanup",
|
||||
"standalone.uploadRelease.darwin64.compress",
|
||||
"standalone.uploadRelease.darwin64.upload"
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { gulptasksReleaseUploader };
|
||||
|
@ -27,7 +27,8 @@ module.exports = ({ watch = false, standalone = false }) => {
|
||||
new webpack.DefinePlugin({
|
||||
assert: "window.assert",
|
||||
assertAlways: "window.assert",
|
||||
abstract: "window.assert(false, 'abstract method called of: ' + (this.name || (this.constructor && this.constructor.name)));",
|
||||
abstract:
|
||||
"window.assert(false, 'abstract method called of: ' + (this.name || (this.constructor && this.constructor.name)));",
|
||||
G_HAVE_ASSERT: "true",
|
||||
G_APP_ENVIRONMENT: JSON.stringify("dev"),
|
||||
G_TRACKING_ENDPOINT: JSON.stringify(
|
||||
@ -60,7 +61,8 @@ module.exports = ({ watch = false, standalone = false }) => {
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [{
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/,
|
||||
enforce: "pre",
|
||||
use: ["./gulp/loader.compressjson"],
|
||||
@ -69,7 +71,8 @@ module.exports = ({ watch = false, standalone = false }) => {
|
||||
{ test: /\.(png|jpe?g|svg)$/, loader: "ignore-loader" },
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: [{
|
||||
use: [
|
||||
{
|
||||
loader: "html-loader",
|
||||
},
|
||||
"markdown-loader",
|
||||
@ -79,13 +82,15 @@ module.exports = ({ watch = false, standalone = false }) => {
|
||||
test: /\.js$/,
|
||||
enforce: "pre",
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
use: [
|
||||
{
|
||||
loader: "webpack-strip-block",
|
||||
options: {
|
||||
start: "typehints:start",
|
||||
end: "typehints:end",
|
||||
},
|
||||
}, ],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.worker\.js$/,
|
||||
|
@ -139,7 +139,8 @@ module.exports = ({
|
||||
beautify: false,
|
||||
braces: false,
|
||||
ecma: es6 ? 6 : 5,
|
||||
preamble: "/* shapez.io Codebase - Copyright 2020 Tobias Springer - " +
|
||||
preamble:
|
||||
"/* shapez.io Codebase - Copyright 2020 Tobias Springer - " +
|
||||
getVersion() +
|
||||
" @ " +
|
||||
getRevision() +
|
||||
@ -163,7 +164,8 @@ module.exports = ({
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [{
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/,
|
||||
enforce: "pre",
|
||||
use: ["./gulp/loader.compressjson"],
|
||||
@ -174,7 +176,8 @@ module.exports = ({
|
||||
test: /\.js$/,
|
||||
enforce: "pre",
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
use: [
|
||||
{
|
||||
loader: "webpack-strip-block",
|
||||
options: {
|
||||
start: "typehints:start",
|
||||
@ -225,7 +228,8 @@ module.exports = ({
|
||||
},
|
||||
{
|
||||
test: /\.worker\.js$/,
|
||||
use: [{
|
||||
use: [
|
||||
{
|
||||
loader: "worker-loader",
|
||||
options: {
|
||||
fallback: false,
|
||||
|
@ -10,7 +10,7 @@
|
||||
"dev": "cd gulp && yarn gulp main.serveDev",
|
||||
"tslint": "cd src/js && tsc",
|
||||
"lint": "eslint src/js",
|
||||
"prettier-all": "prettier --write src/**/*.* && prettier --write gulp/**/*.*",
|
||||
"prettier-all": "prettier --write src/**/*.* && prettier --write gulp/**/*.* && prettier --write electron/**/*.*",
|
||||
"publishOnItchWindows": "butler push tmp_standalone_files/shapez.io-standalone-win32-x64 tobspr/shapezio:windows --userversion-file version",
|
||||
"publishOnItchLinux": "butler push tmp_standalone_files/shapez.io-standalone-linux-x64 tobspr/shapezio:linux --userversion-file version",
|
||||
"publishOnItch": "yarn publishOnItchWindows && yarn publishOnItchLinux",
|
||||
|
Loading…
Reference in New Issue
Block a user