@squiz/dxp-cli-next 5.15.0-develop.1 → 5.15.0-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.
- package/lib/porter/constants.d.ts +2 -0
- package/lib/porter/constants.js +2 -0
- package/lib/porter/index.js +3 -1
- package/lib/porter/port/abort/abort.d.ts +3 -0
- package/lib/porter/port/abort/abort.js +77 -0
- package/lib/porter/port/abort/abort.spec.d.ts +1 -0
- package/lib/porter/port/abort/abort.spec.js +182 -0
- package/lib/porter/port/get/get.d.ts +3 -0
- package/lib/porter/port/get/get.js +93 -0
- package/lib/porter/port/get/get.spec.d.ts +1 -0
- package/lib/porter/port/get/get.spec.js +273 -0
- package/lib/porter/port/portCommand.d.ts +3 -0
- package/lib/porter/port/portCommand.js +19 -0
- package/lib/porter/port/start/start.d.ts +3 -0
- package/lib/porter/port/start/start.js +79 -0
- package/lib/porter/port/start/start.spec.d.ts +1 -0
- package/lib/porter/port/start/start.spec.js +198 -0
- package/lib/porter/project/add/add.js +6 -1
- package/lib/porter/project/add/add.spec.js +52 -99
- package/lib/porter/project/get/get.js +4 -9
- package/lib/porter/project/get/get.spec.js +47 -83
- package/lib/porter/project/projectCommand.js +1 -1
- package/lib/porter/project/remove/remove.js +1 -6
- package/lib/porter/project/remove/remove.spec.js +42 -77
- package/lib/porter/utils/ErrorUtils/ErrorUtils.js +4 -1
- package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.js +17 -2
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.js +2 -1
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.js +4 -3
- package/lib/porter/utils/GetProjectName/GetProjectName.d.ts +4 -0
- package/lib/porter/utils/GetProjectName/GetProjectName.js +30 -0
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.d.ts +1 -0
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.js +91 -0
- package/lib/porter/utils/index.d.ts +1 -0
- package/lib/porter/utils/index.js +1 -0
- package/package.json +2 -2
package/lib/porter/constants.js
CHANGED
|
@@ -6,4 +6,6 @@ exports.PORTER_REGION = 'au';
|
|
|
6
6
|
exports.PORTER_ERRORS = {
|
|
7
7
|
projectAlreadyExists: 'Project directory already exists. Please choose a project directory that does not exist',
|
|
8
8
|
projectNameMissing: 'Project name is missing from the config.json file',
|
|
9
|
+
projectDirectoryInvalid: 'You must be within a porter project directory to use this command',
|
|
10
|
+
portIdBlankError: 'Cannot be blank.',
|
|
9
11
|
};
|
package/lib/porter/index.js
CHANGED
|
@@ -4,9 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const commander_1 = require("commander");
|
|
7
|
+
const portCommand_1 = __importDefault(require("./port/portCommand"));
|
|
7
8
|
const projectCommand_1 = __importDefault(require("./project/projectCommand"));
|
|
8
9
|
const porterCommand = new commander_1.Command('porter');
|
|
9
10
|
porterCommand
|
|
10
11
|
.description('Porter Service Commands')
|
|
11
|
-
.addCommand((0, projectCommand_1.default)())
|
|
12
|
+
.addCommand((0, projectCommand_1.default)())
|
|
13
|
+
.addCommand((0, portCommand_1.default)());
|
|
12
14
|
exports.default = porterCommand;
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const commander_1 = require("commander");
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const ora_1 = __importDefault(require("ora"));
|
|
18
|
+
const ApiService_1 = require("../../../ApiService");
|
|
19
|
+
const utils_1 = require("../../utils");
|
|
20
|
+
const constants_1 = require("../../constants");
|
|
21
|
+
const createAbortPortCommand = () => {
|
|
22
|
+
const getCommand = new commander_1.Command('abortPort')
|
|
23
|
+
.description('Aborts a running website port')
|
|
24
|
+
.configureOutput({
|
|
25
|
+
outputError(str, write) {
|
|
26
|
+
write(chalk_1.default.red(str));
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
.addArgument(new commander_1.Argument('UUID', 'ID of the port').argParser((portId) => {
|
|
30
|
+
const trimmedPortId = portId.trim();
|
|
31
|
+
if (!trimmedPortId) {
|
|
32
|
+
throw new commander_1.InvalidArgumentError(constants_1.PORTER_ERRORS.portIdBlankError);
|
|
33
|
+
}
|
|
34
|
+
return trimmedPortId;
|
|
35
|
+
}))
|
|
36
|
+
.action((uuid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
|
+
yield (0, utils_1.throwErrorIfNotLoggedIn)(getCommand);
|
|
39
|
+
const baseUrl = yield (0, utils_1.buildPorterUrl)();
|
|
40
|
+
const portId = uuid;
|
|
41
|
+
let projectName = '';
|
|
42
|
+
const spinner = (0, ora_1.default)();
|
|
43
|
+
try {
|
|
44
|
+
projectName = yield (0, utils_1.getProjectName)();
|
|
45
|
+
spinner.start('Aborting port..');
|
|
46
|
+
const apiService = new ApiService_1.ApiService(utils_1.validateAxiosStatus, baseUrl);
|
|
47
|
+
const abortRequest = {
|
|
48
|
+
status: 'abort',
|
|
49
|
+
};
|
|
50
|
+
const response = yield apiService.client.patch(`/projects/${projectName}/ports/${portId}`, abortRequest);
|
|
51
|
+
const jsonResponse = response.data;
|
|
52
|
+
(0, utils_1.logDebug)(JSON.stringify(jsonResponse));
|
|
53
|
+
spinner.succeed();
|
|
54
|
+
console.log('');
|
|
55
|
+
console.log('Website port aborted');
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
(0, utils_1.logDebug)(`ERROR: ${error instanceof Error ? `${error.message}` : JSON.stringify(error)}`);
|
|
59
|
+
if (spinner.isSpinning) {
|
|
60
|
+
spinner.fail();
|
|
61
|
+
}
|
|
62
|
+
if (((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.status) === 404) {
|
|
63
|
+
(0, utils_1.logDebug)(error.response.data);
|
|
64
|
+
const errorMessage = 'Website port execution not found';
|
|
65
|
+
return (0, utils_1.handleError)(getCommand, errorMessage);
|
|
66
|
+
}
|
|
67
|
+
if (((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.status) === 409) {
|
|
68
|
+
(0, utils_1.logDebug)(error.response.data);
|
|
69
|
+
const errorMessage = 'Website port cannot be aborted as it is already not running';
|
|
70
|
+
return (0, utils_1.handleError)(getCommand, errorMessage);
|
|
71
|
+
}
|
|
72
|
+
(0, utils_1.handleCommandError)(getCommand, error);
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
return getCommand;
|
|
76
|
+
};
|
|
77
|
+
exports.default = createAbortPortCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const axios_1 = require("axios");
|
|
36
|
+
const ApiService = __importStar(require("../../../ApiService"));
|
|
37
|
+
const PorterUtils = __importStar(require("../../utils"));
|
|
38
|
+
const constants_1 = require("../../constants");
|
|
39
|
+
const dxp_porter_shared_1 = require("@squiz/dxp-porter-shared");
|
|
40
|
+
const logSpy = jest.spyOn(global.console, 'log');
|
|
41
|
+
jest.mock('../../utils');
|
|
42
|
+
describe('abortPort', () => {
|
|
43
|
+
let projectName;
|
|
44
|
+
let portId;
|
|
45
|
+
let baseUrl;
|
|
46
|
+
let mockHandleCommandError;
|
|
47
|
+
let mockHandleError;
|
|
48
|
+
let mockBuildPorterUrl;
|
|
49
|
+
let mockResponse;
|
|
50
|
+
let mockClient;
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
jest.resetAllMocks();
|
|
53
|
+
jest.clearAllMocks();
|
|
54
|
+
projectName = 'mock-project';
|
|
55
|
+
portId = '1234-5678-1234-5678';
|
|
56
|
+
baseUrl = 'mock-url';
|
|
57
|
+
mockHandleCommandError = jest.fn(() => Promise.resolve());
|
|
58
|
+
mockHandleError = jest.fn();
|
|
59
|
+
mockBuildPorterUrl = jest.fn(() => Promise.resolve(baseUrl));
|
|
60
|
+
mockResponse = {
|
|
61
|
+
data: {},
|
|
62
|
+
status: 200,
|
|
63
|
+
};
|
|
64
|
+
mockClient = {
|
|
65
|
+
patch: jest.fn().mockImplementationOnce(() => mockResponse),
|
|
66
|
+
};
|
|
67
|
+
jest.spyOn(PorterUtils, 'throwErrorIfNotLoggedIn').mockImplementation();
|
|
68
|
+
jest
|
|
69
|
+
.spyOn(PorterUtils, 'buildPorterUrl')
|
|
70
|
+
.mockImplementationOnce(mockBuildPorterUrl);
|
|
71
|
+
jest
|
|
72
|
+
.spyOn(PorterUtils, 'getProjectName')
|
|
73
|
+
.mockImplementation(() => Promise.resolve(projectName));
|
|
74
|
+
jest
|
|
75
|
+
.spyOn(PorterUtils, 'handleCommandError')
|
|
76
|
+
.mockImplementationOnce(mockHandleCommandError);
|
|
77
|
+
jest
|
|
78
|
+
.spyOn(PorterUtils, 'handleError')
|
|
79
|
+
.mockImplementationOnce(mockHandleError);
|
|
80
|
+
jest.spyOn(process, 'exit').mockImplementation();
|
|
81
|
+
jest.spyOn(ApiService, 'ApiService').mockImplementationOnce(() => {
|
|
82
|
+
return {
|
|
83
|
+
client: mockClient,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
it('should throw an error if port id is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const portIdInvalid = ' ';
|
|
89
|
+
const { default: createAbortCommand } = require('./abort');
|
|
90
|
+
const program = createAbortCommand();
|
|
91
|
+
yield expect(() => program.parseAsync(['port', 'abortPort', portIdInvalid])).rejects.toThrow(constants_1.PORTER_ERRORS.portIdBlankError);
|
|
92
|
+
}));
|
|
93
|
+
it('should throw an error if not logged in', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const mockError = new Error('Error not logged in');
|
|
95
|
+
jest
|
|
96
|
+
.spyOn(PorterUtils, 'throwErrorIfNotLoggedIn')
|
|
97
|
+
.mockImplementationOnce(() => {
|
|
98
|
+
throw mockError;
|
|
99
|
+
});
|
|
100
|
+
const { default: createAbortCommand } = require('./abort');
|
|
101
|
+
const program = createAbortCommand();
|
|
102
|
+
yield expect(() => program.parseAsync(['port', 'abortPort', portId])).rejects.toThrow(mockError);
|
|
103
|
+
const opts = program.opts();
|
|
104
|
+
expect(opts).toStrictEqual({});
|
|
105
|
+
expect(PorterUtils.buildPorterUrl).not.toHaveBeenCalled();
|
|
106
|
+
}));
|
|
107
|
+
it('should throw an error if project name could not be found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
jest.spyOn(PorterUtils, 'getProjectName').mockImplementationOnce(() => {
|
|
109
|
+
throw new Error();
|
|
110
|
+
});
|
|
111
|
+
const { default: createAbortCommand } = require('./abort');
|
|
112
|
+
const program = createAbortCommand();
|
|
113
|
+
yield program.parseAsync(['port', 'abortPort', portId]);
|
|
114
|
+
expect(PorterUtils.buildPorterUrl).toHaveBeenCalled();
|
|
115
|
+
expect(mockClient.patch).not.toHaveBeenCalled();
|
|
116
|
+
expect(PorterUtils.handleCommandError).toHaveBeenCalled();
|
|
117
|
+
}));
|
|
118
|
+
it('should handle 404 error when port cannot be found for project', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
mockClient.patch = jest.fn(() => {
|
|
120
|
+
throw new axios_1.AxiosError('Port does not exist', '404', undefined, undefined, {
|
|
121
|
+
data: { status: 404 },
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
const { default: createAbortCommand } = require('./abort');
|
|
125
|
+
const program = createAbortCommand();
|
|
126
|
+
yield program.parseAsync(['port', 'abortPort', portId]);
|
|
127
|
+
expect(PorterUtils.buildPorterUrl).toHaveBeenCalled();
|
|
128
|
+
expect(mockClient.patch).toHaveBeenCalledWith(`/projects/${projectName}/ports/${portId}`, { status: 'abort' });
|
|
129
|
+
expect(PorterUtils.handleError).toHaveBeenCalled();
|
|
130
|
+
}));
|
|
131
|
+
it('should handle 409 error when port is already not running', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
mockClient.patch = jest.fn(() => {
|
|
133
|
+
throw new axios_1.AxiosError('Port already not running', '409', undefined, undefined, {
|
|
134
|
+
data: { status: 409 },
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const { default: createAbortCommand } = require('./abort');
|
|
138
|
+
const program = createAbortCommand();
|
|
139
|
+
yield program.parseAsync(['port', 'abortPort', portId]);
|
|
140
|
+
expect(PorterUtils.buildPorterUrl).toHaveBeenCalled();
|
|
141
|
+
expect(mockClient.patch).toHaveBeenCalledWith(`/projects/${projectName}/ports/${portId}`, { status: 'abort' });
|
|
142
|
+
expect(PorterUtils.handleError).toHaveBeenCalled();
|
|
143
|
+
}));
|
|
144
|
+
it('should handle unexpected errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
mockClient.patch = jest.fn(() => {
|
|
146
|
+
throw new axios_1.AxiosError('Internal server error', '500', undefined, undefined, {
|
|
147
|
+
data: { status: 500 },
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
const { default: createAbortCommand } = require('./abort');
|
|
151
|
+
const program = createAbortCommand();
|
|
152
|
+
yield program.parseAsync(['port', 'abortPort', portId]);
|
|
153
|
+
expect(PorterUtils.buildPorterUrl).toHaveBeenCalled();
|
|
154
|
+
expect(mockClient.patch).toHaveBeenCalledWith(`/projects/${projectName}/ports/${portId}`, { status: 'abort' });
|
|
155
|
+
expect(PorterUtils.handleError).not.toHaveBeenCalled();
|
|
156
|
+
expect(PorterUtils.handleCommandError).toHaveBeenCalled();
|
|
157
|
+
}));
|
|
158
|
+
it('should successfully abort a running port', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
+
// mockClient.patch = jest.fn(() => {
|
|
160
|
+
// });
|
|
161
|
+
const mockPatchResponse = {
|
|
162
|
+
portid: portId,
|
|
163
|
+
'artifacts-link': null,
|
|
164
|
+
'report-link': null,
|
|
165
|
+
'stage-settings': {},
|
|
166
|
+
stages: {},
|
|
167
|
+
status: dxp_porter_shared_1.PortStatus.aborted,
|
|
168
|
+
};
|
|
169
|
+
mockResponse = {
|
|
170
|
+
data: mockPatchResponse,
|
|
171
|
+
status: 200,
|
|
172
|
+
};
|
|
173
|
+
const { default: createAbortCommand } = require('./abort');
|
|
174
|
+
const program = createAbortCommand();
|
|
175
|
+
yield program.parseAsync(['port', 'abortPort', portId]);
|
|
176
|
+
expect(PorterUtils.buildPorterUrl).toHaveBeenCalled();
|
|
177
|
+
expect(mockClient.patch).toHaveBeenCalledWith(`/projects/${projectName}/ports/${portId}`, { status: 'abort' });
|
|
178
|
+
expect(PorterUtils.handleError).not.toHaveBeenCalled();
|
|
179
|
+
expect(PorterUtils.handleCommandError).not.toHaveBeenCalled();
|
|
180
|
+
expect(logSpy).toHaveBeenCalledWith('Website port aborted');
|
|
181
|
+
}));
|
|
182
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const commander_1 = require("commander");
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const ora_1 = __importDefault(require("ora"));
|
|
18
|
+
const ApiService_1 = require("../../../ApiService");
|
|
19
|
+
const utils_1 = require("../../utils");
|
|
20
|
+
const constants_1 = require("../../constants");
|
|
21
|
+
const dxp_porter_shared_1 = require("@squiz/dxp-porter-shared");
|
|
22
|
+
const createGetPortCommand = () => {
|
|
23
|
+
const getCommand = new commander_1.Command('getPort')
|
|
24
|
+
.description('Gets the information about a specified website port')
|
|
25
|
+
.configureOutput({
|
|
26
|
+
outputError(str, write) {
|
|
27
|
+
write(chalk_1.default.red(str));
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
.addArgument(new commander_1.Argument('UUID', 'ID of the port').argParser((portId) => {
|
|
31
|
+
const trimmedPortId = portId.trim();
|
|
32
|
+
if (!trimmedPortId) {
|
|
33
|
+
throw new commander_1.InvalidArgumentError(constants_1.PORTER_ERRORS.portIdBlankError);
|
|
34
|
+
}
|
|
35
|
+
return trimmedPortId;
|
|
36
|
+
}))
|
|
37
|
+
.action((uuid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
yield (0, utils_1.throwErrorIfNotLoggedIn)(getCommand);
|
|
40
|
+
const baseUrl = yield (0, utils_1.buildPorterUrl)();
|
|
41
|
+
const portId = uuid;
|
|
42
|
+
let projectName = '';
|
|
43
|
+
const spinner = (0, ora_1.default)();
|
|
44
|
+
try {
|
|
45
|
+
projectName = yield (0, utils_1.getProjectName)();
|
|
46
|
+
spinner.start('Retrieving port..');
|
|
47
|
+
const apiService = new ApiService_1.ApiService(utils_1.validateAxiosStatus, baseUrl);
|
|
48
|
+
const response = yield apiService.client.get(`/projects/${projectName}/ports/${portId}`);
|
|
49
|
+
const jsonResponse = response.data;
|
|
50
|
+
(0, utils_1.logDebug)(JSON.stringify(jsonResponse));
|
|
51
|
+
const { portid, stages, 'stage-settings': stageSettings, status, } = jsonResponse;
|
|
52
|
+
const artifactsLink = (_a = jsonResponse['artifacts-link']) !== null && _a !== void 0 ? _a : 'Not generated';
|
|
53
|
+
const reportLink = (_b = jsonResponse['report-link']) !== null && _b !== void 0 ? _b : 'Not generated';
|
|
54
|
+
spinner.succeed();
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log(`Port ID: ${portid}`);
|
|
57
|
+
console.log(`Status: ${status}`);
|
|
58
|
+
console.log(`Download report: ${reportLink}`);
|
|
59
|
+
console.log(`Download artifacts: ${artifactsLink}`);
|
|
60
|
+
console.log('');
|
|
61
|
+
const excludedStages = [
|
|
62
|
+
dxp_porter_shared_1.Stage['component-transform'],
|
|
63
|
+
dxp_porter_shared_1.Stage['design-dedupe'],
|
|
64
|
+
// Hide validation stage from user (PERSONIZE-771)
|
|
65
|
+
dxp_porter_shared_1.Stage.validation,
|
|
66
|
+
];
|
|
67
|
+
const stagesToLog = Object.values(dxp_porter_shared_1.Stage).filter(stage => !excludedStages.includes(stage));
|
|
68
|
+
for (const stage of stagesToLog) {
|
|
69
|
+
const stageString = stage.replace(/-/, ' ');
|
|
70
|
+
console.log(`Stage ${stageString} status: ${stages[stage].status}`);
|
|
71
|
+
}
|
|
72
|
+
console.log('');
|
|
73
|
+
for (const stage of stagesToLog) {
|
|
74
|
+
const stageString = stage.replace(/-/, ' ');
|
|
75
|
+
console.log(`Stage ${stageString} settings:`, stageSettings[stage]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
(0, utils_1.logDebug)(`ERROR: ${error instanceof Error ? `${error.message}` : JSON.stringify(error)}`);
|
|
80
|
+
if (spinner.isSpinning) {
|
|
81
|
+
spinner.fail();
|
|
82
|
+
}
|
|
83
|
+
if (((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.status) === 404) {
|
|
84
|
+
(0, utils_1.logDebug)(error.response.data);
|
|
85
|
+
const errorMessage = 'Website port execution not found';
|
|
86
|
+
return (0, utils_1.handleError)(getCommand, errorMessage);
|
|
87
|
+
}
|
|
88
|
+
(0, utils_1.handleCommandError)(getCommand, error);
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
return getCommand;
|
|
92
|
+
};
|
|
93
|
+
exports.default = createGetPortCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|