UNPKG

2.47 kBMarkdownView Raw
1<br><br><br><br><br><br><br>
2
3![kopy 1](https://user-images.githubusercontent.com/8784712/50736257-172d9100-11f6-11e9-9408-36bbceab2011.png)
4
5<br><br><br><br><br><br><br>
6
7[![NPM version](https://badgen.net/npm/v/kopy)](https://npmjs.com/package/kopy) [![NPM downloads](https://badgen.net/npm/dm/kopy)](https://npmjs.com/package/kopy) [![CircleCI](https://badgen.net/circleci/github/saojs/kopy/master)](https://circleci.com/gh/saojs/kopy/tree/master) [![package size](https://badgen.net/packagephobia/install/kopy)](https://packagephobia.now.sh/result?p=kopy) [![donate](https://badgen.net/badge/support%20me/donate/ff69b4)](https://patreon.com/egoist) [![chat](https://badgen.net/badge/chat%20on/discord/7289DA)](https://chat.egoist.moe)
8
9---
10
11**The backbone of a scaffolding tool.**
12
13## Features
14
15- Zero-dependency, very light-weight (940KB) compared to [Yeoman](https://packagephobia.now.sh/result?p=yeoman-generator) (12MB)
16- Ultra-simple, this module exists because writing Yeoman generator is hard and time-consuming
17
18## Install
19
20```bash
21yarn add kopy
22```
23
24## Usage
25
26```js
27const kopy = require('kopy')
28
29const config = {
30 prompts() {
31 return [
32 {
33 type: 'input',
34 name: 'name',
35 message: 'what is your name'
36 }
37 ]
38 },
39 actions() {
40 return [
41 {
42 type: 'copy',
43 files: '**',
44 cwd: '/path/to/templates',
45 // When specified, transform the files with `ejs`
46 data: this.answers
47 }
48 ]
49 },
50 completed() {
51 console.log('Done!')
52 }
53}
54
55const generator = kopy(config)
56
57generator
58 .run({
59 outDir: './out'
60 })
61 .catch(kopy.handleError)
62```
63
64Testing:
65
66```js
67const kopy = require('kopy')
68
69test('it works', async () => {
70 const generator = kopy(config)
71 await generator.emulate()
72 expect(generator.answers).toEqual({ name: '' })
73})
74```
75
76**Read more docs on [our website](https://kopy.saojs.org).**
77
78## Contributing
79
801. Fork it!
812. Create your feature branch: `git checkout -b my-new-feature`
823. Commit your changes: `git commit -am 'Add some feature'`
834. Push to the branch: `git push origin my-new-feature`
845. Submit a pull request :D
85
86## Author
87
88**kopy** © EGOIST, Released under the [MIT](./LICENSE) License.<br>
89Authored and maintained by EGOIST with help from contributors ([list](https://github.com/saojs/kopy/contributors)).
90
91> [Website](https://egoist.sh) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@\_egoistlily](https://twitter.com/_egoistlily)