0.1.9 • Published 3 months ago

@tsdiapi/cli v0.1.9

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

TSDIAPI CLI

A powerful and flexible command-line interface (CLI) for managing TSDIAPI projects. TSDIAPI is a modern, ESM-based framework built with TypeScript and NextNode, focusing on Dependency Injection (DI) and seamless integration with PrismaORM. The CLI allows you to create, extend, and automate your API development workflow with built-in support for plugins and generators.


Overview

TSDIAPI CLI is designed to provide a streamlined experience when working with TSDIAPI-based servers. It allows developers to:

  • Initialize new API projects quickly.
  • Extend functionality using modular plugins.
  • Automate code generation for services, controllers, and features.
  • Manage configuration files and environment variables effortlessly.
  • Integrate PrismaORM for database management with ease.

By default, the generated project provides a solid foundation for further customization, leveraging the power of Dependency Injection and PrismaORM for a robust development experience.


Get Started with npx

npx @tsdiapi/cli create my-api
cd my-api
npm start

Installation

Install the CLI globally using npm:

npm install -g @tsdiapi/cli

Once installed, use the tsdiapi command from any terminal.


Creating a New Project

To create a new API project, use:

tsdiapi init <project-name>

This will guide you through an interactive setup, allowing you to configure project details like name, host, and port.

Quick Start

For a fast setup that skips all prompts and immediately starts the server, use:

tsdiapi start <project-name>
CommandDescription
initCreates a new project with interactive setup.
createAlias for init, creates a new project with optional skipping.
startCreates a new project with defaults and starts it immediately.

Extending Your Project with Plugins

TSDIAPI supports modular extensions through plugins. Plugins can introduce features like Prisma ORM, Socket.IO, JWT authentication, and more.

Installing Plugins

To install a new plugin, use:

tsdiapi plugins add <plugin-name>

For example, to add Prisma support:

tsdiapi plugins add prisma

Configuring Plugins

Some plugins require additional configuration. Use:

tsdiapi plugins config <plugin-name>

This will guide you through setting up the necessary parameters.

🔗 Explore all available plugins


Generating Code Automatically

TSDIAPI CLI features a powerful code generation system that detects installed plugins and their generators dynamically.

Using Generators

To generate code, use:

tsdiapi generate <resource|pluginName> <name>

Example:

tsdiapi generate controller user

This will create a UserController.

ResourceDescription
featureGenerate a new feature module.
serviceGenerate a new service.
controllerGenerate a new controller.
<plugin>Use a specific plugin’s generator.

How Generators Work

  • Plugins define generators. Each plugin can introduce its own generators.
  • The CLI automatically detects installed plugins and provides relevant options.
  • You don’t need to configure generators manually—just install the required plugins.

PrismaORM Integration

TSDIAPI seamlessly integrates with PrismaORM for database management. The framework uses PrismaQL Core, a powerful SQL-like DSL for safely and programmatically editing Prisma schema files. This ensures a flexible and robust development workflow.

To add Prisma to your project, use:

tsdiapi prisma

This command will install and configure Prisma in your project, allowing you to manage models, fields, relations, and more with ease.

🔗 Learn more about PrismaQL Core


Developing Plugins

TSDIAPI CLI allows developers to create custom plugins that extend the framework. Plugins can introduce new services, middleware, configurations, and generators.

Creating a New Plugin

To generate a new plugin, use:

tsdiapi dev plugin <name>

This will guide you through configuring the plugin, including:

  • Name (automatically converted to the correct format).
  • Description.
  • Author name.
  • GitHub repository URL (optional).
  • Automatic file loading support.

Once configured, the CLI will generate the necessary files and set up a base plugin structure.

Validating Plugin Configuration

To check if a plugin’s configuration is correct, use:

tsdiapi dev check

This command validates the plugin’s configuration and ensures it follows best practices.


Plugin Lifecycle Methods

Each plugin supports the following lifecycle methods:

Here’s the updated table of all TSDIAPI CLI commands with their descriptions, formatted for a README.md file:


TSDIAPI CLI Commands

Below is a comprehensive list of all available commands in the TSDIAPI CLI, along with their descriptions.

