Skip to content

Commit

Permalink
fix(docz-core): templates files
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Apr 15, 2018
1 parent dec5713 commit a5cda97
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
11 changes: 3 additions & 8 deletions packages/playgrodd-core/src/Bundler.ts
Expand Up @@ -43,7 +43,7 @@ export interface ICompilerOpts {
args: ConfigArgs
}

export interface IConstructorParams<C, S> extends ICompilerOpts {
export interface IBundlerConstructor<C, S> extends ICompilerOpts {
id: string
config: TConfigFn<C>
compiler: TCompilerFn<C>
Expand All @@ -61,14 +61,9 @@ export class Bundler<C = any, S = any> {
private compiler: TCompilerFn<C>
private server: TServerFn<S>

constructor({
args,
constructor(params: IBundlerConstructor<C, S>) {
const { args, id, config, compiler, server } = params

id,
config,
compiler,
server,
}: IConstructorParams<C, S>) {
this.args = args
this.id = id
this.config = config
Expand Down
4 changes: 2 additions & 2 deletions packages/playgrodd-core/src/Entry.ts
Expand Up @@ -17,7 +17,7 @@ const getNameFromDoc = traverseAndAssign<any, string>(
path => path.node.arguments[0].value
)

export interface IConstructorParams {
export interface IEntryConstructor {
file: string
src: string
}
Expand All @@ -27,7 +27,7 @@ export class Entry {
public filepath: string
public route: string

constructor({ src, file }: IConstructorParams) {
constructor({ src, file }: IEntryConstructor) {
const ast = convertToAst(file)
const name = getNameFromDoc(ast) || ''
const srcPath = path.resolve(paths.root, src)
Expand Down
8 changes: 4 additions & 4 deletions packages/playgrodd-core/src/server.ts
Expand Up @@ -14,15 +14,15 @@ const ENV = process.env.NODE_ENV
const HOST = process.env.HOST || '0.0.0.0'
const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http'

export interface IConstructorParams {
export interface IServerConstructor {
port: number
theme: string
files: string
bundler: string
src: string
}

export interface ConfigArgs extends IConstructorParams {
export interface ConfigArgs extends IServerConstructor {
paths: any
env: string
host: string
Expand All @@ -37,7 +37,7 @@ export class Server {
private entries: Entries
private bundler: Bundler

constructor(args: IConstructorParams) {
constructor(args: IServerConstructor) {
const initialArgs = this.getInitialArgs(args)
const { port, theme, files, bundler, src, plugins } = load(
'playgrodd',
Expand All @@ -61,7 +61,7 @@ export class Server {
})
}

private getInitialArgs(args: IConstructorParams) {
private getInitialArgs(args: IServerConstructor) {
return pick(['port', 'theme', 'files', 'bundler', 'src'], args)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/playgrodd-core/templates/app.tpl.js
Expand Up @@ -6,7 +6,7 @@ import { Theme } from '<%- THEME %>'

window.__DOCZ_ROUTES__ = <%- ROUTES %>

const _wrappers = [<%- WRAPPERS %>]
const _wrappers = [<% if (WRAPPERS) {%><%- WRAPPERS %><%}%>]

const recursiveWrappers = ([Wrapper, ...rest], props) => (
<Wrapper {...props}>
Expand Down
4 changes: 2 additions & 2 deletions packages/playgrodd-core/templates/index.tpl.js
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import { render } from 'react-dom'
import { App } from './app'

const _beforeRenders = [<%- BEFORE_RENDERS %>]
const _afterRenders = [<%- AFTER_RENDERS %>]
const _beforeRenders = [<% if (BEFORE_RENDERS) {%><%- BEFORE_RENDERS %><%}%>]
const _afterRenders = [<% if (AFTER_RENDERS) {%><%- AFTER_RENDERS %><%}%>]

const beforeRender = () => _beforeRenders.forEach(f => f && f())
const afterRender = () => _afterRenders.forEach(f => f && f())
Expand Down

0 comments on commit a5cda97

Please sign in to comment.