Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi-language support of chinese #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
dist
dist
131 changes: 96 additions & 35 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,108 @@
module.exports = {
title: 'SAO',
description: 'A scaffolding tool for humans',
locales: {
'/': {
lang: 'English',
title: 'SAO',
description: 'A scaffolding tool for humans'
},
'/zh/': {
lang: '简体中文',
title: 'SAO',
description: '人人都能轻松上手的脚手架工具'
}
},
themeConfig: {
   repo: 'saojs/sao',
   docsRepo: 'saojs/website',
   docsDir: 'docs',
editLinks: true,
nav: [
{
text: 'Guide',
link: '/guide/getting-started'
},
{
text: 'References',
items: [
locales: {
'/': {
selectText: 'Languages',
label: 'English',
repo: 'saojs/sao',
docsRepo: 'saojs/website',
docsDir: 'docs',
editLinks: true,
nav: [
{
text: 'API',
link: '/api'
text: 'Guide',
link: '/guide/getting-started'
},
{
text: 'SAO File',
link: '/saofile'
},
text: 'References',
items: [
{
text: 'API',
link: '/api'
},
{
text: 'SAO File',
link: '/saofile'
},
{
text: 'Generator Instance',
link: '/generator-instance'
}
]
}
],
sidebar: [
{
text: 'Generator Instance',
link: '/generator-instance'
title: 'Guide',
collapsable: false,
children: [
'/',
'/guide/getting-started',
'/guide/creating-generators',
'/guide/testing-generators',
'/guide/sharing-generators',
'/guide/migrate-from-v0'
]
}
]
}
],
sidebar: [
{
title: 'Guide',
collapsable: false,
children: [
'/',
'/guide/getting-started',
'/guide/creating-generators',
'/guide/testing-generators',
'/guide/sharing-generators',
'/guide/migrate-from-v0'
},
'/zh/': {
selectText: '选择语言',
label: '简体中文',
repo: 'saojs/sao',
docsRepo: 'saojs/website',
docsDir: 'docs',
editLinks: true,
nav: [
{
text: '新手入门',
link: '/zh/guide/getting-started'
},
{
text: '参考文档',
items: [
{
text: 'API',
link: '/zh/api'
},
{
text: '文件目录',
link: '/zh/saofile'
},
{
text: '生成器实例',
link: '/zh/generator-instance'
}
]
}
],
sidebar: [
{
title: '教程',
collapsable: false,
children: [
'/zh/',
'/zh/guide/getting-started',
'/zh/guide/creating-generators',
'/zh/guide/testing-generators',
'/zh/guide/sharing-generators',
'/zh/guide/migrate-from-v0'
]
}
]
}
]
}
}
}
2 changes: 1 addition & 1 deletion docs/generator-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ interface InstallOpts {

- Type: `() => void`

Display a message for successful project creation.
Display a message for successful project creation.
6 changes: 3 additions & 3 deletions docs/saofile.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar: auto
# SAO File

::: tip
Make sure you have read the guide for [creating generators](./guide/creating-your-first-generator.md) first!
Make sure you have read the guide for [creating generators](./guide/creating-generators.md) first!
:::

SAO file, i.e. `saofile.js` lies in the root directory of a generator, it's used to create a generator instance which defines how to generate a new project.
Expand Down Expand Up @@ -210,7 +210,7 @@ sao sample:bar

### `prepare`

__Type__: (this: Generator) => Prompt<void> | void`
__Type__: `(this: Generator) => Prompt<void> | void`

Executed before prompts and actions, you can throw an error here to exit the process:

Expand All @@ -230,7 +230,7 @@ module.exports = {

### `completed`

__Type__: (this: Generator) => Prompt<void> | void`
__Type__: `(this: Generator) => Prompt<void> | void`

Executed when all actions are completed.

Expand Down
38 changes: 38 additions & 0 deletions docs/zh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 简介

## SAO,究竟是什么?

SAO使你能够通过指定的[生成器](https://github.com/saojs/awesome-sao)来快速启动新项目。

当然,也可以轻松制作自己的**生成器**,以生成你自定义的新项目。

## 为什么不使用Yeoman?

[Yeoman](http://yeoman.io/)是一个非常棒的项目,除了书写Yeoman生成器非常费劲以外,没有任何缺点。

所以,我创建了SAO来简化书写**生成器**的流程。

## 快速入门SAO

我写了一个专门用来创建新的node模块的**SAO生成器**,

你可以点击[sao-nm](https://npm.im/sao-nm)访问npm主页;

或点击[http://github.com/saojs/sao-nm](http://github.com/saojs/sao-nm)访问GitHub主页。

```bash
sao nm my-node-module
```
在命令行下运行这条命令,SAO将执行以下步骤:

1. 首先,SAO将优先使用`sao-nm`的本地缓存

2. 如果没有找到缓存,就从npm上寻找到`sao-nm`包并下载。

3. 在`my-node-modules`文件夹下,SAO将根据*生成器*中的`saofile.js`来创建新项目。

当然,GitHub上也能找到`sao-nm`的项目,所以你可以这样使用GitHub上的生成器:

```bash
sao saojs/sao-nm my-node-module
```
58 changes: 58 additions & 0 deletions docs/zh/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
sidebar: auto
---

# API

```js
const sao = require('sao')

// 创建SAO实例
const app = sao(options)
```

## 配置项

| 配置项 | 类型:值 | 描述 |
| ---------- | ------------ | ----------- |
| generator | String: 生成器名称 | 参考 [使用生成器](guide/getting-started.html#使用生成器). 例如 `npm:foo`, `egoist/sao-nm`|
| outDir | String: 输出最终文件目录的完整路径 ||


## 实例方法

| Method name | Description |
| ---------- | ------------ |
| Promise: run() | 运行脚手架。 例如: `sao(options).run()`|


## 实例属性

[TODO]

## 示例

### 本地调用SAO命令行

你可以这样本地调用SAO的命令行

`./bin/cli.js`

```js
#!/usr/bin/env node
'use strict'

const path = require('path')
const sao = require('sao')

const generator = path.resolve(__dirname, '../')
const outDir = path.resolve(process.argv[2] || '.')
sao({generator, outDir})
.run()
.catch(err => {
console.trace(err)
process.exit(1)
})
```

示例项目: https://github.com/egoist/poi/blob/master/create-poi-app/bin/cli.js
86 changes: 86 additions & 0 deletions docs/zh/generator-instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
sidebar: auto
---

# 生成器实例

你可以通过 `this`访问生成器实例。

## 属性

### answers

- Type: `{[k:string]: any} | undefined`

弹窗问询的结果。

### gitUser

- Type: `{name?: string, username?: string, email?: string}`

git用户信息。

### outDir

- Type: `string`

输出目录的绝对路径。

### outFolder

- Type: `string`

输出目录的名称。

### npmClient

- Type: `'npm' | 'yarn'`

管理工具是npm还是yarn。

### fs

- Type: [fs-extra](https://github.com/jprichardson/node-fs-extra)

### logger

- Type: [Logger](https://github.com/saojs/sao/blob/master/lib/logger.js)

### spinner

- Type: [Ora](https://github.com/sindresorhus/ora)

### chalk

- Type: [Chalk](https://github.com/chalk/chalk)

## 方法

### gitInit

- Type: `() => void`

同步运行`git init` 命令。

### npmInstall

- Type: `NpmInstall`

运用`npm` 或 `yarn` 来在输出目录下安装包依赖。

```ts
function npmInstall(opts?: InstallOpts): Promise<void>

interface InstallOpts {
/* 安装的包名称,如果省略了,它将自动安装 `package.json`中的依赖。 */
packages?: string[]
/* 安装包作为devDependencies,默认为false
saveDev?: boolean
}
```

### showProjectTips

- Type: `() => void`

显示创建成功的信息。
Loading