1. CLI
LazyKit provides a powerful CLI program that allows you to add utility methods to your project like a pro. This guide will walk you through the initial setup, installation, and teardown commands for effectively managing utility methods.
1. Introduction
One of the simplest ways to add utility methods to your project is by copying the code and pasting it directly into your files. However, this approach can become cumbersome and inefficient over time. The LazyKit CLI program streamlines this process, allowing you to add utility methods to your project in a more efficient and organized manner.
2. Initial Setup
To get started with the LazyKit CLI, you need to initialize your project with the following command:
npx @jrtilak/lazykit@latest init
Note: Ensure that your project contains a package.json
file for the initialization to work correctly.
1. Questions During Initialization
You will be asked the following questions during the initialization process:
- Language: Choose between TypeScript or JavaScript.
- Separate:
true
orfalse
. Iftrue
, the configuration will be stored in a separate file calledlazykit.config.json
; otherwise, it will be included inpackage.json
underlazykit
. - Path to store helper functions: Indicate the directory where you want to save the utility functions from root of the project, e.g.,
/src/helpers
. - Path to store React hooks: Indicate the directory where you want to keep your React hooks from root of the project, e.g.,
/src/hooks
. - Filename convention for helper functions: Choose between
camelCase
orkebab-case
for naming utility function files. - Filename convention for React hooks: Choose between
camelCase
orkebab-case
for naming React hook files.
2. Flags
You can also pass flags to the init
command to skip the interactive questions. Here are the available flags:
--yes
or-y
: Initialize the project with default options.--force
or-f
: Initialize the project even if it is already initialized.
3. Teardown
If you need to remove the LazyKit configuration from your project, you can use the teardown command:
npx @jrtilak/lazykit@latest teardown
This command will delete the configuration file from your project, cleaning up any LazyKit settings.
4. Installation
To install specific utility methods into your project, use the following command:
npx @jrtilak/lazykit@latest add <method-name>
Replace <method-name>
with the name of the utility method you wish to add. This command will seamlessly integrate the chosen utility method into your project.
OR
npx @jrtilak/lazykit@latest add method1 method2 method3
1. Flags
--force
or-f
: Adds the method even if it already exists in the project.
Note: If any method are dependent on other methods, they will be installed automatically.