Skip to content

Commit

Permalink
Restructure plop-dir documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronccasanova committed Sep 20, 2022
1 parent 19652ac commit 2ef6270
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-phones-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'plop-dir': patch
---

Restructure documentation
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions packages/plop-dir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,29 @@ npm i -D plop plop-dir

## Usage

`plop-dir` fits into your existing `plop` workflow
### Example templates directory:

**`plopfile.mjs`**
```
plopfile.mjs
src/
templates/
|__ my-template/
|-- {{kebabCase templateName}}.js
|__ tests/
|__ {{kebabCase templateName}}.test.js
```

### `plopfile.mjs`

`plop-dir` fits into your existing `plop` workflow

```mjs
import * as url from 'node:url'
import * as path from 'node:path'

import { plopDir } from 'plop-dir'

const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))

/** @param {import('plop').NodePlopAPI} plop */
export default async function run(plop) {
Expand All @@ -56,33 +68,21 @@ export default async function run(plop) {
> Note: Currently, `plopDir` is only supported in asynchronous `plopfile`s
Example template directory:
> See the [plop docs](https://plopjs.com/documentation/#case-modifiers) for all
> available case modifiers
```
plopfile.mjs
src/
templates/
|__ my-template/
|-- {{kebabCase templateName}}.js
|__ tests/
|__ {{kebabCase templateName}}.test.js
```
Example template file `my-template/tests/{{kebabCase templateName}}.js`:
> See the [plop docs](https://plopjs.com/documentation/#case-modifiers) for all
> available case modifiers
### Example template file: `my-template/tests/{{kebabCase templateName}}.js`
```js
export default function {{camelCase testName}}() {
return '{{pascalCase templateName}}'
}
```
Run the `plop` CLI:
Note: `testName` is extracted from the file content (e.g.
`{{camelCase testName}}`) and included as a `plop` prompt
> See the [plop docs](https://plopjs.com/documentation/#case-modifiers) for all
> available case modifiers
### Run the `plop` CLI:
```sh
$ npm run plop my-template
Expand Down

3 comments on commit 2ef6270

@vercel
Copy link

@vercel vercel bot commented on 2ef6270 Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

aacc-next-ts – ./recipes/next-ts

aacc-next-ts-git-main-aaronccasanova-gmailcom.vercel.app
aacc-next-ts.vercel.app
aacc-next-ts-aaronccasanova-gmailcom.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2ef6270 Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

aacc-next-ts-styled-comps – ./recipes/next-ts-styled-comps

aacc-next-ts-styled-comps-aaronccasanova-gmailcom.vercel.app
aacc-next-ts-styled-comps.vercel.app
aacc-next-ts-styled-comps-git-main-aaronccasanova-gmailcom.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2ef6270 Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.