@solidactions/cli 3.20.1 → 3.22.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/README.md +12 -6
- package/dist/command-manifest.json +18 -7
- package/dist/commands/connection-list.js +2 -2
- package/dist/commands/crew-env-delete.js +2 -2
- package/dist/commands/crew-env-list.js +2 -2
- package/dist/commands/crew-env-push.js +5 -2
- package/dist/commands/crew-env-set.js +2 -2
- package/dist/commands/database-push.js +1 -1
- package/dist/commands/deploy.js +41 -12
- package/dist/commands/dev.js +4 -4
- package/dist/commands/doc-pull.js +531 -73
- package/dist/commands/doc-push.js +291 -28
- package/dist/commands/doc-upload.js +5 -2
- package/dist/commands/env-delete.js +12 -5
- package/dist/commands/env-list.js +19 -14
- package/dist/commands/env-map.js +7 -5
- package/dist/commands/env-pull.js +5 -6
- package/dist/commands/env-push.js +10 -6
- package/dist/commands/env-reset.js +12 -8
- package/dist/commands/env-set.js +15 -11
- package/dist/commands/init.js +4 -1
- package/dist/commands/login.js +15 -18
- package/dist/commands/oauth-action-list.js +2 -2
- package/dist/commands/oauth-action-platforms.js +2 -2
- package/dist/commands/oauth-action-search.js +2 -2
- package/dist/commands/oauth-action-view.js +2 -2
- package/dist/commands/project-create.js +1 -1
- package/dist/commands/project-list.js +2 -2
- package/dist/commands/project-logs.js +7 -3
- package/dist/commands/project-view.js +26 -9
- package/dist/commands/pull.js +4 -2
- package/dist/commands/run-list.js +27 -22
- package/dist/commands/run-start.js +22 -18
- package/dist/commands/run-view.js +10 -22
- package/dist/commands/schedule-delete.js +5 -10
- package/dist/commands/schedule-list.js +5 -10
- package/dist/commands/schedule-set.js +39 -44
- package/dist/commands/schedule-state.js +12 -16
- package/dist/commands/state.js +3 -3
- package/dist/commands/webhook-list.js +12 -4
- package/dist/commands/webhook-secret.js +12 -4
- package/dist/commands/workflow-view.js +3 -3
- package/dist/commands/workspaces.js +58 -3
- package/dist/index.js +13 -7
- package/dist/utils/api.js +69 -4
- package/dist/utils/config.js +96 -3
- package/dist/utils/crew.js +6 -1
- package/dist/utils/mcp.js +7 -3
- package/dist/utils/project-ref.js +91 -0
- package/dist/utils/run-status.js +61 -0
- package/dist/utils/secure-write.js +40 -5
- package/dist/utils/workspace-lookup.js +30 -3
- package/package.json +2 -2
|
@@ -7,12 +7,11 @@ exports.run = run;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const api_1 = require("../utils/api");
|
|
10
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
|
+
const run_status_1 = require("../utils/run-status");
|
|
10
12
|
async function run(projectName, workflowName, options) {
|
|
11
13
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
12
14
|
const environment = options.env || 'dev';
|
|
13
|
-
const projectSlug = environment === 'production'
|
|
14
|
-
? projectName
|
|
15
|
-
: `${projectName}-${environment}`;
|
|
16
15
|
console.log(chalk_1.default.blue(`Running workflow "${workflowName}" in project "${projectName}" (${environment})...`));
|
|
17
16
|
let inputData = {};
|
|
18
17
|
if (options.input) {
|
|
@@ -25,6 +24,7 @@ async function run(projectName, workflowName, options) {
|
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
try {
|
|
27
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
28
28
|
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/workflows/${workflowName}/trigger`, { input: inputData }, {
|
|
29
29
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
30
30
|
});
|
|
@@ -40,16 +40,16 @@ async function run(projectName, workflowName, options) {
|
|
|
40
40
|
const statusResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runData.id}`, {
|
|
41
41
|
headers: (0, api_1.getApiHeaders)(config),
|
|
42
42
|
});
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
43
|
+
const outcome = (0, run_status_1.describeTerminalRun)(statusResponse.data ?? {});
|
|
44
|
+
if (outcome) {
|
|
45
45
|
clearInterval(poll);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
process.exit(
|
|
46
|
+
if (outcome.exitCode === 0) {
|
|
47
|
+
console.log(chalk_1.default.green(`\n${outcome.message}`));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error(chalk_1.default.red(`\n${outcome.message}`));
|
|
51
|
+
}
|
|
52
|
+
process.exit(outcome.exitCode);
|
|
53
53
|
}
|
|
54
54
|
else if (attempts >= maxAttempts) {
|
|
55
55
|
clearInterval(poll);
|
|
@@ -69,22 +69,26 @@ async function run(projectName, workflowName, options) {
|
|
|
69
69
|
catch (error) {
|
|
70
70
|
if (error.response) {
|
|
71
71
|
if (error.response.status === 401) {
|
|
72
|
-
console.error(chalk_1.default.red(
|
|
72
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
73
73
|
}
|
|
74
74
|
else if (error.response.status === 404) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// Claim the environment is missing only when the family
|
|
76
|
+
// genuinely lacks it (project view's pattern): otherwise the
|
|
77
|
+
// 404 names a missing workflow, not a missing environment.
|
|
78
|
+
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
|
|
79
|
+
const envs = family?.environments ?? [];
|
|
80
|
+
if (envs.length > 0 && !envs.includes(environment)) {
|
|
81
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
|
|
78
82
|
}
|
|
79
83
|
else {
|
|
80
|
-
console.error(chalk_1.default.red(
|
|
84
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
else if (error.response.status === 422) {
|
|
84
88
|
console.error(chalk_1.default.red('Validation error:'), error.response.data.message);
|
|
85
89
|
}
|
|
86
90
|
else {
|
|
87
|
-
console.error(chalk_1.default.red(
|
|
91
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
else {
|
|
@@ -11,6 +11,7 @@ exports.errorMessage = errorMessage;
|
|
|
11
11
|
const axios_1 = __importDefault(require("axios"));
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
13
|
const api_1 = require("../utils/api");
|
|
14
|
+
const run_status_1 = require("../utils/run-status");
|
|
14
15
|
const source_provenance_1 = require("../utils/source-provenance");
|
|
15
16
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
16
17
|
async function runView(runId, options) {
|
|
@@ -118,13 +119,13 @@ async function runView(runId, options) {
|
|
|
118
119
|
catch (error) {
|
|
119
120
|
if (error.response) {
|
|
120
121
|
if (error.response.status === 401) {
|
|
121
|
-
console.error(chalk_1.default.red(
|
|
122
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
122
123
|
}
|
|
123
124
|
else if (error.response.status === 404) {
|
|
124
125
|
console.error(chalk_1.default.red('Run not found.'));
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
|
-
console.error(chalk_1.default.red(
|
|
128
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
else {
|
|
@@ -137,13 +138,17 @@ async function runView(runId, options) {
|
|
|
137
138
|
function displayFullView(runData, timeline, steps, logsData) {
|
|
138
139
|
const status = runData.execution_status || runData.status;
|
|
139
140
|
const exitCode = runData.exit_code;
|
|
140
|
-
const statusColor = getStatusColor(status);
|
|
141
|
+
const statusColor = (0, run_status_1.getStatusColor)(status);
|
|
141
142
|
console.log('');
|
|
142
143
|
console.log(chalk_1.default.bold(`Run #${runData.id}`) + chalk_1.default.gray(` — ${runData.workflow_name} (${runData.project_name})`));
|
|
143
144
|
console.log('');
|
|
144
145
|
// Status line
|
|
145
146
|
const exitStr = exitCode !== null && exitCode !== undefined ? ` (exit ${exitCode})` : '';
|
|
146
|
-
console.log(` Status: ${statusColor(status)}${chalk_1.default.gray(exitStr)}`);
|
|
147
|
+
console.log(` Status: ${statusColor((0, run_status_1.formatRunStatusLabel)(status))}${chalk_1.default.gray(exitStr)}`);
|
|
148
|
+
const admission = (0, run_status_1.describeAdmissionDenied)(runData.admission_denied_reason);
|
|
149
|
+
if (admission) {
|
|
150
|
+
console.log(` Admission: ${chalk_1.default.red(admission)}`);
|
|
151
|
+
}
|
|
147
152
|
console.log(` Trigger: ${chalk_1.default.gray(runData.triggered_by || '-')}`);
|
|
148
153
|
if (Object.prototype.hasOwnProperty.call(runData, 'deployed_revision')) {
|
|
149
154
|
console.log(` Revision (latest session): ${chalk_1.default.gray((0, source_provenance_1.formatDetailedRevision)(runData.deployed_revision))}`);
|
|
@@ -224,7 +229,7 @@ function displayStepsTable(steps, indent = ' ') {
|
|
|
224
229
|
for (const step of steps) {
|
|
225
230
|
const name = (step.name || '?').padEnd(24);
|
|
226
231
|
const status = stepDisplayStatus(step);
|
|
227
|
-
const statusColor = getStatusColor(status);
|
|
232
|
+
const statusColor = (0, run_status_1.getStatusColor)(status);
|
|
228
233
|
const duration = formatDuration(step.durationMs);
|
|
229
234
|
// A failed step's error is more useful than its (null) output — show it, red.
|
|
230
235
|
const output = step.error
|
|
@@ -314,20 +319,3 @@ function truncate(str, max) {
|
|
|
314
319
|
return str;
|
|
315
320
|
return str.substring(0, max - 3) + '...';
|
|
316
321
|
}
|
|
317
|
-
function getStatusColor(status) {
|
|
318
|
-
switch (status?.toLowerCase()) {
|
|
319
|
-
case 'completed':
|
|
320
|
-
case 'success':
|
|
321
|
-
return chalk_1.default.green;
|
|
322
|
-
case 'running':
|
|
323
|
-
return chalk_1.default.blue;
|
|
324
|
-
case 'pending':
|
|
325
|
-
case 'queued':
|
|
326
|
-
return chalk_1.default.yellow;
|
|
327
|
-
case 'failed':
|
|
328
|
-
case 'error':
|
|
329
|
-
return chalk_1.default.red;
|
|
330
|
-
default:
|
|
331
|
-
return chalk_1.default.gray;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
@@ -8,20 +8,15 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const prompts_1 = __importDefault(require("prompts"));
|
|
10
10
|
const api_1 = require("../utils/api");
|
|
11
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const project_view_1 = require("./project-view");
|
|
12
13
|
async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
13
14
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
console.error(chalk_1.default.red(error.message));
|
|
20
|
-
process.exit(1);
|
|
15
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
21
16
|
return;
|
|
22
|
-
}
|
|
23
17
|
console.log(chalk_1.default.blue(`Deleting schedule ${scheduleId} from project "${projectName}"...`));
|
|
24
18
|
try {
|
|
19
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
25
20
|
// First, get the schedule details for confirmation
|
|
26
21
|
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
27
22
|
headers: (0, api_1.getApiHeaders)(config),
|
|
@@ -56,13 +51,13 @@ async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
|
56
51
|
catch (error) {
|
|
57
52
|
if (error.response) {
|
|
58
53
|
if (error.response.status === 401) {
|
|
59
|
-
console.error(chalk_1.default.red(
|
|
54
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
60
55
|
}
|
|
61
56
|
else if (error.response.status === 404) {
|
|
62
57
|
console.error(chalk_1.default.red(`Project "${projectName}" or schedule ${scheduleId} not found.`));
|
|
63
58
|
}
|
|
64
59
|
else {
|
|
65
|
-
console.error(chalk_1.default.red(
|
|
60
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
66
61
|
}
|
|
67
62
|
}
|
|
68
63
|
else {
|
|
@@ -8,6 +8,7 @@ exports.scheduleList = scheduleList;
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const api_1 = require("../utils/api");
|
|
11
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const project_view_1 = require("./project-view");
|
|
12
13
|
function formatScheduleState(schedule) {
|
|
13
14
|
const effective = schedule.enabled ? 'yes' : 'no';
|
|
@@ -23,17 +24,11 @@ function formatScheduleState(schedule) {
|
|
|
23
24
|
}
|
|
24
25
|
async function scheduleList(projectName, options = {}) {
|
|
25
26
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.error(chalk_1.default.red(error.message));
|
|
32
|
-
process.exit(1);
|
|
27
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
33
28
|
return;
|
|
34
|
-
}
|
|
35
29
|
console.log(chalk_1.default.blue(`Schedules for project "${projectName}":`));
|
|
36
30
|
try {
|
|
31
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
37
32
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
38
33
|
headers: (0, api_1.getApiHeaders)(config),
|
|
39
34
|
});
|
|
@@ -67,13 +62,13 @@ async function scheduleList(projectName, options = {}) {
|
|
|
67
62
|
catch (error) {
|
|
68
63
|
if (error.response) {
|
|
69
64
|
if (error.response.status === 401) {
|
|
70
|
-
console.error(chalk_1.default.red(
|
|
65
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
71
66
|
}
|
|
72
67
|
else if (error.response.status === 404) {
|
|
73
68
|
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
74
69
|
}
|
|
75
70
|
else {
|
|
76
|
-
console.error(chalk_1.default.red(
|
|
71
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
77
72
|
}
|
|
78
73
|
}
|
|
79
74
|
else {
|
|
@@ -12,6 +12,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
13
|
const prompts_1 = __importDefault(require("prompts"));
|
|
14
14
|
const api_1 = require("../utils/api");
|
|
15
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
15
16
|
const project_view_1 = require("./project-view");
|
|
16
17
|
function buildSchedulePayload(cron, options, inputData) {
|
|
17
18
|
const payload = { cron };
|
|
@@ -46,15 +47,8 @@ exports.EXISTING_SCHEDULE_CHOICES = [
|
|
|
46
47
|
];
|
|
47
48
|
async function scheduleSet(projectName, cron, options) {
|
|
48
49
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error(chalk_1.default.red(error.message));
|
|
55
|
-
process.exit(1);
|
|
50
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
56
51
|
return;
|
|
57
|
-
}
|
|
58
52
|
// Parse input JSON if provided
|
|
59
53
|
let inputData;
|
|
60
54
|
if (options.input) {
|
|
@@ -66,43 +60,44 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
66
60
|
process.exit(1);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log(chalk_1.default.yellow(`"${workflowName}" already has a schedule: ${existing.cron_expression}`));
|
|
85
|
-
const confirm = await (0, prompts_1.default)({
|
|
86
|
-
type: 'select',
|
|
87
|
-
name: 'action',
|
|
88
|
-
message: 'What would you like to do?',
|
|
89
|
-
choices: exports.EXISTING_SCHEDULE_CHOICES,
|
|
63
|
+
console.log(chalk_1.default.blue(`Setting schedule for project "${projectName}"...`));
|
|
64
|
+
try {
|
|
65
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
66
|
+
// Check for existing schedule on the same workflow
|
|
67
|
+
if (!options.yes) {
|
|
68
|
+
try {
|
|
69
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
70
|
+
headers: (0, api_1.getApiHeaders)(config),
|
|
71
|
+
});
|
|
72
|
+
const schedules = listResponse.data.data || listResponse.data || [];
|
|
73
|
+
const existing = schedules.find((s) => {
|
|
74
|
+
if (options.workflow) {
|
|
75
|
+
return s.workflow_name === options.workflow || s.workflow_slug === options.workflow;
|
|
76
|
+
}
|
|
77
|
+
return true; // No workflow specified — any existing schedule is a match
|
|
90
78
|
});
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
if (existing) {
|
|
80
|
+
const workflowName = existing.workflow_name || existing.workflow_slug || 'unknown';
|
|
81
|
+
console.log(chalk_1.default.yellow(`"${workflowName}" already has a schedule: ${existing.cron_expression}`));
|
|
82
|
+
const confirm = await (0, prompts_1.default)({
|
|
83
|
+
type: 'select',
|
|
84
|
+
name: 'action',
|
|
85
|
+
message: 'What would you like to do?',
|
|
86
|
+
choices: exports.EXISTING_SCHEDULE_CHOICES,
|
|
87
|
+
});
|
|
88
|
+
if (confirm.action === 'cancel' || confirm.action === undefined) {
|
|
89
|
+
console.log(chalk_1.default.gray('Cancelled.'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// The API owns the one-schedule-per-workflow invariant and
|
|
93
|
+
// updates the existing row. Do not delete first: deletion
|
|
94
|
+
// loses YAML provenance and any persistent override state.
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// If we can't check, proceed anyway
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
catch {
|
|
101
|
-
// If we can't check, proceed anyway
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
console.log(chalk_1.default.blue(`Setting schedule for project "${projectName}"...`));
|
|
105
|
-
try {
|
|
106
101
|
const payload = buildSchedulePayload(cron, options, inputData);
|
|
107
102
|
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/schedules`, payload, {
|
|
108
103
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
@@ -135,16 +130,16 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
135
130
|
catch (error) {
|
|
136
131
|
if (error.response) {
|
|
137
132
|
if (error.response.status === 401) {
|
|
138
|
-
console.error(chalk_1.default.red(
|
|
133
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
139
134
|
}
|
|
140
135
|
else if (error.response.status === 404) {
|
|
141
136
|
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
142
137
|
}
|
|
143
138
|
else if (error.response.status === 422) {
|
|
144
|
-
console.error(chalk_1.default.red('Validation error:'),
|
|
139
|
+
console.error(chalk_1.default.red('Validation error:'), (0, api_1.formatValidationError)(error.response.data));
|
|
145
140
|
}
|
|
146
141
|
else {
|
|
147
|
-
console.error(chalk_1.default.red(
|
|
142
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
145
|
else {
|
|
@@ -9,11 +9,12 @@ exports.scheduleReset = scheduleReset;
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const api_1 = require("../utils/api");
|
|
12
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
12
13
|
const project_view_1 = require("./project-view");
|
|
13
|
-
function renderScheduleStateError(error, projectName, scheduleId) {
|
|
14
|
+
function renderScheduleStateError(error, projectName, scheduleId, host) {
|
|
14
15
|
if (error.response) {
|
|
15
16
|
if (error.response.status === 401) {
|
|
16
|
-
console.error(chalk_1.default.red(
|
|
17
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(host)));
|
|
17
18
|
}
|
|
18
19
|
else if (error.response.status === 404) {
|
|
19
20
|
console.error(chalk_1.default.red(error.response.data?.message ?? `Project "${projectName}" or schedule ${scheduleId} not found.`));
|
|
@@ -22,7 +23,7 @@ function renderScheduleStateError(error, projectName, scheduleId) {
|
|
|
22
23
|
console.error(chalk_1.default.red(error.response.data?.message ?? 'Validation error.'));
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
|
-
console.error(chalk_1.default.red(
|
|
26
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
@@ -30,26 +31,19 @@ function renderScheduleStateError(error, projectName, scheduleId) {
|
|
|
30
31
|
}
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
|
-
function resolveProjectSlug(projectName, options) {
|
|
34
|
-
try {
|
|
35
|
-
return (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error(chalk_1.default.red(error.message));
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
34
|
async function setScheduleTarget(projectName, scheduleId, target, options = {}) {
|
|
43
35
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
44
|
-
const projectSlug = resolveProjectSlug(projectName, options);
|
|
45
36
|
const enabled = target === 'enable';
|
|
37
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
38
|
+
return;
|
|
46
39
|
try {
|
|
40
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
47
41
|
await axios_1.default.patch(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/schedules/${encodeURIComponent(scheduleId)}`, { enabled }, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
48
42
|
console.log(chalk_1.default.green(`Schedule ${scheduleId} ${enabled ? 'enabled' : 'disabled'}.`));
|
|
49
43
|
console.log(chalk_1.default.gray('This is a sticky override and survives redeploy until changed or reset.'));
|
|
50
44
|
}
|
|
51
45
|
catch (error) {
|
|
52
|
-
renderScheduleStateError(error, projectName, scheduleId);
|
|
46
|
+
renderScheduleStateError(error, projectName, scheduleId, config.host);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
49
|
async function scheduleEnable(projectName, scheduleId, options = {}) {
|
|
@@ -60,12 +54,14 @@ async function scheduleDisable(projectName, scheduleId, options = {}) {
|
|
|
60
54
|
}
|
|
61
55
|
async function scheduleReset(projectName, scheduleId, options = {}) {
|
|
62
56
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
63
|
-
|
|
57
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
58
|
+
return;
|
|
64
59
|
try {
|
|
60
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
65
61
|
await axios_1.default.post(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/schedules/${encodeURIComponent(scheduleId)}/reset`, {}, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
66
62
|
console.log(chalk_1.default.green(`Schedule ${scheduleId} reset. YAML controls this schedule again.`));
|
|
67
63
|
}
|
|
68
64
|
catch (error) {
|
|
69
|
-
renderScheduleStateError(error, projectName, scheduleId);
|
|
65
|
+
renderScheduleStateError(error, projectName, scheduleId, config.host);
|
|
70
66
|
}
|
|
71
67
|
}
|
package/dist/commands/state.js
CHANGED
|
@@ -73,12 +73,12 @@ function printInverseCommand(target, environment, enabled) {
|
|
|
73
73
|
: `solidactions project ${verb} ${target.project} --env ${environment}`;
|
|
74
74
|
console.log(chalk_1.default.gray(`Undo: ${command}`));
|
|
75
75
|
}
|
|
76
|
-
function errorMessage(error, target) {
|
|
76
|
+
function errorMessage(error, target, host) {
|
|
77
77
|
if (!error.response) {
|
|
78
78
|
return `Connection failed: ${error.message}`;
|
|
79
79
|
}
|
|
80
80
|
if (error.response.status === 401) {
|
|
81
|
-
return
|
|
81
|
+
return (0, api_1.authFailedLine)(host);
|
|
82
82
|
}
|
|
83
83
|
if (error.response.status === 422) {
|
|
84
84
|
return (0, api_1.formatValidationError)(error.response.data);
|
|
@@ -117,7 +117,7 @@ async function setStateWithConfig(target, enabled, options, config) {
|
|
|
117
117
|
printInverseCommand(target, environment, enabled);
|
|
118
118
|
}
|
|
119
119
|
catch (error) {
|
|
120
|
-
console.error(chalk_1.default.red(errorMessage(error, target)));
|
|
120
|
+
console.error(chalk_1.default.red(errorMessage(error, target, config.host)));
|
|
121
121
|
process.exit(1);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -7,6 +7,7 @@ exports.webhookList = webhookList;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const api_1 = require("../utils/api");
|
|
10
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
10
11
|
const webhook_formatters_1 = require("../utils/webhook-formatters");
|
|
11
12
|
async function webhookList(projectName, options = {}) {
|
|
12
13
|
const format = options.format ?? 'table';
|
|
@@ -16,11 +17,11 @@ async function webhookList(projectName, options = {}) {
|
|
|
16
17
|
}
|
|
17
18
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
18
19
|
const environment = options.env || 'dev';
|
|
19
|
-
const projectSlug = environment === 'production' ? projectName : `${projectName}-${environment}`;
|
|
20
20
|
if (format === 'table') {
|
|
21
21
|
console.log(chalk_1.default.blue(`Webhooks for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}:`));
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
24
25
|
const params = {};
|
|
25
26
|
if (options.showSecrets) {
|
|
26
27
|
params.show_secrets = 'true';
|
|
@@ -50,13 +51,20 @@ async function webhookList(projectName, options = {}) {
|
|
|
50
51
|
catch (error) {
|
|
51
52
|
if (error.response) {
|
|
52
53
|
if (error.response.status === 401) {
|
|
53
|
-
console.error(chalk_1.default.red(
|
|
54
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
54
55
|
}
|
|
55
56
|
else if (error.response.status === 404) {
|
|
56
|
-
|
|
57
|
+
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
|
|
58
|
+
const envs = family?.environments ?? [];
|
|
59
|
+
if (envs.length > 0 && !envs.includes(environment)) {
|
|
60
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
else {
|
|
59
|
-
console.error(chalk_1.default.red(
|
|
67
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
else {
|
|
@@ -8,6 +8,7 @@ exports.webhookSecret = webhookSecret;
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const api_1 = require("../utils/api");
|
|
11
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
function formatSecretOutput(rows, workflowFilter) {
|
|
12
13
|
if (workflowFilter) {
|
|
13
14
|
const match = rows.find((r) => r.workflow_name === workflowFilter);
|
|
@@ -29,11 +30,11 @@ async function webhookSecret(projectName, options = {}) {
|
|
|
29
30
|
}
|
|
30
31
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
31
32
|
const environment = options.env || 'dev';
|
|
32
|
-
const projectSlug = environment === 'production' ? projectName : `${projectName}-${environment}`;
|
|
33
33
|
if (format === 'text') {
|
|
34
34
|
process.stderr.write(chalk_1.default.dim(`(environment: ${environment} — pass -e <env> to change)\n`));
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
37
38
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
|
|
38
39
|
headers: (0, api_1.getApiHeaders)(config),
|
|
39
40
|
params: { show_secrets: 'true' },
|
|
@@ -57,13 +58,20 @@ async function webhookSecret(projectName, options = {}) {
|
|
|
57
58
|
catch (error) {
|
|
58
59
|
if (error.response) {
|
|
59
60
|
if (error.response.status === 401) {
|
|
60
|
-
console.error(chalk_1.default.red(
|
|
61
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
61
62
|
}
|
|
62
63
|
else if (error.response.status === 404) {
|
|
63
|
-
|
|
64
|
+
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
|
|
65
|
+
const envs = family?.environments ?? [];
|
|
66
|
+
if (envs.length > 0 && !envs.includes(environment)) {
|
|
67
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
73
|
else {
|
|
66
|
-
console.error(chalk_1.default.red(
|
|
74
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
else {
|
|
@@ -57,13 +57,13 @@ function printAmbiguity(error) {
|
|
|
57
57
|
}
|
|
58
58
|
console.error('Re-run with an exact slug.');
|
|
59
59
|
}
|
|
60
|
-
function printWorkflowViewError(error) {
|
|
60
|
+
function printWorkflowViewError(error, host) {
|
|
61
61
|
if (!error.response) {
|
|
62
62
|
console.error(chalk_1.default.red('Connection failed:'), display(error.message, 'Unknown network error.', 500));
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (error.response.status === 401) {
|
|
66
|
-
console.error(chalk_1.default.red(
|
|
66
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(host)));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
// The GET workflow endpoint uses the v1 {code, message} convention;
|
|
@@ -102,7 +102,7 @@ async function workflowViewWithConfig(project, workflow, options, config) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
|
-
printWorkflowViewError(error);
|
|
105
|
+
printWorkflowViewError(error, config.host);
|
|
106
106
|
process.exit(1);
|
|
107
107
|
}
|
|
108
108
|
}
|