-
Notifications
You must be signed in to change notification settings - Fork 278
Conversation
It's now an npm project with those advantages: - introduces a build step to allow for using modern code syntax that will be automatically transpiled to support older browsers. - includes commit hook to automatically lint the code on committing - enables (selectively) type checking to catch issues early during development - allows to clean up the code and separate into smaller chunks that will be combined into a single bundle - releases will be versioned so that it's possible to refer to concrete versions and possibly include changelogs. - versioning also allows to have non-random URLs for included scripts so that those can be cached by the browser The end-user code is now generated in dist/ so that is what user has to deploy rather than all files in the repo.
@resoai @akloeckner @cgarwood It's a pretty serious change. For those who are involved in the development or plan to be, I encourage you to try it and report issues, annoyances, or anything that might be wrong with this approach. We go forward with it only when everyone is happy. :) BTW. The approach with A proper solution would be to make the config file be an angular service that could be loaded asynchronously but that would be a breaking change that would require all user configs to be adapted. So I don't really see this happening anytime soon. Also, I did as minimal as possible changes to existing scripts. If this gets accepted and merged we can do further things with the scripts like:
|
Wow. Looks like a great deal of changes. I'll have to deep dive into npm and test with some of my devices... I'll report back! |
So, I checkout out your branch and copied my config files to the dist folder. I receive the "invalid config" error... Is stuff like that not allowed anymore?
|
@akloeckner it should still work. You should check the browser console for the exact error. When I've tried this code here I got an error about undefined EDIT: BTW. Is there a reason you won't just put that code in the main config and avoid extra request? |
Ok. I replaced the BTW: Yes. I just prefer my setup to be tidy. So, I moved all helper functions outside of config.js. I just couldn't find my way around in that humongous file anymore... |
Right. Due to this Adding I can't see an immediate clean solution for that but I can look more into it later if we are not fine with this being a breaking change. |
I could get rid of
|
Such a simple check could probably easily be replaced with something like |
I don't understand the process of bundling that you introduced. But would it help for this issue to have only one bundle? And what changes would be required on the user side? If the required changes are easily explainable, I'd say we do the restructure properly in the first place and put a migration section into the wiki. |
There are two bundles because the config needs to be loaded between those two. Those two bundles are:
Config needs to be loaded between those two as it needs access to constants like Making one bundle could work if Config would utilize angular.module('App').provider('configProvider', function () { this.$get = function(Constants, Noty) { ... } }) I believe that should work. I haven't actually tried it yet. |
👍 Have you tried to make app initializing asynchronous? I'm not sure what was the original problem, probably was too lazy to make it. It should help to those who want to make module configs. Though, without rebuilding the app. May be adding global |
Your comment reminded me that there is a way to initialize angularjs manually. It actually works quite well with just a single bundle now. Thanks! :) |
I've reverted some unnecessary style changes to make diffs easier to review. |
In the latest commit, I have fixed issues with assets referenced from CSS not being included in the dist/ folder which meant that those wouldn't be available after deploying. Also made production bundles have hashes in the filename. That means that on every change of some code, the hash will change which should eliminate issues with caching and not seeing the latest changes after updating to the new version. Also we don't have to bust cache on every request which allows the browser to cache those and load TB faster. |
I replaced the |
@resoai let's just merge it and solve all problems afterwards :) |
That is exactly our way! Since I still have absolutely no way to test it, I will leave it up to @rchl and @akloeckner to decide when it is time to merge. |
@akloeckner Actually with my latest changes all of |
Thanks! That seems to work now! (With original config, using When trying to start the development environment (impressive, I must say), I noticed a few thing to probably add to the
I have one open question still: In my "production" environment I use multiple branches currently, which I merge together: As to the huge amount of changes, I'll have to trust you @rchl , since I have no idea of the magic you have done! So, apart from these documentation changes, I suggest to merge the PR. Looks promising! |
Another thought I just had: I have tileboard as a sub-repo in my HA config repo. So, instead of copying files from So, it might help to put a minimal index.html in the tileboard root explaining that the app has moved. It would point people with those kinds of setup in the right direction. |
Good foodback. Will try to address it later. As for your development situation with different branches I'd have to understand that better. Would you be using |
As to different branches, i usually do something like this:
This leaves me with a working directory including all features I need/want. Will those merges work with Probably the branching thing is a specialty of mine. But others might have simple modifications/fixes they don't bother to put in a PR. Such as fixing the issue here #425 . So, suppose the user has fixed that one line from #425 locally, what would be the steps to bring this change into |
I've added an
Changed
Added a note about that. Unfortunately, that won't work for history API right now (home-assistant/core#39727).
Added a note on setting that. |
My HA is runing for days. So this is probably not my very issue. (Still good, it's identified!) My debugging pointed me to some tooltip code. ( EDIT: From what I could
Could you commit that change , so I can test on my end again? EDIT: If it's not fixed, I'll continue debugging.
Well, actually, for me that does work, as I noted in #386. However, good it's in the docs now. I'd still suggest to also give a hint to the HA setting, because that's what I had to do to be able to authenticate with HA, even. |
Sorry... I didn't see that commit. Tested and all seems to be fine now! Thanks! EDIT: Tested in dev server. Very neat. But had to rebuild the |
Thanks for the remainder. Forgot about it. Now it's added.
Yes, every change in the scripts or dependencies requires rebuild. I think this should be solved by forcing build on every commit but since we've decided to investigate not committing the |
Thanks! Sorry for being pedantic: Configure http:
cors_allowed_origins:
- http://<your-server>:8080
Which takes 2m18s on my pi! 30s for the dev server. Maybe we can speed this up once we have the system in place. In my opinion that's anything but "iterate quickly"... Also, it seems to write lots of files. Not sure, what it will do to my SD card wear... |
Personally, I develop on my main Desktop and have a script that just pushes built files to PI. With a dev server I don't even have to push on each change as I can test locally. You could speed up production build by removing But yeah, it can be a bit heavy. There are pros and cons to everything... |
I should start that, too, maybe... :-) I'll try your options and see, what it does. EDIT: 48s without terser and without sourcemaps (js and css). I couldn't find treeshake... Still not great, compared to simply reloading the page. ;-) But minifying is a good thing. And you listed a few strong advantages in the first post. So, let's not be stopped by that. |
I now also got around to testing this with my old iPad, iOS 9.35. I had to create a long-lived token for it (see home-assistant/frontend#5376). However, the TileBoard does not load. It is stuck on the background color. Usually that is an indicator for some broken JS code, hindering the app to initialize. TileBoard works as usual in the old structure. |
Is it possible to get access to the console and see what it errors on exactly? |
I'm not sure, how to access the console. The internet seems to suggest that I need Safari on my Laptop and some USB cable. It might take some time to get that up and running... Looking at this issue, however, the |
Hmm... as it seems, I need Safari for this to work. Unfortunately, Safari is said to be only available on Mac. But I have no Mac. So, I guess I'm stuck... |
I Will take care of the |
OK, pushed a change that actually transpiles the code for older browsers. Not sure if it will handle your old iOS by default. If not then we'll have to change config to target older browsers. |
OK, some bigger changes in the latest commits:
|
I checked my old iOS. It works ( Since everything works now on my end, I'll be fine to merge as soon as you (and @resoai) are happy with the workflows! |
I'm happy with the changes myself too so will merge later in the day. |
It's now an npm project with those advantages:
that will be automatically transpiled to support older browsers.
be combined into a single bundle
versions and possibly include changelogs.
so that those can be cached by the browser
The end-user code is now generated in dist/ so that is what user has todeploy rather than all files in the repo.