Skip to content

Commit e8a93fe

Browse files
committed
docs: add comprehensive JSDoc to all install script helper functions
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent eaf3b00 commit e8a93fe

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

postinstall.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,28 @@ const verbose = logger.verbose
6363
* Validates an agent file by reading and validating its content,
6464
* including version compatibility checking.
6565
*
66+
* Performs the following validations:
67+
* 1. Content structure validation (frontmatter, headers, keywords)
68+
* 2. Version compatibility checking against current OpenCode version
69+
*
6670
* @param {string} filePath - Path to the agent file to validate
6771
* @returns {{ valid: boolean, error?: string }} Validation result with optional error message
72+
*
73+
* @example
74+
* // Validate an agent file
75+
* const result = validateAgentFile('/path/to/agent.md')
76+
* if (!result.valid) {
77+
* console.error(`Validation failed: ${result.error}`)
78+
* }
79+
*
80+
* @example
81+
* // Use in a file copy loop
82+
* for (const file of agentFiles) {
83+
* const validation = validateAgentFile(join(sourceDir, file))
84+
* if (validation.valid) {
85+
* copyFileSync(join(sourceDir, file), join(targetDir, file))
86+
* }
87+
* }
6888
*/
6989
function validateAgentFile(filePath) {
7090
const content = readFileSync(filePath, "utf-8")
@@ -107,6 +127,13 @@ function validateAgentFile(filePath) {
107127
* - 0: All agents installed successfully, or partial success with some failures
108128
* - 1: Complete failure - source directory missing, no agent files found,
109129
* or all file copies failed
130+
*
131+
* @example
132+
* // Run as postinstall script
133+
* main().catch((err) => {
134+
* console.error("Unexpected error:", err.message)
135+
* process.exit(1)
136+
* })
110137
*/
111138
async function main() {
112139
const prefix = DRY_RUN ? "[DRY-RUN] " : ""

preuninstall.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ const verbose = logger.verbose
6767
* Exit codes:
6868
* - 0: Always exits successfully, even if no agents were removed or
6969
* some removals failed. This ensures npm uninstall completes.
70+
*
71+
* @example
72+
* // Run as preuninstall script
73+
* main().catch((err) => {
74+
* console.error("Unexpected error:", err.message)
75+
* // Don't exit with error code - we want uninstall to succeed
76+
* })
7077
*/
7178
async function main() {
7279
const prefix = DRY_RUN ? "[DRY-RUN] " : ""

0 commit comments

Comments
 (0)