@redotech/redo-hydrogen 1.4.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +58 -0
- package/.github/workflows/e2e.yml +72 -0
- package/.github/workflows/publish.yml +68 -0
- package/.prettierrc +7 -0
- package/.vscode/settings.json +10 -0
- package/CHANGELOG.md +36 -24
- package/README.md +37 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/types.d.ts +24 -4
- package/eslint.config.mjs +22 -0
- package/package.json +25 -12
- package/src/components/redo-checkout-buttons.tsx +51 -72
- package/src/components/redo-info-modal.tsx +486 -345
- package/src/hooks/use-purple-dot-preorder.ts +39 -0
- package/src/index.ts +14 -4
- package/src/providers/redo-coverage-client.tsx +67 -69
- package/src/svg.d.ts +2 -2
- package/src/types.ts +30 -23
- package/src/utils/cart.ts +117 -153
- package/src/utils/purple-dot.ts +86 -0
- package/src/utils/react-utils.ts +9 -14
- package/src/utils/security.ts +3 -8
- package/src/utils/timeout.ts +1 -6
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
typecheck:
|
|
11
|
+
name: Typecheck
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20
|
|
18
|
+
cache: npm
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm run typecheck
|
|
21
|
+
|
|
22
|
+
lint:
|
|
23
|
+
name: Lint
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-node@v4
|
|
28
|
+
with:
|
|
29
|
+
node-version: 20
|
|
30
|
+
cache: npm
|
|
31
|
+
- run: npm ci
|
|
32
|
+
- run: npm run lint
|
|
33
|
+
|
|
34
|
+
format:
|
|
35
|
+
name: Format
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
- uses: actions/setup-node@v4
|
|
40
|
+
with:
|
|
41
|
+
node-version: 20
|
|
42
|
+
cache: npm
|
|
43
|
+
- run: npm ci
|
|
44
|
+
- run: npm run format:check
|
|
45
|
+
|
|
46
|
+
build:
|
|
47
|
+
name: Build
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@v4
|
|
51
|
+
- uses: actions/setup-node@v4
|
|
52
|
+
with:
|
|
53
|
+
node-version: 20
|
|
54
|
+
cache: npm
|
|
55
|
+
- run: npm ci
|
|
56
|
+
- run: npm run build
|
|
57
|
+
env:
|
|
58
|
+
NODE_OPTIONS: '--max-old-space-size=12288'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: E2E Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
e2e:
|
|
15
|
+
name: E2E Tests
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
timeout-minutes: 15
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: 20
|
|
24
|
+
cache: npm
|
|
25
|
+
|
|
26
|
+
- name: Setup test environment
|
|
27
|
+
run: bash e2e/scripts/setup.sh
|
|
28
|
+
|
|
29
|
+
- name: Create quickstart .env
|
|
30
|
+
working-directory: e2e/fixtures/hydrogen-quickstart
|
|
31
|
+
run: |
|
|
32
|
+
cat > .env << EOF
|
|
33
|
+
SESSION_SECRET=e2e-ci-secret
|
|
34
|
+
PUBLIC_STOREFRONT_API_TOKEN=${{ secrets.SHOPIFY_QUICKSTART_STOREFRONT_TOKEN }}
|
|
35
|
+
PUBLIC_STORE_DOMAIN=${{ secrets.SHOPIFY_QUICKSTART_STORE_DOMAIN }}
|
|
36
|
+
PUBLIC_REDO_STORE_ID=${{ secrets.REDO_QUICKSTART_STORE_ID }}
|
|
37
|
+
PUBLIC_TEST_PRODUCT_HANDLE=${{ secrets.SHOPIFY_QUICKSTART_PRODUCT_HANDLE }}
|
|
38
|
+
STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}
|
|
39
|
+
EOF
|
|
40
|
+
|
|
41
|
+
- name: Run E2E tests
|
|
42
|
+
run: npx playwright test
|
|
43
|
+
working-directory: e2e
|
|
44
|
+
|
|
45
|
+
- name: Compile test video
|
|
46
|
+
if: always()
|
|
47
|
+
run: bash scripts/compile-video.sh
|
|
48
|
+
working-directory: e2e
|
|
49
|
+
|
|
50
|
+
- name: Upload test video and comment on PR
|
|
51
|
+
if: github.event_name == 'pull_request' && always()
|
|
52
|
+
working-directory: e2e
|
|
53
|
+
run: |
|
|
54
|
+
if [ ! -f test-run.mp4 ]; then
|
|
55
|
+
echo "No video to upload"
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
VIDEO_URL=$(bash scripts/upload-github-video.sh test-run.mp4 ${{ github.event.pull_request.number }})
|
|
59
|
+
BODY="**E2E test recording** (4x speed, 640x480)
|
|
60
|
+
|
|
61
|
+
${VIDEO_URL}"
|
|
62
|
+
gh pr comment ${{ github.event.pull_request.number }} --body "$BODY"
|
|
63
|
+
env:
|
|
64
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
65
|
+
|
|
66
|
+
- name: Upload Playwright report
|
|
67
|
+
uses: actions/upload-artifact@v4
|
|
68
|
+
if: failure()
|
|
69
|
+
with:
|
|
70
|
+
name: playwright-report
|
|
71
|
+
path: e2e/playwright-report/
|
|
72
|
+
retention-days: 14
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: "Exact version to publish (e.g. 2.1.0)"
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
publish:
|
|
17
|
+
name: Publish to npm
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- name: Generate app token
|
|
21
|
+
id: app-token
|
|
22
|
+
uses: actions/create-github-app-token@v1
|
|
23
|
+
with:
|
|
24
|
+
app-id: ${{ secrets.APP_ID }}
|
|
25
|
+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
|
26
|
+
|
|
27
|
+
- uses: actions/checkout@v6
|
|
28
|
+
with:
|
|
29
|
+
token: ${{ steps.app-token.outputs.token }}
|
|
30
|
+
|
|
31
|
+
- uses: actions/setup-node@v6
|
|
32
|
+
with:
|
|
33
|
+
node-version: 24
|
|
34
|
+
cache: npm
|
|
35
|
+
registry-url: https://registry.npmjs.org
|
|
36
|
+
|
|
37
|
+
- run: npm ci
|
|
38
|
+
|
|
39
|
+
- run: npm run build
|
|
40
|
+
|
|
41
|
+
- name: Verify build output
|
|
42
|
+
run: |
|
|
43
|
+
if [ ! -d "dist" ]; then
|
|
44
|
+
echo "Error: dist folder does not exist"
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
- name: Set version
|
|
49
|
+
env:
|
|
50
|
+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
51
|
+
run: |
|
|
52
|
+
CURRENT=$(node -p "require('./package.json').version")
|
|
53
|
+
git config user.name "github-actions[bot]"
|
|
54
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
55
|
+
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
|
|
56
|
+
if [ "$CURRENT" != "${{ inputs.version }}" ]; then
|
|
57
|
+
npm version ${{ inputs.version }} --no-git-tag-version
|
|
58
|
+
git add package.json package-lock.json
|
|
59
|
+
git commit -m "v${{ inputs.version }}"
|
|
60
|
+
git tag "v${{ inputs.version }}"
|
|
61
|
+
git push --follow-tags
|
|
62
|
+
else
|
|
63
|
+
git tag "v${{ inputs.version }}"
|
|
64
|
+
git push --tags
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
- name: Publish
|
|
68
|
+
run: npm publish --access public --provenance
|
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 2.0.0
|
|
2
|
+
|
|
3
|
+
- **Breaking:** migrate from Remix to React Router 7 (requires `@shopify/hydrogen` >=2025.7.0)
|
|
4
|
+
- Update all peer dependencies for Hydrogen 2025.7+ compatibility
|
|
5
|
+
- Themes still using Remix should use the [1.x releases](https://github.com/redoapp/redo-hydrogen/tree/release/1.4)
|
|
6
|
+
|
|
7
|
+
## 1.x
|
|
8
|
+
|
|
9
|
+
### 1.4.7
|
|
10
|
+
|
|
11
|
+
- Add hook to disable pre-order buttons from Purple Dot when using shop on site
|
|
12
|
+
|
|
1
13
|
### 1.4.6
|
|
2
14
|
|
|
3
15
|
- Bugfix: bad deployment
|
|
@@ -8,75 +20,75 @@
|
|
|
8
20
|
|
|
9
21
|
### 1.4.4
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
- Bugfix: remove InfoModal using relative parent not document.head
|
|
12
24
|
|
|
13
25
|
### 1.4.3
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
- Append redo opted in attributes to cart attributes instead of replacing
|
|
16
28
|
|
|
17
29
|
### 1.4.2
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
- Fix Hydrogen mismatched deps
|
|
20
32
|
|
|
21
33
|
### 1.4.1
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
- Allow older and newer versions of Hydrogen
|
|
36
|
+
- Change default background color of modal to white
|
|
25
37
|
|
|
26
38
|
### 1.4.0
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
- Add InfoCard
|
|
29
41
|
|
|
30
42
|
### 1.3.1
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
- Remove unused prop from CheckoutButtons
|
|
33
45
|
|
|
34
46
|
### 1.3.0
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
- Add a spinner visual after button clicked and navigating to cart
|
|
49
|
+
- Bugfixes and improved types for optimistic carts
|
|
38
50
|
|
|
39
51
|
### 1.2.2
|
|
40
52
|
|
|
41
|
-
|
|
53
|
+
- Bugfixes
|
|
42
54
|
|
|
43
55
|
### 1.2.1
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
- Fix root types exports
|
|
46
58
|
|
|
47
59
|
### 1.2.0
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
- If cart is a CartWithActionsDocs, use those cart manipulation functions instead of fetchers
|
|
50
62
|
|
|
51
63
|
### 1.1.3
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
- Allow both Cart and CartWithActionsDocs as cart inputs
|
|
66
|
+
- Retrieve cart lines from either cart.lines.nodes or cart.lines.edges.nodes
|
|
55
67
|
|
|
56
68
|
### 1.1.2
|
|
57
69
|
|
|
58
|
-
|
|
70
|
+
- Update exports to include RedoError and RedoErrorType
|
|
59
71
|
|
|
60
72
|
### 1.1.1
|
|
61
73
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
- Add errors field to RedoCoverageClient
|
|
75
|
+
- Add eligible field to RedoCoverageClient
|
|
76
|
+
- Price returns undefined if not eligible or not loaded
|
|
77
|
+
- Bugfixes
|
|
66
78
|
|
|
67
79
|
### 1.1.0
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
- Remove need for storeId and cart props on CheckoutButtons
|
|
82
|
+
- Bugfixes
|
|
71
83
|
|
|
72
84
|
### 1.0.2
|
|
73
85
|
|
|
74
|
-
|
|
86
|
+
- Bugfixes
|
|
75
87
|
|
|
76
88
|
### 1.0.1
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
- Bugfixes
|
|
79
91
|
|
|
80
92
|
### 1.0.0
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
- Initial release
|
package/README.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Redo Hydrogen
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Utilities to enable and disable Redo coverage on Hydrogen stores.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
Full integration docs: https://developers.redo.com/docs/guides/integrations/hydrogen
|
|
8
|
+
|
|
9
|
+
## Version compatibility
|
|
10
|
+
|
|
11
|
+
| Package version | Hydrogen version | Router |
|
|
12
|
+
| --------------- | ---------------- | ------------- |
|
|
13
|
+
| 2.x | 2025.7+ | React Router 7 |
|
|
14
|
+
| 1.x | Earlier versions | Remix |
|
|
15
|
+
|
|
16
|
+
If your theme still uses Remix, use the [1.x releases](https://github.com/redoapp/redo-hydrogen/tree/release/1.4).
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
npm run build
|
|
23
|
+
npm run dev # watch mode
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Running checks
|
|
27
|
+
|
|
28
|
+
Before submitting a PR, make sure all checks pass:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run typecheck
|
|
32
|
+
npm run lint
|
|
33
|
+
npm run e2e
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
PRs are welcome! This package is maintained by Redo and the Hydrogen community.
|
|
39
|
+
|
|
40
|
+
We would especially love contributions that add more fixtures to our CI/CD pipeline — the more store configurations we test against, the more confident we can be in releases. Check the `e2e/fixtures/` directory for existing examples.
|