antelope-cli 1.2.0 → 1.2.2

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.
@@ -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},\n '${key}': ${value})`;
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
+ // Same edits as onboarding/themes.js, driven by resolved brand state (no prompts).
20
+ function start() {
21
+ const brand = brandModule.getBrand();
22
+ return new Promise((resolve, reject) => {
23
+ const themeVar = `
24
+ .theme-template-${brand.connectedBrandName} {
25
+ #logo {
26
+ display: inline-block;
27
+ width: 240px;
28
+ height: 120px;
29
+ background: url('${brand.logo}') 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
+ return reject(err);
61
+ }
62
+ try {
63
+ data = addColorToMap(
64
+ 'theme-colors',
65
+ brand.connectedBrandName,
66
+ brand.color ? `$${brand.connectedBrandName}` : '$corp',
67
+ data
68
+ );
69
+ data = addColorToMap(
70
+ 'theme-secondary-colors',
71
+ brand.connectedBrandName,
72
+ brand.color ? `'${brand.connectedBrandName}'` : "'corp'",
73
+ data
74
+ );
75
+ } catch (mapError) {
76
+ return reject(mapError);
77
+ }
78
+ const insertionPoint = data.lastIndexOf('@each $color-name');
79
+ const newFileContent = data.slice(0, insertionPoint) + themeVar + data.slice(insertionPoint);
80
+ fs.writeFile(themesPath, newFileContent, 'utf8', (error) => {
81
+ if (error) {
82
+ reject(error);
83
+ } else {
84
+ console.log(chalk.cyan('themes.scss file updated successfully!'));
85
+ resolve(null);
86
+ }
87
+ });
88
+ });
89
+ });
90
+ }
91
+
92
+ module.exports = { start };
@@ -0,0 +1,37 @@
1
+ const fs = require('fs');
2
+ const chalk = require('chalk');
3
+ const brandModule = require('./brand.js');
4
+ const path = require('path');
5
+
6
+ function createTranslationsFolder(translationsDirectory) {
7
+ const folderPath = path.join(translationsDirectory, 'languages');
8
+ if (!fs.existsSync(folderPath)) {
9
+ fs.mkdirSync(folderPath, { recursive: true });
10
+ }
11
+ return folderPath;
12
+ }
13
+
14
+ function createLanguageFiles(languages, folderPath) {
15
+ languages.forEach((language) => {
16
+ const filePath = path.join(folderPath, `${language}.json`);
17
+ fs.writeFileSync(filePath, '{}', 'utf8');
18
+ });
19
+ }
20
+
21
+ // Same as onboarding/translations.js, but the languages list is resolved from flags/prompt upfront.
22
+ function start() {
23
+ const brand = brandModule.getBrand();
24
+ const translationsDir = `src/assets/brands/${brand.connectedBrandName}`;
25
+ return new Promise((resolve, reject) => {
26
+ try {
27
+ const folderPath = createTranslationsFolder(translationsDir);
28
+ createLanguageFiles(brand.languages, folderPath);
29
+ console.log(chalk.cyan('Translations added successfully!'));
30
+ resolve(null);
31
+ } catch (error) {
32
+ reject(error + '\n Please add the translations manually.');
33
+ }
34
+ });
35
+ }
36
+
37
+ module.exports = { start };
@@ -0,0 +1,54 @@
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
+ // Same edits as onboarding/variablesColors.js, driven by resolved brand state (no prompts).
8
+ function start() {
9
+ return new Promise((resolve, reject) => {
10
+ try {
11
+ const { connectedBrandName, color: hexColor } = brandModule.getBrand();
12
+ let data = fs.readFileSync(variablesColorsPath, 'utf8');
13
+
14
+ // Check if $colors map exists in the file
15
+ const colorsRegex = /\$colors:\s*\(([\s\S]*?)\)/;
16
+ const match = data.match(colorsRegex);
17
+ if (match) {
18
+ const colorsMap = match[1];
19
+
20
+ // Append the new brand to the colors map
21
+ const newColorsMap = `$colors: (${colorsMap},\n '${connectedBrandName}': ${
22
+ hexColor ? '$' + connectedBrandName : defaultColor
23
+ })`;
24
+
25
+ // Replace the $colors map in the file with the new one
26
+ data = data.replace(colorsRegex, newColorsMap);
27
+ } else {
28
+ return reject('Error: Could not find $colors map in the file');
29
+ }
30
+
31
+ const brandVar = `\$${connectedBrandName}: (
32
+ 'lighten-5': lighten(${hexColor}, 25%),
33
+ 'lighten-4': lighten(${hexColor}, 20%),
34
+ 'lighten-3': lighten(${hexColor}, 15%),
35
+ 'lighten-2': lighten(${hexColor}, 10%),
36
+ 'lighten-1': lighten(${hexColor}, 5%),
37
+ 'base': ${hexColor},
38
+ 'darken-1': darken(${hexColor}, 5%),
39
+ 'darken-2': darken(${hexColor}, 10%),
40
+ 'darken-3': darken(${hexColor}, 15%),
41
+ 'darken-4': darken(${hexColor}, 20%),
42
+ );\n`;
43
+
44
+ const newData = hexColor ? brandVar + data : data;
45
+ fs.writeFileSync(variablesColorsPath, newData, 'utf8');
46
+ console.log(chalk.cyan('\nvariables-colors.scss file updated successfully!'));
47
+ resolve(null);
48
+ } catch (error) {
49
+ reject(error);
50
+ }
51
+ });
52
+ }
53
+
54
+ module.exports = { start };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antelope-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "CLI-Tool for automating processes for Antelope-Systems ",
5
5
  "main": "index.js",
6
6
  "bin": {