Skip to content

Commit

Permalink
Merge pull request #31 from this-is-tobi/develop
Browse files Browse the repository at this point in the history
fix: fix theme templates copy
  • Loading branch information
this-is-tobi authored Nov 24, 2024
2 parents 3e68b2a + 2d91a22 commit e587c4d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lib/prepare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vi.mock('../utils/const.js', () => ({
FORKS_FILE: '/tmp/docpress/mock/docs/forks.md',
VITEPRESS_CONFIG: '/tmp/docpress/mock/.vitepress/config.js',
VITEPRESS_THEME: '/tmp/docpress/mock/.vitepress/theme',
TEMPLATE_THEME: resolve(import.meta.dirname, '../templates/theme'),
TEMPLATE_THEME: resolve(import.meta.dirname, '../../public/templates/theme'),
}))
vi.mock('./git.js', async importOriginal => ({
...await importOriginal<typeof import('../utils/functions.js')>(),
Expand Down
12 changes: 5 additions & 7 deletions src/lib/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 } from '../utils/templates.js'
import type { GlobalOpts } from '../schemas/global.js'
import type { getUserInfos } from '../utils/functions.js'
import { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js'
Expand Down Expand Up @@ -241,10 +241,8 @@ export function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeo
log(` Generate index file.`, 'info')
writeFileSync(INDEX_FILE, separator.concat(YAML.stringify(index), separator))
log(` Add Docpress theme files.`, 'info')
const templates = extractFiles(TEMPLATE_THEME)
for (const filePath of templates) {
const relativePath = filePath.replace(`${TEMPLATE_THEME}/`, '')
log(` Processing file '${resolve(VITEPRESS_THEME, relativePath)}'.`, 'debug')
generateFile(resolve(TEMPLATE_THEME, filePath), resolve(VITEPRESS_THEME, relativePath))
}
return extractFiles(TEMPLATE_THEME).forEach((path) => {
const relativePath = path.replace(`${TEMPLATE_THEME}/`, '')
generateFile(path, resolve(VITEPRESS_THEME, relativePath))
})
}
5 changes: 4 additions & 1 deletion src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ export const VITEPRESS_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme

export const VITEPRESS_USER_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme/extras')

export const TEMPLATE_THEME = resolve(import.meta.dirname, '../templates/theme')
// eslint-disable-next-line dot-notation
export const TEMPLATE_THEME = process.env['NODE_ENV'] === 'development'
? resolve(import.meta.dirname, '../../public/templates/theme')
: resolve(import.meta.dirname, './templates/theme')
2 changes: 1 addition & 1 deletion src/templates/index.ts → src/utils/templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFileSync, writeFileSync } from 'node:fs'
import { dirname } from 'node:path'
import { createDir } from '../utils/functions.js'
import { createDir } from './functions.js'

export function generateFile(src: string, dest: string) {
const content = readFileSync(src, { encoding: 'utf8' })
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"baseUrl": "./",
"rootDir": "./src",
"rootDirs": ["./src", "./public"],
"types": [
"node",
"vite/client",
Expand Down Expand Up @@ -48,6 +48,7 @@
"include": [
"./src/**/*.ts",
"./src/**/*.d.ts",
"./public/**/*.ts",
],
"exclude": [
"./src/**/*.spec.ts",
Expand Down

0 comments on commit e587c4d

Please sign in to comment.