Skip to content

Commit 0fbb8da

Browse files
authored
migrated to pnpm, next-js example, fixed warning (#310)
* migrated to pnpm, next-js example, fixed warning * upgrade husky and add scripts that replace yarn commands * fixed types, set up pnpm to handle peer dependencies * remove husky from nextjs app * update github action workflow for pnpm * add docs to packages and give script to run docs for development * downgrade react-dom back to 17.2.0 * trying to resolve dependencies * omfg upgrading docusaurus worked * remove process from docusaurus * update lock file * ignoring gatsby, dev builds work again except for docs FML * use most recent webpack * exclude cra and gatsby from workspaces * get rid of gatsby and cra commands * update contributor doc * update package
1 parent 723cf1c commit 0fbb8da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+26463
-25574
lines changed

.github/workflows/test-pull-requests.yml

Lines changed: 67 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name: Tests
66

77
on:
88
pull_request:
9-
branches: [ master, next, dev ]
9+
branches: [master, next, dev]
1010

1111
jobs:
1212
test-package:
@@ -16,86 +16,84 @@ jobs:
1616
- macos-latest
1717
strategy:
1818
matrix:
19-
node_version: [ '12', '14', '16' ]
19+
node_version: ['12', '14', '16']
2020
steps:
21-
- uses: actions/checkout@v2
22-
# Set up Node and Yarn
23-
- uses: actions/setup-node@v2.2.0
24-
with:
25-
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0
26-
node-version: ${{ matrix.node-version }}
27-
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn
28-
cache: yarn
21+
- uses: actions/checkout@v2
22+
# Set up Node and Yarn
23+
- uses: actions/setup-node@v2.2.0
24+
with:
25+
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0
26+
node-version: ${{ matrix.node-version }}
27+
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn
28+
cache: yarn
2929

30-
# Caching for Yarn
31-
- id: yarn-cache-dir-path
32-
run: echo "::set-output name=dir::$(yarn cache dir)"
33-
- uses: actions/cache@v2
34-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
35-
with:
36-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
37-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
38-
restore-keys: |
39-
${{ runner.os }}-yarn-
30+
# Caching for Yarn
31+
- id: yarn-cache-dir-path
32+
run: echo "::set-output name=dir::$(yarn cache dir)"
33+
- uses: actions/cache@v2
34+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
35+
with:
36+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
37+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-yarn-
4040
41-
# Install dependencies
42-
- run: yarn workspace use-shopping-cart install --frozen-lockfile
43-
# Run integration and unit tests
44-
- run: yarn workspace use-shopping-cart test
45-
# Run TypeScript type definition tests
46-
- run: yarn workspace use-shopping-cart test:types
41+
# Install dependencies
42+
- run: pnpm install --frozen-lockfile
43+
# Run integration and unit tests
44+
- run: pnpm --filter use-shopping-cart run test
45+
# Run TypeScript type definition tests
46+
- run: pnpm --filter use-shopping-cart run test:types
4747

4848
build-package:
4949
name: Build
50-
runs-on:
51-
ubuntu-latest
50+
runs-on: ubuntu-latest
5251
steps:
53-
- uses: actions/checkout@v2
54-
- uses: actions/setup-node@v2
55-
with:
56-
node-version: 16
57-
cache: yarn
52+
- uses: actions/checkout@v2
53+
- uses: actions/setup-node@v2
54+
with:
55+
node-version: 16
56+
cache: yarn
57+
58+
# Caching for Yarn
59+
- id: yarn-cache-dir-path
60+
run: echo "::set-output name=dir::$(yarn cache dir)"
61+
- uses: actions/cache@v2
62+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
63+
with:
64+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
65+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-yarn-
5868
59-
# Caching for Yarn
60-
- id: yarn-cache-dir-path
61-
run: echo "::set-output name=dir::$(yarn cache dir)"
62-
- uses: actions/cache@v2
63-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
64-
with:
65-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
66-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
67-
restore-keys: |
68-
${{ runner.os }}-yarn-
69+
# Install dependencies
70+
- run: pnpm install
71+
# Build package
72+
- run: pnpm --filter use-shopping-cart run build
6973

70-
# Install dependencies
71-
- run: yarn workspace use-shopping-cart install --frozen-lockfile
72-
# Build package
73-
- run: yarn workspace use-shopping-cart build
74-
7574
lint-package:
7675
continue-on-error: true
7776
name: Lint
78-
runs-on:
79-
ubuntu-latest
77+
runs-on: ubuntu-latest
8078
steps:
81-
- uses: actions/checkout@v2
82-
- uses: actions/setup-node@v2
83-
with:
84-
node-version: 16
85-
cache: yarn
79+
- uses: actions/checkout@v2
80+
- uses: actions/setup-node@v2
81+
with:
82+
node-version: 16
83+
cache: yarn
8684

87-
# Caching for Yarn
88-
- id: yarn-cache-dir-path
89-
run: echo "::set-output name=dir::$(yarn cache dir)"
90-
- uses: actions/cache@v2
91-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
92-
with:
93-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
94-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
95-
restore-keys: |
96-
${{ runner.os }}-yarn-
85+
# Caching for Yarn
86+
- id: yarn-cache-dir-path
87+
run: echo "::set-output name=dir::$(yarn cache dir)"
88+
- uses: actions/cache@v2
89+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
90+
with:
91+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
92+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
93+
restore-keys: |
94+
${{ runner.os }}-yarn-
9795
98-
# Install dependencies
99-
- run: yarn workspace use-shopping-cart install --frozen-lockfile
100-
# Lint soure code
101-
- run: yarn workspace use-shopping-cart lint
96+
# Install dependencies
97+
- run: pnpm install --frozen-lockfile
98+
# Lint soure code
99+
- run: pnpm --filter use-shopping-cart run lint

.husky/pre-commit

Whitespace-only changes.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
auto-install-peers=true

docs/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"serve": "docusaurus serve"
1212
},
1313
"dependencies": {
14-
"@docusaurus/core": "2.0.0-alpha.70",
15-
"@docusaurus/preset-classic": "2.0.0-alpha.70",
14+
"@docusaurus/core": "2.3.1",
15+
"@docusaurus/preset-classic": "2.3.1",
1616
"@mdx-js/react": "^1.6.22",
1717
"clsx": "^1.1.1",
18+
"prism-react-renderer": "^1.3.5",
1819
"react": "^17.0.2",
1920
"react-dom": "^17.0.2",
2021
"use-shopping-cart": "3.1.0"
@@ -32,3 +33,4 @@
3233
]
3334
}
3435
}
36+

