@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.
@@ -3,6 +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.webhookState = webhookState;
6
7
  exports.formatTable = formatTable;
7
8
  exports.formatJson = formatJson;
8
9
  // src/utils/webhook-formatters.ts
@@ -10,22 +11,48 @@ const chalk_1 = __importDefault(require("chalk"));
10
11
  function columnWidth(min, values) {
11
12
  return Math.max(min, ...values.map(v => v.length)) + 2;
12
13
  }
14
+ function webhookState(webhook) {
15
+ if (webhook.retired === true)
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';
22
+ }
23
+ function colorizeState(state, width) {
24
+ const padded = state.padEnd(width);
25
+ if (state === 'on')
26
+ return chalk_1.default.green(padded);
27
+ if (state === 'off')
28
+ return chalk_1.default.red(padded);
29
+ if (state === 'blocked (project off)')
30
+ return chalk_1.default.yellow(padded);
31
+ return chalk_1.default.gray(padded);
32
+ }
13
33
  function formatTable(webhooks, opts) {
14
34
  const names = webhooks.map(w => w.workflow_name || w.workflow_slug || '?');
35
+ const states = webhooks.map(webhookState);
15
36
  const urls = webhooks.map(w => w.webhook_path_url || w.webhook_url || '?');
16
37
  const nameWidth = columnWidth(30, names);
38
+ const stateWidth = columnWidth(22, states);
17
39
  const urlWidth = columnWidth(60, urls);
18
40
  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;
41
+ ? 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
42
+ : 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
43
+ const dividerWidth = opts.showSecrets
44
+ ? nameWidth + stateWidth + urlWidth + 64
45
+ : nameWidth + stateWidth + urlWidth;
22
46
  const lines = [];
23
47
  lines.push(chalk_1.default.gray(headerPlain));
24
48
  lines.push(chalk_1.default.gray('-'.repeat(dividerWidth)));
25
49
  for (let i = 0; i < webhooks.length; i++) {
26
50
  const name = names[i];
51
+ const state = states[i];
27
52
  const url = urls[i];
28
- let line = name.padEnd(nameWidth) + chalk_1.default.cyan(url.padEnd(urlWidth));
53
+ let line = name.padEnd(nameWidth)
54
+ + colorizeState(state, stateWidth)
55
+ + chalk_1.default.cyan(url.padEnd(urlWidth));
29
56
  if (opts.showSecrets) {
30
57
  const secret = webhooks[i].webhook_secret || '-';
31
58
  line += chalk_1.default.gray(secret);
@@ -39,6 +66,11 @@ function formatJson(webhooks, opts) {
39
66
  const base = {
40
67
  workflow: w.workflow_name ?? w.workflow_slug ?? null,
41
68
  url: w.webhook_path_url ?? w.webhook_url ?? null,
69
+ state: webhookState(w),
70
+ enabled: w.enabled,
71
+ project_enabled: w.project_enabled,
72
+ retired: w.retired,
73
+ effective_enabled: w.effective_enabled,
42
74
  };
43
75
  if (opts.showSecrets) {
44
76
  base.secret = w.webhook_secret ?? '';
@@ -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.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "deploy"
33
33
  ],
34
34
  "scripts": {
35
- "build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs",
35
+ "build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs && node scripts/generate-command-manifest.mjs",
36
36
  "check:release": "npm run build && npm run test && npm run smoke:init",
37
37
  "prepublishOnly": "npm run build",
38
38
  "smoke:init": "node scripts/smoke-init.mjs",