@squiz/dxp-cli-next 5.26.0 → 5.27.0-develop.1
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.
- package/lib/job-runner/job/uploadJob/uploadJob.js +4 -3
- package/lib/migration/settings/settings.js +2 -0
- package/lib/migration/settings/settings.spec.js +26 -0
- package/lib/migration/types/settings.types.d.ts +1 -0
- package/lib/migration/utils/options.d.ts +2 -1
- package/lib/migration/utils/options.js +8 -0
- package/lib/migration/utils/setMigrationSettings.js +5 -0
- package/lib/migration/utils/setMigrationSettings.spec.js +6 -0
- package/package.json +3 -2
|
@@ -12,11 +12,11 @@ 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
|
-
const
|
|
15
|
+
const job_runner_lib_1 = require("@squiz/job-runner-lib");
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const commander_1 = require("commander");
|
|
17
18
|
const ora_1 = __importDefault(require("ora"));
|
|
18
19
|
const ApiService_1 = require("../../../ApiService");
|
|
19
|
-
const component_cli_lib_1 = require("@squiz/component-cli-lib");
|
|
20
20
|
const utils_1 = require("../../utils");
|
|
21
21
|
const createUploadJobCommand = () => {
|
|
22
22
|
const uploadJobCommand = new commander_1.Command('uploadJob')
|
|
@@ -37,7 +37,8 @@ const createUploadJobCommand = () => {
|
|
|
37
37
|
validateStatus: utils_1.validateAxiosStatus,
|
|
38
38
|
baseUrl: yield (0, utils_1.buildJobRunnerUrl)(options.tenant, options.overrideUrl),
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
const jobUploadService = new job_runner_lib_1.JobUploadService();
|
|
41
|
+
yield jobUploadService.uploadJobFolder(apiService.client, inputSource);
|
|
41
42
|
spinner.succeed();
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
@@ -24,6 +24,7 @@ const setMigrationSettingsCommand = () => {
|
|
|
24
24
|
.addOption((0, utils_1.getParamOption)(utils_1.OptionName.MATRIX_URL))
|
|
25
25
|
.addOption((0, utils_1.getParamOption)(utils_1.OptionName.MATRIX_IDENTIFIER))
|
|
26
26
|
.addOption((0, utils_1.getParamOption)(utils_1.OptionName.MATRIX_KEY))
|
|
27
|
+
.addOption((0, utils_1.getParamOption)(utils_1.OptionName.CONTENT_API_KEY))
|
|
27
28
|
.addOption((0, utils_1.getParamOption)(utils_1.OptionName.TENANT, false))
|
|
28
29
|
.configureOutput({
|
|
29
30
|
outputError(str, write) {
|
|
@@ -31,6 +32,7 @@ const setMigrationSettingsCommand = () => {
|
|
|
31
32
|
},
|
|
32
33
|
})
|
|
33
34
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
console.log('options', options);
|
|
34
36
|
const spinner = (0, ora_1.default)('Setting migration configuration...').start();
|
|
35
37
|
yield (0, utils_1.throwErrorIfNotLoggedIn)(settingsCommand);
|
|
36
38
|
try {
|
|
@@ -65,6 +65,7 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
65
65
|
matrixUrl: 'https://matrix.example.com',
|
|
66
66
|
matrixIdentifier: '@user:matrix.example.com',
|
|
67
67
|
matrixKey: '***********123',
|
|
68
|
+
contentApiKey: '***********456',
|
|
68
69
|
};
|
|
69
70
|
mockSetMigrationSettings.setMigrationSettings.mockResolvedValue(mockSetMigrationSettingResponse);
|
|
70
71
|
});
|
|
@@ -82,12 +83,15 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
82
83
|
'@user:matrix.example.com',
|
|
83
84
|
'--matrix-key',
|
|
84
85
|
'secret-key-123',
|
|
86
|
+
'--content-api-key',
|
|
87
|
+
'content-api-key-456',
|
|
85
88
|
]);
|
|
86
89
|
expect(mockUtils.throwErrorIfNotLoggedIn).toHaveBeenCalledWith(program);
|
|
87
90
|
expect(mockSetMigrationSettings.setMigrationSettings).toHaveBeenCalledWith({
|
|
88
91
|
matrixUrl: 'https://matrix.example.com',
|
|
89
92
|
matrixIdentifier: '@user:matrix.example.com',
|
|
90
93
|
matrixKey: 'secret-key-123',
|
|
94
|
+
contentApiKey: 'content-api-key-456',
|
|
91
95
|
});
|
|
92
96
|
expect(mockSetMigrationSettings.setMigrationSettings).toHaveBeenCalledTimes(1);
|
|
93
97
|
expect(mockUtils.handleCommandError).not.toHaveBeenCalled();
|
|
@@ -107,12 +111,15 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
107
111
|
'secret-key-123',
|
|
108
112
|
'--tenant',
|
|
109
113
|
'test-tenant',
|
|
114
|
+
'--content-api-key',
|
|
115
|
+
'content-api-key-456',
|
|
110
116
|
]);
|
|
111
117
|
expect(mockSetMigrationSettings.setMigrationSettings).toHaveBeenCalledWith({
|
|
112
118
|
matrixUrl: 'https://matrix.example.com',
|
|
113
119
|
matrixIdentifier: '@user:matrix.example.com',
|
|
114
120
|
matrixKey: 'secret-key-123',
|
|
115
121
|
tenant: 'test-tenant',
|
|
122
|
+
contentApiKey: 'content-api-key-456',
|
|
116
123
|
});
|
|
117
124
|
}));
|
|
118
125
|
it('should set migration settings with override URL when environment variable is set', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -132,12 +139,15 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
132
139
|
'secret-key-123',
|
|
133
140
|
'--overrideUrl',
|
|
134
141
|
'https://custom.migration.url',
|
|
142
|
+
'--content-api-key',
|
|
143
|
+
'content-api-key-456',
|
|
135
144
|
]);
|
|
136
145
|
expect(mockSetMigrationSettings.setMigrationSettings).toHaveBeenCalledWith({
|
|
137
146
|
matrixUrl: 'https://matrix.example.com',
|
|
138
147
|
matrixIdentifier: '@user:matrix.example.com',
|
|
139
148
|
matrixKey: 'secret-key-123',
|
|
140
149
|
overrideUrl: 'https://custom.migration.url',
|
|
150
|
+
contentApiKey: 'content-api-key-456',
|
|
141
151
|
});
|
|
142
152
|
process.env.ENABLE_OVERRIDE_MIGRATION_URL = originalEnv;
|
|
143
153
|
}));
|
|
@@ -159,6 +169,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
159
169
|
'@user:matrix.example.com',
|
|
160
170
|
'--matrix-key',
|
|
161
171
|
'secret-key-123',
|
|
172
|
+
'--content-api-key',
|
|
173
|
+
'content-api-key-456',
|
|
162
174
|
]);
|
|
163
175
|
expect(mockUtils.handleCommandError).toHaveBeenCalledWith(program, apiError);
|
|
164
176
|
}));
|
|
@@ -178,6 +190,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
178
190
|
'@user:matrix.example.com',
|
|
179
191
|
'--matrix-key',
|
|
180
192
|
'secret-key-123',
|
|
193
|
+
'--content-api-key',
|
|
194
|
+
'content-api-key-456',
|
|
181
195
|
]);
|
|
182
196
|
expect(mockUtils.handleCommandError).toHaveBeenCalledWith(program, networkError);
|
|
183
197
|
}));
|
|
@@ -195,6 +209,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
195
209
|
'@user:matrix.example.com',
|
|
196
210
|
'--matrix-key',
|
|
197
211
|
'secret-key-123',
|
|
212
|
+
'--content-api-key',
|
|
213
|
+
'content-api-key-456',
|
|
198
214
|
]);
|
|
199
215
|
}).toThrow();
|
|
200
216
|
});
|
|
@@ -210,6 +226,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
210
226
|
'https://matrix.example.com',
|
|
211
227
|
'--matrix-key',
|
|
212
228
|
'secret-key-123',
|
|
229
|
+
'--content-api-key',
|
|
230
|
+
'content-api-key-456',
|
|
213
231
|
]);
|
|
214
232
|
}).toThrow();
|
|
215
233
|
});
|
|
@@ -225,6 +243,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
225
243
|
'https://matrix.example.com',
|
|
226
244
|
'--matrix-identifier',
|
|
227
245
|
'@user:matrix.example.com',
|
|
246
|
+
'--content-api-key',
|
|
247
|
+
'content-api-key-456',
|
|
228
248
|
]);
|
|
229
249
|
}).toThrow();
|
|
230
250
|
});
|
|
@@ -248,6 +268,8 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
248
268
|
'@user:matrix.example.com',
|
|
249
269
|
'--matrix-key',
|
|
250
270
|
'secret-key-123',
|
|
271
|
+
'--content-api-key',
|
|
272
|
+
'content-api-key-456',
|
|
251
273
|
'--tenant',
|
|
252
274
|
'test-tenant',
|
|
253
275
|
]);
|
|
@@ -255,6 +277,7 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
255
277
|
expect(opts.matrixUrl).toBe('https://matrix.example.com');
|
|
256
278
|
expect(opts.matrixIdentifier).toBe('@user:matrix.example.com');
|
|
257
279
|
expect(opts.matrixKey).toBe('secret-key-123');
|
|
280
|
+
expect(opts.contentApiKey).toBe('content-api-key-456');
|
|
258
281
|
expect(opts.tenant).toBe('test-tenant');
|
|
259
282
|
});
|
|
260
283
|
it('should parse options with kebab-case to camelCase conversion', () => {
|
|
@@ -270,11 +293,14 @@ describe('setMigrationSettingsCommand', () => {
|
|
|
270
293
|
'@user:matrix.example.com',
|
|
271
294
|
'--matrix-key',
|
|
272
295
|
'secret-key-123',
|
|
296
|
+
'--content-api-key',
|
|
297
|
+
'content-api-key-456',
|
|
273
298
|
]);
|
|
274
299
|
const opts = program.opts();
|
|
275
300
|
expect(opts.matrixUrl).toBe('https://matrix.example.com');
|
|
276
301
|
expect(opts.matrixIdentifier).toBe('@user:matrix.example.com');
|
|
277
302
|
expect(opts.matrixKey).toBe('secret-key-123');
|
|
303
|
+
expect(opts.contentApiKey).toBe('content-api-key-456');
|
|
278
304
|
});
|
|
279
305
|
});
|
|
280
306
|
afterEach(() => {
|
|
@@ -6,7 +6,8 @@ export declare enum OptionName {
|
|
|
6
6
|
TENANT = "tenant",
|
|
7
7
|
MIGRATION_ID = "migration-id",
|
|
8
8
|
MATRIX_IDENTIFIER = "matrix-identifier",
|
|
9
|
-
MATRIX_KEY = "matrix-key"
|
|
9
|
+
MATRIX_KEY = "matrix-key",
|
|
10
|
+
CONTENT_API_KEY = "content-api-key"
|
|
10
11
|
}
|
|
11
12
|
export declare const getParamOption: (param: OptionName, makeOptionMandatory?: boolean) => Option;
|
|
12
13
|
export declare const addOverrideUrlOption: (command: Command) => void;
|
|
@@ -11,6 +11,7 @@ var OptionName;
|
|
|
11
11
|
OptionName["MIGRATION_ID"] = "migration-id";
|
|
12
12
|
OptionName["MATRIX_IDENTIFIER"] = "matrix-identifier";
|
|
13
13
|
OptionName["MATRIX_KEY"] = "matrix-key";
|
|
14
|
+
OptionName["CONTENT_API_KEY"] = "content-api-key";
|
|
14
15
|
})(OptionName = exports.OptionName || (exports.OptionName = {}));
|
|
15
16
|
const params = new Map([
|
|
16
17
|
[
|
|
@@ -62,6 +63,13 @@ const params = new Map([
|
|
|
62
63
|
description: 'The Asset Management API key for the Migrator API to interact with Matrix API',
|
|
63
64
|
},
|
|
64
65
|
],
|
|
66
|
+
[
|
|
67
|
+
OptionName.CONTENT_API_KEY,
|
|
68
|
+
{
|
|
69
|
+
flags: '--content-api-key <string>',
|
|
70
|
+
description: 'The Content API key for the Migrator API to interact with Content API',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
65
73
|
]);
|
|
66
74
|
const getParamOption = (param, makeOptionMandatory = true) => {
|
|
67
75
|
const paramInfo = params.get(param);
|
|
@@ -23,7 +23,9 @@ function setMigrationSettings(options) {
|
|
|
23
23
|
matrixUrl: options.matrixUrl,
|
|
24
24
|
matrixIdentifier: options.matrixIdentifier,
|
|
25
25
|
matrixKey: options.matrixKey,
|
|
26
|
+
contentApiKey: options.contentApiKey,
|
|
26
27
|
};
|
|
28
|
+
console.log('payload', payload);
|
|
27
29
|
const response = yield apiService.client.post(migrationUrl, payload, {
|
|
28
30
|
headers: yield (0, _1.getMigrationHeaders)(options.tenant),
|
|
29
31
|
});
|
|
@@ -39,6 +41,9 @@ function setMigrationSettings(options) {
|
|
|
39
41
|
matrixKey: response.data.matrixKey
|
|
40
42
|
? (0, _1.redactKey)(response.data.matrixKey, 3)
|
|
41
43
|
: '',
|
|
44
|
+
contentApiKey: response.data.contentApiKey
|
|
45
|
+
? (0, _1.redactKey)(response.data.contentApiKey, 3)
|
|
46
|
+
: '',
|
|
42
47
|
};
|
|
43
48
|
return responseData;
|
|
44
49
|
}
|
|
@@ -48,6 +48,7 @@ describe('setMigrationSettings', () => {
|
|
|
48
48
|
matrixUrl: 'https://matrix.example.com',
|
|
49
49
|
matrixIdentifier: 'test-identifier',
|
|
50
50
|
matrixKey: 'test-key-123',
|
|
51
|
+
contentApiKey: 'test-content-api-key-456',
|
|
51
52
|
};
|
|
52
53
|
mockBuildMigrationUrl.mockResolvedValue('https://migration.example.com');
|
|
53
54
|
mockGetMigrationHeaders.mockResolvedValue({
|
|
@@ -63,6 +64,7 @@ describe('setMigrationSettings', () => {
|
|
|
63
64
|
matrixUrl: 'https://matrix.example.com',
|
|
64
65
|
matrixIdentifier: 'test-identifier',
|
|
65
66
|
matrixKey: 'test-key-123',
|
|
67
|
+
contentApiKey: 'test-content-api-key-456',
|
|
66
68
|
},
|
|
67
69
|
};
|
|
68
70
|
mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
|
|
@@ -71,6 +73,7 @@ describe('setMigrationSettings', () => {
|
|
|
71
73
|
matrixUrl: 'https://matrix.example.com',
|
|
72
74
|
matrixIdentifier: 'test-identifier',
|
|
73
75
|
matrixKey: '***123',
|
|
76
|
+
contentApiKey: '***456',
|
|
74
77
|
});
|
|
75
78
|
expect(mockBuildMigrationUrl).toHaveBeenCalledWith('test-tenant', undefined, 'settings');
|
|
76
79
|
expect(mockGetMigrationHeaders).toHaveBeenCalledWith('test-tenant');
|
|
@@ -78,6 +81,7 @@ describe('setMigrationSettings', () => {
|
|
|
78
81
|
matrixUrl: 'https://matrix.example.com',
|
|
79
82
|
matrixIdentifier: 'test-identifier',
|
|
80
83
|
matrixKey: 'test-key-123',
|
|
84
|
+
contentApiKey: 'test-content-api-key-456',
|
|
81
85
|
}, {
|
|
82
86
|
headers: {
|
|
83
87
|
'Content-Type': 'application/json',
|
|
@@ -94,6 +98,7 @@ describe('setMigrationSettings', () => {
|
|
|
94
98
|
matrixUrl: 'https://matrix.example.com',
|
|
95
99
|
matrixIdentifier: 'test-identifier',
|
|
96
100
|
matrixKey: 'test-key-123',
|
|
101
|
+
contentApiKey: 'test-content-api-key-456',
|
|
97
102
|
},
|
|
98
103
|
};
|
|
99
104
|
mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
|
|
@@ -132,6 +137,7 @@ describe('setMigrationSettings', () => {
|
|
|
132
137
|
matrixUrl: 'https://matrix.example.com',
|
|
133
138
|
matrixIdentifier: 'test-identifier',
|
|
134
139
|
matrixKey: 'test-key-123',
|
|
140
|
+
contentApiKey: 'test-content-api-key-456',
|
|
135
141
|
},
|
|
136
142
|
};
|
|
137
143
|
mockApiServiceInstance.client.post.mockResolvedValue(mockResponse);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squiz/dxp-cli-next",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.27.0-develop.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
|
|
6
6
|
},
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
44
44
|
"@squiz/component-cli-lib": "1.72.12",
|
|
45
|
+
"@squiz/dx-logger-lib": "^1.65.1",
|
|
45
46
|
"@squiz/dxp-porter-shared": "0.4.0",
|
|
47
|
+
"@squiz/job-runner-lib": "2.1.0",
|
|
46
48
|
"@squiz/local-component-dev-ui": "0.6.20",
|
|
47
|
-
"@squiz/dx-logger-lib": "^1.65.1",
|
|
48
49
|
"axios": "1.1.3",
|
|
49
50
|
"cli-color": "2.0.3",
|
|
50
51
|
"commander": "9.4.0",
|