cht-conf 4.0.0 → 4.1.1

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.1.1](https://github.com/medic/cht-conf/compare/v4.1.0...v4.1.1) (2024-08-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **#632:** replace cht-conf with cht in readme.md ([fc5b7f3](https://github.com/medic/cht-conf/commit/fc5b7f3ee5e1b8ae381b3182efbeedd4b6631418)), closes [#632](https://github.com/medic/cht-conf/issues/632)
7
+
8
+ # [4.1.0](https://github.com/medic/cht-conf/compare/v4.0.0...v4.1.0) (2024-07-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * **#425:** E2E test actions ([#620](https://github.com/medic/cht-conf/issues/620)) ([ba54d49](https://github.com/medic/cht-conf/commit/ba54d49730b73c6d77b219a45b8ba3d98b909227)), closes [#425](https://github.com/medic/cht-conf/issues/425) [#425](https://github.com/medic/cht-conf/issues/425)
14
+
1
15
  # [4.0.0](https://github.com/medic/cht-conf/compare/v3.23.0...v4.0.0) (2024-07-01)
2
16
 
3
17
 
package/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:16-slim
1
+ FROM node:20-slim
2
2
 
3
3
  RUN apt update \
4
4
  && apt install --no-install-recommends -y \
@@ -9,6 +9,7 @@ RUN apt update \
9
9
  openssh-client \
10
10
  python3-pip \
11
11
  python3-setuptools \
12
+ python3-venv \
12
13
  python3-wheel \
13
14
  xsltproc \
14
15
  # Remove chromium to save space. We only installed it to get the transitive dependencies that are needed
@@ -16,6 +17,10 @@ RUN apt update \
16
17
  && apt remove -y chromium \
17
18
  && rm -rf /var/lib/apt/lists/*
18
19
 
20
+ ENV VIRTUAL_ENV=/opt/venv
21
+ RUN python3 -m venv "$VIRTUAL_ENV"
22
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
23
+
19
24
  RUN python3 -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
20
25
 
21
26
  RUN npm install -g cht-conf
package/README.md CHANGED
@@ -42,7 +42,7 @@ Install [Docker](https://www.docker.com/). If you are using Windows, you also ne
42
42
 
43
43
  ##### VS Code Development Container
44
44
 
45
- If you want to develop CHT apps with VS Code, you can use the Docker image as a Development Container. This will allow you to use the `cht-conf` utility and its associated tech stack from within VS Code (without needing to install dependencies like NodeJS on your host system).
45
+ If you want to develop CHT apps with VS Code, you can use the Docker image as a Development Container. This will allow you to use the `cht` utility and its associated tech stack from within VS Code (without needing to install dependencies like NodeJS on your host system).
46
46
 
47
47
  See the [CHT Documentation](https://docs.communityhealthtoolkit.org/apps/tutorials/local-setup/#developing-with-vs-code-dev-container) for more information on building CHT apps with VS Code Development Containers.
48
48
 
@@ -58,7 +58,7 @@ docker run -it --rm -v "$PWD":/workdir medicmobile/cht-app-ide initialise-projec
58
58
 
59
59
  #### Note on connecting to a local CHT instance
60
60
 
61
- When using `cht-conf` within a Docker container to connect to a CHT instance that is running on your local machine (e.g. a development instance), you cannot use the `--local` flag or `localhost` in your `--url` parameter (since these will be interpreted as "local to the container").
61
+ When using `cht` within a Docker container to connect to a CHT instance that is running on your local machine (e.g. a development instance), you cannot use the `--local` flag or `localhost` in your `--url` parameter (since these will be interpreted as "local to the container").
62
62
 
63
63
  It is recommended to run a local CHT instance using the [CHT Docker Helper script](https://docs.communityhealthtoolkit.org/apps/guides/hosting/4.x/app-developer/). You can connect to the resulting `...my.local-ip.co` URL from the Docker container (or the VS Code terminal). (Just make sure the port your CHT instance is hosted on is not blocked by your firewall).
64
64
 
@@ -66,7 +66,7 @@ It is recommended to run a local CHT instance using the [CHT Docker Helper scrip
66
66
 
67
67
  To enable tab completion in bash, add the following to your `.bashrc`/`.bash_profile`:
68
68
 
69
- eval "$(cht-conf --shell-completion=bash)"
69
+ eval "$(cht --shell-completion=bash)"
70
70
 
71
71
  ## Upgrading
72
72
 
@@ -303,8 +303,16 @@ To develop a new action or improve an existing one, check the ["Actions" doc](sr
303
303
 
304
304
  ## Testing
305
305
 
306
+ ### Unit tests
307
+
306
308
  Execute `npm test` to run static analysis checks and the test suite. Requires Docker to run integration tests against a CouchDB instance.
307
309
 
310
+ ### End-to-end tests
311
+
312
+ Run `npm run test-e2e` to run the end-to-end test suite against an actual CHT instance locally. These tests rely on [CHT Docker Helper](https://docs.communityhealthtoolkit.org/hosting/4.x/app-developer/#cht-docker-helper-for-4x) to spin up and tear down an instance locally.
313
+
314
+ The code interfacing with CHT Docker Helper lives in [`test/e2e/cht-docker-utils.js`](./test/e2e/cht-docker-utils.js). You should rely on the API exposed by this file to orchestrate CHT instances for testing purposes. It is preferable to keep the number of CHT instances orchestrated in E2E tests low as it takes a non-negligible amount of time to spin up an instance and can quickly lead to timeouts.
315
+
308
316
  ## Executing your local branch
309
317
 
310
318
  1. Clone the project locally
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cht-conf",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "Configure CHT deployments",
5
5
  "main": "./src/lib/main.js",
6
6
  "engines": {
@@ -11,7 +11,8 @@
11
11
  "eslint": "eslint 'src/**/*.js' test/*.js 'test/**/*.js'",
12
12
  "docker-start-couchdb": "npm run docker-stop-couchdb && docker run -d -p 6984:5984 --rm --name cht-conf-couchdb couchdb:2.3.1 && sh test/scripts/wait_for_response_code.sh 6984 200 CouchDB",
13
13
  "docker-stop-couchdb": "docker stop cht-conf-couchdb || true",
14
- "test": "npm run eslint && npm run docker-start-couchdb && npm run clean && mkdir -p build/test && cp -r test/data build/test/data && cd build/test && nyc --reporter=html mocha --forbid-only \"../../test/**/*.spec.js\" && cd ../.. && npm run docker-stop-couchdb",
14
+ "test": "npm run eslint && npm run docker-start-couchdb && npm run clean && mkdir -p build/test && cp -r test/data build/test/data && cd build/test && nyc --reporter=html mocha --forbid-only \"../../test/**/*.spec.js\" --exclude \"../../test/e2e/**/*.spec.js\" && cd ../.. && npm run docker-stop-couchdb",
15
+ "test-e2e": "mocha --config test/e2e/.mocharc.js",
15
16
  "semantic-release": "semantic-release"
16
17
  },
