@solidactions/cli 3.29.0 → 3.31.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "cli_name": "solidactions",
4
- "cli_version": "3.29.0",
4
+ "cli_version": "3.31.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -28,6 +28,7 @@ const js_yaml_1 = __importDefault(require("js-yaml"));
28
28
  const prompts_1 = __importDefault(require("prompts"));
29
29
  const env_1 = require("../utils/env");
30
30
  const validate_items_1 = require("../utils/validate-items");
31
+ const app_sync_1 = require("../utils/app-sync");
31
32
  const pages_sync_1 = require("../utils/pages-sync");
32
33
  const functions_sync_1 = require("../utils/functions-sync");
33
34
  const api_1 = require("../utils/api");
@@ -674,6 +675,19 @@ async function deploy(projectName, sourcePath, options = {}) {
674
675
  }
675
676
  }
676
677
  }
678
+ for (const warning of (0, app_sync_1.emptyColourWarnings)(yamlConfig?.app))
679
+ console.log(chalk_1.default.yellow(warning));
680
+ const appResult = await (0, app_sync_1.syncApp)(config, projectSlug, (0, app_sync_1.buildAppSyncPayload)(yamlConfig ?? {}));
681
+ const appSummary = (0, app_sync_1.formatAppSync)(appResult, yamlConfig?.app != null);
682
+ if (appResult.httpStatus === 401)
683
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
684
+ for (const line of appSummary.lines) {
685
+ if (appSummary.failed)
686
+ console.error(chalk_1.default.red(line));
687
+ else
688
+ console.log(line.startsWith('✓') ? chalk_1.default.green(line) : line);
689
+ }
690
+ yamlSyncFailed = yamlSyncFailed || appSummary.failed;
677
691
  const payload = (0, pages_sync_1.buildPagesSyncPayload)(pageFiles, pageBodies, deploymentId, codeRef);
678
692
  const result = await (0, pages_sync_1.syncPages)(config, projectSlug, payload);
679
693
  const rows = result.body?.pages ?? [];
@@ -3,12 +3,20 @@ 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.webhookListParams = webhookListParams;
6
7
  exports.webhookList = webhookList;
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_ref_1 = require("../utils/project-ref");
11
12
  const webhook_formatters_1 = require("../utils/webhook-formatters");
