@solidactions/cli 3.31.0 → 3.32.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.31.0",
4
+ "cli_version": "3.32.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -3,7 +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.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = void 0;
6
+ exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = exports.archiveMd5 = void 0;
7
7
  exports.validateProject = validateProject;
8
8
  exports.cacheBusterEntry = cacheBusterEntry;
9
9
  exports.projectStatusUrl = projectStatusUrl;
@@ -34,6 +34,7 @@ const functions_sync_1 = require("../utils/functions-sync");
34
34
  const api_1 = require("../utils/api");
35
35
  const host_display_1 = require("../utils/host-display");
36
36
  const deploy_ignore_1 = require("../utils/deploy-ignore");
37
+ const sandbox_base_1 = require("../utils/sandbox-base");
37
38
  const slug_1 = require("../utils/slug");
38
39
  const project_ref_1 = require("../utils/project-ref");
39
40
  const skills_1 = require("../utils/skills");
@@ -41,6 +42,7 @@ const tar_archive_1 = require("../utils/tar-archive");
41
42
  const deploy_status_poll_1 = require("../utils/deploy-status-poll");
42
43
  const source_provenance_1 = require("../utils/source-provenance");
43
44
  const project_view_1 = require("./project-view");
45
+ exports.archiveMd5 = null;
44
46
  /** Printed when a deploy target has no SolidActions skill files installed. */
45
47
  exports.SKILLS_TIP_LINES = [
46
48
  'Tip: no SolidActions skill files found (.claude/skills/solidactions-*). Your AI assistant',
@@ -288,7 +290,7 @@ function formatSyncYamlWarnings(warnings) {
288
290
  * (PM round #1127 finding 14: a failed sync must never be reported as
289
291
  * success by the caller).
290
292
  */
291
- async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
293
+ async function pushYamlDeclarations(config, projectSlug, yamlConfig, baseSourceHash) {
292
294
  const parsedVars = (0, env_1.parseYamlEnvVars)(yamlConfig);
293
295
  // Build the declarations array
294
296
  const declarations = parsedVars.map(v => ({
@@ -299,7 +301,7 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
299
301
  yaml_default_docs_path: v.docsPath,
300
302
  source: 'yaml',
301
303
  }));
302
- const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
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 } : {}) }, {
303
305
  headers: (0, api_1.getApiHeaders)(config, 'application/json'),
304
306
  });
305
307
  // Non-fatal: a warning means a declared resource doesn't exist in the
@@ -591,6 +593,10 @@ async function deploy(projectName, sourcePath, options = {}) {
591
593
  process.exit(1);
592
594
  }
593
595
  }
596
+ const base = (0, sandbox_base_1.readSandboxBase)(sourceDir);
597
+ const guardedBase = base?.slug === projectSlug ? base : null;
598
+ const guardedBaseWire = guardedBase ? (0, sandbox_base_1.baseWireValue)(guardedBase) : null;
599
+ const staleBaseLine = () => `The dev copy moved since you pulled. Run "solidactions project pull ${projectSlug} . --yes" and redo your change.`;
594
600
  // --config-only: sync YAML env declarations without building
