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.
- package/ansible/onboarding-ca/README.md +105 -72
- package/ansible/onboarding-ca/onboard-ca.yml +51 -41
- package/ansible/onboarding-ca/requirements.yml +8 -0
- package/ansible/onboarding-ca/roles/onboard_ca/defaults/main.yml +49 -24
- package/ansible/onboarding-ca/roles/onboard_ca/meta/main.yml +10 -10
- package/ansible/onboarding-ca/roles/onboard_ca/tasks/main.yml +193 -76
- package/ansible/onboarding-ca/roles/onboard_ca/tasks/per_branch.yml +107 -106
- package/ansible/onboarding-ca/roles/onboard_ca/vars/main.yml +9 -6
- package/index.js +2 -0
- package/onboarding-ca/brand.js +13 -13
- package/onboarding-ca/index.js +94 -94
- package/onboarding-ca/riskDisclaimer.js +27 -27
- package/onboarding-ca/scss.js +24 -24
- package/onboarding-ca/templates/risk-disclaimer.html +12 -12
- package/onboarding-crm/brand.js +22 -0
- package/onboarding-crm/brandLocations.js +33 -0
- package/onboarding-crm/createConfig.js +40 -0
- package/onboarding-crm/index.js +171 -0
- package/onboarding-crm/themes.js +92 -0
- package/onboarding-crm/translations.js +37 -0
- package/onboarding-crm/variablesColors.js +54 -0
- package/package.json +1 -1
package/onboarding-ca/index.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
const readline = require('readline');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const brandModule = require('./brand.js');
|
|
4
|
-
const scss = require('./scss.js');
|
|
5
|
-
const riskDisclaimer = require('./riskDisclaimer.js');
|
|
6
|
-
|
|
7
|
-
const HELP = `
|
|
8
|
-
Usage: ant-cli onboarding-ca --brand_assets_folder <folder>
|
|
9
|
-
|
|
10
|
-
Creates the Client Area brand assets in the current web-client-area checkout:
|
|
11
|
-
src/assets/other/<folder>/<folder>.scss (empty)
|
|
12
|
-
src/assets/other/<folder>/legal/risk-disclaimer.html
|
|
13
|
-
|
|
14
|
-
Options:
|
|
15
|
-
--brand_assets_folder Brand assets folder name, e.g. "zenithhorizongroup"
|
|
16
|
-
(required in non-interactive mode). This is the value used for
|
|
17
|
-
ENV_branding.brand_assets_folder. Normalized to lowercase, spaces removed.
|
|
18
|
-
-h, --help Show this help
|
|
19
|
-
|
|
20
|
-
Run from the root of a web-client-area checkout — files are written relative to the current directory.
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
// Normalize to the folder convention used across the brand repos (connectedBrandName):
|
|
24
|
-
// lowercase, no spaces. Harmless when a clean folder name is already supplied.
|
|
25
|
-
const normalizeFolder = (value) => value.trim().toLowerCase().replace(/ /g, '');
|
|
26
|
-
|
|
27
|
-
function parseArgs(argv) {
|
|
28
|
-
const opts = {};
|
|
29
|
-
for (let i = 0; i < argv.length; i++) {
|
|
30
|
-
const a = argv[i];
|
|
31
|
-
if (a === '--brand_assets_folder') opts.brandAssetsFolder = argv[++i];
|
|
32
|
-
else if (a === '--help' || a === '-h') opts.help = true;
|
|
33
|
-
}
|
|
34
|
-
return opts;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function promptFolder(rl) {
|
|
38
|
-
return new Promise((resolve) => {
|
|
39
|
-
rl.question('Enter the brand assets folder name (e.g. zenithhorizongroup):\n', (name) => resolve(name));
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function run() {
|
|
44
|
-
// process.argv: [node, index.js, "onboarding-ca", ...flags]
|
|
45
|
-
const opts = parseArgs(process.argv.slice(3));
|
|
46
|
-
if (opts.help) {
|
|
47
|
-
console.log(HELP);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(chalk.underline(chalk.cyan('Antelope Client-Area on-boarding\n')));
|
|
52
|
-
|
|
53
|
-
// Interactive only in a real terminal and when not forced non-interactive (CI / Ansible).
|
|
54
|
-
const interactive = Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
55
|
-
|
|
56
|
-
let rl;
|
|
57
|
-
let rawFolder = opts.brandAssetsFolder;
|
|
58
|
-
if (!rawFolder) {
|
|
59
|
-
if (!interactive) {
|
|
60
|
-
console.error(chalk.red('Error: --brand_assets_folder is required in non-interactive mode.'));
|
|
61
|
-
console.log(HELP);
|
|
62
|
-
process.exitCode = 1;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
66
|
-
rawFolder = await promptFolder(rl);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const brandAssetsFolder = normalizeFolder(rawFolder || '');
|
|
70
|
-
if (!brandAssetsFolder) {
|
|
71
|
-
console.error(chalk.red('Error: brand assets folder must not be empty.'));
|
|
72
|
-
if (rl) rl.close();
|
|
73
|
-
process.exitCode = 1;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
brandModule.updateBrand({ brandAssetsFolder });
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
console.log(chalk.bold(chalk.yellow(`\nOnboarding brand assets folder "${brandAssetsFolder}"`)));
|
|
81
|
-
console.log(chalk.bold(chalk.yellow('\nStep 1: Create brand stylesheet')));
|
|
82
|
-
await scss.start();
|
|
83
|
-
console.log(chalk.bold(chalk.yellow('\nStep 2: Create legal/risk-disclaimer.html')));
|
|
84
|
-
await riskDisclaimer.start();
|
|
85
|
-
console.log(chalk.green('\nClient-Area onboarding completed!'));
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.error(chalk.red(err) + '\n Please delete files added by this failed session.');
|
|
88
|
-
process.exitCode = 1;
|
|
89
|
-
} finally {
|
|
90
|
-
if (rl) rl.close();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
run();
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const brandModule = require('./brand.js');
|
|
4
|
+
const scss = require('./scss.js');
|
|
5
|
+
const riskDisclaimer = require('./riskDisclaimer.js');
|
|
6
|
+
|
|
7
|
+
const HELP = `
|
|
8
|
+
Usage: ant-cli onboarding-ca --brand_assets_folder <folder>
|
|
9
|
+
|
|
10
|
+
Creates the Client Area brand assets in the current web-client-area checkout:
|
|
11
|
+
src/assets/other/<folder>/<folder>.scss (empty)
|
|
12
|
+
src/assets/other/<folder>/legal/risk-disclaimer.html
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--brand_assets_folder Brand assets folder name, e.g. "zenithhorizongroup"
|
|
16
|
+
(required in non-interactive mode). This is the value used for
|
|
17
|
+
ENV_branding.brand_assets_folder. Normalized to lowercase, spaces removed.
|
|
18
|
+
-h, --help Show this help
|
|
19
|
+
|
|
20
|
+
Run from the root of a web-client-area checkout — files are written relative to the current directory.
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
// Normalize to the folder convention used across the brand repos (connectedBrandName):
|
|
24
|
+
// lowercase, no spaces. Harmless when a clean folder name is already supplied.
|
|
25
|
+
const normalizeFolder = (value) => value.trim().toLowerCase().replace(/ /g, '');
|
|
26
|
+
|
|
27
|
+
function parseArgs(argv) {
|
|
28
|
+
const opts = {};
|
|
29
|
+
for (let i = 0; i < argv.length; i++) {
|
|
30
|
+
const a = argv[i];
|
|
31
|
+
if (a === '--brand_assets_folder') opts.brandAssetsFolder = argv[++i];
|
|
32
|
+
else if (a === '--help' || a === '-h') opts.help = true;
|
|
33
|
+
}
|
|
34
|
+
return opts;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function promptFolder(rl) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
rl.question('Enter the brand assets folder name (e.g. zenithhorizongroup):\n', (name) => resolve(name));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function run() {
|
|
44
|
+
// process.argv: [node, index.js, "onboarding-ca", ...flags]
|
|
45
|
+
const opts = parseArgs(process.argv.slice(3));
|
|
46
|
+
if (opts.help) {
|
|
47
|
+
console.log(HELP);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(chalk.underline(chalk.cyan('Antelope Client-Area on-boarding\n')));
|
|
52
|
+
|
|
53
|
+
// Interactive only in a real terminal and when not forced non-interactive (CI / Ansible).
|
|
54
|
+
const interactive = Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
55
|
+
|
|
56
|
+
let rl;
|
|
57
|
+
let rawFolder = opts.brandAssetsFolder;
|
|
58
|
+
if (!rawFolder) {
|
|
59
|
+
if (!interactive) {
|
|
60
|
+
console.error(chalk.red('Error: --brand_assets_folder is required in non-interactive mode.'));
|
|
61
|
+
console.log(HELP);
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
66
|
+
rawFolder = await promptFolder(rl);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const brandAssetsFolder = normalizeFolder(rawFolder || '');
|
|
70
|
+
if (!brandAssetsFolder) {
|
|
71
|
+
console.error(chalk.red('Error: brand assets folder must not be empty.'));
|
|
72
|
+
if (rl) rl.close();
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
brandModule.updateBrand({ brandAssetsFolder });
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
console.log(chalk.bold(chalk.yellow(`\nOnboarding brand assets folder "${brandAssetsFolder}"`)));
|
|
81
|
+
console.log(chalk.bold(chalk.yellow('\nStep 1: Create brand stylesheet')));
|
|
82
|
+
await scss.start();
|
|
83
|
+
console.log(chalk.bold(chalk.yellow('\nStep 2: Create legal/risk-disclaimer.html')));
|
|
84
|
+
await riskDisclaimer.start();
|
|
85
|
+
console.log(chalk.green('\nClient-Area onboarding completed!'));
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error(chalk.red(err) + '\n Please delete files added by this failed session.');
|
|
88
|
+
process.exitCode = 1;
|
|
89
|
+
} finally {
|
|
90
|
+
if (rl) rl.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
run();
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const brandModule = require('./brand.js');
|
|
5
|
-
|
|
6
|
-
// The disclaimer is the same fixed markup for every brand. Read the bundled template
|
|
7
|
-
// via __dirname (resolves inside the installed package, regardless of the cwd we write to).
|
|
8
|
-
const templatePath = path.join(__dirname, 'templates', 'risk-disclaimer.html');
|
|
9
|
-
|
|
10
|
-
function start() {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
try {
|
|
13
|
-
const { brandAssetsFolder } = brandModule.getBrand();
|
|
14
|
-
const dir = path.join('src', 'assets', 'other', brandAssetsFolder, 'legal');
|
|
15
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
16
|
-
const file = path.join(dir, 'risk-disclaimer.html');
|
|
17
|
-
const template = fs.readFileSync(templatePath, 'utf8');
|
|
18
|
-
fs.writeFileSync(file, template, 'utf8');
|
|
19
|
-
console.log(chalk.cyan(`Created ${file}`));
|
|
20
|
-
resolve(file);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
reject(error);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = { start };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const brandModule = require('./brand.js');
|
|
5
|
+
|
|
6
|
+
// The disclaimer is the same fixed markup for every brand. Read the bundled template
|
|
7
|
+
// via __dirname (resolves inside the installed package, regardless of the cwd we write to).
|
|
8
|
+
const templatePath = path.join(__dirname, 'templates', 'risk-disclaimer.html');
|
|
9
|
+
|
|
10
|
+
function start() {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
try {
|
|
13
|
+
const { brandAssetsFolder } = brandModule.getBrand();
|
|
14
|
+
const dir = path.join('src', 'assets', 'other', brandAssetsFolder, 'legal');
|
|
15
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
16
|
+
const file = path.join(dir, 'risk-disclaimer.html');
|
|
17
|
+
const template = fs.readFileSync(templatePath, 'utf8');
|
|
18
|
+
fs.writeFileSync(file, template, 'utf8');
|
|
19
|
+
console.log(chalk.cyan(`Created ${file}`));
|
|
20
|
+
resolve(file);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
reject(error);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = { start };
|
package/onboarding-ca/scss.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const brandModule = require('./brand.js');
|
|
5
|
-
|
|
6
|
-
// Creates the brand stylesheet. It is intentionally EMPTY — matches every existing
|
|
7
|
-
// brand in web-client-area (git blob e69de29b). brands.ts require()s it dynamically.
|
|
8
|
-
function start() {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
try {
|
|
11
|
-
const { brandAssetsFolder } = brandModule.getBrand();
|
|
12
|
-
const dir = path.join('src', 'assets', 'other', brandAssetsFolder);
|
|
13
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
14
|
-
const file = path.join(dir, `${brandAssetsFolder}.scss`);
|
|
15
|
-
fs.writeFileSync(file, '', 'utf8');
|
|
16
|
-
console.log(chalk.cyan(`Created ${file}`));
|
|
17
|
-
resolve(file);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
reject(error);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = { start };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const brandModule = require('./brand.js');
|
|
5
|
+
|
|
6
|
+
// Creates the brand stylesheet. It is intentionally EMPTY — matches every existing
|
|
7
|
+
// brand in web-client-area (git blob e69de29b). brands.ts require()s it dynamically.
|
|
8
|
+
function start() {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
try {
|
|
11
|
+
const { brandAssetsFolder } = brandModule.getBrand();
|
|
12
|
+
const dir = path.join('src', 'assets', 'other', brandAssetsFolder);
|
|
13
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
14
|
+
const file = path.join(dir, `${brandAssetsFolder}.scss`);
|
|
15
|
+
fs.writeFileSync(file, '', 'utf8');
|
|
16
|
+
console.log(chalk.cyan(`Created ${file}`));
|
|
17
|
+
resolve(file);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
reject(error);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { start };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<div class="page-wrapper push-up">
|
|
2
|
-
<a
|
|
3
|
-
class="disclaimer__top-image push-down"
|
|
4
|
-
href="{{ 'RISK.DISCLAIMER.SPONSOR.URL' | translate }}"
|
|
5
|
-
target="_blank"
|
|
6
|
-
layout="row"
|
|
7
|
-
layout-align="center center"
|
|
8
|
-
><img alt=""
|
|
9
|
-
/></a>
|
|
10
|
-
<div class="disclaimer__title"><span translate="COMMON.RISK_DISCLAIMER"></span>:</div>
|
|
11
|
-
<p translate="DISCLAIMER" translate-value-risk="{{$ctrl.risk}}"></p>
|
|
12
|
-
</div>
|
|
1
|
+
<div class="page-wrapper push-up">
|
|
2
|
+
<a
|
|
3
|
+
class="disclaimer__top-image push-down"
|
|
4
|
+
href="{{ 'RISK.DISCLAIMER.SPONSOR.URL' | translate }}"
|
|
5
|
+
target="_blank"
|
|
6
|
+
layout="row"
|
|
7
|
+
layout-align="center center"
|
|
8
|
+
><img alt=""
|
|
9
|
+
/></a>
|
|
10
|
+
<div class="disclaimer__title"><span translate="COMMON.RISK_DISCLAIMER"></span>:</div>
|
|
11
|
+
<p translate="DISCLAIMER" translate-value-risk="{{$ctrl.risk}}"></p>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
let brand = {
|
|
2
|
+
brandId: '',
|
|
3
|
+
brandName: '',
|
|
4
|
+
connectedBrandName: '',
|
|
5
|
+
color: '',
|
|
6
|
+
logo: '',
|
|
7
|
+
languages: null,
|
|
8
|
+
favicon: '',
|
|
9
|
+
FCMSenderId: '',
|
|
10
|
+
type: '',
|
|
11
|
+
baseUrl: ''
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function updateBrand(updatedBrand) {
|
|
15
|
+
brand = { ...brand, ...updatedBrand };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getBrand() {
|
|
19
|
+
return brand;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { updateBrand, getBrand };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const brandModule = require('./brand.js');
|
|
4
|
+
|
|
5
|
+
const brandLocationsPath = 'BRAND_LOCATIONS.md';
|
|
6
|
+
|
|
7
|
+
// Append a sprint-tracking row "<brand_name> → <brand_id>" to BRAND_LOCATIONS.md,
|
|
8
|
+
// mirroring the migrate-brand-to-id skill (today's date, QA sign-off left blank).
|
|
9
|
+
function start() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
try {
|
|
12
|
+
if (!fs.existsSync(brandLocationsPath)) {
|
|
13
|
+
console.log(chalk.yellow(`${brandLocationsPath} not found — skipping tracking row.`));
|
|
14
|
+
return resolve(null);
|
|
15
|
+
}
|
|
16
|
+
const { brandName, brandId } = brandModule.getBrand();
|
|
17
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
18
|
+
const cell = `${brandName} → ${brandId}`;
|
|
19
|
+
const row = `| ${date} | ${cell.padEnd(27)} | |`;
|
|
20
|
+
|
|
21
|
+
let data = fs.readFileSync(brandLocationsPath, 'utf8');
|
|
22
|
+
if (!data.endsWith('\n')) data += '\n';
|
|
23
|
+
data += row + '\n';
|
|
24
|
+
fs.writeFileSync(brandLocationsPath, data, 'utf8');
|
|
25
|
+
console.log(chalk.cyan(`BRAND_LOCATIONS.md updated: ${cell}`));
|
|
26
|
+
resolve(null);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
reject(error);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = { start };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const brandModule = require('./brand.js');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const configsFilePath = 'src/configs/configs.ts';
|
|
5
|
+
|
|
6
|
+
// Writes configs.ts (devops copy-paste this into the env's Consul config).
|
|
7
|
+
// Brand references use the Antelope ID (connectedBrandName = brand_id); baseUrl comes from the flag.
|
|
8
|
+
function start() {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
fs.mkdirSync('src/configs', { recursive: true });
|
|
11
|
+
fs.writeFile(configsFilePath, updateConfigFile(), 'utf8', (error) => {
|
|
12
|
+
if (error) {
|
|
13
|
+
reject(error);
|
|
14
|
+
} else {
|
|
15
|
+
console.log(chalk.cyan('configs.ts file updated successfully!'));
|
|
16
|
+
resolve(null);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const updateConfigFile = () => {
|
|
23
|
+
const brand = brandModule.getBrand();
|
|
24
|
+
return `export const configs: WebCrmConfig = {
|
|
25
|
+
baseUrl: '${brand.baseUrl}',
|
|
26
|
+
appId: 0,
|
|
27
|
+
type: '${brand.type}',
|
|
28
|
+
defaultLanguage: 'en',
|
|
29
|
+
gaTrackingID: 'UA-70456753-2',
|
|
30
|
+
colorTheme: 'theme-${brand.connectedBrandName}',
|
|
31
|
+
templateTheme: 'theme-template-${brand.connectedBrandName}',
|
|
32
|
+
title: '${brand.connectedBrandName}',
|
|
33
|
+
favicon: '${brand.favicon}',
|
|
34
|
+
affiliatesApiUrl: '',
|
|
35
|
+
FCMSenderId: '${brand.FCMSenderId}',
|
|
36
|
+
brandAssetsFolder: '${brand.connectedBrandName}',
|
|
37
|
+
};`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = { start };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const brandModule = require('./brand.js');
|
|
4
|
+
const variablesColors = require('./variablesColors.js');
|
|
5
|
+
const themes = require('./themes.js');
|
|
6
|
+
const translations = require('./translations.js');
|
|
7
|
+
const createConfig = require('./createConfig.js');
|
|
8
|
+
const brandLocations = require('./brandLocations.js');
|
|
9
|
+
|
|
10
|
+
const ALLOWED_TYPES = ['CORP_FL', 'IB_FL', 'CORP_AFF_FL', 'CORP_AFF_IB_PORTAL', 'CORP_AFF_MSQ'];
|
|
11
|
+
const DEFAULT_BASE_URL = 'https://dev-apicrm.antelopesystem.com/SignalsCRM/';
|
|
12
|
+
|
|
13
|
+
const HELP = `
|
|
14
|
+
Usage: ant-cli onboarding-crm --brand_id <id> --brand_name <name> [options]
|
|
15
|
+
|
|
16
|
+
Onboards a CRM brand in the current web-crm checkout, keyed by the brand's Antelope ID.
|
|
17
|
+
All inputs come from flags (interactive prompts are only a fallback in a TTY):
|
|
18
|
+
src/ng1/assets/css/sass/variables-colors.scss (+ $<id> shades and $colors entry)
|
|
19
|
+
src/ng1/assets/css/sass/materialism/themes.scss (+ theme maps and .theme-template-<id> block)
|
|
20
|
+
src/assets/brands/<id>/languages/<lang>.json (one empty file per language)
|
|
21
|
+
src/configs/configs.ts (rewritten for the brand — copy into Consul)
|
|
22
|
+
BRAND_LOCATIONS.md (+ sprint tracking row "<name> -> <id>")
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--brand_id <id> Antelope unique ID, e.g. "xxxxx" — the code identifier used everywhere (required)
|
|
26
|
+
--brand_name <name> Human brand name — recorded in the BRAND_LOCATIONS.md tracking row (required)
|
|
27
|
+
--color <hex> Brand hex color, e.g. "#1a2b3c". Empty => default palette ($corp)
|
|
28
|
+
--logo_url <url> Logo image URL (black background) (required)
|
|
29
|
+
--languages <csv> 2-letter language codes, comma-separated, e.g. "en,ar" (required)
|
|
30
|
+
--favicon_url <url> Favicon image URL → configs.ts favicon (required)
|
|
31
|
+
--fcm_sender_id <id> Firebase FCMSenderId → configs.ts (required)
|
|
32
|
+
--type <type> One of: ${ALLOWED_TYPES.join(', ')} → configs.ts (required)
|
|
33
|
+
--base_url <url> configs.ts baseUrl. Default: ${DEFAULT_BASE_URL}
|
|
34
|
+
-h, --help Show this help
|
|
35
|
+
|
|
36
|
+
Run from the root of a web-crm checkout — files are written relative to the current directory.
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const FLAGS = {
|
|
40
|
+
'--brand_id': 'brandId',
|
|
41
|
+
'--brand_name': 'brandName',
|
|
42
|
+
'--color': 'color',
|
|
43
|
+
'--logo_url': 'logo',
|
|
44
|
+
'--languages': 'languages',
|
|
45
|
+
'--favicon_url': 'favicon',
|
|
46
|
+
'--fcm_sender_id': 'fcmSenderId',
|
|
47
|
+
'--type': 'type',
|
|
48
|
+
'--base_url': 'baseUrl'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function parseArgs(argv) {
|
|
52
|
+
const opts = {};
|
|
53
|
+
for (let i = 0; i < argv.length; i++) {
|
|
54
|
+
const a = argv[i];
|
|
55
|
+
if (a === '--help' || a === '-h') opts.help = true;
|
|
56
|
+
else if (FLAGS[a]) opts[FLAGS[a]] = argv[++i];
|
|
57
|
+
}
|
|
58
|
+
return opts;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Antelope IDs are lowercase alphanumeric; normalize defensively (trim, lowercase, drop spaces).
|
|
62
|
+
const normalizeId = (value) => value.trim().toLowerCase().replace(/ /g, '');
|
|
63
|
+
|
|
64
|
+
const ask = (rl, question) => new Promise((resolve) => rl.question(question, (a) => resolve(a)));
|
|
65
|
+
|
|
66
|
+
// Resolve a value: prefer the flag; otherwise prompt (interactive only). Returns undefined
|
|
67
|
+
// when absent and non-interactive, so the caller can report it as a missing required field.
|
|
68
|
+
async function resolve(opts, key, promptText, interactive, rl) {
|
|
69
|
+
if (opts[key] !== undefined) return opts[key];
|
|
70
|
+
if (interactive) return ask(rl, promptText);
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function run() {
|
|
75
|
+
const opts = parseArgs(process.argv.slice(3));
|
|
76
|
+
if (opts.help) {
|
|
77
|
+
console.log(HELP);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log(chalk.underline(chalk.cyan('Antelope CRM on-boarding\n')));
|
|
82
|
+
|
|
83
|
+
// Interactive only in a real terminal and when not forced non-interactive (CI / Ansible).
|
|
84
|
+
const interactive = Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
85
|
+
const rl = interactive ? readline.createInterface({ input: process.stdin, output: process.stdout }) : null;
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
const brandIdRaw = await resolve(opts, 'brandId', "Enter the brand's Antelope ID (e.g. xxxxx):\n", interactive, rl);
|
|
89
|
+
const brandName = await resolve(opts, 'brandName', "What is the new brand's name?\n", interactive, rl);
|
|
90
|
+
const connectedBrandName = brandIdRaw ? normalizeId(brandIdRaw) : '';
|
|
91
|
+
|
|
92
|
+
// Color is optional (empty => default palette).
|
|
93
|
+
const color = opts.color !== undefined
|
|
94
|
+
? opts.color
|
|
95
|
+
: (interactive ? await ask(rl, `Please set a color for "${connectedBrandName}", use hex value, leave empty for default.\n`) : '');
|
|
96
|
+
|
|
97
|
+
const logo = await resolve(opts, 'logo', 'Please enter the URL to the logo image suitable for a black background:\n', interactive, rl);
|
|
98
|
+
const favicon = await resolve(opts, 'favicon', 'Please provide the url to your favicon image:\n', interactive, rl);
|
|
99
|
+
const languagesInput = await resolve(opts, 'languages', 'Enter the languages (2-letter codes) separated by commas:\n', interactive, rl);
|
|
100
|
+
const fcmSenderId = await resolve(opts, 'fcmSenderId', 'Enter the FCMSenderId value (see https://xsites.atlassian.net/wiki/spaces/IKB/pages/777650347/Onboarding+Branding+Manual+for+devs#Firebase): ', interactive, rl);
|
|
101
|
+
const typeInput = await resolve(opts, 'type', `Enter the type value (allowed values: ${ALLOWED_TYPES.join(', ')}): `, interactive, rl);
|
|
102
|
+
|
|
103
|
+
// baseUrl is optional (defaults to the dev URL).
|
|
104
|
+
const baseUrl = opts.baseUrl !== undefined && opts.baseUrl !== ''
|
|
105
|
+
? opts.baseUrl
|
|
106
|
+
: (interactive ? (await ask(rl, `Enter the configs.ts baseUrl (leave empty for ${DEFAULT_BASE_URL}):\n`)) || DEFAULT_BASE_URL : DEFAULT_BASE_URL);
|
|
107
|
+
|
|
108
|
+
// Validate required fields.
|
|
109
|
+
const missing = [];
|
|
110
|
+
if (!connectedBrandName) missing.push('--brand_id');
|
|
111
|
+
if (!brandName) missing.push('--brand_name');
|
|
112
|
+
if (!logo) missing.push('--logo_url');
|
|
113
|
+
if (!favicon) missing.push('--favicon_url');
|
|
114
|
+
if (!languagesInput) missing.push('--languages');
|
|
115
|
+
if (!fcmSenderId) missing.push('--fcm_sender_id');
|
|
116
|
+
if (!typeInput) missing.push('--type');
|
|
117
|
+
if (missing.length) {
|
|
118
|
+
console.error(chalk.red(`Error: missing required value(s): ${missing.join(', ')}`));
|
|
119
|
+
console.log(HELP);
|
|
120
|
+
process.exitCode = 1;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const type = typeInput.toUpperCase();
|
|
125
|
+
if (!ALLOWED_TYPES.includes(type)) {
|
|
126
|
+
console.error(chalk.red(`Error: invalid --type "${typeInput}". Allowed: ${ALLOWED_TYPES.join(', ')}`));
|
|
127
|
+
process.exitCode = 1;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const languages = languagesInput.trim().split(',').map((l) => l.trim()).filter(Boolean);
|
|
132
|
+
if (!languages.length) {
|
|
133
|
+
console.error(chalk.red('Error: --languages must contain at least one 2-letter code.'));
|
|
134
|
+
process.exitCode = 1;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
brandModule.updateBrand({
|
|
139
|
+
brandId: connectedBrandName,
|
|
140
|
+
brandName,
|
|
141
|
+
connectedBrandName,
|
|
142
|
+
color: color || '',
|
|
143
|
+
logo,
|
|
144
|
+
languages,
|
|
145
|
+
favicon,
|
|
146
|
+
FCMSenderId: fcmSenderId,
|
|
147
|
+
type,
|
|
148
|
+
baseUrl
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
console.log(chalk.bold(chalk.yellow(`\nOnboarding "${brandName}" (id: ${connectedBrandName})`)));
|
|
152
|
+
console.log(chalk.bold(chalk.yellow('\nStep 1: Add to variables-colors.scss')));
|
|
153
|
+
await variablesColors.start();
|
|
154
|
+
console.log(chalk.bold(chalk.yellow('\nStep 2: Add to themes.scss')));
|
|
155
|
+
await themes.start();
|
|
156
|
+
console.log(chalk.bold(chalk.yellow('\nStep 3: Adding translations')));
|
|
157
|
+
await translations.start();
|
|
158
|
+
console.log(chalk.bold(chalk.yellow('\nStep 4: Editing the config file')));
|
|
159
|
+
await createConfig.start();
|
|
160
|
+
console.log(chalk.bold(chalk.yellow('\nStep 5: Recording in BRAND_LOCATIONS.md')));
|
|
161
|
+
await brandLocations.start();
|
|
162
|
+
console.log(chalk.green('\nCRM onboarding completed!'));
|
|
163
|
+
} catch (err) {
|
|
164
|
+
console.error(chalk.red(err) + '\n Please delete files and code added by this failed session.');
|
|
165
|
+
process.exitCode = 1;
|
|
166
|
+
} finally {
|
|
167
|
+
if (rl) rl.close();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
run();
|