From 1c802788dec4e8bb279f841875075b2d5160b454 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 29 Mar 2024 09:06:52 -0400 Subject: [PATCH] chore: convert to monorepo with konami-emoji-blast --- .eslintrc.cjs | 28 +- .github/DEVELOPMENT.md | 40 +- .../{build-dist.yml => build-all.yml} | 5 +- .github/workflows/build.yml | 16 - .github/workflows/post-release.yml | 27 - .github/workflows/release.yml | 29 - .gitignore | 1 + .release-it.json | 18 - README.md | 447 +- cspell.json | 10 +- knip.json | 24 +- package.json | 35 +- packages/.DS_Store | Bin 0 -> 6148 bytes packages/emoji-blast/.github/DEVELOPMENT.md | 22 + .../emoji-blast/CHANGELOG.md | 0 packages/emoji-blast/README.md | 453 ++ .../emoji-blast/demo}/global.html | 0 {demo => packages/emoji-blast/demo}/now.html | 0 .../emoji-blast/demo}/onclick.html | 0 {demo => packages/emoji-blast/demo}/size.html | 0 packages/emoji-blast/package.json | 39 + {src => packages/emoji-blast/src}/actor.ts | 0 {src => packages/emoji-blast/src}/animate.ts | 0 .../emoji-blast/src}/emojiBlast.ts | 0 .../emoji-blast/src}/emojiBlasts.ts | 0 {src => packages/emoji-blast/src}/emojis.ts | 0 {src => packages/emoji-blast/src}/events.ts | 0 {src => packages/emoji-blast/src}/index.ts | 0 .../emoji-blast/src}/mains/global.ts | 0 .../emoji-blast/src}/mains/now.ts | 0 .../emoji-blast/src}/mains/onclick.ts | 0 .../emoji-blast/src}/mains/size.ts | 0 {src => packages/emoji-blast/src}/range.ts | 0 {src => packages/emoji-blast/src}/styles.ts | 0 .../emoji-blast/src}/utils.test.ts | 0 {src => packages/emoji-blast/src}/utils.ts | 0 packages/emoji-blast/tsconfig.eslint.json | 1 + packages/emoji-blast/tsconfig.json | 8 + packages/emoji-blast/vitest.config.ts | 8 + .../emoji-blast/webpack.config.js | 12 +- .../.github/DEVELOPMENT.md | 17 + packages/konami-emoji-blast-astro/README.md | 47 + .../konami-emoji-blast-astro/package.json | 31 + .../konami-emoji-blast-astro/src/index.ts | 14 + .../konami-emoji-blast-astro/tsconfig.json | 10 + .../konami-emoji-blast-astro/vitest.config.ts | 8 + .../webpack.config.js | 41 + .../.github/DEVELOPMENT.md | 17 + packages/konami-emoji-blast-react/README.md | 64 + .../konami-emoji-blast-react/package.json | 45 + .../src/KonamiEmojiBlast.test.tsx | 22 + .../src/KonamiEmojiBlast.tsx | 11 + .../konami-emoji-blast-react/src/index.ts | 2 + .../src/useKonamiEmojiBlast.test.ts | 83 + .../src/useKonamiEmojiBlast.ts | 8 + .../konami-emoji-blast-react/tsconfig.json | 10 + .../konami-emoji-blast-react/vitest.config.ts | 11 + .../webpack.config.js | 41 + .../.github/DEVELOPMENT.md | 17 + packages/konami-emoji-blast-typedoc/README.md | 43 + .../konami-emoji-blast-typedoc/package.json | 34 + .../konami-emoji-blast-typedoc/src/index.ts | 14 + .../konami-emoji-blast-typedoc/tsconfig.json | 9 + .../vitest.config.ts | 8 + .../konami-emoji-blast/.github/DEVELOPMENT.md | 17 + packages/konami-emoji-blast/README.md | 83 + packages/konami-emoji-blast/package.json | 36 + packages/konami-emoji-blast/src/index.ts | 1 + .../src/initializeKonamiEmojiBlast.ts | 21 + .../konami-emoji-blast/src/mains/global.ts | 7 + packages/konami-emoji-blast/src/mains/now.ts | 3 + packages/konami-emoji-blast/tsconfig.json | 9 + packages/konami-emoji-blast/vitest.config.ts | 8 + packages/konami-emoji-blast/webpack.config.js | 41 + pnpm-lock.yaml | 5097 +++++++++-------- pnpm-workspace.yaml | 2 + tsconfig.base.json | 14 + tsconfig.json | 20 +- tsup.config.ts | 11 - vitest.config.ts | 3 - vitest.workspace.ts | 12 + 81 files changed, 4290 insertions(+), 2925 deletions(-) rename .github/workflows/{build-dist.yml => build-all.yml} (61%) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/post-release.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .release-it.json create mode 100644 packages/.DS_Store create mode 100644 packages/emoji-blast/.github/DEVELOPMENT.md rename CHANGELOG.md => packages/emoji-blast/CHANGELOG.md (100%) create mode 100644 packages/emoji-blast/README.md rename {demo => packages/emoji-blast/demo}/global.html (100%) rename {demo => packages/emoji-blast/demo}/now.html (100%) rename {demo => packages/emoji-blast/demo}/onclick.html (100%) rename {demo => packages/emoji-blast/demo}/size.html (100%) create mode 100644 packages/emoji-blast/package.json rename {src => packages/emoji-blast/src}/actor.ts (100%) rename {src => packages/emoji-blast/src}/animate.ts (100%) rename {src => packages/emoji-blast/src}/emojiBlast.ts (100%) rename {src => packages/emoji-blast/src}/emojiBlasts.ts (100%) rename {src => packages/emoji-blast/src}/emojis.ts (100%) rename {src => packages/emoji-blast/src}/events.ts (100%) rename {src => packages/emoji-blast/src}/index.ts (100%) rename {src => packages/emoji-blast/src}/mains/global.ts (100%) rename {src => packages/emoji-blast/src}/mains/now.ts (100%) rename {src => packages/emoji-blast/src}/mains/onclick.ts (100%) rename {src => packages/emoji-blast/src}/mains/size.ts (100%) rename {src => packages/emoji-blast/src}/range.ts (100%) rename {src => packages/emoji-blast/src}/styles.ts (100%) rename {src => packages/emoji-blast/src}/utils.test.ts (100%) rename {src => packages/emoji-blast/src}/utils.ts (100%) create mode 100644 packages/emoji-blast/tsconfig.eslint.json create mode 100644 packages/emoji-blast/tsconfig.json create mode 100644 packages/emoji-blast/vitest.config.ts rename webpack.config.js => packages/emoji-blast/webpack.config.js (62%) create mode 100644 packages/konami-emoji-blast-astro/.github/DEVELOPMENT.md create mode 100644 packages/konami-emoji-blast-astro/README.md create mode 100644 packages/konami-emoji-blast-astro/package.json create mode 100644 packages/konami-emoji-blast-astro/src/index.ts create mode 100644 packages/konami-emoji-blast-astro/tsconfig.json create mode 100644 packages/konami-emoji-blast-astro/vitest.config.ts create mode 100644 packages/konami-emoji-blast-astro/webpack.config.js create mode 100644 packages/konami-emoji-blast-react/.github/DEVELOPMENT.md create mode 100644 packages/konami-emoji-blast-react/README.md create mode 100644 packages/konami-emoji-blast-react/package.json create mode 100644 packages/konami-emoji-blast-react/src/KonamiEmojiBlast.test.tsx create mode 100644 packages/konami-emoji-blast-react/src/KonamiEmojiBlast.tsx create mode 100644 packages/konami-emoji-blast-react/src/index.ts create mode 100644 packages/konami-emoji-blast-react/src/useKonamiEmojiBlast.test.ts create mode 100644 packages/konami-emoji-blast-react/src/useKonamiEmojiBlast.ts create mode 100644 packages/konami-emoji-blast-react/tsconfig.json create mode 100644 packages/konami-emoji-blast-react/vitest.config.ts create mode 100644 packages/konami-emoji-blast-react/webpack.config.js create mode 100644 packages/konami-emoji-blast-typedoc/.github/DEVELOPMENT.md create mode 100644 packages/konami-emoji-blast-typedoc/README.md create mode 100644 packages/konami-emoji-blast-typedoc/package.json create mode 100644 packages/konami-emoji-blast-typedoc/src/index.ts create mode 100644 packages/konami-emoji-blast-typedoc/tsconfig.json create mode 100644 packages/konami-emoji-blast-typedoc/vitest.config.ts create mode 100644 packages/konami-emoji-blast/.github/DEVELOPMENT.md create mode 100644 packages/konami-emoji-blast/README.md create mode 100644 packages/konami-emoji-blast/package.json create mode 100644 packages/konami-emoji-blast/src/index.ts create mode 100644 packages/konami-emoji-blast/src/initializeKonamiEmojiBlast.ts create mode 100644 packages/konami-emoji-blast/src/mains/global.ts create mode 100644 packages/konami-emoji-blast/src/mains/now.ts create mode 100644 packages/konami-emoji-blast/tsconfig.json create mode 100644 packages/konami-emoji-blast/vitest.config.ts create mode 100644 packages/konami-emoji-blast/webpack.config.js create mode 100644 pnpm-workspace.yaml create mode 100644 tsconfig.base.json delete mode 100644 tsup.config.ts create mode 100644 vitest.workspace.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 9ca61642..69510c56 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -7,7 +7,6 @@ module.exports = { extends: [ "eslint:recommended", "plugin:eslint-comments/recommended", - "plugin:n/recommended", "plugin:perfectionist/recommended-natural", "plugin:regexp/recommended", "plugin:vitest/recommended", @@ -15,8 +14,8 @@ module.exports = { ignorePatterns: [ "!.*", "coverage", - "dist", - "lib", + "**/dist", + "**/lib", "node_modules", "pnpm-lock.yaml", ], @@ -32,7 +31,7 @@ module.exports = { "plugin:@typescript-eslint/strict", "plugin:@typescript-eslint/stylistic", ], - files: ["**/*.ts"], + files: ["**/*.{ts,tsx}"], parser: "@typescript-eslint/parser", rules: { // These off-by-default rules work well for this repo and we like them on. @@ -49,19 +48,20 @@ module.exports = { "jsdoc/require-param": "off", "jsdoc/require-property": "off", "jsdoc/require-returns": "off", - "n/no-missing-import": "off", }, }, { - excludedFiles: ["**/*.md/*.ts"], + excludedFiles: ["**/*.md/*.{ts,tsx}"], extends: [ "plugin:@typescript-eslint/strict-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", ], - files: ["**/*.ts"], + files: ["**/*.{ts,tsx}"], parser: "@typescript-eslint/parser", parserOptions: { - project: "./tsconfig.eslint.json", + // Blocked from EXPERIMENTAL_useProjectService on: + // https://github.com/typescript-eslint/typescript-eslint/issues/8206 + project: ["./**/tsconfig.eslint.json", "./**/tsconfig.json"], }, rules: { // These off-by-default rules work well for this repo and we like them on. @@ -77,7 +77,7 @@ module.exports = { }, }, { - excludedFiles: ["package.json"], + excludedFiles: ["**/package.json"], extends: ["plugin:jsonc/recommended-with-json"], files: ["*.json", "*.jsonc"], parser: "jsonc-eslint-parser", @@ -97,9 +97,16 @@ module.exports = { files: ["package.json"], parser: "jsonc-eslint-parser", plugins: ["package-json"], + rules: { + // https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/250 + "package-json/valid-package-def": "off", + + // https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/252 + "package-json/valid-repository-directory": "off", + }, }, { - files: "**/*.test.ts", + files: "**/*.test.{ts,tsx}", rules: { // These on-by-default rules aren't useful in test files. "@typescript-eslint/no-unsafe-assignment": "off", @@ -111,7 +118,6 @@ module.exports = { files: ["**/*.{yml,yaml}"], parser: "yaml-eslint-parser", rules: { - "yml/file-extension": ["error", { extension: "yml" }], "yml/sort-keys": [ "error", { diff --git a/.github/DEVELOPMENT.md b/.github/DEVELOPMENT.md index 1bca2485..7ca88d2c 100644 --- a/.github/DEVELOPMENT.md +++ b/.github/DEVELOPMENT.md @@ -11,37 +11,35 @@ pnpm install > This repository includes a list of suggested VS Code extensions. > It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development. -## Building +## Building (Types) -Run tsup locally to build source files from `src/` into output files in `lib/`: +Run [TypeScript](https://typescriptlang.org) to build each project's files from its `src/` directory into output files in its `lib/` directory: ```shell -pnpm build +pnpm tsc ``` -Add `--watch` to run the builder in a watch mode that continuously cleans and recreates `lib/` as you save files: +Add `--watch` to run the builder in a watch mode that continuously rebuilds as you save files: ```shell -pnpm build --watch +pnpm tsc --watch ``` -### Building Demos +You should also see suggestions from TypeScript in your editor. -A set of `.html` files exists under `demo/` with a different way of showing off `emoji-blast` features. -Each corresponds to a Webpack ["entry point"](https://webpack.js.org/concepts/entry-points) under under the same name. +### Individual Packages -Run [**webpack**](https://webpack.js.org) locally to build source files from `src/` into output files in `dist/`: +Note that some individual packages also have their own `build` command. +Each package `build` runs [webpack](https://webpack.js.org) to build source files from `src/` into output files in `dist/`. -```shell -pnpm build:dist -``` - -Add `--watch` to run the builder in a watch mode: +You can run them all from the root with: ```shell -pnpm build:dist --watch +pnpm build:all ``` +See each package's `.github/DEVELOPMENT.md` for per-package building instructions. + ## Formatting [Prettier](https://prettier.io) is used to format code. @@ -67,7 +65,7 @@ Each should be shown in VS Code, and can be run manually on the command-line: ## Testing [Vitest](https://vitest.dev) is used for tests. -You can run it locally on the command-line: +You can run it on the command-line: ```shell pnpm run test @@ -83,13 +81,3 @@ pnpm run test --coverage This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging unit tests. To launch it, open a test file, then run _Debug Current Test File_ from the VS Code Debug panel (or press F5). - -## Type Checking - -Run [TypeScript](https://typescriptlang.org) locally to type check files in `src/`: - -```shell -pnpm tsc --watch -``` - -You should also see suggestions from TypeScript in your editor. diff --git a/.github/workflows/build-dist.yml b/.github/workflows/build-all.yml similarity index 61% rename from .github/workflows/build-dist.yml rename to .github/workflows/build-all.yml index 9cec1039..3e3bfad7 100644 --- a/.github/workflows/build-dist.yml +++ b/.github/workflows/build-all.yml @@ -4,9 +4,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm build:dist + - run: pnpm build:all + - run: for file in ./packages/*/lib/index.js; do node $file; done -name: Build Dist +name: Build All on: pull_request: ~ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 057fc542..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,16 +0,0 @@ -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/prepare - - run: pnpm build - - run: node ./lib/index.js - -name: Build - -on: - pull_request: ~ - push: - branches: - - main diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml deleted file mode 100644 index ba7015bb..00000000 --- a/.github/workflows/post-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -jobs: - post_release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: echo "npm_version=$(npm pkg get version | tr -d '"')" >> "$GITHUB_ENV" - - uses: apexskier/github-release-commenter@v1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - comment-template: | - :tada: This is included in version {release_link} :tada: - - The release is available on: - - * [GitHub releases](https://github.com/JoshuaKGoldberg/emoji-blast/releases/tag/{release_tag}) - * [npm package (@latest dist-tag)](https://www.npmjs.com/package/emoji-blast/v/${{ env.npm_version }}) - - Cheers! πŸ“¦πŸš€ - -name: Post Release - -on: - release: - types: - - published diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 0cafa53a..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,29 +0,0 @@ -concurrency: - group: ${{ github.workflow }} - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: main - - uses: ./.github/actions/prepare - - run: pnpm build - - run: pnpm build:dist - - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - uses: JoshuaKGoldberg/release-it-action@v0.2.2 - -name: Release - -on: - push: - branches: - - main - -permissions: - contents: write - id-token: write diff --git a/.gitignore b/.gitignore index b08f6bfb..f47348df 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ coverage/ dist/ lib/ node_modules/ +tsconfig.tsbuildinfo diff --git a/.release-it.json b/.release-it.json deleted file mode 100644 index 2b95facc..00000000 --- a/.release-it.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "git": { - "commitMessage": "chore: release v${version}", - "requireCommits": true - }, - "github": { - "autoGenerate": true, - "release": true, - "releaseName": "v${version}" - }, - "npm": { "publishArgs": ["--access public", "--provenance"] }, - "plugins": { - "@release-it/conventional-changelog": { - "infile": "CHANGELOG.md", - "preset": "angular" - } - } -} diff --git a/README.md b/README.md index 5f7d518c..4e1c1461 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

emoji-blast

-

Blasts emoji like fireworks all up in your HTML page. πŸŽ†

+

πŸŽ† Blasts emoji like fireworks all up in your HTML page. πŸŽ†

@@ -15,441 +15,16 @@ πŸ’ͺ TypeScript: Strict

-A straightforward library that triggers fireworks blasts of emoji in any web app or site. -Tell it to start once, or many times, and it will _just work_. -✨ - -> PreviouslyΒ named **`emojisplosion`**. -> Renamed because nobody can remember that name. -> πŸ₯² - -## Usage - -`emoji-blast` provides two APIs: - -- `emojiBlast()`: launches a single blast of emojis at a random location on the page. -- `emojiBlasts()`: starts calling `emojiBlast()` on a random interval of every few seconds. - -Both are shockingly configurable and delightful to use. -πŸŽ‡ - -### Direct HTML Quick Start - -Plop this πŸ‘‡ at the end of your `.html` ``: - -```html - -``` - -That ☝ loads `emoji-blast` soon after your page loads and starts `emojiBlasts()` as soon as it can. - -πŸ‘Œ. - -You'll probably want a little more fine-grained control over when the blasts occur. -To create global `emojiBlast` and `emojiBlasts` functions: - -```html - - -``` - -### Framework Usage - -First install the `emoji-blast` package as a dependency: - -```shell -npm i emoji-blast -``` - -You can then import it in your code to access its `emojiBlast` and `emojiBlasts` functions: - -```ts -import { emojiBlast, emojiBlasts } from "emoji-blast"; - -emojiBlast(); // Just one blast, please. -emojiBlasts(); // Commence blasting! -``` - -If you're using ESM or any modern JavaScript bundler or framework, such as ESBuild, Vite, or Webpack, this should _just work_. -✨ - - - -## Explanation - -Each `emoji-blast` causes a fireworks-like blasts of random emoji to be placed around a random location on your page. -Each blasts contains around a dozen emoji, each of which are animated in JavaScript to: - -- Start with a random horizontal velocity and random upward vertical velocity -- Move along the page as if affected by velocity and preserving inertia - -After an emoji is completely hidden or out of bounds, it is removed from the page. - -### Configuration - -`emoji-blast` and `emojiBlasts` are highly configurable. -The following may be passed to both via configuration objects. - -> Suggestion: see the generated `.d.ts` under `./lib` for full API descriptions. - -#### `className` - -Type: `string` or `() => string` - -CSS class name to add to all emoji elements. -Defaults to `"emoji-styles"`. - -```javascript -emojiBlast({ - className: "my-emoji-styles", -}); -``` - -Whenever a new `className` is passed to `emoji-blast`, a new `