@kiipu/cli 0.0.2 → 0.0.4
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/dist/commands/help.js +2 -0
- package/dist/index.js +7 -1
- package/dist/lib/kiipu-skill-client.js +3 -2
- package/dist/lib/post-actions.js +5 -4
- package/dist/version.js +4 -0
- package/package.json +4 -4
package/dist/commands/help.js
CHANGED
|
@@ -122,9 +122,11 @@ export function getHelpResult(command) {
|
|
|
122
122
|
'',
|
|
123
123
|
'Global options:',
|
|
124
124
|
' --json Print structured JSON instead of plain text',
|
|
125
|
+
' -v, --version Show the current CLI version',
|
|
125
126
|
' -h, --help Show help for the root CLI or a subcommand',
|
|
126
127
|
'',
|
|
127
128
|
'Help:',
|
|
129
|
+
' kiipu -v',
|
|
128
130
|
' kiipu --help',
|
|
129
131
|
' kiipu -h',
|
|
130
132
|
' kiipu <command> --help',
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getHelpResult } from './commands/help.js';
|
|
|
7
7
|
import { runPostCommand } from './commands/post.js';
|
|
8
8
|
import { runSkillsCommand } from './commands/skills.js';
|
|
9
9
|
import { readFlag, hasFlag } from './utils/args.js';
|
|
10
|
+
import { CLI_VERSION } from './version.js';
|
|
10
11
|
function printResult(result, asJson) {
|
|
11
12
|
if (asJson) {
|
|
12
13
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -23,8 +24,9 @@ async function main() {
|
|
|
23
24
|
const normalizedArgs = args[0] === '--' ? args.slice(1) : args;
|
|
24
25
|
const asJson = hasFlag(normalizedArgs, '--json');
|
|
25
26
|
const wantsHelp = hasFlag(normalizedArgs, '--help') || hasFlag(normalizedArgs, '-h');
|
|
27
|
+
const wantsVersion = hasFlag(normalizedArgs, '--version') || hasFlag(normalizedArgs, '-v');
|
|
26
28
|
const positionalArgs = normalizedArgs.filter((arg, index, all) => {
|
|
27
|
-
if (arg === '--json' || arg === '--help' || arg === '-h')
|
|
29
|
+
if (arg === '--json' || arg === '--help' || arg === '-h' || arg === '--version' || arg === '-v')
|
|
28
30
|
return false;
|
|
29
31
|
const prev = all[index - 1];
|
|
30
32
|
return (prev !== '--scheduled-at' &&
|
|
@@ -40,6 +42,10 @@ async function main() {
|
|
|
40
42
|
prev !== '--device-name');
|
|
41
43
|
});
|
|
42
44
|
const [command, subcommand, subject] = positionalArgs;
|
|
45
|
+
if (wantsVersion) {
|
|
46
|
+
console.log(CLI_VERSION);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
43
49
|
if (wantsHelp || command === 'help') {
|
|
44
50
|
return printResult(getHelpResult(command === 'help' ? subcommand : command), asJson);
|
|
45
51
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
function buildError(requestId, message, code = 'request_failed') {
|
|
2
3
|
return {
|
|
3
4
|
ok: false,
|
|
@@ -9,7 +10,7 @@ function buildError(requestId, message, code = 'request_failed') {
|
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
function parseCreatePostRequest(input) {
|
|
12
|
-
const requestId = typeof input.requestId === 'string' ? input.requestId :
|
|
13
|
+
const requestId = typeof input.requestId === 'string' ? input.requestId : randomUUID();
|
|
13
14
|
const rawText = typeof input.rawText === 'string' ? input.rawText.trim() : '';
|
|
14
15
|
if (!rawText) {
|
|
15
16
|
throw new Error('rawText is required.');
|
|
@@ -32,7 +33,7 @@ function parseCreatePostRequest(input) {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
function parsePostMutationRequest(input) {
|
|
35
|
-
const requestId = typeof input.requestId === 'string' ? input.requestId :
|
|
36
|
+
const requestId = typeof input.requestId === 'string' ? input.requestId : randomUUID();
|
|
36
37
|
const postId = typeof input.postId === 'string' ? input.postId.trim() : '';
|
|
37
38
|
if (!postId) {
|
|
38
39
|
throw new Error('postId is required.');
|
package/dist/lib/post-actions.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { KiipuSkillApiClient } from './kiipu-skill-client.js';
|
|
2
3
|
function formatRequestFailed(message, code) {
|
|
3
4
|
return `Request failed: ${message} (${code}).`;
|
|
@@ -26,7 +27,7 @@ export async function executePostAction(config, input) {
|
|
|
26
27
|
}
|
|
27
28
|
if (input.action === 'create') {
|
|
28
29
|
const response = await client.createPost({
|
|
29
|
-
requestId:
|
|
30
|
+
requestId: randomUUID(),
|
|
30
31
|
requestedAt: new Date().toISOString(),
|
|
31
32
|
traceId: `${input.traceIdPrefix ?? 'post'}-${Date.now()}`,
|
|
32
33
|
rawText: input.content,
|
|
@@ -51,7 +52,7 @@ export async function executePostAction(config, input) {
|
|
|
51
52
|
}
|
|
52
53
|
if (input.action === 'delete') {
|
|
53
54
|
const response = await client.deletePost({
|
|
54
|
-
requestId:
|
|
55
|
+
requestId: randomUUID(),
|
|
55
56
|
requestedAt: new Date().toISOString(),
|
|
56
57
|
traceId: `${input.traceIdPrefix ?? 'delete'}-${Date.now()}`,
|
|
57
58
|
postId: input.postId,
|
|
@@ -72,7 +73,7 @@ export async function executePostAction(config, input) {
|
|
|
72
73
|
}
|
|
73
74
|
if (input.action === 'restore') {
|
|
74
75
|
const response = await client.restorePost({
|
|
75
|
-
requestId:
|
|
76
|
+
requestId: randomUUID(),
|
|
76
77
|
requestedAt: new Date().toISOString(),
|
|
77
78
|
traceId: `${input.traceIdPrefix ?? 'restore'}-${Date.now()}`,
|
|
78
79
|
postId: input.postId,
|
|
@@ -92,7 +93,7 @@ export async function executePostAction(config, input) {
|
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
const response = await client.permanentDeletePost({
|
|
95
|
-
requestId:
|
|
96
|
+
requestId: randomUUID(),
|
|
96
97
|
requestedAt: new Date().toISOString(),
|
|
97
98
|
traceId: `${input.traceIdPrefix ?? 'purge'}-${Date.now()}`,
|
|
98
99
|
postId: input.postId,
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiipu/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Kiipu CLI for local authentication, doctor checks, and direct post actions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"skill"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"bin": {
|
|
20
20
|
"kiipu": "dist/index.js"
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"dev": "
|
|
34
|
+
"dev": "tsx src/index.ts",
|
|
35
35
|
"build": "node scripts/clean-build.mjs && tsc -p tsconfig.json",
|
|
36
36
|
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint src test --ext .ts",
|
|
37
|
-
"test": "
|
|
37
|
+
"test": "tsx --test test/**/*.test.ts",
|
|
38
38
|
"release:patch": "npm version patch --no-git-tag-version",
|
|
39
39
|
"release:minor": "npm version minor --no-git-tag-version",
|
|
40
40
|
"release:major": "npm version major --no-git-tag-version",
|