@squiz/dxp-cli-next 5.23.1-develop.1 → 5.23.1-develop.3

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.
@@ -14,12 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const nock_1 = __importDefault(require("nock"));
16
16
  const listJobs_1 = __importDefault(require("./listJobs"));
17
- const logSpy = jest.spyOn(global.console, 'log');
18
17
  describe('listJobs', () => {
19
18
  it('correctly lists the job', () => __awaiter(void 0, void 0, void 0, function* () {
20
19
  process.env.ENABLE_OVERRIDE_JOB_RUNNER_URL = 'true';
21
20
  (0, nock_1.default)('http://localhost:9999')
22
- .get('/job/latest?&page[size]=5')
21
+ .get('/job/latest?&page%5Bsize%5D=5')
23
22
  .reply(200, [{ name: 'simple-job', type: 'job', version: '1.0.0' }]);
24
23
  const program = (0, listJobs_1.default)();
25
24
  yield program.parseAsync([
@@ -44,16 +44,9 @@ const createListJobContextsCommand = () => {
44
44
  size: options.size,
45
45
  });
46
46
  const res = yield apiService.client.get(listJobContextsUrl);
47
- if (Array.isArray(res.data) && res.data.length > 0) {
48
- spinner.succeed(`${res.data.length} contexts successfully retrieved`);
49
- (0, utils_1.writeLineSeparator)();
50
- res.data.forEach((context) => {
51
- console.log(`${chalk_1.default.green(chalk_1.default.bold(context.contextName))}: ${chalk_1.default.green(context.description)}`);
52
- for (const [key, value] of Object.entries(context.environment)) {
53
- console.log(`${chalk_1.default.bold(key)}: ${JSON.stringify(value)}`);
54
- }
55
- (0, utils_1.writeLineSeparator)();
56
- });
47
+ if (Array.isArray(res.data.data) && res.data.data.length > 0) {
48
+ spinner.succeed(`Retrieved ${res.data.data.length} job contexts`);
49
+ yield (0, utils_1.logArrayResults)(res.data.data, res.data.links);
57
50
  }
58
51
  else {
59
52
  spinner.succeed('No job contexts found');
@@ -14,13 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const nock_1 = __importDefault(require("nock"));
16
16
  const listJobContexts_1 = __importDefault(require("./listJobContexts"));
17
- const chalk_1 = __importDefault(require("chalk"));
18
- const logSpy = jest.spyOn(global.console, 'log');
19
17
  describe('listJobContexts', () => {
20
18
  process.env.ENABLE_OVERRIDE_JOB_RUNNER_URL = 'true';
21
19
  it('correctly lists the job contexts', () => __awaiter(void 0, void 0, void 0, function* () {
22
20
  (0, nock_1.default)('http://localhost:9999')
23
- .get('/job-context?')
21
+ .get('/job-context?page%5Bsize%5D=20')
24
22
  .reply(200, [
25
23
  {
26
24
  contextName: 'dev',
@@ -55,10 +53,5 @@ describe('listJobContexts', () => {
55
53
  const opts = program.opts();
56
54
  expect(opts.tenant).toEqual('myTenant');
57
55
  expect(opts.overrideUrl).toEqual('http://localhost:9999');
58
- expect(logSpy).toHaveBeenCalledTimes(9);
59
- expect(logSpy).toHaveBeenCalledWith(`${chalk_1.default.green(chalk_1.default.bold('dev'))}: ${chalk_1.default.green('dev context')}`);
60
- expect(logSpy).toHaveBeenCalledWith(`${chalk_1.default.bold('something')}: ${JSON.stringify('cool')}`);
61
- expect(logSpy).toHaveBeenCalledWith(`${chalk_1.default.bold('somethingElse')}: ${JSON.stringify('cooler')}`);
62
- expect(logSpy).toHaveBeenCalledWith(chalk_1.default.cyan('------------------------------'));
63
56
  }));
64
57
  });
@@ -19,7 +19,7 @@ describe('listJobExecutions', () => {
19
19
  it('correctly lists the job executions', () => __awaiter(void 0, void 0, void 0, function* () {
20
20
  process.env.ENABLE_OVERRIDE_JOB_RUNNER_URL = 'true';
21
21
  (0, nock_1.default)('http://localhost:9999')
22
- .get('/executions/jobName/job-runner?&page[size]=5')
22
+ .get('/executions/jobName/job-runner?&page%5Bsize%5D=5')
23
23
  .reply(200, [
24
24
  {
25
25
  context: 'dev',
@@ -96,19 +96,20 @@ function addPaginationToUrl(url, opts) {
96
96
  if (opts.before && opts.after) {
97
97
  throw new Error('Only one of before and after can be set');
98
98
  }
99
- if (opts.size) {
100
- url += `&page[size]=${PaginationPageLimit[opts.size]}`;
101
- }
102
- else {
103
- `&page[size]=${PaginationPageLimit.small}`;
104
- }
99
+ const parsedUrl = new URL(url);
100
+ const params = parsedUrl.searchParams;
101
+ // Set page size
102
+ params.set('page[size]', opts.size
103
+ ? `${PaginationPageLimit[opts.size]}`
104
+ : `${PaginationPageLimit.small}`);
105
+ // Set pagination parameters
105
106
  if (opts.before) {
106
- url += `&page[before]=${opts.before}`;
107
+ params.set('page[before]', opts.before);
107
108
  }
108
- if (opts.after) {
109
- url += `&page[after]=${opts.after}`;
109
+ else if (opts.after) {
110
+ params.set('page[after]', opts.after);
110
111
  }
111
- return url;
112
+ return parsedUrl.toString();
112
113
  }
113
114
  exports.addPaginationToUrl = addPaginationToUrl;
114
115
  function logArrayResults(results, links) {
@@ -93,11 +93,11 @@ describe('readInputFile', () => {
93
93
  describe('addPaginationToUrl', () => {
94
94
  it('correctly adds the pagination size param to the url', () => __awaiter(void 0, void 0, void 0, function* () {
95
95
  const url = (0, utils_1.addPaginationToUrl)('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?', { size: 'tiny', before: '', after: '' });
96
- expect(url).toBe('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?&page[size]=5');
96
+ expect(url).toBe('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?page%5Bsize%5D=5');
97
97
  }));
98
98
  it('correctly adds the pagination params to the url', () => __awaiter(void 0, void 0, void 0, function* () {
99
99
  const url = (0, utils_1.addPaginationToUrl)('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?', { size: 'tiny', before: '12345', after: '' });
100
- expect(url).toBe('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?&page[size]=5&page[before]=12345');
100
+ expect(url).toBe('http://localhost:9999//__dxp/au/job-runner/someTenant/job/latest?page%5Bsize%5D=5&page%5Bbefore%5D=12345');
101
101
  }));
102
102
  it('correctly throws error for before and after params', () => __awaiter(void 0, void 0, void 0, function* () {
103
103
  expect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.23.1-develop.1",
3
+ "version": "5.23.1-develop.3",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@apidevtools/swagger-parser": "10.1.0",
44
- "@squiz/component-cli-lib": "1.71.12",
44
+ "@squiz/component-cli-lib": "1.72.2",
45
45
  "@squiz/dxp-porter-shared": "0.4.0",
46
46
  "@squiz/local-component-dev-ui": "0.6.18",
47
47
  "axios": "1.1.3",
@@ -54,7 +54,7 @@
54
54
  "opener": "1.5.2",
55
55
  "ora": "^5.4.1",
56
56
  "prompt": "^1.3.0",
57
- "tough-cookie": "4.1.2",
57
+ "tough-cookie": "4.1.4",
58
58
  "update-notifier": "5.1.0",
59
59
  "yaml": "^2.3.4",
60
60
  "zod": "^3.23.8",
@@ -89,6 +89,7 @@
89
89
  "nock": "^13.3.1",
90
90
  "prettier": "2.7.1",
91
91
  "semantic-release": "19.0.3",
92
+ "supertest": "^6.3.4",
92
93
  "ts-jest": "29.2.5",
93
94
  "ts-node": "^10.9.1",
94
95
  "typescript": "4.7.4"