@life-and-dev/mdsite 0.1.1 → 0.2.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/README.md +39 -21
- package/dist/commands/commands.test.js +91 -30
- package/dist/commands/commands.test.js.map +1 -1
- package/dist/commands/init.js +54 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/prepare.js +22 -14
- package/dist/commands/prepare.js.map +1 -1
- package/dist/commands/prepare.test.js +33 -39
- package/dist/commands/prepare.test.js.map +1 -1
- package/dist/commands/preview.d.ts +1 -0
- package/dist/commands/preview.js +11 -10
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/start.d.ts +1 -0
- package/dist/commands/start.js +23 -10
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.js +6 -3
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/workflows.test.js +76 -19
- package/dist/commands/workflows.test.js.map +1 -1
- package/dist/config/mdsite-config.js +1 -1
- package/dist/config/mdsite-config.js.map +1 -1
- package/dist/config/mdsite-config.test.js +1 -1
- package/dist/config/mdsite-config.test.js.map +1 -1
- package/dist/config/menu.js +0 -1
- package/dist/config/menu.js.map +1 -1
- package/dist/index.js +42 -7
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +40 -0
- package/dist/index.test.js.map +1 -1
- package/dist/process/child-process.test.js +3 -3
- package/dist/process/child-process.test.js.map +1 -1
- package/dist/process/runtime-state.d.ts +6 -5
- package/dist/process/runtime-state.js +13 -17
- package/dist/process/runtime-state.js.map +1 -1
- package/dist/process/runtime-state.test.js +21 -13
- package/dist/process/runtime-state.test.js.map +1 -1
- package/dist/renderer/mdsite-nuxt.d.ts +2 -0
- package/dist/renderer/mdsite-nuxt.js +29 -32
- package/dist/renderer/mdsite-nuxt.js.map +1 -1
- package/dist/renderer/mdsite-nuxt.test.js +37 -48
- package/dist/renderer/mdsite-nuxt.test.js.map +1 -1
- package/mdsite-nuxt/app/composables/useAppTheme.ts +22 -3
- package/mdsite-nuxt/app/config/themes.ts +38 -0
- package/mdsite-nuxt/nuxt.config.ts +11 -1
- package/mdsite-nuxt/scripts/generate-favicons.ts +24 -55
- package/mdsite-nuxt/scripts/renderer-hooks.test.ts +0 -8
- package/mdsite-nuxt/scripts/renderer-hooks.ts +1 -2
- package/mdsite-nuxt/scripts/sync-content.ts +5 -79
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
buildContentDataMock,
|
|
7
|
-
copyFaviconsToPublicMock,
|
|
8
7
|
existsSyncMock,
|
|
9
8
|
generateFaviconsMock,
|
|
10
9
|
generateWebManifestMock,
|
|
@@ -20,7 +19,6 @@ const {
|
|
|
20
19
|
writeFileSyncMock,
|
|
21
20
|
} = vi.hoisted(() => ({
|
|
22
21
|
buildContentDataMock: vi.fn(),
|
|
23
|
-
copyFaviconsToPublicMock: vi.fn(),
|
|
24
22
|
existsSyncMock: vi.fn(),
|
|
25
23
|
generateFaviconsMock: vi.fn(),
|
|
26
24
|
generateWebManifestMock: vi.fn(),
|
|
@@ -60,7 +58,6 @@ vi.mock('./generate-indices.js', () => ({
|
|
|
60
58
|
}))
|
|
61
59
|
|
|
62
60
|
vi.mock('./generate-favicons.js', () => ({
|
|
63
|
-
copyFaviconsToPublic: copyFaviconsToPublicMock,
|
|
64
61
|
generateFavicons: generateFaviconsMock,
|
|
65
62
|
generateWebManifest: generateWebManifestMock,
|
|
66
63
|
}))
|
|
@@ -99,7 +96,6 @@ describe('renderer hooks orchestration', () => {
|
|
|
99
96
|
stringifyYamlMock.mockReturnValue('compat-config')
|
|
100
97
|
generateFaviconsMock.mockResolvedValue(true)
|
|
101
98
|
buildContentDataMock.mockResolvedValue(undefined)
|
|
102
|
-
copyFaviconsToPublicMock.mockResolvedValue(undefined)
|
|
103
99
|
generateWebManifestMock.mockResolvedValue(undefined)
|
|
104
100
|
startWatcherMock.mockResolvedValue(undefined)
|
|
105
101
|
syncContentMock.mockResolvedValue(undefined)
|
|
@@ -255,7 +251,6 @@ describe('renderer hooks orchestration', () => {
|
|
|
255
251
|
expect(syncContentMock).toHaveBeenCalledTimes(1)
|
|
256
252
|
expect(buildContentDataMock).toHaveBeenCalledTimes(1)
|
|
257
253
|
expect(generateFaviconsMock).toHaveBeenCalledTimes(1)
|
|
258
|
-
expect(copyFaviconsToPublicMock).toHaveBeenCalledTimes(1)
|
|
259
254
|
expect(generateWebManifestMock).toHaveBeenCalledWith('Docs')
|
|
260
255
|
expect(syncContentMock.mock.invocationCallOrder[0]).toBeLessThan(buildContentDataMock.mock.invocationCallOrder[0])
|
|
261
256
|
expect(buildContentDataMock.mock.invocationCallOrder[0]).toBeLessThan(generateFaviconsMock.mock.invocationCallOrder[0])
|
|
@@ -268,7 +263,6 @@ describe('renderer hooks orchestration', () => {
|
|
|
268
263
|
expect(syncContentMock).toHaveBeenCalledTimes(1)
|
|
269
264
|
expect(buildContentDataMock).toHaveBeenCalledTimes(1)
|
|
270
265
|
expect(generateFaviconsMock).toHaveBeenCalledTimes(1)
|
|
271
|
-
expect(copyFaviconsToPublicMock).toHaveBeenCalledTimes(1)
|
|
272
266
|
expect(generateWebManifestMock).toHaveBeenCalledWith('Docs')
|
|
273
267
|
expect(startWatcherMock).not.toHaveBeenCalled()
|
|
274
268
|
expect(rmMock).not.toHaveBeenCalled()
|
|
@@ -292,7 +286,6 @@ describe('renderer hooks orchestration', () => {
|
|
|
292
286
|
|
|
293
287
|
expect(buildContentDataMock).toHaveBeenCalledTimes(1)
|
|
294
288
|
expect(generateFaviconsMock).toHaveBeenCalledTimes(1)
|
|
295
|
-
expect(copyFaviconsToPublicMock).not.toHaveBeenCalled()
|
|
296
289
|
expect(generateWebManifestMock).not.toHaveBeenCalled()
|
|
297
290
|
})
|
|
298
291
|
|
|
@@ -304,7 +297,6 @@ describe('renderer hooks orchestration', () => {
|
|
|
304
297
|
expect(syncContentMock).toHaveBeenCalledTimes(1)
|
|
305
298
|
expect(buildContentDataMock).toHaveBeenCalledTimes(1)
|
|
306
299
|
expect(generateFaviconsMock).toHaveBeenCalledTimes(1)
|
|
307
|
-
expect(copyFaviconsToPublicMock).not.toHaveBeenCalled()
|
|
308
300
|
expect(generateWebManifestMock).not.toHaveBeenCalled()
|
|
309
301
|
expect(process.env.MDSITE_RENDERER_ORCHESTRATED).toBe('1')
|
|
310
302
|
})
|
|
@@ -3,7 +3,7 @@ import path from 'path'
|
|
|
3
3
|
import YAML from 'yaml'
|
|
4
4
|
|
|
5
5
|
import { buildContentData } from './generate-indices.js'
|
|
6
|
-
import { generateFavicons,
|
|
6
|
+
import { generateFavicons, generateWebManifest } from './generate-favicons.js'
|
|
7
7
|
import { startWatcher, syncContent } from './sync-content.js'
|
|
8
8
|
import { loadMdsiteConfigSync, resolveMdsiteConfigPath } from '../utils/mdsite-config.js'
|
|
9
9
|
|
|
@@ -95,7 +95,6 @@ async function generateFaviconAssets(siteName: string): Promise<void> {
|
|
|
95
95
|
const success = await generateFavicons()
|
|
96
96
|
|
|
97
97
|
if (success) {
|
|
98
|
-
await copyFaviconsToPublic()
|
|
99
98
|
await generateWebManifest(siteName)
|
|
100
99
|
console.log(`✅ Favicons ready for ${siteName}\n`)
|
|
101
100
|
}
|
|
@@ -18,15 +18,6 @@ const STATIC_FILES = [
|
|
|
18
18
|
'site.webmanifest',
|
|
19
19
|
'robots.txt'
|
|
20
20
|
]
|
|
21
|
-
const LOGO_FILE = 'logo.svg'
|
|
22
|
-
const FAVICON_DIR = 'favicon'
|
|
23
|
-
const FAVICON_FILES = [
|
|
24
|
-
'favicon.svg',
|
|
25
|
-
'favicon.ico',
|
|
26
|
-
'apple-touch-icon.png',
|
|
27
|
-
'icon-192.png',
|
|
28
|
-
'icon-512.png'
|
|
29
|
-
]
|
|
30
21
|
|
|
31
22
|
// Debounce timers for JSON regeneration (5 second delay)
|
|
32
23
|
let navigationDebounceTimer: NodeJS.Timeout | null = null
|
|
@@ -118,45 +109,26 @@ export async function generateJsonFiles() {
|
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
/**
|
|
121
|
-
* Copy all images
|
|
112
|
+
* Copy all images from content to public directory (one-time)
|
|
122
113
|
*/
|
|
123
114
|
export async function copyAllImages() {
|
|
124
115
|
const sourceDir = getSourceDir()
|
|
125
116
|
const targetDir = getTargetDir()
|
|
126
117
|
|
|
127
|
-
console.log(`📦 Copying images
|
|
118
|
+
console.log(`📦 Copying images from: ${sourceDir}`)
|
|
128
119
|
console.log(`📦 Target directory: ${targetDir}`)
|
|
129
120
|
|
|
130
121
|
let copiedCount = 0
|
|
131
122
|
|
|
132
|
-
// Copy images (excluding logo.svg and favicon directory - handled separately)
|
|
133
123
|
for (const ext of IMAGE_EXTS) {
|
|
134
124
|
const files = await getAllFiles(sourceDir, ext)
|
|
135
125
|
|
|
136
126
|
for (const sourcePath of files) {
|
|
137
|
-
|
|
138
|
-
// Skip files in favicon directory - handled separately
|
|
139
|
-
if (sourcePath.includes(`${path.sep}${FAVICON_DIR}${path.sep}`)) {
|
|
140
|
-
continue
|
|
141
|
-
}
|
|
142
|
-
|
|
143
127
|
await copyImage(sourcePath, false)
|
|
144
128
|
copiedCount++
|
|
145
129
|
}
|
|
146
130
|
}
|
|
147
131
|
|
|
148
|
-
// Copy favicon files
|
|
149
|
-
const faviconDir = path.join(sourceDir, FAVICON_DIR)
|
|
150
|
-
if (await fs.pathExists(faviconDir)) {
|
|
151
|
-
for (const faviconFile of FAVICON_FILES) {
|
|
152
|
-
const sourcePath = path.join(faviconDir, faviconFile)
|
|
153
|
-
if (await fs.pathExists(sourcePath)) {
|
|
154
|
-
await copyFaviconFile(sourcePath, false)
|
|
155
|
-
copiedCount++
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
132
|
console.log(`✓ Copied ${copiedCount} file(s)\n`)
|
|
161
133
|
}
|
|
162
134
|
|
|
@@ -221,9 +193,7 @@ export async function startWatcher() {
|
|
|
221
193
|
watcher
|
|
222
194
|
.on('add', (filePath) => {
|
|
223
195
|
const fileName = path.basename(filePath)
|
|
224
|
-
if (fileName
|
|
225
|
-
handleLogoChange(filePath, 'added')
|
|
226
|
-
} else if (fileName.endsWith('.md')) {
|
|
196
|
+
if (fileName.endsWith('.md')) {
|
|
227
197
|
// Markdown file added - regenerate both navigation and search
|
|
228
198
|
console.log(`📝 Markdown added: ${fileName}`)
|
|
229
199
|
regenerateNavigation()
|
|
@@ -234,9 +204,7 @@ export async function startWatcher() {
|
|
|
234
204
|
})
|
|
235
205
|
.on('change', (filePath) => {
|
|
236
206
|
const fileName = path.basename(filePath)
|
|
237
|
-
if (fileName
|
|
238
|
-
handleLogoChange(filePath, 'updated')
|
|
239
|
-
} else if (fileName.endsWith('.md')) {
|
|
207
|
+
if (fileName.endsWith('.md')) {
|
|
240
208
|
// Markdown file changed - regenerate both navigation and search
|
|
241
209
|
console.log(`📝 Markdown updated: ${fileName}`)
|
|
242
210
|
regenerateNavigation()
|
|
@@ -247,9 +215,7 @@ export async function startWatcher() {
|
|
|
247
215
|
})
|
|
248
216
|
.on('unlink', (filePath) => {
|
|
249
217
|
const fileName = path.basename(filePath)
|
|
250
|
-
if (fileName
|
|
251
|
-
console.log(`🗑️ Logo removed: ${fileName}`)
|
|
252
|
-
} else if (fileName.endsWith('.md')) {
|
|
218
|
+
if (fileName.endsWith('.md')) {
|
|
253
219
|
// Markdown file deleted - regenerate both navigation and search
|
|
254
220
|
console.log(`📝 Markdown deleted: ${fileName}`)
|
|
255
221
|
regenerateNavigation()
|
|
@@ -363,46 +329,6 @@ async function isDraftOnlyImage(imagePath: string): Promise<boolean> {
|
|
|
363
329
|
return !hasPublishedVersion && hasDraftVersion
|
|
364
330
|
}
|
|
365
331
|
|
|
366
|
-
/**
|
|
367
|
-
* Copy a single favicon file from content to public
|
|
368
|
-
*/
|
|
369
|
-
async function copyFaviconFile(sourcePath: string, log: boolean = true, action: string = 'copied') {
|
|
370
|
-
try {
|
|
371
|
-
const targetDir = getTargetDir()
|
|
372
|
-
const fileName = path.basename(sourcePath)
|
|
373
|
-
const targetPath = path.join(targetDir, fileName)
|
|
374
|
-
|
|
375
|
-
await fs.ensureDir(targetDir)
|
|
376
|
-
await fs.copy(sourcePath, targetPath)
|
|
377
|
-
|
|
378
|
-
if (log) {
|
|
379
|
-
console.log(`✓ Favicon ${action}: ${fileName}`)
|
|
380
|
-
}
|
|
381
|
-
} catch (error) {
|
|
382
|
-
console.error(`❌ Failed to copy favicon ${sourcePath}:`, error)
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Handle logo.svg changes - regenerate favicons
|
|
388
|
-
*/
|
|
389
|
-
async function handleLogoChange(logoPath: string, action: string) {
|
|
390
|
-
const domain = getContentDomain()
|
|
391
|
-
console.log(`🎨 Logo ${action}, regenerating favicons for ${domain}...`)
|
|
392
|
-
|
|
393
|
-
try {
|
|
394
|
-
const { generateFavicons, copyFaviconsToPublic } = await import('./generate-favicons.js')
|
|
395
|
-
const success = await generateFavicons(domain)
|
|
396
|
-
|
|
397
|
-
if (success) {
|
|
398
|
-
await copyFaviconsToPublic(domain)
|
|
399
|
-
console.log(`✓ Favicons regenerated for ${domain}\n`)
|
|
400
|
-
}
|
|
401
|
-
} catch (error) {
|
|
402
|
-
console.error(`❌ Failed to regenerate favicons:`, error)
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
332
|
/**
|
|
407
333
|
* Get all files with specific extension recursively
|
|
408
334
|
*/
|