This is the public-sync
template. It's designed to help you work on your code in a Private
folder and sync non-sensitive files to a Public
folder.
π Quick Start
- Create & Clone: Use this template to create a new repo and clone it.
- Install: Run
npm install
in your local repo. - Init: Run
npm run sync
to createPrivate
&Public
folder. - Work: Add your code to the
Private
folder. - Configure: Adjust
public-sync
settings inpackage.json
if needed. - Sync: Run
npm run sync
to copy files fromPrivate
toPublic
. - Commit & Push: Use
git
commands in your synced directories.
Running npm run sync
copies all files from Private
to Public
, excluding sensitive files. You can specify which files are sensitive in package.json
. This allows you to share your project without exposing sensitive information. For more details, visit the public-sync repository.
After syncing, you can use git
in the Public
folder. The .git
folder is not affected by the sync process, so your version history is preserved.
You can also maintain a separate Git repo in the Private
folder. The .git
folder in Private
is not synced, allowing you to keep some version history private.
Here's how I set up my folders:
.
βββ Private
β βββ .git (private git repo)
β βββ client
β β βββ ... (client-side code)
β β βββ .env (client-side secrets)
β βββ server
β βββ ... (server-side code)
β βββ .env (server-side secrets)
βββ Public
βββ .git (public git repo)
βββ client
β βββ ... (client-side code)
βββ server
βββ ... (server-side code)
I keep .env
files in Private
for client and server secrets. Public
gets all the code, but no .env
files. I set public-sync
to skip .env
files.
I use separate .git
folders in both Public
and Private
for independent version control. This lets me share my code publicly, while keeping sensitive data secure and synced. Remember, the .git
folder can be anywhere. This setup keeps my secrets secret while I share my code.
If you're only dealing with either server or client, you can simplify the structure. Just put your source code directly in the Private
folder. No need to create a separate server
or client
folder.