Plugin-System Tutorial

- Arshpreet Singh Sandhu | Purdue University

Connect with me on LinkedIN and Github

Welcome to the Node.js CLI Plugin Tutorial! This tutorial will guide you through the process of creating and registering custom plugins in the Node.js CLI text transformation application. By following these steps, you will learn how to extend the functionality of the CLI app with ease. Whether you're a beginner or an experienced developer, this tutorial will help you get started with plugin development.

Step 1 - Set Up the Project

Before we begin, let's make sure you have the base project set up. Clone this github repository and follow the instructions given on the README to run it on your local machine. Link to the repository - Node-CLI-Plugin-System

Step 2 - Create Plugin File

A) Create a New File:

Create a new file named alphabetCountPlugin.ts in your plugins directory.

B) Implement the Plugin:

In this file, you'll implement the TextPlugin interface and define the transformText method. This method will contain the logic to count the alphabets in the input text. 

An example is provided below.

Step 3 - Surprise! Your plugin is already registered

Congratulations ! You've successfully created and registered your plugin

Here's how the system finds and registers your plugin

 

  • Setup: The code initializes a PluginManager and defines the path to the plugins directory where all plugin files are stored.

  • Registering Plugins: It reads all .js files in the plugins directory, extracting each file's name and registering it with the PluginManager. Each plugin is identified by its name and relative path.

  • Running the CLI: A TextCLI instance is created with the registered plugins, and cli.displayPrompt() starts the CLI, allowing users to interact with and apply text transformations using the available plugins.

 

 

PRO TIPS

What to do after registering the plugin?

On your terminal, navigate to the src or root directory where your typescript files are and enter 'npx tsc' . Then navigate to the directory where your javascript files are transpiled and run the project using 'node index.js' . 

 

I built a plugin? What next?

Create a pull request and contribute to the github repository given above. Think of more creative plugins and enjoy building.

How can we connect?

Connect with me on LinkedIN/ Github and send me a dm.

“A Heartfelt Thank You to Medical Informatics Engineering, Fort Wayne”

I would like to extend my deepest gratitude to Medical Informatics Engineering, Fort Wayne, for providing me with the incredible opportunity to intern with such a forward-thinking and innovative company. This project, along with many others during my internship, has been a transformative experience for me.

A special thank you to our esteemed CEO, Doug Horner, whose unwavering guidance and support have been instrumental in my development. Doug's mentorship has not only helped me hone my technical skills but has also inspired me to contribute to open source projects and strive for excellence in all my endeavors.

About Me 

Visit my personal website to know more about me - link

Add comment

Comments

There are no comments yet.
Rating: 5 stars
1 vote