@madgex/fert 5.0.3 → 5.0.5

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 (127) hide show
  1. package/README.md +21 -12
  2. package/bin/cli.js +9 -27
  3. package/bin/commands/_service-command-bootstrap.js +12 -52
  4. package/bin/commands/build-tasks/build-tokens.js +8 -22
  5. package/bin/commands/build-tasks/bundle-entry.js +1 -4
  6. package/bin/commands/build.js +1 -0
  7. package/bin/commands/configs.js +17 -53
  8. package/bin/commands/dev-server.js +5 -14
  9. package/bin/commands/init.js +27 -117
  10. package/bin/commands/publish-tasks/asset-store-uploader.js +2 -5
  11. package/bin/commands/publish.js +10 -30
  12. package/bin/utils/configs.js +55 -95
  13. package/bin/utils/cpid-lookup.js +2 -2
  14. package/bin/utils/cpid-matches-git-remote.js +5 -10
  15. package/bin/utils/getSchemaMeta.js +1 -1
  16. package/bin/utils/index.js +14 -25
  17. package/bin/utils/lookup-cf-distribution-ids.js +2 -7
  18. package/bin/utils/resolve-external-assets.js +6 -15
  19. package/constants.js +3 -17
  20. package/package.json +17 -26
  21. package/repo-template/fert.config.js +3 -0
  22. package/repo-template/package.json +22 -0
  23. package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/brand.json +6 -3
  24. package/repo-template/services/jobseekers-frontend/fert.service.config.js +7 -0
  25. package/repo-template/services/jobseekers-frontend/public/icons/user.svg +4 -0
  26. package/repo-template/services/jobseekers-frontend/public/images/favicon.ico +0 -0
  27. package/repo-template/services/jobseekers-frontend/public/images/fred.jpeg +0 -0
  28. package/repo-template/services/jobseekers-frontend/src/css/styles.scss +1152 -0
  29. package/repo-template/services/jobseekers-frontend/src/index.js +9 -0
  30. package/repo-template/services/jobseekers-frontend/src/js/recruiter-link.js +25 -0
  31. package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/context/footer-nav.njk +26 -26
  32. package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/context/main-nav.njk +40 -31
  33. package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/context/user-nav.njk +16 -16
  34. package/repo-template/services/jobseekers-frontend/templates/footer.njk +20 -0
  35. package/repo-template/services/jobseekers-frontend/templates/header.njk +74 -0
  36. package/repo-template/services/jobseekers-frontend/templates/includes/footer-nav.njk +15 -0
  37. package/repo-template/services/jobseekers-frontend/templates/includes/main-nav.njk +19 -0
  38. package/repo-template/services/jobseekers-frontend/templates/includes/user-nav/authenticated.njk +34 -0
  39. package/repo-template/services/jobseekers-frontend/templates/includes/user-nav/unauthenticated.njk +9 -0
  40. package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/en.njk +1 -0
  41. package/server/index.js +2 -3
  42. package/server/plugins/hapi-vite.js +4 -2
  43. package/server/routes/views.js +1 -0
  44. package/server/view-manager.js +2 -5
  45. package/.prettierrc.js +0 -8
  46. package/bin/commands/configs.test.js +0 -182
  47. package/bin/utils/configs.test.js +0 -53
  48. package/bin/utils/persistent-cache-with-ttl.test.js +0 -42
  49. package/bin/utils/resolve-external-assets.test.js +0 -98
  50. package/delivery/jenkinsfile +0 -93
  51. package/eslint.config.mjs +0 -53
  52. package/repo-templates/globals/fert.config.js +0 -9
  53. package/repo-templates/template-basic/_gitignore +0 -6
  54. package/repo-templates/template-basic/package.json +0 -13
  55. package/repo-templates/template-basic/public/favicon.ico +0 -0
  56. package/repo-templates/template-basic/src/css/styles.scss +0 -11
  57. package/repo-templates/template-basic/src/index.js +0 -3
  58. package/repo-templates/template-basic/templates/footer.njk +0 -14
  59. package/repo-templates/template-basic/templates/header.njk +0 -14
  60. package/repo-templates/template-bigworkbag/_gitignore +0 -6
  61. package/repo-templates/template-bigworkbag/brand.json +0 -21
  62. package/repo-templates/template-bigworkbag/package.json +0 -13
  63. package/repo-templates/template-bigworkbag/public/favicon.ico +0 -0
  64. package/repo-templates/template-bigworkbag/public/fonts/mdgx-icons.eot +0 -0
  65. package/repo-templates/template-bigworkbag/public/fonts/mdgx-icons.svg +0 -71
  66. package/repo-templates/template-bigworkbag/public/fonts/mdgx-icons.ttf +0 -0
  67. package/repo-templates/template-bigworkbag/public/fonts/mdgx-icons.woff +0 -0
  68. package/repo-templates/template-bigworkbag/public/fonts/my-font.woff +0 -1
  69. package/repo-templates/template-bigworkbag/public/images/logo.png +0 -0
  70. package/repo-templates/template-bigworkbag/public/images/user-menu-pointer.svg +0 -4
  71. package/repo-templates/template-bigworkbag/src/css/breakpoints.scss +0 -17
  72. package/repo-templates/template-bigworkbag/src/css/clicky-menu.scss +0 -52
  73. package/repo-templates/template-bigworkbag/src/css/desktop-main-nav.scss +0 -25
  74. package/repo-templates/template-bigworkbag/src/css/desktop-user-nav.scss +0 -127
  75. package/repo-templates/template-bigworkbag/src/css/footer.scss +0 -77
  76. package/repo-templates/template-bigworkbag/src/css/header-top.scss +0 -29
  77. package/repo-templates/template-bigworkbag/src/css/leaderboard-ad.scss +0 -22
  78. package/repo-templates/template-bigworkbag/src/css/mobile-main-nav.scss +0 -68
  79. package/repo-templates/template-bigworkbag/src/css/mobile-user-nav.scss +0 -49
  80. package/repo-templates/template-bigworkbag/src/css/reset.scss +0 -91
  81. package/repo-templates/template-bigworkbag/src/css/styles.scss +0 -18
  82. package/repo-templates/template-bigworkbag/src/css/top-bar.scss +0 -13
  83. package/repo-templates/template-bigworkbag/src/css/typography.scss +0 -20
  84. package/repo-templates/template-bigworkbag/src/css/util.scss +0 -28
  85. package/repo-templates/template-bigworkbag/src/css/variables.scss +0 -9
  86. package/repo-templates/template-bigworkbag/src/index.js +0 -3
  87. package/repo-templates/template-bigworkbag/src/js/clicky-menus.js +0 -178
  88. package/repo-templates/template-bigworkbag/src/js/no-js.js +0 -10
  89. package/repo-templates/template-bigworkbag/templates/footer.njk +0 -68
  90. package/repo-templates/template-bigworkbag/templates/header.njk +0 -54
  91. package/repo-templates/template-bigworkbag/templates/includes/desktop-main-nav-items.njk +0 -18
  92. package/repo-templates/template-bigworkbag/templates/includes/desktop-user-nav/loggedin-items.njk +0 -28
  93. package/repo-templates/template-bigworkbag/templates/includes/desktop-user-nav/loggedout-items.njk +0 -9
  94. package/repo-templates/template-bigworkbag/templates/includes/desktop-user-nav/submenu-items.njk +0 -18
  95. package/repo-templates/template-bigworkbag/templates/includes/desktop-user-nav/user-nav.njk +0 -24
  96. package/repo-templates/template-bigworkbag/templates/includes/dev-console-context.njk +0 -7
  97. package/repo-templates/template-bigworkbag/templates/includes/mobile-main-nav-items.njk +0 -25
  98. package/repo-templates/template-bigworkbag/templates/includes/mobile-user-nav/loggedin-items.njk +0 -33
  99. package/repo-templates/template-bigworkbag/templates/includes/mobile-user-nav/loggedout-items.njk +0 -16
  100. package/repo-templates/template-bigworkbag/templates/includes/mobile-user-nav/user-nav.njk +0 -24
  101. package/repo-templates/template-bigworkbag/templates/svgs/arrow-down.svg +0 -3
  102. package/repo-templates/template-bigworkbag/templates/svgs/arrow-left.svg +0 -3
  103. package/repo-templates/template-bigworkbag/templates/svgs/arrow-right.svg +0 -3
  104. package/repo-templates/template-bigworkbag/templates/svgs/arrow-up.svg +0 -3
  105. package/repo-templates/template-bigworkbag/templates/svgs/cart.svg +0 -3
  106. package/repo-templates/template-bigworkbag/templates/svgs/facebook.svg +0 -3
  107. package/repo-templates/template-bigworkbag/templates/svgs/linkedin.svg +0 -3
  108. package/repo-templates/template-bigworkbag/templates/svgs/profile.svg +0 -5
  109. package/repo-templates/template-bigworkbag/templates/svgs/star-filled.svg +0 -3
  110. package/repo-templates/template-bigworkbag/templates/svgs/star-outline.svg +0 -3
  111. package/repo-templates/template-bigworkbag/templates/svgs/twitter.svg +0 -3
  112. package/repo-templates/template-bigworkbag/templates/svgs/youtube.svg +0 -3
  113. /package/{repo-templates/globals → repo-template}/jenkinsfile +0 -0
  114. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/fonts/mdgx-icons.eot +0 -0
  115. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/fonts/mdgx-icons.svg +0 -0
  116. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/fonts/mdgx-icons.ttf +0 -0
  117. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/fonts/mdgx-icons.woff +0 -0
  118. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/fonts/my-font.woff +0 -0
  119. /package/{repo-templates/template-basic → repo-template/services/jobseekers-frontend}/public/images/logo.png +0 -0
  120. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/da.njk +0 -0
  121. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/de.njk +0 -0
  122. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/es.njk +0 -0
  123. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/fr.njk +0 -0
  124. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/nb.njk +0 -0
  125. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/nl.njk +0 -0
  126. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/sv.njk +0 -0
  127. /package/{repo-templates/template-bigworkbag → repo-template/services/jobseekers-frontend}/templates/translations/zh-cn.njk +0 -0
