diff --git a/packages/docz-core/package.json b/packages/docz-core/package.json index fd50891e9..87320e2ec 100644 --- a/packages/docz-core/package.json +++ b/packages/docz-core/package.json @@ -38,7 +38,6 @@ "cpy": "^7.0.1", "deepmerge": "^2.1.1", "detect-port": "^1.2.3", - "docz-theme-default": "^0.3.4", "express": "^4.16.3", "fast-glob": "^2.2.2", "file-loader": "^1.1.11", @@ -66,6 +65,7 @@ "resolve": "^1.8.1", "signale": "^1.2.1", "strip-indent": "^2.0.0", + "titleize": "^1.0.1", "to-vfile": "^5.0.0", "uglifyjs-webpack-plugin": "^1.2.7", "ulid": "^2.3.0", diff --git a/packages/docz-core/src/commands/args.ts b/packages/docz-core/src/commands/args.ts index 155ba2dfc..12c1e4bef 100644 --- a/packages/docz-core/src/commands/args.ts +++ b/packages/docz-core/src/commands/args.ts @@ -1,5 +1,18 @@ +import * as fs from 'fs-extra' +import humanize from 'humanize-string' +import titleize from 'titleize' + import { Plugin } from '../Plugin' import { BabelRC } from '../utils/babelrc' +import * as paths from '../config/paths' + +const removeScope = (name: string) => name.replace(/^@.*\//, '') +const getInitialTitle = () => { + const pkg = fs.readJsonSync(paths.packageJson, { throws: false }) + const name = pkg ? pkg.name : 'MyDoc' + + return titleize(humanize(removeScope(name))) +} export interface Argv { /* io args */ @@ -59,7 +72,7 @@ export const args = (yargs: any) => { }) yargs.positional('title', { type: 'string', - default: 'MyDoc', + default: getInitialTitle(), }) yargs.positional('description', { type: 'string', diff --git a/packages/docz-core/src/types.d.ts b/packages/docz-core/src/types.d.ts index 8f9d70245..fc67c9a06 100644 --- a/packages/docz-core/src/types.d.ts +++ b/packages/docz-core/src/types.d.ts @@ -3,6 +3,7 @@ declare module '@mdx-js/mdx' declare module 'chokidar' declare module '@sindresorhus/slugify' declare module 'humanize-string' +declare module 'titleize' declare module 'unified' declare module 'strip-indent' declare module 'unist-util-is' diff --git a/yarn.lock b/yarn.lock index 6faeacc71..e77c9df74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11037,6 +11037,10 @@ tiny-emitter@^2.0.0: version "2.0.2" resolved "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.2.tgz#82d27468aca5ade8e5fd1e6d22b57dd43ebdfb7c" +titleize@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/titleize/-/titleize-1.0.1.tgz#21bc24fcca658eadc6d3bd3c38f2bd173769b4c5" + tmp@^0.0.29: version "0.0.29" resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0"