Advanced Usage
The command-line interface (CLI) to Intuita is the intuita
command, which accepts a variety of subcommands and options for various preferences. With the Intuita CLI, you can interact with Intuita using a terminal or a script.
If you want to use Intutia through a graphical interface, check out the Intuita VS Code Extension.
To view a list of the commands and options available using the Intuita CLI, run intuita help
:
Commands:
intuita Runs a codemod or recipe [default]
intuita list Lists all the codemods & recipes in the public registry
intuita syncRegistry Syncs all the codemods from the registry
intuita learn Exports the current `git diff` in a file to before/after panels in codemod studio
intuita help Show help
Options:
--version Show version number [boolean]
--include Specify glob pattern(s) for files to include [array] [default: ["**/*.*{ts,tsx,js,jsx,mjs,cjs,mdx}"]]
--exclude Specify glob pattern(s) for files to exclude [array] [default: ["**/node_modules/**/*.*"]]
--targetPath Specify a target directory path [string][default: current project path]
--sourcePath Specify the path of a local codemod to run [string]
--codemodEngine Specify the engine to use while running a local codemod ["jscodeshift", "ts-morph", "repomod-engine"]
--fileLimit Specify a max file limit while running codemods [number] [default: 1000]
--usePrettier Format output with Prettier [boolean] [default: false]
--useCache Use cached codemod instead of redownloading [boolean] [default: false]
--useJson Use JSON responses in the console [boolean] [default: false]
--threadCount Set the number of threads while running codemods [number] [default: 4]
--dryRun Enable dry-run mode while running codemods [boolean] [default: false]
--outputDirectoryPath Specify the dry-run output directory path [string]
--telemetryDisable Disable telemetry [boolean] [default: false]
Commands
Running codemods
You can use the intuita
command to run codemods. The intuita
command uses the following format:
intuita [codemod name]
By default, using the intuita
CLI command will run the codemod over the current directory. To run codemods over a specific file, use the --targetPath
option.
Listing all public codemods
The list
command can be used to list all codemods available in the Codemod Registry. This command uses the following format:
intuita list
Syncing registry
The syncRegistry
command can be used to sync local codemods with the public Codemod Registry. This command uses the following format:
intuita syncRegistry
Generate codemod from file diff
The learn
command can be used to send the diff of the latest edited file to Codemod Studio and have it automatically build an explainable and debuggable codemod.
After running this command, if any git diff exists, Intuita will use the diff as before/after snippets in Codemod Studio. This command uses the following format:
intuita learn
Quick look
If you encounter any issues with the auto-generated codemod, please leave us some feedback here.
Options
The following options can be used to change the default behavior of the Intuita CLI. Option-specific information is provided below.
--include
The --include
option can be used to specify a glob pattern of the files to be targeted by the codemod.
This option uses the following format:
intuita [codemod name] --include "[glob pattern]"
You can specify your glob patterns to include specific file formats or directory structures. The default pattern Intuita CLI uses is: --include "**/*.*{ts,tsx,js,jsx,mjs,cjs,mdx}"
.
--exclude
While running a codemod, you may want to prevent changes from occurring to specific parts of your project. The --exclude
option can be used to specify a glob pattern of the files to be ignored by the codemod.
This option uses the following format:
intuita [codemod name] --exclude "[glob pattern]"
By default, the Intuita CLI excludes the following glob pattern: --exclude "**/node_modules/**/*.*"
. If you are using a different glob pattern, we recommend excluding the node_modules
directory to avoid unnecessary codemod runs.
--targetPath
The --targetPath
option can be used to specify the directory of your project that Intuita should target while running codemods.
This option is set as the current directory by default.
This option uses the following format:
intuita [codemod name] --targetPath [path]
--sourcePath
The --sourcePath
option can be used to specify the path to a local codemod you want to run using Intuita.
Running local codemods requires specifying the codemod engine your codemod uses. You can do this by using the --codemodEngine
option.
This option uses the following format:
intuita --sourcePath [path] --codemodEngine [codemod engine]
--codemodEngine
The --codemodEngine
option can be used to specify the codemod engine that will be used while running the codemod.
The --codemodEngine
option now supports three engines: jscodeshift
, ts-morph
, and repomod-engine
.
This option is used when running a local codemod using the --sourcePath
option.
--fileLimit
The --fileLimit
option can be used to specify a limit to the number of files targeted by the codemod. The file limit is set to 1000
by default.
This option uses the following format:
intuita [codemod name] --fileLimit [number]
--usePrettier
The usePrettier
option can be used to enable/disable prettier formatting to the files affected by the codemod. This option is set to false
by default.
This option uses the following format:
intuita [codemod name] --usePrettier [true/false]
--useCache
The --useCache
option can be used to enable/disable caching downloaded codemod files. Enabling cache can help you save bandwidth and time for repetitive use of the same codemods. While disabling cache ensures you fetch the latest version of the codemod. This option is set to false
by default.
This option uses the following format:
intuita [codemod name] --useCache [true/false]
--useJson
The --useJson
option can be used to switch Intuita's CLI responses to JSON format.
This option uses the following format:
intuita [codemod name] --useJson
--threadCount
The --threadCount
option can be used to specify the number of worker threads Intuita uses while running codemods. This option is set to 4 threads by default.
This option uses the following format:
intuita [codemod name] --threadCount [number of threads]
--dryRun
The --dryRun
option can be used to switch to dry run mode. Dry running codemods helps you see the changes the codemod will make without affecting the project files.
Dry-running codemods requires specifying the output directory to which the codemod's changes will be written. You can do this by using the --outputDirectoryPath
option.
This option uses the following format:
intuita [codemod name] --dryRun true --outputDirectoryPath [path]
--telemetryDisable
The --telemetryDisable
option can be used to disable CLI telemetry. Telemetry is enabled by default.