@madgex/fert 1.3.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.js +1 -1
- package/bin/cli.js +1 -1
- package/bin/commands/build-tasks/build-external-assets.js +1 -1
- package/bin/commands/build-tasks/build-tokens.js +2 -1
- package/bin/commands/build-tasks/bundle-entry.js +2 -2
- package/bin/commands/build.js +2 -1
- package/bin/commands/dev-server.js +2 -1
- package/bin/commands/publish-tasks/asset-store-uploader.js +1 -1
- package/bin/commands/publish.js +2 -1
- package/bin/utils/cpid-lookup.js +22 -11
- package/bin/utils/index.js +0 -17
- package/bin/utils/logging.js +18 -0
- package/constants.js +1 -0
- package/package.json +11 -11
- package/repo-templates/globals/fert.config.js +4 -0
- package/repo-templates/template-basic/package.json +1 -1
- package/repo-templates/template-bigworkbag/package.json +1 -1
- package/server/index.js +9 -2
- package/server/plugins/hapi-vite.js +10 -0
- package/server/routes/views.js +4 -8
package/.prettierrc.js
CHANGED
package/bin/cli.js
CHANGED
|
@@ -30,7 +30,7 @@ const run = () => {
|
|
|
30
30
|
.action((...args) => require('./commands/build.js')(...args));
|
|
31
31
|
|
|
32
32
|
cli
|
|
33
|
-
.command('publish [root]', 'Publish project
|
|
33
|
+
.command('publish [root]', 'Publish the project')
|
|
34
34
|
.option('--target <env>', 'Environment to publish to, "dev" or "prod"')
|
|
35
35
|
.action((...args) => require('./commands/publish')(...args));
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Path = require('path');
|
|
2
2
|
const fs = require('fs/promises');
|
|
3
|
-
const { log } = require('../../utils');
|
|
3
|
+
const { log } = require('../../utils/logging');
|
|
4
4
|
|
|
5
5
|
module.exports = async function buildExternalAssets(fertConfig) {
|
|
6
6
|
const { externalAssets, workingDir } = fertConfig;
|
|
@@ -5,7 +5,8 @@ const {
|
|
|
5
5
|
registerTransforms,
|
|
6
6
|
} = require('@madgex/design-system/tasks/registerTransforms');
|
|
7
7
|
const colorTransforms = require('@madgex/design-system/tasks/colorTransforms');
|
|
8
|
-
const { ensureTrailingSlash,
|
|
8
|
+
const { ensureTrailingSlash, exists } = require('../../utils');
|
|
9
|
+
const { log } = require('../../utils/logging');
|
|
9
10
|
const { TMP_DIR } = require('../../../constants');
|
|
10
11
|
|
|
11
12
|
const dsTokensPath = Path.dirname(
|
|
@@ -3,7 +3,7 @@ const _ = require('lodash');
|
|
|
3
3
|
const vite = require('vite');
|
|
4
4
|
const updateBuildWithBundledDsCSS = require('./bundle-ds-css');
|
|
5
5
|
const buildExternalAssets = require('./build-external-assets');
|
|
6
|
-
const { log } = require('../../utils');
|
|
6
|
+
const { log } = require('../../utils/logging');
|
|
7
7
|
|
|
8
8
|
module.exports = async (fertConfig, options = {}) => {
|
|
9
9
|
let dynamicOptions = {};
|
|
@@ -17,7 +17,7 @@ module.exports = async (fertConfig, options = {}) => {
|
|
|
17
17
|
|
|
18
18
|
dynamicOptions = {
|
|
19
19
|
root: path.resolve(fertConfig.workingDir),
|
|
20
|
-
base: '/_/jobseekers-frontend/',
|
|
20
|
+
base: '/_/jobseekers-frontend/assets/',
|
|
21
21
|
build: {
|
|
22
22
|
cssCodeSplit: false, // important: to get a single, style.css file output
|
|
23
23
|
outDir: path.resolve(fertConfig.workingDir, 'dist'),
|
package/bin/commands/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { rimraf } = require('rimraf');
|
|
3
|
-
const { resolveConfig
|
|
3
|
+
const { resolveConfig } = require('../utils');
|
|
4
|
+
const { log } = require('../utils/logging');
|
|
4
5
|
const bundleEntry = require('./build-tasks/bundle-entry');
|
|
5
6
|
const buildCssFromTokens = require('./build-tasks/build-tokens');
|
|
6
7
|
const buildExternalAssets = require('./build-tasks/build-external-assets');
|
|
@@ -2,7 +2,8 @@ const path = require('path');
|
|
|
2
2
|
const chalk = require('chalk');
|
|
3
3
|
const open = require('open');
|
|
4
4
|
const chokidar = require('chokidar');
|
|
5
|
-
const { resolveConfig
|
|
5
|
+
const { resolveConfig } = require('../utils/index.js');
|
|
6
|
+
const { log } = require('../utils/logging.js');
|
|
6
7
|
const { devServer } = require('../../server');
|
|
7
8
|
const { buildTokens, buildExternalAssets } = require('./build.js');
|
|
8
9
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const Hoek = require('@hapi/hoek');
|
|
4
|
-
const { log } = require('../../utils');
|
|
4
|
+
const { log } = require('../../utils/logging');
|
|
5
5
|
const axios = require('axios');
|
|
6
6
|
const FormData = require('form-data');
|
|
7
7
|
const ora = require('ora');
|
package/bin/commands/publish.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const Hoek = require('@hapi/hoek');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
-
const { resolveConfig
|
|
4
|
+
const { resolveConfig } = require('../utils');
|
|
5
|
+
const { log } = require('../utils/logging');
|
|
5
6
|
const getAwsParam = require('./publish-tasks/get-aws-parameter');
|
|
6
7
|
const AssetStoreUploader = require('./publish-tasks/asset-store-uploader');
|
|
7
8
|
const {
|
package/bin/utils/cpid-lookup.js
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
// Fetch provides support for node 16 and lower
|
|
2
|
-
const
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
const { log } = require('../utils/logging');
|
|
3
4
|
const storage = require('node-persist');
|
|
4
5
|
const dayjs = require('dayjs');
|
|
5
6
|
const duration = require('dayjs/plugin/duration');
|
|
6
7
|
const { PROPERTY_ID_API, TMP_DIR } = require('../../constants');
|
|
8
|
+
const chalk = require('chalk');
|
|
7
9
|
|
|
8
10
|
dayjs.extend(duration);
|
|
9
11
|
|
|
10
12
|
exports.doCpidLookup = async (clientPropertyId) => {
|
|
11
13
|
const API_URL = new URL(clientPropertyId, PROPERTY_ID_API).toString();
|
|
12
14
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const results = await axios
|
|
16
|
+
.get(API_URL, { timeout: 5000 })
|
|
17
|
+
.then((res) => {
|
|
18
|
+
return res.data.data;
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
log.error(
|
|
22
|
+
`Unable to lookup CPID [${chalk.yellow(
|
|
23
|
+
clientPropertyId
|
|
24
|
+
)}] from ${chalk.cyan(API_URL)}: ${chalk.redBright(error.message)}\n`
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
throw Error(error.message);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// const { data: results } = await res.json();
|
|
20
31
|
const { brandName, parentId: parentCpid } = results;
|
|
21
32
|
|
|
22
33
|
return {
|
|
@@ -33,10 +44,10 @@ exports.cpidLookup = async (clientPropertyId) => {
|
|
|
33
44
|
ttl: dayjs.duration(1, 'week').asMilliseconds(),
|
|
34
45
|
});
|
|
35
46
|
|
|
36
|
-
const
|
|
47
|
+
const cache = await storage.getItem(clientPropertyId);
|
|
37
48
|
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
49
|
+
if (cache) {
|
|
50
|
+
return cache;
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
const result = await this.doCpidLookup(clientPropertyId);
|
package/bin/utils/index.js
CHANGED
|
@@ -3,8 +3,6 @@ const fs = require('fs');
|
|
|
3
3
|
const fsp = require('fs/promises');
|
|
4
4
|
const { VERSION } = require('../../constants');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
|
-
const debug = require('debug');
|
|
7
|
-
const debugLog = debug('fert');
|
|
8
6
|
const uuidValidator = require('uuid-validate');
|
|
9
7
|
const Hoek = require('@hapi/hoek');
|
|
10
8
|
const { cpidLookup } = require('./cpid-lookup');
|
|
@@ -14,21 +12,6 @@ exports.printBanner = () => {
|
|
|
14
12
|
console.log(chalk`\n{green.bold Fert} v${VERSION}\n`);
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
exports.log = {
|
|
18
|
-
info: (...args) => {
|
|
19
|
-
console.log(...args);
|
|
20
|
-
},
|
|
21
|
-
success: (...args) => {
|
|
22
|
-
console.log(chalk.green.bold('✔'), ...args);
|
|
23
|
-
},
|
|
24
|
-
error: (...args) => {
|
|
25
|
-
console.log(chalk.red.bold('✖'), ...args);
|
|
26
|
-
},
|
|
27
|
-
debug: (...args) => {
|
|
28
|
-
debugLog(...args);
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
15
|
exports.resolveConfig = async (root, options = {}) => {
|
|
33
16
|
const defaults = {
|
|
34
17
|
clientPropertyId: null,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const debug = require('debug');
|
|
2
|
+
const debugLog = debug('fert');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
exports.log = {
|
|
6
|
+
info: (...args) => {
|
|
7
|
+
console.log(...args);
|
|
8
|
+
},
|
|
9
|
+
success: (...args) => {
|
|
10
|
+
console.log(chalk.green.bold('✔'), ...args);
|
|
11
|
+
},
|
|
12
|
+
error: (...args) => {
|
|
13
|
+
console.log(chalk.red.bold('✖'), ...args);
|
|
14
|
+
},
|
|
15
|
+
debug: (...args) => {
|
|
16
|
+
debugLog(...args);
|
|
17
|
+
},
|
|
18
|
+
};
|
package/constants.js
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = {
|
|
|
14
14
|
AWS_REGION: 'eu-west-1',
|
|
15
15
|
PROPERTY_ID_API:
|
|
16
16
|
'https://property-identification-api.cs.madgexhosting.net/properties/',
|
|
17
|
+
ASSETS_API_URL: 'https://asset-store.job.madgexhosting.net',
|
|
17
18
|
BRAND_JSON_FILENAME: 'brand.json',
|
|
18
19
|
FERT_CONFIG_FILENAME: 'fert.config.js',
|
|
19
20
|
ASSET_STORE_API: 'https://asset-store-api.{env}.madgexhosting.net/',
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/fert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Tool to help build the V6 branding",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fert": "./bin/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"lint": "eslint .",
|
|
10
|
+
"format": "prettier --write .",
|
|
10
11
|
"lint-staged": "lint-staged",
|
|
11
12
|
"semantic-release": "semantic-release",
|
|
12
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -27,11 +28,11 @@
|
|
|
27
28
|
"@hapi/hapi": "^21.3.2",
|
|
28
29
|
"@hapi/hoek": "^11.0.2",
|
|
29
30
|
"@hapi/inert": "^7.1.0",
|
|
30
|
-
"@hapi/vision": "^7.0.
|
|
31
|
+
"@hapi/vision": "^7.0.3",
|
|
31
32
|
"@hapipal/toys": "^4.0.0",
|
|
32
33
|
"@madgex/design-system": "*",
|
|
33
34
|
"@private/header-footer-podlet-server": "github:wiley/madgex-header-footer-podlet",
|
|
34
|
-
"axios": "^1.
|
|
35
|
+
"axios": "^1.5.0",
|
|
35
36
|
"cac": "^6.7.14",
|
|
36
37
|
"chalk": "4.1.2",
|
|
37
38
|
"chokidar": "^3.5.3",
|
|
@@ -39,31 +40,30 @@
|
|
|
39
40
|
"debug": "^4.3.4",
|
|
40
41
|
"form-data": "^4.0.0",
|
|
41
42
|
"lodash": "^4.17.21",
|
|
42
|
-
"node-fetch-commonjs": "^3.3.1",
|
|
43
43
|
"node-persist": "^3.1.3",
|
|
44
44
|
"nunjucks": "^3.2.4",
|
|
45
45
|
"open": "8.4.2",
|
|
46
46
|
"ora": "5.4.1",
|
|
47
47
|
"prompts": "^2.4.2",
|
|
48
48
|
"rimraf": "^5.0.1",
|
|
49
|
-
"sass": "^1.
|
|
49
|
+
"sass": "^1.66.1",
|
|
50
50
|
"simple-update-notifier": "^2.0.0",
|
|
51
51
|
"style-dictionary": "^3.8.0",
|
|
52
52
|
"uuid-validate": "^0.0.3",
|
|
53
|
-
"vite": "^4.4.
|
|
53
|
+
"vite": "^4.4.9",
|
|
54
54
|
"vite-plugin-static-copy": "^0.17.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@commitlint/cli": "^17.6.7",
|
|
58
|
-
"@commitlint/config-conventional": "^17.
|
|
58
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
59
59
|
"commitizen": "^4.3.0",
|
|
60
60
|
"cz-conventional-changelog": "^3.3.0",
|
|
61
|
-
"eslint": "^8.
|
|
62
|
-
"eslint-config-prettier": "^
|
|
61
|
+
"eslint": "^8.49.0",
|
|
62
|
+
"eslint-config-prettier": "^9.0.0",
|
|
63
63
|
"eslint-plugin-prettier": "^5.0.0",
|
|
64
64
|
"husky": "^8.0.3",
|
|
65
|
-
"lint-staged": "^
|
|
66
|
-
"prettier": "^3.0.
|
|
65
|
+
"lint-staged": "^14.0.1",
|
|
66
|
+
"prettier": "^3.0.3",
|
|
67
67
|
"semantic-release": "^21.1.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
package/server/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
const Hapi = require('@hapi/hapi');
|
|
2
2
|
const Toys = require('@hapipal/toys');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const { log } = require('../bin/utils');
|
|
4
|
+
const { log } = require('../bin/utils/logging');
|
|
5
5
|
const podletServer = require('@private/header-footer-podlet-server');
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
VERSION,
|
|
8
|
+
DEFAULT_DEV_PORT,
|
|
9
|
+
PROPERTY_ID_API,
|
|
10
|
+
ASSETS_API_URL,
|
|
11
|
+
} = require('../constants');
|
|
7
12
|
|
|
8
13
|
exports.devServer = async ({ start, fertConfig = {} } = {}) => {
|
|
9
14
|
const server = Hapi.server({
|
|
@@ -33,6 +38,8 @@ exports.devServer = async ({ start, fertConfig = {} } = {}) => {
|
|
|
33
38
|
isFert: true,
|
|
34
39
|
isProd: false,
|
|
35
40
|
templatePath: [path.resolve(fertConfig.workingDir, 'templates')],
|
|
41
|
+
clientPropertiesApi: PROPERTY_ID_API,
|
|
42
|
+
assetsApiUrl: ASSETS_API_URL,
|
|
36
43
|
},
|
|
37
44
|
routes: { prefix: '/_podlet' },
|
|
38
45
|
});
|
|
@@ -33,6 +33,16 @@ module.exports = {
|
|
|
33
33
|
input: options.entry,
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
+
css: {
|
|
37
|
+
preprocessorOptions: {
|
|
38
|
+
scss: {
|
|
39
|
+
additionalData: `
|
|
40
|
+
@import "../../public/tokens/scss/index.scss";
|
|
41
|
+
@import "@madgex/design-system/src/scss/import.scss";
|
|
42
|
+
`, // all scss processed files gets this injected at the top
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
36
46
|
});
|
|
37
47
|
|
|
38
48
|
await server.app.viteServer.listen();
|
package/server/routes/views.js
CHANGED
|
@@ -5,6 +5,7 @@ module.exports = {
|
|
|
5
5
|
path: '/{page*}',
|
|
6
6
|
handler: async (request, h) => {
|
|
7
7
|
const { page } = request.params;
|
|
8
|
+
const fertConfig = request.server.fertConfig();
|
|
8
9
|
|
|
9
10
|
// we'll pass over the headers as ModHeader may be used but
|
|
10
11
|
// remove the browsers 'accept-encoding' header otherwise
|
|
@@ -17,16 +18,11 @@ module.exports = {
|
|
|
17
18
|
method: request.method,
|
|
18
19
|
headers: filteredHeaders,
|
|
19
20
|
auth: request.auth.isAuthenticated ? request.auth : null,
|
|
21
|
+
app: {
|
|
22
|
+
clientPropertyId: fertConfig.clientPropertyId,
|
|
23
|
+
},
|
|
20
24
|
});
|
|
21
25
|
|
|
22
|
-
if (podletResponse.statusCode === 200) {
|
|
23
|
-
try {
|
|
24
|
-
podletResponse.result = JSON.parse(podletResponse.result);
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.error('Unable to parse podlet response', err);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
return h.view(page, {
|
|
31
27
|
auth: request.auth,
|
|
32
28
|
podletResponse,
|