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

[cli] Clean templates, fix a bunch of issues in generated apps #4040

Merged
merged 15 commits into from
Sep 12, 2024

Conversation

bharatkashyap
Copy link
Member

@bharatkashyap bharatkashyap commented Sep 4, 2024

@bharatkashyap bharatkashyap added the create-toolpad-app Issues related to the `create-toolpad-app` CLI tool label Sep 4, 2024
@bharatkashyap bharatkashyap requested review from a team and Janpot and removed request for a team September 4, 2024 11:21
@Janpot Janpot requested a review from a team September 4, 2024 14:05
@bharatkashyap bharatkashyap requested review from a team and apedroferreira and removed request for a team September 5, 2024 06:24
@@ -40,7 +39,7 @@ const NAVIGATION: Navigation = [
];

const BRANDING = {
title: 'My Toolpad Core App',
title: 'My Toolpad Core Next.js Pages App',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes the app easier to identify while testing/running - in all likelihood a person running this example is going to change these anyway regardless of whatever the default text is

Copy link
Member

@Janpot Janpot Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes the app easier to identify while testing/running

Sure, but that's not a problem our users would have, they know what they picked. We can't do it for all permutations, so I propose we do it for none.

e.g. why not

title: 'My Toolpad Core Next.js Pages App with Google+Github auth and joy theme',

🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose we only do it for things that aren't immediately visible on the app (Auth providers/Theme/Branding are all visible and obvious). Currently it would only be the type of router; if we introduce something that fits this criteria in the future, we could do it for that as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous title was already looking a bit too long for the current layout, I would also prefer to use shorter titles...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the longer titles

if (missingVars.length > 0) {
const baseMessage = 'Authentication is configured but the following environment variables are missing:';

if (process.env.NODE_ENV === 'production') {
Copy link
Member

@Janpot Janpot Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid different behavior in dev vs. prod. If it crashes in prod it must crash in dev. Let's just warn then.

Suggestion:

function warnOnMissing(var: string, provider: string, name: string) {
  if (!var) {
    console.warn(`${provider} provider: environment variable "${name}" missing`);
  }
}

warnOnMissing(process.env.GOOGLE_CLIENT_ID, 'Google', 'GOOGLE_CLIENT_ID')
warnOnMissing(process.env.GOOGLE_CLIENT_SECRET, 'Google', 'GOOGLE_CLIENT_SECRET')
// ...

(Avoid dynamically accessing process.env[name], some runtimes want to statically analyze)

@@ -0,0 +1,46 @@
import { SupportedRouter } from '../types';

const indexPage = (authEnabled: boolean, routerType: SupportedRouter) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just give all templates the same options as an object? That way we only have to create that once and can pass it to each template.

@@ -27,6 +27,7 @@ const NAVIGATION: Navigation = [
title: 'Main items',
},
{
segment: '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default segment is already '' so we don't need to include it.

@bharatkashyap bharatkashyap merged commit 73cabd2 into mui:master Sep 12, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-toolpad-app Issues related to the `create-toolpad-app` CLI tool
Projects
None yet
3 participants