-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(cli): add code template for default home page controller #1763
Conversation
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.
Yay for these additions and especially the test setup cleanup. Much simpler / easier flow. Just some minor comments.
'src/controllers/home-page.controller.ts', | ||
/homePage\(\)/, | ||
); | ||
assert.fileContent( |
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.
Can we also assert ./test-helper.ts
file
Client, | ||
} from '@loopback/testlab'; | ||
|
||
export interface AppWithClient { |
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.
Can we move this to be below the function?
|
||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
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.
Update to the newest design so we have a favicon (otherwise loading this throws a console error in the browser (if someone was to check)).
7f28376
to
ca646af
Compare
@virkt25 Updated. PTAL. |
Once this lands -- we will need a follow up PR to add this homepage to our existing examples under |
<body> | ||
<div class="info"> | ||
<h1><%= project.name %></h1> | ||
<p>Version <%= project.version || '1.0.0' %></p> |
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.
IIUC, we are hard-coding project name and version to index.html
at the time when the HomePageController is scaffolded. Subsequent updates to name
and version
in project's package.json
files are not going to be picked up, the home page will display version 1.0.0
forever. I find that rather confusing!
@raymondfeng @virkt25 Is this intentional? I thought our intention was to render the home pages from an EJS template at runtime, that's what I see in loopbackio/loopback4-example-shopping#16.
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 was intentional as the first step:
We wanted to keep the HomePageController implementation simple and easy to understand.
- The generated
public/index.html
is a plain html instead of a template. We set the name/version during code gen but it's up to developers to maintain it - There is no need to use a template engine to render the view
That's been said, I'm fine to upgrade it to an EJS view once #1764 is landed.
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.
Can we remove the Version from the static page then? Application name is unlikely to change, but the version is going to change often.
This PR adds code template for a default home page controller to be generated as part of
lb4 app
.Fixes #1745
Checklist
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated