diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index e05cb1c37..13fb89282 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -7,6 +7,7 @@ import { get } from 'lodash/fp' import { Plugin } from '../lib/Plugin' import * as paths from '../config/paths' +import { doczRcBaseConfig } from './docz' const getEnv = (val: string | string[], defaultValue: any = null): any => envDotProp.get(val, defaultValue, { parse: true }) @@ -131,7 +132,7 @@ export const setArgs = (yargs: Yargs) => { .option('typescript', { alias: 'ts', type: 'boolean', - default: getEnv('docz.typescript', false), + default: getEnv('docz.typescript', doczRcBaseConfig.typescript), }) .option('propsParser', { type: 'boolean', diff --git a/core/docz-core/src/config/docz.ts b/core/docz-core/src/config/docz.ts index 4cd2dac8b..635ac2b1d 100644 --- a/core/docz-core/src/config/docz.ts +++ b/core/docz-core/src/config/docz.ts @@ -1,9 +1,9 @@ import * as path from 'path' import { Arguments } from 'yargs' -import { omit } from 'lodash/fp' +import { omit, merge } from 'lodash/fp' import { load, loadFrom } from 'load-cfg' -import { merge } from 'lodash/fp' import detectPort from 'detect-port' +import fs from 'fs-extra' import * as paths from '../config/paths' import { Config, Argv } from '../config/argv' @@ -11,6 +11,7 @@ import { Plugin } from '../lib/Plugin' const toOmit = ['_', '$0', 'version', 'help'] export const doczRcBaseConfig = { + typescript: fs.existsSync(paths.appTsConfig), themeConfig: {}, themesDir: 'src', mdxExtensions: ['.md', '.mdx'], diff --git a/core/docz-core/src/config/paths.ts b/core/docz-core/src/config/paths.ts index 89a33dcca..8e9cff580 100644 --- a/core/docz-core/src/config/paths.ts +++ b/core/docz-core/src/config/paths.ts @@ -71,6 +71,7 @@ export const docz = resolveApp('.docz') export const cache = path.resolve(docz, '.cache/') export const app = path.resolve(docz, 'app/') export const appPackageJson = resolveApp('package.json') +export const appTsConfig = resolveApp('tsconfig.json') export const gatsbyConfig = resolveApp('gatsby-config.js') export const gatsbyBrowser = resolveApp('gatsby-browser.js') export const gatsbyNode = resolveApp('gatsby-node.js') diff --git a/examples/typescript/doczrc.js b/examples/typescript/doczrc.js deleted file mode 100644 index d979c6058..000000000 --- a/examples/typescript/doczrc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - typescript: true, - title: 'Docz Typescript', - menu: ['Getting Started', 'Components'], -}