mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-23 21:27:59 +01:00
Create script to quickly create release zip files
This commit is contained in:
parent
8e0dcbf232
commit
bb6004f219
6 changed files with 1129 additions and 186 deletions
|
@ -21,6 +21,7 @@
|
|||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
**/releases
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
API.md
|
||||
|
|
|
@ -2,3 +2,4 @@ dist/
|
|||
node_modules/
|
||||
utils/todo-finder.js
|
||||
utils/create-favicons.js
|
||||
utils/create-release-zip.js
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -120,3 +120,6 @@ config*.js*
|
|||
|
||||
# Favicons that are being auto-generated
|
||||
frontend/favicons/
|
||||
|
||||
# Releases
|
||||
releases/
|
||||
|
|
1259
package-lock.json
generated
1259
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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",
|
||||
|
|
48
utils/create-release-zip.js
Normal file
48
utils/create-release-zip.js
Normal 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();
|
Loading…
Reference in a new issue