mirror of
https://github.com/zhigang1992/docz.git
synced 2026-03-26 10:14:33 +08:00
chore: improve monorepo architecture
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "docz start"
|
||||
"dev": "docz dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"docz": "^0.0.1",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { Fragment } from 'react'
|
||||
import { doc } from 'docz-react'
|
||||
import { doc } from 'docz'
|
||||
|
||||
import { Alert } from './Alert'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { doc } from 'docz-react'
|
||||
import { doc } from 'docz'
|
||||
|
||||
import { Button } from './Button'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { doc } from 'docz-react'
|
||||
import { doc } from 'docz'
|
||||
|
||||
doc('withProps')
|
||||
.category('Hocs')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { doc } from 'docz-react'
|
||||
import { doc } from 'docz'
|
||||
import Markdown from 'react-markdown'
|
||||
|
||||
const description = `
|
||||
@@ -17,4 +17,4 @@ A design system can help establish a common vocabulary between everyone in an or
|
||||
doc('Overview')
|
||||
.route('/')
|
||||
.order(1)
|
||||
.description(<Markdown source={description} />)
|
||||
.description(description)
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
"typescript": "^2.8.3"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"packages/bundlers/*",
|
||||
"packages/core/*",
|
||||
"packages/renders/*",
|
||||
"packages/themes/*",
|
||||
"examples/*"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"babel-polyfill": "^7.0.0-beta.3",
|
||||
"babel-preset-react-app": "^4.0.0-next.b2fd8db8",
|
||||
"deepmerge": "^2.1.0",
|
||||
"docz": "^0.0.1",
|
||||
"docz-bundler": "^0.0.1",
|
||||
"express": "^4.16.3",
|
||||
"file-loader": "^1.1.11",
|
||||
"friendly-errors-webpack-plugin": "^1.7.0",
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as path from 'path'
|
||||
import * as webpack from 'webpack'
|
||||
import { Configuration } from 'webpack'
|
||||
import { ConfigArgs } from 'docz'
|
||||
import { Args } from 'docz-bundler'
|
||||
import { load } from 'load-cfg'
|
||||
import merge from 'deepmerge'
|
||||
import Webpackbar from 'webpackbar'
|
||||
@@ -11,7 +11,7 @@ import friendlyErrors from 'friendly-errors-webpack-plugin'
|
||||
|
||||
const INLINE_LIMIT = 10000
|
||||
|
||||
export const createConfig = (args: ConfigArgs) => (): Configuration => {
|
||||
export const createConfig = (args: Args) => (): Configuration => {
|
||||
const { paths, env, debug } = args
|
||||
|
||||
const isProd = env === 'production'
|
||||
@@ -1,13 +1,8 @@
|
||||
import { ConfigArgs } from 'docz'
|
||||
import { Args } from 'docz-bundler'
|
||||
import { Application } from 'express'
|
||||
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware'
|
||||
|
||||
export const devServerConfig = ({
|
||||
paths,
|
||||
host,
|
||||
debug,
|
||||
protocol,
|
||||
}: ConfigArgs) => ({
|
||||
export const devServerConfig = ({ paths, host, debug, protocol }: Args) => ({
|
||||
host,
|
||||
before(app: Application): void {
|
||||
!debug && app.use(errorOverlayMiddleware())
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Configuration as CFG } from 'webpack'
|
||||
import { ConfigArgs, createBundler, BundlerCreate, BundlerServer } from 'docz'
|
||||
import * as WebpackDevServer from 'webpack-dev-server'
|
||||
import { createBundler, Args, BundlerCreate, BundlerServer } from 'docz-bundler'
|
||||
import WebpackDevServer from 'webpack-dev-server'
|
||||
import webpack from 'webpack'
|
||||
|
||||
import { devServerConfig } from './devserver'
|
||||
import { createConfig as config } from './config'
|
||||
|
||||
export const server = (args: ConfigArgs) => (config: CFG): BundlerServer => {
|
||||
export const server = (args: Args) => (config: CFG): BundlerServer => {
|
||||
const compiler = webpack(config)
|
||||
const devserver = devServerConfig(args)
|
||||
const server = new WebpackDevServer(compiler, devserver)
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
@@ -1,23 +1,13 @@
|
||||
{
|
||||
"name": "docz",
|
||||
"name": "docz-bundler",
|
||||
"version": "0.0.1",
|
||||
"main": "dist/index.js",
|
||||
"umd:main": "dist/index.umd.js",
|
||||
"module": "dist/index.m.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"source": [
|
||||
"src/index.ts",
|
||||
"src/Doc.ts",
|
||||
"src/utils/helpers.ts"
|
||||
],
|
||||
"bin": {
|
||||
"docz": "./bin/index.js"
|
||||
},
|
||||
"source": "src/index.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"doc.d.ts",
|
||||
"doc.js",
|
||||
"utils.js",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
@@ -29,7 +19,6 @@
|
||||
"tslint": "tslint --project ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "^0.1.1",
|
||||
"art-template": "^4.12.2",
|
||||
"babel-file-loader": "^1.0.3",
|
||||
"babel-generator": "^6.26.1",
|
||||
@@ -37,8 +26,6 @@
|
||||
"babel-types": "^6.26.0",
|
||||
"chokidar": "^2.0.3",
|
||||
"del": "3.0.0",
|
||||
"docz-bundler-webpack": "^0.0.1",
|
||||
"docz-theme-default": "^0.0.1",
|
||||
"express": "^4.16.3",
|
||||
"fast-glob": "^2.2.0",
|
||||
"json-stringify-pretty-compact": "^1.1.0",
|
||||
@@ -56,7 +43,6 @@
|
||||
"@types/chokidar": "^1.7.5",
|
||||
"@types/del": "^3.0.1",
|
||||
"@types/express": "^4.11.1",
|
||||
"@types/lodash.get": "^4.4.3",
|
||||
"@types/mkdirp": "^0.5.2",
|
||||
"@types/prettier": "^1.12.0",
|
||||
"@types/resolve": "^0.0.7",
|
||||
@@ -50,7 +50,7 @@ export class Entries {
|
||||
this.files = files
|
||||
this.config = config
|
||||
this.entries = files
|
||||
.filter(Entry.check(config.type))
|
||||
.filter(Entry.check)
|
||||
.map(file => new Entry(file, config.src))
|
||||
}
|
||||
|
||||
@@ -8,10 +8,9 @@ import get from 'lodash.get'
|
||||
import * as paths from './config/paths'
|
||||
import { format } from './utils/format'
|
||||
import { traverseAndAssign, traverseAndAssignEach } from './utils/traverse'
|
||||
import { AppType } from './Server'
|
||||
|
||||
const hasImport = (p: NodePath<any>, type: AppType): boolean =>
|
||||
t.isImportDeclaration(p) && get(p, 'node.source.value') === `docz-${type}`
|
||||
const hasImport = (p: NodePath<any>): boolean =>
|
||||
t.isImportDeclaration(p) && get(p, 'node.source.value') === `docz`
|
||||
|
||||
const hasDocFn = (p: NodePath<any>): boolean =>
|
||||
p.node.specifiers &&
|
||||
@@ -20,11 +19,10 @@ const hasDocFn = (p: NodePath<any>): boolean =>
|
||||
t.isImportSpecifier(node) && node.imported.name === 'doc'
|
||||
)
|
||||
|
||||
const checkImport = (type: AppType) =>
|
||||
traverseAndAssign<NodePath<t.Node>, boolean>({
|
||||
when: p => hasImport(p, type) && hasDocFn(p),
|
||||
assign: () => true,
|
||||
})
|
||||
const checkImport = traverseAndAssign<NodePath<t.Node>, boolean>({
|
||||
when: p => hasImport(p) && hasDocFn(p),
|
||||
assign: () => true,
|
||||
})
|
||||
|
||||
const getNameFromDoc = traverseAndAssign<any, string>({
|
||||
when: p => p.isCallExpression() && get(p, 'node.callee.name') === 'doc',
|
||||
@@ -51,8 +49,8 @@ const parseSections = traverseAndAssignEach<NodePath<t.Node>, string[]>({
|
||||
export class Entry {
|
||||
readonly [key: string]: any
|
||||
|
||||
public static check(type: AppType): (file: string) => boolean | null {
|
||||
return file => checkImport(type)(file)
|
||||
public static check(file: string): boolean | null {
|
||||
return checkImport(file)
|
||||
}
|
||||
|
||||
public static parseName(file: string): string | null {
|
||||
@@ -1,7 +1,6 @@
|
||||
import { isFn } from './utils/helpers'
|
||||
|
||||
export type BundlerConfig = <Config>(config: Config, dev: boolean) => Config
|
||||
export type BundlerCompiler = <Compiler>(compiler: Compiler) => void
|
||||
export type BundlerServer = <Server>(server: Server) => void
|
||||
export type BeforeRender = () => void
|
||||
export type AfterRender = () => void
|
||||
@@ -9,7 +8,6 @@ export type Wrapper = <R>(props: { children: any }) => R
|
||||
|
||||
export interface PluginFactory {
|
||||
bundlerConfig: BundlerConfig
|
||||
bundlerCompiler: BundlerCompiler
|
||||
bundlerServer: BundlerServer
|
||||
beforeRender: BeforeRender
|
||||
afterRender: AfterRender
|
||||
@@ -18,7 +16,6 @@ export interface PluginFactory {
|
||||
|
||||
export class Plugin {
|
||||
public readonly bundlerConfig: BundlerConfig
|
||||
public readonly bundlerCompiler: BundlerCompiler
|
||||
public readonly bundlerServer: BundlerServer
|
||||
public readonly beforeRender: BeforeRender
|
||||
public readonly afterRender: AfterRender
|
||||
@@ -29,10 +26,6 @@ export class Plugin {
|
||||
return isFn(p.bundlerConfig) && p.bundlerConfig(config, dev)
|
||||
}
|
||||
|
||||
this.bundlerCompiler = async (compiler: any) => {
|
||||
isFn(p.bundlerCompiler) && (await p.bundlerCompiler(compiler))
|
||||
}
|
||||
|
||||
this.bundlerServer = async (server: any) => {
|
||||
isFn(p.bundlerServer) && (await p.bundlerServer(server))
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import * as chokidar from 'chokidar'
|
||||
import del from 'del'
|
||||
|
||||
import * as paths from './config/paths'
|
||||
|
||||
import { Entry } from './Entry'
|
||||
import { Entries } from './Entries'
|
||||
import { Bundler } from './Bundler'
|
||||
59
packages/core/docz-bundler/src/args.ts
Normal file
59
packages/core/docz-bundler/src/args.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
const EXTS = '{j,t}{s,sx}'
|
||||
const DEFAULT_FILES_GLOB = [
|
||||
`docs/**.${EXTS}`,
|
||||
`**/__docs__/*.${EXTS}`,
|
||||
`**/*.doc.${EXTS}`,
|
||||
]
|
||||
|
||||
export const createArgs = (yargs: any) => {
|
||||
yargs.positional('source', {
|
||||
alias: 'src',
|
||||
type: 'string',
|
||||
default: 'src/',
|
||||
})
|
||||
yargs.positional('files', {
|
||||
type: 'string',
|
||||
default: DEFAULT_FILES_GLOB,
|
||||
})
|
||||
yargs.positional('type', {
|
||||
type: 'string',
|
||||
default: 'react',
|
||||
})
|
||||
yargs.positional('bundler', {
|
||||
type: 'string',
|
||||
default: 'webpack',
|
||||
})
|
||||
yargs.positional('title', {
|
||||
type: 'string',
|
||||
default: 'Docz',
|
||||
})
|
||||
yargs.positional('description', {
|
||||
type: 'string',
|
||||
default: 'My awesome design system!',
|
||||
})
|
||||
yargs.positional('theme', {
|
||||
type: 'string',
|
||||
default: 'docz-theme-default',
|
||||
})
|
||||
yargs.positional('env', {
|
||||
type: 'boolean',
|
||||
default: process.env.NODE_ENV || 'development',
|
||||
})
|
||||
yargs.positional('debug', {
|
||||
type: 'boolean',
|
||||
default: process.env.DEBUG || false,
|
||||
})
|
||||
yargs.positional('protocol', {
|
||||
type: 'string',
|
||||
default: process.env.HTTPS === 'true' ? 'https' : 'http',
|
||||
})
|
||||
yargs.positional('host', {
|
||||
type: 'string',
|
||||
default: process.env.HOST || '0.0.0.0',
|
||||
})
|
||||
yargs.positional('port', {
|
||||
alias: 'p',
|
||||
type: 'number',
|
||||
default: process.env.PORT || 3000,
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as url from 'url'
|
||||
import resolve from 'resolve'
|
||||
import * as resolve from 'resolve'
|
||||
|
||||
const ENV_PUBLIC_URL = process.env.PUBLIC_URL
|
||||
|
||||
@@ -43,7 +43,7 @@ export interface Paths {
|
||||
indexHtml: string
|
||||
}
|
||||
|
||||
export const templates = path.join(resolve.sync('docz'), '../templates')
|
||||
export const templates = path.join(resolve.sync('docz-bundler'), '../templates')
|
||||
|
||||
export const docz = resolveApp('.docz')
|
||||
export const packageJson = resolveApp('package.json')
|
||||
@@ -1,4 +1,5 @@
|
||||
export { Entry } from './Entry'
|
||||
export { createBundler, BundlerCreate, BundlerServer } from './Bundler'
|
||||
export { createPlugin } from './Plugin'
|
||||
export { Server, ConfigArgs } from './Server'
|
||||
export { Server, ConfigArgs as Args } from './Server'
|
||||
export { createArgs } from './args'
|
||||
@@ -2,4 +2,4 @@ declare module 'art-template'
|
||||
declare module 'babel-file-loader'
|
||||
declare module 'babel-generator'
|
||||
declare module 'json-stringify-pretty-compact'
|
||||
declare module '@sindresorhus/slugify'
|
||||
declare module 'lodash.get'
|
||||
@@ -2,7 +2,6 @@ const { keys } = Object
|
||||
|
||||
export const isFn = (value: any): boolean => typeof value === 'function'
|
||||
export const prop = (key: string, obj: any): any => obj[key]
|
||||
export const safeUrl = (value: string) => encodeURI(value.replace(/\s/g, ''))
|
||||
|
||||
export function omit<R = object>(props: string[], obj: any): R {
|
||||
const newObj = keys(obj)
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"declaration": true,
|
||||
"typeRoots": ["node_modules/@types", "index.d.ts"]
|
||||
"typeRoots": ["node_modules/@types", "src/types"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/**"]
|
||||
35
packages/core/docz-theme/package.json
Normal file
35
packages/core/docz-theme/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "docz-theme",
|
||||
"version": "0.0.1",
|
||||
"main": "dist/index.js",
|
||||
"umd:main": "dist/index.umd.js",
|
||||
"module": "dist/index.m.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"source": "src/index.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "libundler watch --ts",
|
||||
"build": "libundler build --ts --c",
|
||||
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" --write",
|
||||
"fix:tslint": "yarn run tslint --fix",
|
||||
"tslint": "tslint --project ."
|
||||
},
|
||||
"dependencies": {
|
||||
"docz": "^0.0.1",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"docz": "^0.0.1",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.3.12",
|
||||
"@types/react-dom": "^16.0.5"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as React from 'react'
|
||||
import { Doc, DocObj, Entry } from 'docz/doc'
|
||||
import { isFn } from 'docz/utils'
|
||||
|
||||
import { cache, Doc, DocObj, Entry } from 'docz'
|
||||
|
||||
console.log(cache)
|
||||
|
||||
export const isFn = (value: any): boolean => typeof value === 'function'
|
||||
|
||||
export interface DocsRenderProps {
|
||||
docs: DocObj[]
|
||||
@@ -11,7 +15,6 @@ export interface DocsProps {
|
||||
children: (renderProps: DocsRenderProps) => React.ReactNode
|
||||
}
|
||||
|
||||
export const cache = new Map()
|
||||
export const entriesContext = React.createContext([] as Entry[])
|
||||
|
||||
const mergeDocsWithEntries = (docs: Doc[], entries: Entry[]): DocObj[] =>
|
||||
2
packages/core/docz-theme/src/index.ts
Normal file
2
packages/core/docz-theme/src/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { theme } from './theme'
|
||||
export { Docs } from './Docs'
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react'
|
||||
import { ComponentType } from 'react'
|
||||
import { Entry } from 'docz/doc'
|
||||
|
||||
import { Entry } from 'docz'
|
||||
import { entriesContext } from './Docs'
|
||||
|
||||
export interface ThemeProps {
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
3
packages/core/docz-theme/tslint.json
Normal file
3
packages/core/docz-theme/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["../../tslint.json"]
|
||||
}
|
||||
14
packages/core/docz/bin/index.js
Executable file
14
packages/core/docz/bin/index.js
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const yargs = require('yargs')
|
||||
const { Server, createArgs } = require('docz-bundler')
|
||||
|
||||
yargs
|
||||
.command('dev [files]', 'initialize docz dev server', createArgs, argv =>
|
||||
new Server(argv).start()
|
||||
)
|
||||
.demandCommand()
|
||||
.help()
|
||||
.wrap(72)
|
||||
.epilog('for more information visit https://github.com/pedronauck/docz')
|
||||
.showHelpOnFail(false, 'whoops, something went wrong! run with --help').argv
|
||||
29
packages/core/docz/package.json
Normal file
29
packages/core/docz/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "docz",
|
||||
"version": "0.0.1",
|
||||
"main": "dist/index.js",
|
||||
"umd:main": "dist/index.umd.js",
|
||||
"module": "dist/index.m.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"source": "src/index.ts",
|
||||
"bin": {
|
||||
"docz": "./bin/index.js"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "libundler watch --ts",
|
||||
"build": "libundler build --ts --c",
|
||||
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" --write",
|
||||
"fix:tslint": "yarn run tslint --fix",
|
||||
"tslint": "tslint --project ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "^0.1.1",
|
||||
"ulid": "^2.3.0",
|
||||
"yargs": "^11.0.0"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
import { ulid } from 'ulid'
|
||||
import slugify from '@sindresorhus/slugify'
|
||||
|
||||
import { isFn, safeUrl } from './utils/helpers'
|
||||
export const cache = new Map()
|
||||
|
||||
export const isFn = (value: any): boolean => typeof value === 'function'
|
||||
export const safeUrl = (value: string) => encodeURI(value.replace(/\s/g, ''))
|
||||
|
||||
export interface Section {
|
||||
id: string
|
||||
@@ -45,14 +48,12 @@ export class Doc {
|
||||
private _filepath: string | undefined
|
||||
private _category: string | undefined
|
||||
private _sections: Section[]
|
||||
private _render: RenderFn
|
||||
|
||||
constructor(name: string, render: RenderFn) {
|
||||
constructor(name: string) {
|
||||
this._name = name
|
||||
this._sections = []
|
||||
this._route = `/${slugify(name)}`
|
||||
this._order = 0
|
||||
this._render = render
|
||||
|
||||
return this
|
||||
}
|
||||
@@ -81,7 +82,7 @@ export class Doc {
|
||||
|
||||
this._sections.push({
|
||||
id,
|
||||
render: (container: HTMLElement) => this._render(render, container),
|
||||
render: (container: HTMLElement) => render(container),
|
||||
...(title && !isFn(title) && { title }),
|
||||
})
|
||||
|
||||
@@ -120,3 +121,10 @@ export class Doc {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const doc = (name: string): Doc => {
|
||||
const newDoc = new Doc(name)
|
||||
|
||||
cache.set(name, newDoc)
|
||||
return newDoc
|
||||
}
|
||||
2
packages/core/docz/src/index.ts
Normal file
2
packages/core/docz/src/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { Doc, DocObj, Entry, Section } from './Doc'
|
||||
export { doc, cache } from './Doc'
|
||||
1
packages/core/docz/src/types.d.ts
vendored
Normal file
1
packages/core/docz/src/types.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module '@sindresorhus/slugify'
|
||||
11
packages/core/docz/tsconfig.json
Normal file
11
packages/core/docz/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"typeRoots": ["node_modules/@types", "src/types"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/**", "templates/**"]
|
||||
}
|
||||
3
packages/core/docz/tslint.json
Normal file
3
packages/core/docz/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["../../tslint.json"]
|
||||
}
|
||||
@@ -24,7 +24,6 @@
|
||||
"find-up": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/deepmerge": "^2.1.0",
|
||||
"@types/find-up": "^2.1.1",
|
||||
"@types/node": "9.6.6"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import findup from 'find-up'
|
||||
import * as findup from 'find-up'
|
||||
import merge from 'deepmerge'
|
||||
|
||||
const finds = (name: string): string[] => [
|
||||
1
packages/core/load-cfg/src/types.d.ts
vendored
Normal file
1
packages/core/load-cfg/src/types.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module 'deepmerge'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
@@ -1,17 +0,0 @@
|
||||
import * as ReactDOM from 'react-dom'
|
||||
import { Doc } from 'docz/doc'
|
||||
import { cache } from './Docs'
|
||||
|
||||
export { theme } from './theme'
|
||||
export { Docs } from './Docs'
|
||||
export { DocObj, Section } from 'docz/doc'
|
||||
|
||||
const render = (child: any, container: HTMLElement) =>
|
||||
ReactDOM.createPortal(child(), container)
|
||||
|
||||
export const doc = (name: string): Doc => {
|
||||
const newDoc = new Doc(name, render)
|
||||
|
||||
cache.set(name, newDoc)
|
||||
return newDoc
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const yargs = require('yargs')
|
||||
const { Server } = require('../dist/index.umd')
|
||||
|
||||
const EXTS = '{j,t}{s,sx}'
|
||||
const DEFAULT_FILES_GLOB = [
|
||||
`docs/**.${EXTS}`,
|
||||
`**/__docs__/*.${EXTS}`,
|
||||
`**/*.doc.${EXTS}`,
|
||||
]
|
||||
|
||||
yargs
|
||||
.command(
|
||||
'start [files]',
|
||||
'initialize docz server',
|
||||
yargs => {
|
||||
yargs.positional('source', {
|
||||
alias: 'src',
|
||||
type: 'string',
|
||||
default: 'src/',
|
||||
})
|
||||
yargs.positional('files', {
|
||||
type: 'string',
|
||||
default: DEFAULT_FILES_GLOB,
|
||||
})
|
||||
yargs.positional('type', {
|
||||
type: 'string',
|
||||
default: 'react',
|
||||
})
|
||||
yargs.positional('bundler', {
|
||||
type: 'string',
|
||||
default: 'webpack',
|
||||
})
|
||||
yargs.positional('title', {
|
||||
type: 'string',
|
||||
default: 'Docz',
|
||||
})
|
||||
yargs.positional('description', {
|
||||
type: 'string',
|
||||
default: 'My awesome design system!',
|
||||
})
|
||||
yargs.positional('theme', {
|
||||
type: 'string',
|
||||
default: 'docz-theme-default',
|
||||
})
|
||||
yargs.positional('env', {
|
||||
type: 'boolean',
|
||||
default: process.env.NODE_ENV || 'development',
|
||||
})
|
||||
yargs.positional('debug', {
|
||||
type: 'boolean',
|
||||
default: process.env.DEBUG || false,
|
||||
})
|
||||
yargs.positional('protocol', {
|
||||
type: 'string',
|
||||
default: process.env.HTTPS === 'true' ? 'https' : 'http',
|
||||
})
|
||||
yargs.positional('host', {
|
||||
type: 'string',
|
||||
default: process.env.HOST || '0.0.0.0',
|
||||
})
|
||||
yargs.positional('port', {
|
||||
alias: 'p',
|
||||
type: 'number',
|
||||
default: process.env.PORT || 3000,
|
||||
})
|
||||
},
|
||||
argv => new Server(argv).start()
|
||||
)
|
||||
.demandCommand()
|
||||
.help()
|
||||
.wrap(72)
|
||||
.epilog('for more information visit https://github.com/pedronauck/docz')
|
||||
.showHelpOnFail(false, 'whoops, something went wrong! run with --help').argv
|
||||
1
packages/docz/doc.d.ts
vendored
1
packages/docz/doc.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export { Doc, DocObj, Entry, Section } from './dist/Doc'
|
||||
@@ -1 +0,0 @@
|
||||
export { Doc } from './dist/Doc'
|
||||
9
packages/docz/utils.d.ts
vendored
9
packages/docz/utils.d.ts
vendored
@@ -1,9 +0,0 @@
|
||||
export {
|
||||
isFn,
|
||||
prop,
|
||||
safeUrl,
|
||||
omit,
|
||||
pick,
|
||||
propOf,
|
||||
isArrEqual,
|
||||
} from './dist/helpers'
|
||||
@@ -1,9 +0,0 @@
|
||||
export {
|
||||
isFn,
|
||||
prop,
|
||||
safeUrl,
|
||||
omit,
|
||||
pick,
|
||||
propOf,
|
||||
isArrEqual,
|
||||
} from './dist/helpers'
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "../../tslint.json"
|
||||
}
|
||||
@@ -13,29 +13,21 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "libundler watch --ts",
|
||||
"build": "libundler build --ts --c --sm",
|
||||
"build": "libundler build --ts --c",
|
||||
"fix:prettier": "prettier \"src/**/*.{ts,tsx}\" --write",
|
||||
"fix:tslint": "yarn run tslint --fix",
|
||||
"tslint": "tslint --project ."
|
||||
},
|
||||
"dependencies": {
|
||||
"docz": "^0.0.1",
|
||||
"prop-types": "^15.6.1",
|
||||
"react": "^16.3.1",
|
||||
"react-dom": "^16.3.1",
|
||||
"ulid": "^2.3.0"
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.3.1",
|
||||
"react-dom": "^16.3.1"
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash.kebabcase": "^4.1.3",
|
||||
"@types/node": "^9.6.6",
|
||||
"@types/react": "^16.3.12",
|
||||
"@types/react-dom": "^16.0.5",
|
||||
"@types/react-router-dom": "^4.2.6",
|
||||
"@types/yargs": "^11.0.0",
|
||||
"rollup-plugin-cpy": "^1.0.0"
|
||||
"@types/react-dom": "^16.0.5"
|
||||
}
|
||||
}
|
||||
6
packages/renders/react/src/index.ts
Normal file
6
packages/renders/react/src/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as React from 'react'
|
||||
import { ComponentType as CT, ReactPortal } from 'react'
|
||||
import * as ReactDOM from 'react-dom'
|
||||
|
||||
export const react = (child: CT) => (el: HTMLElement): ReactPortal =>
|
||||
ReactDOM.createPortal(React.createElement(child), el)
|
||||
11
packages/renders/react/tsconfig.json
Normal file
11
packages/renders/react/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"typeRoots": ["node_modules/@types"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/**", "templates/**"]
|
||||
}
|
||||
3
packages/renders/react/tslint.json
Normal file
3
packages/renders/react/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["../../tslint.json"]
|
||||
}
|
||||
@@ -17,22 +17,23 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"docz-react": "^0.0.1",
|
||||
"docz": "^0.0.1",
|
||||
"docz-theme": "^0.0.1",
|
||||
"emotion": "^9.1.2",
|
||||
"emotion-normalize": "^7.0.1",
|
||||
"history": "^4.7.2",
|
||||
"prismjs": "^1.14.0",
|
||||
"react": "^16.3.1",
|
||||
"react-dom": "^16.3.1",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2",
|
||||
"react-emotion": "^9.1.2",
|
||||
"react-feather": "^1.1.0",
|
||||
"react-powerplug": "^0.1.5",
|
||||
"react-router-dom": "^4.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"docz-react": "^0.0.1",
|
||||
"react": "^16.3.1",
|
||||
"react-dom": "^16.3.1"
|
||||
"docz": "^0.0.1",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.44",
|
||||
@@ -41,6 +42,7 @@
|
||||
"@babel/preset-react": "^7.0.0-beta.44",
|
||||
"@types/classnames": "^2.2.3",
|
||||
"@types/prismjs": "^1.9.0",
|
||||
"@types/react-router-dom": "^4.2.6",
|
||||
"babel-plugin-emotion": "^9.1.0"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { SFC } from 'react'
|
||||
import styled from 'react-emotion'
|
||||
import { DocObj, Section } from 'docz-react'
|
||||
import { DocObj, Section } from 'docz'
|
||||
import { Toggle } from 'react-powerplug'
|
||||
import * as Icon from 'react-feather'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { Fragment, SFC } from 'react'
|
||||
import { Docs, DocObj } from 'docz-react'
|
||||
import { DocObj } from 'docz'
|
||||
import { Docs } from 'docz-theme'
|
||||
import styled from 'react-emotion'
|
||||
|
||||
import * as colors from '../styles/colors'
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { Route } from 'react-router-dom'
|
||||
import { Docs } from 'docz-react'
|
||||
import { Docs } from 'docz-theme'
|
||||
|
||||
import { Doc } from './Doc'
|
||||
|
||||
@@ -3,7 +3,7 @@ import './styles'
|
||||
import * as React from 'react'
|
||||
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
import { theme } from 'docz-react'
|
||||
import { theme } from 'docz-theme'
|
||||
|
||||
import { Main } from './components/Main'
|
||||
import { Menu } from './components/Menu'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"skipLibCheck": true,
|
||||
22
yarn.lock
22
yarn.lock
@@ -1379,22 +1379,6 @@
|
||||
"@types/events" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/lodash.get@^4.4.3":
|
||||
version "4.4.3"
|
||||
resolved "https://registry.npmjs.org/@types/lodash.get/-/lodash.get-4.4.3.tgz#ac823d175a9593c10555b5097b72281effd544b5"
|
||||
dependencies:
|
||||
"@types/lodash" "*"
|
||||
|
||||
"@types/lodash.kebabcase@^4.1.3":
|
||||
version "4.1.3"
|
||||
resolved "https://registry.npmjs.org/@types/lodash.kebabcase/-/lodash.kebabcase-4.1.3.tgz#50d04b46222e43f5e7030c6547c809e582382f84"
|
||||
dependencies:
|
||||
"@types/lodash" "*"
|
||||
|
||||
"@types/lodash@*":
|
||||
version "4.14.107"
|
||||
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.107.tgz#b2d2ae3958bfb8ff828495cbe12214af9e4d035e"
|
||||
|
||||
"@types/mime@*":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.npmjs.org/@types/mime/-/mime-2.0.0.tgz#5a7306e367c539b9f6543499de8dd519fac37a8b"
|
||||
@@ -1413,7 +1397,7 @@
|
||||
version "9.6.0"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-9.6.0.tgz#d3480ee666df9784b1001a1872a2f6ccefb6c2d7"
|
||||
|
||||
"@types/node@9.6.6", "@types/node@^9.6.6":
|
||||
"@types/node@9.6.6":
|
||||
version "9.6.6"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-9.6.6.tgz#439b91f9caf3983cad2eef1e11f6bedcbf9431d2"
|
||||
|
||||
@@ -6572,7 +6556,7 @@ react-dev-utils@^5.0.1:
|
||||
strip-ansi "3.0.1"
|
||||
text-table "0.2.0"
|
||||
|
||||
react-dom@^16.3.1:
|
||||
react-dom@^16.3.1, react-dom@^16.3.2:
|
||||
version "16.3.2"
|
||||
resolved "https://registry.npmjs.org/react-dom/-/react-dom-16.3.2.tgz#cb90f107e09536d683d84ed5d4888e9640e0e4df"
|
||||
dependencies:
|
||||
@@ -6648,7 +6632,7 @@ react-router@^4.2.0:
|
||||
prop-types "^15.5.4"
|
||||
warning "^3.0.0"
|
||||
|
||||
react@^16.3.1:
|
||||
react@^16.3.1, react@^16.3.2:
|
||||
version "16.3.2"
|
||||
resolved "https://registry.npmjs.org/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user