595
601
  if (options.configOnly) {
596
602
  if (!yamlConfig) {
@@ -598,10 +604,13 @@ async function deploy(projectName, sourcePath, options = {}) {
598
604
  process.exit(1);
599
605
  }
600
606
  try {
601
- await pushYamlDeclarations(config, projectSlug, yamlConfig);
607
+ await pushYamlDeclarations(config, projectSlug, yamlConfig, guardedBaseWire ?? undefined);
602
608
  }
603
609
  catch (error) {
604
- if (error.response?.status === 401) {
610
+ if (error.response?.status === 409 && error.response.data?.code === 'stale_base') {
611
+ console.error(chalk_1.default.red(staleBaseLine()));
612
+ }
613
+ else if (error.response?.status === 401) {
605
614
  console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
606
615
  }
607
616
  else {
@@ -648,7 +657,13 @@ async function deploy(projectName, sourcePath, options = {}) {
648
657
  process.exit(1);
649
658
  }
650
659
  const functionsPayload = (0, functions_sync_1.buildFunctionsSyncPayload)(functionFiles, functionSources, codeRef);
660
+ if (guardedBaseWire !== null)
661
+ functionsPayload.base_source_hash = guardedBaseWire;
651
662
  const functionsResult = await (0, functions_sync_1.syncFunctions)(config, projectSlug, functionsPayload);
663
+ if (functionsResult.httpStatus === 409 && functionsResult.body?.code === 'stale_base') {
664
+ console.error(chalk_1.default.red(staleBaseLine()));
665
+ process.exit(1);
666
+ }
652
667
  const functionRows = functionsResult.body?.functions ?? [];
653
668
  const retiredFunctions = functionsResult.body?.retired ?? [];
654
669
  const retireErrors = functionsResult.body?.retire_errors ?? [];
@@ -703,9 +718,6 @@ async function deploy(projectName, sourcePath, options = {}) {
703
718
  const outcome = (0, functions_sync_1.joinSyncOutcomes)(functionsOutcome, pagesOutcome);
704
719
  process.exit((0, pages_sync_1.terminalExitCode)({ buildFailed, yamlSyncFailed, outcome }));
705
720
  };
706
- if (!yamlConfig?.workflows) {
707
- return finishDeploy({ deploymentId: null, buildFailed: false });
708
- }
709
721
  // Plan the file list BEFORE creating the archive write stream so a walk error
710
722
  // (permission error, unreadable dir) aborts cleanly with no orphan tarball.
711
723
  let plan;
@@ -743,7 +755,19 @@ async function deploy(projectName, sourcePath, options = {}) {
743
755
  output.on('close', async () => {
744
756
  console.log(chalk_1.default.gray(`Archived ${archive.pointer()} total bytes`));
745
757
  try {
758
+ const hash = (0, crypto_1.createHash)('md5');
759
+ for await (const chunk of fs_1.default.createReadStream(archivePath)) {
760
+ hash.update(chunk);
761
+ }
762
+ const uploadedArchiveMd5 = hash.digest('hex');
763
+ exports.archiveMd5 = uploadedArchiveMd5;
746
764
  const form = (0, source_provenance_1.buildDeployForm)(archivePath, sourceMetadata);
765
+ if (guardedBaseWire !== null) {
766
+ form.append('base_source_hash', guardedBaseWire);
767
+ }
768
+ if (!yamlConfig?.workflows) {
769
+ form.append('build', '0');
770
+ }
747
771
  if (options.paused) {
748
772
  form.append('paused', '1');
749
773
  }
@@ -759,6 +783,19 @@ async function deploy(projectName, sourcePath, options = {}) {
759
783
  maxContentLength: Infinity,
760
784
  maxBodyLength: Infinity
761
785
  });
786
+ if (guardedBase) {
787
+ if (deployResponse.data?.source_hash === uploadedArchiveMd5) {
788
+ (0, sandbox_base_1.writeSandboxBase)(sourceDir, { source_hash: uploadedArchiveMd5, slug: guardedBase.slug, restored_at: new Date().toISOString() });
789
+ }
790
+ else {
791
+ console.log(chalk_1.default.yellow('The server stored different bytes than this deploy uploaded; base.json was left unchanged.'));
792
+ }
793
+ }
794
+ if (!yamlConfig?.workflows) {
795
+ console.log(chalk_1.default.green('Source archived.'));
796
+ cleanupArchive();
797
+ return await finishDeploy({ deploymentId: null, buildFailed: false });
798
+ }
762
799
  const acceptedDeployment = (0, source_provenance_1.parseDeployAcceptance)(deployResponse.data);
763
800
  if (acceptedDeployment.sourceMetadataRejected) {
764
801
  console.log(chalk_1.default.yellow(`Warning: optional source metadata was not accepted (${acceptedDeployment.sourceMetadataRejected}); deployment continues.`));
@@ -837,7 +874,10 @@ async function deploy(projectName, sourcePath, options = {}) {
837
874
  catch (error) {
838
875
  console.error(chalk_1.default.red('Deployment failed:'));
839
876
  if (error.response) {
840
- if (error.response.status === 404) {
877
+ if (error.response.status === 409 && error.response.data?.code === 'stale_base') {
878
+ console.error(chalk_1.default.red(staleBaseLine()));
879
+ }
880
+ else if (error.response.status === 404) {
841
881
  console.error("Project not found.");
842
882
  }
843
883
  else if (error.response.status === 401) {
@@ -15,6 +15,7 @@ const chalk_1 = __importDefault(require("chalk"));
15
15
  const prompts_1 = __importDefault(require("prompts"));
16
16
  const api_1 = require("../utils/api");
17
17
  const project_ref_1 = require("../utils/project-ref");
18
+ const sandbox_base_1 = require("../utils/sandbox-base");
18
19
  async function pull(projectName, destPath, options = {}) {
19
20
  const config = await (0, api_1.requireConfigWithWorkspace)();
20
21
  const destination = destPath ? path_1.default.resolve(destPath) : process.cwd();
@@ -61,9 +62,15 @@ async function pull(projectName, destPath, options = {}) {
61
62
  // version of the `tar` package).
62
63
  filter: (entryPath) => {
63
64
  const top = entryPath.split('/')[0];
64
- return top === 'tenantcode' && !/\/sa-nocache-[0-9a-f-]+$/.test(entryPath);
65
+ // Belt and braces with the server strip: never lay the
66
+ // server-managed .solidactions/ down, at any depth.
67
+ return top === 'tenantcode' && !/\/sa-nocache-[0-9a-f-]+$/.test(entryPath) && !entryPath.split('/').includes('.solidactions');
65
68
  },
66
69
  }));
70
+ const sourceHash = response.headers['x-source-hash'];
71
+ if ((0, sandbox_base_1.isAppSandbox)() && typeof sourceHash === 'string') {
72
+ (0, sandbox_base_1.writeSandboxBase)(destination, { source_hash: sourceHash, slug: projectSlug, restored_at: new Date().toISOString() });
73
+ }
67
74
  console.log(chalk_1.default.green(`Project "${projectName}" pulled successfully!`));
68
75
  }
69
76
  catch (error) {
@@ -33,10 +33,11 @@ exports.DEFAULT_DEPLOY_IGNORES = [
33
33
  * re-includable by any matcher negation. Covers:
34
34
  * - `.env` and any `.env.*` (secret-leak fix). Anchored so `.envrc` and
35
35
  * `environment.ts` do NOT match.
36
+ * - `.solidactions` (local CLI state at any depth).
36
37
  * - `.steps-deploy.tar.gz` / `.steps-deploy.zip` (our own deploy artifacts,
37
38
  * written into sourceDir while we walk).
38
39
  */
39
- exports.HARD_DENY_BASENAMES = /^(?:\.env(?:$|\..*)|\.steps-deploy\.(?:tar\.gz|zip))$/;
40
+ exports.HARD_DENY_BASENAMES = /^(?:\.env(?:$|\..*)|\.solidactions|\.steps-deploy\.(?:tar\.gz|zip))$/;
40
41
  /**
41
42
  * True if a path is hard-denied (Layer 1). Checked before the matcher so that
42
43
  * no `!` negation in deploy.exclude or .gitignore can re-include it.
@@ -0,0 +1,63 @@
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.SANDBOX_BASE_PATH = void 0;
7
+ exports.isAppSandbox = isAppSandbox;
8
+ exports.readSandboxBase = readSandboxBase;
9
+ exports.writeSandboxBase = writeSandboxBase;
10
+ exports.baseWireValue = baseWireValue;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const crypto_1 = require("crypto");
14
+ exports.SANDBOX_BASE_PATH = path_1.default.join('.solidactions', 'base.json');
15
+ function isAppSandbox(env = process.env) {
16
+ return env.SOLIDACTIONS_APP_SANDBOX === '1';
17
+ }
18
+ function readSandboxBase(dir) {
19
+ try {
20
+ const base = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, exports.SANDBOX_BASE_PATH), 'utf8'));
21
+ if (base === null || typeof base !== 'object' || Array.isArray(base))
22
+ return null;
23
+ const candidate = base;
24
+ if (candidate.source_hash !== null && (typeof candidate.source_hash !== 'string' || !/^[a-f0-9]{32}$/i.test(candidate.source_hash)))
25
+ return null;
26
+ if (typeof candidate.slug !== 'string' || candidate.slug.length === 0 || typeof candidate.restored_at !== 'string' || candidate.restored_at.length === 0)
27
+ return null;
28
+ return { source_hash: candidate.source_hash, slug: candidate.slug, restored_at: candidate.restored_at };
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ function writeSandboxBase(dir, base) {
35
+ const target = path_1.default.join(dir, exports.SANDBOX_BASE_PATH);
36
+ fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
37
+ const temporary = path_1.default.join(path_1.default.dirname(target), `.${path_1.default.basename(target)}.${(0, crypto_1.randomUUID)()}.tmp`);
38
+ let fd;
39
+ let owned = false;
40
+ try {
41
+ fd = fs_1.default.openSync(temporary, 'wx', 0o600);
42
+ owned = true;
43
+ fs_1.default.writeFileSync(fd, JSON.stringify(base));
44
+ fs_1.default.fsyncSync(fd);
45
+ fs_1.default.closeSync(fd);
46
+ fd = undefined;
47
+ fs_1.default.renameSync(temporary, target);
48
+ owned = false;
49
+ }
50
+ finally {
51
+ try {
52
+ if (fd !== undefined)
53
+ fs_1.default.closeSync(fd);
54
+ }
55
+ finally {
56
+ if (owned)
57
+ fs_1.default.unlinkSync(temporary);
58
+ }
59
+ }
60
+ }
61
+ function baseWireValue(base) {
62
+ return base.source_hash ?? 'none';
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.31.0",
3
+ "version": "3.32.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {