# @iyowei/create-templates

> 统一提供模板，额外提供与模板紧密相关、有用的帮助函数。无论是创建 Cli、React、Node、Vue、Electron 等等之中的哪一个项目，都会需要用到模板，而这些模板文件也大都相同，小异可以维护在各自专门的脚手架中。

Latest version **1.0.16** (published 2022-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @iyowei/create-templates
pnpm add @iyowei/create-templates
yarn add @iyowei/create-templates
bun add @iyowei/create-templates
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.16 |
| Published | 2022-01-19 |
| First published | 2021-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=12.20.0 |
| Dependencies | 2 |
| Unpacked size | 27.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | itonyyo |
| Keywords | iyowei |

## Links

- npm: https://www.npmjs.com/package/@iyowei/create-templates
- Repository: https://github.com/iyowei/create-templates
- Homepage: https://github.com/iyowei/create-templates#readme
- Issues: https://github.com/iyowei/create-templates/issues
- npm.io page: https://npm.io/package/@iyowei/create-templates

## Dependencies (2)

- [lodash.template](https://npm.io/package/lodash.template.md) ^4.5.0
- [@iyowei/fast-gitignore](https://npm.io/package/@iyowei/fast-gitignore.md) ^1.0.5

## Recent versions

- 1.0.16 (latest) — 2022-01-19
- 1.0.15 — 2022-01-19
- 1.0.14 — 2022-01-02
- 1.0.13 — 2022-01-02
- 1.0.12 — 2021-12-31
- 1.0.11 — 2021-12-31
- 1.0.10 — 2021-12-30
- 1.0.9 — 2021-12-28
- 1.0.8 — 2021-12-26
- 1.0.7 — 2021-12-25
- 1.0.6 — 2021-12-24
- 1.0.5 — 2021-12-24
- 1.0.4 — 2021-12-24
- 1.0.3 — 2021-12-24
- 1.0.2 — 2021-12-20

## README

# @iyowei/create-templates

> 统一提供模板，额外提供与模板紧密相关、有用的帮助函数。无论是创建 Cli、React、Node、Vue、Electron 等等之中的哪一个项目，都会需要用到模板，而这些模板文件也大都相同，小异可以维护在各自专门的脚手架中。

## 使用

### `copiers`

- 返回 { Object } 纯粹 “拷贝” 用途的模板文件
  - `common` { Array } 通用用途文件列表
  - `eslintrc` { Object } ESlint 配置模板文件列表
    - `esm` [ESM][ecmascript module] 模块用途的 ESlint 配置
  - `mocha` { String } mocha.js 配置文件模板
  - `benchmark` { String } 文件脚本

```js
import { log } from 'console';
import { copiers } from '@iyowei/create-templates';

log(copiers);

/**
 * {
 *   common: [
 *     '/Users/iyowei/Development/iyowei/create-templates/src/.vscode',
 *     '/Users/iyowei/Development/iyowei/create-templates/src/.editorconfig',
 *     ...
 *   ],
 *   esm: [
 *     ...
 *   ],
 *   ...
 * ]
 */
```

### `prints`

- 返回 { Object } 印刷模板，使用方式参见 [`lodash.template()`][lodash.template]。

```js
import { log } from 'console';
import { prints } from '@iyowei/create-templates';

log(prints);

/**
 * {
 *   readme: '/Users/iyowei/Development/iyowei/create-templates/src/README.md',
 *   npmrc: '/Users/iyowei/Development/iyowei/create-templates/src/.npmrc',
 *   ...
 * }
 */
```

### `stockrooms`

- 返回 { Object } 第三方仓库，如：[github/gitignore][github/gitignore]。

```js
import { log } from 'console';
import { stockrooms } from '@iyowei/create-templates';

log(stockrooms);

/**
 * {
 *   gitignore: '/Users/iyowei/Development/iyowei/create-templates/src/gitignore',
 *   ...
 * }
 */
```

### `writeGitignoreSync({ output, topics })`

在指定位置生成包含指定主题内容的 .gitignore 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/.gitignore`
- `topics` { Array | String } [github/gitignore][github/gitignore] 里模板文件的文件名，单个或者集合

```js
import { writeGitignoreSync } from '@iyowei/create-templates';

writeGitignoreSync({
  output: join(process.cwd(), '.gitignore'),
  topics: [
    'macOS',
    'Windows',
    'Linux',
    'Node',
    'VisualStudioCode',
    'SublimeText',
    'CVS',
    'Diff',
    'Vim',
    'TortoiseGit',
  ],
});
```

### `writeGitignore({ output, topics })`

异步方法，在指定位置生成包含指定主题内容的 .gitignore 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/.gitignore`
- `topics` { Array | String } [github/gitignore][github/gitignore] 里模板文件的文件名，单个或者集合

```js
import { writeGitignore } from '@iyowei/create-templates';

(async () => {
  await writeGitignore({
    output: join(process.cwd(), '.gitignore'),
    topics: [
      'macOS',
      'Windows',
      'Linux',
      'Node',
      'VisualStudioCode',
      'SublimeText',
      'CVS',
      'Diff',
      'Vim',
      'TortoiseGit',
    ],
  });
})();
```

### `writeNpmRcSync({ output, data })`

串行方法，在指定位置生成 .npmrc 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/.npmrc`
- `data` { Object} 用来填充[模板][lodash.template]的数据

```js
import { writeNpmRcSync } from '@iyowei/create-templates';

writeNpmRcSync({
  output: join(process.cwd(), '.npmrc'),
  data: { namespace: 'iyowei' },
});
```

### `writeNpmRc({ output, data })`

异步方法，在指定位置生成 .npmrc 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/.npmrc`
- `data` { Object} 用来填充[模板][lodash.template]的数据

```js
import { writeNpmRc } from '@iyowei/create-templates';

(async () => {
  await writeNpmRc({
    output: join(process.cwd(), '.npmrc'),
    data: { namespace: '' },
  });
})();
```

### `writeReadmeSync({ output, data })`

串行方法，在指定位置生成 README.md 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/README.md`
- `data` { Object} 用来填充[模板][lodash.template]的数据

```js
import { writeReadmeSync } from '@iyowei/create-templates';

writeReadmeSync({
  output: join(process.cwd(), 'README.md'),
  data: {
    name: 'iyowei',
    description: 'balabala...',
  },
});
```

### `writeReadme({ output, data })`

异步方法，在指定位置生成 README.md 文件。

- `output` { String } 输出位置，包含输出文件名，例如：`/Users/iyowei/Development/iyowei/README.md`
- `data` { Object} 用来填充[模板][lodash.template]的数据

```js
import { writeReadme } from '@iyowei/create-templates';

(async () => {
  await writeReadme({
    output: join(process.cwd(), 'README.md'),
    data: {
      name: 'iyowei',
      description: 'balabala...',
    },
  });
})();
```

## 安装

<!-- 标明支持的宿主、宿主版本，模块类型 -->

[![Node Version Badge][node version badge]][download node.js] ![esm][esm]

### NPM

```shell
npm add @iyowei/create-templates
```

### PNPM

```shell
pnpm add @iyowei/create-templates
```

### Yarn

```shell
yarn add @iyowei/create-templates
```

## 参考

### ".github" 文件夹

- [为仓库创建拉取请求模板][为仓库创建拉取请求模板]；
- [为仓库配置议题模板][为仓库配置议题模板]；
- [GitHub 表单架构的语法][github 表单架构的语法]；
- [创建议题模板的旧工作流程][创建议题模板的旧工作流程]；

## 参与贡献

![PRs Welcome][prs welcome badge]

## 其它

"@iyowei/create-templates" 使用 [@iyowei/create-esm][create-esm] 脚手架生成。

[创建议题模板的旧工作流程]: https://docs.github.com/cn/communities/using-templates-to-encourage-useful-issues-and-pull-requests/manually-creating-a-single-issue-template-for-your-repository
[为仓库配置议题模板]: https://docs.github.com/cn/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#creating-issue-forms
[github 表单架构的语法]: https://docs.github.com/cn/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
[为仓库创建拉取请求模板]: https://docs.github.com/cn/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
[node version badge]: https://img.shields.io/badge/node.js-%3E%3D12.20.0-brightgreen?style=flat&logo=Node.js
[download node.js]: https://nodejs.org/en/download/
[esm]: https://img.shields.io/badge/ESM-brightgreen?style=flat
[prs welcome badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat
[create-esm]: https://github.com/iyowei/create-esm
[github/gitignore]: https://github.com/github/gitignore
[lodash.template]: https://lodash.com/docs/4.17.15#template
[ecmascript module]: https://nodejs.org/docs/latest-v12.x/api/esm.html

<!-- 更多文档细节，参考 https://github.com/iyowei/readme-templates -->

---
_Source: https://npm.io/package/@iyowei/create-templates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
