-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
New Route CLI command #277
Conversation
🦋 Changeset detectedLatest commit: 1044e2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
Hey @mikenikles, where should we add the annotation to https://github.com/sveltejs/language-tools/tree/master/packages/svelte-vscode/src/sveltekit/generateFiles/templates? |
name: "types", | ||
message: "What types of page do you want to create?", | ||
choices: [ | ||
"+page.svelte", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should read the directory first and add an annotation to files in case they already exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes let's do that. Even better, if we can disable the choices for files that already exist, let's do that too. Lastly, what happens if we can't disable choices and someone selects a file that already exists?
I'd argue we log a warning and ignore that file, keeping the existing one. What do you think?
|
||
module.exports = command; | ||
|
||
function deleteAll( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this function signature is good practise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen del
instead.
name: "types", | ||
message: "What types of page do you want to create?", | ||
choices: [ | ||
"+page.svelte", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes let's do that. Even better, if we can disable the choices for files that already exist, let's do that too. Lastly, what happens if we can't disable choices and someone selects a file that already exists?
I'd argue we log a warning and ignore that file, keeping the existing one. What do you think?
|
||
module.exports = command; | ||
|
||
function deleteAll( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen del
instead.
name: "types", | ||
message: "What types of page do you want to create?", | ||
choices: [ | ||
"+page.svelte", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above the first element of this choices
array is a good place to link to Svelte's language tools repo and add a thank you note.
const target = `src/routes/${directoryName}/${type}`; | ||
const spinner = print.spin(`Creating file "${target}"...`); | ||
|
||
if (existingFiles?.includes(type)) { | ||
spinner.fail(`File "${target}" already exists, skipping...`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should hopefully be unreachable due to the above check, but just in case 😅
closes #275
closes #276