Skip to content

Commit

Permalink
Automatic release creator done.
Browse files Browse the repository at this point in the history
  • Loading branch information
patelka2211 committed Nov 20, 2023
1 parent 941ab27 commit 893d8c0
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

/node_modules

package-lock.json
package-lock.json

release.zip
54 changes: 54 additions & 0 deletions create-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const archiver = require("archiver");
const fs = require("fs");
const path = require("path");

// Create a writable stream for the zip file
const output = fs.createWriteStream("release.zip");
const archive = archiver("zip", {
zlib: { level: 9 }, // compression level
});

// Specify the files and folders to be included in the zip
const filesToZip = [
"back-end/bin/index.cjs.js",
"front-end/out/",
"LICENSE",
"package.json",
"README.md",
];

// Listen for all archive data to be written
output.on("close", () => {
console.log(`${archive.pointer()} total bytes`);
console.log(
"archiver has been finalized and the output file descriptor has closed."
);
});

archive.on("warning", (err) => {
if (err.code === "ENOENT") {
console.warn(err);
} else {
// throw error
throw err;
}
});

archive.on("error", (err) => {
throw err;
});

// Pipe archive data to the file
archive.pipe(output);

// Add files and folders to the archive
filesToZip.forEach((fileOrFolder) => {
const fullPath = path.resolve(__dirname, fileOrFolder);
const stats = fs.statSync(fullPath);

if (stats.isDirectory()) archive.directory(fullPath, fileOrFolder);
else archive.file(fullPath, { name: fileOrFolder });
});

// Finalize the archive (write the zip file)
archive.finalize();
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
"express": "^4.18.2",
"open": "^8.4.2",
"table": "^6.8.1"
},
"devDependencies": {
"archiver": "^6.0.1"
}
}
}

0 comments on commit 893d8c0

Please sign in to comment.