13
+ function webhookListParams(options) {
14
+ const params = { include: 'functions' };
15
+ if (options.showSecrets) {
16
+ params.show_secrets = 'true';
17
+ }
18
+ return params;
19
+ }
12
20
  async function webhookList(projectName, options = {}) {
13
21
  const format = options.format ?? 'table';
14
22
  if (format !== 'table' && format !== 'json') {
@@ -22,10 +30,7 @@ async function webhookList(projectName, options = {}) {
22
30
  }
23
31
  try {
24
32
  const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
25
- const params = {};
26
- if (options.showSecrets) {
27
- params.show_secrets = 'true';
28
- }
33
+ const params = webhookListParams(options);
29
34
  const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
30
35
  headers: (0, api_1.getApiHeaders)(config),
31
36
  params,
@@ -4,24 +4,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.formatSecretOutput = formatSecretOutput;
7
+ exports.formatSecretJson = formatSecretJson;
7
8
  exports.webhookSecret = webhookSecret;
8
9
  const axios_1 = __importDefault(require("axios"));
9
10
  const chalk_1 = __importDefault(require("chalk"));
10
11
  const api_1 = require("../utils/api");
11
12
  const project_ref_1 = require("../utils/project-ref");
13
+ function workflowRowsOnly(rows) {
14
+ return rows.filter((r) => r.kind !== 'function');
15
+ }
12
16
  function formatSecretOutput(rows, workflowFilter) {
17
+ const workflows = workflowRowsOnly(rows);
13
18
  if (workflowFilter) {
14
- const match = rows.find((r) => r.workflow_name === workflowFilter);
19
+ const match = workflows.find((r) => r.workflow_name === workflowFilter);
15
20
  if (!match)
16
21
  return `No webhook named "${workflowFilter}" found.`;
17
22
  return match.webhook_secret ?? '(secret not returned — check your access level)';
18
23
  }
19
- if (rows.length === 1) {
20
- return rows[0].webhook_secret ?? '(secret not returned — check your access level)';
24
+ if (workflows.length === 1) {
25
+ return workflows[0].webhook_secret ?? '(secret not returned — check your access level)';
21
26
  }
22
- const lines = rows.map((r) => `${(r.workflow_name ?? '?').padEnd(32)}${r.webhook_secret ?? '(none)'}`);
27
+ const lines = workflows.map((r) => `${(r.workflow_name ?? '?').padEnd(32)}${r.webhook_secret ?? '(none)'}`);
23
28
  return ['WORKFLOW'.padEnd(32) + 'SECRET', '-'.repeat(80), ...lines].join('\n');
24
29
  }
30
+ function formatSecretJson(rows, workflowFilter) {
31
+ const workflows = workflowRowsOnly(rows);
32
+ const out = workflowFilter
33
+ ? workflows
34
+ .filter((r) => r.workflow_name === workflowFilter)
35
+ .map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
36
+ : workflows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
37
+ return JSON.stringify(out, null, 2);
38
+ }
25
39
  async function webhookSecret(projectName, options = {}) {
26
40
  const format = options.format ?? 'text';
27
41
  if (format !== 'text' && format !== 'json') {
@@ -39,18 +53,13 @@ async function webhookSecret(projectName, options = {}) {
39
53
  headers: (0, api_1.getApiHeaders)(config),
40
54
  params: { show_secrets: 'true' },
41
55
  });
42
- const rows = response.data.data ?? [];
56
+ const rows = workflowRowsOnly(response.data.data ?? []);
43
57
  if (rows.length === 0) {
44
58
  console.error(chalk_1.default.yellow(`No webhook workflows found for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}.`));
45
59
  process.exit(1);
46
60
  }
47
61
  if (format === 'json') {
48
- const out = options.workflow
49
- ? rows
50
- .filter((r) => r.workflow_name === options.workflow)
51
- .map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
52
- : rows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
53
- console.log(JSON.stringify(out, null, 2));
62
+ console.log(formatSecretJson(rows, options.workflow));
54
63
  return;
55
64
  }
56
65
  console.log(formatSecretOutput(rows, options.workflow));
@@ -0,0 +1,102 @@
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.buildAppSyncPayload = buildAppSyncPayload;
7
+ exports.emptyColourWarnings = emptyColourWarnings;
8
+ exports.formatAppSync = formatAppSync;
9
+ exports.syncApp = syncApp;
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const api_1 = require("./api");
12
+ const PALETTE_KEYS = ['sidebar_bg', 'sidebar_fg', 'accent', 'mark'];
13
+ const THEME_MODES = ['light', 'dark'];
14
+ /** The `app:` block exactly as the yaml holds it; the server is the only validator. */
15
+ function buildAppSyncPayload(config) {
16
+ return { app: (config.app ?? null) };
17
+ }
18
+ /**
19
+ * One warning per palette key present in the yaml with a null value: an
20
+ * unquoted #hex is a yaml comment, so the value arrives as null.
21
+ */
22
+ function emptyColourWarnings(app) {
23
+ const theme = isRecord(app) ? app.theme : null;
24
+ if (!isRecord(theme))
25
+ return [];
26
+ const warnings = [];
27
+ for (const mode of THEME_MODES) {
28
+ const palette = theme[mode];
29
+ if (!isRecord(palette))
30
+ continue;
31
+ for (const key of PALETTE_KEYS) {
32
+ if (key in palette && palette[key] === null) {
33
+ warnings.push(`app.theme.${mode}.${key} is empty: quote hex colours in yaml ("#e0a458")`);
34
+ }
35
+ }
36
+ }
37
+ return warnings;
38
+ }
39
+ function formatAppSync(result, sentApp) {
40
+ if (result.transportError) {
41
+ return { lines: ['App settings sync FAILED: could not reach the server'], failed: true };
42
+ }
43
+ const status = result.httpStatus;
44
+ if (status !== null && status >= 200 && status < 300) {
45
+ return { lines: successLines(result.body, sentApp), failed: false };
46
+ }
47
+ if (status === 404) {
48
+ return sentApp
49
+ ? { lines: ['This server does not support app: yet; upgrade the platform'], failed: true }
50
+ : { lines: [], failed: false };
51
+ }
52
+ if (status === 422) {
53
+ return { lines: ['App settings refused:', ...errorLines(result.body?.errors)], failed: true };
54
+ }
55
+ if (status === 401) {
56
+ return { lines: ['App settings sync FAILED: not signed in'], failed: true };
57
+ }
58
+ const message = typeof result.body?.message === 'string' && result.body.message !== '' ? result.body.message : `HTTP ${status}`;
59
+ return { lines: [`App settings sync FAILED: ${message}`], failed: true };
60
+ }
61
+ function successLines(body, sentApp) {
62
+ switch (body?.outcome) {
63
+ case 'set':
64
+ return [`✓ App settings applied (sidebar: ${body.app?.sidebar ?? 'shown'}, theme: ${themeSummary(body.app?.theme)})`];
65
+ case 'unchanged':
66
+ return sentApp ? ['✓ App settings unchanged'] : [];
67
+ case 'cleared':
68
+ return ['✓ App settings cleared (the app: block was removed)'];
69
+ default:
70
+ return [];
71
+ }
72
+ }
73
+ function themeSummary(theme) {
74
+ if (!isRecord(theme))
75
+ return 'none';
76
+ const light = isRecord(theme.light);
77
+ const dark = isRecord(theme.dark);
78
+ if (light && dark)
79
+ return 'light+dark';
80
+ if (light)
81
+ return 'light';
82
+ if (dark)
83
+ return 'dark';
84
+ return 'none';
85
+ }
86
+ function errorLines(errors) {
87
+ if (!isRecord(errors))
88
+ return [];
89
+ return Object.entries(errors).flatMap(([field, messages]) => (Array.isArray(messages) ? messages : [messages]).map(message => ` ${field}: ${String(message)}`));
90
+ }
91
+ function isRecord(value) {
92
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
93
+ }
94
+ async function syncApp(config, projectSlug, payload) {
95
+ try {
96
+ const response = await axios_1.default.put(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/app/sync`, payload, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
97
+ return { httpStatus: response.status, transportError: false, body: response.data };
98
+ }
99
+ catch (error) {
100
+ return { httpStatus: error.response?.status ?? null, transportError: !error.response, body: error.response?.data ?? null };
101
+ }
102
+ }
@@ -12,7 +12,21 @@ const workflow_state_1 = require("./workflow-state");
12
12
  function columnWidth(min, values) {
13
13
  return Math.max(min, ...values.map(v => v.length)) + 2;
14
14
  }
15
+ function isFunctionRow(webhook) {
16
+ return webhook.kind === 'function';
17
+ }
15
18
  function webhookState(webhook) {
19
+ if (isFunctionRow(webhook)) {
20
+ if (webhook.retired === true)
21
+ return 'retired';
22
+ if (webhook.enabled === false)
23
+ return 'off';
24
+ if (webhook.project_enabled === false)
25
+ return 'blocked (project off)';
26
+ if (webhook.effective_enabled === false)
27
+ return 'not live';
28
+ return 'on';
29
+ }
16
30
  return (0, workflow_state_1.workflowEffectiveState)(webhook);
17
31
  }
18
32
  function colorizeState(state, width) {
@@ -26,26 +40,30 @@ function colorizeState(state, width) {
26
40
  return chalk_1.default.gray(padded);
27
41
  }
28
42
  function formatTable(webhooks, opts) {
29
- const names = webhooks.map(w => w.workflow_name || w.workflow_slug || '?');
43
+ const names = webhooks.map(w => w.name ?? w.workflow_name ?? w.slug ?? w.workflow_slug ?? '?');
44
+ const kinds = webhooks.map(w => w.kind ?? 'workflow');
30
45
  const states = webhooks.map(webhookState);
31
46
  const urls = webhooks.map(w => w.webhook_path_url || w.webhook_url || '?');
32
47
  const nameWidth = columnWidth(30, names);
48
+ const kindWidth = columnWidth(8, kinds);
33
49
  const stateWidth = columnWidth(22, states);
34
50
  const urlWidth = columnWidth(60, urls);
35
51
  const headerPlain = opts.showSecrets
36
- ? 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
37
- : 'WORKFLOW'.padEnd(nameWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
52
+ ? 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
53
+ : 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
38
54
  const dividerWidth = opts.showSecrets
39
- ? nameWidth + stateWidth + urlWidth + 64
40
- : nameWidth + stateWidth + urlWidth;
55
+ ? nameWidth + kindWidth + stateWidth + urlWidth + 64
56
+ : nameWidth + kindWidth + stateWidth + urlWidth;
41
57
  const lines = [];
42
58
  lines.push(chalk_1.default.gray(headerPlain));
43
59
  lines.push(chalk_1.default.gray('-'.repeat(dividerWidth)));
44
60
  for (let i = 0; i < webhooks.length; i++) {
45
61
  const name = names[i];
62
+ const kind = kinds[i];
46
63
  const state = states[i];
47
64
  const url = urls[i];
48
65
  let line = name.padEnd(nameWidth)
66
+ + kind.padEnd(kindWidth)
49
67
  + colorizeState(state, stateWidth)
50
68
  + chalk_1.default.cyan(url.padEnd(urlWidth));
51
69
  if (opts.showSecrets) {
@@ -58,7 +76,11 @@ function formatTable(webhooks, opts) {
58
76
  }
59
77
  function formatJson(webhooks, opts) {
60
78
  const rows = webhooks.map(w => {
79
+ const kind = w.kind ?? 'workflow';
61
80
  const base = {
81
+ kind,
82
+ name: w.name ?? w.workflow_name ?? null,
83
+ slug: w.slug ?? w.workflow_slug ?? null,
62
84
  workflow: w.workflow_name ?? w.workflow_slug ?? null,
63
85
  url: w.webhook_path_url ?? w.webhook_url ?? null,
64
86
  state: webhookState(w),
@@ -67,6 +89,9 @@ function formatJson(webhooks, opts) {
67
89
  retired: w.retired,
68
90
  effective_enabled: w.effective_enabled,
69
91
  };
92
+ if (kind === 'function') {
93
+ base.status = w.status ?? null;
94
+ }
70
95
  if (opts.showSecrets) {
71
96
  base.secret = w.webhook_secret ?? '';
72
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.29.0",
3
+ "version": "3.31.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {