@squiz/dxp-cli-next 5.31.0-develop.3 → 5.31.0-develop.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -62,10 +62,11 @@ const createActivateCommand = () => {
|
|
|
62
62
|
else {
|
|
63
63
|
apiUrl = `${scvDeployBaseUrl.dxpUrl}`;
|
|
64
64
|
}
|
|
65
|
+
const headerConfig = {
|
|
66
|
+
headers: Object.assign({}, (!hasRegion && { 'x-dxp-tenant': tenant })),
|
|
67
|
+
};
|
|
65
68
|
const getDeployResponse = (yield apiService.client
|
|
66
|
-
.get(apiUrl,
|
|
67
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, (!hasRegion && { 'x-dxp-tenant': tenant })),
|
|
68
|
-
})
|
|
69
|
+
.get(apiUrl, headerConfig)
|
|
69
70
|
.catch((err) => {
|
|
70
71
|
(0, utils_1.logDebug)(`RAW ERROR: ${JSON.stringify(err)}`);
|
|
71
72
|
if (err.response && err.response.status != 404) {
|
|
@@ -77,9 +78,7 @@ const createActivateCommand = () => {
|
|
|
77
78
|
}
|
|
78
79
|
(0, utils_1.logDebug)(`PUT ${apiUrl}`);
|
|
79
80
|
const activateInstanceAndDeploySchemaResponse = (yield apiService.client
|
|
80
|
-
.put(apiUrl, undefined,
|
|
81
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, (!hasRegion && { 'x-dxp-tenant': tenant })),
|
|
82
|
-
})
|
|
81
|
+
.put(apiUrl, undefined, headerConfig)
|
|
83
82
|
.catch((err) => {
|
|
84
83
|
(0, utils_1.logDebug)(`RAW ERROR: ${JSON.stringify(err)}`);
|
|
85
84
|
if (err.response) {
|
|
@@ -90,7 +89,7 @@ const createActivateCommand = () => {
|
|
|
90
89
|
if (activateInstanceAndDeploySchemaResponse.status === 409) {
|
|
91
90
|
throw new Error('Currently activating instance. Please try again later.');
|
|
92
91
|
}
|
|
93
|
-
yield (0, utils_1.pollForDeployedSchema)(apiUrl, apiService);
|
|
92
|
+
yield (0, utils_1.pollForDeployedSchema)(apiUrl, apiService, headerConfig);
|
|
94
93
|
spinner.succeed('Done!');
|
|
95
94
|
console.log('');
|
|
96
95
|
console.log('Your Schema has been deployed and instance has been activated.');
|
|
@@ -103,9 +103,7 @@ describe('cdpInstanceCommand', () => {
|
|
|
103
103
|
const program = (0, activate_1.default)();
|
|
104
104
|
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
105
105
|
expect(mockedAxiosInstance.put).toHaveBeenCalledWith(`http://localhost:9999/__dxp/${region}/scv-deploy/${mockTenant}`, undefined, {
|
|
106
|
-
headers: {
|
|
107
|
-
'Content-Type': 'application/json',
|
|
108
|
-
},
|
|
106
|
+
headers: {},
|
|
109
107
|
});
|
|
110
108
|
expect(logSpy).toHaveBeenNthCalledWith(1, '');
|
|
111
109
|
expect(logSpy).toHaveBeenNthCalledWith(2, '');
|
|
@@ -139,9 +137,7 @@ describe('cdpInstanceCommand', () => {
|
|
|
139
137
|
const program = (0, activate_1.default)();
|
|
140
138
|
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
141
139
|
expect(mockedAxios.put).toHaveBeenCalledWith(`http://localhost:9999/__dxp/${region}/scv-deploy/${mockTenant}`, undefined, {
|
|
142
|
-
headers: {
|
|
143
|
-
'Content-Type': 'application/json',
|
|
144
|
-
},
|
|
140
|
+
headers: {},
|
|
145
141
|
});
|
|
146
142
|
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Currently activating instance. Please try again later.'));
|
|
147
143
|
}));
|
|
@@ -209,7 +205,6 @@ describe('cdpInstanceCommand', () => {
|
|
|
209
205
|
yield program.parseAsync(createMockArgs());
|
|
210
206
|
expect(mockedAxiosInstance.put).toHaveBeenCalledWith('http://localhost:9999/__dxp/service/scv-deploy', undefined, {
|
|
211
207
|
headers: {
|
|
212
|
-
'Content-Type': 'application/json',
|
|
213
208
|
'x-dxp-tenant': 'myTenant',
|
|
214
209
|
},
|
|
215
210
|
});
|
|
@@ -250,7 +245,6 @@ describe('cdpInstanceCommand', () => {
|
|
|
250
245
|
yield program.parseAsync(createMockArgs());
|
|
251
246
|
expect(mockedAxios.put).toHaveBeenCalledWith('http://localhost:9999/__dxp/service/scv-deploy', undefined, {
|
|
252
247
|
headers: {
|
|
253
|
-
'Content-Type': 'application/json',
|
|
254
248
|
'x-dxp-tenant': 'myTenant',
|
|
255
249
|
},
|
|
256
250
|
});
|
package/lib/cdp/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
3
|
import { ApiService } from '../ApiService';
|
|
3
4
|
export interface tenantDetails {
|
|
4
5
|
tenantid: string;
|
|
@@ -19,4 +20,4 @@ export declare function createMockActivateArgs(region: string): Array<string>;
|
|
|
19
20
|
/**
|
|
20
21
|
* Poll the schema to be deployed.
|
|
21
22
|
*/
|
|
22
|
-
export declare function pollForDeployedSchema(endpointUrl: string, apiService: ApiService): Promise<unknown>;
|
|
23
|
+
export declare function pollForDeployedSchema(endpointUrl: string, apiService: ApiService, requestConfig?: AxiosRequestConfig | null): Promise<unknown>;
|
package/lib/cdp/utils.js
CHANGED
|
@@ -93,7 +93,7 @@ exports.createMockActivateArgs = createMockActivateArgs;
|
|
|
93
93
|
/**
|
|
94
94
|
* Poll the schema to be deployed.
|
|
95
95
|
*/
|
|
96
|
-
function pollForDeployedSchema(endpointUrl, apiService) {
|
|
96
|
+
function pollForDeployedSchema(endpointUrl, apiService, requestConfig = null) {
|
|
97
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
98
|
return new Promise((resolve, reject) => {
|
|
99
99
|
const errHandler = (err) => {
|
|
@@ -104,7 +104,9 @@ function pollForDeployedSchema(endpointUrl, apiService) {
|
|
|
104
104
|
}, API_TIMEOUT);
|
|
105
105
|
const poll = () => __awaiter(this, void 0, void 0, function* () {
|
|
106
106
|
logDebug(`GET ${endpointUrl}`);
|
|
107
|
-
const { data, status } =
|
|
107
|
+
const { data, status } = requestConfig
|
|
108
|
+
? yield apiService.client.get(endpointUrl, requestConfig)
|
|
109
|
+
: yield apiService.client.get(endpointUrl);
|
|
108
110
|
logDebug(`Response: ${JSON.stringify(data)}`);
|
|
109
111
|
if (status !== 200) {
|
|
110
112
|
return reject(`Unexpected poll request status: ${status}`);
|