-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
941ab27
commit 893d8c0
Showing
3 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
|
||
/node_modules | ||
|
||
package-lock.json | ||
package-lock.json | ||
|
||
release.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,8 @@ | |
"express": "^4.18.2", | ||
"open": "^8.4.2", | ||
"table": "^6.8.1" | ||
}, | ||
"devDependencies": { | ||
"archiver": "^6.0.1" | ||
} | ||
} | ||
} |