-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
Documented new frontend development script #2483
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,15 @@ git remote add upstream https://github.com/home-assistant/frontend.git | |
|
||
You will need to have an instance of Home Assistant set up. See our guide on [setting up a development environment](/development_environment.mdx). | ||
|
||
Next step is to configure Home Assistant to use the development mode for the frontend. Do this by updating the frontend config in your `configuration.yaml` and set the path to the frontend repository that you cloned in the last step: | ||
There are two ways to test the frontend. You either configure Home Assistant to use another frontend. Or you configure the frontend to connect to an existing Home Assistant instance. The first option is how it will work in production. The second allows running a development frontend against an existing Home Assistant with minimal interference. The downside is that not everything can be tested this way. For example, the login page will always be the one built-in into your Home Assistant. | ||
|
||
import Tabs from '@theme/Tabs' | ||
import TabItem from '@theme/TabItem' | ||
|
||
<Tabs> | ||
|
||
<TabItem value="frontend inside Home Assistant"> | ||
To configure Home Assistant to use the development mode for the frontend, update the frontend config in your `configuration.yaml` and set the path to the frontend repository that you cloned in the last step: | ||
|
||
```yaml | ||
frontend: | ||
|
@@ -51,6 +59,40 @@ frontend: | |
:::caution | ||
The change to `.devcontainer/devcontainer.json` should be excluded from any PR as it contains your local path to the `frontend` repository. Since the the settings in `.devcontainer/devcontainer.json` are only processed during the container rebuild, you can safely roll back the change after the rebuild has completed. | ||
::: | ||
</TabItem> | ||
|
||
<TabItem value="frontend outside Home Assistant"> | ||
|
||
If you want to connect your development frontend to an existing home assistant instance without replacing the UI completely, you will need to add the url under which your development frontend is hosted in `configuration.yaml` of the home assistant it will be connecting to. | ||
|
||
```yaml | ||
http: | ||
cors_allowed_origins: | ||
- http://localhost:8124 | ||
``` | ||
|
||
After you've setup your frontend development environment so that you can run the `script/develop` script as described in section [Development](#development). You can use the following command as a replacement to develop and run the frontend on http://localhost:8124 and it will connect to the Home Assistant running on http://localhost:8123. Note that if you are running this command from a devcontainer, the url should be accessed from the container host. | ||
|
||
```shell | ||
script/develop_and_serve | ||
``` | ||
|
||
You can change the Home Assistant url the frontend connects to by passing the -c option. This will also work for existing production core instances. It does not need to be a development version hosted locally. However, if you change the value for this option you will need to logout from your development frontend before it actually switches to the new value. For example: | ||
|
||
```shell | ||
script/develop_and_serve -c https://myhost.duckdns.org:8123 | ||
``` | ||
|
||
You can change the port the frontend is served on by passing the -p option. Note that if you are running from a devcontainer, you will need to setup | ||
port forwarding as well if you want to access it from the container host. For example: | ||
|
||
```shell | ||
script/develop_and_serve -p 8654 | ||
``` | ||
Comment on lines
+74
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Documentation refers to a non-existent script The documentation in
🔗 Analysis chainVerify the development server implementation Let's verify how the development server is actually implemented to ensure the documentation matches reality. Let's gather more information by checking the actual script content and related files. Let's check the docusaurus configuration and look for any development-related scripts in the root directory, as the script might be in a different location. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the actual implementation of the development server
# Look for development server related files and scripts
echo "Checking for development server scripts..."
fd -t f "develop.*serve|dev-server"
# Check package.json for development scripts
echo "Checking package.json for development scripts..."
if [ -f "package.json" ]; then
jq '.scripts | with_entries(select(.key | contains("develop")))' package.json
fi
# Look for webpack configurations
echo "Checking for webpack configurations..."
fd -t f "webpack.*config"
Length of output: 506 Script: #!/bin/bash
# Check the content of the script/develop_and_serve
echo "Checking script/develop_and_serve content..."
cat script/develop_and_serve
# Look for any related development scripts
echo -e "\nChecking other development scripts..."
fd -t f "^develop" script/
# Check if there are any related configuration files
echo -e "\nChecking for configuration files..."
fd -t f "config|\.rc" -d 1
# Check docusaurus configuration since we saw docusaurus in package.json
echo -e "\nChecking docusaurus configuration..."
fd -t f "docusaurus\.config\.js"
Length of output: 588 Script: #!/bin/bash
# Check docusaurus configuration content
echo "Checking docusaurus.config.js content..."
cat docusaurus.config.js
# Look for development scripts in the root directory
echo -e "\nChecking for development scripts in root..."
fd -t f "develop.*serve|develop" .
# Check if there are any npm/yarn scripts in package.json
echo -e "\nChecking complete package.json..."
cat package.json
Length of output: 6257 🧰 Tools🪛 LanguageTool[style] ~74-~74: In American English, “you” and “have” do not usually form a contraction unless they’re followed by a past participle. (IVE_I_HAVE_AMERICAN_STYLE) [uncategorized] ~74-~74: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE) [misspelling] ~80-~80: The verb or noun ‘bypass’ is spelled as one word. (BY_PASS) [uncategorized] ~80-~80: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA) [misspelling] ~80-~80: Did you mean the verb “log out” instead of the noun ‘logout’? (LOG_IN) [grammar] ~86-~86: The word “setup” is a noun. The verb is spelled with a space. (NOUN_VERB_CONFUSION) 🪛 Markdownlint (0.37.0)74-74: null (MD034, no-bare-urls) 74-74: null (MD034, no-bare-urls) |
||
|
||
</TabItem> | ||
|
||
</Tabs> | ||
|
||
### Installing Node.js | ||
|
||
|
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.
💡 Codebase verification
Documentation refers to a non-existent script
The documentation refers to a
script/develop_and_serve
script and its-c
option, but this script does not exist in the codebase. The development server is actually managed through npm scripts defined in package.json, which uses Docusaurus commands and doesn't support the documented URL configuration option.docs/frontend/development.md
to reflect the correct development server setup usingnpm start
or the appropriate Docusaurus commands-c
option for changing the Home Assistant URL🔗 Analysis chain
Verify documentation against the frontend implementation
Let's verify that the documented command and options match the implementation in PR #23062.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 272
Script:
Length of output: 299
Script:
Length of output: 1140
🧰 Tools
🪛 LanguageTool
[misspelling] ~67-~67: The verb or noun ‘bypass’ is spelled as one word.
Context: ... Assistant url the frontend connects to by passing the -c option. This will also work for ...
(BY_PASS)
[misspelling] ~67-~67: Did you mean the verb “log out” instead of the noun ‘logout’?
Context: ... value for this option you will need to logout from your development frontend before i...
(LOG_IN)