@solidactions/cli 3.2.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 +4546 -0
- 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 +106 -28
- package/dist/utils/api.js +6 -15
- package/dist/utils/command-manifest.js +221 -0
- 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 +2 -2
package/dist/commands/deploy.js
CHANGED
|
@@ -540,6 +540,9 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
540
540
|
console.log(chalk_1.default.gray(`Archived ${archive.pointer()} total bytes`));
|
|
541
541
|
try {
|
|
542
542
|
const form = (0, source_provenance_1.buildDeployForm)(archivePath, sourceMetadata);
|
|
543
|
+
if (options.paused) {
|
|
544
|
+
form.append('paused', '1');
|
|
545
|
+
}
|
|
543
546
|
console.log(chalk_1.default.yellow('Uploading...'));
|
|
544
547
|
if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
|
|
545
548
|
process.stderr.write(`[deploy-debug] POST ${config.host}/api/v1/projects/${projectSlug}/deploy (workspace=${config.workspaceId ?? '(none)'})\n`);
|
|
@@ -611,6 +614,16 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
611
614
|
console.log(chalk_1.default.blue(`ℹ Webhook secret: run \`solidactions webhook secret ${projectName}${envFlag}\` to retrieve the generated secret.`));
|
|
612
615
|
console.log(chalk_1.default.gray(` Set the same value in your sender (e.g. Telegram setWebhook secret_token).`));
|
|
613
616
|
}
|
|
617
|
+
if (options.paused) {
|
|
618
|
+
console.log('');
|
|
619
|
+
if (acceptedDeployment.schedulesPaused === true) {
|
|
620
|
+
console.log(chalk_1.default.green('Schedules deployed paused.'));
|
|
621
|
+
console.log(chalk_1.default.gray(`Enable one when ready with: solidactions schedule enable ${projectSlug} <schedule-id>`));
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
console.log(chalk_1.default.yellow('Warning: server did not acknowledge paused schedules; verify schedules before relying on them being paused.'));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
614
627
|
cleanupArchive();
|
|
615
628
|
process.exit(0);
|
|
616
629
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = void 0;
|
|
6
|
+
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
7
7
|
exports.resolveLoginApiKey = resolveLoginApiKey;
|
|
8
8
|
exports.getConfig = getConfig;
|
|
9
9
|
exports.saveConfig = saveConfig;
|
|
@@ -13,19 +13,19 @@ exports.backupPathFor = backupPathFor;
|
|
|
13
13
|
exports.preflightDeviceLoginWrite = preflightDeviceLoginWrite;
|
|
14
14
|
exports.persistPreflightedLoginCredential = persistPreflightedLoginCredential;
|
|
15
15
|
exports.loginHostLines = loginHostLines;
|
|
16
|
-
exports.selectWorkspaceInteractively = selectWorkspaceInteractively;
|
|
17
16
|
exports.completeLogin = completeLogin;
|
|
18
17
|
exports.login = login;
|
|
19
18
|
exports.logout = logout;
|
|
20
19
|
exports.whoami = whoami;
|
|
21
20
|
const fs_1 = __importDefault(require("fs"));
|
|
22
21
|
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const readline_1 = __importDefault(require("readline"));
|
|
24
22
|
const chalk_1 = __importDefault(require("chalk"));
|
|
25
23
|
const prompts_1 = __importDefault(require("prompts"));
|
|
26
24
|
const config_1 = require("../utils/config");
|
|
27
25
|
const config_write_target_1 = require("../utils/config-write-target");
|
|
28
26
|
const workspace_lookup_1 = require("../utils/workspace-lookup");
|
|
27
|
+
var workspace_lookup_2 = require("../utils/workspace-lookup");
|
|
28
|
+
Object.defineProperty(exports, "selectWorkspaceInteractively", { enumerable: true, get: function () { return workspace_lookup_2.selectWorkspaceInteractively; } });
|
|
29
29
|
exports.API_KEY_PROMPT = {
|
|
30
30
|
type: 'password',
|
|
31
31
|
name: 'apiKey',
|
|
@@ -218,59 +218,6 @@ function loginHostLines(resolved) {
|
|
|
218
218
|
}
|
|
219
219
|
return [`Host: ${resolved.host}`];
|
|
220
220
|
}
|
|
221
|
-
async function selectWorkspaceInteractively(workspaces, dependencies = {}) {
|
|
222
|
-
if (workspaces.length === 0) {
|
|
223
|
-
console.log(chalk_1.default.yellow('No workspaces found. Create one at your SolidActions dashboard, then run `solidactions workspace set <name>`.'));
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
if (workspaces.length === 1) {
|
|
227
|
-
console.log(chalk_1.default.gray(`Auto-selected workspace: ${workspaces[0].name}`));
|
|
228
|
-
return workspaces[0];
|
|
229
|
-
}
|
|
230
|
-
console.log(chalk_1.default.blue('\nSelect your default workspace (change anytime with `solidactions workspace set`):\n'));
|
|
231
|
-
workspaces.forEach((ws, i) => {
|
|
232
|
-
console.log(` ${chalk_1.default.white(`${i + 1}.`)} ${ws.name}`);
|
|
233
|
-
});
|
|
234
|
-
console.log('');
|
|
235
|
-
const rl = dependencies.question
|
|
236
|
-
? null
|
|
237
|
-
: readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
238
|
-
const question = dependencies.question ?? (async () => {
|
|
239
|
-
if (!rl || rl.closed)
|
|
240
|
-
return undefined;
|
|
241
|
-
return new Promise((resolve) => {
|
|
242
|
-
let answered = false;
|
|
243
|
-
const onClose = () => {
|
|
244
|
-
if (!answered)
|
|
245
|
-
resolve(undefined);
|
|
246
|
-
};
|
|
247
|
-
rl.once('close', onClose);
|
|
248
|
-
rl.question(chalk_1.default.blue('Enter number: '), (answer) => {
|
|
249
|
-
answered = true;
|
|
250
|
-
rl.removeListener('close', onClose);
|
|
251
|
-
resolve(answer);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
try {
|
|
256
|
-
while (true) {
|
|
257
|
-
const answer = await question();
|
|
258
|
-
if (answer === undefined) {
|
|
259
|
-
console.log(chalk_1.default.yellow('Workspace selection cancelled. Run `solidactions workspace list`, then '
|
|
260
|
-
+ '`solidactions workspace set <name>` when ready.'));
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
const index = parseInt(answer, 10) - 1;
|
|
264
|
-
if (!isNaN(index) && index >= 0 && index < workspaces.length) {
|
|
265
|
-
return workspaces[index];
|
|
266
|
-
}
|
|
267
|
-
console.error(chalk_1.default.red('Invalid selection. Enter one of the numbers shown.'));
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
finally {
|
|
271
|
-
rl?.close();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
221
|
/**
|
|
275
222
|
* Shared tail of API-key and device login: resolve the workspace against an
|
|
276
223
|
* already-fetched list, persist the final config, and print success output.
|
|
@@ -313,7 +260,7 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
|
|
|
313
260
|
+ 'run `solidactions workspace set <name>`.'));
|
|
314
261
|
}
|
|
315
262
|
else if (process.stdin.isTTY) {
|
|
316
|
-
const selected = await selectWorkspaceInteractively(workspaces);
|
|
263
|
+
const selected = await (0, workspace_lookup_1.selectWorkspaceInteractively)(workspaces);
|
|
317
264
|
if (selected) {
|
|
318
265
|
config.workspace = selected.slug ?? selected.name;
|
|
319
266
|
config.workspaceId = selected.id;
|
|
@@ -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
|
+
}
|