@madgex/fert 5.0.13 → 5.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/bin/utils/index.js +11 -10
- package/constants.js +1 -0
- package/package.json +2 -2
- package/server/routes/views.js +17 -2
- package/server/view-manager.js +2 -1
- /package/server/templates/{page1.njk → default.njk} +0 -0
package/README.md
CHANGED
|
@@ -79,11 +79,12 @@ e.g.
|
|
|
79
79
|
|
|
80
80
|
`/services/<service-folder>/fert.service.config.js` [required] – a service configuration file in the service folder, specifying the following config to both the Fert dev server and the production asset build:
|
|
81
81
|
|
|
82
|
-
| Option
|
|
83
|
-
|
|
|
84
|
-
| `serviceName` <String>
|
|
85
|
-
| `entry` <String>
|
|
86
|
-
| `externalAssets` <Object>
|
|
82
|
+
| Option | |
|
|
83
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
84
|
+
| `serviceName` <String> | Which service to display and deploy, e.g. `jobseekers-frontend`, `recruiterservices-frontend`. |
|
|
85
|
+
| `entry` <String> | The JavaScript entry file. Any assets (CSS/SCSS/SVGs) included will be processed and be part of the output. Defaults to `['src/index.js']` |
|
|
86
|
+
| `externalAssets` <Object> | |
|
|
87
|
+
|
|
87
88
|
|
|
88
89
|
The `entry` will be used by Vite to create production bundles.
|
|
89
90
|
|
package/bin/utils/index.js
CHANGED
|
@@ -34,16 +34,6 @@ exports.getConfig = async (cpid, configNames = []) => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
exports.resolveConfig = async (options = {}) => {
|
|
37
|
-
const defaults = {
|
|
38
|
-
clientPropertyId: null,
|
|
39
|
-
serviceName: null,
|
|
40
|
-
entry: 'src/index.js',
|
|
41
|
-
externalAssets: {
|
|
42
|
-
links: [],
|
|
43
|
-
scripts: [],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
37
|
Hoek.assert(options.serviceName, 'serviceName is required');
|
|
48
38
|
|
|
49
39
|
const rootDir = await this.findFertConfigDir();
|
|
@@ -55,6 +45,17 @@ exports.resolveConfig = async (options = {}) => {
|
|
|
55
45
|
const { dir: workingDir, serviceConfig } = serviceConfigs.find(
|
|
56
46
|
(item) => item.serviceConfig.serviceName === options.serviceName,
|
|
57
47
|
);
|
|
48
|
+
|
|
49
|
+
const defaults = {
|
|
50
|
+
clientPropertyId: null,
|
|
51
|
+
serviceName: null,
|
|
52
|
+
entry: 'src/index.js',
|
|
53
|
+
externalAssets: {
|
|
54
|
+
links: [],
|
|
55
|
+
scripts: [],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
58
59
|
const fertConfig = Hoek.applyToDefaults(
|
|
59
60
|
defaults,
|
|
60
61
|
// merge fert config with service config
|
package/constants.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
VERSION,
|
|
14
14
|
TMP_DIR: fs.realpathSync(os.tmpdir()),
|
|
15
15
|
FERT_PACKAGE_DIR: path.resolve('./'),
|
|
16
|
+
CUSTOM_TEMPLATES_DIR: './pages',
|
|
16
17
|
AWS_REGION: 'eu-west-1',
|
|
17
18
|
PROPERTY_ID_API: 'https://property-identification-api.cs.madgexhosting.net/properties/',
|
|
18
19
|
ASSETS_API_URL: 'https://asset-store.job.madgexhosting.net',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/fert",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.15",
|
|
4
4
|
"description": "Tool to help build the V6 branding",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fert": "./bin/cli.js"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@hapi/inert": "^7.1.0",
|
|
32
32
|
"@hapi/vision": "^7.0.3",
|
|
33
33
|
"@hapipal/toys": "^4.0.0",
|
|
34
|
-
"@madgex/config-api-sdk": "^1.7.
|
|
34
|
+
"@madgex/config-api-sdk": "^1.7.8",
|
|
35
35
|
"@madgex/design-system": "^9.3.1",
|
|
36
36
|
"@private/header-footer-podlet-server": "github:wiley/madgex-header-footer-podlet",
|
|
37
37
|
"axios": "^1.8.4",
|
package/server/routes/views.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { CUSTOM_TEMPLATES_DIR } = require('../../constants');
|
|
4
|
+
|
|
1
5
|
// eslint-disable-next-line n/no-unpublished-require
|
|
2
6
|
const Joi = require('joi');
|
|
3
7
|
|
|
@@ -27,7 +31,18 @@ module.exports = {
|
|
|
27
31
|
},
|
|
28
32
|
});
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
/*
|
|
35
|
+
This to checks if there is a custom template in this service that matches the page given in the url.
|
|
36
|
+
If not displays the default template.
|
|
37
|
+
|
|
38
|
+
This is useful to check styling such as active state against different routes and can simulate
|
|
39
|
+
navigation locally with relative paths without the need to create additional templates.
|
|
40
|
+
*/
|
|
41
|
+
const customTemplateFound =
|
|
42
|
+
page && fs.existsSync(path.join(fertConfig.workingDir, `${CUSTOM_TEMPLATES_DIR}/${page}.njk`));
|
|
43
|
+
const template = customTemplateFound ? page : 'default';
|
|
44
|
+
|
|
45
|
+
return h.view(template, {
|
|
31
46
|
auth: request.auth,
|
|
32
47
|
podletResponse,
|
|
33
48
|
});
|
|
@@ -35,7 +50,7 @@ module.exports = {
|
|
|
35
50
|
options: {
|
|
36
51
|
validate: {
|
|
37
52
|
params: Joi.object({
|
|
38
|
-
page: Joi.string().empty(['', null])
|
|
53
|
+
page: Joi.string().empty(['', null]),
|
|
39
54
|
}),
|
|
40
55
|
},
|
|
41
56
|
auth: {
|
package/server/view-manager.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const Nunjucks = require('nunjucks');
|
|
2
2
|
const path = require('node:path');
|
|
3
|
+
const { CUSTOM_TEMPLATES_DIR } = require('../constants');
|
|
3
4
|
|
|
4
5
|
module.exports = (server) => {
|
|
5
6
|
const fertConfig = server.fertConfig();
|
|
@@ -29,7 +30,7 @@ module.exports = (server) => {
|
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
path: [
|
|
32
|
-
path.join(fertConfig.workingDir,
|
|
33
|
+
path.join(fertConfig.workingDir, CUSTOM_TEMPLATES_DIR), // user-created 'pages'
|
|
33
34
|
path.join(__dirname, './templates'), // fert-local base templates
|
|
34
35
|
],
|
|
35
36
|
isCached: false,
|
|
File without changes
|