@solidactions/cli 3.28.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.28.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");
@@ -266,6 +267,12 @@ function formatSyncYamlWarnings(warnings) {
266
267
  return `${envName} → no workspace database named "${target}"`;
267
268
  }
268
269
  }
270
+ // Docs warnings carry their own full sentence; print it as is.
271
+ if ((warning?.reason === 'docs_path_not_found' || warning?.reason === 'docs_not_granted')
272
+ && typeof warning.message === 'string'
273
+ && warning.message !== '') {
274
+ return warning.message;
275
+ }
269
276
  return `${envName} → unresolved (${warning?.reason ?? 'unknown reason'})`;
270
277
  });
271
278
  }
@@ -289,6 +296,7 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
289
296
  yaml_default_global_key: v.mappedTo,
290
297
  yaml_default_oauth_name: v.oauthName,
291
298
  yaml_default_database_name: v.databaseName,
299
+ yaml_default_docs_path: v.docsPath,
292
300
  source: 'yaml',
293
301
  }));
294
302
  const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
@@ -311,7 +319,11 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
311
319
  for (const warning of warnings) {
312
320
  console.log(chalk_1.default.yellow(` ⚠ ${warning}`));
313
321
  }
314
- if (warnings.length > 0) {
322
+ // A docs warning does not hold the variable back (it still arrives, with
323
+ // level "none"), so the footer is only true when some warning is not a docs one.
324
+ const hasNonDocsWarning = Array.isArray(rawWarnings)
325
+ && rawWarnings.some((w) => w?.reason !== 'docs_path_not_found' && w?.reason !== 'docs_not_granted');
326
+ if (hasNonDocsWarning) {
315
327
  console.log(chalk_1.default.yellow(" These variables won't get a value from this declaration until the named resource exists (a value set in the dashboard still applies)."));
316
328
  }
317
329
  }
@@ -663,6 +675,19 @@ async function deploy(projectName, sourcePath, options = {}) {
663
675
  }
664
676
  }
665
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;
666
691
  const payload = (0, pages_sync_1.buildPagesSyncPayload)(pageFiles, pageBodies, deploymentId, codeRef);
667
692
  const result = await (0, pages_sync_1.syncPages)(config, projectSlug, payload);
668
693
  const rows = result.body?.pages ?? [];
@@ -516,6 +516,12 @@ async function runDev(opts) {
516
516
  // mapping as "had no value in this env and was skipped" (#140).
517
517
  databaseMappings.push(pv);
518
518
  }
519
+ else if (pv.source_type === 'docs_node' && pv.resolved_value != null) {
520
+ // A docs binding arrives as the run-env JSON ({path, kind, id, level}),
521
+ // the same string a deployed run reads; pass it through, never count
522
+ // it as dropped.
523
+ vars[pv.env_name] = pv.resolved_value;
524
+ }
519
525
  else if (pv.resolved_value != null) {
520
526
  vars[pv.env_name] = pv.resolved_value;
521
527
  }
@@ -76,6 +76,11 @@ async function envList(projectName, options = {}) {
76
76
  || 'Database';
77
77
  }
78
78
  }
79
+ else if (mapping.source_type === 'docs_node') {
80
+ value = '-';
81
+ type = 'docs';
82
+ source = mapping.yaml_default_docs_path || 'Docs';
83
+ }
79
84
  else if (mapping.global_variable_key) {
80
85
  type = 'global';
81
86
  source = mapping.global_variable_key;
@@ -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/dist/utils/env.js CHANGED
@@ -52,6 +52,7 @@ function parseEnvFile(filePath) {
52
52
  * - VAR_NAME: GLOBAL -> { key: "VAR_NAME", mappedTo: "GLOBAL" }
53
53
  * - VAR_NAME:\n oauth: "Name" -> { key: "VAR_NAME", oauthName: "Name" }
54
54
  * - VAR_NAME:\n database: "Name" -> { key: "VAR_NAME", databaseName: "Name" }
55
+ * - VAR_NAME:\n docs: "Folder/Path" -> { key: "VAR_NAME", docsPath: "Folder/Path" }
55
56
  */
56
57
  function parseYamlEnvVars(config) {
57
58
  const parsedVars = [];
@@ -61,11 +62,11 @@ function parseYamlEnvVars(config) {
61
62
  for (const item of config.env) {
62
63
  if (typeof item === 'string') {
63
64
  // Simple string: - VAR_NAME (declared only, needs configuration)
64
- parsedVars.push({ key: item, mappedTo: null, oauthName: null, databaseName: null });
65
+ parsedVars.push({ key: item, mappedTo: null, oauthName: null, databaseName: null, docsPath: null });
65
66
  }
66
67
  else if (typeof item === 'object' && item !== null) {
67
68
  // Object: - VAR_NAME: GLOBAL_NAME, - VAR_NAME: { oauth: connection-name },
68
- // or - VAR_NAME: { database: database-name }
69
+ // - VAR_NAME: { database: database-name }, or - VAR_NAME: { docs: folder/or/doc/path }
69
70
  const keys = Object.keys(item);
70
71
  if (keys.length === 1) {
71
72
  const key = keys[0];
@@ -74,16 +75,22 @@ function parseYamlEnvVars(config) {
74
75
  if (typeof value.oauth !== 'string' || !value.oauth) {
75
76
  throw new Error(`Invalid env config for ${key}: 'oauth' must be a non-empty string`);
76
77
  }
77
- parsedVars.push({ key, mappedTo: null, oauthName: value.oauth, databaseName: null });
78
+ parsedVars.push({ key, mappedTo: null, oauthName: value.oauth, databaseName: null, docsPath: null });
78
79
  }
79
80
  else if (typeof value === 'object' && value !== null && 'database' in value) {
80
81
  if (typeof value.database !== 'string' || !value.database) {
81
82
  throw new Error(`Invalid env config for ${key}: 'database' must be a non-empty string`);
82
83
  }
83
- parsedVars.push({ key, mappedTo: null, oauthName: null, databaseName: value.database });
84
+ parsedVars.push({ key, mappedTo: null, oauthName: null, databaseName: value.database, docsPath: null });
85
+ }
86
+ else if (typeof value === 'object' && value !== null && 'docs' in value) {
87
+ if (typeof value.docs !== 'string' || !value.docs.trim()) {
88
+ throw new Error(`Invalid env config for ${key}: 'docs' must be a non-empty string`);
89
+ }
90
+ parsedVars.push({ key, mappedTo: null, oauthName: null, databaseName: null, docsPath: value.docs });
84
91
  }
85
92
  else {
86
- parsedVars.push({ key, mappedTo: value || null, oauthName: null, databaseName: null });
93
+ parsedVars.push({ key, mappedTo: value || null, oauthName: null, databaseName: null, docsPath: null });
87
94
  }
88
95
  }
89
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.28.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": {
@@ -54,7 +54,7 @@
54
54
  "tar": "^7.5.22"
55
55
  },
56
56
  "devDependencies": {
57
- "@solidactions/sdk": "^0.8.0",
57
+ "@solidactions/sdk": "^0.10.0",
58
58
  "@types/archiver": "^8.0.0",
59
59
  "@types/fs-extra": "^11.0.0",
60
60
  "@types/js-yaml": "^4.0.9",