Skip to content
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

Merged
merged 9 commits into from
Nov 13, 2022
Merged

New Route CLI command #277

merged 9 commits into from
Nov 13, 2022

Conversation

Cahllagerfeld
Copy link
Member

@Cahllagerfeld Cahllagerfeld commented Nov 10, 2022

closes #275
closes #276

@changeset-bot
Copy link

changeset-bot bot commented Nov 10, 2022

🦋 Changeset detected

Latest commit: 1044e2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@webstone/cli Minor
@webstone/core Patch

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

@Cahllagerfeld
Copy link
Member Author

@Cahllagerfeld Cahllagerfeld changed the title Extend Creation of new Routes Extend Creation of new page Nov 10, 2022
name: "types",
message: "What types of page do you want to create?",
choices: [
"+page.svelte",
Copy link
Member Author

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?

Copy link
Collaborator

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(
Copy link
Member Author

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

Copy link
Collaborator

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.

@Cahllagerfeld Cahllagerfeld changed the title Extend Creation of new page New Route CLI command Nov 11, 2022
name: "types",
message: "What types of page do you want to create?",
choices: [
"+page.svelte",
Copy link
Collaborator

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(
Copy link
Collaborator

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",
Copy link
Collaborator

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...`);
Copy link
Member Author

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 😅

@mikenikles mikenikles marked this pull request as ready for review November 13, 2022 17:26
@mikenikles mikenikles merged commit 369bc5b into main Nov 13, 2022
@mikenikles mikenikles deleted the cahllagerfeld/add-options-when-275 branch November 13, 2022 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to create new layouts Add options when creating a new page
2 participants