getJSON = ( cbFn ) => {
	agent
		.get( endpoint )
		.set( 'Accept', 'application/json' )
		.end( ( err, res ) => {
			// Inspect the error and then the response to infer various error states
			if ( err ) {
				console.error( '\nSomething went wrong! Could not download endpoint JSON.' );
				if ( err.status ) {
					console.error( 'Error ' + err.status );
				}
				if ( err.response && err.response.error ) {
					console.error( err.response.error );
				}
				return process.exit( 1 );
			}

			if ( res.type !== 'application/json' ) {
				console.error( '\nError: expected response type "application/json", got ' + res.type );
				console.error( 'Could not save ' + fileName );
				return process.exit( 1 );
			}

			cbFn( res );
		} );
}
To avoid requiring that auto-discovery be utilized every time the API client
is initialized, this library ships with a built-in route definition from a
vanilla WordPress REST API installation. That file may be updated by
installing the API plugin on a clean WP development instance, with no other
plugins running, and downloading the JSON output from `yourwpsite.com/wp-json/`
into the "default-routes.json" file in this directory.

That file can also be generated by running this script against the same live
WP REST API instance to download that same file, the difference being that,
if the `default-routes.json` file is downloaded through this script, it
will be run through the `simplifyObject` utility to cut out about 1/3 of the
bytes of the response by removing properties that do not effect route generation.

This script is NOT intended to be a dependency of any part of wp.js, and is
provided purely as a utility for upgrading the built-in copy of the endpoint
response JSON file that is used to bootstrap the default route handlers.

@example

    # Invoke directly, run against default endpoint (details below)
    ./update-default-routes-json.js

    # Invoke with `node` CLI, and run against a custom endpoint
    node ./update-default-routes-json --endpoint=http://my-site.com/wp-json

    # Invoke with npm script alias, and run against a custom endpoint
    npm run update-default-routes-json -- --endpoint=http://my-site.com/wp-json

This script runs against http://wpapi.local/wp-json by default, but it can be
run against an arbitrary WordPress REST API endpoint by passing the --endpoint
argument on the CLI:

@example

    # Invoke directly, run against an arbitrary WordPress API root
    ./update-default-routes-json.js --endpoint=http://my-site.com/wp-json

    # Invoke with `node` CLI, run against an arbitrary WordPress API root
    node ./update-default-routes-json --endpoint=http://my-site.com/wp-json

Either form will update the `default-routes.json` file in this directory,
providing that the endpoint data is downloaded successfully.

This script also has some utility for downloading a custom JSON file for your
own WP REST API-enabled site, so that you can bootstrap your own routes without
incurring an HTTP request. To output to a different directory than the default
(which is this directory, `lib/data/`), pass an --output argument on the CLI:

@example

    # Output to your current working directory
    ./path/to/this/dir/update-default-routes-json.js --output=.

    # Output to an arbitrary absolute path
    ./path/to/this/dir/update-default-routes-json.js --output=/home/mordor/output.json

These command-line flags may be combined, and you will usually want to use
`--endpoint` alongside `--output` to download your own JSON into your own
application's directory. The name of the output file can be customized with
the `--file` option.