hof 22.8.4-unhandled-error-fix-beta.1 → 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.
- package/CHANGELOG.md +16 -0
- package/README.md +30 -0
- package/config/hof-defaults.js +6 -1
- package/frontend/template-partials/views/layout.html +2 -8
- package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -3
- package/hof-22.9.0.tgz +0 -0
- package/lib/settings.js +1 -0
- package/model/index.js +1 -1
- package/package/.eslintignore +1 -0
- package/package/CHANGELOG.md +232 -0
- package/package/LICENSE +21 -0
- package/package/README.md +1887 -0
- package/package/bin/hof-build +10 -0
- package/package/bin/hof-transpiler +12 -0
- package/package/build/helpers/importer.js +29 -0
- package/package/build/helpers/local.js +35 -0
- package/package/build/helpers/resolver/import.js +32 -0
- package/package/build/helpers/resolver/nearest-package-root.js +33 -0
- package/package/build/helpers/resolver/package.js +29 -0
- package/package/build/helpers/resolver.js +16 -0
- package/package/build/index.js +49 -0
- package/package/build/lib/env.js +36 -0
- package/package/build/lib/mkdir.js +9 -0
- package/package/build/lib/run.js +17 -0
- package/package/build/lib/spawn.js +18 -0
- package/package/build/tasks/browserify/compress.js +15 -0
- package/package/build/tasks/browserify/index.js +48 -0
- package/package/build/tasks/build/index.js +6 -0
- package/package/build/tasks/images/index.js +27 -0
- package/package/build/tasks/index.js +8 -0
- package/package/build/tasks/sass/index.js +67 -0
- package/package/build/tasks/translate/index.js +20 -0
- package/package/build/tasks/watch/index.js +161 -0
- package/package/components/address-lookup/default-model.js +76 -0
- package/package/components/address-lookup/defaults.js +25 -0
- package/package/components/address-lookup/index.js +251 -0
- package/package/components/address-lookup/templates/address-lookup.html +14 -0
- package/package/components/address-lookup/templates/address.html +22 -0
- package/package/components/address-lookup/templates/postcode.html +9 -0
- package/package/components/clear-session/Readme.md +46 -0
- package/package/components/clear-session/index.js +26 -0
- package/package/components/combine-and-loop-fields/Readme.md +42 -0
- package/package/components/combine-and-loop-fields/index.js +156 -0
- package/package/components/date/fields.js +16 -0
- package/package/components/date/index.js +172 -0
- package/package/components/date/templates/date.html +20 -0
- package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
- package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
- package/package/components/emailer/assets/images/spacer.gif +0 -0
- package/package/components/emailer/email-service.js +51 -0
- package/package/components/emailer/emailer.js +53 -0
- package/package/components/emailer/index.js +74 -0
- package/package/components/emailer/transports/debug.js +74 -0
- package/package/components/emailer/transports/index.js +8 -0
- package/package/components/emailer/transports/ses.js +36 -0
- package/package/components/emailer/transports/smtp.js +26 -0
- package/package/components/emailer/transports/stub.js +5 -0
- package/package/components/emailer/views/layout.html +63 -0
- package/package/components/homeoffice-countries/index.js +22 -0
- package/package/components/index.js +13 -0
- package/package/components/notify/index.js +62 -0
- package/package/components/notify/notify.js +51 -0
- package/package/components/session-timeout-warning/index.js +67 -0
- package/package/components/summary/index.js +237 -0
- package/package/config/builder-defaults.js +45 -0
- package/package/config/component-defaults.js +13 -0
- package/package/config/hof-defaults.js +65 -0
- package/package/config/rate-limits.js +20 -0
- package/package/config/sanitisation-rules.js +32 -0
- package/package/controller/base-controller.js +296 -0
- package/package/controller/behaviour-hooks.js +51 -0
- package/package/controller/behaviour-session.js +64 -0
- package/package/controller/controller.js +258 -0
- package/package/controller/deprecate-error.js +10 -0
- package/package/controller/formatting/formatters.js +70 -0
- package/package/controller/formatting/index.js +32 -0
- package/package/controller/index.js +17 -0
- package/package/controller/validation/email.js +30 -0
- package/package/controller/validation/index.js +101 -0
- package/package/controller/validation/validators.js +181 -0
- package/package/controller/validation-error.js +14 -0
- package/package/frontend/govuk-template/build/config.js +24 -0
- package/package/frontend/govuk-template/build/govuk_template.html +102 -0
- package/package/frontend/govuk-template/build/index.js +23 -0
- package/package/frontend/govuk-template/govuk_template_generated.html +102 -0
- package/package/frontend/govuk-template/index.js +29 -0
- package/package/frontend/index.js +9 -0
- package/package/frontend/template-mixins/mixins/helpers.js +103 -0
- package/package/frontend/template-mixins/mixins/index.js +37 -0
- package/package/frontend/template-mixins/mixins/render.js +12 -0
- package/package/frontend/template-mixins/mixins/template-mixins.js +520 -0
- package/package/frontend/template-mixins/partials/forms/checkbox-group.html +47 -0
- package/package/frontend/template-mixins/partials/forms/checkbox.html +16 -0
- package/package/frontend/template-mixins/partials/forms/input-submit.html +1 -0
- package/package/frontend/template-mixins/partials/forms/input-text-date.html +37 -0
- package/package/frontend/template-mixins/partials/forms/input-text-group.html +45 -0
- package/package/frontend/template-mixins/partials/forms/option-group.html +43 -0
- package/package/frontend/template-mixins/partials/forms/select.html +17 -0
- package/package/frontend/template-mixins/partials/forms/textarea-group.html +37 -0
- package/package/frontend/template-mixins/partials/mixins/panel.html +4 -0
- package/package/frontend/template-partials/index.js +9 -0
- package/package/frontend/template-partials/translations/index.js +26 -0
- package/package/frontend/template-partials/translations/src/cy/base.json +4 -0
- package/package/frontend/template-partials/translations/src/cy/buttons.json +6 -0
- package/package/frontend/template-partials/translations/src/cy/cookies.json +104 -0
- package/package/frontend/template-partials/translations/src/cy/errorlist.json +6 -0
- package/package/frontend/template-partials/translations/src/cy/errors.json +18 -0
- package/package/frontend/template-partials/translations/src/cy/terms.json +28 -0
- package/package/frontend/template-partials/translations/src/en/accessibility.json +43 -0
- package/package/frontend/template-partials/translations/src/en/base.json +5 -0
- package/package/frontend/template-partials/translations/src/en/buttons.json +10 -0
- package/package/frontend/template-partials/translations/src/en/cookies.json +116 -0
- package/package/frontend/template-partials/translations/src/en/errorlist.json +7 -0
- package/package/frontend/template-partials/translations/src/en/errors.json +35 -0
- package/package/frontend/template-partials/translations/src/en/exit.json +5 -0
- package/package/frontend/template-partials/translations/src/en/fields.json +5 -0
- package/package/frontend/template-partials/translations/src/en/journey.json +6 -0
- package/package/frontend/template-partials/translations/src/en/save-and-exit.json +4 -0
- package/package/frontend/template-partials/translations/src/en/terms.json +28 -0
- package/package/frontend/template-partials/views/404.html +9 -0
- package/package/frontend/template-partials/views/accessibility.html +55 -0
- package/package/frontend/template-partials/views/confirm.html +8 -0
- package/package/frontend/template-partials/views/confirmation.html +19 -0
- package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
- package/package/frontend/template-partials/views/cookie-error.html +1 -0
- package/package/frontend/template-partials/views/cookies.html +84 -0
- package/package/frontend/template-partials/views/email/data-row.html +4 -0
- package/package/frontend/template-partials/views/email/formatted.html +12 -0
- package/package/frontend/template-partials/views/email/layout.html +63 -0
- package/package/frontend/template-partials/views/email/raw.html +11 -0
- package/package/frontend/template-partials/views/email/section-row.html +3 -0
- package/package/frontend/template-partials/views/error.html +20 -0
- package/package/frontend/template-partials/views/exit.html +9 -0
- package/package/frontend/template-partials/views/feedback-submitted.html +11 -0
- package/package/frontend/template-partials/views/layout.html +55 -0
- package/package/frontend/template-partials/views/partials/analytics-table.html +25 -0
- package/package/frontend/template-partials/views/partials/back.html +5 -0
- package/package/frontend/template-partials/views/partials/bullet-list.html +7 -0
- package/package/frontend/template-partials/views/partials/confirmation-alert.html +6 -0
- package/package/frontend/template-partials/views/partials/continue.html +5 -0
- package/package/frontend/template-partials/views/partials/cookie-banner.html +29 -0
- package/package/frontend/template-partials/views/partials/cookie-notification.html +4 -0
- package/package/frontend/template-partials/views/partials/cookie-settings-button.html +1 -0
- package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +8 -0
- package/package/frontend/template-partials/views/partials/details-summary.html +8 -0
- package/package/frontend/template-partials/views/partials/external-link.html +1 -0
- package/package/frontend/template-partials/views/partials/form.html +10 -0
- package/package/frontend/template-partials/views/partials/gatag.html +60 -0
- package/package/frontend/template-partials/views/partials/head.html +31 -0
- package/package/frontend/template-partials/views/partials/heading.html +11 -0
- package/package/frontend/template-partials/views/partials/items-table.html +32 -0
- package/package/frontend/template-partials/views/partials/maincontent-left.html +10 -0
- package/package/frontend/template-partials/views/partials/navigation.html +8 -0
- package/package/frontend/template-partials/views/partials/page.html +23 -0
- package/package/frontend/template-partials/views/partials/panel-indent.html +3 -0
- package/package/frontend/template-partials/views/partials/session-cookies-table.html +28 -0
- package/package/frontend/template-partials/views/partials/session-timeout-warning.html +38 -0
- package/package/frontend/template-partials/views/partials/summary-table-row.html +14 -0
- package/package/frontend/template-partials/views/partials/summary-table.html +8 -0
- package/package/frontend/template-partials/views/partials/table.html +18 -0
- package/package/frontend/template-partials/views/partials/validation-list.html +3 -0
- package/package/frontend/template-partials/views/partials/validation-summary.html +25 -0
- package/package/frontend/template-partials/views/partials/warn.html +7 -0
- package/package/frontend/template-partials/views/rate-limit-error.html +10 -0
- package/package/frontend/template-partials/views/save-and-exit.html +17 -0
- package/package/frontend/template-partials/views/service-unavailable.html +13 -0
- package/package/frontend/template-partials/views/session-timeout.html +7 -0
- package/package/frontend/template-partials/views/step.html +14 -0
- package/package/frontend/template-partials/views/terms.html +26 -0
- package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +145 -0
- package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +121 -0
- package/package/frontend/themes/gov-uk/client-js/index.js +27 -0
- package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +348 -0
- package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +19 -0
- package/package/frontend/themes/gov-uk/index.js +9 -0
- package/package/frontend/themes/gov-uk/styles/_base.scss +17 -0
- package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +155 -0
- package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +111 -0
- package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +33 -0
- package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +23 -0
- package/package/frontend/themes/gov-uk/styles/_helpers.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/_layout.scss +125 -0
- package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +27 -0
- package/package/frontend/themes/gov-uk/styles/_pdf.scss +42 -0
- package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +121 -0
- package/package/frontend/themes/gov-uk/styles/_typography.scss +27 -0
- package/package/frontend/themes/gov-uk/styles/_variables.scss +11 -0
- package/package/frontend/themes/gov-uk/styles/govuk.scss +43 -0
- package/package/frontend/themes/gov-uk/styles/mixins.scss +16 -0
- package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +73 -0
- package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +8 -0
- package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +20 -0
- package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +5 -0
- package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +17 -0
- package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +51 -0
- package/package/frontend/themes/index.js +5 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
- package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
- package/package/frontend/toolkit/assets/javascript/character-count.js +99 -0
- package/package/frontend/toolkit/assets/javascript/form-focus.js +101 -0
- package/package/frontend/toolkit/assets/javascript/helpers.js +177 -0
- package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +72 -0
- package/package/frontend/toolkit/assets/javascript/validation.js +71 -0
- package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +189 -0
- package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +39 -0
- package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +6 -0
- package/package/frontend/toolkit/assets/stylesheets/_base.scss +17 -0
- package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/_layout.scss +118 -0
- package/package/frontend/toolkit/assets/stylesheets/_typography.scss +27 -0
- package/package/frontend/toolkit/assets/stylesheets/_variables.scss +11 -0
- package/package/frontend/toolkit/assets/stylesheets/app.scss +30 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +47 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +38 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +175 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +167 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +39 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +67 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +40 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +29 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +33 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +33 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +63 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +39 -0
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +63 -0
- package/package/frontend/toolkit/assets/stylesheets/mixins.scss +16 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +73 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +20 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +5 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +17 -0
- package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +51 -0
- package/package/frontend/toolkit/index.js +10 -0
- package/package/index.js +351 -0
- package/package/lib/deindex.js +18 -0
- package/package/lib/encryption.js +23 -0
- package/package/lib/ga-tag.js +89 -0
- package/package/lib/health.js +26 -0
- package/package/lib/helpers.js +66 -0
- package/package/lib/logger.js +65 -0
- package/package/lib/markdown.js +46 -0
- package/package/lib/router.js +111 -0
- package/package/lib/serve-static.js +12 -0
- package/package/lib/sessions.js +82 -0
- package/package/lib/settings.js +74 -0
- package/package/lib/which.js +28 -0
- package/package/middleware/cookies.js +43 -0
- package/package/middleware/deep-translate.js +32 -0
- package/package/middleware/errors.js +119 -0
- package/package/middleware/index.js +10 -0
- package/package/middleware/not-found.js +38 -0
- package/package/middleware/rate-limiter.js +98 -0
- package/package/middleware/service-unavailable.js +64 -0
- package/package/model/apis/axios-settings.js +21 -0
- package/package/model/apis/html-to-pdf-converter.js +35 -0
- package/package/model/apis/index.js +5 -0
- package/package/model/index.js +348 -0
- package/package/package.json +147 -0
- package/package/sandbox/README.md +66 -0
- package/package/sandbox/apps/sandbox/behaviours/clear-session.js +8 -0
- package/package/sandbox/apps/sandbox/behaviours/country-select.js +10 -0
- package/package/sandbox/apps/sandbox/behaviours/international-number.js +22 -0
- package/package/sandbox/apps/sandbox/fields.js +128 -0
- package/package/sandbox/apps/sandbox/index.js +99 -0
- package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +189 -0
- package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +43 -0
- package/package/sandbox/apps/sandbox/translations/src/en/errors.json +5 -0
- package/package/sandbox/apps/sandbox/translations/src/en/exit.json +4 -0
- package/package/sandbox/apps/sandbox/translations/src/en/fields.json +101 -0
- package/package/sandbox/apps/sandbox/translations/src/en/journey.json +7 -0
- package/package/sandbox/apps/sandbox/translations/src/en/pages.json +72 -0
- package/package/sandbox/apps/sandbox/translations/src/en/validation.json +54 -0
- package/package/sandbox/apps/sandbox/views/form-guidance-link.html +8 -0
- package/package/sandbox/apps/sandbox/views/save-and-exit.html +19 -0
- package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
- package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
- package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
- package/package/sandbox/assets/js/index.js +70 -0
- package/package/sandbox/assets/scss/app.scss +27 -0
- package/package/sandbox/codecept.conf.js +15 -0
- package/package/sandbox/config.js +17 -0
- package/package/sandbox/package.json +26 -0
- package/package/sandbox/server.js +23 -0
- package/package/sandbox/yarn.lock +262 -0
- package/package/transpiler/index.js +2 -0
- package/package/transpiler/lib/aggregate.js +32 -0
- package/package/transpiler/lib/build.js +15 -0
- package/package/transpiler/lib/compile.js +12 -0
- package/package/transpiler/lib/expand-dirs.js +14 -0
- package/package/transpiler/lib/write-files.js +24 -0
- package/package/utilities/autofill/index.js +189 -0
- package/package/utilities/autofill/inputs.js +60 -0
- package/package/utilities/countries.js +12 -0
- package/package/utilities/helpers/index.js +189 -0
- package/package/utilities/index.js +9 -0
- package/package/utilities/reqres/index.js +18 -0
- package/package/utilities/test-data/data/domain.json +7 -0
- package/package/utilities/test-data/data/firstname.json +16 -0
- package/package/utilities/test-data/data/lastname.json +10 -0
- package/package/utilities/test-data/data/postcode.json +12 -0
- package/package/utilities/test-data/data/streetname.json +8 -0
- package/package/utilities/test-data/data/streetsuffix.json +7 -0
- package/package/utilities/test-data/data/town.json +9 -0
- package/package/utilities/test-data/index.js +67 -0
- package/package/wizard/behaviours/complete.js +20 -0
- package/package/wizard/behaviours/index.js +5 -0
- package/package/wizard/index.js +124 -0
- package/package/wizard/middleware/back-links.js +68 -0
- package/package/wizard/middleware/check-complete.js +13 -0
- package/package/wizard/middleware/check-progress.js +139 -0
- package/package/wizard/middleware/check-session.js +17 -0
- package/package/wizard/middleware/csrf.js +47 -0
- package/package/wizard/middleware/session-model.js +11 -0
- package/package/wizard/middleware/session.js +9 -0
- package/package/wizard/model.js +29 -0
- package/package/wizard/util/constants.js +5 -0
- package/package/wizard/util/helpers.js +19 -0
- package/package.json +5 -6
- package/.editorconfig +0 -10
- package/.github/workflows/automate-publish.yml +0 -38
- package/.github/workflows/automate-tag.yml +0 -78
- package/.istanbul.yml +0 -20
- package/.nyc_output/be573ac3-d055-4910-a088-9d41b5345cec.json +0 -1
- package/.nyc_output/processinfo/be573ac3-d055-4910-a088-9d41b5345cec.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/codeReviewChecklist.md +0 -22
- package/pull_request_template.md +0 -16
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const args = require('minimist')(process.argv.slice(2));
|
5
|
+
const compile = require('../transpiler/lib/compile');
|
6
|
+
|
7
|
+
const options = {};
|
8
|
+
|
9
|
+
options.sources = args._;
|
10
|
+
options.shared = args.shared || args.s || [];
|
11
|
+
|
12
|
+
compile(options);
|
@@ -0,0 +1,29 @@
|
|
1
|
+
const local = require('./local');
|
2
|
+
const resolve = require('./resolver');
|
3
|
+
|
4
|
+
module.exports = function (options) {
|
5
|
+
const importerOptions = options || {};
|
6
|
+
|
7
|
+
function importer(url, file, done) {
|
8
|
+
let importerUrl = url;
|
9
|
+
if (importerOptions.aliases && importerOptions.aliases[importerUrl]) {
|
10
|
+
importerUrl = importerOptions.aliases[importerUrl];
|
11
|
+
}
|
12
|
+
|
13
|
+
local(importerUrl, file, function (err, isLocal) {
|
14
|
+
if (err || isLocal) {
|
15
|
+
done({ file: importerUrl });
|
16
|
+
} else {
|
17
|
+
resolve(importerUrl, file)
|
18
|
+
.catch(function () { return importerUrl; })
|
19
|
+
.then(function (path) {
|
20
|
+
const importerPath = path.replace(/\.css$/, '');
|
21
|
+
return { file: importerPath };
|
22
|
+
})
|
23
|
+
.then(done);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
}
|
27
|
+
|
28
|
+
return importer;
|
29
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
const glob = require('glob');
|
3
|
+
|
4
|
+
module.exports = function (url, file, done) {
|
5
|
+
// if url starts with . or / then assume it's a local/relative path
|
6
|
+
if (['.', path.sep].indexOf(url.substr(0, 1)) > -1) {
|
7
|
+
return done(null, true);
|
8
|
+
}
|
9
|
+
|
10
|
+
// otherwise construct a glob to match possible relative file paths
|
11
|
+
const basedir = path.dirname(file);
|
12
|
+
|
13
|
+
const bits = url.split(path.sep);
|
14
|
+
|
15
|
+
let filename = bits.pop();
|
16
|
+
const filepath = bits.join(path.sep);
|
17
|
+
|
18
|
+
// support _ prefixing of filenames
|
19
|
+
if (filename[0] !== '_') {
|
20
|
+
filename = '?(_)' + filename;
|
21
|
+
}
|
22
|
+
|
23
|
+
// match .scss, .sass or .css if the extension is not defined
|
24
|
+
if (filename.indexOf('.') === -1) {
|
25
|
+
filename += '.@(sa|c|sc)ss';
|
26
|
+
}
|
27
|
+
|
28
|
+
const target = path.join(basedir, filepath, filename);
|
29
|
+
|
30
|
+
// test the constructed glob against the file system for possible matches
|
31
|
+
glob(target, function (err, list) {
|
32
|
+
done(err, list.length);
|
33
|
+
});
|
34
|
+
return null;
|
35
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
function Import(importUrl) {
|
4
|
+
this.importUrl = importUrl;
|
5
|
+
}
|
6
|
+
|
7
|
+
Import.prototype.isScoped = function () {
|
8
|
+
return this.importUrl[0] === '@';
|
9
|
+
};
|
10
|
+
|
11
|
+
Import.prototype.packageName = function () {
|
12
|
+
if (this.isScoped()) {
|
13
|
+
return this.importUrl.split(path.sep, 2).join(path.sep);
|
14
|
+
}
|
15
|
+
return this.importUrl.split(path.sep, 1)[0];
|
16
|
+
};
|
17
|
+
|
18
|
+
Import.prototype.isEntrypoint = function () {
|
19
|
+
const safePathSplitPattern = new RegExp(path.sep + '.');
|
20
|
+
const pathSegmentCount = this.importUrl.split(safePathSplitPattern).length;
|
21
|
+
|
22
|
+
if (this.isScoped()) {
|
23
|
+
return pathSegmentCount === 2;
|
24
|
+
}
|
25
|
+
return pathSegmentCount === 1;
|
26
|
+
};
|
27
|
+
|
28
|
+
Import.prototype.specifiedFilePath = function () {
|
29
|
+
return this.importUrl.slice(this.packageName().length);
|
30
|
+
};
|
31
|
+
|
32
|
+
module.exports = Import;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
const path = require('path');
|
3
|
+
const findup = require('findup');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @param {string} importOriginPath Path of file that made @import reference
|
7
|
+
*/
|
8
|
+
module.exports = function (packageName, importOriginPath) {
|
9
|
+
const pathToFind = path.join('node_modules', packageName, 'package.json');
|
10
|
+
const dirnameOfImportOrigin = path.dirname(importOriginPath);
|
11
|
+
let handleFoundPath;
|
12
|
+
|
13
|
+
const promise = new Promise(function (resolve, reject) {
|
14
|
+
handleFoundPath = function (err, nearestPackageParent) {
|
15
|
+
if (err) {
|
16
|
+
try {
|
17
|
+
return resolve(path.dirname(require.resolve(`${packageName}/package.json`)));
|
18
|
+
} catch (e) {
|
19
|
+
console.log(e);
|
20
|
+
}
|
21
|
+
return reject(err);
|
22
|
+
}
|
23
|
+
|
24
|
+
const packageJSONLocation = path.join(nearestPackageParent, 'node_modules', packageName);
|
25
|
+
|
26
|
+
return resolve(packageJSONLocation);
|
27
|
+
};
|
28
|
+
});
|
29
|
+
|
30
|
+
findup(dirnameOfImportOrigin, pathToFind, handleFoundPath);
|
31
|
+
|
32
|
+
return promise;
|
33
|
+
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
function Package(rootPath) {
|
4
|
+
this.root = path.join.bind(null, rootPath);
|
5
|
+
this.JSON = require(this.root('package.json'));
|
6
|
+
}
|
7
|
+
|
8
|
+
Package.prototype.fullPathToEntrypoint = function () {
|
9
|
+
return this.root(this.entrypoint());
|
10
|
+
};
|
11
|
+
|
12
|
+
Package.prototype.entrypoint = function () {
|
13
|
+
if (this.JSON.sass) {
|
14
|
+
return this.JSON.sass;
|
15
|
+
// look for "style" declaration in package.json
|
16
|
+
} else if (this.JSON.style) {
|
17
|
+
return this.JSON.style;
|
18
|
+
// look for "styles" declaration in package.json
|
19
|
+
} else if (this.JSON.styles) {
|
20
|
+
return this.JSON.styles;
|
21
|
+
// look for a css/sass/scss file in the "main" declaration in package.json
|
22
|
+
} else if (/\.(sa|c|sc)ss$/.test(this.JSON.main)) {
|
23
|
+
return this.JSON.main;
|
24
|
+
// otherwise assume ./styles.scss
|
25
|
+
}
|
26
|
+
return 'styles';
|
27
|
+
};
|
28
|
+
|
29
|
+
module.exports = Package;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
const Package = require('./resolver/package');
|
2
|
+
const Import = require('./resolver/import');
|
3
|
+
const nearestPackageRoot = require('./resolver/nearest-package-root');
|
4
|
+
|
5
|
+
module.exports = function (importUrl, importOriginPath) {
|
6
|
+
const _import = new Import(importUrl);
|
7
|
+
|
8
|
+
return nearestPackageRoot(_import.packageName(), importOriginPath).then(function (packageRoot) {
|
9
|
+
const _package = new Package(packageRoot);
|
10
|
+
|
11
|
+
if (_import.isEntrypoint()) {
|
12
|
+
return _package.fullPathToEntrypoint();
|
13
|
+
}
|
14
|
+
return _package.root(_import.specifiedFilePath());
|
15
|
+
});
|
16
|
+
};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const path = require('path');
|
5
|
+
const merge = require('lodash').merge;
|
6
|
+
const config = require('../config/builder-defaults');
|
7
|
+
|
8
|
+
module.exports = options => {
|
9
|
+
const settings = {};
|
10
|
+
|
11
|
+
merge(settings, config);
|
12
|
+
|
13
|
+
// load settings from ./hof.settings.json if it exists
|
14
|
+
let localConfig;
|
15
|
+
let hofSettings;
|
16
|
+
try {
|
17
|
+
localConfig = path.resolve(process.cwd(), './hof.settings');
|
18
|
+
hofSettings = require(localConfig).build || {};
|
19
|
+
hofSettings.theme = require(localConfig).theme;
|
20
|
+
} catch (e) {
|
21
|
+
// ignore error for missing config file
|
22
|
+
}
|
23
|
+
|
24
|
+
if (hofSettings) {
|
25
|
+
console.log(`Found local config at ${localConfig}`);
|
26
|
+
merge(settings, hofSettings);
|
27
|
+
}
|
28
|
+
|
29
|
+
// load override config file if defined
|
30
|
+
if (options.config) {
|
31
|
+
merge(settings, require(path.resolve(process.cwd(), options.config)));
|
32
|
+
}
|
33
|
+
|
34
|
+
settings.production = options.production || process.env.NODE_ENV === 'production';
|
35
|
+
settings.watchNodeModules = options['watch-node-modules'];
|
36
|
+
settings.watchDotFiles = options['watch-dotfiles'];
|
37
|
+
settings.verbose = options.verbose;
|
38
|
+
settings.env = options.env;
|
39
|
+
|
40
|
+
const task = options._[0] || 'build';
|
41
|
+
|
42
|
+
try {
|
43
|
+
require.resolve(`./tasks/${task}`);
|
44
|
+
} catch (e) {
|
45
|
+
throw new Error(`Unknown task: ${task}`);
|
46
|
+
}
|
47
|
+
|
48
|
+
return require(`./tasks/${task}`)(settings);
|
49
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const fs = require('fs');
|
5
|
+
const dotenv = require('dotenv');
|
6
|
+
|
7
|
+
function hasenv(envfile) {
|
8
|
+
return new Promise(resolve => {
|
9
|
+
fs.stat(envfile, (err, stat) => err ? resolve(false) : resolve(stat.isFile()));
|
10
|
+
});
|
11
|
+
}
|
12
|
+
|
13
|
+
function readenv(envfile) {
|
14
|
+
return new Promise((resolve, reject) => {
|
15
|
+
fs.readFile(envfile, (err, data) => err ? reject(err) : resolve(data));
|
16
|
+
});
|
17
|
+
}
|
18
|
+
|
19
|
+
function loadenv(envfile, enabled) {
|
20
|
+
return hasenv(envfile)
|
21
|
+
.then(exists => {
|
22
|
+
if (!exists && enabled) {
|
23
|
+
throw new Error(`No env file could be found at ${envfile}`);
|
24
|
+
} else if (exists && !enabled) {
|
25
|
+
console.log(`Local env file found at ${envfile}.`);
|
26
|
+
console.log('To load variables from this file run with --env.');
|
27
|
+
} else if (exists && enabled) {
|
28
|
+
console.log(`Loading variables from env file at ${envfile}`);
|
29
|
+
return readenv(envfile)
|
30
|
+
.then(env => dotenv.parse(env));
|
31
|
+
}
|
32
|
+
return {};
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
module.exports = loadenv;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
module.exports = (tasks, config) => tasks.reduce((promise, task) => {
|
5
|
+
const name = task.task || 'unknown';
|
6
|
+
return promise
|
7
|
+
.then(() => {
|
8
|
+
console.log(`Executing task: ${name}`);
|
9
|
+
return task(config);
|
10
|
+
})
|
11
|
+
.then(() => {
|
12
|
+
console.log(`Completed task: ${name}`);
|
13
|
+
});
|
14
|
+
}, Promise.resolve())
|
15
|
+
.then(() => {
|
16
|
+
console.log();
|
17
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const cp = require('child_process');
|
5
|
+
|
6
|
+
module.exports = (cmd, args) => new Promise((resolve, reject) => {
|
7
|
+
if (process.env.HOF_SANDBOX === 'true') {
|
8
|
+
cmd = cmd.replace('node_modules/hof', '..');
|
9
|
+
}
|
10
|
+
|
11
|
+
const child = cp.spawn(cmd, args, {
|
12
|
+
cwd: process.cwd(),
|
13
|
+
stdio: 'inherit',
|
14
|
+
shell: true
|
15
|
+
});
|
16
|
+
child.on('error', reject);
|
17
|
+
child.on('exit', code => code === 0 ? resolve() : reject(new Error(`${cmd} exited with a non-zero code: ${code}`)));
|
18
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const duplexify = require('duplexify');
|
4
|
+
const spawn = require('child_process').spawn;
|
5
|
+
const which = require('../../../lib/which');
|
6
|
+
const bin = which('uglify-js', 'uglifyjs');
|
7
|
+
|
8
|
+
const args = ['--comments', '/copyright|licen(c|s)e/i', '--'];
|
9
|
+
|
10
|
+
function uglify() {
|
11
|
+
const proc = spawn(bin, args, { stdio: 'pipe' });
|
12
|
+
return duplexify(proc.stdin, proc.stdout);
|
13
|
+
}
|
14
|
+
|
15
|
+
module.exports = uglify;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const browserify = require('browserify');
|
4
|
+
const fs = require('fs');
|
5
|
+
const path = require('path');
|
6
|
+
const minify = require('./compress');
|
7
|
+
const exorcist = require('exorcist');
|
8
|
+
|
9
|
+
const mkdir = require('../../lib/mkdir');
|
10
|
+
|
11
|
+
module.exports = config => {
|
12
|
+
if (!config.browserify) {
|
13
|
+
return Promise.resolve();
|
14
|
+
}
|
15
|
+
|
16
|
+
const out = path.resolve(process.cwd(), config.browserify.out);
|
17
|
+
|
18
|
+
// Enable debug mode (builds source maps) only if not in production
|
19
|
+
const debugMode = !config.production && config.browserify.debug;
|
20
|
+
|
21
|
+
return mkdir(out)
|
22
|
+
.then(() => new Promise((resolve, reject) => {
|
23
|
+
const bundler = browserify(config.browserify.src, {debug: debugMode});
|
24
|
+
if (config.theme) {
|
25
|
+
bundler.transform(require('aliasify'), {
|
26
|
+
aliases: {
|
27
|
+
$$theme: `hof-theme-${config.theme}`
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
let stream = bundler.bundle();
|
32
|
+
if (config.browserify.compress || config.production) {
|
33
|
+
stream = stream.pipe(minify());
|
34
|
+
}
|
35
|
+
|
36
|
+
// If debugging, use exorcist to extract a source map
|
37
|
+
if (debugMode) {
|
38
|
+
const mapPath = path.join(path.dirname(out), path.basename(out) + '.map');
|
39
|
+
stream = stream.pipe(exorcist(mapPath));
|
40
|
+
}
|
41
|
+
|
42
|
+
stream = stream.pipe(fs.createWriteStream(out));
|
43
|
+
|
44
|
+
stream.on('finish', resolve).on('error', reject);
|
45
|
+
}));
|
46
|
+
};
|
47
|
+
|
48
|
+
module.exports.task = 'browserify';
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const fs = require('fs');
|
5
|
+
const chalk = require('chalk');
|
6
|
+
const spawn = require('../../lib/spawn');
|
7
|
+
const mkdir = require('../../lib/mkdir');
|
8
|
+
|
9
|
+
module.exports = config => {
|
10
|
+
if (!config.images) {
|
11
|
+
return Promise.resolve();
|
12
|
+
}
|
13
|
+
|
14
|
+
return new Promise((resolve, reject) => {
|
15
|
+
fs.stat(config.images.src, err => err ? reject(err) : resolve());
|
16
|
+
})
|
17
|
+
.then(() => mkdir(config.images.out))
|
18
|
+
.then(() => spawn('cp', ['-r', config.images.src, config.images.out]))
|
19
|
+
.catch(e => {
|
20
|
+
if (e.code !== 'ENOENT') {
|
21
|
+
throw e;
|
22
|
+
} else {
|
23
|
+
console.log(`${chalk.yellow('warning')}: no images directory found at ${config.images.src}`);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
};
|
27
|
+
module.exports.task = 'copy images';
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const fs = require('fs');
|
5
|
+
const path = require('path');
|
6
|
+
const sass = require('sass');
|
7
|
+
const importer = require('../../helpers/importer');
|
8
|
+
const mkdir = require('../../lib/mkdir');
|
9
|
+
const hofConfig = require('../../../config/hof-defaults');
|
10
|
+
const logger = require('../../../lib/logger')(hofConfig);
|
11
|
+
|
12
|
+
module.exports = config => {
|
13
|
+
if (!config.sass) {
|
14
|
+
return Promise.resolve();
|
15
|
+
}
|
16
|
+
|
17
|
+
const out = path.resolve(process.cwd(), config.sass.out);
|
18
|
+
|
19
|
+
return mkdir(out)
|
20
|
+
.then(() => new Promise((resolve, reject) => {
|
21
|
+
const aliases = {};
|
22
|
+
|
23
|
+
if (config.theme) {
|
24
|
+
console.log('Applying theme: ' + config.theme);
|
25
|
+
aliases.$$theme = `hof-theme-${config.theme}`;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Build source maps if we are not in production
|
29
|
+
const createSourceMaps = !config.production && config.sass.sourceMaps;
|
30
|
+
|
31
|
+
sass.render({
|
32
|
+
file: config.sass.src,
|
33
|
+
importer: importer({ aliases }),
|
34
|
+
aliases,
|
35
|
+
outputStyle: config.sass.outputStyle,
|
36
|
+
quietDeps: config.sass.quietDeps,
|
37
|
+
outFile: out,
|
38
|
+
sourceMap: createSourceMaps
|
39
|
+
}, (err, result) => err ? reject(err) : resolve(result));
|
40
|
+
}))
|
41
|
+
.then(result => {
|
42
|
+
// Write the compiled CSS to the output file
|
43
|
+
const writeCss = new Promise((resolve, reject) => {
|
44
|
+
fs.writeFile(out, result.css, err => err ? reject(err) : resolve());
|
45
|
+
});
|
46
|
+
|
47
|
+
// If a sourcemap was generated, write it to a separate file
|
48
|
+
if (result.map) {
|
49
|
+
const mapPath = path.join(path.dirname(out), path.basename(out) + '.map');
|
50
|
+
const writeMap = new Promise((resolve, reject) => {
|
51
|
+
fs.writeFile(mapPath, result.map, err => {
|
52
|
+
if (err) {
|
53
|
+
logger.error('Failed to create sourcemap:', err);
|
54
|
+
reject(err);
|
55
|
+
} else {
|
56
|
+
logger.info('Sourcemap created successfully:', mapPath);
|
57
|
+
resolve();
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
61
|
+
return Promise.all([writeCss, writeMap]);
|
62
|
+
}
|
63
|
+
|
64
|
+
return writeCss;
|
65
|
+
});
|
66
|
+
};
|
67
|
+
module.exports.task = 'compile sass';
|
@@ -0,0 +1,20 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const spawn = require('../../lib/spawn');
|
4
|
+
|
5
|
+
module.exports = config => {
|
6
|
+
if (!config.translate) {
|
7
|
+
return Promise.resolve();
|
8
|
+
}
|
9
|
+
|
10
|
+
const args = [config.translate.src];
|
11
|
+
if (config.translate.shared) {
|
12
|
+
const shared = [].concat(config.translate.shared);
|
13
|
+
shared.forEach(path => {
|
14
|
+
args.push('--shared', path);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
return spawn('node_modules/hof/bin/hof-transpiler', args);
|
19
|
+
};
|
20
|
+
module.exports.task = 'compile translations';
|