-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathgenerate-command-docs.js
More file actions
326 lines (273 loc) · 9.29 KB
/
generate-command-docs.js
File metadata and controls
326 lines (273 loc) · 9.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/usr/bin/env node
/**
* Generate comprehensive documentation for all CLI commands
* Extracts command metadata from bin/*.js files and creates structured docs
*/
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const BIN_DIR = path.join(__dirname, 'bin')
const DOCS_DIR = path.join(__dirname, 'docs', '02-commands')
// Command category mappings
const COMMAND_CATEGORIES = {
// Connection & Authentication
'connect': 'connection-auth',
'connectViaServiceKey': 'connection-auth',
'createJWT': 'connection-auth',
'inspectJWT': 'connection-auth',
'inspectUser': 'connection-auth',
'users': 'connection-auth',
'connections': 'connection-auth',
'certificates': 'security',
'certificatesUI': 'security',
'pwdPolicy': 'security',
// HDI Management
'activateHDI': 'hdi-management',
'adminHDI': 'hdi-management',
'adminHDIGroup': 'hdi-management',
'createContainer': 'hdi-management',
'createContainerUsers': 'hdi-management',
'createGroup': 'hdi-management',
'dropContainer': 'hdi-management',
'dropGroup': 'hdi-management',
'containers': 'hdi-management',
'containersUI': 'hdi-management',
// HANA Cloud
'hanaCloudInstances': 'hana-cloud',
'hanaCloudStart': 'hana-cloud',
'hanaCloudStop': 'hana-cloud',
'hanaCloudHDIInstances': 'hdi-management',
'hanaCloudSBSSInstances': 'hana-cloud',
'hanaCloudSchemaInstances': 'hana-cloud',
'hanaCloudSecureStoreInstances': 'hana-cloud',
'hanaCloudUPSInstances': 'hana-cloud',
'hanaCloudHDIInstancesUI': 'hdi-management',
'hanaCloudSBSSInstancesUI': 'hana-cloud',
'hanaCloudSchemaInstancesUI': 'hana-cloud',
'hanaCloudSecureStoreInstancesUI': 'hana-cloud',
'hanaCloudUPSInstancesUI': 'hana-cloud',
// Data Operations (extend from existing)
'dataSync': 'data-tools',
'compareData': 'data-tools',
'dataValidator': 'data-tools',
'tableCopy': 'schema-tools',
// Performance & Monitoring
'alerts': 'performance-monitoring',
'blocking': 'performance-monitoring',
'cacheStats': 'performance-monitoring',
'deadlocks': 'performance-monitoring',
'expensiveStatements': 'performance-monitoring',
'longRunning': 'performance-monitoring',
'memoryAnalysis': 'performance-monitoring',
'memoryLeaks': 'performance-monitoring',
'queryPlan': 'performance-monitoring',
'traceContents': 'performance-monitoring',
'traces': 'performance-monitoring',
'workloadManagement': 'performance-monitoring',
// Schema & Object Inspection
'inspectTable': 'object-inspection',
'inspectTableUI': 'object-inspection',
'inspectView': 'object-inspection',
'inspectFunction': 'object-inspection',
'inspectProcedure': 'object-inspection',
'inspectTrigger': 'object-inspection',
'inspectLibrary': 'object-inspection',
'inspectLibMember': 'object-inspection',
'tables': 'object-inspection',
'tablesUI': 'object-inspection',
'tablesPG': 'object-inspection',
'tablesSQLite': 'object-inspection',
'views': 'object-inspection',
'viewsPG': 'object-inspection',
'viewsSQLite': 'object-inspection',
'functions': 'object-inspection',
'functionsUI': 'object-inspection',
'functionsPG': 'object-inspection',
'functionsSQLite': 'object-inspection',
'procedures': 'object-inspection',
'proceduresUI': 'object-inspection',
'proceduresPG': 'object-inspection',
'proceduresSQLite': 'object-inspection',
'schemas': 'object-inspection',
'schemasUI': 'object-inspection',
'objects': 'object-inspection',
'indexes': 'object-inspection',
'indexesUI': 'object-inspection',
'sequences': 'object-inspection',
'triggers': 'object-inspection',
'libraries': 'object-inspection',
'partitions': 'object-inspection',
// Security
'encryptionStatus': 'security',
'privilegeAnalysis': 'security',
'privilegeError': 'security',
'securityScan': 'security',
'grantChains': 'security',
'roles': 'security',
'createXSAAdmin': 'security',
'massUsers': 'mass-operations',
'auditLog': 'security',
// Backup & Recovery
'backup': 'backup-recovery',
'backupList': 'backup-recovery',
'backupStatus': 'backup-recovery',
'restore': 'backup-recovery',
'reclaim': 'backup-recovery',
// Mass Operations
'massConvert': 'mass-operations',
'massConvertUI': 'mass-operations',
'massDelete': 'mass-operations',
'massExport': 'mass-operations',
'massGrant': 'mass-operations',
'massRename': 'mass-operations',
'massUpdate': 'mass-operations',
// BTP Integration
'btp': 'btp-integration',
'btpInfo': 'btp-integration',
'btpInfoUI': 'btp-integration',
'btpSubs': 'btp-integration',
'btpTarget': 'btp-integration',
'openBAS': 'btp-integration',
'openDBExplorer': 'btp-integration',
// System Admin
'diagnose': 'system-admin',
'healthCheck': 'system-admin',
'hostInformation': 'system-admin',
'status': 'system-admin',
'systemInfo': 'system-admin',
'systemInfoUI': 'system-admin',
'recommendations': 'system-admin',
'iniContents': 'system-admin',
'iniFiles': 'system-admin',
'features': 'system-admin',
'featuresUI': 'system-admin',
'featureUsage': 'system-admin',
'featureUsageUI': 'system-admin',
'dataTypes': 'system-admin',
'dataTypesUI': 'system-admin',
'dependencies': 'system-admin',
'disks': 'system-admin',
'ports': 'system-admin',
'crashDumps': 'system-admin',
// Developer Tools
'cds': 'developer-tools',
'createModule': 'developer-tools',
'generateDocs': 'developer-tools',
'helpDocu': 'developer-tools',
'issue': 'developer-tools',
'openChangeLog': 'developer-tools',
'openReadMe': 'developer-tools',
'readMe': 'developer-tools',
'readMeUI': 'developer-tools',
'changeLog': 'developer-tools',
'changeLogUI': 'developer-tools',
'hdbsql': 'developer-tools',
'querySimple': 'developer-tools',
'querySimpleUI': 'developer-tools',
'codeTemplate': 'developer-tools',
'callProcedure': 'developer-tools',
// Analysis Tools (extend from existing)
'dataProfile': 'analysis-tools',
'dataDiff': 'analysis-tools',
'dataLineage': 'analysis-tools',
'duplicateDetection': 'analysis-tools',
'referentialCheck': 'analysis-tools',
'calcViewAnalyzer': 'analysis-tools',
'columnStats': 'analysis-tools',
'erdDiagram': 'analysis-tools',
'fragmentationCheck': 'analysis-tools',
'tableHotspots': 'analysis-tools',
}
function getCategory(commandName) {
return COMMAND_CATEGORIES[commandName] || 'system-tools'
}
function generateCommandDoc(commandName, category) {
const docTemplate = `# ${commandName}
> Command: \`${commandName}\`
> Category: **${category.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')}**
> Status: Production Ready
## Description
The \`${commandName}\` command performs operations related to ${category.split('-').join(' ').toLowerCase()}.
## Syntax
\`\`\`bash
hana-cli ${commandName} [options]
\`\`\`
## Aliases
See command help for available aliases.
## Parameters
### Required Parameters
| Parameter | Description |
|-----------|-------------|
| - | *See 'hana-cli ${commandName} --help' for required parameters* |
### Optional Parameters
| Parameter | Alias | Description | Default |
|-----------|-------|-------------|---------|
| \`--help\` | \`-h\` | Display help information | false |
| \`--verbose\` | \`-v\` | Enable verbose output | false |
## Examples
### Basic Usage
\`\`\`bash
hana-cli ${commandName}
\`\`\`
For more examples, run:
\`\`\`bash
hana-cli ${commandName} --help
\`\`\`
## Documentation
For detailed command documentation, parameters, and examples, use:
\`\`\`bash
hana-cli ${commandName} --help
\`\`\`
## Related Commands
- [All Commands A-Z](../all-commands.md)
- [Commands Overview](..)
## See Also
- [Category: ${category.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')}](..)
- [Command Reference](../all-commands.md)
`
return docTemplate
}
async function main() {
try {
// Get all command files
const commandFiles = fs.readdirSync(BIN_DIR)
.filter(f => f.endsWith('.js') && f !== 'index.js')
.map(f => f.replace('.js', ''))
.sort()
console.log(`Found ${commandFiles.length} command files`)
let generated = 0
let skipped = 0
// Generate docs for each command
for (const commandName of commandFiles) {
const category = getCategory(commandName)
const categoryDir = path.join(DOCS_DIR, category)
// Create category dir if needed
if (!fs.existsSync(categoryDir)) {
fs.mkdirSync(categoryDir, { recursive: true })
}
// Use kebab-case for filenames
const fileName = commandName.replace(/([A-Z])/g, '-$1').toLowerCase().replace(/^-/, '') + '.md'
const filePath = path.join(categoryDir, fileName)
// Skip if file already exists (don't overwrite existing docs)
if (fs.existsSync(filePath)) {
skipped++
continue
}
const docContent = generateCommandDoc(commandName, category)
fs.writeFileSync(filePath, docContent, 'utf8')
generated++
if (generated % 20 === 0) {
console.log(`Generated ${generated} command docs...`)
}
}
console.log(`\n✅ Generation complete!`)
console.log(` Generated: ${generated} new docs`)
console.log(` Skipped: ${skipped} existing docs`)
console.log(` Total commands: ${commandFiles.length}`)
} catch (error) {
console.error('Error generating docs:', error)
process.exit(1)
}
}
main()