@solidactions/cli 3.33.0 → 3.34.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/README.md CHANGED
@@ -331,6 +331,10 @@ revision after the build. Use `--no-git-metadata` or
331
331
  `SOLIDACTIONS_NO_GIT_METADATA=1` to opt out. Deploying a non-Git directory
332
332
  continues normally without revision metadata.
333
333
 
334
+ ### Source of truth and sandbox deploys
335
+
336
+ Every app records whether `git` or `solidactions` owns its source (Settings, "Source of truth"). When the source of truth is git, a deploy made from a sandbox (with its project-scoped token) is refused with `source_of_truth_git`; deploys from your laptop or CI are never refused. To deploy from the sandbox anyway, pass `--override-source-of-truth`: the CLI sends it on every call the deploy makes (functions, config, pages, app settings and the source archive). The deploy is stored and the app shows as drifted until you mark it reconciled in the app's settings or flip its source of truth to SolidActions. While an app is drifted, every deploy prints `Warning: this app is drifted: deployed outside git since <date>. Mark it reconciled in the app's settings, or flip its source of truth to SolidActions.` Apps whose source of truth is SolidActions never warn or refuse.
337
+
334
338
  ### Env declarations (`solidactions.yaml`)
335
339
 
336
340
  Declare the variables a workflow needs with an `env:` list in `solidactions.yaml`. Each entry uses one of four forms:
@@ -369,7 +373,7 @@ Use `solidactions <command> --help` for full flag details on any command.
369
373
  | Command | Key Flags | Description |
370
374
  |---------|-----------|-------------|
371
375
  | `project create <name>` | `-e` | Create an empty project (no source/build); `-e` defaults to `production` |
372
- | `project deploy <name> [path]` | `-e`, `--create`, `--config-only`, `--paused`, `--no-git-metadata` | Deploy or sync config only; optionally land YAML schedules paused |
376
+ | `project deploy <name> [path]` | `-e`, `--create`, `--config-only`, `--paused`, `--override-source-of-truth`, `--no-git-metadata` | Deploy or sync config only; optionally land YAML schedules paused; deploy from a sandbox over a git-owned app |
373
377
  | `project enable <project>` | `-e` (default `dev`) | Allow new starts through this project gate |
374
378
  | `project disable <project>` | `-e` (default `dev`) | Block new root starts without cancelling existing roots |
375
379
  | `project view <project>` | `-e` (default `dev`), `--json` | View status, `Enabled: on|off`, and client-reported deployed revision, incl. an `N behind origin/<branch> at deploy` drift clause when the deployment is behind the default branch |
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "cli_name": "solidactions",
4
- "cli_version": "3.33.0",
4
+ "cli_version": "3.34.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -1694,6 +1694,18 @@
1694
1694
  "negated": false,
1695
1695
  "hidden": false
1696
1696
  },
1697
+ {
1698
+ "flags": "--override-source-of-truth",
1699
+ "long": "--override-source-of-truth",
1700
+ "short": null,
1701
+ "description": "Deploy from a sandbox even though the app's source of truth is git; the app shows as drifted until you mark it reconciled or flip its source of truth to SolidActions",
1702
+ "required": false,
1703
+ "value_required": false,
1704
+ "value_optional": false,
1705
+ "variadic": false,
1706
+ "negated": false,
1707
+ "hidden": false
1708
+ },
1697
1709
  {
1698
1710
  "flags": "--no-cache",
1699
1711
  "long": "--no-cache",
@@ -32,6 +32,7 @@ const app_sync_1 = require("../utils/app-sync");
32
32
  const pages_sync_1 = require("../utils/pages-sync");
33
33
  const functions_sync_1 = require("../utils/functions-sync");
34
34
  const api_1 = require("../utils/api");
35
+ const source_of_truth_1 = require("../utils/source-of-truth");
35
36
  const host_display_1 = require("../utils/host-display");
36
37
  const deploy_ignore_1 = require("../utils/deploy-ignore");
37
38
  const sandbox_base_1 = require("../utils/sandbox-base");
@@ -290,7 +291,7 @@ function formatSyncYamlWarnings(warnings) {
290
291
  * (PM round #1127 finding 14: a failed sync must never be reported as
291
292
  * success by the caller).
292
293
  */
293
- async function pushYamlDeclarations(config, projectSlug, yamlConfig, baseSourceHash) {
294
+ async function pushYamlDeclarations(config, projectSlug, yamlConfig, baseSourceHash, overrideSourceOfTruth) {
294
295
  const parsedVars = (0, env_1.parseYamlEnvVars)(yamlConfig);
295
296
  // Build the declarations array
296
297
  const declarations = parsedVars.map(v => ({
@@ -301,7 +302,7 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig, baseSourceH
301
302
  yaml_default_docs_path: v.docsPath,
302
303
  source: 'yaml',
303
304
  }));
304
- const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations, ...(baseSourceHash !== undefined ? { base_source_hash: baseSourceHash } : {}) }, {
305
+ const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, (0, source_of_truth_1.withOverrideSourceOfTruth)({ declarations, ...(baseSourceHash !== undefined ? { base_source_hash: baseSourceHash } : {}) }, overrideSourceOfTruth), {
305
306
  headers: (0, api_1.getApiHeaders)(config, 'application/json'),
306
307
  });
307
308
  // Non-fatal: a warning means a declared resource doesn't exist in the
@@ -623,12 +624,16 @@ async function deploy(projectName, sourcePath, options = {}) {
623
624
  process.exit(1);
624
625
  }
625
626
  try {
626
- await pushYamlDeclarations(config, projectSlug, yamlConfig, guardedBaseWire ?? undefined);
627
+ await pushYamlDeclarations(config, projectSlug, yamlConfig, guardedBaseWire ?? undefined, options.overrideSourceOfTruth);
627
628
  }
628
629
  catch (error) {
630
+ const refusal = (0, source_of_truth_1.sourceOfTruthRefusal)(error.response?.status, error.response?.data);
629
631
  if (error.response?.status === 409 && error.response.data?.code === 'stale_base') {
630
632
  console.error(chalk_1.default.red(staleBaseLine()));
631
633
  }
634
+ else if (refusal !== null) {
635
+ console.error(chalk_1.default.red(refusal));
636
+ }
632
637
  else if (error.response?.status === 401) {
633
638
  console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
634
639
  }
@@ -677,11 +682,16 @@ async function deploy(projectName, sourcePath, options = {}) {
677
682
  const functionsPayload = (0, functions_sync_1.buildFunctionsSyncPayload)(functionFiles, functionSources, codeRef);
678
683
  if (guardedBaseWire !== null)
679
684
  functionsPayload.base_source_hash = guardedBaseWire;
680
- const functionsResult = await (0, functions_sync_1.syncFunctions)(config, projectSlug, functionsPayload);
685
+ const functionsResult = await (0, functions_sync_1.syncFunctions)(config, projectSlug, (0, source_of_truth_1.withOverrideSourceOfTruth)(functionsPayload, options.overrideSourceOfTruth));
681
686
  if (functionsResult.httpStatus === 409 && functionsResult.body?.code === 'stale_base') {
682
687
  console.error(chalk_1.default.red(staleBaseLine()));
683
688
  process.exit(1);
684
689
  }
690
+ const functionsRefusal = (0, source_of_truth_1.sourceOfTruthRefusal)(functionsResult.httpStatus, functionsResult.body);
691
+ if (functionsRefusal !== null) {
692
+ console.error(chalk_1.default.red(functionsRefusal));
693
+ process.exit(1);
694
+ }
685
695
  const functionRows = functionsResult.body?.functions ?? [];
686
696
  const retiredFunctions = functionsResult.body?.retired ?? [];
687
697
  const retireErrors = functionsResult.body?.retire_errors ?? [];
@@ -696,7 +706,7 @@ async function deploy(projectName, sourcePath, options = {}) {
696
706
  let yamlSyncFailed = false;
697
707
  if (yamlConfig) {
698
708
  try {
699
- await pushYamlDeclarations(config, projectSlug, yamlConfig);
709
+ await pushYamlDeclarations(config, projectSlug, yamlConfig, undefined, options.overrideSourceOfTruth);
700
710
  }
701
711
  catch (error) {
702
712
  yamlSyncFailed = true;
@@ -710,7 +720,7 @@ async function deploy(projectName, sourcePath, options = {}) {
710
720
  }
711
721
  for (const warning of (0, app_sync_1.emptyColourWarnings)(yamlConfig?.app))
712
722
  console.log(chalk_1.default.yellow(warning));
713
- const appResult = await (0, app_sync_1.syncApp)(config, projectSlug, (0, app_sync_1.buildAppSyncPayload)(yamlConfig ?? {}));
723
+ const appResult = await (0, app_sync_1.syncApp)(config, projectSlug, (0, source_of_truth_1.withOverrideSourceOfTruth)((0, app_sync_1.buildAppSyncPayload)(yamlConfig ?? {}), options.overrideSourceOfTruth));
714
724
  const appSummary = (0, app_sync_1.formatAppSync)(appResult, yamlConfig?.app != null);
715
725
  if (appResult.httpStatus === 401)
716
726
  console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
@@ -722,7 +732,7 @@ async function deploy(projectName, sourcePath, options = {}) {
722
732
  }
723
733
  yamlSyncFailed = yamlSyncFailed || appSummary.failed;
724
734
  const payload = (0, pages_sync_1.buildPagesSyncPayload)(pageFiles, pageBodies, deploymentId, codeRef, bundledPages);
725
- const result = await (0, pages_sync_1.syncPages)(config, projectSlug, payload);
735
+ const result = await (0, pages_sync_1.syncPages)(config, projectSlug, (0, source_of_truth_1.withOverrideSourceOfTruth)(payload, options.overrideSourceOfTruth));
726
736
  const rows = result.body?.pages ?? [];
727
737
  const trashed = result.body?.trashed ?? [];
728
738
  const trashErrors = result.body?.trash_errors ?? [];
@@ -789,6 +799,9 @@ async function deploy(projectName, sourcePath, options = {}) {
789
799
  if (options.paused) {
790
800
  form.append('paused', '1');
791
801
  }
802
+ if (options.overrideSourceOfTruth === true) {
803
+ form.append('override_source_of_truth', '1');
804
+ }
792
805
  console.log(chalk_1.default.yellow('Uploading...'));
793
806
  if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
794
807
  process.stderr.write(`[deploy-debug] POST ${(0, host_display_1.displayHost)(config.host)}/api/v1/projects/${projectSlug}/deploy (workspace=${config.workspaceId ?? '(none)'})\n`);
@@ -809,6 +822,9 @@ async function deploy(projectName, sourcePath, options = {}) {
809
822
  console.log(chalk_1.default.yellow('The server stored different bytes than this deploy uploaded; base.json was left unchanged.'));
810
823
  }
811
824
  }
825
+ for (const line of (0, source_of_truth_1.driftWarningLines)(deployResponse.data)) {
826
+ console.log(chalk_1.default.yellow(line));
827
+ }
812
828
  if (!yamlConfig?.workflows) {
813
829
  console.log(chalk_1.default.green('Source archived.'));
814
830
  cleanupArchive();
@@ -892,9 +908,13 @@ async function deploy(projectName, sourcePath, options = {}) {
892
908
  catch (error) {
893
909
  console.error(chalk_1.default.red('Deployment failed:'));
894
910
  if (error.response) {
911
+ const refusal = (0, source_of_truth_1.sourceOfTruthRefusal)(error.response.status, error.response.data);
895
912
  if (error.response.status === 409 && error.response.data?.code === 'stale_base') {
896
913
  console.error(chalk_1.default.red(staleBaseLine()));
897
914
  }
915
+ else if (refusal !== null) {
916
+ console.error(chalk_1.default.red(refusal));
917
+ }
898
918
  else if (error.response.status === 404) {
899
919
  console.error("Project not found.");
900
920
  }
package/dist/index.js CHANGED
@@ -477,6 +477,7 @@ project
477
477
  .option('--create', 'Create environment project if it doesn\'t exist')
478
478
  .option('--config-only', 'Sync YAML env declarations without building/deploying')
479
479
  .option('--paused', 'Deploy with all YAML-declared schedules initially paused')
480
+ .option('--override-source-of-truth', 'Deploy from a sandbox even though the app\'s source of truth is git; the app shows as drifted until you mark it reconciled or flip its source of truth to SolidActions')
480
481
  .option('--no-cache', 'Force a fresh build, bypassing all build caches')
481
482
  .option('--force-rebuild', 'Force a fresh build, bypassing all build caches (alias for --no-cache)')
482
483
  .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')
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withOverrideSourceOfTruth = withOverrideSourceOfTruth;
4
+ exports.sourceOfTruthRefusal = sourceOfTruthRefusal;
5
+ exports.driftWarningLines = driftWarningLines;
6
+ const source_provenance_1 = require("./source-provenance");
7
+ /**
8
+ * Adds `override_source_of_truth: 1` to a JSON body only when the flag is set.
9
+ * When it is not set the SAME payload object comes back, so a deploy without
10
+ * the flag sends byte-identical bodies to today (design invariant 5).
11
+ */
12
+ function withOverrideSourceOfTruth(payload, override) {
13
+ return override === true ? { ...payload, override_source_of_truth: 1 } : payload;
14
+ }
15
+ /**
16
+ * The printable server message of a 409 `source_of_truth_git` refusal, or null
17
+ * when the response is anything else. The server text already names the repo
18
+ * and the override flag, so it is printed as is.
19
+ */
20
+ function sourceOfTruthRefusal(status, body) {
21
+ if (status !== 409 || body === null || typeof body !== 'object' || Array.isArray(body))
22
+ return null;
23
+ const record = body;
24
+ if (record.code !== 'source_of_truth_git')
25
+ return null;
26
+ return (0, source_provenance_1.sanitizeDisplayText)(record.message)
27
+ ?? 'This app\'s source of truth is git. Re-run with --override-source-of-truth to deploy from the sandbox anyway.';
28
+ }
29
+ /** One printable line per `warnings[]` entry with code `drift`; nothing for any other shape. */
30
+ function driftWarningLines(data) {
31
+ const warnings = data !== null && typeof data === 'object' ? data.warnings : undefined;
32
+ if (!Array.isArray(warnings))
33
+ return [];
34
+ return warnings.flatMap((warning) => {
35
+ if (warning === null || typeof warning !== 'object' || warning.code !== 'drift')
36
+ return [];
37
+ const since = (0, source_provenance_1.sanitizeDisplayText)(warning.since, 64) ?? 'an unknown date';
38
+ return [`Warning: this app is drifted: deployed outside git since ${since}. Mark it reconciled in the app's settings, or flip its source of truth to SolidActions.`];
39
+ });
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.33.0",
3
+ "version": "3.34.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {