diff --git a/.changeset/README.md b/.changeset/README.md index e5b6d8d6..468dd170 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -1,8 +1,11 @@ # Changesets -Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works -with multi-package repos, or single-package repos to help you version and publish your code. You can -find the full documentation for it [in our repository](https://github.com/changesets/changesets) +Hello and welcome! This folder has been automatically generated by +`@changesets/cli`, a build tool that works with multi-package repos, or +single-package repos to help you version and publish your code. You can find the +full documentation for it +[in our repository](https://github.com/changesets/changesets) -We have a quick list of common questions to get you started engaging with this project in +We have a quick list of common questions to get you started engaging with this +project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/chilled-apes-tell.md b/.changeset/chilled-apes-tell.md new file mode 100644 index 00000000..08fb1e7d --- /dev/null +++ b/.changeset/chilled-apes-tell.md @@ -0,0 +1,5 @@ +--- +'@luke-ui/button': patch +--- + +Add react-dom to devDependencies diff --git a/.changeset/hot-ads-beg.md b/.changeset/hot-ads-beg.md new file mode 100644 index 00000000..970a402b --- /dev/null +++ b/.changeset/hot-ads-beg.md @@ -0,0 +1,5 @@ +--- +'@luke-ui/button': patch +--- + +Update author and files fields in package.json diff --git a/.changeset/hot-eels-wink.md b/.changeset/hot-eels-wink.md new file mode 100644 index 00000000..17a17ffd --- /dev/null +++ b/.changeset/hot-eels-wink.md @@ -0,0 +1,5 @@ +--- +'eslint-config-luke-ui': minor +--- + +Update dependencies diff --git a/.changeset/shaggy-eagles-count.md b/.changeset/shaggy-eagles-count.md new file mode 100644 index 00000000..fe34013d --- /dev/null +++ b/.changeset/shaggy-eagles-count.md @@ -0,0 +1,5 @@ +--- +'@luke-ui/button': patch +--- + +Format index file diff --git a/.changeset/six-penguins-invent.md b/.changeset/six-penguins-invent.md new file mode 100644 index 00000000..c9d71804 --- /dev/null +++ b/.changeset/six-penguins-invent.md @@ -0,0 +1,5 @@ +--- +'@luke-ui/button': patch +--- + +Update licensing diff --git a/.changeset/spotty-berries-suffer.md b/.changeset/spotty-berries-suffer.md new file mode 100644 index 00000000..bb245741 --- /dev/null +++ b/.changeset/spotty-berries-suffer.md @@ -0,0 +1,5 @@ +--- +'eslint-config-luke-ui': patch +--- + +Update fields in package.json diff --git a/.changeset/two-stingrays-wink.md b/.changeset/two-stingrays-wink.md new file mode 100644 index 00000000..33362e00 --- /dev/null +++ b/.changeset/two-stingrays-wink.md @@ -0,0 +1,5 @@ +--- +'eslint-config-luke-ui': patch +--- + +Update licensing diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f6740a57 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2022 Luke Bennett + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index ece8f59a..33b984c8 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,28 @@ ## Versioning and Publishing packages -Package publishing has been configured using [Changesets](https://github.com/changesets/changesets). Please review their [documentation](https://github.com/changesets/changesets#documentation) to familiarize yourself with the workflow. +Package publishing has been configured using +[Changesets](https://github.com/changesets/changesets). Please review their +[documentation](https://github.com/changesets/changesets#documentation) to +familiarize yourself with the workflow. -This example comes with automated npm releases setup in a [GitHub Action](https://github.com/changesets/action). To get this working, you will need to create an `NPM_TOKEN` and `GITHUB_TOKEN` in your repository settings. You should also install the [Changesets bot](https://github.com/apps/changeset-bot) on your GitHub repository as well. +This example comes with automated npm releases setup in a +[GitHub Action](https://github.com/changesets/action). To get this working, you +will need to create an `NPM_TOKEN` and `GITHUB_TOKEN` in your repository +settings. You should also install the +[Changesets bot](https://github.com/apps/changeset-bot) on your GitHub +repository as well. -For more information about this automation, refer to the official [changesets documentation](https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md) +For more information about this automation, refer to the official +[changesets documentation](https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md) ### npm -If you want to publish package to the public npm registry and make them publicly available, this is already setup. +If you want to publish package to the public npm registry and make them publicly +available, this is already setup. -To publish packages to a private npm organization scope, **remove** the following from each of the `package.json`'s +To publish packages to a private npm organization scope, **remove** the +following from each of the `package.json`'s ```diff - "publishConfig": { @@ -22,4 +33,5 @@ To publish packages to a private npm organization scope, **remove** the followin ### GitHub Package Registry -See [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-a-package-using-publishconfig-in-the-packagejson-file) +See +[Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-a-package-using-publishconfig-in-the-packagejson-file) diff --git a/docs/README.md b/docs/README.md index 1d67ece7..a6dbb01c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,25 +6,38 @@ First, run the development server: yarn dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +Open [http://localhost:3000](http://localhost:3000) with your browser to see the +result. -You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. +You can start editing the page by modifying `pages/index.js`. The page +auto-updates as you edit the file. -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on +[http://localhost:3000/api/hello](http://localhost:3000/api/hello). This +endpoint can be edited in `pages/api/hello.js`. -The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. +The `pages/api` directory is mapped to `/api/*`. Files in this directory are +treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead +of React pages. ## Learn More To learn more about Next.js, take a look at the following resources: -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js + features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! +You can check out +[the Next.js GitHub repository](https://github.com/vercel/next.js/) - your +feedback and contributions are welcome! ## Deploy on Vercel -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_source=github.com&utm_medium=referral&utm_campaign=turborepo-readme) from the creators of Next.js. +The easiest way to deploy your Next.js app is to use the +[Vercel Platform](https://vercel.com/new?utm_source=github.com&utm_medium=referral&utm_campaign=turborepo-readme) +from the creators of Next.js. -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. +Check out our +[Next.js deployment documentation](https://nextjs.org/docs/deployment) for more +details. diff --git a/internal/dev/LICENSE b/internal/dev/LICENSE new file mode 100644 index 00000000..f6740a57 --- /dev/null +++ b/internal/dev/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2022 Luke Bennett + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/internal/dev/package.json b/internal/dev/package.json index 7c534902..f9397a1c 100644 --- a/internal/dev/package.json +++ b/internal/dev/package.json @@ -2,6 +2,14 @@ "name": "@luke-ui-internal/dev", "version": "0.0.1", "private": true, + "homepage": "https://github.com/lukebennett88/luke-ui#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/lukebennett88/luke-ui.git", + "directory": "internal/dev" + }, + "license": "MIT", + "author": "Luke Bennett ", "scripts": { "check:lint": "TIMING=1 eslint .", "check:types": "tsc --noEmit", diff --git a/internal/dev/tsup.d.ts b/internal/dev/tsup.d.ts index 130683e0..6e8e5ea4 100644 --- a/internal/dev/tsup.d.ts +++ b/internal/dev/tsup.d.ts @@ -3,6 +3,7 @@ import type { TsupConfig } from './types'; export function getTsupConfig( entry: string | string[], args: { + packageAuthor: string; packageName: string; packageVersion: string; external?: string[]; @@ -11,6 +12,7 @@ export function getTsupConfig( ): TsupConfig; export function getPackageInfo(packageRoot: string): { - version: string; - name: string; + packageAuthor: string; + packageName: string; + packageVersion: string; }; diff --git a/internal/dev/tsup.js b/internal/dev/tsup.js index a38cf3b0..4eb7ec82 100644 --- a/internal/dev/tsup.js +++ b/internal/dev/tsup.js @@ -2,52 +2,49 @@ const fs = require('node:fs'); const path = require('node:path'); const { defineConfig } = require('tsup'); -function getTsupConfig(entry, { packageName, packageVersion, external = [] }) { +function getTsupConfig( + entry, + { external = [], packageAuthor, packageName, packageVersion } +) { entry = Array.isArray(entry) ? entry : [entry]; external = [...new Set(['react', 'react-dom']), ...external]; - const banner = createBanner(packageName, packageVersion); + const banner = createBanner(packageAuthor, packageName, packageVersion); return defineConfig([ // cjs.dev.js { + banner: { js: banner }, + define: { __DEV__: 'true' }, entry, + external, format: 'cjs', - sourcemap: true, outExtension: getOutExtension('dev'), - external, - banner: { js: banner }, - define: { - __DEV__: 'true', - }, + sourcemap: true, target: 'es2016', }, // cjs.prod.js { + define: { __DEV__: 'false' }, + // @ts-ignore + drop: ['console'], entry, + external, format: 'cjs', minify: true, minifySyntax: true, outExtension: getOutExtension('prod'), - external, pure: ['warning'], - // @ts-ignore - drop: ['console'], - define: { - __DEV__: 'false', - }, target: 'es2016', }, // esm { - entry, + banner: { js: banner }, + define: { __DEV__: 'true' }, dts: { banner }, - format: 'esm', + entry, external, - banner: { js: banner }, - define: { - __DEV__: 'true', - }, + format: 'esm', target: 'es2020', }, ]); @@ -62,20 +59,20 @@ function getOutExtension(env) { /** * @param {string} packageName - * @param {string} version + * @param {string} packageVersion */ -function createBanner(packageName, version) { - return `/** - * ${packageName} v${version} - * - * Copyright (c) Luke Bennett - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */ -`; +function createBanner(packageAuthor, packageName, packageVersion) { + return ` +/** + * @license MIT + * + * ${packageName} v${packageVersion} + * + * Copyright (c) ${packageAuthor} + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */`.trim(); } function getPackageInfo(packageRoot) { @@ -83,8 +80,13 @@ function getPackageInfo(packageRoot) { path.join(packageRoot, 'package.json'), 'utf8' ); - const { version, name } = JSON.parse(packageJson); - return { version, name }; + const { version, name, author } = JSON.parse(packageJson); + const [packageAuthor] = author.split(' <'); + return { + packageAuthor, + packageName: name, + packageVersion: version, + }; } module.exports = { diff --git a/internal/eslint-config-luke-ui/LICENSE b/internal/eslint-config-luke-ui/LICENSE new file mode 100644 index 00000000..f6740a57 --- /dev/null +++ b/internal/eslint-config-luke-ui/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2022 Luke Bennett + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/internal/eslint-config-luke-ui/package.json b/internal/eslint-config-luke-ui/package.json index 9ed92304..ef9ea90c 100644 --- a/internal/eslint-config-luke-ui/package.json +++ b/internal/eslint-config-luke-ui/package.json @@ -1,10 +1,22 @@ { "name": "eslint-config-luke-ui", "version": "0.0.1", + "homepage": "https://github.com/lukebennett88/luke-ui#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/lukebennett88/luke-ui.git", + "directory": "internal/eslint-config-luke-ui" + }, "license": "MIT", + "author": "Luke Bennett ", "sideEffects": false, "type": "commonjs", "main": "index.js", + "files": [ + "CHANGELOG.md", + "index.js", + "LICENSE" + ], "scripts": { "check:lint": "TIMING=1 pnpm eslint", "eslint": "eslint .", diff --git a/internal/tsconfig/LICENSE b/internal/tsconfig/LICENSE new file mode 100644 index 00000000..f6740a57 --- /dev/null +++ b/internal/tsconfig/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2022 Luke Bennett + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/internal/tsconfig/README.md b/internal/tsconfig/README.md index 0da79cf2..6d57107d 100644 --- a/internal/tsconfig/README.md +++ b/internal/tsconfig/README.md @@ -1,3 +1,4 @@ # `tsconfig` -These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s inherit from. +These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s +inherit from. diff --git a/internal/tsconfig/package.json b/internal/tsconfig/package.json index 7b610086..a14d309f 100644 --- a/internal/tsconfig/package.json +++ b/internal/tsconfig/package.json @@ -1,8 +1,14 @@ { "name": "@luke-ui-internal/tsconfig", "version": "0.0.1", - "private": true, + "homepage": "https://github.com/lukebennett88/luke-ui#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/lukebennett88/luke-ui.git", + "directory": "internal/tsconfig" + }, "license": "MIT", + "author": "Luke Bennett ", "publishConfig": { "access": "public" } diff --git a/package.json b/package.json index a540aa70..32c5b8fe 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "luke-ui", "version": "0.0.0", "private": true, + "author": "Luke Bennett ", "scripts": { "build": "turbo run build", "build:docs": "turbo run build --filter=@luke-ui-internal/docs", @@ -26,6 +27,7 @@ "validate": "npm-run-all --parallel check:*" }, "prettier": { + "proseWrap": "always", "quoteProps": "consistent", "singleQuote": true, "tabWidth": 2, @@ -40,6 +42,7 @@ "@testing-library/user-event": "^14.4.3", "@types/eslint": "^8.4.6", "@vitejs/plugin-react": "^2.0.1", + "chalk": "^5.0.1", "eslint": "^8.23.0", "eslint-config-luke-ui": "workspace:*", "happy-dom": "^6.0.4", diff --git a/packages/button/CHANGELOG.md b/packages/button/CHANGELOG.md index cd8cbecc..b80e9839 100644 --- a/packages/button/CHANGELOG.md +++ b/packages/button/CHANGELOG.md @@ -4,13 +4,17 @@ ### Patch Changes -- [`d97d5a8`](https://github.com/lukebennett88/luke-ui/commit/d97d5a8334247c7ae12b8dfe7c996f1bbbd0ef63) Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update homepage field in package.json +- [`d97d5a8`](https://github.com/lukebennett88/luke-ui/commit/d97d5a8334247c7ae12b8dfe7c996f1bbbd0ef63) + Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update homepage + field in package.json ## 0.1.0 ### Minor Changes -- [#5](https://github.com/lukebennett88/luke-ui/pull/5) [`1dfdac5`](https://github.com/lukebennett88/luke-ui/commit/1dfdac59c1622ea01e13f21549ca975abe94022c) Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update types +- [#5](https://github.com/lukebennett88/luke-ui/pull/5) + [`1dfdac5`](https://github.com/lukebennett88/luke-ui/commit/1dfdac59c1622ea01e13f21549ca975abe94022c) + Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update types Export `useButton` hook diff --git a/packages/button/LICENSE b/packages/button/LICENSE new file mode 100644 index 00000000..f6740a57 --- /dev/null +++ b/packages/button/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2022 Luke Bennett + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/button/index.js b/packages/button/index.js index f6de9081..7bd4b6c7 100644 --- a/packages/button/index.js +++ b/packages/button/index.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/index.cjs.prod'); + module.exports = require('./dist/index.cjs.prod'); } else { - module.exports = require('./dist/index.cjs.dev'); + module.exports = require('./dist/index.cjs.dev'); } diff --git a/packages/button/package.json b/packages/button/package.json index df7d31af..9b72b15c 100644 --- a/packages/button/package.json +++ b/packages/button/package.json @@ -8,13 +8,16 @@ "directory": "packages/button" }, "license": "MIT", + "author": "Luke Bennett ", "sideEffects": false, "main": "index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ - "dist", "CHANGELOG.md", + "dist", + "index.js", + "LICENSE", "README.md" ], "scripts": { @@ -36,6 +39,7 @@ "@types/react": "^18.0.18", "@types/react-dom": "^18.0.6", "react": "^18.2.0", + "react-dom": "^18.2.0", "typescript": "^4.8.2" }, "peerDependencies": { diff --git a/packages/button/tsup.config.ts b/packages/button/tsup.config.ts index a4d6806f..12704ba9 100644 --- a/packages/button/tsup.config.ts +++ b/packages/button/tsup.config.ts @@ -5,9 +5,6 @@ type TsupConfig = ReturnType; const packageInfo = getPackageInfo(__dirname); -const tsupConfig: TsupConfig = getTsupConfig('src/index.ts', { - packageName: packageInfo.name, - packageVersion: packageInfo.version, -}); +const tsupConfig: TsupConfig = getTsupConfig('src/index.ts', packageInfo); export default tsupConfig; diff --git a/plop-templates/component/LICENSE.hbs b/plop-templates/component/LICENSE.hbs new file mode 100644 index 00000000..0f161727 --- /dev/null +++ b/plop-templates/component/LICENSE.hbs @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) {{year}} {{authorName}} + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/plop-templates/component/index.js.hbs b/plop-templates/component/index.js.hbs index f6de9081..7bd4b6c7 100644 --- a/plop-templates/component/index.js.hbs +++ b/plop-templates/component/index.js.hbs @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/index.cjs.prod'); + module.exports = require('./dist/index.cjs.prod'); } else { - module.exports = require('./dist/index.cjs.dev'); + module.exports = require('./dist/index.cjs.dev'); } diff --git a/plop-templates/component/package.json.hbs b/plop-templates/component/package.json.hbs index 5d10d43e..76a251cd 100644 --- a/plop-templates/component/package.json.hbs +++ b/plop-templates/component/package.json.hbs @@ -8,13 +8,16 @@ "directory": "packages/{{packageName}}" }, "license": "MIT", + "author": "{{authorName}} <{{authorEmail}}>", "sideEffects": false, "main": "index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ - "dist", "CHANGELOG.md", + "dist", + "index.js", + "LICENSE", "README.md" ], "scripts": { @@ -34,6 +37,7 @@ "@types/react": "^18.0.18", "@types/react-dom": "^18.0.6", "react": "^18.2.0", + "react-dom": "^18.2.0", "typescript": "^4.8.2" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f62bc7e..57238bd6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,7 @@ importers: '@testing-library/user-event': ^14.4.3 '@types/eslint': ^8.4.6 '@vitejs/plugin-react': ^2.0.1 + chalk: ^5.0.1 eslint: ^8.23.0 eslint-config-luke-ui: workspace:* happy-dom: ^6.0.4 @@ -36,6 +37,7 @@ importers: '@testing-library/user-event': 14.4.3_wl4iynrlixafokvgqnhzlvigei '@types/eslint': 8.4.6 '@vitejs/plugin-react': 2.0.1_vite@3.0.9 + chalk: 5.0.1 eslint: 8.23.0 eslint-config-luke-ui: link:internal/eslint-config-luke-ui happy-dom: 6.0.4 diff --git a/scripts/plopfile.mjs b/scripts/plopfile.mjs index 6975444e..46b2f33e 100644 --- a/scripts/plopfile.mjs +++ b/scripts/plopfile.mjs @@ -1,28 +1,44 @@ -export default function newPackage(plop) { - plop.setHelper('repository', 'https://github.com/lukebennett88'); - plop.setHelper('website', 'https://luke-ui.vercel.app'); +import chalk from 'chalk'; + +export default function newPackage( + /** @type {import('plop').NodePlopAPI} */ + plop +) { + plop.setHelper('authorName', () => 'Luke Bennett'); + plop.setHelper('authorEmail', () => 'hello@lukebennett.com.au'); + plop.setHelper('repository', () => 'https://github.com/lukebennett88'); + plop.setHelper('website', () => 'https://luke-ui.vercel.app'); + plop.setHelper('year', () => new Date().getFullYear()); - // controller generator plop.setGenerator('component', { - description: 'add new component', + description: 'Add new component', prompts: [ { type: 'input', name: 'packageName', - message: 'package name, all lowercase (e.g. button)', + message: 'Package name, all lowercase (e.g. button)', validate: (answer) => answer.length > 0, }, { type: 'input', name: 'componentName', message: - 'component name, please use appropriate uppercase (e.g. Button)', + 'Component name, please use appropriate uppercase (e.g. Button)', validate: (answer) => answer.length > 0, }, ], - actions: function (data) { - const { componentName, packageName } = data; + actions: (data) => { + const componentName = data?.componentName; + if (!componentName) { + throw new Error('You must provide a component name'); + } + + const packageName = data?.componentName.toLowerCase(); + if (!packageName) { + throw new Error('You must provide a package name'); + } + const actions = [ { type: 'addMany', @@ -33,6 +49,12 @@ export default function newPackage(plop) { }, ]; + console.log( + chalk.yellowBright.bold( + '\n\nPlease rename LICENSE.hbs to LICENSE manually in newly created package.\n' + ) + ); + return actions; }, });