antelope-cli 1.0.0
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/index.js +7 -0
- package/onboarding/brand.js +19 -0
- package/onboarding/createConfig.js +72 -0
- package/onboarding/favicon.js +138 -0
- package/onboarding/index.js +62 -0
- package/onboarding/logo.js +41 -0
- package/onboarding/themes.js +92 -0
- package/onboarding/translations.js +43 -0
- package/onboarding/variablesColors.js +58 -0
- package/package.json +26 -0
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
let brand = {
|
|
2
|
+
brandName: '',
|
|
3
|
+
kebabCaseName: '',
|
|
4
|
+
connectedBrandName: '',
|
|
5
|
+
color: '',
|
|
6
|
+
languages: null,
|
|
7
|
+
type: '',
|
|
8
|
+
FCMSenderId: ''
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function updateBrand(updatedBrand) {
|
|
12
|
+
brand = { ...brand, ...updatedBrand };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getBrand() {
|
|
16
|
+
return brand;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = { updateBrand, getBrand };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const brandModule = require('./brand.js');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const configsFilePath = '../../src/configs/configs.ts';
|
|
6
|
+
|
|
7
|
+
async function start(rl) {
|
|
8
|
+
try {
|
|
9
|
+
const configFile = path.join(__dirname, configsFilePath);
|
|
10
|
+
// Get User FCMSenderId and type
|
|
11
|
+
let { FCMSenderId, type } = await promptForValues(rl);
|
|
12
|
+
// Making sure the type is all caps
|
|
13
|
+
type = type.toUpperCase();
|
|
14
|
+
// Update brand state
|
|
15
|
+
brandModule.updateBrand({ FCMSenderId, type });
|
|
16
|
+
// Generate new config with new values
|
|
17
|
+
const newConfigContent = updateConfigFile();
|
|
18
|
+
// Write to file
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
fs.writeFile(configFile, newConfigContent, 'utf8', (error) => {
|
|
21
|
+
if (error) {
|
|
22
|
+
reject(error);
|
|
23
|
+
} else {
|
|
24
|
+
console.log(chalk.cyan('configs.ts file updated successfully!'));
|
|
25
|
+
resolve(null);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(e);
|
|
31
|
+
return start(rl);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const updateConfigFile = () => {
|
|
36
|
+
const brand = brandModule.getBrand();
|
|
37
|
+
return `export const configs: WebCrmConfig = {
|
|
38
|
+
baseUrl: 'https://dev-apicrm.antelopesystem.com/SignalsCRM/',
|
|
39
|
+
appId: 0,
|
|
40
|
+
type: '${brand.type}',
|
|
41
|
+
defaultLanguage: 'en',
|
|
42
|
+
gaTrackingID: 'UA-70456753-2',
|
|
43
|
+
colorTheme: 'theme-${brand.connectedBrandName}',
|
|
44
|
+
templateTheme: 'theme-template-${brand.connectedBrandName}',
|
|
45
|
+
title: '${brand.brandName}',
|
|
46
|
+
favicon: '${brand.connectedBrandName}',
|
|
47
|
+
affiliatesApiUrl: '',
|
|
48
|
+
FCMSenderId: '${brand.FCMSenderId}',
|
|
49
|
+
brandAssetsFolder: '${brand.connectedBrandName}',
|
|
50
|
+
};`;
|
|
51
|
+
};
|
|
52
|
+
const promptForValues = (rl) => {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
try {
|
|
55
|
+
rl.question(
|
|
56
|
+
'Enter the FCMSenderId value (see https://xsites.atlassian.net/wiki/spaces/IKB/pages/777650347/Onboarding+Branding+Manual+for+devs#Firebase): ',
|
|
57
|
+
(FCMSenderId) => {
|
|
58
|
+
rl.question(
|
|
59
|
+
'Enter the type value (allowed values: CORP_FL, IB_FL, CORP_AFF_FL, CORP_AFF_IB_PORTAL, CORP_AFF_MSQ): ',
|
|
60
|
+
(type) => {
|
|
61
|
+
resolve({ FCMSenderId, type });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
reject(error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
module.exports = { start };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const brandModule = require('./brand.js');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fetch = require('node-fetch');
|
|
6
|
+
const unzipper = require('unzipper');
|
|
7
|
+
|
|
8
|
+
async function start(rl) {
|
|
9
|
+
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
|
+
const imagePath = await promptUser('Please provide the url to your favicon image: ', rl);
|
|
15
|
+
|
|
16
|
+
// Make a POST request to the RealFaviconGenerator API
|
|
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
|
+
const faviconDirectory = path.join(__dirname, faviconDirLocation);
|
|
35
|
+
await fs.promises.mkdir(faviconDirectory, { recursive: true });
|
|
36
|
+
|
|
37
|
+
const zipUrl = json.favicon_generation_result.favicon.package_url;
|
|
38
|
+
const zipResponse = await fetch(zipUrl);
|
|
39
|
+
const zipBuffer = await zipResponse.buffer();
|
|
40
|
+
const zipContents = await unzipper.Open.buffer(zipBuffer);
|
|
41
|
+
await Promise.all(
|
|
42
|
+
zipContents.files.map(async (file) => {
|
|
43
|
+
const content = await file.buffer();
|
|
44
|
+
const dest = path.join(faviconDirectory, file.path);
|
|
45
|
+
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
|
|
46
|
+
await fs.promises.writeFile(dest, content);
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
console.log(chalk.cyan(`Favicon images generated successfully!`));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(`Error generating favicon images: ${error}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns an object containing the necessary parameters for the RealFaviconGenerator API.
|
|
58
|
+
*/
|
|
59
|
+
function getFaviconRequest(brand, imagePath) {
|
|
60
|
+
return {
|
|
61
|
+
favicon_generation: {
|
|
62
|
+
api_key: process.env.FAVICON_API_KEY,
|
|
63
|
+
master_picture: {
|
|
64
|
+
type: 'url',
|
|
65
|
+
url: imagePath
|
|
66
|
+
},
|
|
67
|
+
favicon_design: {
|
|
68
|
+
ios: {
|
|
69
|
+
picture_aspect: 'no_change',
|
|
70
|
+
margin: '14%',
|
|
71
|
+
manifest: {
|
|
72
|
+
name: '',
|
|
73
|
+
short_name: '',
|
|
74
|
+
icons: [
|
|
75
|
+
{
|
|
76
|
+
src: '/apple-touch-icon-180x180.png',
|
|
77
|
+
sizes: '192x192',
|
|
78
|
+
type: 'image/png'
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
theme_color: '#ffffff',
|
|
82
|
+
background_color: '#ffffff',
|
|
83
|
+
display: 'standalone'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
desktop_browser: {},
|
|
87
|
+
windows: {
|
|
88
|
+
picture_aspect: 'no_change',
|
|
89
|
+
background_color: brand.color || '#FFF',
|
|
90
|
+
assets: {
|
|
91
|
+
windows_80_ie10_tile: true,
|
|
92
|
+
windows_10_ie11_edge_tiles: {
|
|
93
|
+
small: true,
|
|
94
|
+
medium: true,
|
|
95
|
+
big: true,
|
|
96
|
+
rectangle: true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
manifest: {
|
|
100
|
+
name: '',
|
|
101
|
+
short_name: '',
|
|
102
|
+
icons: [
|
|
103
|
+
{
|
|
104
|
+
src: '/mstile-150x150.png',
|
|
105
|
+
sizes: '150x150',
|
|
106
|
+
type: 'image/png'
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
theme_color: '#ffffff',
|
|
110
|
+
background_color: '#ffffff',
|
|
111
|
+
display: 'standalone'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
safari_pinned_tab: {
|
|
115
|
+
picture_aspect: 'silhouette',
|
|
116
|
+
threshold: 20,
|
|
117
|
+
theme_color: brand.color || '#FFF'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Prompts the user for input with the given message.
|
|
126
|
+
* @param {string} message The message to display to the user.
|
|
127
|
+
* @param {readline.Interface} rl The readline interface to use for user input.
|
|
128
|
+
* @returns {Promise<string>} A promise that resolves with the user's input.
|
|
129
|
+
*/
|
|
130
|
+
function promptUser(message, rl) {
|
|
131
|
+
return new Promise((resolve) => {
|
|
132
|
+
rl.question(message, (input) => {
|
|
133
|
+
resolve(input);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { start };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
const variableColors = require('./variablesColors.js');
|
|
3
|
+
const themes = require('./themes.js');
|
|
4
|
+
const favicon = require('./favicon.js');
|
|
5
|
+
const logo = require('./logo.js');
|
|
6
|
+
const translations = require('./translations.js');
|
|
7
|
+
const config = require('./createConfig.js');
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
const { exec } = require('child_process');
|
|
10
|
+
|
|
11
|
+
const rl = readline.createInterface({
|
|
12
|
+
input: process.stdin,
|
|
13
|
+
output: process.stdout
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const finishOnboarding = () => {
|
|
17
|
+
console.log(chalk.green('\nOnboarding completed!'));
|
|
18
|
+
rl.question('Start the application? (yes/no) ', (result) => {
|
|
19
|
+
if (result.toLowerCase() === 'yes') {
|
|
20
|
+
rl.close();
|
|
21
|
+
const startProcess = exec('npm start');
|
|
22
|
+
|
|
23
|
+
startProcess.stdout.on('data', (data) => {
|
|
24
|
+
console.log(data);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
startProcess.stderr.on('data', (data) => {
|
|
28
|
+
console.error(data);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
startProcess.on('close', (code) => {
|
|
32
|
+
console.log(`Child process exited with code ${code}`);
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
rl.close();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const startOnBoarding = async () => {
|
|
41
|
+
console.log(chalk.underline(chalk.cyan("Welcome to Antelope's on-boarding bot \n")));
|
|
42
|
+
try {
|
|
43
|
+
console.log(chalk.bold(chalk.yellow('\nStep 1: Add to variables-colors.scss')));
|
|
44
|
+
await variableColors.start(rl);
|
|
45
|
+
console.log(chalk.bold(chalk.yellow('\nStep 2: Add to themes.scss')));
|
|
46
|
+
await themes.start(rl);
|
|
47
|
+
console.log(chalk.bold(chalk.yellow('\nStep 3: Create favicon package')));
|
|
48
|
+
await favicon.start(rl);
|
|
49
|
+
console.log(chalk.bold(chalk.yellow('\nStep 4: Adding the logo')));
|
|
50
|
+
await logo.start(rl);
|
|
51
|
+
console.log(chalk.bold(chalk.yellow('\nStep 5: Adding translations')));
|
|
52
|
+
await translations.start(rl);
|
|
53
|
+
console.log(chalk.bold(chalk.yellow('\nStep 6: Editing the config file')));
|
|
54
|
+
await config.start(rl);
|
|
55
|
+
finishOnboarding();
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(chalk.red(err) + '\n Please delete files and code added by this fail session.');
|
|
58
|
+
rl.close();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
startOnBoarding();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const brandModule = require('./brand.js');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const downloadLogo = (url, dest) => {
|
|
8
|
+
const file = fs.createWriteStream(dest);
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
https
|
|
11
|
+
.get(url, (response) => {
|
|
12
|
+
response.pipe(file).on('finish', () => {
|
|
13
|
+
file.close(resolve);
|
|
14
|
+
});
|
|
15
|
+
})
|
|
16
|
+
.on('error', (err) => {
|
|
17
|
+
reject(err.message);
|
|
18
|
+
fs.unlink(dest, (error) => reject(error));
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function start(rl) {
|
|
24
|
+
const brand = brandModule.getBrand();
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const logoDirLocation = path.join(__dirname, `../../src/assets/img/logos/${brand.connectedBrandName}.png`);
|
|
27
|
+
rl.question('Please enter the URL to the logo image suitable for a black background:\n', async (url) => {
|
|
28
|
+
try {
|
|
29
|
+
console.log(chalk.inverse('Downloading logo...'));
|
|
30
|
+
await downloadLogo(url, logoDirLocation, brand.connectedBrandName);
|
|
31
|
+
console.log(chalk.cyan('Logo downloaded successfully!'));
|
|
32
|
+
resolve(null);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.error(err);
|
|
35
|
+
return start(rl);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { start };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const brandModule = require('./brand.js');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const themesPath = 'src/ng1/assets/css/sass/materialism/themes.scss';
|
|
5
|
+
|
|
6
|
+
function addColorToMap(mapName, key, value, data) {
|
|
7
|
+
const mapRegex = new RegExp(`\\$${mapName}:\\s*\\(([\\s\\S]*?)\\)`);
|
|
8
|
+
const match = data.match(mapRegex);
|
|
9
|
+
if (match) {
|
|
10
|
+
const mapContent = match[1];
|
|
11
|
+
const newMapContent = `$${mapName}: (${mapContent} '${key}': ${value},\n)`;
|
|
12
|
+
data = data.replace(mapRegex, newMapContent);
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error(`Error: Could not find ${mapName} map in the file`);
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function start(rl) {
|
|
20
|
+
const brand = brandModule.getBrand();
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
try {
|
|
23
|
+
const themeVar = `
|
|
24
|
+
.theme-template-${brand.connectedBrandName} {
|
|
25
|
+
#logo {
|
|
26
|
+
display: inline-block;
|
|
27
|
+
width: 240px;
|
|
28
|
+
height: 120px;
|
|
29
|
+
background: url('src/assets/img/logos/${brand.connectedBrandName}.png') no-repeat center center;
|
|
30
|
+
background-size: contain;
|
|
31
|
+
}
|
|
32
|
+
.navbar-toggle-container {
|
|
33
|
+
background: #222C38;
|
|
34
|
+
|
|
35
|
+
.icon-bar {
|
|
36
|
+
background: #fff !important;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
.sidebar {
|
|
40
|
+
background: #222C38;
|
|
41
|
+
color: #ffffff;
|
|
42
|
+
|
|
43
|
+
ul a,
|
|
44
|
+
i {
|
|
45
|
+
color: #ffffff;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.brand-logo,
|
|
49
|
+
.brand-logo-text {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
.user-logged-in:after {
|
|
53
|
+
background: #26303C;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
\n`;
|
|
58
|
+
fs.readFile(themesPath, 'utf8', (err, data) => {
|
|
59
|
+
if (err) {
|
|
60
|
+
reject(err);
|
|
61
|
+
} else {
|
|
62
|
+
data = addColorToMap(
|
|
63
|
+
'theme-colors',
|
|
64
|
+
brand.connectedBrandName,
|
|
65
|
+
brand.color ? `$${brand.connectedBrandName}` : '$corp',
|
|
66
|
+
data
|
|
67
|
+
);
|
|
68
|
+
data = addColorToMap(
|
|
69
|
+
'theme-secondary-colors',
|
|
70
|
+
brand.connectedBrandName,
|
|
71
|
+
brand.color ? `'${brand.connectedBrandName}'` : "'corp'",
|
|
72
|
+
data
|
|
73
|
+
);
|
|
74
|
+
const insertionPoint = data.lastIndexOf('@each $color-name');
|
|
75
|
+
const newFileContent = data.slice(0, insertionPoint) + themeVar + data.slice(insertionPoint);
|
|
76
|
+
fs.writeFile(themesPath, newFileContent, 'utf8', (error) => {
|
|
77
|
+
if (error) {
|
|
78
|
+
reject(error);
|
|
79
|
+
} else {
|
|
80
|
+
console.log(chalk.cyan('themes.scss file updated successfully!'));
|
|
81
|
+
resolve(null);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error(error);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { start };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const brandModule = require('./brand.js');
|
|
5
|
+
|
|
6
|
+
function createTranslationsFolder(translationsDirectory) {
|
|
7
|
+
const folderPath = path.join(translationsDirectory, 'languages');
|
|
8
|
+
|
|
9
|
+
if (!fs.existsSync(folderPath)) {
|
|
10
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return folderPath;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createLanguageFiles(languages, folderPath) {
|
|
17
|
+
languages.forEach((language) => {
|
|
18
|
+
const filePath = path.join(folderPath, `${language}.json`);
|
|
19
|
+
fs.writeFileSync(filePath, '{}', 'utf8');
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function start(rl) {
|
|
24
|
+
const brand = brandModule.getBrand();
|
|
25
|
+
const translationsDir = `../../src/assets/brands/${brand.connectedBrandName}`;
|
|
26
|
+
const translationsDirectory = path.join(__dirname, translationsDir);
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
try {
|
|
29
|
+
rl.question('Enter the languages (2-letter codes) separated by commas:\n', (languagesInput) => {
|
|
30
|
+
const languages = languagesInput.trim().split(',');
|
|
31
|
+
brandModule.updateBrand({ languages });
|
|
32
|
+
const folderPath = createTranslationsFolder(translationsDirectory);
|
|
33
|
+
createLanguageFiles(languages, folderPath);
|
|
34
|
+
console.log(chalk.cyan('Translations added successfully!'));
|
|
35
|
+
resolve(null);
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
reject(error + '\n Please add the translations manually.');
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = { start };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const brandModule = require('./brand.js');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const variablesColorsPath = 'src/ng1/assets/css/sass/variables-colors.scss';
|
|
5
|
+
const defaultColor = '$corp';
|
|
6
|
+
|
|
7
|
+
function start(rl) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
rl.question("What is the new brand's name?\n", (brandName) => {
|
|
10
|
+
const kebabCaseName = brandName.toLowerCase().replace(/ /g, '-');
|
|
11
|
+
const connectedBrandName = brandName.toLowerCase().replace(/ /g, '');
|
|
12
|
+
rl.question(
|
|
13
|
+
`Please set a color for "${kebabCaseName}", use hex value, leave empty for default.\n`,
|
|
14
|
+
(hexColor) => {
|
|
15
|
+
let data = fs.readFileSync(variablesColorsPath, 'utf8');
|
|
16
|
+
|
|
17
|
+
// Check if $colors map exists in the file
|
|
18
|
+
const colorsRegex = /\$colors:\s*\(([\s\S]*?)\)/;
|
|
19
|
+
const match = data.match(colorsRegex);
|
|
20
|
+
if (match) {
|
|
21
|
+
const colorsMap = match[1];
|
|
22
|
+
|
|
23
|
+
// Append the new brand to the colors map
|
|
24
|
+
const newColorsMap = `$colors: (${colorsMap} '${connectedBrandName}': ${
|
|
25
|
+
hexColor ? '$' + connectedBrandName : defaultColor
|
|
26
|
+
},\n)`;
|
|
27
|
+
|
|
28
|
+
// Replace the $colors map in the file with the new one
|
|
29
|
+
data = data.replace(colorsRegex, newColorsMap);
|
|
30
|
+
} else {
|
|
31
|
+
reject('Error: Could not find $colors map in the file');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const brandVar = `\$${connectedBrandName}: (
|
|
35
|
+
'lighten-5': lighten(${hexColor}, 25%),
|
|
36
|
+
'lighten-4': lighten(${hexColor}, 20%),
|
|
37
|
+
'lighten-3': lighten(${hexColor}, 15%),
|
|
38
|
+
'lighten-2': lighten(${hexColor}, 10%),
|
|
39
|
+
'lighten-1': lighten(${hexColor}, 5%),
|
|
40
|
+
'base': ${hexColor},
|
|
41
|
+
'darken-1': darken(${hexColor}, 5%),
|
|
42
|
+
'darken-2': darken(${hexColor}, 10%),
|
|
43
|
+
'darken-3': darken(${hexColor}, 15%),
|
|
44
|
+
'darken-4': darken(${hexColor}, 20%),
|
|
45
|
+
);\n`;
|
|
46
|
+
|
|
47
|
+
const newData = hexColor ? brandVar + data : data;
|
|
48
|
+
fs.writeFileSync(variablesColorsPath, newData, 'utf8');
|
|
49
|
+
brandModule.updateBrand({ brandName, kebabCaseName, connectedBrandName, color: hexColor || '' });
|
|
50
|
+
console.log(chalk.cyan('\nvariables-colors.scss file updated successfully!'));
|
|
51
|
+
resolve(null);
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { start };
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "antelope-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI-Tool for automating processes for Antelope-Systems ",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ant-cli": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "test"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://bitbucket.org/xsitesinc/antelope-cli.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cli"
|
|
18
|
+
],
|
|
19
|
+
"author": "Idan Atias",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"homepage": "https://bitbucket.org/xsitesinc/antelope-cli#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"dotenv": "^16.4.5",
|
|
24
|
+
"unzipper": "^0.12.1"
|
|
25
|
+
}
|
|
26
|
+
}
|