Skip to main content
Version: 1.2.1-alpha.2

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

OptionAliasDescriptionDefaultRequired
--mapped-json <file>-mPath to the mapped JSON file generated by the map command.mapped.jsonNo
--output <directory>-oDirectory where refactored files will be saved.output_refactoredNo
--tech <tech>-tTechnology used in the JS files (run with -l/--list to see available options).Yes
--list-lList available technologies.falseNo

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.