Skip to content

Commit

Permalink
Prevent exposure of sensitive or unnecessary data in example code
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 committed Aug 22, 2024
1 parent d96d3bb commit f95b9fa
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 41 deletions.
9 changes: 8 additions & 1 deletion components/exampleView/BasicView/commonIgnoreFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ export const COMMON_IGNORE_FILES = [
'*.ico',
'README.md',
'package-lock.json',
'tsconfig.json',
'.gitignore',
'thumbnail.jpg',
'.env.production',
'.eslintrc.js',
'tsconfig.json',
'tsconfig.node.json',
'vite.config.js',
'vite.config.ts',
'vite-env.d.ts',
];
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.

2 changes: 1 addition & 1 deletion pages/examples/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const CalendarExampleView: NextPage = () => {
<ProjectCodes
files={FILE_INFO}
activeFile="/app/page.tsx"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', 'vite.config.js', '/src/vite-env.d.ts']}
ignoreFiles={[...COMMON_IGNORE_FILES, 'next.config.js']}
/>
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ const CodemirrorExampleView: NextPage = () => {
</a>
, a custom CRDT type from Yorkie.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/src/main.ts"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', 'vite.config.js', '/src/vite-env.d.ts']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/src/main.ts" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
</Sidebar.Tabs>
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/kanban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ const KanbanExampleView: NextPage = () => {
Kanban Board is a tool for managing tasks and workflow. It is a visual way to manage tasks and
workflow.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/src/App.vue"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/src/App.vue" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.TabsPanel value="documentStructure">
<div className="codeblock_box">
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/profile-stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ const ProfileStackExampleView: NextPage = () => {
The profile stack shows the list of users currently accessing the Document. Try adding and deleting
users to see how the profile stack changes.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/main.js"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', 'vite.config.js']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/main.js" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
</Sidebar.Tabs>
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/quill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ const QuillExampleView: NextPage = () => {
</a>
.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/src/main.ts"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', 'vite.config.js', '/src/vite-env.d.ts']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/src/main.ts" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
</Sidebar.Tabs>
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/simultaneous-cursors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ const SimultaneousExampleView: NextPage = () => {
</a>
.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/src/App.jsx"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/src/App.jsx" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
</Sidebar.Tabs>
Expand Down
2 changes: 1 addition & 1 deletion pages/examples/tldraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TldrawExampleView: NextPage = () => {
<ProjectCodes
files={FILE_INFO}
activeFile="/src/hooks/useMultiplayerState.ts"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', 'vite.config.js']}
ignoreFiles={COMMON_IGNORE_FILES}
/>
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
Expand Down
6 changes: 1 addition & 5 deletions pages/examples/todomvc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ const TodoListExampleView: NextPage = () => {
</a>
.
</Sidebar.GuideDescription>
<ProjectCodes
files={FILE_INFO}
activeFile="/src/App.tsx"
ignoreFiles={[...COMMON_IGNORE_FILES, '.env', '/src/vite-env.d.ts', 'tsconfig.node.json']}
/>
<ProjectCodes files={FILE_INFO} activeFile="/src/App.tsx" ignoreFiles={COMMON_IGNORE_FILES} />
</Sidebar.TabsPanel>
<Sidebar.Bottom codeURL={EXAMPLE_CODE_URL + exampleKey} />
</Sidebar.Tabs>
Expand Down
4 changes: 4 additions & 0 deletions scripts/fetchExamples.mts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const getFileLanguage = (filename: string): string => {
};

const getFileContent = (filePath: string): string => {
if (filePath.includes('.env.production')) {
return '';
}

const extension = getFileExtension(filePath);
// NOTE(chacha912): Image file is not supported.
if (extension === 'ico' || extension === 'png' || extension === 'jpg') {
Expand Down

0 comments on commit f95b9fa

Please sign in to comment.