Skip to content

Commit

Permalink
refactor: move from plop to turbo gen
Browse files Browse the repository at this point in the history
  • Loading branch information
juliencrn committed Jun 6, 2023
1 parent f5a363c commit 57d9fe5
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 589 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"bump": "bump --tag 'usehooks-ts@%s' --commit 'release: usehooks-ts@%s'",
"test:coverage": "zx ./scripts/coverage.mjs",
"update-readme": "zx ./scripts/updateReadme.mjs",
"generate-docs": "rimraf -rf ./apps/web/generated && zx ./scripts/copyHooks.mjs"
"generate-docs": "rimraf -rf ./apps/web/generated && zx ./scripts/copyHooks.mjs",
"gen-hook": "turbo gen hook"
},
"devDependencies": {
"all-contributors-cli": "^6.20.0",
"plop": "^3.0.5",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"turbo": "^1.9.9",
Expand Down
1 change: 1 addition & 0 deletions packages/usehooks-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"devDependencies": {
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@turbo/gen": "^1.9.9",
"@types/jest": "^29.0.3",
"@types/node": "^18.7.18",
"@types/react": "17.0.0",
Expand Down
17 changes: 9 additions & 8 deletions plopfile.js → ...es/usehooks-ts/turbo/generators/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const format = require('date-fns/format')
import { PlopTypes } from '@turbo/gen'
import format from 'date-fns/format'

module.exports = function (plop) {
plop.setGenerator('component', {
export default function generator(plop: PlopTypes.NodePlopAPI): void {
plop.setGenerator('hook', {
description: 'Create a post',
prompts: [
{
Expand All @@ -15,14 +16,14 @@ module.exports = function (plop) {
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.ts',
templateFile: 'templates/plop/hooks/hook/hook.ts.hbs',
templateFile: 'templates/hook/hook.ts.hbs',
},

// Create the test file
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.test.ts',
templateFile: 'templates/plop/hooks/hook/hook.test.ts.hbs',
templateFile: 'templates/hook/hook.test.ts.hbs',
},

// Create the markdown file to present the hook (doc)
Expand All @@ -32,21 +33,21 @@ module.exports = function (plop) {
},
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.mdx',
templateFile: 'templates/plop/hooks/hook/post.mdx.hbs',
templateFile: 'templates/hook/hook.mdx.hbs',
},

// Create the demo react component file
{
type: 'add',
path: 'src/{{camelCase name}}/{{camelCase name}}.demo.tsx',
templateFile: 'templates/plop/hooks/hook/demo.tsx.hbs',
templateFile: 'templates/hook/hook.demo.tsx.hbs',
},

// Update the global hooks index file
{
type: 'append',
path: 'src/index.ts',
templateFile: 'templates/plop/hooks/index.ts.hbs',
templateFile: 'templates/index.ts.hbs',
},
],
})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
881 changes: 302 additions & 579 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit 57d9fe5

Please sign in to comment.