Skip to content

Commit 201b997

Browse files
authored
Merge pull request #743 from revisit-studies/dev
v2.2.0
2 parents 3e6ffb8 + 96a6c33 commit 201b997

362 files changed

Lines changed: 22098 additions & 5017 deletions

File tree

Some content is hidden

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

.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ VITE_FIREBASE_CONFIG='
99
appId: "1:811568460432:web:995f6b4f1fc8042b5dde15"
1010
}
1111
'
12-
VITE_STORAGE_ENGINE="localStorage" # "firebase" or "localStorage" or your own custom storage engine
12+
VITE_STORAGE_ENGINE="localStorage" # "firebase" or "supabase" or "localStorage" or your own custom storage engine
1313
VITE_RECAPTCHAV3TOKEN="6LdjOd0lAAAAAASvFfDZFWgtbzFSS9Y3so8rHJth" # recaptcha SITE KEY
14-
VITE_REPO_URL="https://github.com/revisit-studies/study/tree/main/public/" # Set the url for the "view source" link on the front page
14+
VITE_REPO_URL="https://github.com/revisit-studies/study/tree/main/public/" # Set the url for the "view source" link on the front page
15+
16+
VITE_SUPABASE_URL="http://localhost:8000"
17+
VITE_SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"

.github/workflows/deploy_website.yaml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
8+
pull_request:
79

810
jobs:
911
deploy:
1012
runs-on: ubuntu-latest
1113
permissions:
1214
contents: write
15+
pull-requests: write
1316
concurrency:
1417
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
1520
steps:
21+
- name: Comment on PR
22+
uses: hasura/comment-progress@v2.2.0
23+
if: ${{ github.ref != 'refs/heads/main' }}
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
repository: ${{ github.repository }}
27+
number: ${{ github.event.number }}
28+
id: deploy-preview
29+
message: "Starting deployment of preview ⏳..."
30+
1631
- uses: actions/checkout@v3
1732

1833
- uses: actions/setup-node@v3
@@ -22,12 +37,14 @@ jobs:
2237

2338
- run: yarn install --immutable
2439

40+
# If on main without env vars, build with .env file
2541
- name: Build with .env file
26-
if: ${{ vars.VITE_STORAGE_ENGINE == '' }}
42+
if: ${{ vars.VITE_STORAGE_ENGINE == '' && github.ref == 'refs/heads/main' }}
2743
run: yarn build
2844

45+
# If on main with env vars, build with github environment variables
2946
- name: Build with github environment variables
30-
if: ${{ vars.VITE_STORAGE_ENGINE != '' }}
47+
if: ${{ vars.VITE_STORAGE_ENGINE != '' && github.ref == 'refs/heads/main' }}
3148
run: VITE_STORAGE_ENGINE=$VITE_STORAGE_ENGINE yarn build
3249
env:
3350
VITE_STORAGE_ENGINE: ${{ vars.VITE_STORAGE_ENGINE }}
@@ -38,3 +55,29 @@ jobs:
3855
with:
3956
github_token: ${{ secrets.GITHUB_TOKEN }}
4057
publish_dir: ./dist
58+
59+
# If on PR, build with github environment variables
60+
- name: Build with github environment variables
61+
if: ${{ vars.VITE_STORAGE_ENGINE != '' && github.ref != 'refs/heads/main' }}
62+
run: VITE_STORAGE_ENGINE=$VITE_STORAGE_ENGINE VITE_BASE_PATH=$VITE_BASE_PATH yarn build
63+
env:
64+
VITE_STORAGE_ENGINE: ${{ vars.VITE_STORAGE_ENGINE }}
65+
VITE_BASE_PATH: "/study/PR${{ github.event.number }}/"
66+
67+
- name: Push PR deploy preview
68+
uses: peaceiris/actions-gh-pages@v3
69+
if: ${{ github.ref != 'refs/heads/main' }}
70+
with:
71+
github_token: ${{ secrets.GITHUB_TOKEN }}
72+
publish_dir: ./dist
73+
destination_dir: "PR${{ github.event.number }}"
74+
75+
- name: Update comment
76+
uses: hasura/comment-progress@v2.2.0
77+
if: ${{ github.ref != 'refs/heads/main' }}
78+
with:
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
repository: ${{ github.repository }}
81+
number: ${{ github.event.number }}
82+
id: deploy-preview
83+
message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ https://revisit.dev/study/PR${{ github.event.number }} ✨\n\nChanges may take a few minutes to propagate."