package/README.md CHANGED
@@ -149,10 +149,9 @@ When faced with an empty branding repo, this will help the user get started with
149
149
 
150
150
  **Options**
151
151
 
152
- | Option | |
153
- | ----------------------- | ------------------------------------------------------ |
154
- | `--template <template>` | Specify the template you wish to use when scaffolding |
155
- | `--cpid <cpid>` | Specify the clientPropertyId to use in the new project |
152
+ | Option | |
153
+ | --------------- | ------------------------------------------------------ |
154
+ | `--cpid <cpid>` | Specify the clientPropertyId to use in the new project |
156
155
 
157
156
  **Outline of implementation**
158
157
 
@@ -198,7 +197,7 @@ Templates & CSS may be processed using the [CSS Modules](https://github.com/css-
198
197
  ## Publish
199
198
 
200
199
  From root, run for all services or a specific service:
201
- `fert publish --target=prod` | `fert publish --target=prod --service-name=jobseekers-frontend`
200
+ `fert publish --target=production` | `fert publish --target=production --service-name=jobseekers-frontend`
202
201
 
203
202
  Run for 1 service from the service folder:
204
203
  `cd services/jobseekers-frontend`
@@ -208,10 +207,10 @@ Run for 1 service from the service folder:
208
207
 
209
208
  `fert publish --target [target]`
210
209
 
211
- | Option | |
212
- | ----------- | ---------------------------------------------------------------------------- |
213
- | `--target` | Where to publish the `dist` directory assets.<br/>`dev` \| `prod` (`string`) |
214
- | `--dry-run` | Dry run, dont actually upload anything |
210
+ | Option | |
211
+ | ----------- | ---------------------------------------------------------------------------------- |
212
+ | `--target` | Where to publish the `dist` directory assets.<br/>`dev` \| `production` (`string`) |
213
+ | `--dry-run` | Dry run, dont actually upload anything |
215
214
 
216
215
  Send all files and directories created in the `dist` directory to either development or production versions of the Asset Store API. Files uploaded to the Asset Store API are available via a CloudFront-based CDN.
217
216
 
@@ -316,7 +315,19 @@ These options are available no matter the command used.
316
315
 
317
316
  # CI/CD
318
317
 
319
- It's intended that the branding repos have their own build/deploy pipeline. Each change that's merged to `master` will trigger a build (`npm run build` as a common entry point) and the resulting output directory (`dist`) is pushed up to the `asset-store-api` for use in production.
318
+ All branding repos use a common jekinsfile and Dockerfile to build/deploy, and will use this FERT tool.
319
+
320
+ - Here is the jenkinsfile all branding repos use: https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy .
321
+ - And the Dockerfile they all use [is in this repo](shared/Dockerfile.brandingRepoPublish).
322
+
323
+ Each change that's pushed to a branch will trigger:
324
+
325
+ 1. a build (`npm run build` inside the [Dockerfile](shared/Dockerfile.brandingRepoPublish) as a common entry point), which creates a `dist` folder full of assets ready to upload.
326
+ 2. The [jenkinsfile](https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy) pipeline will run `fert publish` to send all built assets to the Asset Store API.
327
+ 3. The [jenkinsfile](https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy) pipeline will run `fert configs --publish`, Uploading the branding repo's client `/configs` to the configuration-api.
328
+
329
+ > [!NOTE] > `master` branch will go to `production`. All other branches will go to `jb dev`.
330
+ > `master` branch will go to `production`. All other branches will go to `jb dev`.
320
331
 
321
332
  ## `npm scripts`
322
333
 
@@ -330,5 +341,3 @@ Here are the default npm scripts in a Fert-scaffolded project.
330
341
  }
