diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3f6e5c..9035078 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,7 +68,7 @@ jobs: packages: write with: REGISTRY_NAMESPACE: ${{ needs.expose-vars.outputs.REGISTRY_NAMESPACE }} - PR_NUMBER: ${{ github.event.pull_request.number || github.event.number || null }} + PR_NUMBER: ${{ github.event.pull_request.number || github.event.number || '' }} MULTI_ARCH: ${{ needs.expose-vars.outputs.MULTI_ARCH == 'true' }} USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }} diff --git a/src/lib/prepare.ts b/src/lib/prepare.ts index 26974cd..2ed28cc 100644 --- a/src/lib/prepare.ts +++ b/src/lib/prepare.ts @@ -2,11 +2,11 @@ import { basename, dirname, parse, resolve } from 'node:path' import { appendFileSync, cpSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs' import YAML from 'yaml' import type { defineConfig } from 'vitepress' -import { generateFile } from '../templates/index.js' +import { generateFile, themeTemplates } from '../templates/index.js' import type { GlobalOpts } from '../schemas/global.js' import type { getUserInfos } from '../utils/functions.js' import { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js' -import { DOCS_DIR, FORKS_FILE, INDEX_FILE, TEMPLATE_THEME, VITEPRESS_CONFIG, VITEPRESS_THEME } from '../utils/const.js' +import { DOCS_DIR, FORKS_FILE, INDEX_FILE, VITEPRESS_CONFIG } from '../utils/const.js' import { replaceReadmePath, replaceRelativePath } from '../utils/regex.js' import { log } from '../utils/logger.js' import type { EnhancedRepository } from './fetch.js' @@ -241,10 +241,8 @@ export function generateVitepressFiles(vitepressConfig: Partial { + log(` Processing file '${path}'.`, 'debug') + generateFile(path, content) + }) } diff --git a/src/templates/index.ts b/src/templates/index.ts index a0afe1a..a959b46 100644 --- a/src/templates/index.ts +++ b/src/templates/index.ts @@ -1,9 +1,24 @@ import { readFileSync, writeFileSync } from 'node:fs' -import { dirname } from 'node:path' -import { createDir } from '../utils/functions.js' +import { dirname, resolve } from 'node:path' +import { TEMPLATE_THEME, VITEPRESS_THEME } from '../utils/const.js' +import { createDir, extractFiles } from '../utils/functions.js' -export function generateFile(src: string, dest: string) { - const content = readFileSync(src, { encoding: 'utf8' }) - createDir(dirname(dest)) - writeFileSync(dest, content) +export function generateFile(path: string, content: string) { + createDir(dirname(path)) + writeFileSync(path, content) } + +function getTemplates() { + console.log(extractFiles(TEMPLATE_THEME)) + return extractFiles(TEMPLATE_THEME).map((path) => { + const relativePath = path.replace(`${TEMPLATE_THEME}/`, '') + return { + path: resolve(VITEPRESS_THEME, relativePath), + content: readFileSync(path, { encoding: 'utf8' }), + } + }) +} + +export const themeTemplates = getTemplates() + +console.log({ themeTemplates })