diff --git a/package.json b/package.json index 614bc7ff..df9174b9 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,12 @@ "lint": "turbo run lint" }, "devDependencies": { + "@turbo/gen": "1.12.2", "eslint": "8.56.0", + "just-camel-case": "6.2.0", + "just-pascal-case": "3.2.0", "tsconfig": "workspace:*", - "turbo": "1.12.2", - "@turbo/gen": "1.12.2" + "turbo": "1.12.2" }, "packageManager": "pnpm@8.15.1", "name": "ui" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d7f5a32..b1f69ee0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,12 @@ importers: eslint: specifier: 8.56.0 version: 8.56.0 + just-camel-case: + specifier: 6.2.0 + version: 6.2.0 + just-pascal-case: + specifier: 3.2.0 + version: 3.2.0 tsconfig: specifier: workspace:* version: link:packages/tsconfig @@ -5624,6 +5630,14 @@ packages: object.assign: 4.1.4 dev: true + /just-camel-case@6.2.0: + resolution: {integrity: sha512-ICenRLXwkQYLk3UyvLQZ+uKuwFVJ3JHFYFn7F2782G2Mv2hW8WPePqgdhpnjGaqkYtSVWnyCESZhGXUmY3/bEg==} + dev: true + + /just-pascal-case@3.2.0: + resolution: {integrity: sha512-B0PW5mgJrsGmXdvDLxC2Kdfyie74m+mRO+iCjJ+Es0Jl5kcQwVfB0qb/qiDOCE3m0XUOo1SdZBWzUlNCO9zreg==} + dev: true + /katex@0.16.9: resolution: {integrity: sha512-fsSYjWS0EEOwvy81j3vRA8TEAhQhKiqO+FQaKWp0m39qwOzHVBgAUBIXWj1pB+O2W3fIpNa6Y9KSKCVbfPhyAQ==} hasBin: true diff --git a/turbo/generators/config.ts b/turbo/generators/config.ts index f971aa7f..59f560b0 100644 --- a/turbo/generators/config.ts +++ b/turbo/generators/config.ts @@ -1,4 +1,6 @@ import type { PlopTypes } from "@turbo/gen"; +import camelCase from 'just-camel-case'; +import pascalCase from 'just-pascal-case'; // Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation @@ -37,9 +39,21 @@ function hookTemplate(packageName: string) { templateFile: `templates/${packageName.substring(0, packageName.length - 1)}DocsPage.hbs`, }, // Changelog + { + type: 'modify', + path: `packages/${packageName}/.changelog.json`, + transform: (content: string, data: any) => { + const hookName = camelCase(data.name); + + const parsedConfiguration = JSON.parse(content); + parsedConfiguration.categories.push(hookName); + + return JSON.stringify(parsedConfiguration, null, 2); + } + }, { type: "add", - path: `packages/${packageName}/changes/Added {{camelCase name}} hook`, + path: `packages/${packageName}/changes/Added [{{camelCase name}}] Hook`, } ], } @@ -86,9 +100,21 @@ export default function generator(plop: PlopTypes.NodePlopAPI): void { templateFile: "templates/componentDocsPage.hbs", }, // Changelog + { + type: 'modify', + path: 'packages/react-ui/.changelog.json', + transform: (content: string, data: any) => { + const componentName = pascalCase(data.name); + + const parsedConfiguration = JSON.parse(content); + parsedConfiguration.categories.push(componentName); + + return JSON.stringify(parsedConfiguration, null, 2); + } + }, { type: "add", - path: "packages/react-ui/changes/Added {{pascalCase name}} component", + path: "packages/react-ui/changes/Added [{{pascalCase name}}] Component", } ], });