@squiz/dxp-cli-next 2.11.0 → 2.11.1-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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const dev_mode_1 = require("../../cmp/dev-mode");
13
+ describe('cmp dev', () => {
14
+ it('correctly parses the port', () => __awaiter(void 0, void 0, void 0, function* () {
15
+ const program = (0, dev_mode_1.buildDevModeCommand)()
16
+ .exitOverride()
17
+ .action(() => { });
18
+ program.parse(['node', 'dxp-cli', 'dev', '--port', '3005']);
19
+ const opts = program.opts();
20
+ expect(opts.port).toStrictEqual(3005);
21
+ }));
22
+ it('defaults the port to 3000', () => {
23
+ const program = (0, dev_mode_1.buildDevModeCommand)()
24
+ .exitOverride()
25
+ .action(() => { });
26
+ program.parse(['node', 'dxp-cli', 'dev']);
27
+ const opts = program.opts();
28
+ expect(opts.port).toStrictEqual(3000);
29
+ });
30
+ it.each(['3000', '3001', '65535', '1024'])('correctly parses the port (%s)', (attemptedPort) => __awaiter(void 0, void 0, void 0, function* () {
31
+ const program = (0, dev_mode_1.buildDevModeCommand)()
32
+ .exitOverride()
33
+ .action(() => { });
34
+ program.parse(['node', 'dxp-cli', 'dev', '--port', attemptedPort]);
35
+ const opts = program.opts();
36
+ expect(typeof opts.port).toStrictEqual('number');
37
+ }));
38
+ it.each([
39
+ 'hello_world',
40
+ '3_000',
41
+ '65_535',
42
+ '1000',
43
+ '100',
44
+ '1_000_000',
45
+ '1000000',
46
+ 'abc_1000',
47
+ '1000arst',
48
+ ])('errors when port (%s) is not a number between 1000-65535', attemptedPort => {
49
+ const program = (0, dev_mode_1.buildDevModeCommand)()
50
+ .exitOverride()
51
+ .action(() => { });
52
+ expect(() => program.parse(['node', 'dxp-cli', 'dev', '--port', attemptedPort])).toThrowError('Port must be a number between 1024-65535');
53
+ });
54
+ });
@@ -1,3 +1,4 @@
1
1
  import { Command } from 'commander';
2
+ export declare const buildDevModeCommand: () => Command;
2
3
  declare const devModeCommand: Command;
3
4
  export default devModeCommand;
@@ -9,9 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.buildDevModeCommand = void 0;
12
13
  const commander_1 = require("commander");
13
14
  const component_cli_lib_1 = require("@squiz/component-cli-lib");
14
- const devModeCommand = new commander_1.Command()
15
+ const MIN_PORT = 1024;
16
+ const MAX_PORT = 65535;
17
+ const buildDevModeCommand = () => new commander_1.Command()
15
18
  .name('dev')
16
19
  .description('A local component runner for developing new components')
17
20
  .addHelpText('after', `
@@ -22,8 +25,18 @@ The logs are currently \`bunyan\` formatted and should be piped into the bunyan
22
25
  .argument('<source>', 'folder containing the template files in development')
23
26
  .addOption(new commander_1.Option('-p, --port <number>', 'Define port the webserver runs on')
24
27
  .default(3000)
25
- .argParser(parseInt))
28
+ .argParser(v => {
29
+ const parsedPort = Number(v);
30
+ if (isNaN(parsedPort) ||
31
+ MIN_PORT > parsedPort ||
32
+ parsedPort > MAX_PORT) {
33
+ throw new commander_1.InvalidArgumentError(`Port must be a number between ${MIN_PORT}-${MAX_PORT}`);
34
+ }
35
+ return parsedPort;
36
+ }))
26
37
  .action((source, options) => __awaiter(void 0, void 0, void 0, function* () {
27
38
  yield (0, component_cli_lib_1.startDevelopmentRender)(source, options);
28
39
  }));
40
+ exports.buildDevModeCommand = buildDevModeCommand;
41
+ const devModeCommand = (0, exports.buildDevModeCommand)();
29
42
  exports.default = devModeCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "2.11.0",
3
+ "version": "2.11.1-develop.2",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/developer-experience/dxp-cli-next"
6
6
  },
@@ -39,25 +39,25 @@
39
39
  "codecov"
40
40
  ],
41
41
  "dependencies": {
42
- "@squiz/component-cli-lib": "1.2.1-alpha.68",
42
+ "@squiz/component-cli-lib": "1.2.1-alpha.70",
43
43
  "@squiz/deployment-service-lib": "1.1.5-alpha.83",
44
44
  "cli-color": "2.0.3",
45
- "commander": "9.3.0",
45
+ "commander": "9.4.0",
46
46
  "update-notifier": "5.1.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@semantic-release/git": "10.0.1",
50
- "@semantic-release/gitlab": "9.3.2",
50
+ "@semantic-release/gitlab": "9.4.1",
51
51
  "@semantic-release/npm": "9.0.1",
52
52
  "@types/cli-color": "2.0.2",
53
- "@types/jest": "28.1.4",
53
+ "@types/jest": "28.1.6",
54
54
  "@types/node": "17.0.45",
55
55
  "@types/update-notifier": "5.1.0",
56
- "@typescript-eslint/eslint-plugin": "5.30.5",
57
- "@typescript-eslint/parser": "5.30.5",
58
56
  "chalk": "4.1.2",
57
+ "@typescript-eslint/eslint-plugin": "5.30.7",
58
+ "@typescript-eslint/parser": "5.30.7",
59
59
  "codecov": "3.8.3",
60
- "commitizen": "4.2.4",
60
+ "commitizen": "4.2.5",
61
61
  "cz-conventional-changelog": "3.3.0",
62
62
  "eslint": "8.19.0",
63
63
  "eslint-config-prettier": "8.5.0",
@@ -65,12 +65,12 @@
65
65
  "eslint-plugin-prettier": "4.2.1",
66
66
  "execa": "5.1.1",
67
67
  "husky": "8.0.1",
68
- "jest": "28.1.2",
68
+ "jest": "28.1.3",
69
69
  "lint-staged": "13.0.3",
70
70
  "prettier": "2.7.1",
71
71
  "semantic-release": "19.0.3",
72
- "ts-jest": "28.0.5",
73
- "ts-node": "10.8.2",
72
+ "ts-jest": "28.0.7",
73
+ "ts-node": "10.9.1",
74
74
  "typescript": "4.7.4"
75
75
  },
76
76
  "config": {