@solidactions/cli 3.4.0 → 3.6.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/deploy.js +29 -14
- 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/env.js +15 -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.6.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",
|
package/dist/commands/deploy.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.isConfirmationMatch = isConfirmationMatch;
|
|
|
11
11
|
exports.confirmDeploymentWithRetry = confirmDeploymentWithRetry;
|
|
12
12
|
exports.formatDeploymentConfirmation = formatDeploymentConfirmation;
|
|
13
13
|
exports.safeCollectSourceMetadata = safeCollectSourceMetadata;
|
|
14
|
+
exports.pushYamlDeclarations = pushYamlDeclarations;
|
|
14
15
|
exports.shouldPrintWorkspaceMismatch = shouldPrintWorkspaceMismatch;
|
|
15
16
|
exports.isPlanLimitReachedError = isPlanLimitReachedError;
|
|
16
17
|
exports.handlePlanLimitReached = handlePlanLimitReached;
|
|
@@ -214,28 +215,29 @@ function safeCollectSourceMetadata(sourceDir, options, collector = source_proven
|
|
|
214
215
|
/**
|
|
215
216
|
* Push YAML env declarations to the project.
|
|
216
217
|
* This registers all YAML-declared vars and their mappings.
|
|
218
|
+
*
|
|
219
|
+
* Always POSTs, even when `parsedVars` is empty: the endpoint prunes stale
|
|
220
|
+
* mappings on an explicit `declarations: []`, so removing the last YAML env
|
|
221
|
+
* declaration must still reach it (spec #1127 §4B).
|
|
222
|
+
*
|
|
223
|
+
* Throws the raw axios error on failure — callers decide how to handle it
|
|
224
|
+
* (PM round #1127 finding 14: a failed sync must never be reported as
|
|
225
|
+
* success by the caller).
|
|
217
226
|
*/
|
|
218
227
|
async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
|
|
219
228
|
const parsedVars = (0, env_1.parseYamlEnvVars)(yamlConfig);
|
|
220
|
-
if (parsedVars.length === 0) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
229
|
// Build the declarations array
|
|
224
230
|
const declarations = parsedVars.map(v => ({
|
|
225
231
|
env_name: v.key,
|
|
226
232
|
yaml_default_global_key: v.mappedTo,
|
|
227
233
|
yaml_default_oauth_name: v.oauthName,
|
|
234
|
+
yaml_default_database_name: v.databaseName,
|
|
228
235
|
source: 'yaml',
|
|
229
236
|
}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations`));
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
console.error(chalk_1.default.yellow('Warning: Failed to sync YAML declarations:'), error.response?.data?.message || error.message);
|
|
238
|
-
}
|
|
237
|
+
await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
|
|
238
|
+
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
239
|
+
});
|
|
240
|
+
console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations`));
|
|
239
241
|
}
|
|
240
242
|
/**
|
|
241
243
|
* Returns true only when a 404 on the environment-specific project lookup
|
|
@@ -492,7 +494,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
492
494
|
console.error(chalk_1.default.red('Cannot sync config: solidactions.yaml not found or invalid.'));
|
|
493
495
|
process.exit(1);
|
|
494
496
|
}
|
|
495
|
-
|
|
497
|
+
try {
|
|
498
|
+
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
499
|
+
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
|
|
502
|
+
process.exit(1);
|
|
503
|
+
}
|
|
496
504
|
console.log(chalk_1.default.green(`✓ Config synced for ${projectSlug}${envLabel}`));
|
|
497
505
|
return;
|
|
498
506
|
}
|
|
@@ -606,7 +614,14 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
606
614
|
}
|
|
607
615
|
// Always sync YAML declarations (registers variables and their mappings)
|
|
608
616
|
if (yamlConfig) {
|
|
609
|
-
|
|
617
|
+
try {
|
|
618
|
+
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
619
|
+
}
|
|
620
|
+
catch (error) {
|
|
621
|
+
console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
|
|
622
|
+
cleanupArchive();
|
|
623
|
+
process.exit(1);
|
|
624
|
+
}
|
|
610
625
|
}
|
|
611
626
|
if (yamlConfig && shouldPrintWebhookSecretNotice(yamlConfig.workflows ?? [])) {
|
|
612
627
|
const envFlag = environment !== 'dev' ? ` -e ${environment}` : '';
|
|
@@ -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')
|
package/dist/utils/env.js
CHANGED
|
@@ -48,8 +48,10 @@ function parseEnvFile(filePath) {
|
|
|
48
48
|
/**
|
|
49
49
|
* Parse YAML env declarations into structured format.
|
|
50
50
|
* Handles the new simplified format:
|
|
51
|
-
* - VAR_NAME
|
|
52
|
-
* - VAR_NAME: GLOBAL
|
|
51
|
+
* - VAR_NAME -> { key: "VAR_NAME", mappedTo: null }
|
|
52
|
+
* - VAR_NAME: GLOBAL -> { key: "VAR_NAME", mappedTo: "GLOBAL" }
|
|
53
|
+
* - VAR_NAME:\n oauth: "Name" -> { key: "VAR_NAME", oauthName: "Name" }
|
|
54
|
+
* - VAR_NAME:\n database: "Name" -> { key: "VAR_NAME", databaseName: "Name" }
|
|
53
55
|
*/
|
|
54
56
|
function parseYamlEnvVars(config) {
|
|
55
57
|
const parsedVars = [];
|
|
@@ -59,10 +61,11 @@ function parseYamlEnvVars(config) {
|
|
|
59
61
|
for (const item of config.env) {
|
|
60
62
|
if (typeof item === 'string') {
|
|
61
63
|
// Simple string: - VAR_NAME (declared only, needs configuration)
|
|
62
|
-
parsedVars.push({ key: item, mappedTo: null, oauthName: null });
|
|
64
|
+
parsedVars.push({ key: item, mappedTo: null, oauthName: null, databaseName: null });
|
|
63
65
|
}
|
|
64
66
|
else if (typeof item === 'object' && item !== null) {
|
|
65
|
-
// Object: - VAR_NAME: GLOBAL_NAME
|
|
67
|
+
// Object: - VAR_NAME: GLOBAL_NAME, - VAR_NAME: { oauth: connection-name },
|
|
68
|
+
// or - VAR_NAME: { database: database-name }
|
|
66
69
|
const keys = Object.keys(item);
|
|
67
70
|
if (keys.length === 1) {
|
|
68
71
|
const key = keys[0];
|
|
@@ -71,10 +74,16 @@ function parseYamlEnvVars(config) {
|
|
|
71
74
|
if (typeof value.oauth !== 'string' || !value.oauth) {
|
|
72
75
|
throw new Error(`Invalid env config for ${key}: 'oauth' must be a non-empty string`);
|
|
73
76
|
}
|
|
74
|
-
parsedVars.push({ key, mappedTo: null, oauthName: value.oauth });
|
|
77
|
+
parsedVars.push({ key, mappedTo: null, oauthName: value.oauth, databaseName: null });
|
|
78
|
+
}
|
|
79
|
+
else if (typeof value === 'object' && value !== null && 'database' in value) {
|
|
80
|
+
if (typeof value.database !== 'string' || !value.database) {
|
|
81
|
+
throw new Error(`Invalid env config for ${key}: 'database' must be a non-empty string`);
|
|
82
|
+
}
|
|
83
|
+
parsedVars.push({ key, mappedTo: null, oauthName: null, databaseName: value.database });
|
|
75
84
|
}
|
|
76
85
|
else {
|
|
77
|
-
parsedVars.push({ key, mappedTo: value || null, oauthName: null });
|
|
86
|
+
parsedVars.push({ key, mappedTo: value || null, oauthName: null, databaseName: null });
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
}
|
|
@@ -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
|
+
}
|