()
| 33 | }; |
| 34 | |
| 35 | const generatePatterns = function() { |
| 36 | const framework = Helpers.getFramework({ useOutputData: true }); |
| 37 | const data = framework.getData(); |
| 38 | |
| 39 | try { |
| 40 | const configJson = data.getConfigFileItem().item; |
| 41 | const defaultLanguage = configJson._defaultLanguage || 'en'; |
| 42 | const courseJson = data.getLanguage(defaultLanguage).getCourseFileItem().item; |
| 43 | |
| 44 | // Backwards compatibility for courses missing 'description' |
| 45 | if (!courseJson.hasOwnProperty('description')) { |
| 46 | courseJson.description = ''; |
| 47 | } |
| 48 | |
| 49 | // A shim for edge cases where xAPI has not been configured. |
| 50 | if (!configJson.hasOwnProperty('_xapi')) { |
| 51 | configJson._xapi = { |
| 52 | _activityID: '', |
| 53 | _isEnabled: false |
| 54 | }; |
| 55 | } else { |
| 56 | // xAPI has been enabled, check if the activityID has been set. |
| 57 | if (configJson._xapi.hasOwnProperty('_activityID') && configJson._xapi._activityID === '') { |
| 58 | grunt.log.writeln('WARNING: xAPI activityID has not been set'); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Shim to preserve the 'adapt_manifest' identifier. |
| 63 | const spoor = configJson._spoor; |
| 64 | if (spoor) { |
| 65 | spoor._advancedSettings = spoor._advancedSettings || {}; |
| 66 | spoor._advancedSettings._manifestIdentifier = spoor._advancedSettings._manifestIdentifier || 'adapt_manifest'; |
| 67 | } |
| 68 | |
| 69 | // Combine the course, config and build JSON to pass to replace. |
| 70 | return { |
| 71 | course: filterNullValues(courseJson), |
| 72 | config: filterNullValues(configJson), |
| 73 | build: filterNullValues(Helpers.generateConfigData()) |
| 74 | }; |
| 75 | } catch (ex) { |
| 76 | return {}; |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | return { |
| 81 | dist: { |
no test coverage detected