Skip to content

Commit

Permalink
Catalyst 836ee7b
Browse files Browse the repository at this point in the history
  • Loading branch information
CNanninga committed Feb 9, 2024
1 parent 6794376 commit c68b84a
Show file tree
Hide file tree
Showing 290 changed files with 1,094 additions and 988 deletions.
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
BIGCOMMERCE_STORE_HASH=

# The access token from a store-level API account. The only scope required to run Catalyst is Carts `read-only`.
# See https://developer.bigcommerce.com/api-docs/getting-started/api-accounts#store-level-api-accounts
# See https://developer.bigcommerce.com/docs/start/authentication/api-accounts#store-level-api-accounts
BIGCOMMERCE_ACCESS_TOKEN=

# A bearer token that authorizes server-to-server requests to the GraphQL Storefront API
Expand All @@ -18,5 +18,10 @@ BIGCOMMERCE_CHANNEL_ID=1
# You may also delete /admin/route.ts if you wish.
ENABLE_ADMIN_ROUTE=true

# Used by NextAuth, can be generated by running `openssl rand -hex 32` in your terminal.
# Used by NextAuth. To generate, run `openssl rand -hex 32` in your terminal.
AUTH_SECRET=

# Recommended so that you can use Turborepo's Remote Cache feature with signed artifacts
# https://turbo.build/repo/docs/core-concepts/remote-caching#artifact-integrity-and-authenticity-verification
# This can also be generated with `openssl rand -hex 32`, but do not re-use the value from AUTH_SECRET
TURBO_REMOTE_CACHE_SIGNATURE_KEY=
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @bigcommerce/team-catalyst
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: Have questions?
url: https://catalyst.dev/docs
url: https://github.com/bigcommerce/catalyst/blob/main/README.md
about: Explore the Catalyst Docs.
- name: Need help with Catalyst?
url: https://github.com/bigcommerce/catalyst/discussions/new?category=q-a
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }}
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }}

Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,27 @@ jobs:
name: Deployment Audit
timeout-minutes: 30
runs-on: ubuntu-latest
if: ${{ github.event.deployment_status.state == 'success' && contains(github.event.deployment_status.target_url, 'catalyst-latest') }}

steps:
- name: Checkout code
uses: actions/checkout@main

- uses: pnpm/action-setup@v2

- name: Requires audit
id: requires_audit
env:
DEPLOY_URL: ${{ github.event.deployment_status.target_url }}
run: |
if [[ $DEPLOY_URL =~ "storybook" ]]; then
echo "AUDIT=false" >> "$GITHUB_ENV"
else
echo "AUDIT=true" >> "$GITHUB_ENV"
fi
- uses: pnpm/action-setup@v3

- name: Audit preview URL with Lighthouse
if: env.AUDIT == 'true'
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v10
uses: treosh/lighthouse-ci-action@v11
with:
urls: |
${{ github.event.deployment_status.target_url }}
uploadArtifacts: true
temporaryPublicStorage: true
runs: 1
runs: 3

- name: Format lighthouse score
if: env.AUDIT == 'true'
id: format_lighthouse_score
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
Expand All @@ -54,14 +42,12 @@ jobs:
core.setOutput("comment", comment);
- name: Find pull request
if: env.AUDIT == 'true'
uses: jwalton/gh-find-current-pr@v1
uses: jwalton/[email protected]
id: finder

