@squiz/dxp-cli-next 5.30.0-develop.1 → 5.30.0-develop.2
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.
|
@@ -35,7 +35,7 @@ const createDeployCommand = () => {
|
|
|
35
35
|
.addOption(new commander_1.Option('-t, --tenant <string>', 'Tenant ID to deploy to. If not provided will use configured tenant from login').env('SQUIZ_DXP_TENANT_ID'))
|
|
36
36
|
.addOption(new commander_1.Option('--dry-run', 'Run all pre-deployment processes without deploying').default(false))
|
|
37
37
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
var _a, _b, _c, _d;
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
39
39
|
if (options.contentServiceUrl) {
|
|
40
40
|
console.log(`NOTICE: CONTENT_SERVICE_URL is set and will deploy to ${options.contentServiceUrl}`);
|
|
41
41
|
}
|
|
@@ -59,6 +59,9 @@ const createDeployCommand = () => {
|
|
|
59
59
|
const response = yield uploadLayout(apiService.client, layout, contentServiceUrl, options.dryRun);
|
|
60
60
|
if (!options.dryRun) {
|
|
61
61
|
exports.logger.info(`Layout "${layout.name}" version ${response.data.version} deployed successfully.`);
|
|
62
|
+
// Log the deployed layout URL (clickable)
|
|
63
|
+
const layoutUrl = `${baseUrl}/organization/${(_e = options.tenant) !== null && _e !== void 0 ? _e : maybeConfig === null || maybeConfig === void 0 ? void 0 : maybeConfig.tenant}/component-service/all-layouts/${encodeURIComponent(layout.name)}`;
|
|
64
|
+
exports.logger.info(`Deployed layout URL: \u001b]8;;${layoutUrl}\u001b\\${layoutUrl}\u001b]8;;\u001b\\`);
|
|
62
65
|
}
|
|
63
66
|
else {
|
|
64
67
|
exports.logger.info(`Layout "${layout.name}" dry run successful.`);
|
|
@@ -87,6 +90,7 @@ const createDeployCommand = () => {
|
|
|
87
90
|
};
|
|
88
91
|
exports.default = createDeployCommand;
|
|
89
92
|
function uploadLayout(client, layout, contentServiceUrl, dryRun) {
|
|
93
|
+
var _a, _b;
|
|
90
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
95
|
try {
|
|
92
96
|
const queryParam = dryRun ? '?_dryRun=true' : '';
|
|
@@ -96,7 +100,11 @@ function uploadLayout(client, layout, contentServiceUrl, dryRun) {
|
|
|
96
100
|
if (response.status === 200) {
|
|
97
101
|
return response;
|
|
98
102
|
}
|
|
99
|
-
|
|
103
|
+
const error = new Error(response.data.message);
|
|
104
|
+
if ((_b = (_a = response.data.details) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.message) {
|
|
105
|
+
error.message += `: ${response.data.details.input.message}`;
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
100
108
|
}
|
|
101
109
|
catch (error) {
|
|
102
110
|
throw error;
|
|
@@ -93,13 +93,13 @@ describe('deployCommand', () => {
|
|
|
93
93
|
const file = './src/__tests__/layouts/page-layout.yaml';
|
|
94
94
|
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
95
95
|
const mockLayout = {
|
|
96
|
-
name: '
|
|
96
|
+
name: 'test-layout',
|
|
97
97
|
zones: {
|
|
98
98
|
content: { displayName: 'Content', description: 'Main content' },
|
|
99
99
|
},
|
|
100
100
|
template: '<div>{{zones.content}}</div>',
|
|
101
101
|
};
|
|
102
|
-
const mockResponse = { name: '
|
|
102
|
+
const mockResponse = { name: 'test-layout', version: '12345' };
|
|
103
103
|
definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
|
|
104
104
|
(0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
|
|
105
105
|
.post('/page-layout', mockLayout)
|
|
@@ -107,20 +107,21 @@ describe('deployCommand', () => {
|
|
|
107
107
|
const program = (0, deploy_1.default)();
|
|
108
108
|
yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl }));
|
|
109
109
|
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(1, `Loading layout data from the file ${file}`);
|
|
110
|
-
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "
|
|
110
|
+
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "test-layout" version 12345 deployed successfully.');
|
|
111
|
+
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(3, 'Deployed layout URL: \u001b]8;;http://dxp-base-url.com/organization/myTenant/component-service/all-layouts/test-layout\u001b\\http://dxp-base-url.com/organization/myTenant/component-service/all-layouts/test-layout\u001b]8;;\u001b\\');
|
|
111
112
|
}));
|
|
112
113
|
it('deploys a layout with dry-run option', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
114
|
const file = './src/__tests__/layout.yaml';
|
|
114
115
|
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
115
116
|
const dryRun = true;
|
|
116
117
|
const mockLayout = {
|
|
117
|
-
name: '
|
|
118
|
+
name: 'test-layout',
|
|
118
119
|
zones: {
|
|
119
120
|
content: { displayName: 'Content', description: 'Main content' },
|
|
120
121
|
},
|
|
121
122
|
template: '<div>{{zones.content}}</div>',
|
|
122
123
|
};
|
|
123
|
-
const mockResponse = { name: '
|
|
124
|
+
const mockResponse = { name: 'test-layout', version: '12345' };
|
|
124
125
|
definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
|
|
125
126
|
(0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
|
|
126
127
|
.post('/page-layout', mockLayout)
|
|
@@ -129,7 +130,7 @@ describe('deployCommand', () => {
|
|
|
129
130
|
const program = (0, deploy_1.default)();
|
|
130
131
|
yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl, dryRun }));
|
|
131
132
|
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(1, `Loading layout data from the file ${file}`);
|
|
132
|
-
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "
|
|
133
|
+
expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "test-layout" dry run successful.');
|
|
133
134
|
}));
|
|
134
135
|
it('handles InvalidLoginSessionError', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
136
|
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
@@ -171,13 +172,30 @@ describe('deployCommand', () => {
|
|
|
171
172
|
yield program.parseAsync(createMockArgs({ contentServiceUrl }));
|
|
172
173
|
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('An unknown error occurred'));
|
|
173
174
|
}));
|
|
175
|
+
it('should log additional details when layout validation fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
+
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
177
|
+
(0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
|
|
178
|
+
.post('/page-layout')
|
|
179
|
+
.reply(400, {
|
|
180
|
+
message: 'Layout validation failed',
|
|
181
|
+
details: {
|
|
182
|
+
input: {
|
|
183
|
+
message: 'ERROR: Validation failed: "version" is an excess property and therefore is not allowed',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
const program = (0, deploy_1.default)();
|
|
188
|
+
errorSpy = jest.spyOn(program, 'error').mockImplementation();
|
|
189
|
+
yield program.parseAsync(createMockArgs({ dxpBaseUrl }));
|
|
190
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Layout validation failed: ERROR: Validation failed: "version" is an excess property and therefore is not allowed'));
|
|
191
|
+
}));
|
|
174
192
|
describe('zone consistency validation', () => {
|
|
175
193
|
it('should handle zone consistency validation errors where zones are used but not defined in the layout', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
194
|
const file = './src/__tests__/layout.yaml';
|
|
177
195
|
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
178
196
|
// Mock layout with zones that don't match the template
|
|
179
197
|
const mockLayout = {
|
|
180
|
-
name: '
|
|
198
|
+
name: 'test-layout',
|
|
181
199
|
zones: {
|
|
182
200
|
col1: { displayName: 'Column 1', description: 'The first column' },
|
|
183
201
|
},
|
|
@@ -193,7 +211,7 @@ describe('deployCommand', () => {
|
|
|
193
211
|
const file = './src/__tests__/layout.yaml';
|
|
194
212
|
const dxpBaseUrl = 'http://dxp-base-url.com';
|
|
195
213
|
const mockLayout = {
|
|
196
|
-
name: '
|
|
214
|
+
name: 'test-layout',
|
|
197
215
|
zones: {
|
|
198
216
|
col1: { displayName: 'Column 1', description: 'The first column' },
|
|
199
217
|
col2: { displayName: 'Column 2', description: 'The second column' }, // col2 is defined but not used in the template
|