@solidactions/cli 3.3.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/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,8 @@ 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");
93
+ const workflow_view_1 = require("./commands/workflow-view");
91
94
  const config_1 = require("./utils/config");
92
95
  // eslint-disable-next-line @typescript-eslint/no-var-requires
93
96
  const pkg = require('../package.json');
@@ -212,13 +215,12 @@ const project = exports.program.command('project').description('Manage projects'
212
215
  project
213
216
  .command('view')
214
217
  .description('View project status and the client-reported deployed revision')
215
- .argument('<project>', 'Exact project slug (or project family/name when --env is explicit)')
216
- .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
218
+ .argument('<project>', 'Project family slug or name')
219
+ .option('-e, --env <environment>', 'Target environment (production/staging/dev). Defaults to dev.', 'dev')
217
220
  .addHelpText('after', `
218
- Without --env, <project> is used as an exact slug. With --env production it is
219
- used unchanged; staging/dev use the same "-<env>" suffix rule as deploy.
220
- Unlike historical commands such as \`run start\`, project view has no implicit
221
- 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.`)
222
224
  .action(async (projectName, options) => {
223
225
  await (0, project_view_1.projectView)(projectName, options);
224
226
  });
@@ -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,59 @@ 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('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
+ });
314
+ workflow
315
+ .command('enable')
316
+ .description('Allow new starts for a deployed workflow')
317
+ .argument('<project>', 'Project name')
318
+ .argument('<workflow>', 'Workflow name or slug')
319
+ .option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
320
+ .action(async (projectName, workflowName, options) => {
321
+ await (0, state_1.workflowEnable)(projectName, workflowName, options);
322
+ });
323
+ workflow
324
+ .command('disable')
325
+ .description('Block new starts for a deployed workflow')
326
+ .argument('<project>', 'Project name')
327
+ .argument('<workflow>', 'Workflow name or slug')
328
+ .option('-e, --env <environment>', 'Environment (production/staging/dev). Defaults to dev.', 'dev')
329
+ .action(async (projectName, workflowName, options) => {
330
+ await (0, state_1.workflowDisable)(projectName, workflowName, options);
331
+ });
276
332
  // =============================================================================
277
333
  // run <subcommand>
278
334
  // =============================================================================
@@ -458,6 +514,8 @@ schedule
458
514
  .option('--workflow <name>', 'Workflow name (if project has multiple)')
459
515
  .option('-i, --input <json>', 'JSON input to pass to scheduled runs')
460
516
  .option('-z, --timezone <iana>', 'IANA timezone the cron is evaluated in (e.g. America/Chicago); defaults to UTC')
517
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
518
+ .option('--paused', 'Create or replace the schedule disabled')
461
519
  .option('-y, --yes', 'Skip confirmation if schedule already exists')