docs/src/components/landing-page/codeExamples.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
const process = {
2+
env: {
3+
URL: 'https://useshoppingcart.com'
4+
}
5+
}
6+
17
export const exampleProducts = `
28
[
39
{

docs/src/theme/Root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function Root({ children }) {
99
<CartProvider
1010
mode="payment"
1111
cartMode="checkout-session"
12-
stripe={process.env.REACT_APP_STRIPE_API_PUBLIC}
12+
stripe={''}
1313
billingAddressCollection={false}
1414
successUrl="https://stripe.com"
1515
cancelUrl="https://twitter.com/dayhaysoos"

examples/cra/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"react-dom": "^17.0.2",
1111
"react-scripts": "^4.0.3",
1212
"theme-ui": "^0.10.0",
13-
"use-shopping-cart": "file:../../use-shopping-cart",
13+
"use-shopping-cart": "workspace:^3.1.4",
1414
"web-vitals": "^1.0.1"
1515
},
1616
"scripts": {

examples/gatsby/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react": "^17.0.2",
2020
"react-dom": "^17.0.2",
2121
"react-helmet": "^5.2.1",
22-
"use-shopping-cart": "*"
22+
"use-shopping-cart": "workspace:^3.1.4"
2323
},
2424
"keywords": [
2525
"gatsby"

examples/nextjs/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel

examples/nextjs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Resources used:
2+
- [Tabler icons](https://tabler-icons.io/) for shopping cart icon

0 commit comments

Comments
 (0)