Skip to content

Commit db89f0d

Browse files
committed
Init
0 parents  commit db89f0d

File tree

430 files changed

+33865
-0
lines changed

Some content is hidden

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

430 files changed

+33865
-0
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": [
11+
"partial-prerendering",
12+
"summer-sale",
13+
"svelte-example",
14+
"next-13",
15+
"next-14",
16+
"next-15"
17+
],
18+
"snapshot": {
19+
"useCalculatedVersion": true
20+
}
21+
}

.changeset/olive-chairs-grab.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
'@vercel/flags': minor
3+
---
4+
5+
@vercel/flags/next: Export `dedupe` function
6+
7+
`dedupe` is a middleware-friendly version of `React.cache`. It allows ensuring a function only ever runs once for a request.
8+
9+
```ts
10+
import { dedupe } from '@vercel/flags/next';
11+
12+
let i = 0;
13+
const runOnce = dedupe(async () => {
14+
return i++;
15+
});
16+
17+
await runOnce(); // returns 0
18+
await runOnce(); // still returns 0
19+
```
20+
21+
This function is useful when you want to deduplicate work within each feature flag's `decide` function. For example if multiple flags need to check auth you can dedupe the auth function so it only runs once per request.
22+
23+
`dedupe` is also useful to optimistically generate a random visitor id to be set in a cookie, while also allowing each feature flag to access the id. You can call a dedupe'd function to generate the random id within your Edge Middleware and also within your feature flag's `decide` functions. The function will return a consistent id.
24+
25+
```ts
26+
import { nanoid } from 'nanoid';
27+
import { cookies, headers } from 'next/headers';
28+
import { dedupe } from '@vercel/flags/next';
29+
30+
/**
31+
* Reads the visitor id from a cookie or returns a new visitor id
32+
*/
33+
export const getOrGenerateVisitorId = dedupe(
34+
async (): Promise<{ value: string; fresh: boolean }> => {
35+
const visitorIdCookie = (await cookies()).get('visitor-id')?.value;
36+
37+
return visitorIdCookie
38+
? { value: visitorIdCookie, fresh: false }
39+
: { value: nanoid(), fresh: true };
40+
},
41+
);
42+
```
43+
44+
> Note: "once per request" is an imprecise description. A `dedupe`d function actually runs once per request, per compute instance. If a dedupe'd function is used in Edge Middleware and in a React Server Component it will run twice, as there are two separate compute instances handling this request.
45+
46+
> Note: This function acts as a sort of polyfill until similar functionality lands in Next.js directly.

.changeset/poor-rules-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vercel/flags': major
3+
---
4+
5+
add identify, drop getPrecomputationContext, change .run({})

.changeset/ten-eagles-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vercel/flags': major
3+
---
4+
5+
remove unstable\_ prefixes

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { resolve } = require('node:path');
2+
3+
module.exports = {
4+
root: true,
5+
// This tells ESLint to load the config from the package `eslint-config-custom`
6+
extends: ['custom'],
7+
rules: {
8+
'@typescript-eslint/explicit-function-return-type': 'off',
9+
'import/no-default-export': 'off',
10+
'@typescript-eslint/no-confusing-void-expression': 'off',
11+
},
12+
parserOptions: {
13+
project: [
14+
resolve(__dirname, './packages/*/tsconfig.json'),
15+
resolve(__dirname, './tooling/*/tsconfig.json'),
16+
resolve(__dirname, './examples/*/tsconfig.json'),
17+
resolve(__dirname, './tests/*/tsconfig.json'),
18+
],
19+
},
20+
};

.github/workflows/playwright.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: ['*']
7+
jobs:
8+
test:
9+
timeout-minutes: 5
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup pnpm
14+
uses: pnpm/action-setup@v2
15+
with:
16+
version: 9
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version-file: '.node-version'
20+
cache: 'pnpm'
21+
- name: Install dependencies
22+
run: pnpm install --frozen-lockfile
23+
- name: Install Playwright Browsers
24+
run: pnpm exec playwright install chromium
25+
- name: Install Playwright System Dependencies
26+
run: pnpm exec playwright install-deps chromium
27+
- name: Run Playwright tests
28+
run: pnpm test:e2e
29+
- uses: actions/upload-artifact@v4
30+
if: ${{ !cancelled() }}
31+
with:
32+
name: playwright-report
33+
path: playwright-report/
34+
retention-days: 30

