
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
nanoweb-sync
Advanced tools
Nanoweb Sync is a basic abstract package that provides core functionalities for synchronizing and deploying files. It serves as the foundation for protocol-specific implementations like nanoweb-sync-ftp and nanoweb-sync-php.
deploy function for file synchronization.nanoweb-sync-ftp is built on top of nanoweb-sync and uses FTP protocol for file synchronization.nanoweb-sync-php is built on top of nanoweb-sync and communicates with a PHP-based backend.Ensure you have Node.js installed, then install dependencies:
npm install
To copy files from a public directory to a local directory:
import { deploy } from 'nanoweb-sync'
deploy({ publicDir: './public', local: './local', logger: console })
To use FTP:
npm install nanoweb-sync-ftp
To use PHP:
npm install nanoweb-sync-php
Should copy files from publicDir to local.
import process from 'node:process'
import { resolve } from 'node:path'
const PUBLIC_DIR = resolve(process.cwd(), 'public')
const LOCAL_DIR = resolve(process.cwd(), 'dist')
const logger = console
await deploy({ publicDir: PUBLIC_DIR, local: LOCAL_DIR, logger })
Should log a warning if publicDir is not defined.
import process from 'node:process'
import { resolve } from 'node:path'
const LOCAL_DIR = resolve(process.cwd(), 'dist')
const logger = console
await deploy({ local: LOCAL_DIR, logger })
// Public directory is not defined
Proposed configuration settings for the nanoweb-sync-* drivers.
Check env.example.
SYNC_HOST=ftp.nanoweb.org
SYNC_USER=nanoweb
SYNC_PASS=*********
SYNC_PORT=21
SYNC_SECURE=false
SYNC_MAX_CONNECTIONS=1
SYNC_ACCEPT_UNAUTHORIZED=true
SYNC_STRATEGY=sync
SYNC_LOCAL=dist
SYNC_REMOTE=/
SYNC_PUBLIC=public
SYNC_CACHE=.nanoweb-sync.json
SYNC_IGNORE=^v2/
Nanoweb Sync provides various utility functions to assist with file operations and synchronization.
This function generates an MD5 hash for a given file.
const hash = await getFileHash(join(PUBLIC_DIR, 'file.txt'))
console.log(hash);
// Outputs a 32-character hex string => 9473fdd0d880a43c21b7778d34872157
Retrieves a list of files and directories from a given path.
const result = await getAllFiles(PUBLIC_DIR)
console.log(result)
// Outputs { files: [{ path, size, hash }], directories: [] }
Identifies files that need to be uploaded based on changes.
@todo Add tests for ignore
cmd.addOption('ignore', String, true, 'Ignored paths regular expressions', ['^v2/', '.+/modules/.+'], true);
const mockResult = await findFilesToUpload({ recent: './recent.json', local: LOCAL_DIR, remote: '/remote', logger })
console.log(mockResult)
// Outputs { uploadQueue: Map(1), uploadDirs: [], uploadCount: 1, uploadSize: 12, skipCount: 0, skipSize: 0, skipList: {} }
Logs a friendly message to indicate the process completion.
takeCare(console)
// Outputs 'Take care 🙏'
To run tests:
npm test
Feel free to submit issues or pull requests if you find any improvements.
This project is licensed under the MIT License.
FAQs
Nanoweb sync driver abstract package
We found that nanoweb-sync demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.