@yokio42/unit-labs-cli 0.1.0 → 0.1.2
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 +60 -0
- package/package.json +1 -1
- package/src/config.js +34 -17
- package/src/index.js +1025 -143
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @yokio42/unit-labs-cli
|
|
2
|
+
|
|
3
|
+
CLI для Unit Labs: логин, выбор проекта/стейджа и работа с задачами из терминала.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g @yokio42/unit-labs-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
unit-labs auth login
|
|
15
|
+
unit-labs project ls
|
|
16
|
+
unit-labs project use 1
|
|
17
|
+
unit-labs task ls
|
|
18
|
+
unit-labs task new "Ship MVP"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
### Auth
|
|
24
|
+
- `unit-labs auth login`
|
|
25
|
+
- `unit-labs auth whoami`
|
|
26
|
+
- `unit-labs auth logout`
|
|
27
|
+
|
|
28
|
+
### Config
|
|
29
|
+
- `unit-labs config show`
|
|
30
|
+
- `unit-labs config set-api <url>`
|
|
31
|
+
|
|
32
|
+
### Project
|
|
33
|
+
- `unit-labs project ls [--team <teamId>] [--json]`
|
|
34
|
+
- `unit-labs project new --name "<name>" [--workflow stages|flat] [--team <teamId>]`
|
|
35
|
+
- `unit-labs project view <number|name|id> [--json]`
|
|
36
|
+
- `unit-labs project use <number|name|id>`
|
|
37
|
+
- `unit-labs project current [--json]`
|
|
38
|
+
|
|
39
|
+
### Stage
|
|
40
|
+
- `unit-labs stage ls [--project <number|name|id>] [--json]`
|
|
41
|
+
- `unit-labs stage new --name "<name>" --description "<text>" [--project <number|name|id>]`
|
|
42
|
+
- `unit-labs stage use <number|name|id> [--project <number|name|id>]`
|
|
43
|
+
- `unit-labs stage current [--json]`
|
|
44
|
+
|
|
45
|
+
### Task
|
|
46
|
+
- `unit-labs task ls [--project <number|name|id>] [--stage <number|name|id>] [--all] [--json]`
|
|
47
|
+
- `unit-labs task new "<title>" [--project <number|name|id>] [--stage <number|name|id>]`
|
|
48
|
+
- `unit-labs task done <number|title|id>`
|
|
49
|
+
- `unit-labs task close <number|title|id>`
|
|
50
|
+
- `unit-labs task assign <number|title|id> <me|none|number|username|email|id>`
|
|
51
|
+
- `unit-labs task unassign <number|title|id>`
|
|
52
|
+
- `unit-labs task edit <number|title|id> --title "<new title>"`
|
|
53
|
+
- `unit-labs task rm <number|title|id>`
|
|
54
|
+
- `unit-labs task delete <number|title|id>`
|
|
55
|
+
|
|
56
|
+
## Notes
|
|
57
|
+
|
|
58
|
+
- По умолчанию API: `https://popuitka2-be.onrender.com`
|
|
59
|
+
- CLI хранит `apiBase`, токен и текущий контекст в `~/.unit-labs/config.json`
|
|
60
|
+
- Для проектов с `workflow=flat` команды `stage` недоступны
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -20,37 +20,53 @@ function ensureConfigDir() {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function getDefaultConfig() {
|
|
24
|
+
return {
|
|
25
|
+
apiBase: DEFAULT_API_BASE,
|
|
26
|
+
token: null,
|
|
27
|
+
currentProjectId: null,
|
|
28
|
+
currentProjectName: null,
|
|
29
|
+
currentProjectWorkflow: null,
|
|
30
|
+
currentStageId: null,
|
|
31
|
+
currentStageName: null,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function normalizeConfig(input) {
|
|
36
|
+
const base = getDefaultConfig()
|
|
37
|
+
const raw = input && typeof input === "object" ? input : {}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...base,
|
|
41
|
+
...raw,
|
|
42
|
+
apiBase: normalizeApiBase(raw.apiBase || base.apiBase),
|
|
43
|
+
token: raw.token || null,
|
|
44
|
+
currentProjectId: raw.currentProjectId || null,
|
|
45
|
+
currentProjectName: raw.currentProjectName || null,
|
|
46
|
+
currentProjectWorkflow: raw.currentProjectWorkflow || null,
|
|
47
|
+
currentStageId: raw.currentStageId || null,
|
|
48
|
+
currentStageName: raw.currentStageName || null,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
23
52
|
function readConfig() {
|
|
24
53
|
ensureConfigDir()
|
|
25
54
|
|
|
26
55
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
27
|
-
return
|
|
28
|
-
apiBase: DEFAULT_API_BASE,
|
|
29
|
-
token: null,
|
|
30
|
-
}
|
|
56
|
+
return getDefaultConfig()
|
|
31
57
|
}
|
|
32
58
|
|
|
33
59
|
try {
|
|
34
60
|
const raw = fs.readFileSync(CONFIG_FILE, "utf-8")
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
apiBase: normalizeApiBase(parsed.apiBase),
|
|
38
|
-
token: parsed.token || null,
|
|
39
|
-
}
|
|
61
|
+
return normalizeConfig(JSON.parse(raw))
|
|
40
62
|
} catch (error) {
|
|
41
|
-
return
|
|
42
|
-
apiBase: DEFAULT_API_BASE,
|
|
43
|
-
token: null,
|
|
44
|
-
}
|
|
63
|
+
return getDefaultConfig()
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
66
|
|
|
48
67
|
function writeConfig(config) {
|
|
49
68
|
ensureConfigDir()
|
|
50
|
-
const normalized =
|
|
51
|
-
apiBase: normalizeApiBase(config.apiBase),
|
|
52
|
-
token: config.token || null,
|
|
53
|
-
}
|
|
69
|
+
const normalized = normalizeConfig(config)
|
|
54
70
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(normalized, null, 2), "utf-8")
|
|
55
71
|
}
|
|
56
72
|
|
|
@@ -61,3 +77,4 @@ module.exports = {
|
|
|
61
77
|
readConfig,
|
|
62
78
|
writeConfig,
|
|
63
79
|
}
|
|
80
|
+
|