bdy 1.19.5-dev-pipeline → 1.19.5-dev
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/distTs/package.json +2 -2
- package/distTs/src/api/client.js +2 -103
- package/distTs/src/command/pipeline/run.js +125 -22
- package/distTs/src/command/pipeline.js +0 -23
- package/distTs/src/command/project/get.js +18 -0
- package/distTs/src/command/project/link.js +11 -11
- package/distTs/src/command/project/set.js +31 -0
- package/distTs/src/command/sandbox/get/yaml.js +30 -0
- package/distTs/src/command/vt/scrape.js +193 -0
- package/distTs/src/input.js +10 -11
- package/distTs/src/output.js +31 -149
- package/distTs/src/texts.js +35 -85
- package/distTs/src/tunnel/http.js +51 -14
- package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
- package/distTs/src/tunnel/tcp.js +7 -0
- package/package.json +2 -2
- package/distTs/src/command/crawl/link.js +0 -61
- package/distTs/src/command/crawl/run.js +0 -147
- package/distTs/src/command/crawl/validation.js +0 -154
- package/distTs/src/command/crawl.js +0 -13
- package/distTs/src/command/pipeline/create.js +0 -45
- package/distTs/src/command/pipeline/get.js +0 -42
- package/distTs/src/command/pipeline/list.js +0 -43
- package/distTs/src/command/pipeline/run/apply.js +0 -62
- package/distTs/src/command/pipeline/run/approve.js +0 -62
- package/distTs/src/command/pipeline/run/cancel.js +0 -36
- package/distTs/src/command/pipeline/run/list.js +0 -52
- package/distTs/src/command/pipeline/run/logs.js +0 -37
- package/distTs/src/command/pipeline/run/retry.js +0 -36
- package/distTs/src/command/pipeline/run/start.js +0 -96
- package/distTs/src/command/pipeline/run/status.js +0 -35
- package/distTs/src/command/pipeline/update.js +0 -41
- package/distTs/src/command/pipeline/yaml.js +0 -38
- package/distTs/src/command/tests/capture/validation.js +0 -46
- package/distTs/src/command/tests/capture.js +0 -103
- package/distTs/src/command/tests/unit/link.js +0 -61
- package/distTs/src/command/tests/unit/upload.js +0 -91
- package/distTs/src/command/tests/unit.js +0 -13
- package/distTs/src/command/tests/visual/link.js +0 -61
- package/distTs/src/command/tests/visual/session/close.js +0 -32
- package/distTs/src/command/tests/visual/session/create.js +0 -86
- package/distTs/src/command/tests/visual/session.js +0 -13
- package/distTs/src/command/tests/visual/setup.js +0 -20
- package/distTs/src/command/tests/visual/shared/validation.js +0 -145
- package/distTs/src/command/tests/visual/upload.js +0 -141
- package/distTs/src/command/tests/visual.js +0 -17
- package/distTs/src/command/tests.js +0 -15
- package/distTs/src/crawl/requests.js +0 -141
- package/distTs/src/output/pipeline.js +0 -1555
- package/distTs/src/types/crawl.js +0 -2
- package/distTs/src/types/pipeline.js +0 -424
- package/distTs/src/unitTest/context.js +0 -26
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const texts_1 = require("../../texts");
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const node_zlib_1 = require("node:zlib");
|
|
11
|
-
const promises_1 = require("node:stream/promises");
|
|
12
|
-
const node_fs_1 = require("node:fs");
|
|
13
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const promises_2 = require("node:fs/promises");
|
|
15
|
-
const commandCrawlRun = (0, utils_1.newCommand)('run', texts_1.DESC_COMMAND_CRAWL_RUN);
|
|
16
|
-
commandCrawlRun.argument('[url]', texts_1.OPTION_CRAWL_URL);
|
|
17
|
-
commandCrawlRun.option('--follow', texts_1.OPTION_CRAWL_FOLLOW, false);
|
|
18
|
-
commandCrawlRun.option('--respectRobots', texts_1.OPTION_COMPARE_RESPECT_ROBOTS, false);
|
|
19
|
-
commandCrawlRun.addOption(new commander_1.Option('--outputType <type>', texts_1.OPTION_CRAWL_OUTPUT_TYPE).choices([
|
|
20
|
-
'jpeg',
|
|
21
|
-
'png',
|
|
22
|
-
'md',
|
|
23
|
-
'html',
|
|
24
|
-
]));
|
|
25
|
-
commandCrawlRun.option('--outputTypes <json>', texts_1.OPTION_CRAWL_OUTPUT_TYPES);
|
|
26
|
-
commandCrawlRun.option('--quality <quality>', texts_1.OPTION_CRAWL_QUALITY);
|
|
27
|
-
commandCrawlRun.option('--fullPage', texts_1.OPTION_CRAWL_FULL_PAGE, false);
|
|
28
|
-
commandCrawlRun.option('--cssSelector <selector>', texts_1.OPTION_CRAWL_CSS_SELECTOR);
|
|
29
|
-
commandCrawlRun.option('--xpathSelector <selector>', texts_1.OPTION_CRAWL_XPATH_SELECTOR);
|
|
30
|
-
commandCrawlRun.addOption(new commander_1.Option('--colorScheme <scheme>', texts_1.OPTION_CRAWL_COLOR_SCHEME).choices([
|
|
31
|
-
'LIGHT',
|
|
32
|
-
'DARK',
|
|
33
|
-
'LIGHT_AND_DARK',
|
|
34
|
-
]));
|
|
35
|
-
commandCrawlRun.option('--browsers <browsers>', texts_1.OPTION_CRAWL_BROWSERS);
|
|
36
|
-
commandCrawlRun.option('--devices <devices>', texts_1.OPTION_CRAWL_DEVICES);
|
|
37
|
-
commandCrawlRun.option('--waitFor <waitFors...>', texts_1.OPTION_COMPARE_WAIT_FOR);
|
|
38
|
-
commandCrawlRun.option('--cookie <cookies...>', texts_1.OPTION_COMPARE_COOKIE);
|
|
39
|
-
commandCrawlRun.option('--header <headers...>', texts_1.OPTION_COMPARE_HEADER);
|
|
40
|
-
commandCrawlRun.option('--localStorage <items...>', texts_1.OPTION_CRAWL_LOCAL_STORAGE);
|
|
41
|
-
commandCrawlRun.option('--delay <delays...>', texts_1.OPTION_CRAWL_DELAY);
|
|
42
|
-
commandCrawlRun.option('--outputDir <dir>', texts_1.OPTION_CRAWL_OUTPUT_DIR, '.');
|
|
43
|
-
commandCrawlRun.action(async (inputUrl, options) => {
|
|
44
|
-
const { downloadCrawlPackage, sendCrawl } = require('../../crawl/requests');
|
|
45
|
-
const { createCrawlContext, applyToken, applyCiAndCommitInfo } = require('../../visualTest/context');
|
|
46
|
-
const { validateInputAndOptions } = require('./validation');
|
|
47
|
-
const { getCiAndGitInfo } = require('@buddy-works/ci-info');
|
|
48
|
-
const tar = require('tar-stream');
|
|
49
|
-
const Input = require('../../input').default;
|
|
50
|
-
const token = await Input.crawlSuiteToken();
|
|
51
|
-
if (!token) {
|
|
52
|
-
output_1.default.exitError(texts_1.ERR_MISSING_CRAWL_TOKEN);
|
|
53
|
-
}
|
|
54
|
-
const ctx = createCrawlContext();
|
|
55
|
-
applyToken(ctx, token);
|
|
56
|
-
const { url, follow, respectRobots, outputTypes, outputDir, colorScheme, browsers, devices, cookies, requestHeaders, delays, waitForSelectors, localStorage, } = validateInputAndOptions(inputUrl, options);
|
|
57
|
-
try {
|
|
58
|
-
const ciAndGitInfo = await getCiAndGitInfo({});
|
|
59
|
-
applyCiAndCommitInfo(ctx, ciAndGitInfo);
|
|
60
|
-
const { buildId } = await sendCrawl(ctx, url, follow, respectRobots, outputTypes, colorScheme, browsers, devices, cookies, requestHeaders, delays, waitForSelectors, localStorage);
|
|
61
|
-
const status = await watchSessionStatus(ctx, buildId);
|
|
62
|
-
if (!status.ok) {
|
|
63
|
-
output_1.default.exitError(`Crawl session failed: ${status.error}`);
|
|
64
|
-
}
|
|
65
|
-
output_1.default.normal('Downloading crawl package');
|
|
66
|
-
const crawlPackageStream = await downloadCrawlPackage(ctx, buildId);
|
|
67
|
-
const brotliDecompressor = (0, node_zlib_1.createBrotliDecompress)();
|
|
68
|
-
const unpack = tar.extract();
|
|
69
|
-
unpack.on('entry', async (header, stream, next) => {
|
|
70
|
-
const currentDir = process.cwd();
|
|
71
|
-
const preparedOutputDir = outputDir.startsWith('.')
|
|
72
|
-
? node_path_1.default.join(currentDir, outputDir)
|
|
73
|
-
: outputDir;
|
|
74
|
-
const newFilePath = node_path_1.default.join(preparedOutputDir, header.name);
|
|
75
|
-
try {
|
|
76
|
-
if (header.type === 'file') {
|
|
77
|
-
await (0, promises_2.mkdir)(node_path_1.default.dirname(newFilePath), { recursive: true });
|
|
78
|
-
const fileWriteStream = (0, node_fs_1.createWriteStream)(newFilePath);
|
|
79
|
-
await (0, promises_1.pipeline)(stream, fileWriteStream);
|
|
80
|
-
next();
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
stream.resume();
|
|
84
|
-
next();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch (entryError) {
|
|
88
|
-
output_1.default.error(`Error processing entry ${header.name}: ${entryError}`);
|
|
89
|
-
next(entryError);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
await (0, promises_1.pipeline)(crawlPackageStream, brotliDecompressor, unpack);
|
|
93
|
-
output_1.default.exitSuccess('Downloading crawl package finished');
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
output_1.default.exitError(`${error}`);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
async function watchSessionStatus(ctx, buildId) {
|
|
100
|
-
const { connectToCrawlSession } = require('../../crawl/requests');
|
|
101
|
-
return new Promise((resolve) => {
|
|
102
|
-
const eventSource = connectToCrawlSession(ctx, buildId);
|
|
103
|
-
eventSource.addEventListener('SESSION_STATUS', (event) => {
|
|
104
|
-
const data = JSON.parse(event.data);
|
|
105
|
-
if (data.status === 'STARTED') {
|
|
106
|
-
output_1.default.normal('Crawl session started');
|
|
107
|
-
}
|
|
108
|
-
else if (data.status === 'GATHER_URLS_COMPLETED') {
|
|
109
|
-
output_1.default.normal(`Gathering URLs completed, found ${data.text} URLs`);
|
|
110
|
-
}
|
|
111
|
-
else if (data.status === 'GATHER_URLS_FAILED') {
|
|
112
|
-
output_1.default.error('Gathering URLs failed');
|
|
113
|
-
}
|
|
114
|
-
else if (data.status === 'CRAWL_URL_COMPLETED') {
|
|
115
|
-
output_1.default.normal(`Crawling ${data.text} completed`);
|
|
116
|
-
}
|
|
117
|
-
else if (data.status === 'CRAWL_URL_FAILED') {
|
|
118
|
-
output_1.default.error(`Crawling ${data.text} failed`);
|
|
119
|
-
}
|
|
120
|
-
else if (data.status === 'CREATE_PACKAGE_COMPLETED') {
|
|
121
|
-
output_1.default.normal('Package created');
|
|
122
|
-
}
|
|
123
|
-
else if (data.status === 'CREATE_PACKAGE_FAILED') {
|
|
124
|
-
output_1.default.error('Package creation failed');
|
|
125
|
-
}
|
|
126
|
-
else if (data.status === 'ERROR') {
|
|
127
|
-
eventSource.close();
|
|
128
|
-
resolve({ ok: false, error: data.text });
|
|
129
|
-
}
|
|
130
|
-
else if (data.status === 'FINISHED') {
|
|
131
|
-
eventSource.close();
|
|
132
|
-
output_1.default.normal('Crawl session finished');
|
|
133
|
-
resolve({ ok: true });
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
eventSource.addEventListener('error', (event) => {
|
|
137
|
-
if (event.code) {
|
|
138
|
-
eventSource.close();
|
|
139
|
-
if (event.code === 410) {
|
|
140
|
-
output_1.default.normal('Crawl session finished');
|
|
141
|
-
}
|
|
142
|
-
resolve({ ok: event.code === 410, error: event.code });
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
exports.default = commandCrawlRun;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateInputAndOptions = validateInputAndOptions;
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
|
-
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const validation_1 = require("../tests/visual/shared/validation");
|
|
10
|
-
const urlSchema = zod_1.z.string().url().optional();
|
|
11
|
-
const browserSchema = zod_1.z.enum(['chrome', 'firefox', 'safari']);
|
|
12
|
-
const browsersListSchema = zod_1.z
|
|
13
|
-
.string()
|
|
14
|
-
.transform((value) => value
|
|
15
|
-
.split(',')
|
|
16
|
-
.map((browser) => browser.trim().toLowerCase())
|
|
17
|
-
.filter((browser) => browser.length > 0))
|
|
18
|
-
.refine((browsers) => browsers.length > 0, {
|
|
19
|
-
message: 'Invalid browsers list. Supported values: chrome,firefox,safari',
|
|
20
|
-
})
|
|
21
|
-
.pipe(zod_1.z.array(browserSchema))
|
|
22
|
-
.transform((browsers) => Array.from(new Set(browsers.map((browser) => browser === 'chrome'
|
|
23
|
-
? 'CHROMIUM'
|
|
24
|
-
: browser === 'firefox'
|
|
25
|
-
? 'FIREFOX'
|
|
26
|
-
: 'WEBKIT'))));
|
|
27
|
-
const optionsSchema = zod_1.z.object({
|
|
28
|
-
follow: zod_1.z.boolean(),
|
|
29
|
-
respectRobots: zod_1.z.boolean().optional(),
|
|
30
|
-
outputType: zod_1.z.enum(['jpeg', 'png', 'md', 'html']).optional(),
|
|
31
|
-
outputTypes: zod_1.z.string().optional(),
|
|
32
|
-
quality: zod_1.z.coerce.number().min(1).max(100).optional(),
|
|
33
|
-
outputDir: zod_1.z.string().default('.'),
|
|
34
|
-
fullPage: zod_1.z.boolean().optional(),
|
|
35
|
-
cssSelector: zod_1.z.string().optional(),
|
|
36
|
-
xpathSelector: zod_1.z.string().optional(),
|
|
37
|
-
colorScheme: zod_1.z.enum(['LIGHT', 'DARK', 'LIGHT_AND_DARK']).optional(),
|
|
38
|
-
browsers: browsersListSchema.optional(),
|
|
39
|
-
devices: zod_1.z.string().optional(),
|
|
40
|
-
delay: validation_1.delaySchema,
|
|
41
|
-
waitFor: validation_1.waitForSchema,
|
|
42
|
-
cookie: validation_1.cookieSchema,
|
|
43
|
-
header: validation_1.headerSchema,
|
|
44
|
-
localStorage: zod_1.z
|
|
45
|
-
.array(zod_1.z.string().regex(/^(?:([^:]+)::)?([^=]+)=(.*)$/, {
|
|
46
|
-
message: "LocalStorage option must follow pattern '[scope::]key=value' (scope is optional)",
|
|
47
|
-
}))
|
|
48
|
-
.optional()
|
|
49
|
-
.transform((value) => value?.map((v) => {
|
|
50
|
-
const { scope, key, value } = (0, validation_1.parseScopedKeyValue)(v);
|
|
51
|
-
return { scope, key, value };
|
|
52
|
-
})),
|
|
53
|
-
});
|
|
54
|
-
function validateInputAndOptions(input, options) {
|
|
55
|
-
try {
|
|
56
|
-
const url = urlSchema.parse(input);
|
|
57
|
-
const { follow, respectRobots, outputType, outputTypes: rawOutputTypes, quality, outputDir, fullPage, cssSelector, xpathSelector, colorScheme, browsers: parsedBrowsers, devices: rawDevices, delay, waitFor, cookie, header, localStorage, } = optionsSchema.parse(options);
|
|
58
|
-
let parsedOutputTypes;
|
|
59
|
-
if (rawOutputTypes) {
|
|
60
|
-
try {
|
|
61
|
-
const outputTypeEntrySchema = zod_1.z.array(zod_1.z
|
|
62
|
-
.object({
|
|
63
|
-
type: zod_1.z.string().transform((v) => v.toUpperCase()),
|
|
64
|
-
selector: zod_1.z
|
|
65
|
-
.object({
|
|
66
|
-
type: zod_1.z.enum(['CSS', 'XPATH']).optional(),
|
|
67
|
-
value: zod_1.z.string().optional(),
|
|
68
|
-
})
|
|
69
|
-
.optional(),
|
|
70
|
-
quality: zod_1.z.number().min(1).max(100).optional(),
|
|
71
|
-
fullPage: zod_1.z.boolean().optional(),
|
|
72
|
-
})
|
|
73
|
-
.transform((data) => ({
|
|
74
|
-
...data,
|
|
75
|
-
type: data.type,
|
|
76
|
-
})));
|
|
77
|
-
parsedOutputTypes = outputTypeEntrySchema.parse(JSON.parse(rawOutputTypes));
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
output_1.default.exitError("Invalid --outputTypes value. Use JSON array, e.g. --outputTypes '[{\"type\":\"png\"},{\"type\":\"jpeg\",\"quality\":80}]'");
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if (outputType) {
|
|
84
|
-
if (typeof quality === 'number' && outputType !== 'jpeg') {
|
|
85
|
-
output_1.default.exitError('Quality is only supported for jpeg output type, use --outputType jpeg');
|
|
86
|
-
}
|
|
87
|
-
if (cssSelector && xpathSelector) {
|
|
88
|
-
output_1.default.exitError('Only one of --cssSelector or --xpathSelector can be used');
|
|
89
|
-
}
|
|
90
|
-
const entry = {
|
|
91
|
-
type: outputType.toUpperCase(),
|
|
92
|
-
};
|
|
93
|
-
if (cssSelector) {
|
|
94
|
-
entry.selector = { type: 'CSS', value: cssSelector };
|
|
95
|
-
}
|
|
96
|
-
else if (xpathSelector) {
|
|
97
|
-
entry.selector = { type: 'XPATH', value: xpathSelector };
|
|
98
|
-
}
|
|
99
|
-
if (typeof quality === 'number') {
|
|
100
|
-
entry.quality = quality;
|
|
101
|
-
}
|
|
102
|
-
if (fullPage) {
|
|
103
|
-
entry.fullPage = fullPage;
|
|
104
|
-
}
|
|
105
|
-
parsedOutputTypes = [entry];
|
|
106
|
-
}
|
|
107
|
-
let parsedDevices;
|
|
108
|
-
if (rawDevices) {
|
|
109
|
-
try {
|
|
110
|
-
const dimensionSchema = zod_1.z
|
|
111
|
-
.string()
|
|
112
|
-
.regex(/^\d+x\d+$/, 'Must be in format "widthxheight"')
|
|
113
|
-
.transform((val) => {
|
|
114
|
-
const [width, height] = val.split('x').map(Number);
|
|
115
|
-
return { width, height };
|
|
116
|
-
});
|
|
117
|
-
const deviceSchema = zod_1.z.array(zod_1.z.object({
|
|
118
|
-
name: zod_1.z.string().optional(),
|
|
119
|
-
viewport: dimensionSchema,
|
|
120
|
-
screen: dimensionSchema,
|
|
121
|
-
devicePixelRatio: zod_1.z.number().positive(),
|
|
122
|
-
isMobile: zod_1.z.boolean(),
|
|
123
|
-
}));
|
|
124
|
-
parsedDevices = deviceSchema.parse(JSON.parse(rawDevices));
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
output_1.default.exitError('Invalid --devices value. Use JSON array, e.g. --devices \'[{"viewport":"1920x1080","screen":"1920x1080","devicePixelRatio":1,"isMobile":false}]\'');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
url,
|
|
132
|
-
follow,
|
|
133
|
-
respectRobots,
|
|
134
|
-
outputTypes: parsedOutputTypes,
|
|
135
|
-
outputDir,
|
|
136
|
-
colorScheme,
|
|
137
|
-
browsers: parsedBrowsers,
|
|
138
|
-
devices: parsedDevices,
|
|
139
|
-
cookies: cookie,
|
|
140
|
-
requestHeaders: header,
|
|
141
|
-
delays: delay ?? [],
|
|
142
|
-
waitForSelectors: waitFor,
|
|
143
|
-
localStorage,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
if (error instanceof zod_1.ZodError) {
|
|
148
|
-
output_1.default.exitError(error.errors.map((e) => `${e.path}: ${e.message}`).join(', '));
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const texts_1 = require("../texts");
|
|
8
|
-
const run_1 = __importDefault(require("./crawl/run"));
|
|
9
|
-
const link_1 = __importDefault(require("./crawl/link"));
|
|
10
|
-
const commandCrawl = (0, utils_1.newCommand)('crawl', texts_1.DESC_COMMAND_CRAWL);
|
|
11
|
-
commandCrawl.addCommand(run_1.default);
|
|
12
|
-
commandCrawl.addCommand(link_1.default);
|
|
13
|
-
exports.default = commandCrawl;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandPipelineCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_PIPELINE_CREATE);
|
|
11
|
-
commandPipelineCreate.alias('add');
|
|
12
|
-
commandPipelineCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineCreate.option('-n, --name <name>', texts_1.OPTION_PIPELINE_NAME);
|
|
15
|
-
commandPipelineCreate.option('-i, --identifier <identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
16
|
-
commandPipelineCreate.option('--yaml <content|@path>', texts_1.OPTION_PIPELINE_YAML);
|
|
17
|
-
commandPipelineCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_CREATE}`);
|
|
18
|
-
commandPipelineCreate.action(async (options) => {
|
|
19
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
|
-
const project = input_1.default.restApiProject(options.project);
|
|
21
|
-
const client = input_1.default.restApiTokenClient();
|
|
22
|
-
const humanId = require('human-id').default;
|
|
23
|
-
const timestamp = Date.now().toString(36);
|
|
24
|
-
const baseName = humanId({ separator: '-', capitalize: false });
|
|
25
|
-
const defaultIdentifier = `${baseName}-${timestamp}`;
|
|
26
|
-
let body = {
|
|
27
|
-
name: options.name || options.identifier || baseName,
|
|
28
|
-
identifier: options.identifier || defaultIdentifier,
|
|
29
|
-
};
|
|
30
|
-
let result = await client.createPipeline(workspace, project, body);
|
|
31
|
-
if (options.yaml) {
|
|
32
|
-
const yaml = input_1.default.restApiYaml(options.yaml);
|
|
33
|
-
body = {
|
|
34
|
-
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
35
|
-
};
|
|
36
|
-
await client.updatePipelineYml(workspace, project, result.id, body);
|
|
37
|
-
}
|
|
38
|
-
result = await client.getPipeline(workspace, project, result.id);
|
|
39
|
-
output_1.default.dim('Identifier: ', false);
|
|
40
|
-
output_1.default.cyan(result.identifier);
|
|
41
|
-
output_1.default.cyan(result.html_url);
|
|
42
|
-
output_1.default.green(texts_1.TXT_PIPELINE_CREATED);
|
|
43
|
-
output_1.default.exitNormal();
|
|
44
|
-
});
|
|
45
|
-
exports.default = commandPipelineCreate;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandPipelineGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PIPELINE_GET);
|
|
11
|
-
commandPipelineGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
-
commandPipelineGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
-
commandPipelineGet.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
14
|
-
commandPipelineGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_GET}`);
|
|
15
|
-
commandPipelineGet.action(async (identifier, options) => {
|
|
16
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
|
-
const project = input_1.default.restApiProject(options.project);
|
|
18
|
-
const client = input_1.default.restApiTokenClient();
|
|
19
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
20
|
-
if (!data || !data.domain) {
|
|
21
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
22
|
-
}
|
|
23
|
-
if (!data.project_identifier) {
|
|
24
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
25
|
-
}
|
|
26
|
-
if (!data.pipeline_id) {
|
|
27
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
28
|
-
}
|
|
29
|
-
const pipeline = await client.getPipeline(workspace, project, data.pipeline_id);
|
|
30
|
-
const OutputPipeline = require('../../output/pipeline').default;
|
|
31
|
-
const table = [
|
|
32
|
-
['Field', 'Value'],
|
|
33
|
-
['Name', pipeline.name || '-'],
|
|
34
|
-
['Status', OutputPipeline.runStatusText(pipeline.last_execution_status || '-')],
|
|
35
|
-
['ID', String(pipeline.id || '-')],
|
|
36
|
-
['Identifier', pipeline.identifier || '-'],
|
|
37
|
-
['URL', pipeline.html_url || '-'],
|
|
38
|
-
];
|
|
39
|
-
output_1.default.table(table);
|
|
40
|
-
output_1.default.exitNormal();
|
|
41
|
-
});
|
|
42
|
-
exports.default = commandPipelineGet;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const texts_1 = require("../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandPipelineList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PIPELINE_LIST);
|
|
11
|
-
commandPipelineList.alias('ls');
|
|
12
|
-
commandPipelineList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
|
|
15
|
-
commandPipelineList.option('--per-page <number>', texts_1.OPTION_REST_API_PER_PAGE, '10');
|
|
16
|
-
commandPipelineList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_LIST}`);
|
|
17
|
-
commandPipelineList.action(async (options) => {
|
|
18
|
-
const page = input_1.default.restApiPage(options.page);
|
|
19
|
-
const perPage = input_1.default.restApiPerPage(options.perPage);
|
|
20
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
|
-
const project = input_1.default.restApiProject(options.project);
|
|
22
|
-
const client = input_1.default.restApiTokenClient();
|
|
23
|
-
const r = await client.getPipelines(workspace, project, page, perPage);
|
|
24
|
-
if (!r.pipelines.length) {
|
|
25
|
-
output_1.default.exitError(texts_1.ERR_PIPELINES_NOT_FOUND);
|
|
26
|
-
}
|
|
27
|
-
const data = [
|
|
28
|
-
['NAME', 'STATUS', 'ID', 'IDENTIFIER', 'URL']
|
|
29
|
-
];
|
|
30
|
-
const OutputPipeline = require('../../output/pipeline').default;
|
|
31
|
-
for (const pipeline of r.pipelines) {
|
|
32
|
-
data.push([
|
|
33
|
-
pipeline.name || '-',
|
|
34
|
-
OutputPipeline.runStatusText(pipeline.last_execution_status || '-'),
|
|
35
|
-
String(pipeline.id || '-'),
|
|
36
|
-
pipeline.identifier || '-',
|
|
37
|
-
pipeline.html_url || '-',
|
|
38
|
-
]);
|
|
39
|
-
}
|
|
40
|
-
output_1.default.table(data);
|
|
41
|
-
output_1.default.exitNormal();
|
|
42
|
-
});
|
|
43
|
-
exports.default = commandPipelineList;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const texts_1 = require("../../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const pipeline_1 = require("../../../types/pipeline");
|
|
11
|
-
const commandPipelineRunApply = (0, utils_1.newCommand)('apply', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
|
|
12
|
-
commandPipelineRunApply.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineRunApply.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineRunApply.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
15
|
-
commandPipelineRunApply.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
|
|
16
|
-
commandPipelineRunApply.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
17
|
-
commandPipelineRunApply.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
|
|
18
|
-
commandPipelineRunApply.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
19
|
-
commandPipelineRunApply.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN_APPLY);
|
|
20
|
-
commandPipelineRunApply.action(async (identifier, runId, runActionId, options) => {
|
|
21
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
-
const project = input_1.default.restApiProject(options.project);
|
|
23
|
-
const rid = input_1.default.pipelineRunId(runId);
|
|
24
|
-
const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
|
|
25
|
-
const client = input_1.default.restApiTokenClient();
|
|
26
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
27
|
-
if (!data || !data.domain) {
|
|
28
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
29
|
-
}
|
|
30
|
-
if (!data.project_identifier) {
|
|
31
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
32
|
-
}
|
|
33
|
-
if (!data.pipeline_id) {
|
|
34
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
35
|
-
}
|
|
36
|
-
const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
|
|
37
|
-
let type;
|
|
38
|
-
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
39
|
-
type = 'APPLY';
|
|
40
|
-
}
|
|
41
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
42
|
-
type = 'APPROVE_VT';
|
|
43
|
-
}
|
|
44
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
45
|
-
type = 'APPLY_VARIABLES';
|
|
46
|
-
}
|
|
47
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
48
|
-
type = 'SET_VARIABLES';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
|
|
52
|
-
}
|
|
53
|
-
const body = {
|
|
54
|
-
operation: type,
|
|
55
|
-
approve_action_id: runActionId,
|
|
56
|
-
variables,
|
|
57
|
-
};
|
|
58
|
-
await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
|
|
59
|
-
const OutputPipeline = require('../../../output/pipeline').default;
|
|
60
|
-
await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
|
|
61
|
-
});
|
|
62
|
-
exports.default = commandPipelineRunApply;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const texts_1 = require("../../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const pipeline_1 = require("../../../types/pipeline");
|
|
11
|
-
const commandPipelineRunApprove = (0, utils_1.newCommand)('approve', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
|
|
12
|
-
commandPipelineRunApprove.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineRunApprove.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineRunApprove.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
15
|
-
commandPipelineRunApprove.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
16
|
-
commandPipelineRunApprove.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
17
|
-
commandPipelineRunApprove.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
|
|
18
|
-
commandPipelineRunApprove.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
19
|
-
commandPipelineRunApprove.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_APPLY}`);
|
|
20
|
-
commandPipelineRunApprove.action(async (identifier, runId, runActionId, options) => {
|
|
21
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
-
const project = input_1.default.restApiProject(options.project);
|
|
23
|
-
const rid = input_1.default.pipelineRunId(runId);
|
|
24
|
-
const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
|
|
25
|
-
const client = input_1.default.restApiTokenClient();
|
|
26
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
27
|
-
if (!data || !data.domain) {
|
|
28
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
29
|
-
}
|
|
30
|
-
if (!data.project_identifier) {
|
|
31
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
32
|
-
}
|
|
33
|
-
if (!data.pipeline_id) {
|
|
34
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
35
|
-
}
|
|
36
|
-
const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
|
|
37
|
-
let type;
|
|
38
|
-
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
39
|
-
type = 'APPLY';
|
|
40
|
-
}
|
|
41
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
42
|
-
type = 'APPROVE_VT';
|
|
43
|
-
}
|
|
44
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
45
|
-
type = 'APPLY_VARIABLES';
|
|
46
|
-
}
|
|
47
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
48
|
-
type = 'SET_VARIABLES';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
|
|
52
|
-
}
|
|
53
|
-
const body = {
|
|
54
|
-
operation: type,
|
|
55
|
-
approve_action_id: runActionId,
|
|
56
|
-
variables,
|
|
57
|
-
};
|
|
58
|
-
await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
|
|
59
|
-
const OutputPipeline = require('../../../output/pipeline').default;
|
|
60
|
-
await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
|
|
61
|
-
});
|
|
62
|
-
exports.default = commandPipelineRunApprove;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const texts_1 = require("../../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const commandPipelineRunCancel = (0, utils_1.newCommand)('cancel', texts_1.DESC_COMMAND_PIPELINE_RUN_CANCEL);
|
|
11
|
-
commandPipelineRunCancel.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
-
commandPipelineRunCancel.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
-
commandPipelineRunCancel.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
14
|
-
commandPipelineRunCancel.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
15
|
-
commandPipelineRunCancel.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
16
|
-
commandPipelineRunCancel.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_CANCEL}`);
|
|
17
|
-
commandPipelineRunCancel.action(async (identifier, runId, options) => {
|
|
18
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
-
const project = input_1.default.restApiProject(options.project);
|
|
20
|
-
const client = input_1.default.restApiTokenClient();
|
|
21
|
-
const rid = input_1.default.pipelineRunId(runId);
|
|
22
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
23
|
-
if (!data || !data.domain) {
|
|
24
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
25
|
-
}
|
|
26
|
-
if (!data.project_identifier) {
|
|
27
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
28
|
-
}
|
|
29
|
-
if (!data.pipeline_id) {
|
|
30
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
31
|
-
}
|
|
32
|
-
await client.pipelineRunCancel(workspace, project, data.pipeline_id, rid);
|
|
33
|
-
const OutputPipeline = require('../../../output/pipeline').default;
|
|
34
|
-
await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
|
|
35
|
-
});
|
|
36
|
-
exports.default = commandPipelineRunCancel;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const texts_1 = require("../../../texts");
|
|
8
|
-
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const commandPipelineRunList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PIPELINE_RUN_LIST);
|
|
11
|
-
commandPipelineRunList.alias('ls');
|
|
12
|
-
commandPipelineRunList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineRunList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineRunList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
|
|
15
|
-
commandPipelineRunList.option('--per-page <number>', texts_1.OPTION_REST_API_PER_PAGE, '10');
|
|
16
|
-
commandPipelineRunList.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
17
|
-
commandPipelineRunList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LIST}`);
|
|
18
|
-
commandPipelineRunList.action(async (identifier, options) => {
|
|
19
|
-
const page = input_1.default.restApiPage(options.page);
|
|
20
|
-
const perPage = input_1.default.restApiPerPage(options.perPage);
|
|
21
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
-
const project = input_1.default.restApiProject(options.project);
|
|
23
|
-
const client = input_1.default.restApiTokenClient();
|
|
24
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
25
|
-
if (!data || !data.domain) {
|
|
26
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
27
|
-
}
|
|
28
|
-
if (!data.project_identifier) {
|
|
29
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
30
|
-
}
|
|
31
|
-
if (!data.pipeline_id) {
|
|
32
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
33
|
-
}
|
|
34
|
-
const result = await client.getPipelineRuns(workspace, project, data.pipeline_id, page, perPage);
|
|
35
|
-
if (!result.executions.length) {
|
|
36
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_RUNS_NOT_FOUND);
|
|
37
|
-
}
|
|
38
|
-
const OutputPipeline = require('../../../output/pipeline').default;
|
|
39
|
-
const table = [['ID', 'STATUS', 'STARTED', 'FINISHED', 'URL']];
|
|
40
|
-
for (const run of result.executions) {
|
|
41
|
-
table.push([
|
|
42
|
-
String(run.id),
|
|
43
|
-
OutputPipeline.runStatusText(run.status),
|
|
44
|
-
run.start_date || '-',
|
|
45
|
-
run.finish_date || '-',
|
|
46
|
-
run.html_url,
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
output_1.default.table(table);
|
|
50
|
-
output_1.default.exitNormal('');
|
|
51
|
-
});
|
|
52
|
-
exports.default = commandPipelineRunList;
|