Create script to quickly create release zip files

This commit is contained in:
Wolvan 2022-02-04 22:10:58 +01:00
parent 8e0dcbf232
commit bb6004f219
6 changed files with 1129 additions and 186 deletions

View file

@ -21,6 +21,7 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/releases
README.md
CHANGELOG.md
API.md

View file

@ -2,3 +2,4 @@ dist/
node_modules/
utils/todo-finder.js
utils/create-favicons.js
utils/create-release-zip.js

3
.gitignore vendored
View file

@ -120,3 +120,6 @@ config*.js*
# Favicons that are being auto-generated
frontend/favicons/
# Releases
releases/

1259
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,8 @@
"find-todo": "node utils/todo-finder.js ./src && node utils/todo-finder.js ./frontend",
"mocha": "mocha",
"lint": "eslint .",
"build:release-zip": "node utils/create-release-zip",
"build:release": "npm test && npm run build && npm run build:release-zip",
"build:favicons": "node utils/create-favicons",
"build": "rimraf ./dist && npm run build:favicons && tsc",
"test": "npm run lint && npm run find-todo && npm run mocha",
@ -50,6 +52,7 @@
"@types/serve-favicon": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"archiver": "^5.3.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint": "^8.3.0",

View file

@ -0,0 +1,48 @@
"use strict";
const archiver = require("archiver");
const fs = require("fs");
const { resolve } = require("path");
const { version } = require("../package.json");
fs.mkdirSync(resolve(__dirname, "../releases"), { recursive: true });
const output = fs.createWriteStream(resolve(__dirname, "../releases/Release-" + version + ".zip"));
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
output
.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
if (require("os").platform() !== "win32") {
if (fs.existsSync(resolve(__dirname, "../releases/latest.zip")))
fs.unlinkSync(resolve(__dirname, "../releases/latest.zip"));
fs.symlinkSync("Release-" + version + ".zip", resolve(__dirname, "../releases/latest.zip"));
}
});
archive
.on('warning', function(err) {
if (err.code === 'ENOENT') {
console.warn(err);
} else {
throw err;
}
})
.on('error', function(err) {
throw err;
});
archive.pipe(output);
[
"package.json",
"package-lock.json"
].forEach(file => archive.append(fs.createReadStream(resolve(__dirname, "..", file)), { name: file }));
[
"frontend/",
"dist/"
].forEach(dir => archive.directory(resolve(__dirname, "..", dir), dir));
archive.finalize();