antelope-cli 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/onboarding/brand.js
CHANGED
|
@@ -42,7 +42,7 @@ const updateConfigFile = () => {
|
|
|
42
42
|
colorTheme: 'theme-${brand.connectedBrandName}',
|
|
43
43
|
templateTheme: 'theme-template-${brand.connectedBrandName}',
|
|
44
44
|
title: '${brand.brandName}',
|
|
45
|
-
favicon: '${brand.
|
|
45
|
+
favicon: '${brand.favicon}',
|
|
46
46
|
affiliatesApiUrl: '',
|
|
47
47
|
FCMSenderId: '${brand.FCMSenderId}',
|
|
48
48
|
brandAssetsFolder: '${brand.connectedBrandName}',
|
package/onboarding/favicon.js
CHANGED
|
@@ -1,131 +1,18 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const brandModule = require('./brand.js');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fetch = require('node-fetch');
|
|
6
|
-
const unzipper = require('unzipper');
|
|
7
4
|
|
|
8
5
|
async function start(rl) {
|
|
9
6
|
try {
|
|
10
|
-
const brand = brandModule.getBrand();
|
|
11
|
-
const faviconDirLocation = `src/assets/img/favicon/${brand.connectedBrandName}`;
|
|
12
|
-
|
|
13
|
-
// Prompt user for the URL of the logo image
|
|
14
7
|
const imagePath = await promptUser('Please provide the url to your favicon image: ', rl);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log(chalk.inverse('Creating a favicon pack...'));
|
|
18
|
-
const response = await fetch('https://realfavicongenerator.net/api/favicon', {
|
|
19
|
-
method: 'POST',
|
|
20
|
-
headers: {
|
|
21
|
-
'Content-Type': 'application/json'
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify(getFaviconRequest(brand, imagePath))
|
|
24
|
-
});
|
|
25
|
-
const json = await response.json();
|
|
26
|
-
|
|
27
|
-
// Handle error responses
|
|
28
|
-
if (json.favicon_generation_result.result.error_message) {
|
|
29
|
-
console.error(`Error generating favicon images: ${json.favicon_generation_result.result.error_message}`);
|
|
30
|
-
return start(rl);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Download and extract the zip file to the favicon directory
|
|
34
|
-
await fs.promises.mkdir(faviconDirLocation, { recursive: true });
|
|
35
|
-
|
|
36
|
-
const zipUrl = json.favicon_generation_result.favicon.package_url;
|
|
37
|
-
const zipResponse = await fetch(zipUrl);
|
|
38
|
-
const zipBuffer = await zipResponse.buffer();
|
|
39
|
-
const zipContents = await unzipper.Open.buffer(zipBuffer);
|
|
40
|
-
await Promise.all(
|
|
41
|
-
zipContents.files.map(async (file) => {
|
|
42
|
-
const content = await file.buffer();
|
|
43
|
-
const dest = path.join(faviconDirLocation, file.path);
|
|
44
|
-
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
|
|
45
|
-
await fs.promises.writeFile(dest, content);
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
|
|
8
|
+
console.log(chalk.cyan(imagePath));
|
|
9
|
+
brandModule.updateBrand({favicon: imagePath})
|
|
49
10
|
console.log(chalk.cyan(`Favicon images generated successfully!`));
|
|
50
11
|
} catch (error) {
|
|
51
12
|
console.error(`Error generating favicon images: ${error}`);
|
|
52
13
|
}
|
|
53
14
|
}
|
|
54
15
|
|
|
55
|
-
/**
|
|
56
|
-
* Returns an object containing the necessary parameters for the RealFaviconGenerator API.
|
|
57
|
-
*/
|
|
58
|
-
function getFaviconRequest(brand, imagePath) {
|
|
59
|
-
return {
|
|
60
|
-
favicon_generation: {
|
|
61
|
-
api_key: '9123c4e1f216b0538089859917ff21b791a4c6db',
|
|
62
|
-
master_picture: {
|
|
63
|
-
type: 'url',
|
|
64
|
-
url: imagePath
|
|
65
|
-
},
|
|
66
|
-
favicon_design: {
|
|
67
|
-
ios: {
|
|
68
|
-
picture_aspect: 'no_change',
|
|
69
|
-
margin: '14%',
|
|
70
|
-
manifest: {
|
|
71
|
-
name: '',
|
|
72
|
-
short_name: '',
|
|
73
|
-
icons: [
|
|
74
|
-
{
|
|
75
|
-
src: '/apple-touch-icon-180x180.png',
|
|
76
|
-
sizes: '192x192',
|
|
77
|
-
type: 'image/png'
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
theme_color: '#ffffff',
|
|
81
|
-
background_color: '#ffffff',
|
|
82
|
-
display: 'standalone'
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
desktop_browser: {},
|
|
86
|
-
windows: {
|
|
87
|
-
picture_aspect: 'no_change',
|
|
88
|
-
background_color: brand.color || '#FFF',
|
|
89
|
-
assets: {
|
|
90
|
-
windows_80_ie10_tile: true,
|
|
91
|
-
windows_10_ie11_edge_tiles: {
|
|
92
|
-
small: true,
|
|
93
|
-
medium: true,
|
|
94
|
-
big: true,
|
|
95
|
-
rectangle: true
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
manifest: {
|
|
99
|
-
name: '',
|
|
100
|
-
short_name: '',
|
|
101
|
-
icons: [
|
|
102
|
-
{
|
|
103
|
-
src: '/mstile-150x150.png',
|
|
104
|
-
sizes: '150x150',
|
|
105
|
-
type: 'image/png'
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
theme_color: '#ffffff',
|
|
109
|
-
background_color: '#ffffff',
|
|
110
|
-
display: 'standalone'
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
safari_pinned_tab: {
|
|
114
|
-
picture_aspect: 'silhouette',
|
|
115
|
-
threshold: 20,
|
|
116
|
-
theme_color: brand.color || '#FFF'
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Prompts the user for input with the given message.
|
|
125
|
-
* @param {string} message The message to display to the user.
|
|
126
|
-
* @param {readline.Interface} rl The readline interface to use for user input.
|
|
127
|
-
* @returns {Promise<string>} A promise that resolves with the user's input.
|
|
128
|
-
*/
|
|
129
16
|
function promptUser(message, rl) {
|
|
130
17
|
return new Promise((resolve) => {
|
|
131
18
|
rl.question(message, (input) => {
|
|
@@ -23,7 +23,7 @@ function start(rl) {
|
|
|
23
23
|
// Append the new brand to the colors map
|
|
24
24
|
const newColorsMap = `$colors: (${colorsMap},\n '${connectedBrandName}': ${
|
|
25
25
|
hexColor ? '$' + connectedBrandName : defaultColor
|
|
26
|
-
}
|
|
26
|
+
})`;
|
|
27
27
|
|
|
28
28
|
// Replace the $colors map in the file with the new one
|
|
29
29
|
data = data.replace(colorsRegex, newColorsMap);
|