-
Notifications
You must be signed in to change notification settings - Fork 84
feat: sync new files from WebContainer to editor #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AriPerkkio
merged 11 commits into
stackblitz:main
from
isaacplmann:add-new-files-in-paths
Nov 5, 2024
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00f514a
feat: sync new files from WebContainer to editor
isaacplmann 67d585d
chore: fixes from review
isaacplmann f256113
chore: account for file deletion
isaacplmann 69f7cd3
Update e2e/src/components/ButtonDeleteFile.tsx
isaacplmann 95c7e65
Merge branch 'main' into add-new-files-in-paths
AriPerkkio 8d7ffc4
test: prefer `toBeVisible` selectors
AriPerkkio f2403a9
test: prefer `toBeVisible` selectors
AriPerkkio 49c941c
test: prefer `toBeVisible` selectors
AriPerkkio 060abf4
feat: sync new files from WebContainer to editor
isaacplmann c79bafe
chore: remove console log
isaacplmann ffa57ef
docs: document filesystem watch globs
isaacplmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { webcontainer } from 'tutorialkit:core'; | ||
|
||
interface Props { | ||
filePath: string; | ||
newContent: string; | ||
|
||
// default to 'store' | ||
access?: 'store' | 'webcontainer'; | ||
testId?: string; | ||
} | ||
|
||
export function ButtonDeleteFile({ filePath, access = 'webcontainer', testId = 'delete-file' }: Props) { | ||
async function deleteFile() { | ||
switch (access) { | ||
case 'webcontainer': { | ||
const webcontainerInstance = await webcontainer; | ||
|
||
await webcontainerInstance.fs.rm(filePath); | ||
|
||
return; | ||
} | ||
case 'store': { | ||
throw new Error('Delete from store not implemented'); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<button data-testid={testId} onClick={deleteFile}> | ||
Delete File | ||
</button> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/filesystem/watch-glob/_files/a/b/baz.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Baz |
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/filesystem/watch-glob/_files/bar.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Initial content |
19 changes: 19 additions & 0 deletions
19
e2e/src/content/tutorial/tests/filesystem/watch-glob/content.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
type: lesson | ||
title: Watch Glob | ||
focus: /bar.txt | ||
filesystem: | ||
watch: ['/*.txt', '/a/**/*', '/src/**/*'] | ||
--- | ||
|
||
import { ButtonWriteToFile } from '@components/ButtonWriteToFile'; | ||
import { ButtonDeleteFile } from '@components/ButtonDeleteFile'; | ||
|
||
# Watch filesystem test | ||
|
||
<ButtonWriteToFile client:load access="webcontainer" filePath="/bar.txt" newContent='Something else' /> | ||
<ButtonWriteToFile client:load access="webcontainer" filePath="/a/b/baz.txt" newContent='Foo' testId='write-to-file-in-subfolder' /> | ||
<ButtonWriteToFile client:load access="webcontainer" filePath="/src/new.txt" newContent='New' testId='write-new-file' /> | ||
<ButtonWriteToFile client:load access="webcontainer" filePath="/unknown/other.txt" newContent='Ignore this' testId='write-new-ignored-file' /> | ||
|
||
<ButtonDeleteFile client:load access="webcontainer" filePath="/bar.txt" testId='delete-file' /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
// https://github.com/micromatch/picomatch?tab=readme-ov-file#api | ||
declare module 'picomatch/posix.js' { | ||
export { default } from 'picomatch'; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.