462
520
  .action((projectName, cron, options) => {
463
521
  (0, schedule_set_1.scheduleSet)(projectName, cron, options);
@@ -466,14 +524,43 @@ schedule
466
524
  .command('list')
467
525
  .description('List schedules for a project')
468
526
  .argument('<project>', 'Project name')
469
- .action((projectName) => {
470
- (0, schedule_list_1.scheduleList)(projectName);
527
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
528
+ .action((projectName, options) => {
529
+ (0, schedule_list_1.scheduleList)(projectName, options);
530
+ });
531
+ schedule
532
+ .command('enable')
533
+ .description('Enable a schedule with a sticky operator override')
534
+ .argument('<project>', 'Project name')
535
+ .argument('<schedule-id>', 'Schedule ID')
536
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
537
+ .action((projectName, scheduleId, options) => {
538
+ (0, schedule_state_1.scheduleEnable)(projectName, scheduleId, options);
539
+ });
540
+ schedule
541
+ .command('disable')
542
+ .description('Disable a schedule with a sticky operator override')
543
+ .argument('<project>', 'Project name')
544
+ .argument('<schedule-id>', 'Schedule ID')
545
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
546
+ .action((projectName, scheduleId, options) => {
547
+ (0, schedule_state_1.scheduleDisable)(projectName, scheduleId, options);
548
+ });
549
+ schedule
550
+ .command('reset')
551
+ .description('Return a schedule to its last declared YAML configuration')
552
+ .argument('<project>', 'Project name')
553
+ .argument('<schedule-id>', 'Schedule ID')
554
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
555
+ .action((projectName, scheduleId, options) => {
556
+ (0, schedule_state_1.scheduleReset)(projectName, scheduleId, options);
471
557
  });
472
558
  schedule
473
559
  .command('delete')
474
560
  .description('Delete a schedule')
475
561
  .argument('<project>', 'Project name')
476
562
  .argument('<schedule-id>', 'Schedule ID')
563
+ .option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
477
564
  .option('-y, --yes', 'Skip confirmation prompt')
478
565
  .action((projectName, scheduleId, options) => {
479
566
  (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
- console.log(chalk_1.default.blue('\nSelect your default workspace (change anytime with `solidactions workspace set`):\n'));
290
- workspaces.forEach((ws, i) => {
291
- console.log(` ${chalk_1.default.white(`${i + 1}.`)} ${ws.name} ${chalk_1.default.gray(`(${ws.org_name}, ${ws.role})`)}`);
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
- console.log('');
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 = workspaces[index];
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
  }
@@ -3,29 +3,51 @@ 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.webhookState = webhookState;
6
7
  exports.formatTable = formatTable;
7
8
  exports.formatJson = formatJson;
8
9
  // src/utils/webhook-formatters.ts
9
10
  const chalk_1 = __importDefault(require("chalk"));
11
+ const workflow_state_1 = require("./workflow-state");
10
12
  function columnWidth(min, values) {
11
13
  return Math.max(min, ...values.map(v => v.length)) + 2;
12
14
  }
15
+ function webhookState(webhook) {
16
+ return (0, workflow_state_1.workflowEffectiveState)(webhook);
17
+ }
18
+ function colorizeState(state, width) {
19
+ const padded = state.padEnd(width);
20
+ if (state === 'on')
21
+ return chalk_1.default.green(padded);
22
+ if (state === 'off')
23
+ return chalk_1.default.red(padded);
24
+ if (state === 'blocked (project off)')
25
+ return chalk_1.default.yellow(padded);
26
+ return chalk_1.default.gray(padded);
27
+ }
13
28
  function formatTable(webhooks, opts) {
14
29
  const names = webhooks.map(w => w.workflow_name || w.workflow_slug || '?');
30
+ const states = webhooks.map(webhookState);
15
31
  const urls = webhooks.map(w => w.webhook_path_url || w.webhook_url || '?');
16
32
  const nameWidth = columnWidth(30, names);
33
+ const stateWidth = columnWidth(22, states);
17
34
  const urlWidth = columnWidth(60, urls);
18
35
  const headerPlain = opts.showSecrets
19
- ? 'WORKFLOW'.padEnd(nameWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
20
- : 'WORKFLOW'.padEnd(nameWidth) + 'URL';
21
- const dividerWidth = opts.showSecrets ? nameWidth + urlWidth + 64 : nameWidth + urlWidth;
36
+ ? 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
37
+ : 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
38
+ const dividerWidth = opts.showSecrets
39
+ ? nameWidth + stateWidth + urlWidth + 64
40
+ : nameWidth + stateWidth + urlWidth;
22
41
  const lines = [];
23
42
  lines.push(chalk_1.default.gray(headerPlain));
24
43
  lines.push(chalk_1.default.gray('-'.repeat(dividerWidth)));
25
44
  for (let i = 0; i < webhooks.length; i++) {
26
45
  const name = names[i];
46
+ const state = states[i];
27
47
  const url = urls[i];
28
- let line = name.padEnd(nameWidth) + chalk_1.default.cyan(url.padEnd(urlWidth));
48
+ let line = name.padEnd(nameWidth)
49
+ + colorizeState(state, stateWidth)
50
+ + chalk_1.default.cyan(url.padEnd(urlWidth));
29
51
  if (opts.showSecrets) {
30
52
  const secret = webhooks[i].webhook_secret || '-';
31
53
  line += chalk_1.default.gray(secret);
@@ -39,6 +61,11 @@ function formatJson(webhooks, opts) {
39
61
  const base = {
40
62
  workflow: w.workflow_name ?? w.workflow_slug ?? null,
41
63
  url: w.webhook_path_url ?? w.webhook_url ?? null,
64
+ state: webhookState(w),
65
+ enabled: w.enabled,
66
+ project_enabled: w.project_enabled,
67
+ retired: w.retired,
68
+ effective_enabled: w.effective_enabled,
42
69
  };
43
70
  if (opts.showSecrets) {
44
71
  base.secret = w.webhook_secret ?? '';
@@ -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
+ }
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.matchWorkspace = matchWorkspace;
7
7
  exports.fetchWorkspaces = fetchWorkspaces;
8
+ exports.selectWorkspaceInteractively = selectWorkspaceInteractively;
8
9
  exports.resolveWorkspaceInput = resolveWorkspaceInput;
9
10
  const axios_1 = __importDefault(require("axios"));
10
11
  const chalk_1 = __importDefault(require("chalk"));
12
+ const readline_1 = __importDefault(require("readline"));
11
13
  /**
12
14
  * Pure: given a list of workspaces and an input string, return the matching
13
15
  * workspace. Match order: id, slug, name (first match wins). Cross-tenant
@@ -41,6 +43,60 @@ async function fetchWorkspaces(config) {
41
43
  const scope = response.data.scope ?? null;
42
44
  return { workspaces: out, scope };
43
45
  }
46
+ async function selectWorkspaceInteractively(workspaces, dependencies = {}) {
47
+ if (workspaces.length === 0) {
48
+ console.log(chalk_1.default.yellow('No workspaces found. Create one at your SolidActions dashboard, then run `solidactions workspace set <name>`.'));
49
+ return undefined;
50
+ }
51
+ if (workspaces.length === 1) {
52
+ console.log(chalk_1.default.gray(`Auto-selected workspace: ${workspaces[0].name}`));
53
+ return workspaces[0];
54
+ }
55
+ const label = dependencies.label ?? ((ws) => ws.name);
56
+ console.log(chalk_1.default.blue('\nSelect your default workspace (change anytime with `solidactions workspace set`):\n'));
57
+ workspaces.forEach((ws, i) => {
58
+ console.log(` ${chalk_1.default.white(`${i + 1}.`)} ${label(ws)}`);
59
+ });
60
+ console.log('');
61
+ const rl = dependencies.question
62
+ ? null
63
+ : readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
64
+ const question = dependencies.question ?? (async () => {
65
+ if (!rl || rl.closed)
66
+ return undefined;
67
+ return new Promise((resolve) => {
68
+ let answered = false;
69
+ const onClose = () => {
70
+ if (!answered)
71
+ resolve(undefined);
72
+ };
73
+ rl.once('close', onClose);
74
+ rl.question(chalk_1.default.blue('Enter number: '), (answer) => {
75
+ answered = true;
76
+ rl.removeListener('close', onClose);
77
+ resolve(answer);
78
+ });
79
+ });
80
+ });
81
+ try {
82
+ while (true) {
83
+ const answer = await question();
84
+ if (answer === undefined) {
85
+ console.log(chalk_1.default.yellow('Workspace selection cancelled. Run `solidactions workspace list`, then '
86
+ + '`solidactions workspace set <name>` when ready.'));
87
+ return undefined;
88
+ }
89
+ const index = parseInt(answer, 10) - 1;
90
+ if (!isNaN(index) && index >= 0 && index < workspaces.length) {
91
+ return workspaces[index];
92
+ }
93
+ console.error(chalk_1.default.red('Invalid selection. Enter one of the numbers shown.'));
94
+ }
95
+ }
96
+ finally {
97
+ rl?.close();
98
+ }
99
+ }
44
100
  /**
45
101
  * High-level: fetch + match. Errors with a clear CLI message and exits
46
102
  * non-zero if no match is found.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {