@solidactions/cli 3.29.0 → 3.30.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.30.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 ?? [];
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {