cht-conf 4.5.0 → 4.7.0

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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [4.7.0](https://github.com/medic/cht-conf/compare/v4.6.0...v4.7.0) (2025-04-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * **#683:** add autocompletion feature for zsh ([#684](https://github.com/medic/cht-conf/issues/684)) ([356f2e8](https://github.com/medic/cht-conf/commit/356f2e8c25fa42e26d53e2d6df3be85da1bda704)), closes [#683](https://github.com/medic/cht-conf/issues/683)
7
+
8
+ # [4.6.0](https://github.com/medic/cht-conf/compare/v4.5.0...v4.6.0) (2025-04-23)
9
+
10
+
11
+ ### Features
12
+
13
+ * **#502:** warn when using deprecated `db-object` appearance ([#682](https://github.com/medic/cht-conf/issues/682)) ([ca6691b](https://github.com/medic/cht-conf/commit/ca6691b1f3285d1a59093fc3a6bb2c980dcb78e0)), closes [#502](https://github.com/medic/cht-conf/issues/502)
14
+
1
15
  # [4.5.0](https://github.com/medic/cht-conf/compare/v4.4.1...v4.5.0) (2025-04-15)
2
16
 
3
17
 
package/README.md CHANGED
@@ -68,6 +68,11 @@ To enable tab completion in bash, add the following to your `.bashrc`/`.bash_pro
68
68
 
69
69
  eval "$(cht --shell-completion=bash)"
70
70
 
71
+ ## Zsh completion
72
+ To enable tab completion in zsh, add the following to your `~/.zshrc` file:
73
+
74
+ eval "$(cht --shell-completion=zsh)"
75
+
71
76
  ## Upgrading
72
77
 
73
78
  To upgrade to the latest version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cht-conf",
3
- "version": "4.5.0",
3
+ "version": "4.7.0",
4
4
  "description": "Configure CHT deployments",
5
5
  "main": "./src/lib/main.js",
6
6
  "engines": {
@@ -1,6 +1,6 @@
1
1
  const fs = require('../lib/sync-fs');
2
2
 
3
- const SUPPORTED_SHELLS = ['bash'];
3
+ const SUPPORTED_SHELLS = ['bash','zsh'];
4
4
 
5
5
  module.exports = shell => {
6
6
  if (SUPPORTED_SHELLS.includes(shell)){
@@ -0,0 +1,26 @@
1
+ #compdef cht
2
+
3
+ _cht() {
4
+ local curcontext="$curcontext" state line
5
+ typeset -A opt_args
6
+
7
+ # Get the current word being completed
8
+ local current_word="${words[CURRENT]}"
9
+ local current_pos=$CURRENT
10
+
11
+ # Call the shell-completion-for-cht program to get available options
12
+ # current_pos - 1 gives the index of the previous word, which is typically the argument it is the word just before the current word
13
+ # previous_word helps in setting correct context for the completion
14
+
15
+ local completion_options
16
+ completion_options=$(shell-completion-for-cht $((current_pos-1)) "$current_word")
17
+
18
+ # Split the output by spaces into an array
19
+ local -a completion_array
20
+ completion_array=(${=completion_options})
21
+
22
+ # Provide completions
23
+ compadd -a completion_array
24
+ }
25
+ #Register the completion function
26
+ compdef _cht cht
@@ -120,6 +120,7 @@ const compileAppSettingsForProject = async (projectDir, options) => {
120
120
  );
121
121
  appSettings = fs.readJson(appSettingsPath);
122
122
  }
123
+
123
124
  appSettings.contact_summary = await compilation.compileContactSummary(projectDir, options);
124
125
  const compiledTasksAndTargets = await compilation.compileTasksAndTargets(projectDir, options);
125
126
  appSettings.tasks = {
@@ -133,7 +134,10 @@ const compileAppSettingsForProject = async (projectDir, options) => {
133
134
  if (purgeConfig) {
134
135
  appSettings.purge = purgeConfig;
135
136
  }
136
-
137
+ else{
138
+ warn('Setting purge configuration to empty object as purge.js and purging.js files were not found.');
139
+ appSettings.purge = {};
140
+ }
137
141
  return appSettings;
138
142
  };
139
143
 
@@ -53,9 +53,8 @@ module.exports = (projectDir) => {
53
53
  }
54
54
 
55
55
  if (typeof purgeFn !== 'function') {
56
- throwError('Configured purging.js does not contain a function');
56
+ throwError('Configured purge file does not contain a function');
57
57
  }
58
-
59
58
  const appSettings = fs.readJson(path.join(projectDir, 'app_settings.json'));
60
59
  purgeConfig = appSettings.purging || {};
61
60
  purgeConfig.fn = purgeFnString;
@@ -24,6 +24,11 @@ const getDeprecatedAppearances = (apiVersion) => [
24
24
  getReplacement: () => 'columns-pack no-buttons',
25
25
  versionDeprecated: '4.0.0'
26
26
  },
27
+ {
28
+ match: appearance => appearance.match(/(?:^|\s)db-object(?:$|\s)/),
29
+ getReplacement: () => 'select-contact',
30
+ versionDeprecated: '3.9.0'
31
+ },
27
32
  ].filter(deprecatedAppearance => semver.gte(apiVersion, deprecatedAppearance.versionDeprecated));
28
33
 
29
34
  const getElementsWithAppearance = (xmlDoc) => getNodes(xmlDoc, '/h:html/h:body//*[@appearance]');
@@ -54,8 +59,7 @@ const createWarning = ({ ref, appearance, deprecatedAppearance }) => {
54
59
  const populateWarningHeader = (xformPath, warnings) => {
55
60
  if (warnings.length) {
56
61
  warnings.unshift(
57
- `Form at ${xformPath} contains fields with the deprecated \`horizontal\`/\`compact\` appearance. `
58
- + 'These have been deprecated in favor of the `columns` appearance. Please update the following fields:'
62
+ `Form at ${xformPath} contains fields with a deprecated appearance. Please update the following:`
59
63
  );
60
64
  }
61
65
  };