mod-build 3.6.39 → 3.6.40-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.6.40
4
+
5
+ - added functionality to fetch & merge default form filed config in templateData
6
+
3
7
  ## 3.6.39
4
8
 
5
9
  - implementing a buffer to our `grab-shared-scripts` task, which fixes the hashing issue we were facing for our larger files. updated the hashing algorithm to MD5, so it matches our CircleCI CLI hash. updated `mod-form-beta.min.js` to `homeowner.min.js`
@@ -1,4 +1,5 @@
1
1
  var merge = require('lodash.merge');
2
+ var request = require('request');
2
3
 
3
4
  module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
4
5
  // Merge site's data with shared data
@@ -144,7 +145,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
144
145
  fn: function(obj) {
145
146
  var output = '';
146
147
  var ignoreKeys = Array.prototype.slice.call(arguments, 1, -1);
147
-
148
+
148
149
  for (var key in obj.attributes) {
149
150
  if (ignoreKeys.indexOf(key) === -1) {
150
151
  if (typeof obj.attributes[key] !== 'object') {
@@ -165,7 +166,36 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
165
166
  }
166
167
  ];
167
168
 
168
- return function() {
169
+ var getDefaultFormFieldConfig = async function() {
170
+ const siteData = templatesData;
171
+ await new Promise((resolve) => {
172
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/input/defaultFormFieldConfig.json`, async function(err, xhr, response) {
173
+ if (xhr.statusCode !== 200) {
174
+ throw new Error(`${xhr.statusCode}: Error while fetching shared-components/defaultFormFieldConfig.json`);
175
+ }
176
+ if (!siteData.steps) {
177
+ throw new Error('steps not found!');
178
+ }
179
+ response = await JSON.parse(response);
180
+ siteData.steps.items.forEach(item => {
181
+ item.fields = item.fields.map(field => {
182
+ if (field.name && response[field.name]) {
183
+ field = Object.assign(response[field.name], field);
184
+ }
185
+ return field;
186
+ });
187
+ });
188
+ resolve();
189
+ })
190
+ });
191
+ return siteData;
192
+ };
193
+
194
+ return async function() {
195
+ if (!templatesData.doNotUseDefaultFieldConfig) {
196
+ await getDefaultFormFieldConfig();
197
+ }
198
+
169
199
  return gulp.src([
170
200
  siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html',
171
201
  '!' + siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/_partials/**/*.html'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.39",
3
+ "version": "3.6.40-beta.2",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",