mod-build 3.7.15-beta.2 → 3.7.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.7.15
4
+
5
+ - Added the Clients List modal to be grabbed as part of the `grab-cdn` task.
6
+
3
7
  ## 3.7.14
4
8
 
5
9
  - Added trade steps configs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.7.15-beta.2",
3
+ "version": "3.7.15",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/tasks/grab-cdn.js DELETED
@@ -1,130 +0,0 @@
1
- import { defaultSettings } from '../src/data/config.js';
2
- import axios from 'axios';
3
- import { createWriteStream } from 'node:fs';
4
- import * as stream from 'node:stream';
5
- import { promisify } from 'node:util';
6
- import fs from 'node:fs';
7
- import path from 'node:path';
8
- import { responseInterceptor } from '../src/scripts/retry-axios.js';
9
-
10
- const axiosInstance = axios.create();
11
- responseInterceptor(axiosInstance);
12
-
13
- async function duplicateHtmlFilestoHbs(externalResources) {
14
- for (const inputPath in externalResources) {
15
- const [destPath, fileName] = externalResources[inputPath];
16
- const fileExtension = path.extname(fileName);
17
-
18
- if (fileExtension === '.html') {
19
- const newFileName = fileName.replace('.html', '.hbs');
20
- const sourceFilePath = path.join(destPath, fileName);
21
- const destinationFilePath = path.join(destPath, newFileName);
22
-
23
- if (fs.existsSync(sourceFilePath) && !fs.existsSync(destinationFilePath)) {
24
- fs.copyFileSync(sourceFilePath, destinationFilePath);
25
- console.log(`${sourceFilePath} duplicated as ${destinationFilePath}`);
26
- }
27
- }
28
- }
29
- }
30
-
31
- function streamToDestination(inputPath, destPath, fileName) {
32
- const finished = promisify(stream.finished);
33
- const url = `https://${defaultSettings.nodeEnv}${inputPath}`;
34
-
35
- return new Promise(resolve => {
36
- if (!fs.existsSync(`${destPath}`)) {
37
- fs.mkdirSync(`${destPath}`, { recursive: true });
38
- }
39
-
40
- // if file exists, do not create it again
41
- if (fs.existsSync(`${destPath}${fileName}`)) {
42
- resolve();
43
- } else {
44
- const writer = createWriteStream(`${destPath}${fileName}`);
45
- const options = {
46
- url,
47
- method: 'get',
48
- responseType: 'stream',
49
- };
50
-
51
- axiosInstance(options).then(resp => {
52
- if (resp.status !== 200) {
53
- throw new Error(`${resp.status}: Error while fetching ${url}`);
54
- }
55
- resp.data.pipe(writer);
56
- console.log(`${destPath}${fileName} created...`);
57
- return finished(writer);
58
- }).then(() => {
59
- resolve();
60
- }).catch(error => {
61
- console.error(error);
62
- process.exit(1);
63
- }).finally(() => {
64
- axiosInstance.interceptors.response.eject(responseInterceptor);
65
- });
66
- }
67
- });
68
- }
69
-
70
- export default async function(config) {
71
- const { nodeEnv, srcFolder, publicFolder } = defaultSettings;
72
- const { isQSPage, isWhiteLabel, page } = config;
73
- const themeFile = page?.themeFile;
74
- const cssThemes = page?.cssThemes;
75
- const isModWhiteLabel = isWhiteLabel && !isQSPage
76
- const domainHasModernize = config?.domain?.indexOf('modernize') > -1 && !(config?.domain?.includes('bestcompany'));
77
-
78
- let externalResources;
79
- // listing of Static Resources sub-path and site destination paths
80
- // key: inputPath, value: destPath
81
-
82
- externalResources = {
83
- '/quote/resources/mod-site/templates/scripts/trusted-form.html': [`${publicFolder}/resources/scripts/`, 'trusted-form.html'],
84
- '/quote/resources/shared-resources/scripts/geolocation/geolocation.min.js': [`${publicFolder}/resources/scripts/geolocation/`, 'geolocation.min.js'],
85
- '/quote/resources/data/tcpa.json': [`${srcFolder}/resources/data/`, 'tcpa.json']
86
- };
87
-
88
- // grab footer modals and place under the resources
89
- Object.assign(externalResources, {
90
- '/quote/resources/shared-resources/templates/modals/about/': [`${srcFolder}/resources/templates/modals/about/`, 'index.html'],
91
- '/quote/resources/shared-resources/templates/modals/privacy/': [`${srcFolder}/resources/templates/modals/privacy/`, 'index.html'],
92
- '/quote/resources/shared-resources/templates/modals/terms/': [`${srcFolder}/resources/templates/modals/terms/`, 'index.html'],
93
- '/quote/resources/shared-resources/templates/modals/contact-us/': [`${srcFolder}/resources/templates/modals/contact-us/`, 'index.html'],
94
- '/quote/resources/shared-resources/templates/modals/faq/': [`${srcFolder}/resources/templates/modals/faq/`, 'index.html'],
95
- '/quote/resources/shared-resources/templates/modals/e-sign-consent/': [`${srcFolder}/resources/templates/modals/e-sign-consent/`, 'index.html'],
96
- '/quote/resources/shared-resources/templates/modals/clients/': [`${srcFolder}/resources/templates/modals/clients/`, 'index.html']
97
- })
98
-
99
- if (isModWhiteLabel || domainHasModernize) {
100
- Object.assign(externalResources, {'/quote/resources/mod-site/templates/scripts/recaptcha.html': [`${publicFolder}/resources/scripts/`, 'recaptcha.html']});
101
- }
102
-
103
- if (cssThemes && cssThemes.length > 0) {
104
- cssThemes.forEach(theme => {
105
- const themeFileName = `_${theme}.scss`;
106
- const themePath = `/quote/resources/shared-resources/styles/themes/${themeFileName}`;
107
- Object.assign(externalResources, {[themePath]: [`${srcFolder}/resources/styles/themes/`, themeFileName]});
108
- });
109
- }
110
-
111
- // theme JSON
112
- if (isQSPage && themeFile) {
113
- Object.assign(externalResources, {
114
- [`/quote/resources/data/themes/${themeFile}.json`]: [`${srcFolder}/data/`, 'theme.json']
115
- });
116
- }
117
-
118
- if (!nodeEnv) {
119
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
120
- }
121
-
122
- const filesPromiseMap = Object.keys(externalResources).map(async key => {
123
- const destinationPath = externalResources[key][0];
124
- const fileName = externalResources[key][1];
125
- await streamToDestination(key, destinationPath, fileName);
126
- });
127
-
128
- await Promise.all(filesPromiseMap);
129
- await duplicateHtmlFilestoHbs(externalResources);
130
- }