automata-cli 0.10.0-develop.396 → 0.10.0-develop.408

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -371,6 +371,17 @@ function getPrInfo() {
371
371
  };
372
372
  }
373
373
 
374
+ // src/remote/backend.ts
375
+ function selectBackend(config) {
376
+ return config.remoteType === "azdo" ? "azdo" : "gh";
377
+ }
378
+ function isAzdo(config) {
379
+ return selectBackend(config) === "azdo";
380
+ }
381
+ function isExplicitGitHub(config) {
382
+ return config.remoteType === "gh";
383
+ }
384
+
374
385
  // src/run/commandTrace.ts
375
386
  var sink = null;
376
387
  function startCommandTrace() {
@@ -895,7 +906,7 @@ async function getPrInfoGh(branch) {
895
906
  }
896
907
  async function getPrInfo2(branch) {
897
908
  const config = readConfig();
898
- if (config.remoteType === "azdo") {
909
+ if (selectBackend(config) === "azdo") {
899
910
  return getPrInfo();
900
911
  }
901
912
  return getPrInfoGh(branch);
@@ -1104,7 +1115,7 @@ function getPrCommentsGh(branch) {
1104
1115
  }
1105
1116
  function getPrComments(branch) {
1106
1117
  const config = readConfig();
1107
- if (config.remoteType === "azdo") {
1118
+ if (selectBackend(config) === "azdo") {
1108
1119
  return "unsupported";
1109
1120
  }
1110
1121
  return getPrCommentsGh(branch);
@@ -2790,7 +2801,7 @@ Select issue (1-${issues.length}): `, resolve2)
2790
2801
  return issues[n - 1];
2791
2802
  }
2792
2803
  function validateConfig(config) {
2793
- if (config.remoteType !== "gh") {
2804
+ if (!isExplicitGitHub(config)) {
2794
2805
  process.stderr.write(
2795
2806
  "Error: implement-next is not supported in Azure DevOps mode. Work item discovery is not available in azdo-cli. See docs/azdo-gap.md for details.\n"
2796
2807
  );
@@ -3264,7 +3275,7 @@ var executeCheckIssueCmd = addAiOptions(
3264
3275
  process.exit(1);
3265
3276
  }
3266
3277
  const config = readConfig();
3267
- if (config.remoteType === "azdo") {
3278
+ if (isAzdo(config)) {
3268
3279
  process.stderr.write(
3269
3280
  "Error: check-issue is not supported for Azure DevOps. See docs/azdo-gap.md for details.\n"
3270
3281
  );
@@ -4670,12 +4681,14 @@ import {
4670
4681
  accessSync as accessSync2,
4671
4682
  appendFileSync,
4672
4683
  constants as constants2,
4684
+ mkdirSync as mkdirSync2,
4673
4685
  readFileSync as readFileSync6,
4674
4686
  renameSync as renameSync2,
4675
4687
  unlinkSync as unlinkSync3,
4676
4688
  writeFileSync as writeFileSync3
4677
4689
  } from "fs";
4678
4690
  import { randomUUID as randomUUID2 } from "crypto";
4691
+ import { tmpdir, userInfo } from "os";
4679
4692
  import { dirname as dirname2, join as join5 } from "path";
4680
4693
  var EXECUTION_LOG_FILE = "automata-execution.log";
4681
4694
  var WORK_LOG_FILE = "automata-work.log";
@@ -4690,7 +4703,25 @@ var OUTCOMES = [
4690
4703
  "deferred"
4691
4704
  ];
4692
4705
  function operationLogDirectory() {
4693
- return dirname2(process.cwd());
4706
+ const parent = dirname2(process.cwd());
4707
+ try {
4708
+ accessSync2(parent, constants2.W_OK);
4709
+ return parent;
4710
+ } catch {
4711
+ return fallbackLogDirectory();
4712
+ }
4713
+ }
4714
+ function fallbackLogDirectory() {
4715
+ return join5(tmpdir(), `automata-${userSegment()}`);
4716
+ }
4717
+ function userSegment() {
4718
+ const uid = process.getuid?.();
4719
+ if (uid !== void 0) return String(uid);
4720
+ try {
4721
+ return userInfo().username.replace(/[^A-Za-z0-9_.-]/g, "_");
4722
+ } catch {
4723
+ return "user";
4724
+ }
4694
4725
  }
4695
4726
  function inspectLogDirectory(dir = operationLogDirectory(), cwd = process.cwd()) {
4696
4727
  try {
@@ -4823,6 +4854,11 @@ function appendWithRetention(dir, file, content, retain) {
4823
4854
  }
4824
4855
  }
4825
4856
  function recordTick(tick, dir = operationLogDirectory()) {
4857
+ try {
4858
+ if (dir === fallbackLogDirectory()) mkdirSync2(dir, { recursive: true, mode: 448 });
4859
+ } catch {
4860
+ return;
4861
+ }
4826
4862
  try {
4827
4863
  accessSync2(dir, constants2.W_OK);
4828
4864
  } catch {
@@ -5760,7 +5796,7 @@ function resolveSettingsResult(options, verifyIdentity) {
5760
5796
  }
5761
5797
  }
5762
5798
  function requireParticipants(config) {
5763
- if (config.remoteType !== "gh") {
5799
+ if (!isExplicitGitHub(config)) {
5764
5800
  failSettings(
5765
5801
  "do-work is only supported for GitHub remotes. Set it with `automata config set type gh`. Azure DevOps lacks the issue conversation APIs this needs \u2014 see docs/azdo-gap.md."
5766
5802
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.10.0-develop.396",
3
+ "version": "0.10.0-develop.408",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "engines": {