A CLI tool to sort Wrangler configuration files written in JSON format (wrangler.json or wrangler.jsonc) based on their schema definition while preserving all original comments.
Important
This package is not yet published to any registry. You can use it by cloning the repository and installing it by running pnpm link in the project root.
- Sorts keys within the configuration based on the schema
- Sorts keys within the environment-specific configurations as well as the top-level one
- Places the
envkey at the end of the configuration for a clear inheritance hierarchy - Preserves all comments
- Supports both dry-run (write to stdout) and in-place editing modes
Print the output of the sorting result to stdout:
npx sort-wrangler-json [<CONFIG>] [OPTIONS]| Parameter | Type | Description | Default |
|---|---|---|---|
<CONFIG> |
string | Path to the configuration file to sort | ./wrangler.jsonc |
| Option | Type | Description | Default |
|---|---|---|---|
-c, --cwd |
string | Directory to run the command from (relative to the current working directory) | undefined |
-s, --schema |
string | Path to the schema file to override (relative to the configuration file) | undefined |
-w, --write |
boolean | Whether to write the sorted output back to the file instead of stdout | false |
-h, --help |
boolean | Whether to print the help message | false |
- Reads the Wrangler configuration file from the current directory (or specified path)
- Extracts the
$schemakey to locate the schema file - Dynamically builds an ESLint configuration with the
jsonc/sort-keysrule based on the schema - Applies ESLint's autofixes
- Writes the output to stdout or the original file