17
18
  "bin": {
@@ -35,46 +36,46 @@
35
36
  },
36
37
  "homepage": "https://github.com/medic/cht-conf#readme",
37
38
  "dependencies": {
38
- "@medic/translation-checker": "^1.0.1",
39
- "@parcel/watcher": "^2.0.5",
39
+ "@medic/translation-checker": "^1.1.0",
40
+ "@parcel/watcher": "^2.1.0",
40
41
  "@xmldom/xmldom": "^0.8.10",
41
42
  "async-retry": "^1.3.3",
42
43
  "canonical-json": "0.0.4",
43
- "csv-parse": "^4.16.0",
44
+ "csv-parse": "^5.5.6",
44
45
  "dom-compare": "^0.6.0",
45
- "eslint": "^6.8.0",
46
- "eslint-loader": "^3.0.4",
47
- "googleapis": "^84.0.0",
48
- "iso-639-1": "^3.1.0",
49
- "joi": "^17.11.0",
50
- "json-diff": "^0.5.4",
46
+ "eslint": "^8.57.0",
47
+ "eslint-webpack-plugin": "^2.7.0",
48
+ "googleapis": "^140.0.1",
49
+ "iso-639-1": "^3.1.2",
50
+ "joi": "^17.13.3",
51
+ "json-diff": "^1.0.6",
51
52
  "json-stringify-safe": "^5.0.1",
52
53
  "json2csv": "^4.5.4",
53
54
  "mime-types": "^2.1.35",
54
55
  "minimist": "^1.2.8",
55
- "mkdirp": "^1.0.4",
56
- "open": "^7.4.2",
56
+ "mkdirp": "^3.0.1",
57
+ "open": "^8.4.2",
57
58
  "pluralize": "^8.0.0",
58
59
  "pouchdb-adapter-http": "^7.2.2",
59
60
  "pouchdb-core": "^7.2.2",
60
61
  "pouchdb-mapreduce": "^7.2.2",
61
- "pouchdb-session-authentication": "^1.3.0",
62
+ "pouchdb-session-authentication": "^1.4.0",
62
63
  "properties": "^1.2.1",
63
64
  "queue-promise": "^2.2.1",
64
65
  "readline-sync": "^1.4.10",
65
66
  "redact-basic-auth": "^1.0.1",
66
67
  "request": "^2.88.2",
67
68
  "request-promise-native": "^1.0.9",
68
- "semver": "^6.1.1",
69
- "svgo": "^1.3.2",
70
- "terser-webpack-plugin": "^1.4.3",
71
- "uuid": "^8.3.2",
72
- "webpack": "^4.46.0",
69
+ "semver": "^7.6.3",
70
+ "svgo": "^3.3.2",
71
+ "terser-webpack-plugin": "^5.3.10",
72
+ "uuid": "^10.0.0",
73
+ "webpack": "^5.93.0",
73
74
  "xpath": "0.0.33"
74
75
  },
75
76
  "devDependencies": {
76
- "@commitlint/cli": "^13.2.0",
77
- "@commitlint/config-conventional": "^13.2.0",
77
+ "@commitlint/cli": "^19.3.0",
78
+ "@commitlint/config-conventional": "^19.2.2",
78
79
  "@semantic-release/changelog": "^6.0.3",
79
80
  "@semantic-release/git": "^10.0.1",
80
81
  "body-parser": "^1.20.2",
@@ -83,16 +84,16 @@
83
84
  "chai-exclude": "^2.1.0",
84
85
  "chai-shallow-deep-equal": "^1.4.6",
85
86
  "chai-xml": "^0.4.1",
86
- "eslint-plugin-node": "^11.1.0",
87
- "express": "^4.18.2",
87
+ "eslint-plugin-n": "^17.9.0",
88
+ "express": "^4.19.2",
88
89
  "express-pouchdb": "^4.2.0",
89
- "fs-extra": "8.1.0",
90
- "husky": "^7.0.2",
91
- "mocha": "^6.2.3",
92
- "nyc": "^15.1.0",
90
+ "fs-extra": "11.2.0",
91
+ "husky": "^9.1.1",
92
+ "mocha": "^10.7.0",
93
+ "nyc": "^17.0.0",
93
94
  "pouchdb-adapter-memory": "^7.2.2",
94
- "rewire": "^5.0.0",
95
- "semantic-release": "^18.0.0",
96
- "sinon": "^8.1.1"
95
+ "rewire": "^7.0.0",
96
+ "semantic-release": "^22.0.0",
97
+ "sinon": "^18.0.0"
97
98
  }
98
99
  }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "env": {
3
- "es6": true,
3
+ "es2022": true,
4
4
  "node": true
5
5
  },
6
6
  "root": true,
7
7
  "parserOptions": {
8
- "ecmaVersion": 5
8
+ "ecmaVersion": 2022
9
9
  },
10
10
  "extends": "eslint:recommended",
