diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# 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 +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f86a2cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +Dockerfile +.dockerignore +**/node_modules/ +**/.git +README.md +npm-debug.log +.coverage +.coverage.* +.env +.aws +.next diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..c7589a9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @trueberryless diff --git a/.github/labeler.yaml b/.github/labeler.yaml new file mode 100644 index 0000000..a6fa2c4 --- /dev/null +++ b/.github/labeler.yaml @@ -0,0 +1,34 @@ +# See https://github.com/actions/labeler/tree/v5 + +"🚨 action": + - changed-files: + - any-glob-to-any-file: .github/workflows/** + +"πŸ“ changeset": + - changed-files: + - any-glob-to-any-file: "**/.changeset/**.{md,mdx}" + +"🚧 config": + - changed-files: + - any-glob-to-any-file: "**/*config*.{js,ts,jsx,tsx,mjs,mts,json,yml,yaml,toml,cjs,cts}" + +"βœ’οΈ documentation": + - changed-files: + - any-glob-to-any-file: "**/README.md" + +"🌏 i18n": + - changed-files: + - all-globs-to-any-file: ["**/docs/**", "!**/docs/en/**"] + +"πŸš€ manifest": + - changed-files: + - any-glob-to-any-file: "manifest*/**" + +"πŸ“¦ package": + - changed-files: + - any-glob-to-any-file: "**/packages/**" + - any-glob-to-any-file: "**/package.json" + +"🏯 styles": + - changed-files: + - any-glob-to-any-file: "**/*.{css,scss,sass,less,styl}" diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..4f2167a --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + ":disableDependencyDashboard", + ":disablePeerDependencies", + ":semanticPrefixFixDepsChoreOthers", + ":ignoreModulesAndTests", + "workarounds:all", + "helpers:pinGitHubActionDigestsToSemver", + "docker:disable" + ], + "rangeStrategy": "bump", + "ignorePaths": ["**/node_modules/**"], + "commitMessageSuffix": "[skip ci]", + "packageRules": [ + { + "groupName": "github-actions", + "matchManagers": ["github-actions"] + }, + { + "matchManagers": ["npm"], + "matchDepTypes": ["dependencies", "devDependencies"], + "separateMajorMinor": true + }, + { + "description": "Disable package manager version updates", + "matchPackageNames": ["pnpm"], + "matchDepTypes": ["packageManager"], + "enabled": false + } + ] +} diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index 9517a1d..f48c9ca 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -1,74 +1,180 @@ name: Deployment on: - push: - branches: [main] - merge_group: - pull_request: - branches: [main] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Automatically cancel in-progress actions on the same branch + push: + branches: [main] + workflow_dispatch: + concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true env: - REGISTRY: docker.io - IMAGE_NAME: trueberryless/truzzles - NODE_VERSION: 20 + REGISTRY: docker.io + IMAGE_OWNER: trueberryless + IMAGE_NAME: truzzles + NODE_VERSION: 20 jobs: - deployment: - if: contains(github.event.head_commit.message, 'deploy') || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Check out the repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create tag - run: echo "IMAGE_TAG=$(echo $GITHUB_REF_NAME-$GITHUB_SHA)" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: | - ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - ${{ env.IMAGE_NAME }}:latest - labels: ${{ steps.meta.outputs.labels }} - - - name: Update deployment.yaml file - run: | - yq eval '.spec.template.spec.containers[0].image = "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}"' -i manifest/deployment.yaml - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: update deployment.json container image (automated) - - - uses: ncipollo/release-action@v1 - with: - tag: ${{ env.IMAGE_TAG }} - makeLatest: true - body: "A docker image has been deployed to [Docker Hub](https://hub.docker.com/r/${{ env.IMAGE_NAME }}/tags)." + changesets: + name: Changesets + runs-on: ubuntu-latest + outputs: + hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} + permissions: + contents: write + pull-requests: write + steps: + - name: Generate GitHub App token + id: generate_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + + - name: Checkout Repo + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "pnpm" + + - name: Install Dependencies + run: pnpm i + + - name: Create Release Pull Request + uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 + id: changesets + with: + version: pnpm run version + commit: "ci: release" + title: "ci: release [skip netlify]" + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token}} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Get published version + if: steps.changesets.outputs.hasChangesets == 'true' + run: | + git checkout changeset-release/main + VERSION=$(node -p "require('./<%= projectFolder %>/package.json').version") + NAME=$(node -p "require('./<%= projectFolder %>/package.json').name") + git commit --amend -m "ci: release $NAME v$VERSION" --no-edit + git push origin changeset-release/main:changeset-release/main --force + + image-tag: + name: Image Tag + runs-on: ubuntu-latest + outputs: + IMAGE_TAG: ${{ env.IMAGE_TAG }} + steps: + - name: Check out the repo + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - name: Read version from package.json + id: get_version + run: | + VERSION=$(jq -r '.version' <%= projectFolder %>/package.json) + echo "IMAGE_TAG=$VERSION" >> $GITHUB_ENV + + deployment: + needs: [changesets, image-tag] + if: > + ( + needs.changesets.outputs.hasChangesets == 'false' && + ( + contains(github.event.head_commit.message, 'deploy') || + contains(github.event.head_commit.message, 'release') + ) + ) || + github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repo + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 + + - name: Log in to Docker Hub + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 + with: + context: ./<%= projectFolder %> + push: true + tags: | + ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }} + ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + + - name: Update deployment.yaml file + run: | + yq eval '.spec.template.spec.containers[0].image = "${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.IMAGE_TAG }}"' -i manifest/deployment.yaml + + - uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0 + with: + commit_message: update deployment.json container image (automated) + + release: + name: Release + needs: [image-tag, deployment] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repo + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - id: extract-changelog + uses: sean0x42/markdown-extract@7b185cbe85263116bbf741e739e7198ba86465dc # v2.1.0 + with: + file: <%= projectFolder %>/CHANGELOG.md + pattern: ${{ needs.image-tag.outputs.IMAGE_TAG }} + + - uses: ncipollo/release-action@v1 + id: create_release + with: + tag: ${{ env.IMAGE_NAME }}@${{ needs.image-tag.outputs.IMAGE_TAG }} + makeLatest: false + body: ${{ steps.extract-changelog.outputs.markdown }} + skipIfReleaseExists: true + + - name: Check if release was created + id: check_release + run: | + if [ -z "${{ steps.create_release.outputs.html_url }}" ]; then + echo "RELEASE_SKIPPED=true" >> $GITHUB_ENV + else + echo "RELEASE_SKIPPED=false" >> $GITHUB_ENV + fi + + - name: Discord notification + if: env.RELEASE_SKIPPED == 'false' + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0 + with: + args: | + # ${{ env.IMAGE_NAME }}@${{ needs.image-tag.outputs.IMAGE_TAG }} + + ${{ steps.extract-changelog.outputs.markdown }} diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 0000000..ecc2f94 --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,37 @@ +name: autofix.ci +on: + pull_request: + push: + branches: [main] +permissions: + contents: read + +jobs: + autofix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 20.19.5 + cache: "pnpm" + + - name: Install Dependencies + run: pnpm i + + - name: Run prettier + run: pnpm exec prettier . --write + + # Optimize all PNGs with https://pngquant.org/ + - run: sudo apt-get update && sudo apt-get install -y pngquant + - name: Run pngquant + run: | + shopt -s globstar + find . -name '*.png' -exec pngquant --ext .png 256 {} \; + + - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml new file mode 100644 index 0000000..83e3c99 --- /dev/null +++ b/.github/workflows/labeler.yaml @@ -0,0 +1,55 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Generate GitHub App token + id: generate_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + - name: Ensure labels exist + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh label delete "bug" --yes || true + gh label delete "documentation" --yes || true + gh label delete "duplicate" --yes || true + gh label delete "enhancement" --yes || true + gh label delete "good first issue" --yes || true + gh label delete "help wanted" --yes || true + gh label delete "invalid" --yes || true + gh label delete "question" --yes || true + gh label delete "wontfix" --yes || true + + gh label create "🚨 action" --description "Changes in GitHub workflows or actions" --color "A75AD5" --force + gh label create "πŸ€– bot" --description "Automatically generated pull request" --color "0075CA" --force + gh label create "πŸ› bug" --description "Something isn't working" --color "D73A4A" --force + gh label create "πŸ“ changeset" --description "Contains changeset files" --color "304EF9" --force + gh label create "🚧 config" --description "Configuration file updates" --color "C0ED4F" --force + gh label create "βœ’οΈ documentation" --description "Documentation updates, like README changes" --color "66741D" --force + gh label create "πŸ” duplicate" --description "This issue or pull request already exists" --color "008672" --force + gh label create "⏫ enhancement" --description "New feature or request" --color "3C11FD" --force + gh label create "πŸ₯‡ good first issue" --description "Good for newcomers" --color "7057FF" --force + gh label create "πŸ†˜ help wanted" --description "Extra attention is needed" --color "BFD4F2" --force + gh label create "🌏 i18n" --description "Updates to internationalized docs, excluding English" --color "006B75" --force + gh label create "πŸ‘€ invalid" --description "This doesn't seem right" --color "E4E669" --force + gh label create "πŸš€ manifest" --description "Manifest-related changes" --color "96D3D7" --force + gh label create "πŸ“¦ package" --description "Updates in package structure or package.json" --color "F34A37" --force + gh label create "❓ question" --description "Further information is requested" --color "D876E3" --force + gh label create "🏯 styles" --description "Stylesheets or design updates" --color "550F5A" --force + gh label create "πŸ”’ wontfix" --description "This will not be worked on" --color "FFFFFF" --force + + - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5 + with: + configuration-path: .github/labeler.yaml + sync-labels: true diff --git a/.github/workflows/welcome-bot.yaml b/.github/workflows/welcome-bot.yaml new file mode 100644 index 0000000..63b6b82 --- /dev/null +++ b/.github/workflows/welcome-bot.yaml @@ -0,0 +1,43 @@ +name: WelcomeBot + +on: + pull_request_target: + branches: [main] + types: [opened] + +permissions: + pull-requests: write + +jobs: + welcome: + name: Welcome First-Time Contributors + runs-on: ubuntu-latest + steps: + - name: Generate GitHub App token + id: generate_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + - name: Convert Repository Name to Title Case + id: convert_repo_name + run: | + REPO_NAME="${{ github.event.repository.name }}" + TITLE_CASE_REPO_NAME=$(echo "$REPO_NAME" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))} 1') + echo "title_case_repo_name=$TITLE_CASE_REPO_NAME" >> $GITHUB_ENV + - uses: zephyrproject-rtos/action-first-interaction@58853996b1ac504b8e0f6964301f369d2bb22e5c + with: + repo-token: ${{ steps.generate_token.outputs.token }} + pr-opened-message: | + Hello! Thank you for opening your **first PR** to ${{ env.title_case_repo_name }}! ✨ + + Here’s what will happen next: + + 1. Our GitHub bots will run to check your changes. + If they spot any issues you will see some error messages on this PR. + Don’t hesitate to ask any questions if you’re not sure what these mean! + + 2. One or more of our maintainers will take a look and may ask you to make changes. + We try to be responsive, but don’t worry if this takes a few days. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38d0ade --- /dev/null +++ b/.gitignore @@ -0,0 +1,135 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Astro +.astro + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist +.output + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for (testing) VSCode extensions +.vscode +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..af546af --- /dev/null +++ b/.prettierignore @@ -0,0 +1,44 @@ +# Dependency directories +node_modules/ +dist/ +build/ +out/ + +# Lock files +pnpm-lock.yaml +package-lock.json +yarn.lock + +# Build and generated files +*.min.* +*.bundle.* +*.map + +# Git and version control +**/.git + +# Framework-specific files +next-env.d.ts +__generated__/ + +# Test and coverage files +coverage/ +*.spec.* +*.test.* + +# Editor-specific files +.vscode/ +.idea/ +*.sublime-project +*.sublime-workspace + +# OS generated files +.DS_Store +Thumbs.db + +# Markdown and MDX files +*.md +*.mdx + +# Changelog +.changeset diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..4e785a8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,29 @@ +{ + "plugins": ["prettier-plugin-astro", "@trivago/prettier-plugin-sort-imports"], + "trailingComma": "es5", + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "endOfLine": "lf", + "htmlWhitespaceSensitivity": "css", + "overrides": [ + { + "files": "*.astro", + "options": { + "parser": "astro" + } + } + ], + "importOrder": [ + "", + "^@internal/(.*)$", + "^@/models/(.*)$", + "^@/utils/(.*)$", + "^@/components/(?!ui/)(.*)$", + "^@/components/ui/(.*)$", + "^[./].*(? (https://trueberryless.org)", + "scripts": { + "version": "pnpm changeset version && pnpm i --no-frozen-lockfile" + }, + "devDependencies": { + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "^2.27.11", + "@trivago/prettier-plugin-sort-imports": "5.2.2", + "prettier": "3.5.3", + "prettier-plugin-astro": "0.14.1" + }, + "packageManager": "pnpm@10.10.0" +}