automata-cli 0.1.0-001-config-wizard.3
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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/index.js +109 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Beads Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# automata-cli
|
|
2
|
+
|
|
3
|
+
A command-line interface tool.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g automata-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
automata --help
|
|
15
|
+
```
|
|
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
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
### Prerequisites
|
|
41
|
+
|
|
42
|
+
- Node.js LTS (20+)
|
|
43
|
+
- npm
|
|
44
|
+
|
|
45
|
+
### Setup
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/alkampfergit/automata-cli.git
|
|
49
|
+
cd automata-cli
|
|
50
|
+
npm install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Scripts
|
|
54
|
+
|
|
55
|
+
| Command | Description |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `npm run build` | Build the CLI with tsup |
|
|
58
|
+
| `npm test` | Build and run tests with vitest |
|
|
59
|
+
| `npm run lint` | Lint source files with ESLint |
|
|
60
|
+
| `npm run typecheck` | Type-check with tsc (no emit) |
|
|
61
|
+
| `npm run format` | Check formatting with Prettier |
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
[MIT](LICENSE)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command as Command2 } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/version.ts
|
|
7
|
+
import { readFileSync } from "fs";
|
|
8
|
+
import { dirname, resolve } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
var packageJson = JSON.parse(readFileSync(resolve(__dirname, "../package.json"), "utf8"));
|
|
12
|
+
var version = packageJson.version;
|
|
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
|
+
|
|
101
|
+
// src/index.ts
|
|
102
|
+
var program = new Command2();
|
|
103
|
+
program.name("automata").description("Automata CLI tool").version(version, "-v, --version");
|
|
104
|
+
program.addCommand(configCommand);
|
|
105
|
+
program.showHelpAfterError();
|
|
106
|
+
program.parse();
|
|
107
|
+
if (process.argv.length <= 2) {
|
|
108
|
+
program.help();
|
|
109
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "automata-cli",
|
|
3
|
+
"version": "0.1.0-001-config-wizard.3",
|
|
4
|
+
"description": "Automata CLI tool",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"automata": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup",
|
|
14
|
+
"lint": "eslint src/",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"format": "prettier --check src/",
|
|
17
|
+
"test": "npm run build && vitest run tests/unit",
|
|
18
|
+
"test:integration": "npm run build && vitest run tests/integration"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/alkampfergit/automata-cli.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"commander": "^14.0.3",
|
|
27
|
+
"ink": "^6.8.0",
|
|
28
|
+
"react": "^19.2.4"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@eslint/js": "^10.0.1",
|
|
32
|
+
"@types/node": "^25.5.0",
|
|
33
|
+
"@types/react": "^19.2.14",
|
|
34
|
+
"eslint": "^10.1.0",
|
|
35
|
+
"prettier": "^3.8.1",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"typescript-eslint": "^8.57.2",
|
|
39
|
+
"vitest": "^4.1.2"
|
|
40
|
+
}
|
|
41
|
+
}
|