Skip to content

Commit

Permalink
Updated unlimited resources for 0.17, changed helper scripts to types…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
barthuijgen committed May 1, 2019
1 parent a2aa482 commit e5536fa
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 63 deletions.
56 changes: 0 additions & 56 deletions build.js

This file was deleted.

56 changes: 56 additions & 0 deletions build.ts
@@ -0,0 +1,56 @@
import * as path from "path";
import * as util from "util";
import * as fs from "fs-extra";
import * as archiver from "archiver";

const OUTPUT_DIR = path.join(__dirname, "build");

async function main() {
if (!process.argv[2]) {
return console.log("Please supply a directory name as argument");
}

const mod = path.join(__dirname, process.argv[2]);

fs.stat(mod, (err, x) => {
if (err) return console.log(`The directory ${mod} does not exist`);
if (!x.isDirectory()) return console.log(`${mod} is not a directory`);

build(mod);
});
}

async function build(mod_name: string) {
console.log(`Building ${mod_name}`);

const info = await fs.readJSON(path.join(mod_name, "info.json"));
const filename = `${info.name}_${info.version}`;

await zip(mod_name, filename);
}

async function zip(mod_name: string, filename: string) {
return new Promise(async (resolve, reject) => {
console.log(`Zipping ${mod_name}...`);

await fs.ensureDir(OUTPUT_DIR);

const output_path = path.resolve(OUTPUT_DIR, `${filename}.zip`);
const output = fs.createWriteStream(output_path);

const archive = archiver("zip", {
zlib: { level: 9 }
});

archive.directory(mod_name, filename);

output.on("close", () => {
console.log(`Done: ${output_path} [${Math.round(archive.pointer() / 102.4) / 10}kb]`);
});

archive.pipe(output);
archive.finalize();
});
}

main().catch(console.error);
128 changes: 128 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions package.json
Expand Up @@ -4,7 +4,8 @@
"description": "Node build script to automatically zip mods",
"main": "build.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "ts-node build.ts",
"watch": "ts-node watch.ts"
},
"repository": {
"type": "git",
Expand All @@ -18,6 +19,13 @@
"homepage": "https://gitlab.com/barrykun/factorio#README",
"dependencies": {
"archiver": "^3.0.0",
"readdirp": "^2.2.1"
"fs-extra": "^7.0.1",
"readdirp": "^2.2.1",
"ts-node": "^8.1.0",
"typescript": "^3.4.5"
},
"devDependencies": {
"@types/archiver": "^2.1.3",
"@types/fs-extra": "^5.0.5"
}
}
6 changes: 3 additions & 3 deletions unlimited-resources/README.md
@@ -1,16 +1,16 @@
# Unlimited Resources

Ore patches cannot empty and are unlimted and automatically refill, configure numbers in mod settings!
Ore patches cannot empty and are unlimited and automatically refill, configure numbers in mod settings!

- When a ore patch depletes it is automatically refilled to the defined amount
- When new parts of the map are generated ore patches are set to defined amount
- When you enable interval refill, ore patches are set to defined amount on interval

## Known issues

Having refill enabled will cause lag spikes on the interval, this is likely to cause issues on multiplayer. Setting the time high is reccomended if you use it. For this reason it is disabled by default, I am still looking for more multiplayer-friendly ways to handle refilling ore patches.
Having refill enabled will cause lag spikes on the interval, this is likely to cause issues on multiplayer. Setting the time high is recommended if you use it. For this reason it is disabled by default, I am still looking for more multiplayer-friendly ways to handle refilling ore patches.

# Changelog
# Change log

### 1.0.8

Expand Down
2 changes: 1 addition & 1 deletion unlimited-resources/info.json
@@ -1,6 +1,6 @@
{
"name": "Unlimited-Resources",
"version": "1.0.9",
"version": "1.0.8",
"factorio_version": "0.17",
"title": "Unlimited Resources",
"author": "Barry",
Expand Down
2 changes: 1 addition & 1 deletion watch.js → watch.ts
Expand Up @@ -45,7 +45,7 @@ async function watch(mod) {
watchDirectory(file.fullPath, mod, destination);
})
.on("error", reason => {
reject(reason);
console.error(reason);
})
.on("end", () => {
console.log(`Now watching all files in ${mod}`);
Expand Down

0 comments on commit e5536fa

Please sign in to comment.