Skip to content

Commit d3ac726

Browse files
committed
Added CMA Host to connect to SDK
1 parent 5fad02e commit d3ac726

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fileignoreconfig:
66
- filename: src/commands/cm/stacks/validate-regex.ts
77
checksum: 60a38392c57ddfd834c0b8204a7b766d53e47681e11e7eb1936bf624a09ee70e
88
- filename: src/utils/connect-stack.ts
9-
checksum: 05307c5f7af5c30c8f512f522fc67fd9fc22d868933730efbb4e358e0c072f6a
9+
checksum: 4531b14cadad275114fa73df74ad55202157a3cd4a984d9170b7bc52abc0a87c
1010
- filename: test/utils/connect-stack.test.ts
1111
checksum: f5b2cea668977cc0ffd5c278207e729e7f1493e70a77a3e273942939cfd4509a
1212
- filename: test/utils/get-management-token.test.ts

src/commands/cm/stacks/validate-regex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class ValidateRegex extends Command {
5151
await inquireModule(commandObject.flags)
5252

5353
try {
54-
await connectStack(commandObject.flags, authToken, tokenDetails.apiKey)
54+
await connectStack(commandObject.flags, this.cmaHost, authToken, tokenDetails.apiKey)
5555
} catch (error) {
5656
this.error(regexMessages.errors.stack.fetch)
5757
}

src/utils/connect-stack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import {cli} from 'cli-ux'
33
import processStack from './process-stack'
44
const regexMessages = require('../../messages/index.json').validateRegex
55

6-
export default async function connectStack(flags: any, authToken: string, apiKey: string) {
6+
export default async function connectStack(flags: any, host: string, authToken: string, apiKey: string) {
77
try {
88
const startTime = Date.now()
99
cli.action.start(regexMessages.cliAction.connectStackStart, '', {stdout: true})
1010
const client = contentstackSdk.client({
11+
host: host,
1112
authtoken: authToken,
1213
})
1314
await client.stack({api_key: apiKey}).fetch().then(async (stack: any) => {

test/utils/connect-stack.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('Get Client from Management SDK, connect with Stack & process Stack', (
2323
})
2424

2525
test('API Key is Valid', async () => {
26+
const host = 'api-contentstack.io'
2627
const apiKey = 'blt1234'
2728
const authToken = 'blt1234'
2829
const flags = {
@@ -38,13 +39,14 @@ describe('Get Client from Management SDK, connect with Stack & process Stack', (
3839
}),
3940
}
4041
})
41-
await connectStack(flags, authToken, apiKey)
42+
await connectStack(flags, host, authToken, apiKey)
4243
expect(cli.action.start).toHaveBeenCalled()
4344
expect(processStack).toHaveBeenCalled()
4445
})
4546

4647
test('API Key is Invalid', async () => {
4748
try {
49+
const host = 'api-contentstack.io'
4850
const apiKey = 'blt1234'
4951
const authToken = 'blt1234'
5052
const flags = {
@@ -60,7 +62,7 @@ describe('Get Client from Management SDK, connect with Stack & process Stack', (
6062
}),
6163
}
6264
})
63-
await connectStack(flags, authToken, apiKey)
65+
await connectStack(flags, host, authToken, apiKey)
6466
expect(cli.action.start).toHaveBeenCalled()
6567
} catch (error) {
6668
expect(error.message).toBe(regexMessages.errors.stack.apiKey)

0 commit comments

Comments
 (0)