.github/workflows/quality.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Quality
2+
3+
env:
4+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
5+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
6+
7+
on:
8+
push:
9+
branches: [main]
10+
pull_request:
11+
branches: [main]
12+
13+
jobs:
14+
prettier:
15+
name: 'Prettier'
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v2
23+
24+
- uses: actions/setup-node@v3
25+
with:
26+
node-version-file: '.node-version'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
- name: Run Prettier check
33+
run: pnpm prettier-check
34+
35+
eslint:
36+
name: 'ESLint'
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Setup pnpm
43+
uses: pnpm/action-setup@v2
44+
45+
- uses: actions/setup-node@v3
46+
with:
47+
node-version-file: '.node-version'
48+
cache: 'pnpm'
49+
50+
- name: Install dependencies
51+
run: pnpm install
52+
53+
- name: Run ESLint
54+
run: pnpm run lint
55+
56+
types:
57+
name: 'TypeScript'
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Setup pnpm
64+
uses: pnpm/action-setup@v2
65+
66+
- uses: actions/setup-node@v3
67+
with:
68+
node-version-file: '.node-version'
69+
cache: 'pnpm'
70+
71+
- name: Install dependencies
72+
run: pnpm install
73+
74+
- name: Run TypeScript type check
75+
run: pnpm run type-check
76+
77+
publint:
78+
name: 'publint'
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
84+
- name: Setup pnpm
85+
uses: pnpm/action-setup@v2
86+
87+
- uses: actions/setup-node@v3
88+
with:
89+
node-version-file: '.node-version'
90+
cache: 'pnpm'
91+
92+
- name: Install dependencies
93+
run: pnpm install
94+
95+
- name: Run Publint
96+
run: pnpm run publint
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This workflow lets you manually create snapshot relases
2+
#
3+
# A snapshot release is useful when you want to try out changes on a pull request
4+
# before making a full release and without making a pre release mode.
5+
#
6+
# Problem
7+
#
8+
# This is useful as changesets force pre release mode across all packages in our
9+
# mono repo. When using pre releases then stable releases of all packages are
10+
# blocked until pre release is exited.
11+
#
12+
# What are snapshot releases
13+
#
14+
# To work around this issue we have this workflow. It lets you create a
15+
# once-off release for a specific branch. We call those snapshot releases.
16+
# Snapshot releases are published under the `snapshot` dist-tag and have
17+
# versions like 0.4.0-579bd13f016c7de43a2830340634b3948db358b6-20230913164912,
18+
# which consist of the version that would be generated, the commit hash and
19+
# the timestamp.
20+
#
21+
# How to create a snapshot release
22+
#
23+
# Make sure you have a branch pushed to GitHub, and make sure that branch has
24+
# a changeset committed. You can generate a changeset with "pnpm changeset".
25+
#
26+
# Then open github.com/vercel/variants and click on Actions > Release Snapshot
27+
# Then click "Run workflow" on the right and select the branch you want to
28+
# create a snapshot release for and click the "Run workflow" button.
29+
#
30+
# Then wait for the run to kick off and open the details.
31+
# Find the "Create Snapshot Release" step in the logs.
32+
# The last line of that log should contain something like
33+
# 🦋 success packages published successfully:
34+
# 🦋 @vercel/edge-config@0.4.0-579bd13f016c7de43a2830340634b3948db358b6-20230913164912
35+
# This shows the version which was generated.
36+
37+
name: Release Snapshot
38+
39+
env:
40+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
41+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
42+
43+
on:
44+
workflow_dispatch:
45+
46+
jobs:
47+
release-snapshot:
48+
name: Release
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Setup pnpm
55+
uses: pnpm/action-setup@v2
56+
57+
- uses: actions/setup-node@v3
58+
with:
59+
node-version-file: '.node-version'
60+
cache: 'pnpm'
61+
62+
- name: Add npm auth token to pnpm
63+
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN_ELEVATED}"
64+
env:
65+
NPM_TOKEN_ELEVATED: ${{secrets.NPM_TOKEN_ELEVATED}}
66+
67+
- name: Install Dependencies
68+
run: pnpm install
69+
70+
- name: Add SHORT_SHA env property with commit short sha
71+
run: echo "SHORT_SHA=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_ENV
72+
73+
- name: Version Packages
74+
run: pnpm changeset version --snapshot ${SHORT_SHA}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
78+
79+
- name: Build
80+
run: pnpm build
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
84+
EDGE_CONFIG: ${{ secrets.EDGE_CONFIG }}
85+
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
86+
FLAGS: ${{ secrets.FLAGS }}
87+
LAUNCHDARKLY_API_TOKEN: ${{ secrets.LAUNCHDARKLY_API_TOKEN }}
88+
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
89+
HAPPYKIT_ENV_KEY: ${{ secrets.HAPPYKIT_ENV_KEY }}
90+
91+
- name: Publish Snapshot Release
92+
run: pnpm changeset publish --no-git-tag --tag snapshot
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
env:
4+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
5+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
concurrency: ${{ github.workflow }}-${{ github.ref }}
13+
14+
jobs:
15+
release:
16+
name: Release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v2
24+
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version-file: '.node-version'
28+
cache: 'pnpm'
29+
30+
- name: Install Dependencies
31+
run: pnpm install
32+
33+
- name: Create Release Pull Request or Publish to npm
34+
id: changesets
35+
uses: changesets/action@v1
36+
with:
37+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
38+
publish: pnpm release
39+
version: pnpm version-packages
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
43+
EDGE_CONFIG: ${{ secrets.EDGE_CONFIG }}
44+
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
45+
LAUNCHDARKLY_API_TOKEN: ${{ secrets.LAUNCHDARKLY_API_TOKEN }}
46+
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
47+
HAPPYKIT_ENV_KEY: ${{ secrets.HAPPYKIT_ENV_KEY }}

0 commit comments

Comments
 (0)