automata-cli 0.2.0-develop.1 → 0.2.0-develop.7

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 (3) hide show
  1. package/README.md +21 -0
  2. package/dist/index.js +90 -2
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -14,6 +14,27 @@ npm install -g automata-cli
14
14
  automata --help
15
15
  ```
16
16
 
17
+ ## Commands
18
+
19
+ ### `automata config`
20
+
21
+ Launch the interactive configuration wizard. Use arrow keys to select the remote environment type and press Enter to save.
22
+
23
+ ```bash
24
+ automata config
25
+ ```
26
+
27
+ ### `automata config set type <value>`
28
+
29
+ Set a configuration value non-interactively (useful in scripts or CI).
30
+
31
+ ```bash
32
+ automata config set type gh # GitHub
33
+ automata config set type azdo # Azure DevOps
34
+ ```
35
+
36
+ Configuration is saved to `.automata/config.json` in the current directory.
37
+
17
38
  ## Development
18
39
 
19
40
  ### Prerequisites
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command } from "commander";
4
+ import { Command as Command2 } from "commander";
5
5
 
6
6
  // src/version.ts
7
7
  import { readFileSync } from "fs";
@@ -11,9 +11,97 @@ var __dirname = dirname(fileURLToPath(import.meta.url));
11
11
  var packageJson = JSON.parse(readFileSync(resolve(__dirname, "../package.json"), "utf8"));
12
12
  var version = packageJson.version;
13
13
 
14
+ // src/commands/config.ts
15
+ import { Command } from "commander";
16
+ import { render } from "ink";
17
+ import React2 from "react";
18
+
19
+ // src/config/ConfigWizard.tsx
20
+ import { useState } from "react";
21
+ import { Box, Text, useInput, useApp } from "ink";
22
+
23
+ // src/config/configStore.ts
24
+ import { readFileSync as readFileSync2, writeFileSync, mkdirSync } from "fs";
25
+ import { join } from "path";
26
+ var CONFIG_DIR = ".automata";
27
+ var CONFIG_FILE = "config.json";
28
+ function configPath() {
29
+ return join(process.cwd(), CONFIG_DIR, CONFIG_FILE);
30
+ }
31
+ function readConfig() {
32
+ try {
33
+ const raw = readFileSync2(configPath(), "utf8");
34
+ return JSON.parse(raw);
35
+ } catch {
36
+ return {};
37
+ }
38
+ }
39
+ function writeConfig(config) {
40
+ const dir = join(process.cwd(), CONFIG_DIR);
41
+ mkdirSync(dir, { recursive: true });
42
+ writeFileSync(configPath(), JSON.stringify(config, null, 2) + "\n", "utf8");
43
+ }
44
+
45
+ // src/config/ConfigWizard.tsx
46
+ import { jsx, jsxs } from "react/jsx-runtime";
47
+ var OPTIONS = [
48
+ { label: "GitHub", value: "gh" },
49
+ { label: "Azure DevOps", value: "azdo" }
50
+ ];
51
+ function ConfigWizard() {
52
+ const existing = readConfig();
53
+ const initialIndex = OPTIONS.findIndex((o) => o.value === existing.remoteType);
54
+ const [selectedIndex, setSelectedIndex] = useState(initialIndex >= 0 ? initialIndex : 0);
55
+ const { exit } = useApp();
56
+ useInput((input, key) => {
57
+ if (key.upArrow) {
58
+ setSelectedIndex((i) => i > 0 ? i - 1 : OPTIONS.length - 1);
59
+ } else if (key.downArrow) {
60
+ setSelectedIndex((i) => i < OPTIONS.length - 1 ? i + 1 : 0);
61
+ } else if (key.return) {
62
+ const chosen = OPTIONS[selectedIndex];
63
+ writeConfig({ ...existing, remoteType: chosen.value });
64
+ exit();
65
+ } else if (key.escape || key.ctrl && input === "c") {
66
+ exit();
67
+ }
68
+ });
69
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginY: 1, children: [
70
+ /* @__PURE__ */ jsx(Text, { bold: true, children: "Configure Automata" }),
71
+ /* @__PURE__ */ jsx(Text, { children: " " }),
72
+ /* @__PURE__ */ jsx(Text, { children: "Remote environment type:" }),
73
+ OPTIONS.map((option, index) => /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { color: index === selectedIndex ? "cyan" : void 0, children: [
74
+ index === selectedIndex ? "\u276F " : " ",
75
+ option.label
76
+ ] }) }, option.value)),
77
+ /* @__PURE__ */ jsx(Text, { children: " " }),
78
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2191/\u2193 to move \xB7 Enter to confirm \xB7 Ctrl+C to cancel" })
79
+ ] });
80
+ }
81
+
82
+ // src/commands/config.ts
83
+ var VALID_TYPES = ["gh", "azdo"];
84
+ var configSetType = new Command("type").description("Set the remote environment type").argument("<value>", "Remote type: gh (GitHub) or azdo (Azure DevOps)").action((value) => {
85
+ if (!VALID_TYPES.includes(value)) {
86
+ process.stderr.write(`Error: invalid type "${value}". Must be one of: ${VALID_TYPES.join(", ")}
87
+ `);
88
+ process.exit(1);
89
+ }
90
+ const current = readConfig();
91
+ writeConfig({ ...current, remoteType: value });
92
+ process.stdout.write(`Remote type set to: ${value}
93
+ `);
94
+ });
95
+ var configSet = new Command("set").description("Set a configuration value").addCommand(configSetType);
96
+ var configCommand = new Command("config").description("Configure automata settings").addCommand(configSet).action(async () => {
97
+ const { waitUntilExit } = render(React2.createElement(ConfigWizard));
98
+ await waitUntilExit();
99
+ });
100
+
14
101
  // src/index.ts
15
- var program = new Command();
102
+ var program = new Command2();
16
103
  program.name("automata").description("Automata CLI tool").version(version, "-v, --version");
104
+ program.addCommand(configCommand);
17
105
  program.showHelpAfterError();
18
106
  program.parse();
19
107
  if (process.argv.length <= 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.2.0-develop.1",
3
+ "version": "0.2.0-develop.7",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,11 +23,14 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "commander": "^14.0.3"
26
+ "commander": "^14.0.3",
27
+ "ink": "^6.8.0",
28
+ "react": "^19.2.4"
27
29
  },
28
30
  "devDependencies": {
29
31
  "@eslint/js": "^10.0.1",
30
32
  "@types/node": "^25.5.0",
33
+ "@types/react": "^19.2.14",
31
34
  "eslint": "^10.1.0",
32
35
  "prettier": "^3.8.1",
33
36
  "tsup": "^8.5.1",