https://github.com/magicdawn/create-with-generator
use `pnpm create` / `yarn create` / `npm init` with yeoman generator
https://github.com/magicdawn/create-with-generator
Last synced: 3 months ago
JSON representation
use `pnpm create` / `yarn create` / `npm init` with yeoman generator
- Host: GitHub
- URL: https://github.com/magicdawn/create-with-generator
- Owner: magicdawn
- License: mit
- Created: 2022-12-02T10:46:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-02T14:11:45.000Z (over 3 years ago)
- Last Synced: 2024-10-08T18:42:12.862Z (over 1 year ago)
- Language: TypeScript
- Size: 79.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# create-with-generator
> use `pnpm create` / `yarn create` / `npm init` with yeoman generator
[](https://github.com/magicdawn/create-with-generator/actions/workflows/ci.yml)
[](https://codecov.io/gh/magicdawn/create-with-generator)
[](https://www.npmjs.com/package/create-with-generator)
[](https://www.npmjs.com/package/create-with-generator)
[](http://magicdawn.mit-license.org)
## Install
```sh
$ pnpm add create-with-generator
```
## API
```js
require('create-with-generator').runGenerator({ __dirname })
```
### options
| key | type | required | description |
| ----------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `__dirname` | `string` | `true` | your `__dirname`, used to detect who is calling `runGenerator`, if running in a symlinked environment, you need pass `__dirname` explicitly |
| `name` | `string` | `false` | generator name, can be bareName(like `augular` or `@scope/augular` ) or fullname name(like `generator-angular` or `@scope/generator-angular`) |
| `subname` | `string` | `false` | generator subname, defaults empty, stands for `yo :app` |
## Usage Guide
example we have `generator-angular`, and we want to build the `create-angular` package
- init package.json via `npm init`
- install deps: `pnpm add create-with-generator 'generator-angular@*'`
- add `index.js` with contents below
- add `main` & `bin` field of package.json to `index.js`
- tweak your package.json as you want, then run `npm publish`
- start create using `pnpm create angular`
### `index.js`
```js
require('create-with-generator').runGenerator({ __dirname })
```
### `package.json`
```json
{
"main": "index.js",
"bin": "index.js"
}
```
## Changelog
[CHANGELOG.md](CHANGELOG.md)
## License
the MIT License http://magicdawn.mit-license.org