Skip to content

Commit

Permalink
feat: allow overriding the default API host
Browse files Browse the repository at this point in the history
  • Loading branch information
t-col committed Feb 6, 2024
1 parent 8c6fde9 commit 4acb81c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/bin/cli.ts
Expand Up @@ -56,7 +56,7 @@ const makeTerminatingFunction =

export const createMakeRequest = (
client: PlainClientAPI,
{ spaceId, environmentId, limit = 10 }
{ spaceId, environmentId, limit = 10, host = 'api.contentful.com' }
) => {
const throttle = pThrottle({
limit,
Expand All @@ -66,7 +66,7 @@ export const createMakeRequest = (

const makeBaseUrl = (url: string) => {
const parts = [
'https://api.contentful.com',
`https://${host}`,
'spaces',
spaceId,
'environments',
Expand Down Expand Up @@ -114,12 +114,15 @@ const createRun = ({ shouldThrow }) =>
},
getConfig(argv)
)
// allow users to override the default host via the contentful-cli
argv.host && Object.assign(clientConfig, { host: argv.host })

const client = createManagementClient(clientConfig)
const makeRequest = createMakeRequest(client, {
spaceId: clientConfig.spaceId,
environmentId: clientConfig.environmentId,
limit: argv.requestLimit
limit: argv.requestLimit,
host: clientConfig.host
})

const migrationParser = createMigrationParser(makeRequest, clientConfig)
Expand Down

0 comments on commit 4acb81c

Please sign in to comment.