From 8d10aa79ed876875ef553d2ad750585e1c2cc0ff Mon Sep 17 00:00:00 2001 From: Pedro Nauck Date: Tue, 24 Apr 2018 10:21:01 -0300 Subject: [PATCH] chore: use template on core package --- packages/docz/src/Entries.ts | 17 ++++++++--------- packages/docz/src/config/paths.ts | 5 +---- .../{docz-react => docz}/templates/app.tpl.js | 0 .../templates/index.tpl.html | 0 .../{docz-react => docz}/templates/index.tpl.js | 0 5 files changed, 9 insertions(+), 13 deletions(-) rename packages/{docz-react => docz}/templates/app.tpl.js (100%) rename packages/{docz-react => docz}/templates/index.tpl.html (100%) rename packages/{docz-react => docz}/templates/index.tpl.js (100%) diff --git a/packages/docz/src/Entries.ts b/packages/docz/src/Entries.ts index 1299e10..bdb7593 100644 --- a/packages/docz/src/Entries.ts +++ b/packages/docz/src/Entries.ts @@ -10,7 +10,7 @@ import { propOf } from './utils/helpers' import { format } from './utils/format' import { Entry } from './Entry' -import { ConfigArgs, AppType } from './Server' +import { ConfigArgs } from './Server' const mkd = (dir: string): void => { try { @@ -27,8 +27,12 @@ const touch = (file: string, raw: string) => { fs.writeFileSync(file, content, 'utf-8') } -const compiled = (type: AppType) => (file: string) => - compile(fs.readFileSync(path.join(paths.templatesOf(type), file), 'utf-8')) +const compiled = (file: string) => + compile(fs.readFileSync(path.join(paths.templates, file), 'utf-8')) + +const app = compiled('app.tpl.js') +const js = compiled('index.tpl.js') +const html = compiled('index.tpl.html') export class Entries { public files: string[] @@ -80,12 +84,7 @@ export class Entries { } public write(): void { - const { plugins, title, description, theme, type } = this.config - const template = compiled(type) - - const app = template('app.tpl.js') - const js = template('index.tpl.js') - const html = template('index.tpl.html') + const { plugins, title, description, theme } = this.config const wrappers = propOf(plugins, 'wrapper') const afterRenders = propOf(plugins, 'afterRender') diff --git a/packages/docz/src/config/paths.ts b/packages/docz/src/config/paths.ts index 00c56ef..87e9cf9 100644 --- a/packages/docz/src/config/paths.ts +++ b/packages/docz/src/config/paths.ts @@ -3,8 +3,6 @@ import * as path from 'path' import * as url from 'url' import resolve from 'resolve' -import { AppType } from '../Server' - const ENV_PUBLIC_URL = process.env.PUBLIC_URL const ensureSlash = (filepath: any, needsSlash: boolean) => { @@ -45,8 +43,7 @@ export interface Paths { indexHtml: string } -export const templatesOf = (type: AppType) => - path.join(resolve.sync(`docz-${type}`), '../templates') +export const templates = path.join(resolve.sync('docz'), '../templates') export const docz = resolveApp('.docz') export const packageJson = resolveApp('package.json') diff --git a/packages/docz-react/templates/app.tpl.js b/packages/docz/templates/app.tpl.js similarity index 100% rename from packages/docz-react/templates/app.tpl.js rename to packages/docz/templates/app.tpl.js diff --git a/packages/docz-react/templates/index.tpl.html b/packages/docz/templates/index.tpl.html similarity index 100% rename from packages/docz-react/templates/index.tpl.html rename to packages/docz/templates/index.tpl.html diff --git a/packages/docz-react/templates/index.tpl.js b/packages/docz/templates/index.tpl.js similarity index 100% rename from packages/docz-react/templates/index.tpl.js rename to packages/docz/templates/index.tpl.js