@madgex/fert 4.1.0 → 4.1.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/.husky/commit-msg CHANGED
@@ -1,4 +1 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
1
  npx --no -- commitlint --edit "${1}"
package/.husky/pre-commit CHANGED
@@ -1,4 +1,2 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
1
  npm run lint-staged
2
+ npm run test
@@ -4,6 +4,7 @@ const Hoek = require('@hapi/hoek');
4
4
  const { log } = require('../utils/logging');
5
5
  const chalk = require('chalk');
6
6
  const ora = require('ora');
7
+ const { CONFIG_DIR } = require('../../constants');
7
8
 
8
9
  /**
9
10
  * Validates the local configuration files against the provided schema.
@@ -18,6 +19,13 @@ const ora = require('ora');
18
19
  const validateLocalConfigs = async (fertConfig, options = { catch: true }) => {
19
20
  Hoek.assert(fertConfig, 'fertConfig is required');
20
21
 
22
+ const dir = path.join(fertConfig.workingDir, CONFIG_DIR);
23
+ if (!fs.existsSync(dir)) {
24
+ log.debug(`Directory does not exist: ${dir}`);
25
+
26
+ return;
27
+ }
28
+
21
29
  const api = await getConfigAPI({
22
30
  clientPropertyId: fertConfig.clientPropertyId,
23
31
  });
@@ -65,13 +73,8 @@ const getConfigAPI = async ({
65
73
  };
66
74
 
67
75
  const loadLocalConfigs = (fertConfig) => {
68
- const dir = path.join(fertConfig.workingDir, 'config');
76
+ const dir = path.join(fertConfig.workingDir, CONFIG_DIR);
69
77
  const configs = {};
70
-
71
- if (!fs.existsSync(dir)) {
72
- throw new Error(`Directory does not exist: ${dir}`);
73
- }
74
-
75
78
  const files = fs.readdirSync(dir);
76
79
 
77
80
  files.forEach((file) => {
@@ -110,8 +113,15 @@ const updateProjectConfigs = async (
110
113
  ) => {
111
114
  Hoek.assert(fertConfig, 'fertConfig is required');
112
115
 
116
+ const dir = path.join(fertConfig.workingDir, CONFIG_DIR);
113
117
  let spinner;
114
118
 
119
+ if (!fs.existsSync(dir)) {
120
+ log.debug(`Directory does not exist: ${dir}`);
121
+
122
+ return;
123
+ }
124
+
115
125
  try {
116
126
  const api = await getConfigAPI({
117
127
  clientPropertyId: fertConfig.clientPropertyId,
@@ -0,0 +1,45 @@
1
+ const assert = require('node:assert');
2
+ const { describe, it } = require('node:test');
3
+ const fs = require('node:fs');
4
+ const { validateLocalConfigs, updateProjectConfigs } = require('./configs');
5
+ const { log } = require('../utils/logging');
6
+
7
+ describe('configs', () => {
8
+ describe('validateLocalConfigs', () => {
9
+ it('logs debug message if config directory does not exist', async (t) => {
10
+ const fsSpy = t.mock.method(fs, 'existsSync');
11
+ const logSpy = t.mock.method(log, 'debug');
12
+ const fertConfig = { workingDir: '/non/existent/dir' };
13
+ let calls;
14
+
15
+ await validateLocalConfigs(fertConfig);
16
+
17
+ calls = fsSpy.mock.calls;
18
+ assert.strictEqual(calls[0].arguments[0], '/non/existent/dir/config');
19
+ assert.strictEqual(fsSpy.mock.calls[0].result, false);
20
+
21
+ calls = logSpy.mock.calls;
22
+ assert.strictEqual(calls.length, 1);
23
+ assert.strictEqual(typeof calls[0].arguments[0], 'string');
24
+ });
25
+ });
26
+
27
+ describe('updateProjectConfigs', () => {
28
+ it('logs debug message if config directory does not exist', async (t) => {
29
+ const fsSpy = t.mock.method(fs, 'existsSync');
30
+ const logSpy = t.mock.method(log, 'debug');
31
+ const fertConfig = { workingDir: '/non/existent/dir' };
32
+ let calls;
33
+
34
+ await updateProjectConfigs(fertConfig);
35
+
36
+ calls = fsSpy.mock.calls;
37
+ assert.strictEqual(calls[0].arguments[0], '/non/existent/dir/config');
38
+ assert.strictEqual(fsSpy.mock.calls[0].result, false);
39
+
40
+ calls = logSpy.mock.calls;
41
+ assert.strictEqual(calls.length, 1);
42
+ assert.strictEqual(typeof calls[0].arguments[0], 'string');
43
+ });
44
+ });
45
+ });
package/constants.js CHANGED
@@ -51,4 +51,5 @@ module.exports = {
51
51
  ONE_WEEK,
52
52
  CONFIG_API:
53
53
  'https://configuration-api.job.madgexhosting.net/configs/override/{cpid}/production/clientconfig/{config}',
54
+ CONFIG_DIR: 'config',
54
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madgex/fert",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "Tool to help build the V6 branding",
5
5
  "bin": {
6
6
  "fert": "./bin/cli.js"
@@ -10,8 +10,8 @@
10
10
  "format": "prettier --write .",
11
11
  "lint-staged": "lint-staged",
12
12
  "semantic-release": "semantic-release",
13
- "test": "echo \"Error: no test specified\" && exit 1",
14
- "prepare": "husky install"
13
+ "test": "node --test ./bin/**/*.test.js",
14
+ "prepare": "husky"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -23,34 +23,34 @@
23
23
  "author": "Madgex",
