@solidactions/cli 3.4.0 → 3.5.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 +15 -9
- package/dist/command-manifest.json +68 -4
- package/dist/commands/project-view.js +4 -1
- package/dist/commands/workflow-view.js +112 -0
- package/dist/index.js +21 -6
- package/dist/utils/webhook-formatters.js +2 -7
- package/dist/utils/workflow-state.js +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -170,20 +170,21 @@ Use `solidactions <command> --help` for full flag details on any command.
|
|
|
170
170
|
|---------|-----------|-------------|
|
|
171
171
|
| `project create <name>` | `-e` | Create an empty project (no source/build); `-e` defaults to `production` |
|
|
172
172
|
| `project deploy <name> [path]` | `-e`, `--create`, `--config-only`, `--paused`, `--no-git-metadata` | Deploy or sync config only; optionally land YAML schedules paused |
|
|
173
|
-
| `project view <project>` | `-e` | View status and client-reported deployed revision |
|
|
174
|
-
| `project deploy <name> [path]` | `-e`, `--create`, `--config-only`, `--no-git-metadata` | Deploy or sync config only |
|
|
175
173
|
| `project enable <project>` | `-e` (default `dev`) | Allow new starts through this project gate |
|
|
176
174
|
| `project disable <project>` | `-e` (default `dev`) | Block new root starts without cancelling existing roots |
|
|
177
|
-
| `project view <project>` | `-e` | View status, `Enabled: on|off`, and client-reported deployed revision |
|
|
175
|
+
| `project view <project>` | `-e` (default `dev`) | View status, `Enabled: on|off`, and client-reported deployed revision |
|
|
178
176
|
| `project pull <name> [path]` | `-y` | Pull source (warns before overwriting) |
|
|
179
177
|
| `project logs <name>` | | View build logs |
|
|
180
178
|
| `project list` | `--json` | List project families; environments render as `environment:on/off` |
|
|
181
179
|
|
|
182
|
-
For `project view`,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
For `project view`, `<project>` is a project family slug or name and omitting
|
|
181
|
+
`--env` targets dev (`billing` resolves to `billing-dev`). Use `--env production`
|
|
182
|
+
to pass the supplied production name/slug unchanged; `--env staging` and
|
|
183
|
+
`--env dev` derive the same suffixed slug as deploy.
|
|
184
|
+
|
|
185
|
+
This changes exact-suffixed positional input: `project view billing-dev` now
|
|
186
|
+
targets `billing-dev-dev`. Use `project view billing` for the dev target, or
|
|
187
|
+
pass `--env production` when `billing-dev` is the legitimate production slug.
|
|
187
188
|
|
|
188
189
|
Project enable/disable is an explicit, non-interactive operator action. It does
|
|
189
190
|
not cascade to workflows or schedules, and deploy does not undo the manual
|
|
@@ -193,10 +194,15 @@ state.
|
|
|
193
194
|
|
|
194
195
|
| Command | Key Flags | Description |
|
|
195
196
|
|---------|-----------|-------------|
|
|
197
|
+
| `workflow view <project> <workflow>` | `-e` (default `dev`), `--json` | Inspect stored workflow/project gates, retirement, enabled source, and effective state |
|
|
196
198
|
| `workflow enable <project> <workflow>` | `-e` (default `dev`) | Enable the workflow gate; direct starts still require the project, and scheduled starts also require the schedule |
|
|
197
199
|
| `workflow disable <project> <workflow>` | `-e` (default `dev`) | Block new root starts without cancelling existing roots |
|
|
198
200
|
|
|
199
|
-
Workflow enable/disable accepts
|
|
201
|
+
Workflow view/enable/disable accepts an exact workflow slug or an exact name and
|
|
202
|
+
does not prompt. View defaults to dev like the mutation commands, and reports
|
|
203
|
+
`Enabled source: manual override (deploy will not change it)` or
|
|
204
|
+
`Enabled source: YAML declaration`; use `--json` for the unmodified
|
|
205
|
+
machine-queryable state.
|
|
200
206
|
The manual state is sticky across deploys; enabling a workflow does not enable
|
|
201
207
|
its project or schedule.
|
|
202
208
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"cli_name": "solidactions",
|
|
4
|
-
"cli_version": "3.
|
|
4
|
+
"cli_version": "3.5.0",
|
|
5
5
|
"global_options": [
|
|
6
6
|
{
|
|
7
7
|
"flags": "-V, --version",
|
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
"name": "project",
|
|
403
403
|
"required": true,
|
|
404
404
|
"variadic": false,
|
|
405
|
-
"description": "
|
|
405
|
+
"description": "Project family slug or name"
|
|
406
406
|
}
|
|
407
407
|
],
|
|
408
408
|
"options": [
|
|
@@ -410,13 +410,14 @@
|
|
|
410
410
|
"flags": "-e, --env <environment>",
|
|
411
411
|
"long": "--env",
|
|
412
412
|
"short": "-e",
|
|
413
|
-
"description": "
|
|
413
|
+
"description": "Target environment (production/staging/dev). Defaults to dev.",
|
|
414
414
|
"required": false,
|
|
415
415
|
"value_required": true,
|
|
416
416
|
"value_optional": false,
|
|
417
417
|
"variadic": false,
|
|
418
418
|
"negated": false,
|
|
419
|
-
"hidden": false
|
|
419
|
+
"hidden": false,
|
|
420
|
+
"default": "dev"
|
|
420
421
|
},
|
|
421
422
|
{
|
|
422
423
|
"flags": "-h, --help",
|
|
@@ -876,6 +877,69 @@
|
|
|
876
877
|
}
|
|
877
878
|
]
|
|
878
879
|
},
|
|
880
|
+
{
|
|
881
|
+
"path": [
|
|
882
|
+
"workflow",
|
|
883
|
+
"view"
|
|
884
|
+
],
|
|
885
|
+
"name": "view",
|
|
886
|
+
"aliases": [],
|
|
887
|
+
"description": "View a deployed workflow's enabled state",
|
|
888
|
+
"hidden": false,
|
|
889
|
+
"arguments": [
|
|
890
|
+
{
|
|
891
|
+
"name": "project",
|
|
892
|
+
"required": true,
|
|
893
|
+
"variadic": false,
|
|
894
|
+
"description": "Project name"
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"name": "workflow",
|
|
898
|
+
"required": true,
|
|
899
|
+
"variadic": false,
|
|
900
|
+
"description": "Exact workflow slug or name"
|
|
901
|
+
}
|
|
902
|
+
],
|
|
903
|
+
"options": [
|
|
904
|
+
{
|
|
905
|
+
"flags": "-e, --env <environment>",
|
|
906
|
+
"long": "--env",
|
|
907
|
+
"short": "-e",
|
|
908
|
+
"description": "Environment (production/staging/dev). Defaults to dev.",
|
|
909
|
+
"required": false,
|
|
910
|
+
"value_required": true,
|
|
911
|
+
"value_optional": false,
|
|
912
|
+
"variadic": false,
|
|
913
|
+
"negated": false,
|
|
914
|
+
"hidden": false,
|
|
915
|
+
"default": "dev"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"flags": "--json",
|
|
919
|
+
"long": "--json",
|
|
920
|
+
"short": null,
|
|
921
|
+
"description": "Output the server workflow state as JSON",
|
|
922
|
+
"required": false,
|
|
923
|
+
"value_required": false,
|
|
924
|
+
"value_optional": false,
|
|
925
|
+
"variadic": false,
|
|
926
|
+
"negated": false,
|
|
927
|
+
"hidden": false
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
"flags": "-h, --help",
|
|
931
|
+
"long": "--help",
|
|
932
|
+
"short": "-h",
|
|
933
|
+
"description": "display help for command",
|
|
934
|
+
"required": false,
|
|
935
|
+
"value_required": false,
|
|
936
|
+
"value_optional": false,
|
|
937
|
+
"variadic": false,
|
|
938
|
+
"negated": false,
|
|
939
|
+
"hidden": false
|
|
940
|
+
}
|
|
941
|
+
]
|
|
942
|
+
},
|
|
879
943
|
{
|
|
880
944
|
"path": [
|
|
881
945
|
"workflow",
|
|
@@ -20,6 +20,9 @@ function projectSlugForView(project, environment) {
|
|
|
20
20
|
if (!['production', 'staging', 'dev'].includes(environment)) {
|
|
21
21
|
throw new Error('Environment must be production, staging, or dev.');
|
|
22
22
|
}
|
|
23
|
+
if ((0, slug_1.slugifyName)(project) === '') {
|
|
24
|
+
throw new Error('Project must contain at least one letter or number.');
|
|
25
|
+
}
|
|
23
26
|
return environment === 'production'
|
|
24
27
|
? project
|
|
25
28
|
: (0, slug_1.buildProjectSlug)(project, environment);
|
|
@@ -100,7 +103,7 @@ function formatProjectView(project) {
|
|
|
100
103
|
async function projectViewWithConfig(project, options, config, writeLine = console.log) {
|
|
101
104
|
let slug;
|
|
102
105
|
try {
|
|
103
|
-
slug = projectSlugForView(project, options.env);
|
|
106
|
+
slug = projectSlugForView(project, options.env ?? 'dev');
|
|
104
107
|
}
|
|
105
108
|
catch (error) {
|
|
106
109
|
console.error(chalk_1.default.red(error.message));
|
|
@@ -0,0 +1,112 @@
|
|
|
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.formatWorkflowView = formatWorkflowView;
|
|
7
|
+
exports.workflowViewWithConfig = workflowViewWithConfig;
|
|
8
|
+
exports.workflowView = workflowView;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const api_1 = require("../utils/api");
|
|
12
|
+
const source_provenance_1 = require("../utils/source-provenance");
|
|
13
|
+
const workflow_state_1 = require("../utils/workflow-state");
|
|
14
|
+
const state_1 = require("./state");
|
|
15
|
+
function display(value, fallback = 'unknown', maxLength = 255) {
|
|
16
|
+
return (0, source_provenance_1.sanitizeDisplayText)(value, maxLength) ?? fallback;
|
|
17
|
+
}
|
|
18
|
+
// The API's `enabled_source` stays `manual|yaml` even when a workflow is
|
|
19
|
+
// retired: retirement (app WorkflowSyncService.php:80) nulls `yaml_enabled`
|
|
20
|
+
// but the projection doesn't special-case retirement, so a non-overridden
|
|
21
|
+
// retired workflow still reports 'yaml'. Decided NOT to add a third API
|
|
22
|
+
// value for this (see app plan decision ledger for #1098's PM fix round) —
|
|
23
|
+
// fix the contradictory wording here instead.
|
|
24
|
+
function enabledSourceLabel(source, retired) {
|
|
25
|
+
if (source === 'manual')
|
|
26
|
+
return 'manual override (deploy will not change it)';
|
|
27
|
+
if (source === 'yaml')
|
|
28
|
+
return retired ? 'YAML-managed (retired)' : 'YAML declaration';
|
|
29
|
+
return display(source);
|
|
30
|
+
}
|
|
31
|
+
function formatWorkflowView(workflow) {
|
|
32
|
+
return [
|
|
33
|
+
`Workflow: ${display(workflow.name)}`,
|
|
34
|
+
`Slug: ${display(workflow.slug)}`,
|
|
35
|
+
`Project: ${display(workflow.project_name)}`,
|
|
36
|
+
`Project slug: ${display(workflow.project_slug)}`,
|
|
37
|
+
`Environment: ${display(workflow.environment, 'unknown', 32)}`,
|
|
38
|
+
`Workflow enabled: ${workflow.enabled ? 'on' : 'off'}`,
|
|
39
|
+
`Enabled source: ${enabledSourceLabel(workflow.enabled_source, workflow.retired)}`,
|
|
40
|
+
`Project enabled: ${workflow.project_enabled ? 'on' : 'off'}`,
|
|
41
|
+
`Retired: ${workflow.retired ? 'yes' : 'no'}`,
|
|
42
|
+
`Effective state: ${(0, workflow_state_1.workflowEffectiveState)(workflow)}`,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
function serverMessage(error, fallback) {
|
|
46
|
+
return display(error.response?.data?.message, fallback, 500);
|
|
47
|
+
}
|
|
48
|
+
function printAmbiguity(error) {
|
|
49
|
+
console.error(chalk_1.default.red(serverMessage(error, 'More than one workflow has that name.')));
|
|
50
|
+
const candidates = Array.isArray(error.response?.data?.candidates)
|
|
51
|
+
? error.response.data.candidates
|
|
52
|
+
: [];
|
|
53
|
+
for (const candidate of candidates) {
|
|
54
|
+
const slug = display(candidate.slug);
|
|
55
|
+
const lifecycle = candidate.retired === true ? 'retired' : 'active';
|
|
56
|
+
console.error(` ${slug} (${lifecycle})`);
|
|
57
|
+
}
|
|
58
|
+
console.error('Re-run with an exact slug.');
|
|
59
|
+
}
|
|
60
|
+
function printWorkflowViewError(error) {
|
|
61
|
+
if (!error.response) {
|
|
62
|
+
console.error(chalk_1.default.red('Connection failed:'), display(error.message, 'Unknown network error.', 500));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (error.response.status === 401) {
|
|
66
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// The GET workflow endpoint uses the v1 {code, message} convention;
|
|
70
|
+
// fall back to the legacy `error` key defensively (e.g. older servers,
|
|
71
|
+
// or the sibling PUT .../enabled route, which still uses `error`).
|
|
72
|
+
const errorCode = error.response.data?.code ?? error.response.data?.error;
|
|
73
|
+
if (error.response.status === 409 && errorCode === 'ambiguous_workflow') {
|
|
74
|
+
printAmbiguity(error);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const fallback = error.response.status === 404
|
|
78
|
+
? 'Project or workflow not found.'
|
|
79
|
+
: `Failed to view workflow: ${error.response.status}`;
|
|
80
|
+
console.error(chalk_1.default.red(serverMessage(error, fallback)));
|
|
81
|
+
}
|
|
82
|
+
async function workflowViewWithConfig(project, workflow, options, config) {
|
|
83
|
+
let projectSlug;
|
|
84
|
+
try {
|
|
85
|
+
const environment = (0, state_1.resolveStateEnvironment)(options.env);
|
|
86
|
+
projectSlug = (0, state_1.projectSlugForState)(project, environment);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error(chalk_1.default.red(error.message));
|
|
90
|
+
process.exit(1);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/workflows/${encodeURIComponent(workflow)}`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
95
|
+
const data = response.data.data;
|
|
96
|
+
if (options.json) {
|
|
97
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}\n`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const line of formatWorkflowView(data)) {
|
|
101
|
+
console.log(line);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
printWorkflowViewError(error);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function workflowView(project, workflow, options = {}) {
|
|
110
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
111
|
+
await workflowViewWithConfig(project, workflow, options, config);
|
|
112
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ const crew_env_list_1 = require("./commands/crew-env-list");
|
|
|
90
90
|
const crew_env_delete_1 = require("./commands/crew-env-delete");
|
|
91
91
|
const crew_env_push_1 = require("./commands/crew-env-push");
|
|
92
92
|
const state_1 = require("./commands/state");
|
|
93
|
+
const workflow_view_1 = require("./commands/workflow-view");
|
|
93
94
|
const config_1 = require("./utils/config");
|
|
94
95
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
95
96
|
const pkg = require('../package.json');
|
|
@@ -214,13 +215,12 @@ const project = exports.program.command('project').description('Manage projects'
|
|
|
214
215
|
project
|
|
215
216
|
.command('view')
|
|
216
217
|
.description('View project status and the client-reported deployed revision')
|
|
217
|
-
.argument('<project>', '
|
|
218
|
-
.option('-e, --env <environment>', '
|
|
218
|
+
.argument('<project>', 'Project family slug or name')
|
|
219
|
+
.option('-e, --env <environment>', 'Target environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
219
220
|
.addHelpText('after', `
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
dev environment default.`)
|
|
221
|
+
Defaults to dev: <project> is normalized as a project family and "-dev" is
|
|
222
|
+
appended. Use --env staging for the "-staging" target. Use --env production to
|
|
223
|
+
pass the supplied production slug or name through unchanged.`)
|
|
224
224
|
.action(async (projectName, options) => {
|
|
225
225
|
await (0, project_view_1.projectView)(projectName, options);
|
|
226
226
|
});
|
|
@@ -296,6 +296,21 @@ project
|
|
|
296
296
|
// workflow <subcommand>
|
|
297
297
|
// =============================================================================
|
|
298
298
|
const workflow = exports.program.command('workflow').description('Manage deployed workflows');
|
|
299
|
+
workflow
|
|
300
|
+
.command('view')
|
|
301
|
+
.description('View a deployed workflow\'s enabled state')
|
|
302
|
+
.argument('<project>', 'Project name')
|
|
303
|
+
.argument('<workflow>', 'Exact workflow slug or name')
|
|
304
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
|
|
305
|
+
.option('--json', 'Output the server workflow state as JSON')
|
|
306
|
+
.addHelpText('after', `
|
|
307
|
+
The environment defaults to dev. The project argument is normalized and dev or
|
|
308
|
+
staging appends the corresponding "-<env>" suffix; production uses the base
|
|
309
|
+
slug. This matches \`project view\`, which also defaults to dev and normalizes
|
|
310
|
+
its project argument the same way.`)
|
|
311
|
+
.action(async (projectName, workflowName, options) => {
|
|
312
|
+
await (0, workflow_view_1.workflowView)(projectName, workflowName, options);
|
|
313
|
+
});
|
|
299
314
|
workflow
|
|
300
315
|
.command('enable')
|
|
301
316
|
.description('Allow new starts for a deployed workflow')
|
|
@@ -8,17 +8,12 @@ exports.formatTable = formatTable;
|
|
|
8
8
|
exports.formatJson = formatJson;
|
|
9
9
|
// src/utils/webhook-formatters.ts
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const workflow_state_1 = require("./workflow-state");
|
|
11
12
|
function columnWidth(min, values) {
|
|
12
13
|
return Math.max(min, ...values.map(v => v.length)) + 2;
|
|
13
14
|
}
|
|
14
15
|
function webhookState(webhook) {
|
|
15
|
-
|
|
16
|
-
return 'retired';
|
|
17
|
-
if (webhook.enabled === false)
|
|
18
|
-
return 'off';
|
|
19
|
-
if (webhook.project_enabled === false)
|
|
20
|
-
return 'blocked (project off)';
|
|
21
|
-
return 'on';
|
|
16
|
+
return (0, workflow_state_1.workflowEffectiveState)(webhook);
|
|
22
17
|
}
|
|
23
18
|
function colorizeState(state, width) {
|
|
24
19
|
const padded = state.padEnd(width);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workflowEffectiveState = workflowEffectiveState;
|
|
4
|
+
/**
|
|
5
|
+
* Derive the operator-facing workflow gate state in admission precedence.
|
|
6
|
+
*
|
|
7
|
+
* The server also reports `effective_enabled`, but callers need the richer
|
|
8
|
+
* reason label and older responses may omit that derived boolean.
|
|
9
|
+
*/
|
|
10
|
+
function workflowEffectiveState(workflow) {
|
|
11
|
+
if (workflow.retired === true)
|
|
12
|
+
return 'retired';
|
|
13
|
+
if (workflow.enabled === false)
|
|
14
|
+
return 'off';
|
|
15
|
+
if (workflow.project_enabled === false)
|
|
16
|
+
return 'blocked (project off)';
|
|
17
|
+
return 'on';
|
|
18
|
+
}
|