@solidactions/cli 3.30.0 → 3.31.0
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.
|
@@ -3,12 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.webhookListParams = webhookListParams;
|
|
6
7
|
exports.webhookList = webhookList;
|
|
7
8
|
const axios_1 = __importDefault(require("axios"));
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const api_1 = require("../utils/api");
|
|
10
11
|
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const webhook_formatters_1 = require("../utils/webhook-formatters");
|
|
13
|
+
function webhookListParams(options) {
|
|
14
|
+
const params = { include: 'functions' };
|
|
15
|
+
if (options.showSecrets) {
|
|
16
|
+
params.show_secrets = 'true';
|
|
17
|
+
}
|
|
18
|
+
return params;
|
|
19
|
+
}
|
|
12
20
|
async function webhookList(projectName, options = {}) {
|
|
13
21
|
const format = options.format ?? 'table';
|
|
14
22
|
if (format !== 'table' && format !== 'json') {
|
|
@@ -22,10 +30,7 @@ async function webhookList(projectName, options = {}) {
|
|
|
22
30
|
}
|
|
23
31
|
try {
|
|
24
32
|
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
25
|
-
const params =
|
|
26
|
-
if (options.showSecrets) {
|
|
27
|
-
params.show_secrets = 'true';
|
|
28
|
-
}
|
|
33
|
+
const params = webhookListParams(options);
|
|
29
34
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
|
|
30
35
|
headers: (0, api_1.getApiHeaders)(config),
|
|
31
36
|
params,
|
|
@@ -4,24 +4,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.formatSecretOutput = formatSecretOutput;
|
|
7
|
+
exports.formatSecretJson = formatSecretJson;
|
|
7
8
|
exports.webhookSecret = webhookSecret;
|
|
8
9
|
const axios_1 = __importDefault(require("axios"));
|
|
9
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
11
|
const api_1 = require("../utils/api");
|
|
11
12
|
const project_ref_1 = require("../utils/project-ref");
|
|
13
|
+
function workflowRowsOnly(rows) {
|
|
14
|
+
return rows.filter((r) => r.kind !== 'function');
|
|
15
|
+
}
|
|
12
16
|
function formatSecretOutput(rows, workflowFilter) {
|
|
17
|
+
const workflows = workflowRowsOnly(rows);
|
|
13
18
|
if (workflowFilter) {
|
|
14
|
-
const match =
|
|
19
|
+
const match = workflows.find((r) => r.workflow_name === workflowFilter);
|
|
15
20
|
if (!match)
|
|
16
21
|
return `No webhook named "${workflowFilter}" found.`;
|
|
17
22
|
return match.webhook_secret ?? '(secret not returned — check your access level)';
|
|
18
23
|
}
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
24
|
+
if (workflows.length === 1) {
|
|
25
|
+
return workflows[0].webhook_secret ?? '(secret not returned — check your access level)';
|
|
21
26
|
}
|
|
22
|
-
const lines =
|
|
27
|
+
const lines = workflows.map((r) => `${(r.workflow_name ?? '?').padEnd(32)}${r.webhook_secret ?? '(none)'}`);
|
|
23
28
|
return ['WORKFLOW'.padEnd(32) + 'SECRET', '-'.repeat(80), ...lines].join('\n');
|
|
24
29
|
}
|
|
30
|
+
function formatSecretJson(rows, workflowFilter) {
|
|
31
|
+
const workflows = workflowRowsOnly(rows);
|
|
32
|
+
const out = workflowFilter
|
|
33
|
+
? workflows
|
|
34
|
+
.filter((r) => r.workflow_name === workflowFilter)
|
|
35
|
+
.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
|
|
36
|
+
: workflows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
|
|
37
|
+
return JSON.stringify(out, null, 2);
|
|
38
|
+
}
|
|
25
39
|
async function webhookSecret(projectName, options = {}) {
|
|
26
40
|
const format = options.format ?? 'text';
|
|
27
41
|
if (format !== 'text' && format !== 'json') {
|
|
@@ -39,18 +53,13 @@ async function webhookSecret(projectName, options = {}) {
|
|
|
39
53
|
headers: (0, api_1.getApiHeaders)(config),
|
|
40
54
|
params: { show_secrets: 'true' },
|
|
41
55
|
});
|
|
42
|
-
const rows = response.data.data ?? [];
|
|
56
|
+
const rows = workflowRowsOnly(response.data.data ?? []);
|
|
43
57
|
if (rows.length === 0) {
|
|
44
58
|
console.error(chalk_1.default.yellow(`No webhook workflows found for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}.`));
|
|
45
59
|
process.exit(1);
|
|
46
60
|
}
|
|
47
61
|
if (format === 'json') {
|
|
48
|
-
|
|
49
|
-
? rows
|
|
50
|
-
.filter((r) => r.workflow_name === options.workflow)
|
|
51
|
-
.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
|
|
52
|
-
: rows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
|
|
53
|
-
console.log(JSON.stringify(out, null, 2));
|
|
62
|
+
console.log(formatSecretJson(rows, options.workflow));
|
|
54
63
|
return;
|
|
55
64
|
}
|
|
56
65
|
console.log(formatSecretOutput(rows, options.workflow));
|
|
@@ -12,7 +12,21 @@ const workflow_state_1 = require("./workflow-state");
|
|
|
12
12
|
function columnWidth(min, values) {
|
|
13
13
|
return Math.max(min, ...values.map(v => v.length)) + 2;
|
|
14
14
|
}
|
|
15
|
+
function isFunctionRow(webhook) {
|
|
16
|
+
return webhook.kind === 'function';
|
|
17
|
+
}
|
|
15
18
|
function webhookState(webhook) {
|
|
19
|
+
if (isFunctionRow(webhook)) {
|
|
20
|
+
if (webhook.retired === true)
|
|
21
|
+
return 'retired';
|
|
22
|
+
if (webhook.enabled === false)
|
|
23
|
+
return 'off';
|
|
24
|
+
if (webhook.project_enabled === false)
|
|
25
|
+
return 'blocked (project off)';
|
|
26
|
+
if (webhook.effective_enabled === false)
|
|
27
|
+
return 'not live';
|
|
28
|
+
return 'on';
|
|
29
|
+
}
|
|
16
30
|
return (0, workflow_state_1.workflowEffectiveState)(webhook);
|
|
17
31
|
}
|
|
18
32
|
function colorizeState(state, width) {
|
|
@@ -26,26 +40,30 @@ function colorizeState(state, width) {
|
|
|
26
40
|
return chalk_1.default.gray(padded);
|
|
27
41
|
}
|
|
28
42
|
function formatTable(webhooks, opts) {
|
|
29
|
-
const names = webhooks.map(w => w.workflow_name
|
|
43
|
+
const names = webhooks.map(w => w.name ?? w.workflow_name ?? w.slug ?? w.workflow_slug ?? '?');
|
|
44
|
+
const kinds = webhooks.map(w => w.kind ?? 'workflow');
|
|
30
45
|
const states = webhooks.map(webhookState);
|
|
31
46
|
const urls = webhooks.map(w => w.webhook_path_url || w.webhook_url || '?');
|
|
32
47
|
const nameWidth = columnWidth(30, names);
|
|
48
|
+
const kindWidth = columnWidth(8, kinds);
|
|
33
49
|
const stateWidth = columnWidth(22, states);
|
|
34
50
|
const urlWidth = columnWidth(60, urls);
|
|
35
51
|
const headerPlain = opts.showSecrets
|
|
36
|
-
? '
|
|
37
|
-
: '
|
|
52
|
+
? 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
|
|
53
|
+
: 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
|
|
38
54
|
const dividerWidth = opts.showSecrets
|
|
39
|
-
? nameWidth + stateWidth + urlWidth + 64
|
|
40
|
-
: nameWidth + stateWidth + urlWidth;
|
|
55
|
+
? nameWidth + kindWidth + stateWidth + urlWidth + 64
|
|
56
|
+
: nameWidth + kindWidth + stateWidth + urlWidth;
|
|
41
57
|
const lines = [];
|
|
42
58
|
lines.push(chalk_1.default.gray(headerPlain));
|
|
43
59
|
lines.push(chalk_1.default.gray('-'.repeat(dividerWidth)));
|
|
44
60
|
for (let i = 0; i < webhooks.length; i++) {
|
|
45
61
|
const name = names[i];
|
|
62
|
+
const kind = kinds[i];
|
|
46
63
|
const state = states[i];
|
|
47
64
|
const url = urls[i];
|
|
48
65
|
let line = name.padEnd(nameWidth)
|
|
66
|
+
+ kind.padEnd(kindWidth)
|
|
49
67
|
+ colorizeState(state, stateWidth)
|
|
50
68
|
+ chalk_1.default.cyan(url.padEnd(urlWidth));
|
|
51
69
|
if (opts.showSecrets) {
|
|
@@ -58,7 +76,11 @@ function formatTable(webhooks, opts) {
|
|
|
58
76
|
}
|
|
59
77
|
function formatJson(webhooks, opts) {
|
|
60
78
|
const rows = webhooks.map(w => {
|
|
79
|
+
const kind = w.kind ?? 'workflow';
|
|
61
80
|
const base = {
|
|
81
|
+
kind,
|
|
82
|
+
name: w.name ?? w.workflow_name ?? null,
|
|
83
|
+
slug: w.slug ?? w.workflow_slug ?? null,
|
|
62
84
|
workflow: w.workflow_name ?? w.workflow_slug ?? null,
|
|
63
85
|
url: w.webhook_path_url ?? w.webhook_url ?? null,
|
|
64
86
|
state: webhookState(w),
|
|
@@ -67,6 +89,9 @@ function formatJson(webhooks, opts) {
|
|
|
67
89
|
retired: w.retired,
|
|
68
90
|
effective_enabled: w.effective_enabled,
|
|
69
91
|
};
|
|
92
|
+
if (kind === 'function') {
|
|
93
|
+
base.status = w.status ?? null;
|
|
94
|
+
}
|
|
70
95
|
if (opts.showSecrets) {
|
|
71
96
|
base.secret = w.webhook_secret ?? '';
|
|
72
97
|
}
|