- name: Add comment to PR
if: env.AUDIT == 'true'
id: comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2.8.0
uses: marocchino/sticky-pull-request-comment@v2.9.0
with:
recreate: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lighthouseCommentMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const scoreRow = (
* @param {LighthouseOutputs} lighthouseOutputs
*/
function makeComment(lighthouseOutputs) {
const { summary } = lighthouseOutputs.manifest[0];
const { summary } = lighthouseOutputs.manifest[2];
const [[testedUrl, reportUrl]] = Object.entries(lighthouseOutputs.links);

const comment = `## ⚡️🏠 Lighthouse report
Expand Down
179 changes: 120 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,161 @@
# Catalyst
<a href="https://catalyst.dev" target="_blank" rel="noopener norerrer">
<img src="https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_banner.png" alt="Catalyst for Composable Commerce Image Banner" title="Catalyst">
</a>

> [!WARNING]
> - Catalyst is in development and should not be used in production environments.
<br />
<br />

**Catalyst** is a composable, fully customizable headless storefront that offers a set of opinionated defaults. It is intended to fit the needs of modern developers, merchants, and shoppers. Catalyst is built with [Next.js (nextjs.org)](https://nextjs.org/) and uses our [React.js-based (react.dev)](https://react.dev/) storefront components.
<div align="center">

The Catalyst monorepo contains the following:
[![MIT License](https://img.shields.io/github/license/bigcommerce/catalyst)](LICENSE.md)
[![Lighthouse Report](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml) [![Lint, Typecheck, GraphQL Codegen](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml)

* The core **Catalyst** Next.js storefront, in [apps/core](apps/core).
* The storefront component library, in [packages/components](packages/components).
* The BigCommerce [GraphQL Storefront API (BigCommerce Dev Center)](https://developer.bigcommerce.com/docs/graphql-storefront) client, in [packages/client](packages/client).
</div>

## Requirements
**Catalyst** is the composable, fully customizable headless commerce framework for
[BigCommerce](https://www.bigcommerce.com/). Catalyst is built with [Next.js](https://nextjs.org/), uses
our [React](https://react.dev/) storefront components, and is backed by the
[GraphQL Storefront API](https://developer.bigcommerce.com/docs/storefront/graphql).

* [Node.js 18+](#node.js)
* [Corepack-managed pnpm](#corepack-and-pnpm)
By choosing Catalyst, you'll have a fully-functional storefront within a few seconds, and spend zero time on wiring
up APIs or building SEO, Accessibility, and Performance-optimized ecommerce components you've probably written many
times before. You can instead go straight to work building your brand and making this your own.

### Node.js
![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)

Use Node.js 18+.
<p align="center">
<a href="https://www.catalyst.dev">🚀 catalyst.dev</a> •
<a href="https://developer.bigcommerce.com/community">🤗 BigCommerce Developer Community</a> •
<a href="https://github.com/bigcommerce/catalyst/discussions">💬 GitHub Discussions</a>
</p>

You may wish to use Node Version Manager, or [nvm (GitHub)](https://github.com/nvm-sh/nvm#installing-and-updating), to facilitate moving back and forth between different versions of node. You can install nvm using either the instructions at the preceding link or your operating system package manager of choice.
![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)

### Corepack and pnpm

This project uses [corepack (nodejs.org)](https://nodejs.org/api/corepack.html) to install and enable the [pnpm (pnpm.io)](https://pnpm.io/) package manager. Corepack comes bundled with Node 18, so you do not need to install either of these packages on their own.
## Deploy on Vercel

Catalyst is configured such that pnpm replaces npm. When you enhance your project with additional packages or scripts, be sure to use the `pnpm` command. For more information, see the [pnpm documentation](https://pnpm.io/cli/add).
The easiest way to deploy your Catalyst Storefront is to use the [Vercel Platform](https://vercel.com/new) from the creators of Next.js.

## Getting Started
Check out the [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

1. Clone the project to your local environment:
<div align="left">
<a href="https://vercel.com/new/clone?repository-url=https://github.com/bigcommerce/catalyst&env=BIGCOMMERCE_STORE_HASH,BIGCOMMERCE_CHANNEL_ID,BIGCOMMERCE_ACCESS_TOKEN,BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN,AUTH_SECRET,TURBO_REMOTE_CACHE_SIGNATURE_KEY&envDescription=API+Keys+needed+to+deploy+your+Catalyst+Storefront&envLink=https://github.com/bigcommerce/catalyst/blob/main/.env.example&project-name=my-faster-storefront&repository-name=my-faster-storefront&demo-title=BigCommerce+Catalyst+with+Vercel&demo-description=Create+a+BigCommerce+Catalyst+Storefront+and+Deploy+to+Vercel&demo-url=catalyst-git-main.store&demo-image=https://storage.googleapis.com/s.mkswft.com/RmlsZTozODgzZmY3Yy1hNmVlLTQ1MGUtYjRkMS1mMjEyNzgxNjk5MTY%3D/Social-image-Catalyst.png&root-directory=apps/core"><img src="https://vercel.com/button" alt="Deploy with Vercel"/></a>
</div>

```shell
git clone [email protected]:bigcommerce/catalyst.git && cd catalyst
## Quickstart

Create a new project interactively by running:

```bash
npm create catalyst-storefront@latest
```

2. Use corepack to enable pnpm, then use pnpm to install project dependencies:
You'll then get the following prompts:

```console
? What would you like to call your project? my-faster-storefront
? Which would you like?
Link Catalyst to a BigCommerce Store
Use sample data

? Would you like to create a new channel? y

? What would you like to name the new channel? My Faster Storefront

```shell
corepack enable pnpm
Success! Created 'my-faster-storefront' at '/Users/first.last/Documents/GitHub/my-faster-storefront'
```

```shell
pnpm install
Next steps:

```bash
cd my-faster-storefront && npm run dev
```
Learn more about Catalyst at [catalyst.dev](https://catalyst.dev).

3. **Set up environment variables.**
## Resources

This repository contains a setup script that generates a local development environment file, `.env.local`. The environment file contains the authentication credentials and other variables required to connect Catalyst to an existing BigCommerce store. Run the script from the root directory of this repository and follow the prompts:
- [GraphQL Storefront API Playground](https://developer.bigcommerce.com/graphql-storefront/playground)
- [GraphQL Storefront API Explorer](https://developer.bigcommerce.com/graphql-storefront/explorer)
- [BigCommerce DevDocs](https://developer.bigcommerce.com/docs/build)

```shell
node scripts/setup.mjs
```
> [!IMPORTANT]
> The rest of this README is related to development on top of this monorepo.
> If you just want to build a storefront, start with the [CLI](#quickstart).
*If you prefer to manually enter your own environment variables, you can run `cp .env.example .env.local` to get started.*
![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)

The following table contains a description of each variable in the `.env.local` file:
## Overview

| Variable | Description |
|:---------|:------------|
| `BIGCOMMERCE_STORE_HASH` | The hash visible in the subject store's URL when signed in to the store control panel. The control panel URL is of the form `https://store-{hash}.mybigcommerce.com`. |
| `BIGCOMMERCE_ACCESS_TOKEN` | The access token from a [store-level API account (BigCommerce Dev Center)](https://developer.bigcommerce.com/api-docs/getting-started/api-accounts#store-level-api-accounts). The only [OAuth scope (BigCommerce Dev Center)](https://developer.bigcommerce.com/api-docs/getting-started/api-accounts#oauth-scopes) required to run Catalyst is Carts `read-only`. |
| `BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN` | A bearer token that authorizes server-to-server requests to the [GraphQL Storefront API (BigCommerce Dev Center)](https://developer.bigcommerce.com/docs/storefront/graphql). |
| `BIGCOMMERCE_CHANNEL_ID` | The channel ID for the Catalyst storefront's dedicated channel. |
| `AUTH_SECRET` | Used by NextAuth, can be generated by running `openssl rand -hex 32` in your terminal. |
This Catalyst monorepo contains the following:

5. Optionally, to optimize your workflow, use the following command to configure VSCode with the project-specific settings the Catalyst team has created:
- The core **Catalyst** Next.js storefront, in [apps/core](apps/core). This is what is installed when you run the command above in [Quickstart](#quickstart).
- By default the storefront supports an end-to-end B2C focused shopper journey, inclusive of:
- Global Header & Footers
- Home Page
- Product Listing Pages (Category, Brand, Search/Faceted search, Comparison page)
- Product Detail Pages
- Cart
- Headless Redirected Checkout
- This includes end-to-end support for most features connected to Customer accounts, like:
- Price Lists
- Customer-specific pricing
- Customer-specific category visibility
- Customer-specific product visibility
- To extend into more complex B2C and B2B scenarios, you'll want to utilize more of our [GraphQL Storefront API](https://developer.bigcommerce.com/docs/storefront/graphql).
- The storefront component library, in [packages/components](packages/components), and a [Storybook](https://storybook.js.org/) instance to view the collection.
- The BigCommerce [GraphQL Storefront API](https://developer.bigcommerce.com/docs/graphql-storefront) client, in [packages/client](packages/client).

```shell
cp .vscode/settings.example.json .vscode/settings.json
![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)

### Requirements to use the monorepo

- Node.js 18+
- Corepack-managed `pnpm`

![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)

### Getting started

1. Clone the project to your local environment:

```bash
git clone [email protected]:bigcommerce/catalyst.git && cd catalyst
```

6. Start the Catalyst development server!
2. Use corepack to enable pnpm, then use pnpm to install project dependencies:

```shell
pnpm run dev
```bash
corepack enable pnpm && pnpm install
```

The `dev` script runs all packages and apps in watch mode. The following table lists localhost URLs with the default ports. When a port is unavailable, Catalyst uses the next available port. For example, if `3000` is in use, `core` will run on `3001`.
3. Set up environment variables by running:

| Process | URL with port |
|:--------|:--------------|
| Core Catalyst storefront | http://localhost:3000 |
| Components Storybook | http://localhost:6006 |
```bash
cp .env.example .env.local
```

Happy developing! Let us know how things are going in the dedicated Slack channel.
You can find documentation for each field in the `.env.local` file in [.env.example](.env.example).

## Deploy using Vercel
4. If you use VS Code, use the following command to configure VSCode with the project-specific settings the Catalyst team has created:

One common way to deploy a Next.js app is to use the [Vercel Platform (vercel.com)](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme). Consult the [Next.js deployment documentation (next.js)](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
```bash
cp .vscode/settings.example.json .vscode/settings.json
```

## Resources
5. Start the Catalyst development server!

```bash
pnpm run dev
```

### Next.js
The `dev` script runs all packages and apps in watch mode.
The following table lists localhost URLs with the default ports.
When a port is unavailable, Catalyst uses the next available port.
For example, if `3000` is in use, `core` will run on `3001`.

| Process | URL with port |
| :------------------- | :-------------------- |
| Catalyst storefront | http://localhost:3000 |
| Components Storybook | http://localhost:6006 |

- [Next.js documentation (nextjs.org)](https://nextjs.org/docs)
- [Interactive Next.js tutorial (nextjs.org)](https://nextjs.org/learn)
- [Next.js repository (GitHub)](https://github.com/vercel/next.js/)
![-----------------------------------------------------](https://storage.googleapis.com/bigcommerce-developers/images/catalyst_readme_hr.png)
9 changes: 7 additions & 2 deletions apps/core/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ const config = {
],
},
],
'check-file/filename-naming-convention': 'off',
'check-file/folder-naming-convention': 'off',
'check-file/folder-naming-convention': [
'error',
{
'**': 'NEXT_JS_APP_ROUTER_CASE',
},
],
},
ignorePatterns: ['client/generated/**/*.ts'],
};

module.exports = config;
Loading

0 comments on commit c68b84a

Please sign in to comment.