24
24
  "license": "UNLICENSED",
25
25
  "dependencies": {
26
- "@aws-sdk/client-cloudfront": "^3.515.0",
27
- "@aws-sdk/client-ssm": "^3.519.0",
28
- "@aws-sdk/credential-providers": "^3.515.0",
29
- "@hapi/hapi": "^21.3.2",
30
- "@hapi/hoek": "^11.0.2",
26
+ "@aws-sdk/client-cloudfront": "^3.670.0",
27
+ "@aws-sdk/client-ssm": "^3.670.0",
28
+ "@aws-sdk/credential-providers": "^3.670.0",
29
+ "@hapi/hapi": "^21.3.10",
30
+ "@hapi/hoek": "^11.0.4",
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.0.6",
35
- "@madgex/design-system": "^7.0.0",
34
+ "@madgex/config-api-sdk": "^1.0.8",
35
+ "@madgex/design-system": "^9.1.2",
36
36
  "@private/header-footer-podlet-server": "github:wiley/madgex-header-footer-podlet",
37
- "axios": "^1.6.2",
37
+ "axios": "^1.7.7",
38
38
  "cac": "^6.7.14",
39
39
  "chalk": "4.1.2",
40
40
  "chokidar": "^3.5.3",
41
- "dayjs": "^1.11.10",
41
+ "dayjs": "^1.11.13",
42
42
  "debug": "^4.3.4",
43
43
  "dedent": "^1.5.3",
44
44
  "flat-cache": "^4.0.0",
45
- "form-data": "^4.0.0",
45
+ "form-data": "^4.0.1",
46
46
  "lodash": "^4.17.21",
47
47
  "nunjucks": "^3.2.4",
48
48
  "open": "8.4.2",
49
49
  "ora": "5.4.1",
50
50
  "prompts": "^2.4.2",
51
51
  "rimraf": "^5.0.5",
52
- "sass": "^1.69.5",
53
- "simple-git": "^3.24.0",
52
+ "sass": "^1.80.1",
53
+ "simple-git": "^3.27.0",
54
54
  "simple-update-notifier": "^2.0.0",
55
55
  "style-dictionary": "3.9.0",
56
56
  "uuid-validate": "^0.0.3",
@@ -58,16 +58,16 @@
58
58
  "vite-plugin-static-copy": "^0.17.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@commitlint/cli": "^18.4.2",
62
- "@commitlint/config-conventional": "^18.4.2",
63
- "commitizen": "^4.3.0",
61
+ "@commitlint/cli": "^19.6.0",
62
+ "@commitlint/config-conventional": "^19.6.0",
63
+ "commitizen": "^4.3.1",
64
64
  "cz-conventional-changelog": "^3.3.0",
65
65
  "eslint": "^8.53.0",
66
66
  "eslint-config-prettier": "^9.0.0",
67
67
  "eslint-plugin-prettier": "^5.0.1",
68
- "husky": "^8.0.3",
69
- "lint-staged": "^15.1.0",
70
- "prettier": "^3.1.0",
68
+ "husky": "^9.1.7",
69
+ "lint-staged": "^15.2.10",
70
+ "prettier": "^3.3.3",
71
71
  "semantic-release": "^22.0.8"
72
72
  },
73
73
  "peerDependencies": {