.github/workflows/pr_close.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: delete preview on PR close
2+
on:
3+
pull_request:
4+
types: [closed]
5+
6+
jobs:
7+
delete_preview:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
steps:
13+
- name: make empty dir
14+
run: mkdir public
15+
16+
- name: delete folder
17+
uses: peaceiris/actions-gh-pages@v3
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
publish_dir: ./public
21+
destination_dir: "PR${{ github.event.number }}"
22+
23+
- name: Comment on PR
24+
uses: hasura/comment-progress@v2.2.0
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
repository: ${{ github.repository }}
28+
number: ${{ github.event.number }}
29+
id: deploy-preview
30+
message: "🪓 PR closed, deleted preview."

.github/workflows/release_github.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111
jobs:
1212
release:
1313
name: Release pushed tag
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- name: Create release
1717
env:

.github/workflows/vitest.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Playwright Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- main
8+
9+
jobs:
10+
test:
11+
name: 🧪 Unit Tests
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 20
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: lts/*
20+
cache: "yarn"
21+
22+
- name: Install dependencies
23+
run: yarn install --immutable
24+
25+
- name: Run Playwright tests
26+
run: yarn unittest

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ dist-ssr
1313
*.local
1414

1515
# Editor directories and files
16-
.vscode/*
1716
!.vscode/extensions.json
1817
.idea
1918
.DS_Store
@@ -33,3 +32,8 @@ docsLibraries/
3332

3433
public/__revisit-widget
3534
src/public/__revisit-widget
35+
36+
supabase/volumes/*
37+
!supabase/volumes/db/
38+
supabase/volumes/db/data
39+
!supabase/volumes/api/

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"yaml.schemas": {
3+
"./src/parser/StudyConfigSchema.json": "*.yaml"
4+
}
5+
}

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default [{
4040
},
4141

4242
parser: tsParser,
43-
ecmaVersion: 2022,
43+
ecmaVersion: 'latest',
4444
sourceType: 'module',
4545
},
4646

libraryDocGenerator.cjs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ const path = require('path');
99
const generateMd = (library, libraryConfig, forDocs) => `
1010
# ${library}
1111
12+
${forDocs ?
13+
`import StructuredLinks from '@site/src/components/StructuredLinks/StructuredLinks.tsx';
14+
15+
<StructuredLinks
16+
demoLinks={[
17+
{name: "${library} Demo", url: "https://revisit.dev/study/library-${library}"}
18+
]}
19+
codeLinks={[
20+
{name: "${library} Code", url: "https://github.com/revisit-studies/study/tree/main/public/library-${library}"}
21+
]}
22+
${
23+
(libraryConfig.doi || libraryConfig.externalLink)
24+
? `referenceLinks={[
25+
${libraryConfig.doi ? `{name: "DOI", url: "https://dx.doi.org/${libraryConfig.doi}"}` : ''}${libraryConfig.doi && libraryConfig.externalLink ? ',' : ''}
26+
${libraryConfig.externalLink ? `{name: "${library}", url: "${libraryConfig.externalLink}"}` : ''}
27+
]}`
28+
: ''}
29+
/>` : ''}
30+
1231
${!forDocs ? `This is an example study of the library \`${library}\`.` : ''}
1332
1433
${libraryConfig.description}
@@ -30,12 +49,15 @@ ${Object.keys(libraryConfig.components).map((component) => `- ${component}`).sor
3049
${Object.keys(libraryConfig.sequences).length > 0
3150
? Object.keys(libraryConfig.sequences).map((sequence) => `- ${sequence}`).sort((a, b) => a.localeCompare(b)).join('\n')
3251
: 'None'}
52+
53+
${libraryConfig.additionalDescription ? `## Additional Description\n\n${libraryConfig.additionalDescription}` : ''}
3354
`;
3455

3556
const librariesPath = path.join(__dirname, './public/libraries');
3657
const docsLibrariesPath = path.join(__dirname, './docsLibraries');
3758

38-
const libraries = fs.readdirSync(librariesPath);
59+
const libraries = fs.readdirSync(librariesPath)
60+
.filter(library => !library.startsWith('.') && !library.endsWith('.DS_Store'));
3961

4062
if (!fs.existsSync(docsLibrariesPath)) {
4163
fs.mkdirSync(docsLibrariesPath);
@@ -60,6 +82,7 @@ libraries.forEach((library) => {
6082
if (fs.existsSync(exampleAssetsPath)) {
6183
const exampleDocsPath = path.join(exampleAssetsPath, `${library}.md`);
6284
fs.writeFileSync(exampleDocsPath, exampleMd);
85+
6386
// eslint-disable-next-line no-console
6487
console.log(`Documentation saved to ${exampleDocsPath}`);
6588
}

libraryExampleStudyGenerator.cjs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const { exec } = require('child_process');
1515
const librariesPath = path.join(__dirname, './public/libraries');
1616
const publicPath = path.join(__dirname, './public');
1717

18+
1819
// Create example study config template
1920
const createExampleConfig = (libraryName) => ({
2021
$schema: 'https://raw.githubusercontent.com/revisit-studies/study/dev/src/parser/StudyConfigSchema.json',
@@ -30,7 +31,7 @@ const createExampleConfig = (libraryName) => ({
3031
contactEmail: '',
3132
logoPath: 'revisitAssets/revisitLogoSquare.svg',
3233
withProgressBar: true,
33-
sidebar: true,
34+
withSidebar: true,
3435
},
3536
importedLibraries: [libraryName],
3637
components: {
@@ -49,10 +50,16 @@ const createExampleConfig = (libraryName) => ({
4950
});
5051

5152
// Process each library
52-
const libraries = fs.readdirSync(librariesPath);
53+
const libraries = fs.readdirSync(librariesPath)
54+
.filter(library => !library.startsWith('.') && !library.endsWith('.DS_Store'));
55+
5356
libraries.forEach((library) => {
5457
// Skip hidden folders and files, and libraries in skip list
55-
if (library.startsWith('.')) return;
58+
if (library.startsWith('.')) {
59+
// eslint-disable-next-line no-console
60+
console.log(`Skipping ${library} library`);
61+
return;
62+
}
5663

5764
const exampleFolderName = `library-${library}`;
5865
const examplePath = path.join(publicPath, exampleFolderName);
@@ -69,14 +76,15 @@ libraries.forEach((library) => {
6976
fs.mkdirSync(assetsPath);
7077
// eslint-disable-next-line no-console
7178
console.log(`Created ${exampleFolderName}/assets directory`);
79+
80+
// Create config.json
81+
const configPath = path.join(examplePath, 'config.json');
82+
const configContent = createExampleConfig(library);
83+
fs.writeFileSync(configPath, JSON.stringify(configContent, null, 2));
84+
// eslint-disable-next-line no-console
85+
console.log(`Created/Updated ${exampleFolderName}/config.json`);
7286
}
7387

74-
// Create config.json
75-
const configPath = path.join(examplePath, 'config.json');
76-
const configContent = createExampleConfig(library);
77-
fs.writeFileSync(configPath, JSON.stringify(configContent, null, 2));
78-
// eslint-disable-next-line no-console
79-
console.log(`Created/Updated ${exampleFolderName}/config.json`);
8088
});
8189

8290
// eslint-disable-next-line no-console

0 commit comments

Comments
 (0)