fix(docz-core): templates files

This commit is contained in:
Pedro Nauck
2018-04-15 00:19:09 -03:00
parent dec571325a
commit a5cda97d60
5 changed files with 12 additions and 17 deletions

View File

@@ -43,7 +43,7 @@ export interface ICompilerOpts {
args: ConfigArgs args: ConfigArgs
} }
export interface IConstructorParams<C, S> extends ICompilerOpts { export interface IBundlerConstructor<C, S> extends ICompilerOpts {
id: string id: string
config: TConfigFn<C> config: TConfigFn<C>
compiler: TCompilerFn<C> compiler: TCompilerFn<C>
@@ -61,14 +61,9 @@ export class Bundler<C = any, S = any> {
private compiler: TCompilerFn<C> private compiler: TCompilerFn<C>
private server: TServerFn<S> private server: TServerFn<S>
constructor({ constructor(params: IBundlerConstructor<C, S>) {
args, const { args, id, config, compiler, server } = params
id,
config,
compiler,
server,
}: IConstructorParams<C, S>) {
this.args = args this.args = args
this.id = id this.id = id
this.config = config this.config = config

View File

@@ -17,7 +17,7 @@ const getNameFromDoc = traverseAndAssign<any, string>(
path => path.node.arguments[0].value path => path.node.arguments[0].value
) )
export interface IConstructorParams { export interface IEntryConstructor {
file: string file: string
src: string src: string
} }
@@ -27,7 +27,7 @@ export class Entry {
public filepath: string public filepath: string
public route: string public route: string
constructor({ src, file }: IConstructorParams) { constructor({ src, file }: IEntryConstructor) {
const ast = convertToAst(file) const ast = convertToAst(file)
const name = getNameFromDoc(ast) || '' const name = getNameFromDoc(ast) || ''
const srcPath = path.resolve(paths.root, src) const srcPath = path.resolve(paths.root, src)

View File

@@ -14,7 +14,7 @@ const ENV = process.env.NODE_ENV
const HOST = process.env.HOST || '0.0.0.0' const HOST = process.env.HOST || '0.0.0.0'
const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http' const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http'
export interface IConstructorParams { export interface IServerConstructor {
port: number port: number
theme: string theme: string
files: string files: string
@@ -22,7 +22,7 @@ export interface IConstructorParams {
src: string src: string
} }
export interface ConfigArgs extends IConstructorParams { export interface ConfigArgs extends IServerConstructor {
paths: any paths: any
env: string env: string
host: string host: string
@@ -37,7 +37,7 @@ export class Server {
private entries: Entries private entries: Entries
private bundler: Bundler private bundler: Bundler
constructor(args: IConstructorParams) { constructor(args: IServerConstructor) {
const initialArgs = this.getInitialArgs(args) const initialArgs = this.getInitialArgs(args)
const { port, theme, files, bundler, src, plugins } = load( const { port, theme, files, bundler, src, plugins } = load(
'playgrodd', 'playgrodd',
@@ -61,7 +61,7 @@ export class Server {
}) })
} }
private getInitialArgs(args: IConstructorParams) { private getInitialArgs(args: IServerConstructor) {
return pick(['port', 'theme', 'files', 'bundler', 'src'], args) return pick(['port', 'theme', 'files', 'bundler', 'src'], args)
} }

View File

@@ -6,7 +6,7 @@ import { Theme } from '<%- THEME %>'
window.__DOCZ_ROUTES__ = <%- ROUTES %> window.__DOCZ_ROUTES__ = <%- ROUTES %>
const _wrappers = [<%- WRAPPERS %>] const _wrappers = [<% if (WRAPPERS) {%><%- WRAPPERS %><%}%>]
const recursiveWrappers = ([Wrapper, ...rest], props) => ( const recursiveWrappers = ([Wrapper, ...rest], props) => (
<Wrapper {...props}> <Wrapper {...props}>

View File

@@ -2,8 +2,8 @@ import React from 'react'
import { render } from 'react-dom' import { render } from 'react-dom'
import { App } from './app' import { App } from './app'
const _beforeRenders = [<%- BEFORE_RENDERS %>] const _beforeRenders = [<% if (BEFORE_RENDERS) {%><%- BEFORE_RENDERS %><%}%>]
const _afterRenders = [<%- AFTER_RENDERS %>] const _afterRenders = [<% if (AFTER_RENDERS) {%><%- AFTER_RENDERS %><%}%>]
const beforeRender = () => _beforeRenders.forEach(f => f && f()) const beforeRender = () => _beforeRenders.forEach(f => f && f())
const afterRender = () => _afterRenders.forEach(f => f && f()) const afterRender = () => _afterRenders.forEach(f => f && f())