CommandDescription
tsdiapi init [name]Initializes a new TSDIAPI project with an interactive setup.
tsdiapi create <name>Alias for init, creates a new project.
tsdiapi start <name>Quickly creates a project with default settings and starts the server.
tsdiapi plugins add <pluginName>Adds a plugin to the project.
tsdiapi add <pluginName>Alias for plugins add, adds a plugin to the project.
tsdiapi plugins config <pluginName>Configures an installed plugin.
tsdiapi config <pluginName>Alias for plugins config, configures a plugin.
tsdiapi plugins update <pluginName>Updates an installed plugin.
tsdiapi generate <pluginArg> <name>Generates files using a plugin or built-in generator.
tsdiapi prismaAdds PrismaORM to the project.
tsdiapi feature <name>Alias for generate feature <name>, generates a new feature module.
tsdiapi service <name> [feature]Alias for generate service <name> with optional feature module.
tsdiapi controller <name> [feature]Alias for generate controller <name> with optional feature module.

Developer Commands

CommandDescription
tsdiapi dev plugin <name>Creates a new plugin with an interactive setup.
tsdiapi dev checkValidates the configuration of a plugin.

Usage Examples

  1. Create a new project:

    tsdiapi create my-api
  2. Add the plugin:

    tsdiapi plugins add prisma
  3. Generate a feature:

    tsdiapi generate feature user

    or

    tsdiapi feature user
  4. Add Prisma to the project:

    tsdiapi prisma

Auto-loading Files

If a plugin supports auto-loading files, it should specify bootstrapFilesGlobPath in its configuration. This ensures that all matching files are automatically registered.


Contributing & Contact

TSDIAPI is an open-source project. Contributions are always welcome! If you want to contribute, suggest features, or report issues, feel free to reach out.

📧 Contact: unbywyd

🚀 Happy coding with TSDIAPI CLI!


Getting Started

  1. Install the CLI:

    npm install -g @tsdiapi/cli
  2. Create a new project:

    tsdiapi init my-api
  3. Add Prisma support:

    tsdiapi prisma
  4. Generate a new controller:

    tsdiapi generate controller user
  5. Start your server:

    cd my-api
    npm start

With TSDIAPI, you can build scalable, maintainable, and modular APIs with ease. Dive in and start building your next project today! 🚀

0.0.2-alpha.2

3 months ago

0.0.2-alpha.1

3 months ago

0.0.2-alpha.3

3 months ago

0.1.0

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.1.8

3 months ago

0.1.9

3 months ago

0.1.4

3 months ago

0.1.3

3 months ago

0.1.6

3 months ago

0.1.5

3 months ago

0.0.1-alpha.47

3 months ago

0.0.1-alpha.45

4 months ago

0.0.1-alpha.44

4 months ago

0.0.1-alpha.46

3 months ago

0.0.1-alpha.41

4 months ago

0.0.1-alpha.40

4 months ago

0.0.1-alpha.42

4 months ago

0.0.1-alpha.38

4 months ago

0.0.1-alpha.37

4 months ago

0.0.1-alpha.39

4 months ago

0.0.1-alpha.22

4 months ago

0.0.1-alpha.25

4 months ago

0.0.1-alpha.24

4 months ago

0.0.1-alpha.27

4 months ago

0.0.1-alpha.26

4 months ago

0.0.1-alpha.29

4 months ago

0.0.1-alpha.28

4 months ago

0.0.1-alpha.21

4 months ago

0.0.1-alpha.20

4 months ago

0.0.1-alpha.34

4 months ago

0.0.1-alpha.33

4 months ago

0.0.1-alpha.36

4 months ago

0.0.1-alpha.35

4 months ago

0.0.1-alpha.16

4 months ago

0.0.1-alpha.17

4 months ago

0.0.1-alpha.30

4 months ago

0.0.1-alpha.32

4 months ago

0.0.1-alpha.31

4 months ago

0.0.1-alpha.19

4 months ago

0.0.1-alpha.12

4 months ago

0.0.1-alpha.14

4 months ago

0.0.1-alpha.13

4 months ago

0.0.1-alpha.15

4 months ago

0.0.1-alpha.9

4 months ago

0.0.1-alpha.8

5 months ago

0.0.1-alpha.7

5 months ago

0.0.1-alpha.6

5 months ago

0.0.1-alpha.5

5 months ago

0.0.1-alpha.4

5 months ago

0.0.1-alpha.3

5 months ago

0.0.1-alpha.2

5 months ago

0.0.1-alpha.1

5 months ago