Automatically find JS files and have them right order to load
Summary:
Automate the discovery and inclusion of Javascript files in the correct load order. The primary focus of this blueprint will be on Javascript files, as scss and html inclusion workflow is slightly different.
Motivation:
Currently in Horizon, static resources like Javascripts are manually listed in .html or .py files. Whenever a Javascript file is created, renamed, moved or removed, a developer has to do all the updating manually; a painful and error-prone process.
Although AngularJS module architecture makes it much easier to defined and resolved sources, ordering of Javascripts is still significant (as shown in the HTML scripts inclusion). With a standard naming convention applied across Horizon, it should be possible to load static resources in the right order.
Description:
Assume we have the following file structure:
/feature
|- feature.
|- feature.
|- feature.html
|- feature.module.js
|- feature.
|- feature.scss
|- /subfeature
|- subfeature.
|- subfeature.
We can iterate through this tree and extract files based on their extensions, while preserving the order. This gives us the ability to then populate the files correctly based on hierarchy and extensions.
Jasmine.py
----------
sources = [
/feature.module.js
/feature.
/feature/
]
specs = [
/feature.
/feature.
/feature/
]
base.html
---------
<script src="/feature.
<script src="/feature.
<script src="/feature/
UX:
N/A
Outside Dependencies:
N/A
Doc Impact:
May need to update the Angular part to recommend the file structure.
Blueprint information
- Status:
- Complete
- Approver:
- David Lyle
- Priority:
- Medium
- Drafter:
- Shaoquan Chen
- Direction:
- Approved
- Assignee:
- Shaoquan Chen
- Definition:
- Approved
- Series goal:
- Accepted for liberty
- Implementation:
- Implemented
- Milestone target:
- 8.0.0
- Started by
- Thai Tran
- Completed by
- David Lyle
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
WIP - Utils for auto-file-discovery
Gerrit topic: https:/
Addressed by: https:/
auto-
Addressed by: https:/
Rename files to enable auto-file-discovery
Addressed by: https:/
Apply auto-file-discovery to _10_project
Addressed by: https:/
WIP - injectjs - a Django command to inject JS
Addressed by: https:/
WIP Applying auto-file-discovery
Gerrit topic: https:/
Gerrit topic: https:/
Addressed by: https:/
Appling auto-file-discovery to framework part
Gerrit topic: https:/
Addressed by: https:/
[WIP] Adding documentation for auto-file-discovery
Gerrit topic: https:/
Addressed by: https:/
[WIP] Unit tests for auto file discovery