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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vortecx/filegen-cli

v2.1.1

Published

File generator CLI for typescript backend projects

Downloads

31

Readme

Filegen CLI

Welcome to the Vortecx template-based file generator. In many projects, following a consistent code structure is crucial for maintenance. These structures, known as Patterns, often lead to repeated code elements. While some of these repetitions can't be abstracted into functions or other patterns, automation can still be applied.

In certain backend projects using object-oriented programming, I frequently encounter declarations for service, controller, repository, test, entity, and more. These are all usually linked to a specific functionality with a basic structure. Wouldn't it be great if we could generate all of these at once? Well, we can.

Getting Started

To begin, install the CLI and initiate the configuration with npm install --save-dev @vortecx/filegen-cli. Then, run npx fgen init to start the setup. A file like this should appear at the root of your project:

// fgen.ts
import { Config } from "@vortecx/filegen-cli";

// Let's add some modules
export const config: Config = {
  modules: [
    {
      name: "user",
      // For names that don't simply become plural by adding an 's',
      // define an array with the singular and plural forms
      types: ["controller", "service", ["repository", "repositories"]],
    },
    {
      name: ["company", "companies"],
      types: ["controller", "service", "presenter", "gateway"],
      ext: "js", // (optional) default is 'ts'
    },
  ],
};

With the modules created, you can set up the templates using npx fgen mold. This command will create a new folder named ".vortecx" at the root of your project, containing your templates. The templates are divided into header and body sections.

Everything before the --- line is the header, and below it is the content that will be inserted into the file. You can change the file's location and name right after ->, using some substitution patterns.

Possible Patterns: | Syntax | Description | EX: Input | EX: Output | | ------------- | --------------------------------------------------------------------------- | --------- | ---------- | | {{module}} | Will be replaced by the value of name for each module | test | test | | {{Module}} | | test | Test | | {{MODULE}} | | test | TEST | | {{modules}} | The module name + 's' or the second parameter of the array passed to name | test | tests | | {{Modules}} | | test | Tests | | {{MODULES}} | | test | TESTS | | {{name}} | Value entered during the interactive command | test | test | | {{Name}} | | test | Test | | {{NAME}} | | test | TEST | | {{type}} | The type of file being generated | test | test | | {{Type}} | | test | Test | | {{TYPE}} | | test | TEST | | {{ext}} | | js | js |

These are all the parameters passed to the template. Some, like name, are obtained during the generator's execution with npx fgen gen, which will prompt a selector to choose the name, modules, and types to generate.

Examples

Suppose you need a controller and a service for user creation. Define the user module in the fgen.ts configuration with the types service and controller:

import { Config } from "@vortecx/filegen-cli";

export const config: Config = {
  modules: [
    {
      name: "user",
      types: ["controller", "service"],
    },
  ],
};

After running npx fgen mold, the templates will appear in their respective folders within .vortex/fgen/{{module}}/{{type}}/index.vort. Let's take a closer look at one of these files, specifically the service template, assuming we want to export a service class:

folder->src/{{module}}/{{type}}/
filename->{{name}}.{{type}}.{{ext}}
---
import { Injectable } from '@nest/common'
import { {{Modules}}Repository } from '@modules/{{modules}}/repositories/{{Modules}}Repository'

type Request = {}

type Response = {}

// Here, the template becomes highly reusable since I can run the CLI
// and pass the name 'create', resulting in CreateUserService. If I pass 'update',
// it will become UpdateUserService, and so on.
@Injectable()
export class {{Name}}{{Module}}{{Type}} implements {{Type}} {
    constructor(
        private readonly {{modules}}Repository: {{Modules}}Repository
    ) {}

    async execute(req: Request): Promise<Response> {
        // #TODO
    }
}

This allows for a very granular and organized control over where files are generated, how they are structured, and what imports they include. It prevents various copy-paste errors while generating multiple files simultaneously.