Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
4d052764
Commit
4d052764
authored
Sep 05, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base script for bungle generation
parent
e9a45f37
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
0 deletions
+138
-0
.gitignore
deploy/tools/favicon-generator/.gitignore
+3
-0
config.template.json
deploy/tools/favicon-generator/config.template.json
+28
-0
script.sh
deploy/tools/favicon-generator/script.sh
+107
-0
No files found.
deploy/tools/favicon-generator/.gitignore
0 → 100644
View file @
4d052764
/output
config.json
favicon_package**
\ No newline at end of file
deploy/tools/favicon-generator/config.template.json
0 → 100644
View file @
4d052764
{
"favicon_generation"
:
{
"api_key"
:
"<api_key>"
,
"master_picture"
:
{
"type"
:
"url"
,
"url"
:
"<master_url>"
},
"files_location"
:
{
"type"
:
"path"
,
"path"
:
"/favicons"
},
"favicon_design"
:
{
"desktop_browser"
:
{}
},
"settings"
:
{
"compression"
:
"3"
,
"scaling_algorithm"
:
"Mitchell"
,
"error_on_image_too_small"
:
true
,
"readme_file"
:
false
,
"html_code_file"
:
false
,
"use_path_as_is"
:
false
},
"versioning"
:
{
"param_name"
:
"ver"
,
"param_value"
:
"15Zd8"
}
}
}
\ No newline at end of file
deploy/tools/favicon-generator/script.sh
0 → 100755
View file @
4d052764
#!/bin/bash
echo
"🌀 Generating favicons bundle..."
echo
# Check if MASTER_URL is provided
if
[
-z
"
$MASTER_URL
"
]
;
then
echo
"🛑 Error: MASTER_URL variable is not provided."
exit
1
fi
# Check if API_KEY is provided
if
[
-z
"
$API_KEY
"
]
;
then
echo
"Error: API_KEY variable is not provided."
exit
1
fi
# Mask the API_KEY to display only the first 4 characters
API_KEY_MASKED
=
"
${
API_KEY
:0:8
}
***"
echo
"🆗 The following variables are provided:"
echo
" MASTER_URL:
$MASTER_URL
"
echo
" API_KEY:
$API_KEY_MASKED
"
echo
# RealFaviconGenerator API endpoint URL
API_URL
=
"https://realfavicongenerator.net/api/favicon"
# Target folder for the downloaded assets
TARGET_FOLDER
=
"./output"
# Path to the config JSON template file
CONFIG_TEMPLATE_FILE
=
"config.template.json"
# Path to the generated config JSON file
CONFIG_FILE
=
"config.json"
# Replace <api_key> and <master_url> placeholders in the JSON template file
API_KEY_VALUE
=
"
$API_KEY
"
sed
-e
"s|<api_key>|
$API_KEY_VALUE
|"
-e
"s|<master_url>|
$MASTER_URL
|"
"
$CONFIG_TEMPLATE_FILE
"
>
"
$CONFIG_FILE
"
# Make the API POST request with JSON data from the config file
echo
"⏳ Making request to API..."
API_RESPONSE
=
$(
curl
-s
-X
POST
-H
"Content-Type: application/json"
-d
@
"
$CONFIG_FILE
"
"
$API_URL
"
)
# Check if the API response is valid JSON and contains success status
if
!
jq
-e
'.favicon_generation_result.result.status == "success"'
<<<
"
$API_RESPONSE
"
>
/dev/null
;
then
echo
"🛑 Error: API response does not contain the expected structure or has an error status."
exit
1
fi
echo
"🆗 API responded with success status."
# Create the response.json file with the API response
echo
"
$API_RESPONSE
"
>
response.json
# Parse the JSON response to extract the file URL and remove backslashes
FILE_URL
=
$(
echo
"
$API_RESPONSE
"
| jq
-r
'.favicon_generation_result.favicon.package_url'
|
tr
-d
'\\'
)
# Check if FILE_URL is empty
if
[
-z
"
$FILE_URL
"
]
;
then
echo
"🛑 File URL not found in JSON response."
exit
1
fi
echo
"🆗 Found following file URL in the response:
$FILE_URL
"
echo
# Generate a filename based on the URL
FILE_NAME
=
$(
basename
"
$FILE_URL
"
)
# Check if the target folder exists and clear its contents if it does
if
[
-d
"
$TARGET_FOLDER
"
]
;
then
rm
-r
"
$TARGET_FOLDER
"
/
*
else
mkdir
-p
"
$TARGET_FOLDER
"
fi
# Download the file
echo
"⏳ Trying to download the file..."
curl
-s
-L
"
$FILE_URL
"
-o
"
$FILE_NAME
"
# Check if the download was successful
if
[
$?
-eq
0
]
;
then
echo
"🆗 File downloaded successfully."
echo
else
echo
"🛑 Error: Failed to download the file."
exit
1
fi
# Unzip the downloaded file to the target folder
echo
"⏳ Unzipping the file..."
unzip
-q
"
$FILE_NAME
"
-d
"
$TARGET_FOLDER
"
# Check if the unzip operation was successful
if
[
$?
-eq
0
]
;
then
echo
"🆗 File unzipped successfully."
echo
else
echo
"🛑 Failed to unzip the file."
exit
1
fi
# Clean up - remove the JSON response file and temporary JSON config file
rm
response.json
"
$CONFIG_FILE
"
echo
"✅ Done."
echo
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment