Skip to content

Commit e110752

Browse files
committed
feat(repo): merge master from [email protected]:supabase/auth-js.git
2 parents 2d16a08 + 9dfff67 commit e110752

Some content is hidden

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

79 files changed

+166650
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"ecmaVersion": 12,
10+
"sourceType": "module"
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"ignorePatterns": ["*.md", "test/__snapshots__/**/*"],
14+
"rules": {
15+
"comma-dangle": "off",
16+
"@typescript-eslint/no-explicit-any": "off",
17+
"@typescript-eslint/ban-types": "off"
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- next
9+
- rc
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
name: Test / OS ${{ matrix.os }} / Node ${{ matrix.node }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest]
18+
node: ["18", "20"]
19+
20+
runs-on: ${{ matrix.os }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node }}
29+
30+
- name: Build
31+
run: |
32+
npm ci
33+
npm run build
34+
35+
- name: Run tests
36+
run: |
37+
cd test && npm ci && cd ..
38+
npm t
39+
40+
- name: Upload coverage results to Coveralls
41+
uses: coverallsapp/github-action@v2
42+
with:
43+
fail-on-error: false
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
path-to-lcov: ./test/coverage/lcov.info
46+
base-path: ./src
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
5+
const TITLE_PATTERN =
6+
/^(?<prefix>[^:!(]+)(?<package>\([^)]+\))?(?<breaking>[!])?:.+$/;
7+
const RELEASE_AS_DIRECTIVE = /^\s*Release-As:/im;
8+
const BREAKING_CHANGE_DIRECTIVE = /^\s*BREAKING[ \t]+CHANGE:/im;
9+
10+
const ALLOWED_CONVENTIONAL_COMMIT_PREFIXES = [
11+
"feat",
12+
"fix",
13+
"ci",
14+
"docs",
15+
"chore",
16+
];
17+
18+
const object = process.argv[2];
19+
const payload = JSON.parse(fs.readFileSync(process.argv[3], "utf-8"));
20+
21+
let validate = [];
22+
23+
if (object === "pr") {
24+
validate.push({
25+
title: payload.pull_request.title,
26+
content: payload.pull_request.body,
27+
});
28+
} else if (object === "push") {
29+
validate.push(
30+
...payload.commits.map((commit) => ({
31+
title: commit.message.split("\n")[0],
32+
content: commit.message,
33+
})),
34+
);
35+
} else {
36+
console.error(
37+
`Unknown object for first argument "${object}", use 'pr' or 'push'.`,
38+
);
39+
process.exit(0);
40+
}
41+
42+
let failed = false;
43+
44+
validate.forEach((payload) => {
45+
if (payload.title) {
46+
const { groups } = payload.title.match(TITLE_PATTERN);
47+
48+
if (groups) {
49+
if (groups.breaking) {
50+
console.error(
51+
`PRs are not allowed to declare breaking changes at this stage of the project. Please remove the ! in your PR title or commit message and adjust the functionality to be backward compatible.`,
52+
);
53+
failed = true;
54+
}
55+
56+
if (
57+
!ALLOWED_CONVENTIONAL_COMMIT_PREFIXES.find(
58+
(prefix) => prefix === groups.prefix,
59+
)
60+
) {
61+
console.error(
62+
`PR (or a commit in it) is using a disallowed conventional commit prefix ("${groups.prefix}"). Only ${ALLOWED_CONVENTIONAL_COMMIT_PREFIXES.join(", ")} are allowed. Make sure the prefix is lowercase!`,
63+
);
64+
failed = true;
65+
}
66+
67+
if (groups.package && groups.prefix !== "chore") {
68+
console.warn(
69+
"Avoid using package specifications in PR titles or commits except for the `chore` prefix.",
70+
);
71+
}
72+
} else {
73+
console.error(
74+
"PR or commit title must match conventional commit structure.",
75+
);
76+
failed = true;
77+
}
78+
}
79+
80+
if (payload.content) {
81+
if (payload.content.match(RELEASE_AS_DIRECTIVE)) {
82+
console.error(
83+
"PR descriptions or commit messages must not contain Release-As conventional commit directives.",
84+
);
85+
failed = true;
86+
}
87+
88+
if (payload.content.match(BREAKING_CHANGE_DIRECTIVE)) {
89+
console.error(
90+
"PR descriptions or commit messages must not contain a BREAKING CHANGE conventional commit directive. Please adjust the functionality to be backward compatible.",
91+
);
92+
failed = true;
93+
}
94+
}
95+
});
96+
97+
if (failed) {
98+
process.exit(1);
99+
}
100+
101+
process.exit(0);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Check pull requests
2+
3+
on:
4+
push:
5+
branches-ignore: # Run the checks on all branches but the protected ones
6+
- master
7+
- release/*
8+
9+
pull_request_target:
10+
branches:
11+
- master
12+
- release/*
13+
types:
14+
- opened
15+
- edited
16+
- reopened
17+
- ready_for_review
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
check-conventional-commits:
24+
runs-on: ubuntu-latest
25+
if: github.actor != 'dependabot[bot]' # skip for dependabot PRs
26+
env:
27+
EVENT: ${{ toJSON(github.event) }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
sparse-checkout: |
32+
.github
33+
34+
- if: ${{ github.event_name == 'pull_request_target' }}
35+
run: |
36+
set -ex
37+
TMP_FILE=$(mktemp)
38+
echo "${EVENT}" > "$TMP_FILE"
39+
node .github/workflows/conventional-commits-lint.js pr "${TMP_FILE}"
40+
41+
- if: ${{ github.event_name == 'push' }}
42+
run: |
43+
set -ex
44+
45+
TMP_FILE=$(mktemp)
46+
echo "${EVENT}" > "$TMP_FILE"
47+
node .github/workflows/conventional-commits-lint.js push "${TMP_FILE}"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
docs:
11+
name: Publish docs / OS ${{ matrix.os }} / Node ${{ matrix.node }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest]
15+
node: ['20']
16+
17+
runs-on: ${{ matrix.os }}
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up Node
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node }}
26+
27+
- run: |
28+
npm ci
29+
npm run docs
30+
npm run docs:json
31+
32+
- name: Publish
33+
uses: peaceiris/actions-gh-pages@v3
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
publish_dir: docs
37+
force_orphan: true
38+
commit_message: 'docs: update'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Dogfooding Check
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted, edited]
6+
7+
pull_request:
8+
9+
push:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
check_dogfooding:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
if: github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.ref == 'release-please--branches--master'
20+
with:
21+
ref: master # used to identify the latest RC version via git describe --tags --match rc*
22+
fetch-depth: 0
23+
24+
- if: github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.ref == 'release-please--branches--master'
25+
run: |
26+
set -ex
27+
28+
# finds the latest RC version on master
29+
RELEASE_VERSION=@supabase/auth-js@$(node -e "const a = '$(git describe --tags --match rc*)'.replace(/^rc/, '').split('-'); console.log(a[0] + '-' + a[1]);")
30+
31+
# use some clever Ruby magic to extract the snapshots['@supabase/auth-js@...'] version from the pnpm-lock.yaml file
32+
STUDIO_VERSION=$(curl 'https://raw.githubusercontent.com/supabase/supabase/refs/heads/master/pnpm-lock.yaml' | ruby -e 'require("yaml"); l = YAML.load(STDIN); puts(l["snapshots"].find { |k, v| k.start_with? "@supabase/auth-js" }.first)')
33+
34+
echo "Expecting RC version $RELEASE_VERSION to be used in Supabase Studio."
35+
36+
if [ "$STUDIO_VERSION" != "$RELEASE_VERSION" ]
37+
then
38+
echo "Version in Supabase Studio is not the latest release candidate. Please release this RC first to proof the release before merging this PR."
39+
exit 1
40+
fi
41+
42+
echo "Release away!"
43+
exit 0
44+
45+
- if: github.event.pull_request.base.ref != 'master' || github.event.pull_request.head.ref != 'release-please--branches--master'
46+
run: |
47+
set -ex
48+
49+
echo "This PR is not subject to dogfooding checks."
50+
exit 0
51+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Manual Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
package:
7+
description: Package name
8+
type: choice
9+
required: true
10+
options:
11+
- auth-js
12+
- gotrue-js
13+
version:
14+
description: Version to publish (1.2.3 not v1.2.3)
15+
type: string
16+
required: true
17+
reason:
18+
description: Why are you manually publishing?
19+
type: string
20+
required: true
21+
22+
jobs:
23+
publish:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- run: |
28+
echo 'Package: ${{ inputs.package }}'
29+
echo 'Version: ${{ inputs.version }}'
30+
echo 'Reason: ${{ inputs.reason }}'
31+
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: v${{ inputs.version }}
35+
36+
- name: Set up Node
37+
uses: actions/setup-node@v1
38+
with:
39+
node-version: '20'
40+
41+
- run: |
42+
npm ci
43+
npm run build
44+
45+
- name: Publish @supabase/${{ inputs.package }} @v${{ inputs.version }}
46+
env:
47+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
run: |
49+
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ~/.npmrc
50+
51+
set -ex
52+
53+
for f in package.json package-lock.json
54+
do
55+
sed -i 's/0.0.0/${{ inputs.version }}/' "$f"
56+
57+
sed -i 's|\(["/]\)auth-js|\1${{ inputs.package }}|g' "$f"
58+
done
59+
60+
npm publish # not with --tag latest!
61+

0 commit comments

Comments
 (0)