1.0.3 • Published 4 months ago

folder-validator v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Folder Validator 📁

npm version License: MIT Node.js Version

The Folder Validator package is a powerful tool designed to ensure consistency in your application's folder structure across different developers. With this package, you can maintain a uniform folder layout, preventing any structural changes that might lead to application breaks.

"I've created this package because I was tired of having to check the folder structure of my application every time another developer was working on it. I wanted to make sure that the folder structure of my application was consistent and that it was not changed by another developer preventing breaks in the application, so I created this package." - Daniel Rosa

🌟 Key Features

  • Structure Validation: Automatically validates your project's folder structure against a predefined configuration
  • Real-time Monitoring: Watch mode for continuous folder structure validation during development
  • Flexible Configuration: Simple and intuitive configuration file to define your desired folder structure
  • Required vs Optional: Specify which folders are mandatory and which are optional
  • Nested Structures: Support for deep nested folder hierarchies
  • Developer Friendly: Clear error messages and validation feedback
  • Zero Runtime Dependencies: Lightweight and fast execution

🚀 Why Folder Validator?

  • Maintain Consistency: Ensure all team members follow the same project structure
  • Prevent Breaking Changes: Catch structural inconsistencies before they cause issues
  • Improve Onboarding: New developers can quickly understand and maintain the correct project structure
  • CI/CD Integration: Easy to integrate into your continuous integration pipeline
  • Framework Agnostic: Works with any JavaScript/TypeScript project structure

📦 Installation

npm install folder-validator -D

🛠️ Usage

  1. Create a folder.config.js file in your project root:
export default [
  {
    name: "src",
    required: true,
    children: [
      {
        name: "components",
        required: true,
      },
      {
        name: "pages",
        required: true,
      },
    ],
  },
  {
    name: "public",
    required: true,
  },
  {
    name: "styles",
    required: false,
  },
];
  1. Add validation scripts to your package.json:
{
  "scripts": {
    "validate:folders": "folder-validator",
    "validate:watch": "folder-validator --watch"
  }
}
  1. Run the validator:
# One-time validation
npm run validate:folders

# Watch mode for development
npm run validate:watch

📖 Configuration Options

Folder Definition

PropertyTypeDescription
namestringName of the folder
requiredbooleanWhether the folder must exist
childrenarrayNested folder definitions (optional)

🔍 Examples

Basic Structure

export default [
  {
    name: "src",
    required: true,
  },
];

Complex Structure

export default [
  {
    name: "src",
    required: true,
    children: [
      {
        name: "components",
        required: true,
        children: [
          {
            name: "common",
            required: true,
          },
          {
            name: "layouts",
            required: false,
          },
        ],
      },
    ],
  },
];

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author

Daniel Rosa

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago