hof 22.8.4 → 22.9.0-beta

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.
Files changed (326) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +30 -0
  3. package/config/hof-defaults.js +6 -1
  4. package/frontend/govuk-template/govuk_template_generated.html +102 -0
  5. package/frontend/template-partials/views/layout.html +2 -8
  6. package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -3
  7. package/hof-22.9.0.tgz +0 -0
  8. package/lib/settings.js +1 -0
  9. package/package/.eslintignore +1 -0
  10. package/package/CHANGELOG.md +232 -0
  11. package/package/LICENSE +21 -0
  12. package/package/README.md +1887 -0
  13. package/package/bin/hof-build +10 -0
  14. package/package/bin/hof-transpiler +12 -0
  15. package/package/build/helpers/importer.js +29 -0
  16. package/package/build/helpers/local.js +35 -0
  17. package/package/build/helpers/resolver/import.js +32 -0
  18. package/package/build/helpers/resolver/nearest-package-root.js +33 -0
  19. package/package/build/helpers/resolver/package.js +29 -0
  20. package/package/build/helpers/resolver.js +16 -0
  21. package/package/build/index.js +49 -0
  22. package/package/build/lib/env.js +36 -0
  23. package/package/build/lib/mkdir.js +9 -0
  24. package/package/build/lib/run.js +17 -0
  25. package/package/build/lib/spawn.js +18 -0
  26. package/package/build/tasks/browserify/compress.js +15 -0
  27. package/package/build/tasks/browserify/index.js +48 -0
  28. package/package/build/tasks/build/index.js +6 -0
  29. package/package/build/tasks/images/index.js +27 -0
  30. package/package/build/tasks/index.js +8 -0
  31. package/package/build/tasks/sass/index.js +67 -0
  32. package/package/build/tasks/translate/index.js +20 -0
  33. package/package/build/tasks/watch/index.js +161 -0
  34. package/package/components/address-lookup/default-model.js +76 -0
  35. package/package/components/address-lookup/defaults.js +25 -0
  36. package/package/components/address-lookup/index.js +251 -0
  37. package/package/components/address-lookup/templates/address-lookup.html +14 -0
  38. package/package/components/address-lookup/templates/address.html +22 -0
  39. package/package/components/address-lookup/templates/postcode.html +9 -0
  40. package/package/components/clear-session/Readme.md +46 -0
  41. package/package/components/clear-session/index.js +26 -0
  42. package/package/components/combine-and-loop-fields/Readme.md +42 -0
  43. package/package/components/combine-and-loop-fields/index.js +156 -0
  44. package/package/components/date/fields.js +16 -0
  45. package/package/components/date/index.js +172 -0
  46. package/package/components/date/templates/date.html +20 -0
  47. package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
  48. package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
  49. package/package/components/emailer/assets/images/spacer.gif +0 -0
  50. package/package/components/emailer/email-service.js +51 -0
  51. package/package/components/emailer/emailer.js +53 -0
  52. package/package/components/emailer/index.js +74 -0
  53. package/package/components/emailer/transports/debug.js +74 -0
  54. package/package/components/emailer/transports/index.js +8 -0
  55. package/package/components/emailer/transports/ses.js +36 -0
  56. package/package/components/emailer/transports/smtp.js +26 -0
  57. package/package/components/emailer/transports/stub.js +5 -0
  58. package/package/components/emailer/views/layout.html +63 -0
  59. package/package/components/homeoffice-countries/index.js +22 -0
  60. package/package/components/index.js +13 -0
  61. package/package/components/notify/index.js +62 -0
  62. package/package/components/notify/notify.js +51 -0
  63. package/package/components/session-timeout-warning/index.js +67 -0
  64. package/package/components/summary/index.js +237 -0
  65. package/package/config/builder-defaults.js +45 -0
  66. package/package/config/component-defaults.js +13 -0
  67. package/package/config/hof-defaults.js +65 -0
  68. package/package/config/rate-limits.js +20 -0
  69. package/package/config/sanitisation-rules.js +32 -0
  70. package/package/controller/base-controller.js +296 -0
  71. package/package/controller/behaviour-hooks.js +51 -0
  72. package/package/controller/behaviour-session.js +64 -0
  73. package/package/controller/controller.js +258 -0
  74. package/package/controller/deprecate-error.js +10 -0
  75. package/package/controller/formatting/formatters.js +70 -0
  76. package/package/controller/formatting/index.js +32 -0
  77. package/package/controller/index.js +17 -0
  78. package/package/controller/validation/email.js +30 -0
  79. package/package/controller/validation/index.js +101 -0
  80. package/package/controller/validation/validators.js +181 -0
  81. package/package/controller/validation-error.js +14 -0
  82. package/package/frontend/govuk-template/build/config.js +24 -0
  83. package/package/frontend/govuk-template/build/govuk_template.html +102 -0
  84. package/package/frontend/govuk-template/build/index.js +23 -0
  85. package/package/frontend/govuk-template/govuk_template_generated.html +102 -0
  86. package/package/frontend/govuk-template/index.js +29 -0
  87. package/package/frontend/index.js +9 -0
  88. package/package/frontend/template-mixins/mixins/helpers.js +103 -0
  89. package/package/frontend/template-mixins/mixins/index.js +37 -0
  90. package/package/frontend/template-mixins/mixins/render.js +12 -0
  91. package/package/frontend/template-mixins/mixins/template-mixins.js +520 -0
  92. package/package/frontend/template-mixins/partials/forms/checkbox-group.html +47 -0
  93. package/package/frontend/template-mixins/partials/forms/checkbox.html +16 -0
  94. package/package/frontend/template-mixins/partials/forms/input-submit.html +1 -0
  95. package/package/frontend/template-mixins/partials/forms/input-text-date.html +37 -0
  96. package/package/frontend/template-mixins/partials/forms/input-text-group.html +45 -0
  97. package/package/frontend/template-mixins/partials/forms/option-group.html +43 -0
  98. package/package/frontend/template-mixins/partials/forms/select.html +17 -0
  99. package/package/frontend/template-mixins/partials/forms/textarea-group.html +37 -0
  100. package/package/frontend/template-mixins/partials/mixins/panel.html +4 -0
  101. package/package/frontend/template-partials/index.js +9 -0
  102. package/package/frontend/template-partials/translations/index.js +26 -0
  103. package/package/frontend/template-partials/translations/src/cy/base.json +4 -0
  104. package/package/frontend/template-partials/translations/src/cy/buttons.json +6 -0
  105. package/package/frontend/template-partials/translations/src/cy/cookies.json +104 -0
  106. package/package/frontend/template-partials/translations/src/cy/errorlist.json +6 -0
  107. package/package/frontend/template-partials/translations/src/cy/errors.json +18 -0
  108. package/package/frontend/template-partials/translations/src/cy/terms.json +28 -0
  109. package/package/frontend/template-partials/translations/src/en/accessibility.json +43 -0
  110. package/package/frontend/template-partials/translations/src/en/base.json +5 -0
  111. package/package/frontend/template-partials/translations/src/en/buttons.json +10 -0
  112. package/package/frontend/template-partials/translations/src/en/cookies.json +116 -0
  113. package/package/frontend/template-partials/translations/src/en/errorlist.json +7 -0
  114. package/package/frontend/template-partials/translations/src/en/errors.json +35 -0
  115. package/package/frontend/template-partials/translations/src/en/exit.json +5 -0
  116. package/package/frontend/template-partials/translations/src/en/fields.json +5 -0
  117. package/package/frontend/template-partials/translations/src/en/journey.json +6 -0
  118. package/package/frontend/template-partials/translations/src/en/save-and-exit.json +4 -0
  119. package/package/frontend/template-partials/translations/src/en/terms.json +28 -0
  120. package/package/frontend/template-partials/views/404.html +9 -0
  121. package/package/frontend/template-partials/views/accessibility.html +55 -0
  122. package/package/frontend/template-partials/views/confirm.html +8 -0
  123. package/package/frontend/template-partials/views/confirmation.html +19 -0
  124. package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
  125. package/package/frontend/template-partials/views/cookie-error.html +1 -0
  126. package/package/frontend/template-partials/views/cookies.html +84 -0
  127. package/package/frontend/template-partials/views/email/data-row.html +4 -0
  128. package/package/frontend/template-partials/views/email/formatted.html +12 -0
  129. package/package/frontend/template-partials/views/email/layout.html +63 -0
  130. package/package/frontend/template-partials/views/email/raw.html +11 -0
  131. package/package/frontend/template-partials/views/email/section-row.html +3 -0
  132. package/package/frontend/template-partials/views/error.html +20 -0
  133. package/package/frontend/template-partials/views/exit.html +9 -0
  134. package/package/frontend/template-partials/views/feedback-submitted.html +11 -0
  135. package/package/frontend/template-partials/views/layout.html +55 -0
  136. package/package/frontend/template-partials/views/partials/analytics-table.html +25 -0
  137. package/package/frontend/template-partials/views/partials/back.html +5 -0
  138. package/package/frontend/template-partials/views/partials/bullet-list.html +7 -0
  139. package/package/frontend/template-partials/views/partials/confirmation-alert.html +6 -0
  140. package/package/frontend/template-partials/views/partials/continue.html +5 -0
  141. package/package/frontend/template-partials/views/partials/cookie-banner.html +29 -0
  142. package/package/frontend/template-partials/views/partials/cookie-notification.html +4 -0
  143. package/package/frontend/template-partials/views/partials/cookie-settings-button.html +1 -0
  144. package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +8 -0
  145. package/package/frontend/template-partials/views/partials/details-summary.html +8 -0
  146. package/package/frontend/template-partials/views/partials/external-link.html +1 -0
  147. package/package/frontend/template-partials/views/partials/form.html +10 -0
  148. package/package/frontend/template-partials/views/partials/gatag.html +60 -0
  149. package/package/frontend/template-partials/views/partials/head.html +31 -0
  150. package/package/frontend/template-partials/views/partials/heading.html +11 -0
  151. package/package/frontend/template-partials/views/partials/items-table.html +32 -0
  152. package/package/frontend/template-partials/views/partials/maincontent-left.html +10 -0
  153. package/package/frontend/template-partials/views/partials/navigation.html +8 -0
  154. package/package/frontend/template-partials/views/partials/page.html +23 -0
  155. package/package/frontend/template-partials/views/partials/panel-indent.html +3 -0
  156. package/package/frontend/template-partials/views/partials/session-cookies-table.html +28 -0
  157. package/package/frontend/template-partials/views/partials/session-timeout-warning.html +38 -0
  158. package/package/frontend/template-partials/views/partials/summary-table-row.html +14 -0
  159. package/package/frontend/template-partials/views/partials/summary-table.html +8 -0
  160. package/package/frontend/template-partials/views/partials/table.html +18 -0
  161. package/package/frontend/template-partials/views/partials/validation-list.html +3 -0
  162. package/package/frontend/template-partials/views/partials/validation-summary.html +25 -0
  163. package/package/frontend/template-partials/views/partials/warn.html +7 -0
  164. package/package/frontend/template-partials/views/rate-limit-error.html +10 -0
  165. package/package/frontend/template-partials/views/save-and-exit.html +17 -0
  166. package/package/frontend/template-partials/views/service-unavailable.html +13 -0
  167. package/package/frontend/template-partials/views/session-timeout.html +7 -0
  168. package/package/frontend/template-partials/views/step.html +14 -0
  169. package/package/frontend/template-partials/views/terms.html +26 -0
  170. package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +145 -0
  171. package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +121 -0
  172. package/package/frontend/themes/gov-uk/client-js/index.js +27 -0
  173. package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +348 -0
  174. package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +19 -0
  175. package/package/frontend/themes/gov-uk/index.js +9 -0
  176. package/package/frontend/themes/gov-uk/styles/_base.scss +17 -0
  177. package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +155 -0
  178. package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +111 -0
  179. package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +33 -0
  180. package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +23 -0
  181. package/package/frontend/themes/gov-uk/styles/_helpers.scss +5 -0
  182. package/package/frontend/themes/gov-uk/styles/_layout.scss +125 -0
  183. package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +27 -0
  184. package/package/frontend/themes/gov-uk/styles/_pdf.scss +42 -0
  185. package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +121 -0
  186. package/package/frontend/themes/gov-uk/styles/_typography.scss +27 -0
  187. package/package/frontend/themes/gov-uk/styles/_variables.scss +11 -0
  188. package/package/frontend/themes/gov-uk/styles/govuk.scss +43 -0
  189. package/package/frontend/themes/gov-uk/styles/mixins.scss +16 -0
  190. package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +73 -0
  191. package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +5 -0
  192. package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +8 -0
  193. package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +20 -0
  194. package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +5 -0
  195. package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +17 -0
  196. package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +51 -0
  197. package/package/frontend/themes/index.js +5 -0
  198. package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
  199. package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
  200. package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
  201. package/package/frontend/toolkit/assets/javascript/character-count.js +99 -0
  202. package/package/frontend/toolkit/assets/javascript/form-focus.js +101 -0
  203. package/package/frontend/toolkit/assets/javascript/helpers.js +177 -0
  204. package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +72 -0
  205. package/package/frontend/toolkit/assets/javascript/validation.js +71 -0
  206. package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +189 -0
  207. package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +39 -0
  208. package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +6 -0
  209. package/package/frontend/toolkit/assets/stylesheets/_base.scss +17 -0
  210. package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +5 -0
  211. package/package/frontend/toolkit/assets/stylesheets/_layout.scss +118 -0
  212. package/package/frontend/toolkit/assets/stylesheets/_typography.scss +27 -0
  213. package/package/frontend/toolkit/assets/stylesheets/_variables.scss +11 -0
  214. package/package/frontend/toolkit/assets/stylesheets/app.scss +30 -0
  215. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +47 -0
  216. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +38 -0
  217. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +175 -0
  218. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +167 -0
  219. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +39 -0
  220. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +67 -0
  221. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +40 -0
  222. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +29 -0
  223. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +33 -0
  224. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +33 -0
  225. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +63 -0
  226. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +39 -0
  227. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +63 -0
  228. package/package/frontend/toolkit/assets/stylesheets/mixins.scss +16 -0
  229. package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +73 -0
  230. package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +5 -0
  231. package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +20 -0
  232. package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +5 -0
  233. package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +17 -0
  234. package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +51 -0
  235. package/package/frontend/toolkit/index.js +10 -0
  236. package/package/index.js +351 -0
  237. package/package/lib/deindex.js +18 -0
  238. package/package/lib/encryption.js +23 -0
  239. package/package/lib/ga-tag.js +89 -0
  240. package/package/lib/health.js +26 -0
  241. package/package/lib/helpers.js +66 -0
  242. package/package/lib/logger.js +65 -0
  243. package/package/lib/markdown.js +46 -0
  244. package/package/lib/router.js +111 -0
  245. package/package/lib/serve-static.js +12 -0
  246. package/package/lib/sessions.js +82 -0
  247. package/package/lib/settings.js +74 -0
  248. package/package/lib/which.js +28 -0
  249. package/package/middleware/cookies.js +43 -0
  250. package/package/middleware/deep-translate.js +32 -0
  251. package/package/middleware/errors.js +119 -0
  252. package/package/middleware/index.js +10 -0
  253. package/package/middleware/not-found.js +38 -0
  254. package/package/middleware/rate-limiter.js +98 -0
  255. package/package/middleware/service-unavailable.js +64 -0
  256. package/package/model/apis/axios-settings.js +21 -0
  257. package/package/model/apis/html-to-pdf-converter.js +35 -0
  258. package/package/model/apis/index.js +5 -0
  259. package/package/model/index.js +348 -0
  260. package/package/package.json +147 -0
  261. package/package/sandbox/README.md +66 -0
  262. package/package/sandbox/apps/sandbox/behaviours/clear-session.js +8 -0
  263. package/package/sandbox/apps/sandbox/behaviours/country-select.js +10 -0
  264. package/package/sandbox/apps/sandbox/behaviours/international-number.js +22 -0
  265. package/package/sandbox/apps/sandbox/fields.js +128 -0
  266. package/package/sandbox/apps/sandbox/index.js +99 -0
  267. package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +189 -0
  268. package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +43 -0
  269. package/package/sandbox/apps/sandbox/translations/src/en/errors.json +5 -0
  270. package/package/sandbox/apps/sandbox/translations/src/en/exit.json +4 -0
  271. package/package/sandbox/apps/sandbox/translations/src/en/fields.json +101 -0
  272. package/package/sandbox/apps/sandbox/translations/src/en/journey.json +7 -0
  273. package/package/sandbox/apps/sandbox/translations/src/en/pages.json +72 -0
  274. package/package/sandbox/apps/sandbox/translations/src/en/validation.json +54 -0
  275. package/package/sandbox/apps/sandbox/views/form-guidance-link.html +8 -0
  276. package/package/sandbox/apps/sandbox/views/save-and-exit.html +19 -0
  277. package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
  278. package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
  279. package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
  280. package/package/sandbox/assets/js/index.js +70 -0
  281. package/package/sandbox/assets/scss/app.scss +27 -0
  282. package/package/sandbox/codecept.conf.js +15 -0
  283. package/package/sandbox/config.js +17 -0
  284. package/package/sandbox/package.json +26 -0
  285. package/package/sandbox/server.js +23 -0
  286. package/package/sandbox/yarn.lock +262 -0
  287. package/package/transpiler/index.js +2 -0
  288. package/package/transpiler/lib/aggregate.js +32 -0
  289. package/package/transpiler/lib/build.js +15 -0
  290. package/package/transpiler/lib/compile.js +12 -0
  291. package/package/transpiler/lib/expand-dirs.js +14 -0
  292. package/package/transpiler/lib/write-files.js +24 -0
  293. package/package/utilities/autofill/index.js +189 -0
  294. package/package/utilities/autofill/inputs.js +60 -0
  295. package/package/utilities/countries.js +12 -0
  296. package/package/utilities/helpers/index.js +189 -0
  297. package/package/utilities/index.js +9 -0
  298. package/package/utilities/reqres/index.js +18 -0
  299. package/package/utilities/test-data/data/domain.json +7 -0
  300. package/package/utilities/test-data/data/firstname.json +16 -0
  301. package/package/utilities/test-data/data/lastname.json +10 -0
  302. package/package/utilities/test-data/data/postcode.json +12 -0
  303. package/package/utilities/test-data/data/streetname.json +8 -0
  304. package/package/utilities/test-data/data/streetsuffix.json +7 -0
  305. package/package/utilities/test-data/data/town.json +9 -0
  306. package/package/utilities/test-data/index.js +67 -0
  307. package/package/wizard/behaviours/complete.js +20 -0
  308. package/package/wizard/behaviours/index.js +5 -0
  309. package/package/wizard/index.js +124 -0
  310. package/package/wizard/middleware/back-links.js +68 -0
  311. package/package/wizard/middleware/check-complete.js +13 -0
  312. package/package/wizard/middleware/check-progress.js +139 -0
  313. package/package/wizard/middleware/check-session.js +17 -0
  314. package/package/wizard/middleware/csrf.js +47 -0
  315. package/package/wizard/middleware/session-model.js +11 -0
  316. package/package/wizard/middleware/session.js +9 -0
  317. package/package/wizard/model.js +29 -0
  318. package/package/wizard/util/constants.js +5 -0
  319. package/package/wizard/util/helpers.js +19 -0
  320. package/package.json +5 -6
  321. package/.editorconfig +0 -10
  322. package/.github/workflows/automate-publish.yml +0 -38
  323. package/.github/workflows/automate-tag.yml +0 -78
  324. package/.istanbul.yml +0 -20
  325. package/codeReviewChecklist.md +0 -22
  326. package/pull_request_template.md +0 -16
@@ -0,0 +1,262 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ abbrev@1:
6
+ version "1.1.1"
7
+ resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
8
+ integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
9
+
10
+ anymatch@~3.1.2:
11
+ version "3.1.2"
12
+ resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
13
+ integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==
14
+ dependencies:
15
+ normalize-path "^3.0.0"
16
+ picomatch "^2.0.4"
17
+
18
+ balanced-match@^1.0.0:
19
+ version "1.0.2"
20
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
21
+ integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
22
+
23
+ binary-extensions@^2.0.0:
24
+ version "2.2.0"
25
+ resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
26
+ integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
27
+
28
+ brace-expansion@^1.1.7:
29
+ version "1.1.11"
30
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
31
+ integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
32
+ dependencies:
33
+ balanced-match "^1.0.0"
34
+ concat-map "0.0.1"
35
+
36
+ braces@~3.0.2:
37
+ version "3.0.3"
38
+ resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
39
+ integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
40
+ dependencies:
41
+ fill-range "^7.1.1"
42
+
43
+ "chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.2:
44
+ version "3.5.3"
45
+ resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
46
+ integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
47
+ dependencies:
48
+ anymatch "~3.1.2"
49
+ braces "~3.0.2"
50
+ glob-parent "~5.1.2"
51
+ is-binary-path "~2.1.0"
52
+ is-glob "~4.0.1"
53
+ normalize-path "~3.0.0"
54
+ readdirp "~3.6.0"
55
+ optionalDependencies:
56
+ fsevents "~2.3.2"
57
+
58
+ concat-map@0.0.1:
59
+ version "0.0.1"
60
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
61
+ integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
62
+
63
+ debug@^3.2.7:
64
+ version "3.2.7"
65
+ resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
66
+ integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
67
+ dependencies:
68
+ ms "^2.1.1"
69
+
70
+ fill-range@^7.1.1:
71
+ version "7.1.1"
72
+ resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
73
+ integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
74
+ dependencies:
75
+ to-regex-range "^5.0.1"
76
+
77
+ fsevents@~2.3.2:
78
+ version "2.3.2"
79
+ resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
80
+ integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
81
+
82
+ glob-parent@~5.1.2:
83
+ version "5.1.2"
84
+ resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
85
+ integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
86
+ dependencies:
87
+ is-glob "^4.0.1"
88
+
89
+ govuk-frontend@3.14:
90
+ version "3.14.0"
91
+ resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-3.14.0.tgz#d3a9c54437c08f5188f87b1f4480ba60e95c8eb6"
92
+ integrity sha512-y7FTuihCSA8Hty+e9h0uPhCoNanCAN+CLioNFlPmlbeHXpbi09VMyxTcH+XfnMPY4Cp++7096v0rLwwdapTXnA==
93
+
94
+ has-flag@^3.0.0:
95
+ version "3.0.0"
96
+ resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
97
+ integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==
98
+
99
+ ignore-by-default@^1.0.1:
100
+ version "1.0.1"
101
+ resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09"
102
+ integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==
103
+
104
+ immutable@^4.0.0:
105
+ version "4.1.0"
106
+ resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.1.0.tgz#f795787f0db780183307b9eb2091fcac1f6fafef"
107
+ integrity sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==
108
+
109
+ is-binary-path@~2.1.0:
110
+ version "2.1.0"
111
+ resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09"
112
+ integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==
113
+ dependencies:
114
+ binary-extensions "^2.0.0"
115
+
116
+ is-extglob@^2.1.1:
117
+ version "2.1.1"
118
+ resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
119
+ integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==
120
+
121
+ is-glob@^4.0.1, is-glob@~4.0.1:
122
+ version "4.0.3"
123
+ resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
124
+ integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
125
+ dependencies:
126
+ is-extglob "^2.1.1"
127
+
128
+ is-number@^7.0.0:
129
+ version "7.0.0"
130
+ resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
131
+ integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
132
+
133
+ jquery@>=1.11:
134
+ version "3.6.0"
135
+ resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
136
+ integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==
137
+
138
+ jquery@^3.7.1:
139
+ version "3.7.1"
140
+ resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de"
141
+ integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==
142
+
143
+ minimatch@^3.0.4:
144
+ version "3.1.2"
145
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
146
+ integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
147
+ dependencies:
148
+ brace-expansion "^1.1.7"
149
+
150
+ ms@^2.1.1:
151
+ version "2.1.3"
152
+ resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
153
+ integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
154
+
155
+ nodemon@^2.0.15:
156
+ version "2.0.19"
157
+ resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.19.tgz#cac175f74b9cb8b57e770d47841995eebe4488bd"
158
+ integrity sha512-4pv1f2bMDj0Eeg/MhGqxrtveeQ5/G/UVe9iO6uTZzjnRluSA4PVWf8CW99LUPwGB3eNIA7zUFoP77YuI7hOc0A==
159
+ dependencies:
160
+ chokidar "^3.5.2"
161
+ debug "^3.2.7"
162
+ ignore-by-default "^1.0.1"
163
+ minimatch "^3.0.4"
164
+ pstree.remy "^1.1.8"
165
+ semver "^5.7.1"
166
+ simple-update-notifier "^1.0.7"
167
+ supports-color "^5.5.0"
168
+ touch "^3.1.0"
169
+ undefsafe "^2.0.5"
170
+
171
+ nopt@~1.0.10:
172
+ version "1.0.10"
173
+ resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
174
+ integrity sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==
175
+ dependencies:
176
+ abbrev "1"
177
+
178
+ normalize-path@^3.0.0, normalize-path@~3.0.0:
179
+ version "3.0.0"
180
+ resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
181
+ integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
182
+
183
+ picomatch@^2.0.4, picomatch@^2.2.1:
184
+ version "2.3.1"
185
+ resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
186
+ integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
187
+
188
+ pstree.remy@^1.1.8:
189
+ version "1.1.8"
190
+ resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.8.tgz#c242224f4a67c21f686839bbdb4ac282b8373d3a"
191
+ integrity sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==
192
+
193
+ readdirp@~3.6.0:
194
+ version "3.6.0"
195
+ resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
196
+ integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
197
+ dependencies:
198
+ picomatch "^2.2.1"
199
+
200
+ sass@^1.53.0:
201
+ version "1.54.5"
202
+ resolved "https://registry.yarnpkg.com/sass/-/sass-1.54.5.tgz#93708f5560784f6ff2eab8542ade021a4a947b3a"
203
+ integrity sha512-p7DTOzxkUPa/63FU0R3KApkRHwcVZYC0PLnLm5iyZACyp15qSi32x7zVUhRdABAATmkALqgGrjCJAcWvobmhHw==
204
+ dependencies:
205
+ chokidar ">=3.0.0 <4.0.0"
206
+ immutable "^4.0.0"
207
+ source-map-js ">=0.6.2 <2.0.0"
208
+
209
+ semver@^5.7.1:
210
+ version "5.7.2"
211
+ resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
212
+ integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
213
+
214
+ semver@~7.0.0:
215
+ version "7.0.0"
216
+ resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
217
+ integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
218
+
219
+ simple-update-notifier@^1.0.7:
220
+ version "1.0.7"
221
+ resolved "https://registry.yarnpkg.com/simple-update-notifier/-/simple-update-notifier-1.0.7.tgz#7edf75c5bdd04f88828d632f762b2bc32996a9cc"
222
+ integrity sha512-BBKgR84BJQJm6WjWFMHgLVuo61FBDSj1z/xSFUIozqO6wO7ii0JxCqlIud7Enr/+LhlbNI0whErq96P2qHNWew==
223
+ dependencies:
224
+ semver "~7.0.0"
225
+
226
+ "source-map-js@>=0.6.2 <2.0.0":
227
+ version "1.0.2"
228
+ resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
229
+ integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
230
+
231
+ supports-color@^5.5.0:
232
+ version "5.5.0"
233
+ resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
234
+ integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
235
+ dependencies:
236
+ has-flag "^3.0.0"
237
+
238
+ to-regex-range@^5.0.1:
239
+ version "5.0.1"
240
+ resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
241
+ integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
242
+ dependencies:
243
+ is-number "^7.0.0"
244
+
245
+ touch@^3.1.0:
246
+ version "3.1.0"
247
+ resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b"
248
+ integrity sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==
249
+ dependencies:
250
+ nopt "~1.0.10"
251
+
252
+ typeahead-aria@^1.0.4:
253
+ version "1.0.4"
254
+ resolved "https://registry.yarnpkg.com/typeahead-aria/-/typeahead-aria-1.0.4.tgz#d2829cc01c0226a367627f3098a468c4e0343f00"
255
+ integrity sha512-6g0XtcM1AiPMlyXOuAb90Lg0WGi9PdbH68La7kUJmZwxUdpE80IC6tewBg0a/ug1Betoz1xCfEqTgkhuN6wo4w==
256
+ dependencies:
257
+ jquery ">=1.11"
258
+
259
+ undefsafe@^2.0.5:
260
+ version "2.0.5"
261
+ resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
262
+ integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
@@ -0,0 +1,2 @@
1
+ module.exports = require('./lib/compile');
2
+ module.exports.aggregate = require('./lib/aggregate');
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const mapValues = require('lodash').mapValues;
6
+
7
+ /**
8
+ * Traverse over a directory and build an object containing all the translations within that directory
9
+ */
10
+
11
+ module.exports = (dir, nsp) => {
12
+ const namespace = nsp || 'default';
13
+
14
+ const langs = fs.readdirSync(dir);
15
+
16
+ const resources = langs.reduce((map, lang) => {
17
+ const stat = fs.statSync(path.resolve(dir, lang));
18
+ if (stat.isDirectory()) {
19
+ map[lang] = { default: {} };
20
+ const files = fs.readdirSync(path.resolve(dir, lang));
21
+ files.forEach(file => {
22
+ if (path.extname(file) === '.json') {
23
+ const name = path.basename(file, '.json');
24
+ map[lang].default[name] = require(path.resolve(dir, lang, file));
25
+ }
26
+ });
27
+ }
28
+ return map;
29
+ }, {});
30
+
31
+ return mapValues(resources, lang => ({ [namespace]: lang.default }));
32
+ };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const expand = require('./expand-dirs');
4
+ const aggregate = require('./aggregate');
5
+ const _ = require('lodash');
6
+
7
+ module.exports = options => {
8
+ const directories = expand(options.sources);
9
+ const shared = expand([].concat(options.shared || [])).map(dir => aggregate(dir));
10
+
11
+ return _.zipObject(directories, directories.map(dir => {
12
+ const inputs = [{}].concat(shared).concat([aggregate(dir)]);
13
+ return _.merge.apply(null, inputs);
14
+ }));
15
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ const build = require('./build');
4
+ const write = require('./write-files');
5
+
6
+ module.exports = options => {
7
+ const output = build(options);
8
+
9
+ Object.keys(output).forEach(dir => {
10
+ write(dir, output[dir]);
11
+ });
12
+ };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const glob = require('glob');
4
+ const flatten = require('lodash').flatten;
5
+ const path = require('path');
6
+
7
+ /**
8
+ * Takes an array of globs and returns an array of absolute paths of matching directories
9
+ */
10
+
11
+ module.exports = gls => {
12
+ const globs = gls || [];
13
+ return flatten(globs.map(dir => glob.sync(dir))).map(dir => path.resolve(process.cwd(), dir));
14
+ };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const rm = require('rimraf').sync;
6
+
7
+ const debug = require('debug')('hof:transpiler');
8
+
9
+ module.exports = (dir, data) => {
10
+ const langs = Object.keys(data);
11
+
12
+ debug(`Compiled content from ${dir} in ${langs.join(', ')}`);
13
+
14
+ langs.forEach(lang => {
15
+ const outputDir = path.resolve(dir, '..', lang);
16
+ rm(outputDir);
17
+ debug(`Emptied directory ${outputDir}`);
18
+ fs.mkdirSync(outputDir);
19
+ debug(`Made directory ${outputDir}`);
20
+ Object.keys(data[lang]).forEach(namespace => {
21
+ fs.writeFileSync(path.resolve(outputDir, `${namespace}.json`), JSON.stringify(data[lang][namespace], null, ' '));
22
+ });
23
+ });
24
+ };
@@ -0,0 +1,189 @@
1
+ /* eslint-disable consistent-return, node/no-deprecated-api */
2
+ 'use strict';
3
+
4
+ const url = require('url');
5
+ const Inputs = require('./inputs');
6
+ const Promise = require('bluebird');
7
+
8
+ const debug = require('debug')('hof:util:autofill');
9
+
10
+ const MAX_LOOPS = 3;
11
+
12
+ module.exports = browser => (target, input, opts) => {
13
+ const options = opts || {};
14
+ options.maxLoops = options.maxLoops || MAX_LOOPS;
15
+
16
+ const getValue = Inputs(input);
17
+
18
+ let last;
19
+ let count = 0;
20
+
21
+ function completeTextField(element, name) {
22
+ const value = getValue(name, 'text');
23
+ debug(`Filling field: ${name} with value: ${value}`);
24
+ return browser
25
+ .elementIdClear(element)
26
+ .elementIdValue(element, value)
27
+ .catch(() => {
28
+ // any error here is *probably* because the field is hidden
29
+ // ignore and hope for the best
30
+ });
31
+ }
32
+
33
+ function completeFileField(element, name) {
34
+ const value = getValue(name, 'file');
35
+ if (value) {
36
+ debug(`Uploading file: ${value}`);
37
+ return browser.uploadFile(value)
38
+ .then(response => {
39
+ debug(`Uploaded file: ${value} - remote path ${response.value}`);
40
+ return browser
41
+ .addValue(`input[name="${name}"]`, response.value);
42
+ });
43
+ }
44
+ debug(`No file specified for input ${name} - ignoring`);
45
+ }
46
+
47
+ function completeRadio(element, name) {
48
+ const value = getValue(name, 'radio');
49
+ if (!value) {
50
+ return browser.elements(`input[type="radio"][name="${name}"]`)
51
+ .then(radios => {
52
+ debug(`Checking random radio: ${name}`);
53
+ const index = 1 + Math.floor(Math.random() * (radios.value.length - 1));
54
+ return browser.elementIdClick(radios.value[index].ELEMENT);
55
+ });
56
+ }
57
+ return browser.elementIdAttribute(element, 'value')
58
+ .then(val => {
59
+ if (val.value === value) {
60
+ debug(`Checking radio: ${name} with value: ${val.value}`);
61
+ browser.elementIdClick(element);
62
+ }
63
+ });
64
+ }
65
+
66
+ function completeCheckbox(element, name) {
67
+ const value = getValue(name, 'checkbox');
68
+ return browser.elementIdAttribute(element, 'value')
69
+ .then(val => browser.elementIdAttribute(element, 'checked')
70
+ .then(checked => {
71
+ if (value === null) {
72
+ if (!checked.value) {
73
+ debug(`Leaving checkbox: ${name} blank`);
74
+ return;
75
+ }
76
+ debug(`Unchecking checkbox: ${name}`);
77
+ return browser.elementIdClick(element);
78
+ }
79
+ if (!value && !checked.value) {
80
+ debug(`Checking checkbox: ${name} with value: ${val.value}`);
81
+ return browser.elementIdClick(element);
82
+ } else if (value && value.indexOf(val.value) > -1 && !checked.value) {
83
+ debug(`Checking checkbox: ${name} with value: ${val.value}`);
84
+ return browser.elementIdClick(element);
85
+ } else if (value && value.indexOf(val.value) === -1 && checked.value) {
86
+ debug(`Unchecking checkbox: ${name} with value: ${val.value}`);
87
+ return browser.elementIdClick(element);
88
+ }
89
+ debug(`Ignoring checkbox: ${name} with value: ${val.value} - looking for ${value}`);
90
+ }));
91
+ }
92
+
93
+ function completeSelectElement(element, name) {
94
+ const value = getValue(name, 'select');
95
+ if (!value) {
96
+ return browser.elementIdElements(element, 'option')
97
+ .then(o => {
98
+ const index = 1 + Math.floor(Math.random() * (o.value.length - 1));
99
+ debug(`Selecting option: ${index} from select box: ${name}`);
100
+ return browser.selectByIndex(`select[name="${name}"]`, index);
101
+ });
102
+ }
103
+ debug(`Selecting options: ${value} from select box: ${name}`);
104
+ return browser.selectByValue(`select[name="${name}"]`, value);
105
+ }
106
+
107
+ function completeStep(path) {
108
+ return browser
109
+ .elements('input')
110
+ .then(fields => {
111
+ debug(`Found ${fields.value.length} <input> elements`);
112
+ return Promise.map(fields.value, field => browser.elementIdAttribute(field.ELEMENT, 'type')
113
+ .then(type => browser.elementIdAttribute(field.ELEMENT, 'name')
114
+ .then(name => {
115
+ if (type.value === 'radio') {
116
+ return completeRadio(field.ELEMENT, name.value);
117
+ } else if (type.value === 'checkbox') {
118
+ return completeCheckbox(field.ELEMENT, name.value);
119
+ } else if (type.value === 'file') {
120
+ return completeFileField(field.ELEMENT, name.value);
121
+ } else if (type.value === 'text') {
122
+ return completeTextField(field.ELEMENT, name.value);
123
+ }
124
+ debug(`Ignoring field of type ${type.value}`);
125
+ })), {concurrency: 1});
126
+ })
127
+ .elements('select')
128
+ .then(fields => {
129
+ debug(`Found ${fields.value.length} <select> elements`);
130
+ return Promise.map(fields.value, field => browser.elementIdAttribute(field.ELEMENT, 'name')
131
+ .then(name => completeSelectElement(field.ELEMENT, name.value)));
132
+ })
133
+ .elements('textarea')
134
+ .then(fields => {
135
+ debug(`Found ${fields.value.length} <textarea> elements`);
136
+ return Promise.map(fields.value, field => browser.elementIdAttribute(field.ELEMENT, 'name')
137
+ .then(name => completeTextField(field.ELEMENT, name.value)));
138
+ })
139
+ .then(() => {
140
+ if (options.screenshots) {
141
+ const screenshot = require('path').resolve(options.screenshots, 'hof-autofill.pre-submit.png');
142
+ return browser.saveScreenshot(screenshot);
143
+ }
144
+ })
145
+ .then(() => {
146
+ debug('Submitting form');
147
+ return browser.$('input[type="submit"]').click();
148
+ })
149
+ .then(() => browser.getUrl()
150
+ .then(p => {
151
+ const u = url.parse(p);
152
+ debug(`New page is: ${u.path}`);
153
+ if (u.path !== path) {
154
+ debug(`Checking current path ${u.path} against last path ${last}`);
155
+ if (last === u.path) {
156
+ count++;
157
+ debug(`Stuck on path ${u.path} for ${count} iterations`);
158
+ if (count === options.maxLoops) {
159
+ if (options.screenshots) {
160
+ const screenshot = require('path').resolve(options.screenshots, 'hof-autofill.debug.png');
161
+ return browser.saveScreenshot(screenshot)
162
+ .then(() => {
163
+ throw new Error(`Progress stuck at ${u.path} - screenshot saved to ${screenshot}`);
164
+ });
165
+ }
166
+ throw new Error(`Progress stuck at ${u.path}`);
167
+ }
168
+ } else {
169
+ count = 0;
170
+ }
171
+ last = u.path;
172
+ return completeStep(path);
173
+ }
174
+ debug(`Arrived at ${path}. Done.`);
175
+ }))
176
+ .catch(e => browser.getText('#content')
177
+ .then(text => {
178
+ debug('PAGE CONTENT >>>>>>');
179
+ debug(text);
180
+ debug('END PAGE CONTENT >>>>>>');
181
+ })
182
+ .catch(() => null)
183
+ .then(() => {
184
+ throw e;
185
+ }));
186
+ }
187
+
188
+ return completeStep(target);
189
+ };
@@ -0,0 +1,60 @@
1
+ /* eslint-disable consistent-return */
2
+ 'use strict';
3
+ /* eslint complexity: 0 */
4
+
5
+ const Data = require('../test-data');
6
+
7
+ module.exports = i => {
8
+ const input = i || {};
9
+ input.default = input.default || 'abc';
10
+
11
+ const getDefault = (name, t) => {
12
+ const type = t || 'text';
13
+ if (name.indexOf('name') > -1) {
14
+ if (name.indexOf('last') > -1 || name.indexOf('surname') > -1) {
15
+ return Data.lastname;
16
+ }
17
+ if (name.indexOf('first') > -1) {
18
+ return Data.firstname;
19
+ }
20
+ return Data.name;
21
+ }
22
+ if (name.indexOf('country') > -1 || name.indexOf('nationality') > -1) {
23
+ return Data.country;
24
+ }
25
+ if (name.indexOf('postcode') > -1) {
26
+ return Data.postcode;
27
+ }
28
+ if (name.indexOf('day') > -1) {
29
+ return Data.number(1, 28).toString();
30
+ }
31
+ if (name.indexOf('month') > -1) {
32
+ return Data.number(1, 12).toString();
33
+ }
34
+ if (name.indexOf('year') > -1) {
35
+ return Data.number(1950, 1990).toString();
36
+ }
37
+
38
+ if (name.indexOf('email') > -1) {
39
+ return Data.email;
40
+ }
41
+ if (name.indexOf('phone') > -1) {
42
+ return Data.phone;
43
+ }
44
+ // don't provide a default value for field types with defined options
45
+ if (['select', 'radio', 'checkbox', 'file'].indexOf(type) === -1) {
46
+ return input.default;
47
+ }
48
+ };
49
+
50
+ return (name, type) => {
51
+ const value = input[name] !== undefined ? input[name] : getDefault(name, type);
52
+ if (typeof value === 'function') {
53
+ return value();
54
+ }
55
+ if (value && type === 'checkbox') {
56
+ return [].concat(value);
57
+ }
58
+ return value;
59
+ };
60
+ };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ const countries = require('homeoffice-countries');
4
+
5
+ const transform = (list, options) => {
6
+ const opts = options || {};
7
+ const parse = opts.parse || (country => country);
8
+ const filter = opts.filter || (() => true);
9
+ return list.filter(filter).map(country => ({ value: country, label: parse(country) }));
10
+ };
11
+
12
+ module.exports = options => transform(countries.allCountries, options);