Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Refactor to starters #64

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 28 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ on:

jobs:
build:
strategy:
matrix:
app: [shopify-meilisearch, shopify-algolia]
include:
- app: shopify-meilisearch
working-directory: ./starters/shopify-meilisearch
- app: shopify-algolia
working-directory: ./starters/shopify-algolia

environment: production
name: Build and Test
name: Build and Test (${{ matrix.app }})
timeout-minutes: 15
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.app }}-${{ github.ref }}
cancel-in-progress: true

env:
SKIP_ENV_VALIDATION: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
Expand All @@ -35,16 +48,26 @@ jobs:
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-check-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ matrix.app }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline

- name: Licenses check
run: npx --yes license-checker-rseidelsohn --production --excludePrivatePackages --onlyAllow "MPL-2.0;UNKNOWN;MIT;Apache;AAL;BSD;Artistic;CC0;ISC;ISCL;PostgreSQL License;Public Domain;Unlicense;UPL;W3C;WTFPL;Python;CC-;BlueOak"

- name: Build
run: yarn build

- name: Test
run: yarn test
working-directory: ${{ matrix.working-directory }}

- name: Lint
run: yarn lint
working-directory: ${{ matrix.working-directory }}

- name: Format
run: yarn format
working-directory: ${{ matrix.working-directory }}

- name: Build
run: yarn build
working-directory: ${{ matrix.working-directory }}
91 changes: 42 additions & 49 deletions .github/workflows/nextjs_bundle_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ on:
- develop
workflow_dispatch:

defaults:
run:
# change this if your nextjs app does not live at the root of the repo
working-directory: ./apps/web/

jobs:
analyze:
strategy:
matrix:
app: [shopify-meilisearch, shopify-algolia]
include:
- app: shopify-meilisearch
working-directory: ./starters/shopify-meilisearch
- app: shopify-algolia
working-directory: ./starters/shopify-algolia

environment: production
name: Analyze (${{ matrix.app }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.app }}-${{ github.ref }}
cancel-in-progress: true

env:
SKIP_ENV_VALIDATION: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
Expand All @@ -30,7 +40,7 @@ jobs:
MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST }}
SHOPIFY_APP_API_SECRET_KEY: ${{ secrets.SHOPIFY_APP_API_SECRET_KEY }}
REPLICATE_API_KEY: ${{ secrets.REPLICATE_API_KEY }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: echo "node_version=$(cat ../../.github/nodejs.version)" >> $GITHUB_ENV
Expand All @@ -42,7 +52,7 @@ jobs:
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-bundle-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ matrix.app }}-bundle-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
Expand All @@ -51,85 +61,68 @@ jobs:
uses: actions/cache@v3
id: restore-build-cache
env:
cache-name: cache-next-build
cache-name: cache-next-build-${{ matrix.app }}
with:
path: .next/cache
# change this if you prefer a more strict cache
path: ${{ matrix.working-directory }}/.next/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Build next.js app
env:
SKIP_BUILD_PRODUCT_REDIRECTS: 1
# change this if your site requires a custom build command
run: cd ../../ && yarn build && cd -
run: cd ${{ matrix.working-directory }} && yarn build && cd -

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle
working-directory: ${{ matrix.working-directory }}
run: node report-bundle-size.js

- name: Upload bundle
uses: actions/upload-artifact@v3
with:
name: bundle
path: .next/analyze/__bundle_analysis.json
name: bundle-${{ matrix.app }}
path: ${{ matrix.working-directory }}/.next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with:
workflow: nextjs_bundle_analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: .next/analyze/base

# And here's the second place - this runs after we have both the current and
# base branch bundle stats, and will compare them to determine what changed.
# There are two configurable arguments that come from package.json:
#
# - budget: optional, set a budget (bytes) against which size changes are measured
# it's set to 350kb here by default, as informed by the following piece:
# https://infrequently.org/2021/03/the-performance-inequality-gap/
#
# - red-status-percentage: sets the percent size increase where you get a red
# status indicator, defaults to 20%
#
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# entry in your package.json file.
name: bundle-${{ matrix.app }}
path: ${{ matrix.working-directory }}/.next/analyze/base

- name: Compare with base branch bundle
if: success() && github.event.number
working-directory: ${{ matrix.working-directory }}
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare

- name: Get comment body
id: get-comment-body
if: success() && github.event.number
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const fs = require('fs')
const comment = fs.readFileSync('.next/analyze/__bundle_analysis_comment.txt', 'utf8')
core.setOutput('body', comment)
working-directory: ${{ matrix.working-directory }}
run: |
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"

- name: Find Comment
uses: peter-evans/find-comment@v2
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: "<!-- __NEXTJS_BUNDLE -->"

- name: Create Comment
uses: peter-evans/create-or-update-comment@v3
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-author: "github-actions[bot]"
body-includes: "<!-- NEXTJS_BUNDLE_${{ matrix.app }} -->"

- name: Update Comment
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
if: success() && github.event.number
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
body: |
<!-- NEXTJS_BUNDLE_${{ matrix.app }} -->
# Next.js Bundle Analysis (${{ matrix.app }})
${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
25 changes: 22 additions & 3 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ on:
- develop
pull_request: null
workflow_dispatch: null

jobs:
test:
strategy:
matrix:
app: [shopify-meilisearch, shopify-algolia]
include:
- app: shopify-meilisearch
working-directory: ./starters/shopify-meilisearch
- app: shopify-algolia
working-directory: ./starters/shopify-algolia

environment: test
name: E2E Tests (${{ matrix.app }})
env:
NODE_ENV: test
SKIP_ENV_VALIDATION: true
Expand All @@ -25,6 +36,10 @@ jobs:
FLAGS_SECRET: EAMwX-AhlPipEaZfTc-24bxAZ7BvLikwuIV2Zq7FP64
timeout-minutes: 60
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.app }}-${{ github.ref }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v4
- run: echo "node_version=$(cat .github/nodejs.version)" >> $GITHUB_ENV
Expand All @@ -36,17 +51,21 @@ jobs:
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-playwright-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ matrix.app }}-playwright-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline

- name: Install Playwright Browsers
run: yarn playwright install

- name: Run Playwright tests
run: yarn e2e
working-directory: ${{ matrix.working-directory }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
name: playwright-report-${{ matrix.app }}
path: ${{ matrix.working-directory }}/playwright-report/
retention-days: 30
20 changes: 0 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ node_modules
.pnp
.pnp.js

# testing
coverage

# next.js
.next/
out/
build

build/**
dist/**
**/dist/**
.next/**

# misc
.DS_Store
*.pem
Expand All @@ -33,9 +20,6 @@ yarn-error.log*
.env.development.local
.env.test.local
.env.production.local
/test-results/
/playwright-report/
/playwright/.cache/
**/**/.env.*
**/**/.env

Expand All @@ -45,9 +29,5 @@ yarn-error.log*

.turbo

.vitepress/cache/
apps/docs/.vitepress/cache/
apps/docs/.vitepress/config.mts.timestamp-*
apps/docs/.vitepress/dist/
.vercel
.env*.local
10 changes: 7 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"tailwindCSS.experimental.classRegex": [["cva(?:<[^>]*>)?(([^)]*))", "[\"'`]([^\"'`]*).*?[\"'`]", "(?:twMerge|twJoin)\\(([^\\);]*)[\\);]"]],
"prettier.configPath": "prettier.config.js"
"tailwindCSS.experimental.classRegex": [
[
"cva(?:<[^>]*>)?(([^)]*))",
"[\"'`]([^\"'`]*).*?[\"'`]",
"(?:twMerge|twJoin)\\(([^\\);]*)[\\);]"
]
]
}
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ $ yarn create commerce
- TailwindCSS
- Analytics (GTM, Vercel)
- Highly Scalable SEO Redirects ([Bloom Filters](https://nextjs.org/docs/app/building-your-application/routing/redirecting#managing-redirects-at-scale-advanced))
- Complete and fast CI/CD pipelines
- Platform agnostic (integrated with Shopify by default)
- Easy migration - migrate your existing solution in minutes
- Conventional commits git hook
- Playwright - write end-to-end tests like a pro
- Storybook - create, test, and showcase your components
- T3 Env - manage your environment variables with ease
Expand Down
3 changes: 0 additions & 3 deletions apps/web/.eslintrc.js

This file was deleted.

5 changes: 0 additions & 5 deletions apps/web/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions apps/web/clients/replicate.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/web/clients/search.ts

This file was deleted.

Loading
Loading