gfiletinator
v1.0.0
Published
Generate file with data and directory structure based on a text file
Downloads
7
Maintainers
Readme
gfileTinator 🚀
A simple Node.js script for rapidly creating a project's directory and file structure based on a predefined text file. Ideal for quickly bootstrapping new projects or generating repetitive code snippets.
Features ✨
- Parses a specific text format defining files and their content
- Automatically creates nested directories as needed
- Populates created files with the provided content, preserving indentation
- Supports creating empty files if a block contains no content
- Displays clear progress logs and potential errors during generation
Prerequisites 📋
- Node.js: Installed on your system (LTS version or newer recommended). You can check your version by typing
node -vin your terminal.
Installation 💾
Option 1: Local Installation
Clone the repository:
git clone https://github.com/stanislawmocia/gfileTinator.git cd gfileTinatorMake it executable:
chmod +x gfileTinator.js
Option 2: Global NPM Installation
Install the package globally to use it from anywhere:
npm install -g gfiletinatorUsage 🛠️
Run the script from your terminal, providing the path to the text file containing the structure definition as an argument. You should run the script inside the directory where you want the new project structure to be generated.
# Local usage
node gfileTinator.js <path/to/your/structure_file.txt>
# If made executable
./gfileTinator.js <path/to/your/structure_file.txt>
# If installed globally
gfiletinator <path/to/your/structure_file.txt>Example:
node gfileTinator.js project_template.txtInput File Format 📝
The input file (e.g., project_template.txt) defines the structure using a specific format:
- Separators: Individual file definitions are separated from each other by a long line of dashes:
–––––––––––––––––––––––––––––––––– - File Path: Immediately after the separator, on a new line, is the relative path to the file to be created (e.g.,
src/components/Button.jsor.gitignore). - File Content: All lines following the file path, up to the next separator (or the end of the file), constitute the content of that file.
- Indentation and formatting within the content block are preserved.
- Empty lines at the very beginning and end of the content block are ignored (trimmed).
- If there are no content lines after the file path before the next separator, an empty file will be created.
Example Input File (example_structure.txt)
––––––––––––––––––––––––––––––––––
README.md
––––––––––––––––––––––––––––––––––
# My Awesome New Project
Project description goes here.
## Getting Started
1. Clone the repo.
2. Run `npm install`.
3. ...
––––––––––––––––––––––––––––––––––
src/main.js
––––––––––––––––––––––––––––––––––
// Main application file
function startApp() {
console.log("Application starting!");
// TODO: Add more logic
}
startApp();
––––––––––––––––––––––––––––––––––
config/.env.example
––––––––––––––––––––––––––––––––––
API_KEY=your_api_key
DATABASE_URL=postgresql://user:pass@host:port/db
––––––––––––––––––––––––––––––––––
docs/empty_notes.txt
––––––––––––––––––––––––––––––––––Result of Running the Example
The following structure will be created in the directory where the script was executed:
.
├── README.md
├── config/
│ └── .env.example
├── docs/
│ └── empty_notes.txt
└── src/
└── main.jsThe files README.md, src/main.js, and config/.env.example will contain the content defined in example_structure.txt, and docs/empty_notes.txt will be an empty file.
License 📄
This script is released under the ISC License. Feel free to use and modify it as you wish.
