@numbered/docs-to-context 0.3.0 → 0.3.1
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/package.json +1 -1
- package/scripts/inject.ts +8 -4
package/package.json
CHANGED
package/scripts/inject.ts
CHANGED
|
@@ -30,6 +30,7 @@ const REGENERATE_CMD = 'bunx @numbered/docs-to-context'
|
|
|
30
30
|
interface CoreDocs {
|
|
31
31
|
frontend: string[]
|
|
32
32
|
entities: string[]
|
|
33
|
+
entitiesRoot: string
|
|
33
34
|
bestPractices: string[]
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -98,7 +99,7 @@ function copyBestPractices(projectRoot: string, platform: string): string[] {
|
|
|
98
99
|
|
|
99
100
|
function discoverCoreDocs(projectRoot: string, bestPractices: string[]): CoreDocs {
|
|
100
101
|
const docsDir = join(projectRoot, CORE_DOCS_ROOT)
|
|
101
|
-
const result: CoreDocs = { frontend: [], entities: [], bestPractices }
|
|
102
|
+
const result: CoreDocs = { frontend: [], entities: [], entitiesRoot: '', bestPractices }
|
|
102
103
|
|
|
103
104
|
if (!isDir(docsDir)) return result
|
|
104
105
|
|
|
@@ -110,7 +111,8 @@ function discoverCoreDocs(projectRoot: string, bestPractices: string[]): CoreDoc
|
|
|
110
111
|
// Entities: architecture specs
|
|
111
112
|
const archDir = join(docsDir, 'specs', 'architecture')
|
|
112
113
|
if (isDir(archDir)) {
|
|
113
|
-
result.
|
|
114
|
+
result.entitiesRoot = relative(docsDir, archDir)
|
|
115
|
+
result.entities = walkDir(archDir, ['.md', '.mdx']).map((f) => relative(archDir, f))
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
return result
|
|
@@ -163,9 +165,11 @@ function buildIndexBlock(indexPath: string, coreDocs: CoreDocs | null): string |
|
|
|
163
165
|
|
|
164
166
|
// Entities (grouped by directory)
|
|
165
167
|
if (coreDocs?.entities.length) {
|
|
166
|
-
|
|
168
|
+
const entRoot = coreDocs.entitiesRoot ? `${docsRoot}/${coreDocs.entitiesRoot}` : docsRoot
|
|
169
|
+
lines.push(`|[Entities]|root: ${entRoot}`)
|
|
167
170
|
for (const [dirPath, files] of groupByDir(coreDocs.entities)) {
|
|
168
|
-
|
|
171
|
+
const prefix = dirPath === '.' ? '' : `${dirPath}:`
|
|
172
|
+
lines.push(`|${prefix}{${files.join(',')}}`)
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
|