Refactor Command
The refactor
command processes the mapped JSON file generated by the map
command and outputs the refactored JavaScript files to a specified directory. This is particularly useful for code transformation and restructuring tasks.
Usage
js-recon refactor -t <technology> [options]
Options
Option | Alias | Description | Default | Required |
---|---|---|---|---|
--mapped-json <file> | -m | Path to the mapped JSON file generated by the map command. | mapped.json | No |
--output <directory> | -o | Directory where refactored files will be saved. | output_refactored | No |
--tech <tech> | -t | Technology used in the JS files (run with -l /--list to see available options). | Yes | |
--list | -l | List available technologies. | false | No |
Examples
Basic Usage
To refactor code using the default mapped.json
file and output to the default output_refactored
directory:
js-recon refactor -t next
Custom Input and Output
Specify a custom input JSON file and output directory:
js-recon refactor -m custom-mapped.json -o refactored_output -t next
List Available Technologies
To see all supported technologies:
js-recon refactor --list
Output Structure
The command creates the following directory structure:
output_refactored/
├── 1.js
├── 2.js
└── ...
Each numbered .js
file corresponds to a chunk from the input JSON file, containing the refactored code.
Notes
- The command requires a mapped JSON file generated by the
map
command. - The technology (
-t
/--tech
) flag is required to ensure proper refactoring rules are applied. - If the output directory doesn't exist, it will be created automatically.
- Existing files in the output directory with the same names will be overwritten.