@solidactions/cli 3.3.0 → 3.4.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 +30 -6
- package/dist/command-manifest.json +446 -1
- package/dist/commands/deploy.js +13 -0
- package/dist/commands/login.js +4 -57
- package/dist/commands/project-list.js +27 -6
- package/dist/commands/project-view.js +3 -0
- package/dist/commands/schedule-delete.js +12 -2
- package/dist/commands/schedule-list.js +29 -5
- package/dist/commands/schedule-set.js +18 -2
- package/dist/commands/schedule-state.js +71 -0
- package/dist/commands/state.js +139 -0
- package/dist/index.js +74 -2
- package/dist/utils/api.js +6 -15
- package/dist/utils/source-provenance.js +3 -0
- package/dist/utils/webhook-formatters.js +36 -4
- package/dist/utils/workspace-lookup.js +56 -0
- package/package.json +1 -1
|
@@ -8,6 +8,18 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const api_1 = require("../utils/api");
|
|
10
10
|
const table_1 = require("../utils/table");
|
|
11
|
+
function projectEnvironments(project) {
|
|
12
|
+
const details = project.environment_details;
|
|
13
|
+
if (Array.isArray(details) && details.length > 0) {
|
|
14
|
+
return details
|
|
15
|
+
.map((detail) => `${detail.environment}:${detail.enabled ? 'on' : 'off'}`)
|
|
16
|
+
.join(', ');
|
|
17
|
+
}
|
|
18
|
+
return (project.environments || [project.environment || 'production']).join(', ');
|
|
19
|
+
}
|
|
20
|
+
function colorizeEnvironmentStates(value) {
|
|
21
|
+
return value.replace(/\b(on|off)\b/g, (state) => (state === 'on' ? chalk_1.default.green(state) : chalk_1.default.red(state)));
|
|
22
|
+
}
|
|
11
23
|
async function projectList(options = {}) {
|
|
12
24
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
13
25
|
try {
|
|
@@ -26,17 +38,26 @@ async function projectList(options = {}) {
|
|
|
26
38
|
console.log(chalk_1.default.gray('No projects found.'));
|
|
27
39
|
return;
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
// Reconstruction below colorizes only the final ENVIRONMENTS cell. Use
|
|
42
|
+
// the renderer's exact sanitized/truncated value so adding ANSI color
|
|
43
|
+
// can never reintroduce discarded content or corrupt prefix slicing.
|
|
44
|
+
const environmentCells = projects.map((project) => ((0, table_1.truncateCell)((0, table_1.sanitizeCell)(projectEnvironments(project)))));
|
|
45
|
+
const rows = projects.map((project, index) => [
|
|
46
|
+
project.name || '?',
|
|
47
|
+
project.status || '?',
|
|
48
|
+
project.snapshot_name || '-',
|
|
49
|
+
environmentCells[index],
|
|
50
|
+
]);
|
|
33
51
|
const lines = (0, table_1.renderTable)(['NAME', 'STATUS', 'SNAPSHOT', 'ENVIRONMENTS'], rows, {
|
|
34
52
|
minWidths: [25, 15, 30],
|
|
35
53
|
});
|
|
36
54
|
console.log(chalk_1.default.gray(lines[0]));
|
|
37
55
|
console.log(chalk_1.default.gray(lines[1]));
|
|
38
|
-
for (
|
|
39
|
-
|
|
56
|
+
for (let index = 0; index < projects.length; index++) {
|
|
57
|
+
const line = lines[index + 2];
|
|
58
|
+
const environmentCell = environmentCells[index];
|
|
59
|
+
const prefix = line.slice(0, line.length - environmentCell.length);
|
|
60
|
+
console.log(prefix + colorizeEnvironmentStates(environmentCell));
|
|
40
61
|
}
|
|
41
62
|
console.log('');
|
|
42
63
|
console.log(chalk_1.default.gray(`${projects.length} project(s)`));
|
|
@@ -82,6 +82,9 @@ function formatProjectView(project) {
|
|
|
82
82
|
const slug = (0, source_provenance_1.sanitizeDisplayText)(project.slug ?? project.name, 255) ?? 'unknown';
|
|
83
83
|
const status = (0, source_provenance_1.sanitizeDisplayText)(project.status, 64) ?? 'unknown';
|
|
84
84
|
const lines = [`Project: ${slug}`, `Status: ${status}`];
|
|
85
|
+
if (typeof project.enabled === 'boolean') {
|
|
86
|
+
lines.push(`Enabled: ${project.enabled ? 'on' : 'off'}`);
|
|
87
|
+
}
|
|
85
88
|
const deployment = project.latest_successful_deployment ?? null;
|
|
86
89
|
if (!project.deployed_hash && !deployment) {
|
|
87
90
|
lines.push('No deployment provenance recorded (deployed before tracking).');
|
|
@@ -8,12 +8,22 @@ 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_view_1 = require("./project-view");
|
|
11
12
|
async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
12
13
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
14
|
+
let projectSlug;
|
|
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);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
13
23
|
console.log(chalk_1.default.blue(`Deleting schedule ${scheduleId} from project "${projectName}"...`));
|
|
14
24
|
try {
|
|
15
25
|
// First, get the schedule details for confirmation
|
|
16
|
-
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${
|
|
26
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
17
27
|
headers: (0, api_1.getApiHeaders)(config),
|
|
18
28
|
});
|
|
19
29
|
const schedules = listResponse.data || [];
|
|
@@ -36,7 +46,7 @@ async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
// Delete the schedule
|
|
39
|
-
await axios_1.default.delete(`${config.host}/api/v1/projects/${
|
|
49
|
+
await axios_1.default.delete(`${config.host}/api/v1/projects/${projectSlug}/schedules/${scheduleId}`, {
|
|
40
50
|
headers: (0, api_1.getApiHeaders)(config),
|
|
41
51
|
});
|
|
42
52
|
console.log(chalk_1.default.green(`Schedule ${scheduleId} deleted successfully.`));
|
|
@@ -3,15 +3,38 @@ 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.formatScheduleState = formatScheduleState;
|
|
6
7
|
exports.scheduleList = scheduleList;
|
|
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_view_1 = require("./project-view");
|
|
12
|
+
function formatScheduleState(schedule) {
|
|
13
|
+
const effective = schedule.enabled ? 'yes' : 'no';
|
|
14
|
+
if (!schedule.enabled_override) {
|
|
15
|
+
return effective;
|
|
16
|
+
}
|
|
17
|
+
if (schedule.yaml_enabled !== null
|
|
18
|
+
&& schedule.yaml_enabled !== undefined
|
|
19
|
+
&& schedule.yaml_enabled !== schedule.enabled) {
|
|
20
|
+
return `${effective} (override; last declared YAML: ${schedule.yaml_enabled ? 'yes' : 'no'})`;
|
|
21
|
+
}
|
|
22
|
+
return `${effective} (override)`;
|
|
23
|
+
}
|
|
24
|
+
async function scheduleList(projectName, options = {}) {
|
|
11
25
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
26
|
+
let projectSlug;
|
|
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);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
12
35
|
console.log(chalk_1.default.blue(`Schedules for project "${projectName}":`));
|
|
13
36
|
try {
|
|
14
|
-
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${
|
|
37
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
15
38
|
headers: (0, api_1.getApiHeaders)(config),
|
|
16
39
|
});
|
|
17
40
|
const schedules = response.data || [];
|
|
@@ -20,21 +43,22 @@ async function scheduleList(projectName) {
|
|
|
20
43
|
return;
|
|
21
44
|
}
|
|
22
45
|
console.log('');
|
|
23
|
-
console.log(chalk_1.default.gray('ID'.padEnd(8) + 'WORKFLOW'.padEnd(25) + 'CRON'.padEnd(18) + 'TIMEZONE'.padEnd(20) + 'ENABLED'.padEnd(
|
|
24
|
-
console.log(chalk_1.default.gray('-'.repeat(
|
|
46
|
+
console.log(chalk_1.default.gray('ID'.padEnd(8) + 'WORKFLOW'.padEnd(25) + 'CRON'.padEnd(18) + 'TIMEZONE'.padEnd(20) + 'ENABLED'.padEnd(48) + 'NEXT RUN'));
|
|
47
|
+
console.log(chalk_1.default.gray('-'.repeat(143)));
|
|
25
48
|
for (const schedule of schedules) {
|
|
26
49
|
const id = schedule.id?.toString() || '?';
|
|
27
50
|
const workflow = schedule.workflow_name || schedule.workflow_slug || '?';
|
|
28
51
|
const cron = schedule.cron_expression || '?';
|
|
29
52
|
const timezone = schedule.timezone || 'UTC';
|
|
30
53
|
const enabled = schedule.enabled;
|
|
54
|
+
const enabledState = formatScheduleState(schedule);
|
|
31
55
|
const nextRun = schedule.next_run_at ? formatRelativeTime(schedule.next_run_at) : '-';
|
|
32
56
|
const enabledColor = enabled ? chalk_1.default.green : chalk_1.default.red;
|
|
33
57
|
console.log(chalk_1.default.gray(id.padEnd(8)) +
|
|
34
58
|
workflow.padEnd(25) +
|
|
35
59
|
chalk_1.default.cyan(cron.padEnd(18)) +
|
|
36
60
|
chalk_1.default.gray(timezone.padEnd(20)) +
|
|
37
|
-
enabledColor(
|
|
61
|
+
enabledColor(enabledState.padEnd(48)) +
|
|
38
62
|
chalk_1.default.gray(nextRun));
|
|
39
63
|
}
|
|
40
64
|
console.log('');
|
|
@@ -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_view_1 = require("./project-view");
|
|
15
16
|
function buildSchedulePayload(cron, options, inputData) {
|
|
16
17
|
const payload = { cron };
|
|
17
18
|
if (options.workflow) {
|
|
@@ -23,6 +24,9 @@ function buildSchedulePayload(cron, options, inputData) {
|
|
|
23
24
|
if (options.timezone) {
|
|
24
25
|
payload.timezone = options.timezone;
|
|
25
26
|
}
|
|
27
|
+
if (options.paused) {
|
|
28
|
+
payload.enabled = false;
|
|
29
|
+
}
|
|
26
30
|
return payload;
|
|
27
31
|
}
|
|
28
32
|
/** True when the user asked for a timezone the server did not apply (pre-item-5-App server). */
|
|
@@ -42,6 +46,15 @@ exports.EXISTING_SCHEDULE_CHOICES = [
|
|
|
42
46
|
];
|
|
43
47
|
async function scheduleSet(projectName, cron, options) {
|
|
44
48
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
49
|
+
let projectSlug;
|
|
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);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
45
58
|
// Parse input JSON if provided
|
|
46
59
|
let inputData;
|
|
47
60
|
if (options.input) {
|
|
@@ -56,7 +69,7 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
56
69
|
// Check for existing schedule on the same workflow
|
|
57
70
|
if (!options.yes) {
|
|
58
71
|
try {
|
|
59
|
-
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${
|
|
72
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
60
73
|
headers: (0, api_1.getApiHeaders)(config),
|
|
61
74
|
});
|
|
62
75
|
const schedules = listResponse.data.data || listResponse.data || [];
|
|
@@ -91,7 +104,7 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
91
104
|
console.log(chalk_1.default.blue(`Setting schedule for project "${projectName}"...`));
|
|
92
105
|
try {
|
|
93
106
|
const payload = buildSchedulePayload(cron, options, inputData);
|
|
94
|
-
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${
|
|
107
|
+
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/schedules`, payload, {
|
|
95
108
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
96
109
|
});
|
|
97
110
|
// Verify, don't trust: a server predating timezone support silently
|
|
@@ -115,6 +128,9 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
115
128
|
if (inputData) {
|
|
116
129
|
console.log(chalk_1.default.gray(` Input: ${JSON.stringify(inputData)}`));
|
|
117
130
|
}
|
|
131
|
+
if (options.paused) {
|
|
132
|
+
console.log(chalk_1.default.gray(' Enabled: no (sticky override; survives redeploy)'));
|
|
133
|
+
}
|
|
118
134
|
}
|
|
119
135
|
catch (error) {
|
|
120
136
|
if (error.response) {
|
|
@@ -0,0 +1,71 @@
|
|
|
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.scheduleEnable = scheduleEnable;
|
|
7
|
+
exports.scheduleDisable = scheduleDisable;
|
|
8
|
+
exports.scheduleReset = scheduleReset;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const api_1 = require("../utils/api");
|
|
12
|
+
const project_view_1 = require("./project-view");
|
|
13
|
+
function renderScheduleStateError(error, projectName, scheduleId) {
|
|
14
|
+
if (error.response) {
|
|
15
|
+
if (error.response.status === 401) {
|
|
16
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
|
|
17
|
+
}
|
|
18
|
+
else if (error.response.status === 404) {
|
|
19
|
+
console.error(chalk_1.default.red(error.response.data?.message ?? `Project "${projectName}" or schedule ${scheduleId} not found.`));
|
|
20
|
+
}
|
|
21
|
+
else if (error.response.status === 422) {
|
|
22
|
+
console.error(chalk_1.default.red(error.response.data?.message ?? 'Validation error.'));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data?.message ?? error.response.data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
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
|
+
async function setScheduleTarget(projectName, scheduleId, target, options = {}) {
|
|
43
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
44
|
+
const projectSlug = resolveProjectSlug(projectName, options);
|
|
45
|
+
const enabled = target === 'enable';
|
|
46
|
+
try {
|
|
47
|
+
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
|
+
console.log(chalk_1.default.green(`Schedule ${scheduleId} ${enabled ? 'enabled' : 'disabled'}.`));
|
|
49
|
+
console.log(chalk_1.default.gray('This is a sticky override and survives redeploy until changed or reset.'));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
renderScheduleStateError(error, projectName, scheduleId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function scheduleEnable(projectName, scheduleId, options = {}) {
|
|
56
|
+
await setScheduleTarget(projectName, scheduleId, 'enable', options);
|
|
57
|
+
}
|
|
58
|
+
async function scheduleDisable(projectName, scheduleId, options = {}) {
|
|
59
|
+
await setScheduleTarget(projectName, scheduleId, 'disable', options);
|
|
60
|
+
}
|
|
61
|
+
async function scheduleReset(projectName, scheduleId, options = {}) {
|
|
62
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
63
|
+
const projectSlug = resolveProjectSlug(projectName, options);
|
|
64
|
+
try {
|
|
65
|
+
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
|
+
console.log(chalk_1.default.green(`Schedule ${scheduleId} reset. YAML controls this schedule again.`));
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
renderScheduleStateError(error, projectName, scheduleId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
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.resolveStateEnvironment = resolveStateEnvironment;
|
|
7
|
+
exports.projectSlugForState = projectSlugForState;
|
|
8
|
+
exports.setStateWithConfig = setStateWithConfig;
|
|
9
|
+
exports.projectEnable = projectEnable;
|
|
10
|
+
exports.projectDisable = projectDisable;
|
|
11
|
+
exports.workflowEnable = workflowEnable;
|
|
12
|
+
exports.workflowDisable = workflowDisable;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
const api_1 = require("../utils/api");
|
|
16
|
+
const slug_1 = require("../utils/slug");
|
|
17
|
+
const STATE_ENVIRONMENTS = ['production', 'staging', 'dev'];
|
|
18
|
+
function resolveStateEnvironment(environment) {
|
|
19
|
+
const resolved = environment ?? 'dev';
|
|
20
|
+
if (!STATE_ENVIRONMENTS.includes(resolved)) {
|
|
21
|
+
throw new Error('Environment must be production, staging, or dev.');
|
|
22
|
+
}
|
|
23
|
+
return resolved;
|
|
24
|
+
}
|
|
25
|
+
function projectSlugForState(project, environment) {
|
|
26
|
+
const slug = (0, slug_1.buildProjectSlug)(project, environment);
|
|
27
|
+
if (!slug || slug === `-${environment}`) {
|
|
28
|
+
throw new Error('Project must contain at least one letter or number.');
|
|
29
|
+
}
|
|
30
|
+
return slug;
|
|
31
|
+
}
|
|
32
|
+
function stateUrl(config, target, environment) {
|
|
33
|
+
const projectSlug = encodeURIComponent(projectSlugForState(target.project, environment));
|
|
34
|
+
const base = `${config.host}/api/v1/projects/${projectSlug}`;
|
|
35
|
+
if (target.type === 'workflow') {
|
|
36
|
+
return `${base}/workflows/${encodeURIComponent(target.workflow)}/enabled`;
|
|
37
|
+
}
|
|
38
|
+
return `${base}/enabled`;
|
|
39
|
+
}
|
|
40
|
+
function inverseVerb(enabled) {
|
|
41
|
+
return enabled ? 'disable' : 'enable';
|
|
42
|
+
}
|
|
43
|
+
function printDisableResult(target, environment) {
|
|
44
|
+
if (target.type === 'workflow') {
|
|
45
|
+
console.log(chalk_1.default.green(`Workflow "${target.workflow}" in project "${target.project}" (${environment}) disabled.`));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(chalk_1.default.green(`Project "${target.project}" (${environment}) disabled.`));
|
|
49
|
+
}
|
|
50
|
+
console.log('New root starts are blocked through CLI/API, schedules, webhooks, MCP, manual dead-letter retry, and manual rerun paths.');
|
|
51
|
+
console.log('Already-created roots continue, including their queued work, automatic retries, child legs, sleeping/signal-waiting phases, and running work.');
|
|
52
|
+
console.log('Deploy will not undo this manual state.');
|
|
53
|
+
}
|
|
54
|
+
function printEnableResult(target, environment) {
|
|
55
|
+
if (target.type === 'workflow') {
|
|
56
|
+
console.log(chalk_1.default.green(`Workflow "${target.workflow}" in project "${target.project}" (${environment}) enabled.`));
|
|
57
|
+
console.log('Direct starts require an enabled parent project.');
|
|
58
|
+
console.log('Scheduled starts additionally require an enabled schedule.');
|
|
59
|
+
console.log('Enabling this workflow does not enable its project or schedule.');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.log(chalk_1.default.green(`Project "${target.project}" (${environment}) enabled.`));
|
|
63
|
+
console.log('Direct starts require an enabled target workflow.');
|
|
64
|
+
console.log('Scheduled starts additionally require an enabled schedule.');
|
|
65
|
+
console.log('Enabling this project does not enable its workflows or schedules.');
|
|
66
|
+
}
|
|
67
|
+
console.log('Deploy will not undo this manual state.');
|
|
68
|
+
}
|
|
69
|
+
function printInverseCommand(target, environment, enabled) {
|
|
70
|
+
const verb = inverseVerb(enabled);
|
|
71
|
+
const command = target.type === 'workflow'
|
|
72
|
+
? `solidactions workflow ${verb} ${target.project} ${target.workflow} --env ${environment}`
|
|
73
|
+
: `solidactions project ${verb} ${target.project} --env ${environment}`;
|
|
74
|
+
console.log(chalk_1.default.gray(`Undo: ${command}`));
|
|
75
|
+
}
|
|
76
|
+
function errorMessage(error, target) {
|
|
77
|
+
if (!error.response) {
|
|
78
|
+
return `Connection failed: ${error.message}`;
|
|
79
|
+
}
|
|
80
|
+
if (error.response.status === 401) {
|
|
81
|
+
return 'Authentication failed. Run "solidactions login --global" to re-configure.';
|
|
82
|
+
}
|
|
83
|
+
if (error.response.status === 422) {
|
|
84
|
+
return (0, api_1.formatValidationError)(error.response.data);
|
|
85
|
+
}
|
|
86
|
+
const serverMessage = error.response.data?.message;
|
|
87
|
+
if (typeof serverMessage === 'string' && serverMessage.trim() !== '') {
|
|
88
|
+
return serverMessage;
|
|
89
|
+
}
|
|
90
|
+
if (error.response.status === 404) {
|
|
91
|
+
return target.type === 'workflow'
|
|
92
|
+
? `Project or workflow "${target.workflow}" not found.`
|
|
93
|
+
: `Project "${target.project}" not found.`;
|
|
94
|
+
}
|
|
95
|
+
return `Failed to update state: ${error.response.status}`;
|
|
96
|
+
}
|
|
97
|
+
async function setStateWithConfig(target, enabled, options, config) {
|
|
98
|
+
let environment;
|
|
99
|
+
let url;
|
|
100
|
+
try {
|
|
101
|
+
environment = resolveStateEnvironment(options.env);
|
|
102
|
+
url = stateUrl(config, target, environment);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error(chalk_1.default.red(error.message));
|
|
106
|
+
process.exit(1);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
await axios_1.default.put(url, { enabled }, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
111
|
+
if (enabled) {
|
|
112
|
+
printEnableResult(target, environment);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
printDisableResult(target, environment);
|
|
116
|
+
}
|
|
117
|
+
printInverseCommand(target, environment, enabled);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error(chalk_1.default.red(errorMessage(error, target)));
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function setState(target, enabled, options) {
|
|
125
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
126
|
+
await setStateWithConfig(target, enabled, options, config);
|
|
127
|
+
}
|
|
128
|
+
async function projectEnable(project, options = {}) {
|
|
129
|
+
await setState({ type: 'project', project }, true, options);
|
|
130
|
+
}
|
|
131
|
+
async function projectDisable(project, options = {}) {
|
|
132
|
+
await setState({ type: 'project', project }, false, options);
|
|
133
|
+
}
|
|
134
|
+
async function workflowEnable(project, workflow, options = {}) {
|
|
135
|
+
await setState({ type: 'workflow', project, workflow }, true, options);
|
|
136
|
+
}
|
|
137
|
+
async function workflowDisable(project, workflow, options = {}) {
|
|
138
|
+
await setState({ type: 'workflow', project, workflow }, false, options);
|
|
139
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ const env_set_1 = require("./commands/env-set");
|
|
|
61
61
|
const schedule_set_1 = require("./commands/schedule-set");
|
|
62
62
|
const schedule_list_1 = require("./commands/schedule-list");
|
|
63
63
|
const schedule_delete_1 = require("./commands/schedule-delete");
|
|
64
|
+
const schedule_state_1 = require("./commands/schedule-state");
|
|
64
65
|
const webhook_list_1 = require("./commands/webhook-list");
|
|
65
66
|
const webhook_secret_1 = require("./commands/webhook-secret");
|
|
66
67
|
const dev_1 = require("./commands/dev");
|
|
@@ -88,6 +89,7 @@ const crew_env_set_1 = require("./commands/crew-env-set");
|
|
|
88
89
|
const crew_env_list_1 = require("./commands/crew-env-list");
|
|
89
90
|
const crew_env_delete_1 = require("./commands/crew-env-delete");
|
|
90
91
|
const crew_env_push_1 = require("./commands/crew-env-push");
|
|
92
|
+
const state_1 = require("./commands/state");
|
|
91
93
|
const config_1 = require("./utils/config");
|
|
92
94
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
93
95
|
const pkg = require('../package.json');
|
|
@@ -238,6 +240,7 @@ project
|
|
|
238
240
|
.option('-e, --env <environment>', 'Target environment (production/staging/dev). Required on first deploy of a new project.')
|
|
239
241
|
.option('--create', 'Create environment project if it doesn\'t exist')
|
|
240
242
|
.option('--config-only', 'Sync YAML env declarations without building/deploying')
|
|
243
|
+
.option('--paused', 'Deploy with all YAML-declared schedules initially paused')
|
|
241
244
|
.option('--no-cache', 'Force a fresh build, bypassing all build caches')
|
|
242
245
|
.option('--force-rebuild', 'Force a fresh build, bypassing all build caches (alias for --no-cache)')
|
|
243
246
|
.option('--no-git-metadata', 'Do not transmit Git provenance (branch, commit subject, and sanitized remote repository URL; credentials are stripped); also available as SOLIDACTIONS_NO_GIT_METADATA=1')
|
|
@@ -273,6 +276,44 @@ project
|
|
|
273
276
|
.action((options) => {
|
|
274
277
|
(0, project_list_1.projectList)(options);
|
|
275
278
|
});
|
|
279
|
+
project
|
|
280
|
+
.command('enable')
|
|
281
|
+
.description('Allow new workflow starts for a project environment')
|
|
282
|
+
.argument('<project>', 'Project name')
|
|
283
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
284
|
+
.action(async (projectName, options) => {
|
|
285
|
+
await (0, state_1.projectEnable)(projectName, options);
|
|
286
|
+
});
|
|
287
|
+
project
|
|
288
|
+
.command('disable')
|
|
289
|
+
.description('Block new workflow starts for a project environment')
|
|
290
|
+
.argument('<project>', 'Project name')
|
|
291
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
292
|
+
.action(async (projectName, options) => {
|
|
293
|
+
await (0, state_1.projectDisable)(projectName, options);
|
|
294
|
+
});
|
|
295
|
+
// =============================================================================
|
|
296
|
+
// workflow <subcommand>
|
|
297
|
+
// =============================================================================
|
|
298
|
+
const workflow = exports.program.command('workflow').description('Manage deployed workflows');
|
|
299
|
+
workflow
|
|
300
|
+
.command('enable')
|
|
301
|
+
.description('Allow new starts for a deployed workflow')
|
|
302
|
+
.argument('<project>', 'Project name')
|
|
303
|
+
.argument('<workflow>', 'Workflow name or slug')
|
|
304
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
305
|
+
.action(async (projectName, workflowName, options) => {
|
|
306
|
+
await (0, state_1.workflowEnable)(projectName, workflowName, options);
|
|
307
|
+
});
|
|
308
|
+
workflow
|
|
309
|
+
.command('disable')
|
|
310
|
+
.description('Block new starts for a deployed workflow')
|
|
311
|
+
.argument('<project>', 'Project name')
|
|
312
|
+
.argument('<workflow>', 'Workflow name or slug')
|
|
313
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
314
|
+
.action(async (projectName, workflowName, options) => {
|
|
315
|
+
await (0, state_1.workflowDisable)(projectName, workflowName, options);
|
|
316
|
+
});
|
|
276
317
|
// =============================================================================
|
|
277
318
|
// run <subcommand>
|
|
278
319
|
// =============================================================================
|
|
@@ -458,6 +499,8 @@ schedule
|
|
|
458
499
|
.option('--workflow <name>', 'Workflow name (if project has multiple)')
|
|
459
500
|
.option('-i, --input <json>', 'JSON input to pass to scheduled runs')
|
|
460
501
|
.option('-z, --timezone <iana>', 'IANA timezone the cron is evaluated in (e.g. America/Chicago); defaults to UTC')
|
|
502
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
503
|
+
.option('--paused', 'Create or replace the schedule disabled')
|
|
461
504
|
.option('-y, --yes', 'Skip confirmation if schedule already exists')
|
|
462
505
|
.action((projectName, cron, options) => {
|
|
463
506
|
(0, schedule_set_1.scheduleSet)(projectName, cron, options);
|
|
@@ -466,14 +509,43 @@ schedule
|
|
|
466
509
|
.command('list')
|
|
467
510
|
.description('List schedules for a project')
|
|
468
511
|
.argument('<project>', 'Project name')
|
|
469
|
-
.
|
|
470
|
-
(
|
|
512
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
513
|
+
.action((projectName, options) => {
|
|
514
|
+
(0, schedule_list_1.scheduleList)(projectName, options);
|
|
515
|
+
});
|
|
516
|
+
schedule
|
|
517
|
+
.command('enable')
|
|
518
|
+
.description('Enable a schedule with a sticky operator override')
|
|
519
|
+
.argument('<project>', 'Project name')
|
|
520
|
+
.argument('<schedule-id>', 'Schedule ID')
|
|
521
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
522
|
+
.action((projectName, scheduleId, options) => {
|
|
523
|
+
(0, schedule_state_1.scheduleEnable)(projectName, scheduleId, options);
|
|
524
|
+
});
|
|
525
|
+
schedule
|
|
526
|
+
.command('disable')
|
|
527
|
+
.description('Disable a schedule with a sticky operator override')
|
|
528
|
+
.argument('<project>', 'Project name')
|
|
529
|
+
.argument('<schedule-id>', 'Schedule ID')
|
|
530
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
531
|
+
.action((projectName, scheduleId, options) => {
|
|
532
|
+
(0, schedule_state_1.scheduleDisable)(projectName, scheduleId, options);
|
|
533
|
+
});
|
|
534
|
+
schedule
|
|
535
|
+
.command('reset')
|
|
536
|
+
.description('Return a schedule to its last declared YAML configuration')
|
|
537
|
+
.argument('<project>', 'Project name')
|
|
538
|
+
.argument('<schedule-id>', 'Schedule ID')
|
|
539
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
540
|
+
.action((projectName, scheduleId, options) => {
|
|
541
|
+
(0, schedule_state_1.scheduleReset)(projectName, scheduleId, options);
|
|
471
542
|
});
|
|
472
543
|
schedule
|
|
473
544
|
.command('delete')
|
|
474
545
|
.description('Delete a schedule')
|
|
475
546
|
.argument('<project>', 'Project name')
|
|
476
547
|
.argument('<schedule-id>', 'Schedule ID')
|
|
548
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
477
549
|
.option('-y, --yes', 'Skip confirmation prompt')
|
|
478
550
|
.action((projectName, scheduleId, options) => {
|
|
479
551
|
(0, schedule_delete_1.scheduleDelete)(projectName, scheduleId, options);
|
package/dist/utils/api.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.ensureWorkspaceSelected = ensureWorkspaceSelected;
|
|
|
17
17
|
exports.requireConfigWithWorkspace = requireConfigWithWorkspace;
|
|
18
18
|
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
const chalk_1 = __importDefault(require("chalk"));
|
|
20
|
-
const readline_1 = __importDefault(require("readline"));
|
|
21
20
|
const config_1 = require("./config");
|
|
22
21
|
const workspace_lookup_1 = require("./workspace-lookup");
|
|
23
22
|
// Backend (solidactions-app PR #128) returns: "Project '<slug>' not found in your active workspace '<workspace-slug>'."
|
|
@@ -223,7 +222,7 @@ function authFailureMessage(config, sources) {
|
|
|
223
222
|
const keySource = sources?.apiKey ?? 'config';
|
|
224
223
|
return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
|
|
225
224
|
}
|
|
226
|
-
async function ensureWorkspaceSelected(config) {
|
|
225
|
+
async function ensureWorkspaceSelected(config, dependencies = {}) {
|
|
227
226
|
if (config.workspaceId) {
|
|
228
227
|
return config;
|
|
229
228
|
}
|
|
@@ -286,22 +285,14 @@ async function ensureWorkspaceSelected(config) {
|
|
|
286
285
|
+ 'Run `solidactions workspace set <name-or-id> --local` (or --global).'));
|
|
287
286
|
process.exit(1);
|
|
288
287
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
const chosen = await (0, workspace_lookup_1.selectWorkspaceInteractively)(workspaces, {
|
|
289
|
+
...dependencies,
|
|
290
|
+
label: (ws) => `${ws.name} ${chalk_1.default.gray(`(${ws.org_name}, ${ws.role})`)}`,
|
|
292
291
|
});
|
|
293
|
-
|
|
294
|
-
const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
295
|
-
const answer = await new Promise((resolve) => {
|
|
296
|
-
rl.question(chalk_1.default.blue('Enter number: '), resolve);
|
|
297
|
-
});
|
|
298
|
-
rl.close();
|
|
299
|
-
const index = parseInt(answer, 10) - 1;
|
|
300
|
-
if (isNaN(index) || index < 0 || index >= workspaces.length) {
|
|
301
|
-
console.error(chalk_1.default.red('Invalid selection.'));
|
|
292
|
+
if (!chosen) {
|
|
302
293
|
process.exit(1);
|
|
303
294
|
}
|
|
304
|
-
selected =
|
|
295
|
+
selected = chosen;
|
|
305
296
|
}
|
|
306
297
|
config.workspace = selected.slug ?? selected.name;
|
|
307
298
|
config.workspaceId = selected.id;
|
|
@@ -237,5 +237,8 @@ function parseDeployAcceptance(data) {
|
|
|
237
237
|
deploymentId: nullableString(body.deployment_id),
|
|
238
238
|
sourceMetadata,
|
|
239
239
|
sourceMetadataRejected: nullableString(body.source_metadata_rejected),
|
|
240
|
+
schedulesPaused: typeof body.schedules_paused === 'boolean'
|
|
241
|
+
? body.schedules_paused
|
|
242
|
+
: null,
|
|
240
243
|
};
|
|
241
244
|
}
|