feat(cli): sv create --from-playground#662
Conversation
🦋 Changeset detectedLatest commit: b4b6d33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
This is exciting 🤩 I have this one that could show a few things: https://svelte.dev/playground/770bbef086034b9f8e337bab57efe8d8
+layout.svelte example<script lang="ts"> import favicon from '$lib/assets/favicon.svg'; |
This is perfect, and i was able to get it fully working from the tests.
Not sure, I'm a fan of this. The current "download app" button does nothing like this. Also, I'm not sure if this provides any additional value to the user, or just causes styling problems because of the added css. We can always add this later if users want this. |
|
Great progress 🚀🚀🚀 Nice
The cool thing about a layout like this is that:
Yes, I love this idea 😜 Anyhow, very nice job |
|
Updated pr description, this is working now. Let me know what you think. |
jycouet
left a comment
There was a problem hiding this comment.
Comments in random order:
- I find it strange to have the "Template content" coming from a playground. Maybe
+page.svelteshould have ONLY<App />, nothing else ? - I still like the playground layout idea :p
- Maybe a default folder name could be proposed "svelte-playground-slug-name-of-playgound" ?
- Maybe the
readme.mdcould mention the origin of the playground ? - If some extra deps are needed, prompt it in CLI and add it to readme.md ?
It's probably nitpicking, because it's working well already.
Great work 🎉🎉🎉
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to create SvelteKit projects from Svelte playground URLs using the --from-playground flag. Users can now run sv create --from-playground=<url> to generate a project based on playground code with automatic dependency detection and installation.
Key changes:
- Added playground URL validation and parsing functionality
- Implemented automatic detection and installation of external dependencies
- Created comprehensive test suite for playground functionality
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rolldown.config.js | Added playground.ts to the build inputs for the create package |
| packages/create/test/playground.ts | Added comprehensive tests for playground URL validation, parsing, and project creation |
| packages/create/playground.ts | Core implementation for playground functionality including URL validation, data download, and project setup |
| packages/create/package.json | Added export for playground module and cli-core dependency |
| packages/cli/commands/create.ts | Integrated playground functionality into the create command with user prompts and validation |
| .changeset/brown-comics-take.md | Added changeset entry documenting the new feature |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agree, modified.
That would leave us to handle all that characters that cannot be directly translated into a directory name. Also, most of the repls I would personally download would have the name "Hello world (edited)" so I don't think this is super important. Can always be added later without any problems.
I understand, but I'm hesitant about this. Adding it near the top / somewhere in the middle is going to be hard, adding it at the end is easy, but probably nobody would notice. Would leave this open and wait for user feedback.
Totally agree and implemented The only major thing left is detecting and using the svelte version parameter from the playground url. And more testing. Let me know what you think about the code. Also if you have a 3-5 more real playground urls to test this again, that would be great. |
|
I did a bit of cleanup in my playgrounds:
Nothing really special.
On top top, it's not that easy ? |
|
I just added a final change to support the If everybody agrees, this should be good to go now. |
jycouet
left a comment
There was a problem hiding this comment.
Looks great 🚀
You want to silently launch without docs? Or you want to add the new option directly?
BTW, how to run docs locally with new changes? 👀
Uupps, good catch. Is the description I added to detailed? That reminded me that we were considering adding that command to playground itself. Going to start a thread in discord in a second.
Don't! If you really want to here are the docs: https://github.com/sveltejs/svelte.dev/?tab=readme-ov-file#setup |
Co-authored-by: jyc.dev <jycouet@gmail.com>
|
Let's go! If you feel like adding this to the playground, feel free |


Closes #602
You can now run
pnpx https://pkg.pr.new/sveltejs/cli/sv@662 create --from-playground=https://svelte.dev/playground/hello-world. This is currently doing more or less the same the stuff theDownload Appbutton in the playground is doing. Apart from that, you can choose additional addons,tsvsjsand install deps. External dependencies are auto-detected and installed into thepackage.jsonTodos:
svelte-?version=parameter from the playground urldominikg: one thing to remember is that this is untrusted input basically, the playground could reference malicious packages, so installation with --ignore-scripts and making users aware that they have to check the content beforehand would be good.