Skip to content

Commit

Permalink
Restructure plop-dir examples and align README documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronccasanova committed Sep 18, 2022
1 parent 9e2c8c5 commit 11a3fc8
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-books-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'plop-dir': patch
---

Restructure examples and align README 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.

6 changes: 3 additions & 3 deletions packages/plop-dir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { plopDir } from 'plop-dir'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

/** @param {import('plop').NodePlopAPI} plop */
export default async function (plop) {
export default async function run(plop) {
plop.setGenerator(
'my-generator',
await plopDir({
Expand All @@ -47,7 +47,7 @@ export default async function (plop) {
}
```
> Note: Currently, `plopDir` is only supported in asynchronous `plopfile`s.
> Note: Currently, `plopDir` is only supported in asynchronous `plopfile`s
Example template directory:
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function {{camelCase extractedPrompt}}() {
Run the `plop` CLI:
```sh
$ npx plop my-generator
$ npm run plop my-generator
Enter extractedPrompt: <answer>
Enter anotherPrompt: <answer>
✔ plop-dir successfully wrote files to <outputDir>
Expand Down
2 changes: 1 addition & 1 deletion packages/plop-dir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint": "TIMING=1 eslint . --ext .js,.ts --cache",
"test": "jest",
"prepublishOnly": "npm run build",
"generate": "plop"
"plop": "plop"
},
"files": [
"dist"
Expand Down
22 changes: 10 additions & 12 deletions packages/plop-dir/plopfile.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import * as url from 'node:url'
import * as path from 'node:path'

import { plopDir } from './dist/esm/index.mjs'

// eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))

/** @param {import('plop').NodePlopAPI} plop */
// eslint-disable-next-line import/no-default-export
export default async function generate(plop) {
export default async function run(plop) {
plop.setGenerator(
'scss-migration',
'my-generator',
await plopDir({
plop,
templateDir: url.fileURLToPath(new URL('./templates', import.meta.url)),
outputDir: url.fileURLToPath(new URL('./src/nested', import.meta.url)),
// Path to my-generator templates
templateDir: path.join(__dirname, './templates/my-generator'),
// Path to output my-generator files
outputDir: path.join(__dirname, './tmp'),
}),
)

// plop.setGenerator(
// 'typescript-migration',
// await plopDir(plop, {
// templateDir: url.fileURLToPath(new URL('./templates', import.meta.url)),
// outputDir: url.fileURLToPath(new URL('./src/nested', import.meta.url)),
// }),
// )
}

3 comments on commit 11a3fc8

@vercel
Copy link

@vercel vercel bot commented on 11a3fc8 Sep 18, 2022

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 11a3fc8 Sep 18, 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.vercel.app
aacc-next-ts-styled-comps-aaronccasanova-gmailcom.vercel.app
aacc-next-ts-styled-comps-git-main-aaronccasanova-gmailcom.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 11a3fc8 Sep 18, 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

Please sign in to comment.