The last thing I do on a freelance web job, after the site works and the client has said it looks good, is pack the files. That sounds simple. It is not, if you pack the wrong folder.
I have almost sent a client a zip that still had a .env file in it. I have also sent zips that included node_modules, a .DS_Store, an editor folder and a debug log. None of those help the client. Some of them can cause real trouble. A secret in a delivery zip is still a secret that left your machine.
I'm a freelance full-stack developer in Karachi, and I now treat the delivery zip as its own small task, with a script I can run the same way every time. This post walks through that script: a default ignore list, a way to add your own patterns, a walk of the project folder, and a zip written in plain Node with no packages to install.
If you are new to handing work back on a marketplace, Digital Dialogue's guide on what to do after you win an Upwork job covers the human side of kickoff and delivery. The freelance client onboarding checklist is useful at the other end of the job, when you first get access. Here I'll stay with the files you actually attach.
What should not go in the zip
A delivery zip is not a backup of your working copy. It is the project the client can keep, reopen and, if they want, hand to the next developer. That means:
- Secrets stay out.
.env,.env.local, private keys,.pemfiles. - Dependencies are reinstallable.
node_modulesis large, machine-specific and easy to rebuild frompackage.json. - Your tools stay out.
.git,.vscode,.idea,.DS_Store, log files, coverage folders, Next.js cache folders. - The useful files stay in. Source,
package.json, a lockfile if you have one,README, assets the site needs, and any.env.examplethat lists variable names without values.
If the agreed delivery is a built static site, you can keep dist or build and still skip the rest. The script below does not ignore those folders by default, on purpose.
The ignore list
The script starts with a list of names I do not want to ship. A line that ends with / matches a folder anywhere in the tree. A line that starts with *. matches a suffix. Anything else matches that file name, including nested copies such as src/.env.local.
export const DEFAULT_IGNORE = [ "node_modules/", ".git/", ".svn/", ".hg/", ".DS_Store", "Thumbs.db", ".env", ".env.local", ".env.production", ".env.development", ".env.test", ".vscode/", ".idea/", "coverage/", ".next/", ".cache/", "npm-debug.log", "yarn-error.log", "*.log", "*.pem", "id_rsa", "id_rsa.pub", "id_ed25519", "id_ed25519.pub", ".deliveryignore", ]; A project can also add a .deliveryignore file next to the source, with one pattern per line and # for comments. That is how I skip a scratch file or a local screenshot folder without editing the script.
export function isIgnored(relPath, patterns) { const rel = relPath.split(sep).join("/"); const parts = rel.split("/"); const base = parts[parts.length - 1] || ""; for (const pat of patterns) { if (pat.startsWith("*.")) { if (base.endsWith(pat.slice(1))) return true; continue; } if (pat.endsWith("/")) { if (parts.includes(pat.slice(0, -1))) return true; continue; } if (base === pat || rel === pat) return true; } return false; } The folder test is done on path parts, so node_modules/left-pad/index.js is ignored even when it sits two levels down.
Walking the project and writing the zip
The walk is a normal recursive read. In the snippet below, fromRoot is a one-line helper that returns the path from the project folder to the current file. Each skipped path is kept on a list so I can see what was left out before I send the file.
export async function listFiles(sourceDir, patterns) { const kept = []; const skipped = []; async function walk(dir) { const entries = await readdir(dir, { withFileTypes: true }); for (const entry of entries) { const abs = join(dir, entry.name); const rel = fromRoot(sourceDir, abs); if (isIgnored(rel, patterns) || (entry.isDirectory() && isIgnored(rel + "/", patterns))) { skipped.push(rel.split(sep).join("/") + (entry.isDirectory() ? "/" : "")); continue; } if (entry.isDirectory()) await walk(abs); else if (entry.isFile()) kept.push(rel); } } await walk(sourceDir); kept.sort(); skipped.sort(); return { kept, skipped }; } For the zip itself I did not want a package, and I did not want to depend on a system zip binary. Node 18 and later already ship zlib.deflateRawSync and zlib.crc32, which is enough to write a standard ZIP file: a local file header and deflated bytes for each entry, then a central directory, then an end record. Any normal unzip tool can open the result, including the one on macOS, Windows and the unzip command on Linux.
The writer is a few dozen lines of buffers and unsigned integers, so I am not going to paste every byte here. The full file is pack-delivery.mjs in the companion folder I keep with this draft. The public function is small:
export async function pack(sourceDir, outPath) { const patterns = loadIgnore(sourceDir); const { kept, skipped } = await listFiles(sourceDir, patterns); if (kept.length === 0) { throw new Error("Nothing to pack. Every file matched the ignore list."); } await writeZip(sourceDir, kept, outPath); return { kept, skipped, outPath }; } Run it like this:
node pack-delivery.mjs ./my-site ./my-site-delivery.zip It prints the path it wrote, how many files were packed, and every skipped path. That skip list is the part I actually read. If .env is not on it, I stop and find out why.
A test fixture, not a hope
I do not want to discover a leaked secret after the zip has been sent. A short test builds a fake project with a source file, package.json, a README, node_modules, .env, a nested .env.local, a .DS_Store, a log file and a scratch file named in .deliveryignore. Then it packs that folder and opens the zip back up.
On a run of that test, the zip contained:
README.md, package.json, src/index.js and skipped:
.DS_Store, .deliveryignore, .env, debug.log, node_modules/, notes.tmp, src/.env.local That is the result I want: the project, and nothing that belongs only on my machine. The test also checks that the bytes inside src/index.js survive the round trip, so the zip is not just a list of names.
A few habits around the script
Read the skip list every time. The script will not catch a secret with a surprising name, such as passwords.txt or firebase-adminsdk.json. If I have created a file like that, I add it to .deliveryignore or I move it out of the project folder.
Keep an example env file, not a real one. A .env.example with empty or clearly fake values is useful. The real file stays out of the zip.
Say what you sent. In the delivery message I mention that node_modules is not included and that the client can run npm install from package.json. I also mention any build step, and I attach the zip as the file I just built, not an older one sitting on the desktop.
Do not pack from the wrong folder. I run the command from a known path and pass the project folder explicitly. Packing my home directory, or packing a folder that still contains other clients' work, is a mistake the ignore list cannot fix.
Built site or source folder?
Some jobs ask for the source. Some ask for a folder the client can drop onto hosting. Those are different zips.
- Source delivery. Keep
package.json, the source, the README and a lockfile. Skipnode_modulesand skip any compiled output you can rebuild. Say how to install and how to start the dev server. - Static hosting delivery. If the client only needs files they can upload to Netlify, GitHub Pages, cPanel or a similar host, pack the built output (
dist,build,outor_site) plus a short README that says "upload the contents of this folder". Skip the source if that was the agreement, or send two zips if they want both. - WordPress or PHP on shared hosting. Pack the theme or plugin you actually built, not the whole
wp-contenttree of some other project, and notwp-config.phpwith the database password still in it.
The script does not make this choice for you. It only stops the obvious junk from riding along. You still pick the folder you point it at.
Before you click send
I run through a short list, out loud if I am tired:
- I opened the zip on my own machine and confirmed the top-level folder looks right.
- I searched the skip list for
.envand fornode_modules. - I searched the packed file list for anything named like a key, a password or a dump.
- I confirmed the README I packed is the one I meant to send, not an old scratch file.
- I wrote the delivery message so the client knows what to unzip, what to install and how to reach me about problems.
None of that takes long. It is much cheaper than sending the wrong file and then writing an apology.
The script will not make you a more careful freelancer on its own. It just removes a class of mistakes that are easy to make at the end of a job, when you want to close the tab and move on. I still run it, every time, because that is exactly when those mistakes happen.
Once the zip is clean, the rest of the close-out is the usual work: a short delivery note, a walkthrough of how to run the project, and anything the contract says you still owe. The script only handles the files. The message still has to be written by you.
If you want a wider view of how web work runs on the marketplace, how Upwork works for a freelance web developer is a clear starting point. Use the script as a last check, not as a substitute for reading what you are about to send.