331
342
  }
332
343
  ```
333
-
334
- Its expected that a Jenkins pipeline will run `fert publish` to send all built assets to the Asset Store API.
package/bin/cli.js CHANGED
@@ -6,18 +6,13 @@ const cli = require('cac')('fert');
6
6
  const { VERSION } = require('../constants');
7
7
  const { printBanner } = require('./utils/index.js');
8
8
 
9
- const {
10
- serivceCommandBootstrap,
11
- } = require('./commands/_service-command-bootstrap.js');
9
+ const { serivceCommandBootstrap } = require('./commands/_service-command-bootstrap.js');
12
10
 
13
11
  const run = () => {
14
12
  printBanner();
15
13
 
16
14
  cli
17
- .command(
18
- '',
19
- 'Start layout server. Can supply a branding directory if running FERT standalone'
20
- )
15
+ .command('', 'Start layout server. Can supply a branding directory if running FERT standalone')
21
16
  .alias('dev')
22
17
  .option('--open', 'Automatically open the dev server in your browser')
23
18
  .option('--host [host]', '[string] specify hostname')
@@ -26,10 +21,7 @@ const run = () => {
26
21
  .action((...args) => serivceCommandBootstrap('dev', ...args));
27
22
 
28
23
  cli
29
- .command(
30
- 'build',
31
- 'Build project. Can supply a branding directory if running FERT standalone'
32
- )
24
+ .command('build', 'Build project. Can supply a branding directory if running FERT standalone')
33
25
  .option('--only <task>', `Only run part of the build [ 'assets', 'tokens']`)
34
26
  .option('--config [dir]', 'Use custom rollup config file')
35
27
  .option('--service-name <serviceName>', '[string] run a single service')
@@ -37,34 +29,24 @@ const run = () => {
37
29
 
38
30
  cli
39
31
  .command('publish', 'Publish the project')
40
- .option('--target <env>', 'Environment to publish to, "dev" or "prod"')
32
+ .option('--target <env>', 'Environment to publish to, "dev" or "production"')
41
33
  .option('--service-name <serviceName>', '[string] run a single service')
42
34
  .option('--dry-run', 'Dry run, dont actually upload anything')
43
35
  .action((...args) => serivceCommandBootstrap('publish', ...args));
44
36
 
45
37
  cli
46
38
  .command('configs', 'Query/Publish project configs')
47
- .option(
48
- '--publish <env>',
49
- 'Publish configs to Configuration API environment "dev" or "production"'
50
- )
39
+ .option('--publish <env>', 'Publish configs to Configuration API environment "dev" or "production"')
51
40
  .option(
52
41
  '--download <env>',
53
- 'Download known configs from the Configuration API for environment "dev" or "production"'
54
- )
55
- .option(
56
- '--query [configName]',
57
- 'Describe known keys for a config, omit to list all known configs'
42
+ 'Download known configs from the Configuration API for environment "dev" or "production"',
58
43
  )
44
+ .option('--query [configName]', 'Describe known keys for a config, omit to list all known configs')
59
45
  .action((...args) => require('./commands/configs')(...args));
60
46
 
61
47
  cli
62
48
  .command('init [root]', 'Create a new branding project')
63
- .option('--template <template>', 'Template to use when scaffolding project')
64
- .option(
65
- '--cpid <cpid>',
66
- 'Specify the clientPropertyId to use in the new project'
67
- )
49
+ .option('--cpid <cpid>', 'Specify the clientPropertyId to use in the new project')
68
50
  .action((...args) => require('./commands/init')(...args));
69
51
 
70
52
  cli.option('--no-cache', 'Do not use cache');
@@ -89,6 +71,6 @@ try {
89
71
  } else {
90
72
  console.error(error);
91
73
  }
92
-
74
+ // eslint-disable-next-line n/no-process-exit
93
75
  process.exit(1);
94
76
  }
@@ -1,12 +1,6 @@
1
1
  const chalk = require('chalk');
2
2
 
3
- const {
4
- loadServiceConfigFiles,
5
- loadConfigFromFile,
6
- findFertConfigDir,
7
- } = require('../utils/index.js');
8
- const { getConfigAPI, validateLocalConfigs } = require('../utils/configs.js');
9
- const { handlePublish } = require('../commands/configs.js');
3
+ const { loadServiceConfigFiles, loadConfigFromFile } = require('../utils/index.js');
10
4
 
11
5
  const commandDevSever = require('./dev-server.js');
12
6
  const commandBuild = require('./build.js');
@@ -24,10 +18,7 @@ const commandMap = {
24
18
  * determine if we are running a single service, otherwise search for all services
25
19
  * Then run command
26
20
  */
27
- module.exports.serivceCommandBootstrap = async function serivceCommandBootstrap(
28
- command,
29
- options
30
- ) {
21
+ module.exports.serivceCommandBootstrap = async function serivceCommandBootstrap(command, options) {
31
22
  // explicitly run a single service - via CLI option
32
23
  if (options.serviceName) {
33
24
  console.log(`🔦 ${chalk.green('Running single service mode')}`);
@@ -65,50 +56,19 @@ module.exports.serivceCommandBootstrap = async function serivceCommandBootstrap(
65
56
  }
66
57
 
67
58
  console.log(
68
- `🔦 ${chalk.green('Running multi service mode')}, calling ${chalk.cyan(command)} on ${chalk.cyan(serviceConfigs.length)} ${serviceConfigs.length === 1 ? 'service' : 'services'} [${serviceConfigs.map((i) => chalk.cyanBright(i?.serviceConfig?.serviceName || 'Unknown')).join(', ')}]`
59
+ `🔦 ${chalk.green('Running multi service mode')}, calling ${chalk.cyan(command)} on ${chalk.cyan(serviceConfigs.length)} ${serviceConfigs.length === 1 ? 'service' : 'services'} [${serviceConfigs.map((i) => chalk.cyanBright(i?.serviceConfig?.serviceName || 'Unknown')).join(', ')}]`,
69
60
  );
70
- try {
71
- for (const { serviceConfig } of serviceConfigs) {
72
- try {
73
- await commandMap[command]({
74
- ...options,
75
- serviceName: serviceConfig.serviceName,
76
- });
77
- } catch (err) {
78
- throw new Error(
79
- `Failed to run command ${command} on service ${serviceConfig.serviceName}: ${err.message}`,
80
- { cause: err }
81
- );
82
- }
83
- }
84
61
 
85
- // if we're publishing, update all configs on configuration API
86
- if (command === 'publish') {
87
- options.target = options.target === 'dev' ? 'dev' : 'production';
88
- const rootDir = await findFertConfigDir();
89
- const { clientPropertyId } = await loadConfigFromFile({ dir: rootDir });
90
- const api = await getConfigAPI({
91
- clientPropertyId,
92
- environment: options.target,
62
+ for (const { serviceConfig } of serviceConfigs) {
63
+ try {
64
+ await commandMap[command]({
65
+ ...options,
66
+ serviceName: serviceConfig.serviceName,
67
+ });
68
+ } catch (err) {
69
+ throw new Error(`Failed to run command ${command} on service ${serviceConfig.serviceName}: ${err.message}`, {
70
+ cause: err,
93
71
  });
94
-
95
- // validate & upload local configs to configuration API
96
- if (!options.dryRun) {
97
- await handlePublish({ clientPropertyId, workingDir: rootDir }, api, {
98
- publish: options.target,
99
- });
100
- } else {
101
- await validateLocalConfigs({
102
- clientPropertyId,
103
- workingDir: rootDir,
104
- throwable: true,
105
- });
106
- }
107
-
108
- log.success(`${chalk.green('Publish completed successfully')}`);
109
72
  }
110
- } catch (error) {
111
- log.error('Failed to run command', command, options);
112
- console.error(error);
113
73
  }
114
74
  };
@@ -1,17 +1,13 @@
1
1
  const Path = require('node:path');
2
2
  const fs = require('node:fs/promises');
3
3
  const StyleDictionaryPackage = require('style-dictionary');
4
- const {
5
- registerTransforms,
6
- } = require('@madgex/design-system/tasks/registerTransforms');
4
+ const { registerTransforms } = require('@madgex/design-system/tasks/registerTransforms');
7
5
  const colorTransforms = require('@madgex/design-system/tasks/colorTransforms');
8
6
  const { ensureTrailingSlash, exists } = require('../../utils');
9
7
  const { log } = require('../../utils/logging');
10
8
  const { TMP_DIR } = require('../../../constants');
11
9
 
12
- const dsTokensPath = Path.dirname(
13
- require.resolve('@madgex/design-system/src/tokens/_config.js')
14
- );
10
+ const dsTokensPath = Path.dirname(require.resolve('@madgex/design-system/src/tokens/_config.js'));
15
11
 
16
12
  // eslint-disable-next-line no-unused-vars
17
13
  const createTempBrandFile = async (dir = './') => {
@@ -35,9 +31,9 @@ async function runSilently(fn) {
35
31
  console.log = originalLog;
36
32
  }
37
33
 
38
- module.exports = async function buildCssFromTokens(srcTokensPath, buildPath) {
39
- srcTokensPath = ensureTrailingSlash(Path.resolve(srcTokensPath));
40
- buildPath = ensureTrailingSlash(Path.resolve(buildPath));
34
+ module.exports = async function buildCssFromTokens(_srcTokensPath, _buildPath) {
35
+ const srcTokensPath = ensureTrailingSlash(Path.resolve(_srcTokensPath));
36
+ const buildPath = ensureTrailingSlash(Path.resolve(_buildPath));
41
37
 
42
38
  const brandFile = Path.join(srcTokensPath, 'brand.json');
43
39
 
@@ -46,24 +42,14 @@ module.exports = async function buildCssFromTokens(srcTokensPath, buildPath) {
46
42
  }
47
43
 
48
44
  // Fetch the file so we can transform the colours in style dictionary
49
- const brandObj = JSON.parse(
50
- await fs.readFile(brandFile, { encoding: 'utf8' })
51
- );
45
+ const brandObj = JSON.parse(await fs.readFile(brandFile, { encoding: 'utf8' }));
52
46
  const tmpBrandFile = await createTempBrandFile(srcTokensPath);
53
47
 
54
- await fs.writeFile(
55
- Path.join(tmpBrandFile),
56
- JSON.stringify(colorTransforms(brandObj))
57
- );
48
+ await fs.writeFile(Path.join(tmpBrandFile), JSON.stringify(colorTransforms(brandObj)));
58
49
 
59
50
  // TODO - Investigate whether we can retrieve from DS instead of redefining
60
51
  // e.g. const { registerTransforms } = require('@madgex/design-system/tasks/registerTransforms');
61
- const transforms = [
62
- 'attribute/cti',
63
- 'name/cti/kebab',
64
- 'color/css',
65
- 'css/rawData',
66
- ];
52
+ const transforms = ['attribute/cti', 'name/cti/kebab', 'color/css', 'css/rawData'];
67
53
  const prefix = 'mds';
68
54
 
69
55
  // TODO - Investigate whether we can retrieve from DS instead of redefining
@@ -21,10 +21,7 @@ module.exports = async (fertConfig, options = {}) => {
21
21
  cssCodeSplit: false, // important: to get a single, style.css file output
22
22
  outDir: path.resolve(fertConfig.workingDir, 'dist'),
23
23
  rollupOptions: {
24
- input: path.resolve(
25
- fertConfig.workingDir,
26
- fertConfig.entry || './src/index.js'
27
- ),
24
+ input: path.resolve(fertConfig.workingDir, fertConfig.entry || './src/index.js'),
28
25
  },
29
26
  },
30
27
  };
@@ -34,6 +34,7 @@ module.exports = async (options = {}) => {
34
34
  }
35
35
  };
36
36
 
37
+ // eslint-disable-next-line n/no-exports-assign
37
38
  exports = module.exports; // allow default export & { named } exports
38
39
 
39
40
  // eslint-disable-next-line no-unused-vars
@@ -12,9 +12,7 @@ const handleDownload = async ({ workingDir }, api, options) => {
12
12
  const validTargets = ['dev', 'production'];
13
13
 
14
14
  if (!validTargets.includes(options.download)) {
15
- throw new Error(
16
- `Missing or invalid --download option. Choose from [${validTargets}]`
17
- );
15
+ throw new Error(`Missing or invalid --download option. Choose from [${validTargets}]`);
18
16
  }
19
17
 
20
18
  const spinner = ora('Downloading v6 configs...').start();
@@ -53,7 +51,7 @@ const handleDownload = async ({ workingDir }, api, options) => {
53
51
  } catch (error) {
54
52
  log.debug(
55
53
  `Unable to retrieve ${chalk.cyan(error.url || schemaName + '/' + configKey)}`,
56
- error.message || error.statusText || error
54
+ error.message || error.statusText || error,
57
55
  );
58
56
  }
59
57
  }
@@ -61,9 +59,7 @@ const handleDownload = async ({ workingDir }, api, options) => {
61
59
 
62
60
  spinner.succeed();
63
61
  } catch (error) {
64
- spinner.fail(
65
- `Error ${error.code ? `[${error.code}]` : ''}: ${error.message}`
66
- );
62
+ spinner.fail(`Error ${error.code ? `[${error.code}]` : ''}: ${error.message}`);
67
63
  throw error;
68
64
  }
69
65
 
@@ -83,17 +79,11 @@ const handleDownload = async ({ workingDir }, api, options) => {
83
79
  }
84
80
  };
85
81
 
86
- const handlePublish = async (
87
- { workingDir, clientPropertyId },
88
- api,
89
- options
90
- ) => {
82
+ const handlePublish = async ({ workingDir, clientPropertyId }, api, options) => {
91
83
  const validTargets = ['dev', 'production'];
92
84
 
93
85
  if (!validTargets.includes(options.publish)) {
94
- throw new Error(
95
- `Missing or invalid --publish option. Choose from [${validTargets}]`
96
- );
86
+ throw new Error(`Missing or invalid --publish option. Choose from [${validTargets}]`);
97
87
  }
98
88
 
99
89
  try {
@@ -104,34 +94,23 @@ const handlePublish = async (
104
94
  });
105
95
  } catch (err) {
106
96
  log.debug(err);
97
+ // eslint-disable-next-line n/no-process-exit
107
98
  process.exit(1);
108
99
  }
109
100
  };
110
101
 
111
- const handleQuery = async (
112
- /* { workingDir, clientPropertyId } */ _,
113
- api,
114
- options
115
- ) => {
102
+ const handleQuery = async (/* { workingDir, clientPropertyId } */ _, api, options) => {
116
103
  try {
117
104
  if (options.query !== true) {
118
- console.log(
119
- chalk.cyan(
120
- `\nGetting schema description for config: ${chalk.bold(options.query)}...`
121
- )
122
- );
105
+ console.log(chalk.cyan(`\nGetting schema description for config: ${chalk.bold(options.query)}...`));
123
106
  const schema = api.schemas[options.query];
124
107
  if (!schema) {
125
- console.error(
126
- chalk.red(`Schema not found for ${chalk.bold(options.query)}`)
127
- );
108
+ console.error(chalk.red(`Schema not found for ${chalk.bold(options.query)}`));
128
109
  return;
129
110
  }
130
111
 
131
112
  console.log(JSON.stringify(schema.describe().keys, null, 2));
132
- console.log(
133
- `\n${chalk.cyan('Configs default values')}:\n${JSON.stringify(schema.validate({}).value, null, 2)}`
134
- );
113
+ console.log(`\n${chalk.cyan('Configs default values')}:\n${JSON.stringify(schema.validate({}).value, null, 2)}`);
135
114
  return;
136
115
  }
137
116
 
@@ -141,14 +120,13 @@ const handleQuery = async (
141
120
  .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
142
121
  .map((key) => ` * ${key}`)
143
122
  .join('\n'),
144
- '\n'
123
+ '\n',
145
124
  );
146
125
 
147
- console.log(
148
- 'Use `fert configs <configName>` to get a specific schema description'
149
- );
126
+ console.log('Use `fert configs <configName>` to get a specific schema description');
150
127
  } catch (err) {
151
128
  log.debug(err);
129
+ // eslint-disable-next-line n/no-process-exit
152
130
  process.exit(1);
153
131
  }
154
132
  };
@@ -165,30 +143,16 @@ module.exports = async (options) => {
165
143
  });
166
144
 
167
145
  if (!options.publish && !options.query && !options.download) {
168
- console.log(
169
- chalk.red(`Missing required --publish, --query or --download option`)
170
- );
146
+ console.log(chalk.red(`Missing required --publish, --query or --download option`));
171
147
  return;
172
148
  }
173
149
 
174
150
  if (options.download) {
175
- await handleDownload(
176
- { clientPropertyId, workingDir: fertConfigDir },
177
- api,
178
- options
179
- );
151
+ await handleDownload({ clientPropertyId, workingDir: fertConfigDir }, api, options);
180
152
  } else if (options.publish) {
181
- await handlePublish(
182
- { clientPropertyId, workingDir: fertConfigDir },
183
- api,
184
- options
185
- );
153
+ await handlePublish({ clientPropertyId, workingDir: fertConfigDir }, api, options);
186
154
  } else if (options.query) {
187
- await handleQuery(
188
- { clientPropertyId, workingDir: fertConfigDir },
189
- api,
190
- options
191
- );
155
+ await handleQuery({ clientPropertyId, workingDir: fertConfigDir }, api, options);
192
156
  }
193
157
  };
194
158
 
@@ -7,21 +7,15 @@ const { log } = require('../utils/logging.js');
7
7
  const { validateLocalConfigs } = require('../utils/configs.js');
8
8
  const { devServer } = require('../../server');
9
9
  const { buildTokens, buildExternalAssets } = require('./build.js');
10
- const {
11
- BRAND_JSON_FILENAME,
12
- FERT_CONFIG_FILENAME,
13
- FERT_SERVICE_CONFIG_FILENAME,
14
- } = require('../../constants.js');
10
+ const { BRAND_JSON_FILENAME, FERT_CONFIG_FILENAME, FERT_SERVICE_CONFIG_FILENAME } = require('../../constants.js');
15
11
 
16
12
  module.exports = async (options = {}) => {
17
13
  let fertConfig = await resolveConfig(options);
18
14
 
19
15
  console.log(
20
- `Starting branding server for ${chalk.green(
21
- fertConfig.client.brandName
22
- )} [${fertConfig.serviceName}] ${chalk.dim(
23
- `(${fertConfig.clientPropertyId})`
24
- )}\n`
16
+ `Starting branding server for ${chalk.green(fertConfig.client.brandName)} [${fertConfig.serviceName}] ${chalk.dim(
17
+ `(${fertConfig.clientPropertyId})`,
18
+ )}\n`,
25
19
  );
26
20
 
27
21
  await validateLocalConfigs({
@@ -50,10 +44,7 @@ module.exports = async (options = {}) => {
50
44
  });
51
45
 
52
46
  const configPath = path.resolve(fertConfigDir, FERT_CONFIG_FILENAME);
53
- const serviceConfigPath = path.resolve(
54
- fertConfig.workingDir,
55
- FERT_SERVICE_CONFIG_FILENAME
56
- );
47
+ const serviceConfigPath = path.resolve(fertConfig.workingDir, FERT_SERVICE_CONFIG_FILENAME);
57
48
  chokidar.watch([configPath, serviceConfigPath]).on('change', async () => {
58
49
  console.log('Config changed, reloading…');
59
50
  fertConfig = await resolveConfig(options);