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| Option | Short | Type | Description | Default |
|---|---|---|---|---|
--config <path> |
-c |
string | Path to the configuration file | ./wrangler.jsonc |
--schema <path> |
-s |
string | Override the schema file path | undefined |
--write |
-w |
boolean | Write the output to the original file | false |
--help |
-h |
boolean | Print 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