11
11
  "rules": {
@@ -1,4 +1,4 @@
1
- /*eslint node/no-missing-require: "off"*/
1
+ /*eslint n/no-missing-require: "off"*/
2
2
  const compressPng = require('../lib/compress-png').execute;
3
3
  const compressSvg = require('../lib/compress-svg').execute;
4
4
 
@@ -2,8 +2,7 @@ const environment = require('../lib/environment');
2
2
  const fs = require('../lib/sync-fs');
3
3
  const { info, trace, warn } = require('../lib/log');
4
4
 
5
- const SVGO = require('svgo');
6
- const svgo = new SVGO();
5
+ const svgo = require('svgo');
7
6
 
8
7
  module.exports = {
9
8
  requiresInstance: false,
@@ -1,4 +1,4 @@
1
- const csvParse = require('csv-parse/lib/sync');
1
+ const { parse: csvParse } = require('csv-parse/sync');
2
2
  const userPrompt = require('../../src/lib/user-prompt');
3
3
 
4
4
  const api = require('../lib/api');
@@ -90,4 +90,4 @@ const execute = async () => {
90
90
  module.exports = {
91
91
  requiresInstance: true,
92
92
  execute
93
- };
93
+ };
@@ -20,10 +20,10 @@ const LAYOUT = {
20
20
  '.eslintrc': `{
21
21
  "env": {
22
22
  "node": true,
23
- "es6": true
23
+ "es2022": true,
24
24
  },
25
25
  "parserOptions": {
26
- "ecmaVersion": 6
26
+ "ecmaVersion": 2022
27
27
  }
28
28
  }`,
29
29
  forms: {
@@ -2,6 +2,7 @@ const fs = require('fs');
2
2
  const os = require('os');
3
3
  const path = require('path');
4
4
  const TerserPlugin = require('terser-webpack-plugin');
5
+ const ESLintPlugin = require('eslint-webpack-plugin');
5
6
  const webpack = require('webpack');
6
7
 
7
8
  const fsUtils = require('../sync-fs');
@@ -17,7 +18,7 @@ module.exports = (pathToProject, entry, baseEslintPath, options = {}) => {
17
18
  const outputDirectoryPath = os.tmpdir();
18
19
  const outputFilename = `./${libName}.js`;
19
20
 
20
- const compiler = webpack([{
21
+ const compiler = webpack({
21
22
  mode: 'production',
22
23
  entry,
23
24
  output: {
@@ -25,7 +26,7 @@ module.exports = (pathToProject, entry, baseEslintPath, options = {}) => {
25
26
  filename: outputFilename,
26
27
  libraryTarget: options.libraryTarget ? 'umd' : undefined,
27
28
  globalObject: options.libraryTarget,
28
- hashFunction: 'sha512' // remove when we upgrade to webpack 5
29
+ hashFunction: 'xxhash64'
29
30
  },
30
31
  optimization: {
31
32
  minimize: !!options.minifyScripts,
@@ -54,29 +55,21 @@ module.exports = (pathToProject, entry, baseEslintPath, options = {}) => {
54
55
  'node_modules',
55
56
  ],
56
57
  },
57
- module: {
58
- rules: [
59
- {
60
- enforce: 'pre',
61
- test: /\.js$/,
62
- loader: require.resolve('eslint-loader'),
63
- exclude: /node_modules/,
64
- options: {
65
- baseConfig: baseEslintConfig,
66
- useEslintrc: true,
67
- ignore: !options.skipEslintIgnore,
68
-
69
- // pack the library regardless of the eslint result
70
- failOnError: false,
71
- failOnWarning: false,
72
- },
73
- },
74
- ],
75
- },
76
58
  plugins: [
77
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // Ignore all optional deps of moment.js
78
- ]
79
- }]);
59
+ new ESLintPlugin({
60
+ context: pathToProject,
61
+ extensions: 'js',
62
+ exclude: 'node_modules',
63
+ baseConfig: baseEslintConfig,
64
+ useEslintrc: true,
65
+ ignore: !options.skipEslintIgnore,
66
+ // pack the library regardless of the eslint result
67
+ failOnError: false,
68
+ failOnWarning: false,
69
+ }),
70
+ new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), // Ignore all optional deps of moment.js
71
+ ],
72
+ });
80
73
 
81
74
  return new Promise((resolve, reject) => {
82
75
  compiler.run((err, stats) => {
@@ -92,17 +85,21 @@ module.exports = (pathToProject, entry, baseEslintPath, options = {}) => {
92
85
  info(stats.toString());
93
86
 
94
87
  if (stats.hasErrors()) {
95
- const hasErrorsNotRelatedToLinting = stats.toJson().errors.some(err => !err.includes('node_modules/eslint-loader'));
96
- const shouldHalt = options.haltOnLintMessage || hasErrorsNotRelatedToLinting;
88
+ return reject(Error(`Webpack errors when building ${libName}`));
89
+ }
90
+
91
+ if (stats.hasWarnings()) {
92
+ const hasWarningsRelatedToLinting = stats.toJson().warnings.some(warning => warning.message.includes('warnings potentially fixable'));
93
+ const shouldHalt = options.haltOnWebpackWarning ||
94
+ options.haltOnLintMessage && hasWarningsRelatedToLinting;
95
+
97
96
  if (shouldHalt) {
98
- return reject(Error(`Webpack errors when building ${libName}`));
99
- } else {
100
- warn('Ignoring linting errors');
97
+ return reject(Error(`Webpack warnings when building ${libName}`));
101
98
  }
102
- }
103
99
 
104
- if (stats.hasWarnings() && options.haltOnWebpackWarning) {
105
- return reject(Error(`Webpack warnings when building ${libName}`));
100
+ if (hasWarningsRelatedToLinting) {
101
+ warn('Ignoring linting errors');
102
+ }
106
103
  }
107
104
 
108
105
  const outputPath = path.join(outputDirectoryPath, outputFilename);
@@ -1,4 +1,4 @@
1
- const csvParse = require('csv-parse/lib/sync');
1
+ const { parse: csvParse } = require('csv-parse/sync');
2
2
  const fs = require('fs');
3
3
  const mkdirp = require('mkdirp').sync;
4
4
  const os = require('os');
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "env": {
3
- "es6": true,
3
+ "es2022": true,
4
4
  "node": true
5
5
  },
6
6
  "root": true,
7
7
  "parserOptions": {
8
- "ecmaVersion": 5
8
+ "ecmaVersion": 2022
9
9
  },
10
10
  "extends": "eslint:recommended",
11
11
  "rules": {