chore(v2): fix TS definition & workspaces config

This commit is contained in:
endiliey 2019-05-25 23:43:43 +08:00
parent 99a58263ca
commit d52e6d3c3f
5 changed files with 17 additions and 6 deletions

View file

@ -3,7 +3,8 @@
"workspaces": [ "workspaces": [
"packages/*", "packages/*",
"website", "website",
"website-1.x" "website-1.x",
"packages/docusaurus/templates/*"
], ],
"scripts": { "scripts": {
"start": "yarn tsc && yarn start:v2", "start": "yarn tsc && yarn start:v2",

View file

@ -13,7 +13,7 @@ import path from 'path';
import _ from 'lodash'; import _ from 'lodash';
import {execSync} from 'child_process'; import {execSync} from 'child_process';
function hasYarn() { function hasYarn(): Boolean {
try { try {
execSync('yarnpkg --version', {stdio: 'ignore'}); execSync('yarnpkg --version', {stdio: 'ignore'});
return true; return true;
@ -22,11 +22,11 @@ function hasYarn() {
} }
} }
function isValidGitRepoUrl(gitRepoUrl) { function isValidGitRepoUrl(gitRepoUrl): Boolean {
return gitRepoUrl.startsWith('https://') || gitRepoUrl.startsWith('git@'); return gitRepoUrl.startsWith('https://') || gitRepoUrl.startsWith('git@');
} }
async function updatePkg(pkgPath, obj) { async function updatePkg(pkgPath: string, obj): Promise<void> {
const content = await fs.readFile(pkgPath, 'utf-8'); const content = await fs.readFile(pkgPath, 'utf-8');
const pkg = JSON.parse(content); const pkg = JSON.parse(content);
const newPkg = Object.assign(pkg, obj); const newPkg = Object.assign(pkg, obj);
@ -87,7 +87,7 @@ export async function init(
const {gitRepoUrl} = await inquirer.prompt({ const {gitRepoUrl} = await inquirer.prompt({
type: 'input', type: 'input',
name: 'gitRepoUrl', name: 'gitRepoUrl',
validate: url => { validate: (url?: string) => {
if (url && isValidGitRepoUrl(url)) { if (url && isValidGitRepoUrl(url)) {
return true; return true;
} }

View file

@ -78,7 +78,7 @@ export async function loadRoutes(pluginsRouteConfigs: RouteConfig[]) {
} }
function genRouteChunkNames( function genRouteChunkNames(
value: RouteModule | Module | null | undefined, value: RouteModule | RouteModule[] | Module | null | undefined,
prefix?: string, prefix?: string,
name?: string, name?: string,
) { ) {

View file

@ -0,0 +1,8 @@
# Templates
Official templates provided by Docusaurus. They are designed to be selected when using the `docusaurus init` CLI command.
## Guide to Test Templates for Developer
1. `yarn install` in the root of the repo (one level above this directory).
1. Go to any template's directory, example: `cd classic && yarn start`.

View file

@ -1,4 +1,6 @@
{ {
"name": "docusaurus-2-classic-template",
"version": "2.0.0-alpha.16",
"private": true, "private": true,
"scripts": { "scripts": {
"docusaurus": "docusaurus", "docusaurus": "docusaurus",