Skip to content

Commit

Permalink
Merge branch 'main' into merx-899-prevent-install-app-twice
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch authored Aug 27, 2024
2 parents b7a7749 + 7161fae commit bd23bca
Show file tree
Hide file tree
Showing 24 changed files with 345 additions and 210 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

version: 2
updates:
- package-ecosystem: "npm"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/assign-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ on:
jobs:
assign_creator:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- name: Assign PR to creator
uses: thomaseizinger/[email protected].0
uses: toshimaru/auto-author-assign@ebd30f10fb56e46eb0759a14951f36991426fed0 # v2.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release @dev tag to npm
on:
pull_request:
types: [labeled]

jobs:
release:
if: ${{ github.event.label.name == 'release dev tag' }}
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--frozen-lockfile]
- name: Check for changeset
run: pnpm exec changeset status --since origin/main
- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release on @dev tag in npm
run: pnpm publish:ci-dev
- name: Get new package version
run: |
VERSION=$(cat package.json | jq -r '.version')
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Add installation instructions PR comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
env:
VERSION: ${{ env.VERSION }}
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Released snapshot build with `@dev` tag in npm with version: `${{ env.VERSION }}`.
Install it with:
```shell
pnpm add @saleor/app-sdk@${{ env.VERSION }}
```
102 changes: 31 additions & 71 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,58 @@ name: QA
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
- uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Check linters
run_install: |
- args: [--frozen-lockfile]
- name: Check linter
run: pnpm lint
- name: Check types
run: pnpm check-types

test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8.2.0
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
node-version: 18
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Test
run_install: |
- args: [--frozen-lockfile]
- name: Run tests
run: pnpm test:ci
- name: Generate coverage report
uses: irongut/[email protected]
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
if: ${{ github.actor != 'dependabot[bot]' }}
with:
filename: coverage/cobertura-coverage.xml
format: markdown
output: file

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
with:
recreate: true
path: code-coverage-results.md

build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
node-version: 18
cache: pnpm
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-
- name: Install dependencies
run: pnpm install
- name: Build project
run_install: |
- args: [--frozen-lockfile]
- name: Build package
run: pnpm build
- name: Creating .npmrc
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release on @dev tag in npm
if: ${{ github.actor != 'dependabot[bot]' }}
run: npx changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks
# Store package.json version in env
- run: echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV
if: ${{ github.actor != 'dependabot[bot]' }}
- run: echo '${{ fromJson(env.PACKAGE_JSON).version }}'
if: ${{ github.actor != 'dependabot[bot]' }}
# Post a comment with released snapshot
- name: Create with released tag
if: ${{ github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Released snapshot build with `@dev` tag in npm with version: `${{ fromJson(env.PACKAGE_JSON).version }}`
Install it with
```bash
pnpm add @saleor/app-sdk@${{ fromJson(env.PACKAGE_JSON).version }}
```
34 changes: 14 additions & 20 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@ on:

concurrency: ${{ github.workflow }}-${{ github.ref }}

#
# TODO
# - Add tags for each app (e.g. [email protected]) for easier parsing
# - Print versions name to commit, for easier Vercel deployments
#
jobs:
release:
name: Prepare release with Changesets
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
HUSKY: 0
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- uses: pnpm/[email protected] # Use version from package.json
- name: Setup Node.js 16 # It was default for Changesets action, check if it can be bumped to v18
uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: 16
- uses: pnpm/action-setup@v2
name: Install pnpm
- run: pnpm install
# TODO -> publish to npm as pre-release https://github.com/changesets/changesets/blob/8447c677a37d1d23858059e0ce2b5cd98f4c24ae/docs/snapshot-releases.md
token: ${{ secrets.PAT }}
- name: Setup PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--frozen-lockfile]
- name: Create Release Pull Request
uses: changesets/action@v1
id: changesets
uses: changesets/action@e2f8e964d080ae97c874b19e27b12e0a8620fb6c # v1.4.6
with:
title: Release to npm
commit: Release to npm
publish: "pnpm publish:ci"
publish: "pnpm publish:ci-prod"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use private access token so Github can trigger another workflow from this one
GITHUB_TOKEN: ${{ secrets.PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ dist
.pnp.*

.idea/
.vscode/
.vscode/
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run test:ci
pnpm check-types && pnpm test:ci
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @saleor/app-sdk

## 0.50.1

### Patch Changes

- d24c734: Added additional debug logs for createManifestHandler utility. Now app with DEBUG env variable will print extra messagess helpful with broken app installations

## 0.50.0

### Minor Changes

- ef61335: Fix wrong logic introduced in [0.49.0](https://github.com/saleor/app-sdk/releases/tag/v0.49.0): there is not header `saleor-schema-version` when app-sdk is processing saleor webhook. This header is only present on install request.

Now app-sdk will try to parse version from `version` field on GraphQL subscription [Event](https://docs.saleor.io/docs/3.x/api-storefront/miscellaneous/interfaces/event#code-style-fontweight-normal-eventbversionbcodestring-). If field is not present `null` will be returned.

## 0.49.0

### Minor Changes

- 53b8cdc: Parse the `saleor-schema-version` header and include the parsed version in the contexts of `createHandler` and `webhookFactory`. If the header is absent (Saleor version below 3.15), the version will default to `null`. This parsed version enables supporting multiple schemas in a single app, as outlined in the [RFC](https://github.com/saleor/apps/issues/1213).

## 0.48.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @saleor/apps
* @saleor/apps-guild
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saleor/app-sdk",
"version": "0.48.2",
"version": "0.50.1",
"description": "SDK for building great Saleor Apps",
"scripts": {
"prepublishOnly": "pnpm build",
Expand All @@ -10,9 +10,11 @@
"test": "vitest",
"test:ci": "CI=true vitest --coverage --silent",
"prepare": "husky install",
"lint": "tsc --noEmit && prettier --loglevel warn --write . && eslint --fix .",
"check-types": "tsc --noEmit",
"lint": "prettier --loglevel warn --write . && eslint --fix .",
"copy-readme": "cp README.md dist/README.md",
"publish:ci": "pnpm publish && npx changeset tag && git push --follow-tags",
"publish:ci-prod": "pnpm publish && pnpm exec changeset tag && git push --follow-tags",
"publish:ci-dev": "pnpm exec changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks",
"lint-staged": "lint-staged"
},
"keywords": [],
Expand All @@ -35,7 +37,7 @@
"uuid": "9.0.0"
},
"devDependencies": {
"@changesets/cli": "2.26.2",
"@changesets/cli": "2.27.1",
"@testing-library/dom": "^8.17.1",
"@testing-library/react": "^13.4.0",
"@types/debug": "^4.1.7",
Expand Down
Loading

0 comments on commit bd23bca

Please sign in to comment.