@meistrari/tela-build 1.29.1 → 1.29.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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { execSync } from 'node:child_process'
|
|
3
|
+
import { existsSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
2
4
|
import { defineNuxtModule, createResolver } from '@nuxt/kit'
|
|
3
5
|
import { resolve } from 'pathe'
|
|
4
|
-
import { existsSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
5
6
|
import { collectComponentDocs, generateMarkdown, generateDocsToDirectory } from '../../lib/doc-generator'
|
|
6
7
|
import { ensureOverlayTsconfig } from '../../lib/extractors/volar-extract'
|
|
7
8
|
|
|
@@ -82,9 +83,11 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
82
83
|
// Generate documentation (directory-first unless outFile explicitly set)
|
|
83
84
|
logger.log(`${colors.gray}[tela/build] ${colors.orange}◐${colors.gray} Generating documentation for ${componentDocs.length} components${colors.reset}`)
|
|
84
85
|
|
|
86
|
+
const baseDir = findGitRoot(nuxt.options.rootDir) ?? nuxt.options.rootDir
|
|
87
|
+
|
|
85
88
|
if (options.outFile) {
|
|
86
89
|
// Single-file mode (legacy)
|
|
87
|
-
const outPath = resolve(
|
|
90
|
+
const outPath = resolve(baseDir, options.outFile)
|
|
88
91
|
const outDir = resolve(outPath, '..')
|
|
89
92
|
if (!existsSync(outDir)) {
|
|
90
93
|
mkdirSync(outDir, { recursive: true })
|
|
@@ -95,7 +98,7 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
95
98
|
}
|
|
96
99
|
else {
|
|
97
100
|
// Directory output: single Skill (tela-build) + supporting component pages
|
|
98
|
-
const outDir = resolve(
|
|
101
|
+
const outDir = resolve(baseDir, options.outDir!)
|
|
99
102
|
generateDocsToDirectory(componentDocs, typeResolver, outDir, layerPath)
|
|
100
103
|
logger.log(`${colors.gray}[tela/build] ${colors.green}●${colors.gray} Documentation complete → ${outDir}${colors.reset}`)
|
|
101
104
|
}
|
|
@@ -124,6 +127,15 @@ export default defineNuxtModule<TelaBuildDocsOptions>({
|
|
|
124
127
|
},
|
|
125
128
|
})
|
|
126
129
|
|
|
130
|
+
function findGitRoot(cwd: string): string | null {
|
|
131
|
+
try {
|
|
132
|
+
return execSync('git rev-parse --show-toplevel', { cwd, encoding: 'utf-8' }).trim()
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
127
139
|
function resolveLayerPath(): string | null {
|
|
128
140
|
// Use createResolver to resolve paths relative to this module
|
|
129
141
|
// This works correctly even when the module is installed from npm/github
|