@solidactions/cli 0.1.0 → 0.2.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.
- package/dist/commands/init.js +1 -1
- package/dist/commands/webhooks.js +75 -0
- package/dist/index.js +13 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -52,7 +52,7 @@ async function init(apiKey, options) {
|
|
|
52
52
|
host = 'http://localhost:8000';
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
host = 'https://solidactions.
|
|
55
|
+
host = 'https://app.solidactions.com';
|
|
56
56
|
}
|
|
57
57
|
// Validate API key format (should be a Sanctum token)
|
|
58
58
|
if (!apiKey || apiKey.trim().length === 0) {
|
|
@@ -0,0 +1,75 @@
|
|
|
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.webhookList = webhookList;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const init_1 = require("./init");
|
|
10
|
+
async function webhookList(projectName, options = {}) {
|
|
11
|
+
const config = (0, init_1.getConfig)();
|
|
12
|
+
if (!config?.apiKey) {
|
|
13
|
+
console.error(chalk_1.default.red('Not initialized. Run "solidactions init <api-key>" first.'));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const environment = options.env || 'production';
|
|
17
|
+
const projectSlug = environment === 'production' ? projectName : `${projectName}-${environment}`;
|
|
18
|
+
console.log(chalk_1.default.blue(`Webhooks for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}:`));
|
|
19
|
+
try {
|
|
20
|
+
const params = {};
|
|
21
|
+
if (options.showSecrets) {
|
|
22
|
+
params.show_secrets = 'true';
|
|
23
|
+
}
|
|
24
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
|
|
25
|
+
headers: {
|
|
26
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
27
|
+
'Accept': 'application/json',
|
|
28
|
+
},
|
|
29
|
+
params,
|
|
30
|
+
});
|
|
31
|
+
const webhooks = response.data || [];
|
|
32
|
+
if (webhooks.length === 0) {
|
|
33
|
+
console.log(chalk_1.default.yellow('No webhooks found for project "' + projectName + '".'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.log('');
|
|
37
|
+
if (options.showSecrets) {
|
|
38
|
+
console.log(chalk_1.default.gray('WORKFLOW'.padEnd(30) + 'URL'.padEnd(60) + 'SECRET'));
|
|
39
|
+
console.log(chalk_1.default.gray('-'.repeat(120)));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(chalk_1.default.gray('WORKFLOW'.padEnd(30) + 'URL'));
|
|
43
|
+
console.log(chalk_1.default.gray('-'.repeat(90)));
|
|
44
|
+
}
|
|
45
|
+
for (const webhook of webhooks) {
|
|
46
|
+
const name = webhook.name || webhook.slug || '?';
|
|
47
|
+
const url = webhook.url || '?';
|
|
48
|
+
let line = name.padEnd(30) + chalk_1.default.cyan(url.padEnd(60));
|
|
49
|
+
if (options.showSecrets) {
|
|
50
|
+
const secret = webhook.secret || '-';
|
|
51
|
+
line += chalk_1.default.gray(secret);
|
|
52
|
+
}
|
|
53
|
+
console.log(line);
|
|
54
|
+
}
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log(chalk_1.default.gray(`${webhooks.length} webhook(s)`));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.response) {
|
|
60
|
+
if (error.response.status === 401) {
|
|
61
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions init <api-key>" to re-configure.'));
|
|
62
|
+
}
|
|
63
|
+
else if (error.response.status === 404) {
|
|
64
|
+
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
72
|
+
}
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const env_pull_1 = require("./commands/env-pull");
|
|
|
17
17
|
const schedule_set_1 = require("./commands/schedule-set");
|
|
18
18
|
const schedule_list_1 = require("./commands/schedule-list");
|
|
19
19
|
const schedule_delete_1 = require("./commands/schedule-delete");
|
|
20
|
+
const webhooks_1 = require("./commands/webhooks");
|
|
20
21
|
const program = new commander_1.Command();
|
|
21
22
|
program
|
|
22
23
|
.name('solidactions')
|
|
@@ -188,4 +189,16 @@ program
|
|
|
188
189
|
.action((project, scheduleId, options) => {
|
|
189
190
|
(0, schedule_delete_1.scheduleDelete)(project, scheduleId, options);
|
|
190
191
|
});
|
|
192
|
+
// =============================================================================
|
|
193
|
+
// Webhooks
|
|
194
|
+
// =============================================================================
|
|
195
|
+
program
|
|
196
|
+
.command('webhooks')
|
|
197
|
+
.description('List webhook URLs for a project')
|
|
198
|
+
.argument('<project>', 'Project name')
|
|
199
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev)')
|
|
200
|
+
.option('--show-secrets', 'Show webhook secrets')
|
|
201
|
+
.action((project, options) => {
|
|
202
|
+
(0, webhooks_1.webhookList)(project, options);
|
|
203
|
+
});
|
|
191
204
|
program.parse();
|