@squiz/dxp-cli-next 5.30.0-develop.3 → 5.30.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.
|
@@ -37,6 +37,9 @@ const createActivateCommand = () => {
|
|
|
37
37
|
write(chalk_1.default.red(str));
|
|
38
38
|
},
|
|
39
39
|
})
|
|
40
|
+
.addOption(new commander_1.Option('-r, --region <string>', 'Region for your cdp instance to be activated e.g. au')
|
|
41
|
+
.choices(['au', 'us', 'uk'])
|
|
42
|
+
.default(''))
|
|
40
43
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
44
|
yield (0, utils_1.throwErrorIfNotLoggedIn)(activateCommand);
|
|
42
45
|
console.log('');
|
|
@@ -47,10 +50,22 @@ const createActivateCommand = () => {
|
|
|
47
50
|
return status < 400 || status === 404;
|
|
48
51
|
},
|
|
49
52
|
});
|
|
50
|
-
const scvDeployBaseUrl = yield (0, utils_1.buildDXPUrl)(constants_1.SCV_DEPLOY_SERVICE_NAME);
|
|
51
|
-
|
|
53
|
+
const scvDeployBaseUrl = yield (0, utils_1.buildDXPUrl)(constants_1.SCV_DEPLOY_SERVICE_NAME, '', '', options.region);
|
|
54
|
+
let apiUrl = '';
|
|
55
|
+
const tenant = scvDeployBaseUrl.tenant;
|
|
56
|
+
const hasRegion = options.region !== '';
|
|
57
|
+
// If the region is provided, use the region specific URL
|
|
58
|
+
// Otherwise, we utilize service to automatically retrieve the region for us
|
|
59
|
+
if (hasRegion) {
|
|
60
|
+
apiUrl = `${scvDeployBaseUrl.dxpUrl}/${tenant}`;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
apiUrl = `${scvDeployBaseUrl.dxpUrl}`;
|
|
64
|
+
}
|
|
52
65
|
const getDeployResponse = (yield apiService.client
|
|
53
|
-
.get(apiUrl
|
|
66
|
+
.get(apiUrl, {
|
|
67
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, (!hasRegion && { 'x-dxp-tenant': tenant })),
|
|
68
|
+
})
|
|
54
69
|
.catch((err) => {
|
|
55
70
|
(0, utils_1.logDebug)(`RAW ERROR: ${JSON.stringify(err)}`);
|
|
56
71
|
if (err.response && err.response.status != 404) {
|
|
@@ -62,7 +77,9 @@ const createActivateCommand = () => {
|
|
|
62
77
|
}
|
|
63
78
|
(0, utils_1.logDebug)(`PUT ${apiUrl}`);
|
|
64
79
|
const activateInstanceAndDeploySchemaResponse = (yield apiService.client
|
|
65
|
-
.put(apiUrl
|
|
80
|
+
.put(apiUrl, {
|
|
81
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, (!hasRegion && { 'x-dxp-tenant': tenant })),
|
|
82
|
+
})
|
|
66
83
|
.catch((err) => {
|
|
67
84
|
(0, utils_1.logDebug)(`RAW ERROR: ${JSON.stringify(err)}`);
|
|
68
85
|
if (err.response) {
|
|
@@ -42,7 +42,7 @@ const activate = __importStar(require("./activate"));
|
|
|
42
42
|
const utils = __importStar(require("../../utils"));
|
|
43
43
|
const axios_1 = __importDefault(require("axios"));
|
|
44
44
|
jest.mock('axios');
|
|
45
|
-
const mockDomainWithPath = 'http://localhost:9999/__dxp/
|
|
45
|
+
const mockDomainWithPath = 'http://localhost:9999/__dxp/service/scv-deploy/myTenant';
|
|
46
46
|
function createMockArgs() {
|
|
47
47
|
return ['node', 'dxp-cli', 'cdp', 'instance', 'activate'];
|
|
48
48
|
}
|
|
@@ -65,103 +65,216 @@ describe('cdpInstanceCommand', () => {
|
|
|
65
65
|
afterEach(() => {
|
|
66
66
|
jest.clearAllMocks();
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
68
|
+
describe('when region is provided', () => {
|
|
69
|
+
it.each(['au', 'us', 'uk'])('should throw error when tenant exists for %s region', (region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
const mockedAxiosInstance = {
|
|
71
|
+
get: jest.fn().mockResolvedValue({ status: 200 }),
|
|
72
|
+
interceptors: {
|
|
73
|
+
request: { use: jest.fn() },
|
|
74
|
+
response: { use: jest.fn() },
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
78
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
79
|
+
dxpUrl: `${mockDomain}/__dxp/${region}/scv-deploy`,
|
|
80
|
+
tenant: mockTenant,
|
|
81
|
+
});
|
|
82
|
+
const program = (0, activate_1.default)();
|
|
83
|
+
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
84
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining(activate_1.errorMessage));
|
|
85
|
+
}));
|
|
86
|
+
it.each(['au', 'us', 'uk'])('deploys a default schema and activate an instance for %s region', (region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
88
|
+
dxpUrl: `${mockDomain}/__dxp/${region}/scv-deploy`,
|
|
89
|
+
tenant: mockTenant,
|
|
90
|
+
});
|
|
91
|
+
jest.spyOn(utils, 'pollForDeployedSchema').mockResolvedValue({});
|
|
92
|
+
const mockedAxiosInstance = {
|
|
93
|
+
get: jest.fn().mockResolvedValue({ status: 404 }),
|
|
94
|
+
put: jest
|
|
95
|
+
.fn()
|
|
96
|
+
.mockResolvedValue({ status: 200, data: { message: 'Success' } }),
|
|
97
|
+
interceptors: {
|
|
98
|
+
request: { use: jest.fn() },
|
|
99
|
+
response: { use: jest.fn() },
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
103
|
+
const program = (0, activate_1.default)();
|
|
104
|
+
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
105
|
+
expect(mockedAxiosInstance.put).toHaveBeenCalledWith(`http://localhost:9999/__dxp/${region}/scv-deploy/${mockTenant}`, {
|
|
106
|
+
headers: {
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
expect(logSpy).toHaveBeenNthCalledWith(1, '');
|
|
111
|
+
expect(logSpy).toHaveBeenNthCalledWith(2, '');
|
|
112
|
+
expect(logSpy).toHaveBeenNthCalledWith(3, 'Your Schema has been deployed and instance has been activated.');
|
|
113
|
+
expect(logSpy).toHaveBeenNthCalledWith(4, '');
|
|
114
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
115
|
+
}));
|
|
116
|
+
it.each(['au', 'us', 'uk'])('should throw error when trying to activate an instance currently for %s region', (region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
118
|
+
dxpUrl: `${mockDomain}/__dxp/${region}/scv-deploy`,
|
|
119
|
+
tenant: mockTenant,
|
|
120
|
+
});
|
|
121
|
+
jest.spyOn(utils, 'pollForDeployedSchema').mockResolvedValue({});
|
|
122
|
+
const mockedAxios = axios_1.default;
|
|
123
|
+
//GET request (404)
|
|
124
|
+
mockedAxios.get.mockResolvedValueOnce({
|
|
125
|
+
status: 404,
|
|
126
|
+
data: { status: deploy_const_1.CDP_DEPLOY_STATUS_ERROR },
|
|
127
|
+
});
|
|
128
|
+
// PUT request (409)
|
|
129
|
+
mockedAxios.put.mockResolvedValueOnce({
|
|
130
|
+
status: 409,
|
|
131
|
+
data: {
|
|
132
|
+
tenantid: 'myTenant',
|
|
133
|
+
version: 'unknown',
|
|
134
|
+
stack: 'stackName',
|
|
135
|
+
status: deploy_const_1.CDP_DEPLOY_STATUS_DEPLOYING,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
axios_1.default.create.mockReturnValue(mockedAxios);
|
|
139
|
+
const program = (0, activate_1.default)();
|
|
140
|
+
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
141
|
+
expect(mockedAxios.put).toHaveBeenCalledWith(`http://localhost:9999/__dxp/${region}/scv-deploy/${mockTenant}`, {
|
|
142
|
+
headers: {
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Currently activating instance. Please try again later.'));
|
|
147
|
+
}));
|
|
148
|
+
it.each(['au', 'us', 'uk'])('should throw error when get tenant returns 403 for %s region', (region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
const mockedAxiosInstance = {
|
|
150
|
+
get: jest.fn().mockRejectedValue({
|
|
151
|
+
response: { status: 403, data: {} },
|
|
152
|
+
}),
|
|
153
|
+
interceptors: {
|
|
154
|
+
request: { use: jest.fn() },
|
|
155
|
+
response: { use: jest.fn() },
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
159
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
160
|
+
dxpUrl: `${mockDomain}/__dxp/${region}/scv-deploy`,
|
|
161
|
+
tenant: mockTenant,
|
|
162
|
+
});
|
|
163
|
+
const handleActivateErrorSpy = jest.spyOn(activate, 'handleActivateError');
|
|
164
|
+
const program = (0, activate_1.default)();
|
|
165
|
+
yield program.parseAsync((0, utils_1.createMockActivateArgs)(region));
|
|
166
|
+
expect(handleActivateErrorSpy).toHaveBeenCalledWith(403, {});
|
|
167
|
+
}));
|
|
168
|
+
});
|
|
169
|
+
describe('when region is not provided', () => {
|
|
170
|
+
it('should throw error when tenant exists', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
const mockedAxiosInstance = {
|
|
172
|
+
get: jest.fn().mockResolvedValue({ status: 200 }),
|
|
173
|
+
interceptors: {
|
|
174
|
+
request: { use: jest.fn() },
|
|
175
|
+
response: { use: jest.fn() },
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
179
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
180
|
+
dxpUrl: `${mockDomain}/__dxp/service/scv-deploy`,
|
|
181
|
+
tenant: mockTenant,
|
|
182
|
+
});
|
|
183
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant);
|
|
184
|
+
expect(`${mockDomain}${mockPath}`).toEqual(mockDomainWithPath);
|
|
185
|
+
const program = (0, activate_1.default)();
|
|
186
|
+
yield program.parseAsync(createMockArgs());
|
|
187
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining(activate_1.errorMessage));
|
|
188
|
+
}));
|
|
189
|
+
it('deploys a default schema and activate an instance', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
190
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
191
|
+
dxpUrl: `${mockDomain}/__dxp/service/scv-deploy`,
|
|
192
|
+
tenant: mockTenant,
|
|
193
|
+
});
|
|
194
|
+
jest.spyOn(utils, 'pollForDeployedSchema').mockResolvedValue({});
|
|
195
|
+
const mockedAxiosInstance = {
|
|
196
|
+
get: jest.fn().mockResolvedValue({ status: 404 }),
|
|
197
|
+
put: jest
|
|
198
|
+
.fn()
|
|
199
|
+
.mockResolvedValue({ status: 200, data: { message: 'Success' } }),
|
|
200
|
+
interceptors: {
|
|
201
|
+
request: { use: jest.fn() },
|
|
202
|
+
response: { use: jest.fn() },
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
206
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant);
|
|
207
|
+
expect(`${mockDomain}${mockPath}`).toEqual(mockDomainWithPath);
|
|
208
|
+
const program = (0, activate_1.default)();
|
|
209
|
+
yield program.parseAsync(createMockArgs());
|
|
210
|
+
expect(mockedAxiosInstance.put).toHaveBeenCalledWith('http://localhost:9999/__dxp/service/scv-deploy', {
|
|
211
|
+
headers: {
|
|
212
|
+
'Content-Type': 'application/json',
|
|
213
|
+
'x-dxp-tenant': 'myTenant',
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
// Note the output from the spinner doesn't seem to appear here but this still tests that it
|
|
217
|
+
// ran without displaying an error.
|
|
218
|
+
expect(logSpy).toHaveBeenNthCalledWith(1, '');
|
|
219
|
+
expect(logSpy).toHaveBeenNthCalledWith(2, '');
|
|
220
|
+
expect(logSpy).toHaveBeenNthCalledWith(3, 'Your Schema has been deployed and instance has been activated.');
|
|
221
|
+
expect(logSpy).toHaveBeenNthCalledWith(4, '');
|
|
222
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
223
|
+
}));
|
|
224
|
+
it('should throw error when trying to activate an instance currently', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
226
|
+
dxpUrl: `${mockDomain}/__dxp/service/scv-deploy`,
|
|
227
|
+
tenant: mockTenant,
|
|
228
|
+
});
|
|
229
|
+
jest.spyOn(utils, 'pollForDeployedSchema').mockResolvedValue({});
|
|
230
|
+
const mockedAxios = axios_1.default;
|
|
231
|
+
//GET request (404)
|
|
232
|
+
mockedAxios.get.mockResolvedValueOnce({
|
|
233
|
+
status: 404,
|
|
234
|
+
data: { status: deploy_const_1.CDP_DEPLOY_STATUS_ERROR },
|
|
235
|
+
});
|
|
236
|
+
// PUT request (409)
|
|
237
|
+
mockedAxios.put.mockResolvedValueOnce({
|
|
238
|
+
status: 409,
|
|
239
|
+
data: {
|
|
240
|
+
tenantid: 'myTenant',
|
|
241
|
+
version: 'unknown',
|
|
242
|
+
stack: 'stackName',
|
|
243
|
+
status: deploy_const_1.CDP_DEPLOY_STATUS_DEPLOYING,
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
axios_1.default.create.mockReturnValue(mockedAxios);
|
|
247
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant);
|
|
248
|
+
expect(`${mockDomain}${mockPath}`).toEqual(mockDomainWithPath);
|
|
249
|
+
const program = (0, activate_1.default)();
|
|
250
|
+
yield program.parseAsync(createMockArgs());
|
|
251
|
+
expect(mockedAxios.put).toHaveBeenCalledWith('http://localhost:9999/__dxp/service/scv-deploy', {
|
|
252
|
+
headers: {
|
|
253
|
+
'Content-Type': 'application/json',
|
|
254
|
+
'x-dxp-tenant': 'myTenant',
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Currently activating instance. Please try again later.'));
|
|
258
|
+
}));
|
|
259
|
+
it('should throw error when get tenant returns 403', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
|
+
const mockedAxiosInstance = {
|
|
261
|
+
get: jest.fn().mockRejectedValue({
|
|
262
|
+
response: { status: 403, data: {} },
|
|
263
|
+
}),
|
|
264
|
+
interceptors: {
|
|
265
|
+
request: { use: jest.fn() },
|
|
266
|
+
response: { use: jest.fn() },
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
axios_1.default.create.mockReturnValue(mockedAxiosInstance);
|
|
270
|
+
jest.spyOn(utils, 'buildDXPUrl').mockResolvedValue({
|
|
271
|
+
dxpUrl: `${mockDomain}/__dxp/service/scv-deploy`,
|
|
272
|
+
tenant: mockTenant,
|
|
273
|
+
});
|
|
274
|
+
const handleActivateErrorSpy = jest.spyOn(activate, 'handleActivateError');
|
|
275
|
+
const program = (0, activate_1.default)();
|
|
276
|
+
yield program.parseAsync(createMockArgs());
|
|
277
|
+
expect(handleActivateErrorSpy).toHaveBeenCalledWith(403, {});
|
|
278
|
+
}));
|
|
279
|
+
});
|
|
167
280
|
});
|
|
@@ -60,7 +60,7 @@ describe('cdpSchemaCommand', () => {
|
|
|
60
60
|
jest.clearAllMocks(); // Clear all spies
|
|
61
61
|
});
|
|
62
62
|
it('correctly handles command arguments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const mockPath = (0, utils_1.createMockUrl)(
|
|
63
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant, mockRegion);
|
|
64
64
|
(0, nock_1.default)(mockDomain)
|
|
65
65
|
.put(mockPath, require(path_1.default.resolve(process.cwd(), './src/__tests__/cdp/scv/schema.json')))
|
|
66
66
|
.reply(200, {
|
|
@@ -81,7 +81,7 @@ describe('cdpSchemaCommand', () => {
|
|
|
81
81
|
}));
|
|
82
82
|
it('presents a formatted invalid schema message', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
83
|
const schemaFileContent = require(path_1.default.resolve(process.cwd(), mockFilePath));
|
|
84
|
-
const mockPath = (0, utils_1.createMockUrl)(
|
|
84
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant, mockRegion);
|
|
85
85
|
expect(`${mockDomain}${mockPath}`).toEqual('http://localhost:9999/__dxp/us/scv-deploy/myTenant');
|
|
86
86
|
(0, nock_1.default)(mockDomain)
|
|
87
87
|
.get(mockPath)
|
|
@@ -110,7 +110,7 @@ describe('cdpSchemaCommand', () => {
|
|
|
110
110
|
}));
|
|
111
111
|
it('deploys a schema', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
112
|
const schemaFileContent = require(path_1.default.resolve(process.cwd(), mockFilePath));
|
|
113
|
-
const mockPath = (0, utils_1.createMockUrl)(
|
|
113
|
+
const mockPath = (0, utils_1.createMockUrl)(mockTenant, mockRegion);
|
|
114
114
|
expect(`${mockDomain}${mockPath}`).toEqual('http://localhost:9999/__dxp/us/scv-deploy/myTenant');
|
|
115
115
|
(0, nock_1.default)(mockDomain)
|
|
116
116
|
.get(mockPath)
|
package/lib/cdp/utils.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare function buildDXPUrl(serviceName: string, tenantID?: string, over
|
|
|
14
14
|
tenant: string | undefined;
|
|
15
15
|
}>;
|
|
16
16
|
export declare function handleCommandError(error: Error): void;
|
|
17
|
-
export declare function createMockUrl(
|
|
17
|
+
export declare function createMockUrl(path: string, region?: string): string;
|
|
18
|
+
export declare function createMockActivateArgs(region: string): Array<string>;
|
|
18
19
|
/**
|
|
19
20
|
* Poll the schema to be deployed.
|
|
20
21
|
*/
|
package/lib/cdp/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.pollForDeployedSchema = exports.createMockUrl = exports.handleCommandError = exports.buildDXPUrl = exports.throwErrorIfNotLoggedIn = exports.logDebug = void 0;
|
|
15
|
+
exports.pollForDeployedSchema = exports.createMockActivateArgs = exports.createMockUrl = exports.handleCommandError = exports.buildDXPUrl = exports.throwErrorIfNotLoggedIn = exports.logDebug = void 0;
|
|
16
16
|
const ApplicationStore_1 = require("../ApplicationStore");
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
18
|
const ApplicationConfig_1 = require("../ApplicationConfig");
|
|
@@ -43,14 +43,14 @@ function buildDXPUrl(serviceName, tenantID, override, region) {
|
|
|
43
43
|
const existingConfig = yield (0, ApplicationConfig_1.fetchApplicationConfig)(tenantID);
|
|
44
44
|
logDebug(`existingConfig: ${JSON.stringify(existingConfig)}`);
|
|
45
45
|
return {
|
|
46
|
-
dxpUrl: `${existingConfig.baseUrl}/__dxp/${region ||
|
|
46
|
+
dxpUrl: `${existingConfig.baseUrl}/__dxp/${region || 'service'}/${serviceName}`,
|
|
47
47
|
tenant: existingConfig.tenant,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
logDebug(`Using override URL: ${override}`);
|
|
52
52
|
return {
|
|
53
|
-
dxpUrl: `${override}/__dxp/${region || '
|
|
53
|
+
dxpUrl: `${override}/__dxp/${region || 'service'}/${serviceName}`,
|
|
54
54
|
tenant: tenantID,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -82,10 +82,14 @@ function handleCommandError(error) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
exports.handleCommandError = handleCommandError;
|
|
85
|
-
function createMockUrl(
|
|
86
|
-
return `/__dxp/${region}/scv-deploy/${path}`;
|
|
85
|
+
function createMockUrl(path, region) {
|
|
86
|
+
return `/__dxp/${region || 'service'}/scv-deploy/${path}`;
|
|
87
87
|
}
|
|
88
88
|
exports.createMockUrl = createMockUrl;
|
|
89
|
+
function createMockActivateArgs(region) {
|
|
90
|
+
return ['node', 'dxp-cli', 'cdp', 'instance', 'activate', '--region', region];
|
|
91
|
+
}
|
|
92
|
+
exports.createMockActivateArgs = createMockActivateArgs;
|
|
89
93
|
/**
|
|
90
94
|
* Poll the schema to be deployed.
|
|
91
95
|
*/
|