-
Notifications
You must be signed in to change notification settings - Fork 27
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
🐛✨ [Frontend] Automatically pull latest frontend version (nocache) #7054
Open
odeimaiz
wants to merge
12
commits into
ITISFoundation:master
Choose a base branch
from
odeimaiz:feature/force-no-cache
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0d73576
pass argument to sript VCS_REF_CLIENT
odeimaiz 581c377
add_no_cache_param
odeimaiz 9412779
minor
odeimaiz 0240d19
minor
odeimaiz 9bcee2b
minor
odeimaiz b01806b
udpate also boojt.js
odeimaiz 0f0ce27
addNoCacheParam to true
odeimaiz 8fa8076
cleanup
odeimaiz 2c19c45
minor
odeimaiz e6348e2
last touches
odeimaiz c3ec6ea
minor
odeimaiz 824982a
Merge branch 'master' into feature/force-no-cache
odeimaiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,82 @@ | ||
import os | ||
import json | ||
|
||
import os | ||
import random | ||
|
||
output_folders = [ | ||
"source-output", # dev output | ||
"source-output", # dev output | ||
"build-output", # default production output | ||
"build-client" # I believe we create the production outputs here | ||
"build-client", # I believe we create the production outputs here | ||
] | ||
|
||
|
||
def read_json_file(filename): | ||
def _read_json_file(filename): | ||
dirname = os.path.dirname(__file__) | ||
meta_filename = os.path.join(dirname, filename) | ||
with open(meta_filename, "r") as file: | ||
with open(meta_filename) as file: | ||
metadata = json.load(file) | ||
return metadata["applications"] | ||
|
||
|
||
def update_apps_metadata(): | ||
dirname = os.path.dirname(__file__) | ||
applications = read_json_file("apps_metadata.json") | ||
applications = _read_json_file("apps_metadata.json") | ||
for i in applications: | ||
application = i.get("application") | ||
replacements = i.get("replacements") | ||
for output_folder in output_folders: | ||
filename = os.path.join(dirname, '..', output_folder, application, "index.html") | ||
filename = os.path.join( | ||
dirname, "..", output_folder, application, "index.html" | ||
) | ||
if not os.path.isfile(filename): | ||
continue | ||
with open(filename, "r") as file: | ||
with open(filename) as file: | ||
data = file.read() | ||
replacements = i.get("replacements") | ||
for key in replacements: | ||
replace_text = replacements[key] | ||
data = data.replace("${"+key+"}", replace_text) | ||
with open(filename, "w") as file: | ||
data = data.replace("${" + key + "}", replace_text) | ||
with open(filename, "w") as file: | ||
print(f"Updating app metadata: {filename}") | ||
file.write(data) | ||
|
||
|
||
def _get_output_file_paths(filename): | ||
index_file_paths = [] | ||
dirname = os.path.dirname(__file__) | ||
applications = _read_json_file("apps_metadata.json") | ||
for i in applications: | ||
application = i.get("application") | ||
for output_folder in output_folders: | ||
index_file_paths.append( | ||
os.path.join(dirname, "..", output_folder, application, filename) | ||
) | ||
return index_file_paths | ||
|
||
|
||
def add_no_cache_param(vcs_ref_client): | ||
index_file_paths = _get_output_file_paths("index.html") | ||
for index_file_path in index_file_paths: | ||
if not os.path.isfile(index_file_path): | ||
continue | ||
with open(index_file_path) as index_file: | ||
data = index_file.read() | ||
data = data.replace("${boot_params}", "nocache=" + vcs_ref_client) | ||
with open(index_file_path, "w") as file: | ||
print(f"Updating vcs_ref_client: {index_file_path}") | ||
file.write(data) | ||
|
||
boot_file_paths = _get_output_file_paths("boot.js") | ||
for boot_file_path in boot_file_paths: | ||
if not os.path.isfile(boot_file_path): | ||
continue | ||
with open(boot_file_path) as boot_file: | ||
data = boot_file.read() | ||
data = data.replace("addNoCacheParam : false", "addNoCacheParam : true") | ||
with open(boot_file_path, "w") as file: | ||
print(f"Updating URL_PARAMETERS: {boot_file_path}") | ||
file.write(data) | ||
|
||
|
||
if __name__ == "__main__": | ||
update_apps_metadata() | ||
vcs_ref_client = os.getenv("VCS_REF_CLIENT", str(random.random())) | ||
add_no_cache_param(vcs_ref_client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TIP: if you would instead use
pathlib.Path
, your code would become more compactand the same with all the operations to compose paths.