npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dir-cloner

v1.0.1

Published

Help user to clone directory

Downloads

94

Readme

Dir-Cloner

Dir-Cloner is a command-line tool for cloning directory structures into a JSON format, allowing you to selectively copy file contents, skip specific files or directories, and rebuild directory structures from the JSON file. This tool is particularly useful for replicating directory structures while avoiding large audio or video files or customizing the contents to be copied.

Features

  • Clone a Directory: Creates a JSON representation of the directory structure, including file and directory names. The JSON includes fields to indicate whether to copy file contents and whether to skip specific files or directories. Audio and video files are automatically excluded during the cloning process.
  • Selective Content Copying: You can rerun a command to copy the contents of files that are marked for content copying in a separate JSON file. This keeps the main JSON file easier to edit manually.
  • Rebuild Directory: Rebuild the directory structure from the JSON, optionally including file contents. The rebuild process only creates directories and files if they do not already exist.

Installation

To install Dir-Cloner, ensure you have Node.js installed, and then use npm to install the tool globally:

npm install -g dir-cloner

This will make the dir-cloner command available globally on your system.

Usage

1. Clone a Directory

The clone command generates a JSON file that represents the structure of a directory. By default, audio and video files will not have their contents copied.

dir-cloner clone -s /path/to/source/directory -o /path/to/output.json
  • -s, --source: Path to the source directory to be cloned.
  • -o, --output: Path to the output JSON file.

2. Edit the JSON

You can manually edit the generated JSON file to customize the structure:

  • Set "skip": true to skip a file or directory during the rebuild.
  • Set "copyContent": true or "copyContent": false to control whether the content of a file should be copied.

3. Copy Content of Files

Once the JSON file is configured, use the copy-content command to copy the contents of files that are marked for content copying. This command saves the content in a separate JSON file to keep the main JSON easier to manage.

dir-cloner copy-content -i /my/config/folder-structure.json -s /my/source/folder -o /my/config/updated-folder-structure.json
  • -i, --input: Path to the JSON file.
  • -s, --source: Path to the original source directory (used during cloning).
  • -d, --destination: Path to the output JSON file where updated content will be saved.
  • -v, --verbose: Enable verbose logging (optional).

4. Rebuild the Directory

The rebuild command reconstructs the directory structure from the JSON file. This will create directories and files as specified in the JSON. The content will be copied from a separate JSON file if it was previously done using the copy-content command.

dir-cloner rebuild -i /path/to/folder-structure.json -c /path/to/file-contents.json -d /path/to/destination
  • -i, --input: Path to the JSON file with directory structure.
  • -c, --content: Path to the JSON file with file contents.
  • -d, --destination: Path to the destination directory where the structure will be rebuilt.
  • -o, --overwrite: Overwrite existing files with content from JSON (optional, default: false).
  • -v, --verbose: Enable verbose logging (optional).

Example Workflow

Follow these steps to clone, customize, and rebuild a directory structure:

  1. Clone the directory:
dir-cloner clone -s /my/source/folder -o /my/config folder-structure.json

This command creates a JSON file representing the structure of /my/source/folder.

  1. Edit the JSON: Open /my/config/folder-structure.json and modify it according to your requirements. For example, set "skip": true for files you want to exclude or "copyContent": true for files you want to include content.

  2. Copy contents of specific files:

dir-cloner copy-content -i /my/config/folder-structure.json -s /my/source/folder -o /my/config/file-contents.json

This copies the contents of files marked with "copyContent": true from the source and saves the updated JSON to the specified output file.

  1. Rebuild the directory structure:
dir-cloner rebuild -i /my/config/folder-structure.json -c /my/config/file-contents.json -d /my/target/folder -o -v

This reconstructs the directory structure in /my/target/ folder as defined in the JSON file, and copies the file contents from the separate JSON file.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes with clear and descriptive messages.
  4. Push to your fork and submit a pull request.

Support

If you encounter any issues or have questions, feel free to open an issue on GitHub.

License

This project is licensed under the MIT License.