Skip to content

Commit

Permalink
Update script to fetch code by version tag and adjust yorkie-js-sdk v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
chacha912 committed Aug 22, 2024
1 parent f95b9fa commit 0190520
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/nextjs-scheduler/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/profile-stack/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/react-tldraw/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/react-todomvc/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/simultaneous-cursors/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/vanilla-codemirror6/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/vanilla-quill/fileInfo.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/vuejs-kanban/fileInfo.ts

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/node": "18.11.5",
"@types/react": "18.0.23",
"@types/react-dom": "18.0.7",
"dotenv": "^16.4.5",
"eslint": "8.26.0",
"eslint-config-next": "13.0.0",
"postcss-path-replace": "^1.0.4",
Expand Down
10 changes: 9 additions & 1 deletion scripts/fetch-examples.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/usr/bin/env bash

export $(grep -v '^#' .env | xargs)
version=$NEXT_PUBLIC_YORKIE_JS_VERSION

git clone https://github.com/yorkie-team/yorkie-js-sdk.git temp
cd temp
git fetch origin refs/tags/v$version
git checkout tags/v$version
echo "Checked out to tag v$version."
cd ..

for f in temp/examples/* ; do
if [ -d "$f" ]; then
Expand All @@ -19,4 +27,4 @@ done

npm i -g ts-node
ts-node --esm scripts/fetchExamples.mts
rm -rf temp
rm -rf temp
9 changes: 9 additions & 0 deletions scripts/fetchExamples.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import fs from 'fs';
import path from 'path';
import dotenv from 'dotenv';
import type { DirectoryInfo, FileInfo } from '../utils/exampleFileUtils';

dotenv.config();
const yorkieVersion = process.env.NEXT_PUBLIC_YORKIE_JS_VERSION;

const makeDirectory = (dirPath: string) => {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
Expand Down Expand Up @@ -78,6 +82,11 @@ const getFileContent = (filePath: string): string => {
return '';
}

if (filePath.includes('package.json')) {
const content = readFile(filePath);
return content.replace(/"yorkie-js-sdk": "workspace:\*"/g, `"yorkie-js-sdk": "^${yorkieVersion}"`);
}

return readFile(filePath);
};

Expand Down

0 comments on commit 0190520

Please sign in to comment.