@jackwener/opencli 0.9.5 → 0.9.8
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/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +42 -0
- package/.github/ISSUE_TEMPLATE/new_site_adapter.yml +57 -0
- package/.github/dependabot.yml +27 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/ci.yml +14 -8
- package/.github/workflows/e2e-headed.yml +6 -2
- package/.github/workflows/pkg-pr-new.yml +2 -2
- package/.github/workflows/release-please.yml +25 -0
- package/.github/workflows/release.yml +2 -2
- package/.github/workflows/security.yml +36 -0
- package/CLI-ELECTRON.md +89 -36
- package/CONTRIBUTING.md +167 -0
- package/README.md +98 -32
- package/README.zh-CN.md +99 -33
- package/dist/browser/discover.js +22 -7
- package/dist/browser.test.js +23 -0
- package/dist/build-manifest.d.ts +26 -0
- package/dist/build-manifest.js +132 -60
- package/dist/build-manifest.test.d.ts +1 -0
- package/dist/build-manifest.test.js +26 -0
- package/dist/cli-manifest.json +1875 -271
- package/dist/clis/antigravity/model.js +2 -2
- package/dist/clis/antigravity/send.js +2 -2
- package/dist/clis/bilibili/download.d.ts +10 -0
- package/dist/clis/bilibili/download.js +135 -0
- package/dist/clis/chatgpt/ask.d.ts +1 -0
- package/dist/clis/chatgpt/ask.js +68 -0
- package/dist/clis/chatgpt/send.js +11 -0
- package/dist/clis/chatwise/ask.d.ts +1 -0
- package/dist/clis/chatwise/ask.js +76 -0
- package/dist/clis/chatwise/export.d.ts +1 -0
- package/dist/clis/chatwise/export.js +46 -0
- package/dist/clis/chatwise/history.d.ts +1 -0
- package/dist/clis/chatwise/history.js +43 -0
- package/dist/clis/chatwise/model.d.ts +1 -0
- package/dist/clis/chatwise/model.js +81 -0
- package/dist/clis/chatwise/new.d.ts +1 -0
- package/dist/clis/chatwise/new.js +18 -0
- package/dist/clis/chatwise/read.d.ts +1 -0
- package/dist/clis/chatwise/read.js +39 -0
- package/dist/clis/chatwise/screenshot.d.ts +1 -0
- package/dist/clis/chatwise/screenshot.js +27 -0
- package/dist/clis/chatwise/send.d.ts +1 -0
- package/dist/clis/chatwise/send.js +45 -0
- package/dist/clis/chatwise/status.d.ts +1 -0
- package/dist/clis/chatwise/status.js +22 -0
- package/dist/clis/codex/ask.d.ts +1 -0
- package/dist/clis/codex/ask.js +67 -0
- package/dist/clis/codex/export.d.ts +1 -0
- package/dist/clis/codex/export.js +37 -0
- package/dist/clis/codex/history.d.ts +1 -0
- package/dist/clis/codex/history.js +43 -0
- package/dist/clis/codex/read.js +3 -5
- package/dist/clis/codex/screenshot.d.ts +1 -0
- package/dist/clis/codex/screenshot.js +27 -0
- package/dist/clis/codex/send.js +3 -6
- package/dist/clis/codex/status.js +2 -1
- package/dist/clis/cursor/ask.d.ts +1 -0
- package/dist/clis/cursor/ask.js +69 -0
- package/dist/clis/cursor/composer.js +9 -28
- package/dist/clis/cursor/export.d.ts +1 -0
- package/dist/clis/cursor/export.js +51 -0
- package/dist/clis/cursor/history.d.ts +1 -0
- package/dist/clis/cursor/history.js +43 -0
- package/dist/clis/cursor/new.js +4 -13
- package/dist/clis/cursor/screenshot.d.ts +1 -0
- package/dist/clis/cursor/screenshot.js +31 -0
- package/dist/clis/discord-app/channels.d.ts +1 -0
- package/dist/clis/discord-app/channels.js +45 -0
- package/dist/clis/discord-app/members.d.ts +1 -0
- package/dist/clis/discord-app/members.js +38 -0
- package/dist/clis/discord-app/read.d.ts +1 -0
- package/dist/clis/discord-app/read.js +45 -0
- package/dist/clis/discord-app/search.d.ts +1 -0
- package/dist/clis/discord-app/search.js +56 -0
- package/dist/clis/discord-app/send.d.ts +1 -0
- package/dist/clis/discord-app/send.js +27 -0
- package/dist/clis/discord-app/servers.d.ts +1 -0
- package/dist/clis/discord-app/servers.js +36 -0
- package/dist/clis/discord-app/status.d.ts +1 -0
- package/dist/clis/discord-app/status.js +16 -0
- package/dist/clis/feishu/new.d.ts +1 -0
- package/dist/clis/feishu/new.js +27 -0
- package/dist/clis/feishu/read.d.ts +1 -0
- package/dist/clis/feishu/read.js +40 -0
- package/dist/clis/feishu/search.d.ts +1 -0
- package/dist/clis/feishu/search.js +30 -0
- package/dist/clis/feishu/send.d.ts +1 -0
- package/dist/clis/feishu/send.js +39 -0
- package/dist/clis/feishu/status.d.ts +1 -0
- package/dist/clis/feishu/status.js +28 -0
- package/dist/clis/grok/ask.d.ts +1 -0
- package/dist/clis/grok/ask.js +82 -0
- package/dist/clis/grok/debug.d.ts +1 -0
- package/dist/clis/grok/debug.js +45 -0
- package/dist/clis/jimeng/generate.yaml +84 -0
- package/dist/clis/jimeng/history.yaml +47 -0
- package/dist/clis/linux-do/categories.yaml +41 -0
- package/dist/clis/linux-do/category.yaml +49 -0
- package/dist/clis/linux-do/hot.yaml +50 -0
- package/dist/clis/linux-do/latest.yaml +40 -0
- package/dist/clis/linux-do/search.yaml +45 -0
- package/dist/clis/linux-do/topic.yaml +38 -0
- package/dist/clis/notion/export.d.ts +1 -0
- package/dist/clis/notion/export.js +31 -0
- package/dist/clis/notion/favorites.d.ts +1 -0
- package/dist/clis/notion/favorites.js +84 -0
- package/dist/clis/notion/new.d.ts +1 -0
- package/dist/clis/notion/new.js +34 -0
- package/dist/clis/notion/read.d.ts +1 -0
- package/dist/clis/notion/read.js +30 -0
- package/dist/clis/notion/search.d.ts +1 -0
- package/dist/clis/notion/search.js +46 -0
- package/dist/clis/notion/sidebar.d.ts +1 -0
- package/dist/clis/notion/sidebar.js +41 -0
- package/dist/clis/notion/status.d.ts +1 -0
- package/dist/clis/notion/status.js +16 -0
- package/dist/clis/notion/write.d.ts +1 -0
- package/dist/clis/notion/write.js +40 -0
- package/dist/clis/twitter/download.d.ts +8 -0
- package/dist/clis/twitter/download.js +204 -0
- package/dist/clis/wechat/chats.d.ts +1 -0
- package/dist/clis/wechat/chats.js +28 -0
- package/dist/clis/wechat/contacts.d.ts +1 -0
- package/dist/clis/wechat/contacts.js +28 -0
- package/dist/clis/wechat/read.d.ts +1 -0
- package/dist/clis/wechat/read.js +58 -0
- package/dist/clis/wechat/search.d.ts +1 -0
- package/dist/clis/wechat/search.js +31 -0
- package/dist/clis/wechat/send.d.ts +1 -0
- package/dist/clis/wechat/send.js +42 -0
- package/dist/clis/wechat/status.d.ts +1 -0
- package/dist/clis/wechat/status.js +29 -0
- package/dist/clis/xiaohongshu/creator-note-detail.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-note-detail.js +88 -0
- package/dist/clis/xiaohongshu/creator-notes.d.ts +11 -0
- package/dist/clis/xiaohongshu/creator-notes.js +109 -0
- package/dist/clis/xiaohongshu/creator-profile.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-profile.js +54 -0
- package/dist/clis/xiaohongshu/creator-stats.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-stats.js +74 -0
- package/dist/clis/xiaohongshu/download.d.ts +7 -0
- package/dist/clis/xiaohongshu/download.js +155 -0
- package/dist/clis/xiaohongshu/search.js +1 -1
- package/dist/clis/xiaohongshu/user-helpers.d.ts +15 -0
- package/dist/clis/xiaohongshu/user-helpers.js +67 -0
- package/dist/clis/xiaohongshu/user-helpers.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/user-helpers.test.js +81 -0
- package/dist/clis/xiaohongshu/user.js +46 -29
- package/dist/clis/zhihu/download.d.ts +11 -0
- package/dist/clis/zhihu/download.js +186 -0
- package/dist/clis/zhihu/download.test.d.ts +1 -0
- package/dist/clis/zhihu/download.test.js +10 -0
- package/dist/download/index.d.ts +79 -0
- package/dist/download/index.js +325 -0
- package/dist/download/progress.d.ts +36 -0
- package/dist/download/progress.js +111 -0
- package/dist/engine.test.js +15 -0
- package/dist/main.js +16 -3
- package/dist/pipeline/registry.js +2 -0
- package/dist/pipeline/steps/download.d.ts +34 -0
- package/dist/pipeline/steps/download.js +251 -0
- package/dist/pipeline/template.js +28 -0
- package/package.json +4 -3
- package/scripts/test-site.mjs +70 -0
- package/src/browser/discover.ts +23 -7
- package/src/browser.test.ts +23 -0
- package/src/build-manifest.test.ts +28 -0
- package/src/build-manifest.ts +147 -57
- package/src/clis/antigravity/README.md +2 -3
- package/src/clis/antigravity/README.zh-CN.md +2 -3
- package/src/clis/antigravity/SKILL.md +1 -1
- package/src/clis/antigravity/model.ts +2 -2
- package/src/clis/antigravity/send.ts +2 -2
- package/src/clis/bilibili/download.ts +161 -0
- package/src/clis/chatgpt/README.md +25 -16
- package/src/clis/chatgpt/README.zh-CN.md +27 -18
- package/src/clis/chatgpt/ask.ts +77 -0
- package/src/clis/chatgpt/send.ts +12 -0
- package/src/clis/chatwise/README.md +38 -0
- package/src/clis/chatwise/README.zh-CN.md +38 -0
- package/src/clis/chatwise/ask.ts +87 -0
- package/src/clis/chatwise/export.ts +51 -0
- package/src/clis/chatwise/history.ts +47 -0
- package/src/clis/chatwise/model.ts +87 -0
- package/src/clis/chatwise/new.ts +21 -0
- package/src/clis/chatwise/read.ts +42 -0
- package/src/clis/chatwise/screenshot.ts +33 -0
- package/src/clis/chatwise/send.ts +50 -0
- package/src/clis/chatwise/status.ts +25 -0
- package/src/clis/codex/ask.ts +77 -0
- package/src/clis/codex/export.ts +42 -0
- package/src/clis/codex/extract-diff.ts +1 -0
- package/src/clis/codex/history.ts +47 -0
- package/src/clis/codex/read.ts +5 -6
- package/src/clis/codex/screenshot.ts +33 -0
- package/src/clis/codex/send.ts +6 -7
- package/src/clis/codex/status.ts +4 -2
- package/src/clis/cursor/ask.ts +81 -0
- package/src/clis/cursor/composer.ts +9 -30
- package/src/clis/cursor/export.ts +57 -0
- package/src/clis/cursor/history.ts +47 -0
- package/src/clis/cursor/new.ts +4 -15
- package/src/clis/cursor/screenshot.ts +38 -0
- package/src/clis/discord-app/README.md +28 -0
- package/src/clis/discord-app/README.zh-CN.md +28 -0
- package/src/clis/discord-app/channels.ts +48 -0
- package/src/clis/discord-app/members.ts +41 -0
- package/src/clis/discord-app/read.ts +49 -0
- package/src/clis/discord-app/search.ts +64 -0
- package/src/clis/discord-app/send.ts +32 -0
- package/src/clis/discord-app/servers.ts +39 -0
- package/src/clis/discord-app/status.ts +18 -0
- package/src/clis/feishu/README.md +20 -0
- package/src/clis/feishu/README.zh-CN.md +20 -0
- package/src/clis/feishu/new.ts +32 -0
- package/src/clis/feishu/read.ts +48 -0
- package/src/clis/feishu/search.ts +35 -0
- package/src/clis/feishu/send.ts +46 -0
- package/src/clis/feishu/status.ts +34 -0
- package/src/clis/grok/ask.ts +90 -0
- package/src/clis/grok/debug.ts +49 -0
- package/src/clis/jimeng/generate.yaml +84 -0
- package/src/clis/jimeng/history.yaml +47 -0
- package/src/clis/linux-do/categories.yaml +41 -0
- package/src/clis/linux-do/category.yaml +49 -0
- package/src/clis/linux-do/hot.yaml +50 -0
- package/src/clis/linux-do/latest.yaml +40 -0
- package/src/clis/linux-do/search.yaml +45 -0
- package/src/clis/linux-do/topic.yaml +38 -0
- package/src/clis/notion/README.md +29 -0
- package/src/clis/notion/README.zh-CN.md +29 -0
- package/src/clis/notion/export.ts +36 -0
- package/src/clis/notion/favorites.ts +87 -0
- package/src/clis/notion/new.ts +39 -0
- package/src/clis/notion/read.ts +33 -0
- package/src/clis/notion/search.ts +54 -0
- package/src/clis/notion/sidebar.ts +44 -0
- package/src/clis/notion/status.ts +18 -0
- package/src/clis/notion/write.ts +45 -0
- package/src/clis/twitter/download.ts +227 -0
- package/src/clis/wechat/README.md +28 -0
- package/src/clis/wechat/README.zh-CN.md +28 -0
- package/src/clis/wechat/chats.ts +33 -0
- package/src/clis/wechat/contacts.ts +33 -0
- package/src/clis/wechat/read.ts +72 -0
- package/src/clis/wechat/search.ts +36 -0
- package/src/clis/wechat/send.ts +49 -0
- package/src/clis/wechat/status.ts +35 -0
- package/src/clis/xiaohongshu/creator-note-detail.ts +95 -0
- package/src/clis/xiaohongshu/creator-notes.ts +116 -0
- package/src/clis/xiaohongshu/creator-profile.ts +60 -0
- package/src/clis/xiaohongshu/creator-stats.ts +81 -0
- package/src/clis/xiaohongshu/download.ts +173 -0
- package/src/clis/xiaohongshu/search.ts +1 -1
- package/src/clis/xiaohongshu/user-helpers.test.ts +106 -0
- package/src/clis/xiaohongshu/user-helpers.ts +85 -0
- package/src/clis/xiaohongshu/user.ts +52 -32
- package/src/clis/zhihu/download.test.ts +12 -0
- package/src/clis/zhihu/download.ts +223 -0
- package/src/download/index.ts +395 -0
- package/src/download/progress.ts +125 -0
- package/src/engine.test.ts +17 -0
- package/src/main.ts +12 -3
- package/src/pipeline/registry.ts +2 -0
- package/src/pipeline/steps/download.ts +310 -0
- package/src/pipeline/template.ts +26 -0
- package/tests/e2e/browser-auth.test.ts +25 -0
package/dist/build-manifest.js
CHANGED
|
@@ -10,11 +10,108 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import * as fs from 'node:fs';
|
|
12
12
|
import * as path from 'node:path';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
14
14
|
import yaml from 'js-yaml';
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
const CLIS_DIR = path.resolve(__dirname, 'clis');
|
|
17
17
|
const OUTPUT = path.resolve(__dirname, '..', 'dist', 'cli-manifest.json');
|
|
18
|
+
function extractBalancedBlock(source, startIndex, openChar, closeChar) {
|
|
19
|
+
let depth = 0;
|
|
20
|
+
let quote = null;
|
|
21
|
+
let escaped = false;
|
|
22
|
+
for (let i = startIndex; i < source.length; i++) {
|
|
23
|
+
const ch = source[i];
|
|
24
|
+
if (quote) {
|
|
25
|
+
if (escaped) {
|
|
26
|
+
escaped = false;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (ch === '\\') {
|
|
30
|
+
escaped = true;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ch === quote)
|
|
34
|
+
quote = null;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (ch === '"' || ch === '\'' || ch === '`') {
|
|
38
|
+
quote = ch;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (ch === openChar) {
|
|
42
|
+
depth++;
|
|
43
|
+
}
|
|
44
|
+
else if (ch === closeChar) {
|
|
45
|
+
depth--;
|
|
46
|
+
if (depth === 0) {
|
|
47
|
+
return source.slice(startIndex + 1, i);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function extractTsArgsBlock(source) {
|
|
54
|
+
const argsMatch = source.match(/args\s*:/);
|
|
55
|
+
if (!argsMatch || argsMatch.index === undefined)
|
|
56
|
+
return null;
|
|
57
|
+
const bracketIndex = source.indexOf('[', argsMatch.index);
|
|
58
|
+
if (bracketIndex === -1)
|
|
59
|
+
return null;
|
|
60
|
+
return extractBalancedBlock(source, bracketIndex, '[', ']');
|
|
61
|
+
}
|
|
62
|
+
function parseInlineChoices(body) {
|
|
63
|
+
const choicesMatch = body.match(/choices\s*:\s*\[([^\]]*)\]/);
|
|
64
|
+
if (!choicesMatch)
|
|
65
|
+
return undefined;
|
|
66
|
+
const values = choicesMatch[1]
|
|
67
|
+
.split(',')
|
|
68
|
+
.map(s => s.trim().replace(/^['"`]|['"`]$/g, ''))
|
|
69
|
+
.filter(Boolean);
|
|
70
|
+
return values.length > 0 ? values : undefined;
|
|
71
|
+
}
|
|
72
|
+
export function parseTsArgsBlock(argsBlock) {
|
|
73
|
+
const args = [];
|
|
74
|
+
let cursor = 0;
|
|
75
|
+
while (cursor < argsBlock.length) {
|
|
76
|
+
const nameMatch = argsBlock.slice(cursor).match(/\{\s*name\s*:\s*['"`](\w+)['"`]/);
|
|
77
|
+
if (!nameMatch || nameMatch.index === undefined)
|
|
78
|
+
break;
|
|
79
|
+
const objectStart = cursor + nameMatch.index;
|
|
80
|
+
const body = extractBalancedBlock(argsBlock, objectStart, '{', '}');
|
|
81
|
+
if (body == null)
|
|
82
|
+
break;
|
|
83
|
+
const typeMatch = body.match(/type\s*:\s*['"`](\w+)['"`]/);
|
|
84
|
+
const defaultMatch = body.match(/default\s*:\s*([^,}]+)/);
|
|
85
|
+
const requiredMatch = body.match(/required\s*:\s*(true|false)/);
|
|
86
|
+
const helpMatch = body.match(/help\s*:\s*['"`]([^'"`]*)['"`]/);
|
|
87
|
+
const positionalMatch = body.match(/positional\s*:\s*(true|false)/);
|
|
88
|
+
let defaultVal = undefined;
|
|
89
|
+
if (defaultMatch) {
|
|
90
|
+
const raw = defaultMatch[1].trim();
|
|
91
|
+
if (raw === 'true')
|
|
92
|
+
defaultVal = true;
|
|
93
|
+
else if (raw === 'false')
|
|
94
|
+
defaultVal = false;
|
|
95
|
+
else if (/^\d+$/.test(raw))
|
|
96
|
+
defaultVal = parseInt(raw, 10);
|
|
97
|
+
else if (/^\d+\.\d+$/.test(raw))
|
|
98
|
+
defaultVal = parseFloat(raw);
|
|
99
|
+
else
|
|
100
|
+
defaultVal = raw.replace(/^['"`]|['"`]$/g, '');
|
|
101
|
+
}
|
|
102
|
+
args.push({
|
|
103
|
+
name: nameMatch[1],
|
|
104
|
+
type: typeMatch?.[1] ?? 'str',
|
|
105
|
+
default: defaultVal,
|
|
106
|
+
required: requiredMatch?.[1] === 'true',
|
|
107
|
+
positional: positionalMatch?.[1] === 'true' || undefined,
|
|
108
|
+
help: helpMatch?.[1] ?? '',
|
|
109
|
+
choices: parseInlineChoices(body),
|
|
110
|
+
});
|
|
111
|
+
cursor = objectStart + body.length + 2;
|
|
112
|
+
}
|
|
113
|
+
return args;
|
|
114
|
+
}
|
|
18
115
|
function scanYaml(filePath, site) {
|
|
19
116
|
try {
|
|
20
117
|
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
@@ -95,42 +192,9 @@ function scanTs(filePath, site) {
|
|
|
95
192
|
entry.columns = colMatch[1].split(',').map(s => s.trim().replace(/^['"`]|['"`]$/g, '')).filter(Boolean);
|
|
96
193
|
}
|
|
97
194
|
// Extract args array items: { name: '...', ... }
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
const argRegex = /\{\s*name\s*:\s*['"`](\w+)['"`]([^}]*)\}/g;
|
|
102
|
-
let m;
|
|
103
|
-
while ((m = argRegex.exec(argsBlock)) !== null) {
|
|
104
|
-
const argName = m[1];
|
|
105
|
-
const body = m[2];
|
|
106
|
-
const typeMatch = body.match(/type\s*:\s*['"`](\w+)['"`]/);
|
|
107
|
-
const defaultMatch = body.match(/default\s*:\s*([^,}]+)/);
|
|
108
|
-
const requiredMatch = body.match(/required\s*:\s*(true|false)/);
|
|
109
|
-
const helpMatch = body.match(/help\s*:\s*['"`]([^'"`]*)['"`]/);
|
|
110
|
-
const positionalMatch = body.match(/positional\s*:\s*(true|false)/);
|
|
111
|
-
let defaultVal = undefined;
|
|
112
|
-
if (defaultMatch) {
|
|
113
|
-
const raw = defaultMatch[1].trim();
|
|
114
|
-
if (raw === 'true')
|
|
115
|
-
defaultVal = true;
|
|
116
|
-
else if (raw === 'false')
|
|
117
|
-
defaultVal = false;
|
|
118
|
-
else if (/^\d+$/.test(raw))
|
|
119
|
-
defaultVal = parseInt(raw, 10);
|
|
120
|
-
else if (/^\d+\.\d+$/.test(raw))
|
|
121
|
-
defaultVal = parseFloat(raw);
|
|
122
|
-
else
|
|
123
|
-
defaultVal = raw.replace(/^['"`]|['"`]$/g, '');
|
|
124
|
-
}
|
|
125
|
-
entry.args.push({
|
|
126
|
-
name: argName,
|
|
127
|
-
type: typeMatch?.[1] ?? 'str',
|
|
128
|
-
default: defaultVal,
|
|
129
|
-
required: requiredMatch?.[1] === 'true',
|
|
130
|
-
positional: positionalMatch?.[1] === 'true' || undefined,
|
|
131
|
-
help: helpMatch?.[1] ?? '',
|
|
132
|
-
});
|
|
133
|
-
}
|
|
195
|
+
const argsBlock = extractTsArgsBlock(src);
|
|
196
|
+
if (argsBlock) {
|
|
197
|
+
entry.args = parseTsArgsBlock(argsBlock);
|
|
134
198
|
}
|
|
135
199
|
}
|
|
136
200
|
catch {
|
|
@@ -138,30 +202,38 @@ function scanTs(filePath, site) {
|
|
|
138
202
|
}
|
|
139
203
|
return entry;
|
|
140
204
|
}
|
|
141
|
-
|
|
142
|
-
const manifest = [];
|
|
143
|
-
if (fs.existsSync(CLIS_DIR)) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
205
|
+
export function buildManifest() {
|
|
206
|
+
const manifest = [];
|
|
207
|
+
if (fs.existsSync(CLIS_DIR)) {
|
|
208
|
+
for (const site of fs.readdirSync(CLIS_DIR)) {
|
|
209
|
+
const siteDir = path.join(CLIS_DIR, site);
|
|
210
|
+
if (!fs.statSync(siteDir).isDirectory())
|
|
211
|
+
continue;
|
|
212
|
+
for (const file of fs.readdirSync(siteDir)) {
|
|
213
|
+
const filePath = path.join(siteDir, file);
|
|
214
|
+
if (file.endsWith('.yaml') || file.endsWith('.yml')) {
|
|
215
|
+
const entry = scanYaml(filePath, site);
|
|
216
|
+
if (entry)
|
|
217
|
+
manifest.push(entry);
|
|
218
|
+
}
|
|
219
|
+
else if ((file.endsWith('.ts') && !file.endsWith('.d.ts') && file !== 'index.ts') ||
|
|
220
|
+
(file.endsWith('.js') && !file.endsWith('.d.js') && file !== 'index.js')) {
|
|
221
|
+
manifest.push(scanTs(filePath, site));
|
|
222
|
+
}
|
|
158
223
|
}
|
|
159
224
|
}
|
|
160
225
|
}
|
|
226
|
+
return manifest;
|
|
227
|
+
}
|
|
228
|
+
function main() {
|
|
229
|
+
const manifest = buildManifest();
|
|
230
|
+
fs.mkdirSync(path.dirname(OUTPUT), { recursive: true });
|
|
231
|
+
fs.writeFileSync(OUTPUT, JSON.stringify(manifest, null, 2));
|
|
232
|
+
const yamlCount = manifest.filter(e => e.type === 'yaml').length;
|
|
233
|
+
const tsCount = manifest.filter(e => e.type === 'ts').length;
|
|
234
|
+
console.log(`✅ Manifest compiled: ${manifest.length} entries (${yamlCount} YAML, ${tsCount} TS) → ${OUTPUT}`);
|
|
235
|
+
}
|
|
236
|
+
const entrypoint = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : null;
|
|
237
|
+
if (entrypoint === import.meta.url) {
|
|
238
|
+
main();
|
|
161
239
|
}
|
|
162
|
-
// Ensure output directory exists
|
|
163
|
-
fs.mkdirSync(path.dirname(OUTPUT), { recursive: true });
|
|
164
|
-
fs.writeFileSync(OUTPUT, JSON.stringify(manifest, null, 2));
|
|
165
|
-
const yamlCount = manifest.filter(e => e.type === 'yaml').length;
|
|
166
|
-
const tsCount = manifest.filter(e => e.type === 'ts').length;
|
|
167
|
-
console.log(`✅ Manifest compiled: ${manifest.length} entries (${yamlCount} YAML, ${tsCount} TS) → ${OUTPUT}`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { parseTsArgsBlock } from './build-manifest.js';
|
|
3
|
+
describe('parseTsArgsBlock', () => {
|
|
4
|
+
it('keeps args with nested choices arrays', () => {
|
|
5
|
+
const args = parseTsArgsBlock(`
|
|
6
|
+
{
|
|
7
|
+
name: 'period',
|
|
8
|
+
type: 'string',
|
|
9
|
+
default: 'seven',
|
|
10
|
+
help: 'Stats period: seven or thirty',
|
|
11
|
+
choices: ['seven', 'thirty'],
|
|
12
|
+
},
|
|
13
|
+
`);
|
|
14
|
+
expect(args).toEqual([
|
|
15
|
+
{
|
|
16
|
+
name: 'period',
|
|
17
|
+
type: 'string',
|
|
18
|
+
default: 'seven',
|
|
19
|
+
required: false,
|
|
20
|
+
positional: undefined,
|
|
21
|
+
help: 'Stats period: seven or thirty',
|
|
22
|
+
choices: ['seven', 'thirty'],
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
});
|