cht-conf 3.16.2 → 3.17.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,11 @@
1
+ # [3.17.0](https://github.com/medic/cht-conf/compare/v3.16.2...v3.17.0) (2023-04-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **#545:** publish cht-app-ide docker image ([#550](https://github.com/medic/cht-conf/issues/550)) ([8b5e62e](https://github.com/medic/cht-conf/commit/8b5e62e8f2191c4457433d30024266aa27ae1129)), closes [#545](https://github.com/medic/cht-conf/issues/545)
7
+ * **#547:** add command for uploading extension libs ([3b13e40](https://github.com/medic/cht-conf/commit/3b13e40e276d37e554cb5863974cea1090ed4585)), closes [#547](https://github.com/medic/cht-conf/issues/547)
8
+
1
9
  ## [3.16.2](https://github.com/medic/cht-conf/compare/v3.16.1...v3.16.2) (2023-03-18)
2
10
 
3
11
 
package/README.md CHANGED
@@ -34,73 +34,33 @@ As Administrator:
34
34
 
35
35
  CHT Conf can also be run from within a Docker container. This is useful if you are already familiar with Docker and do not wish to configure the various dependencies required for developing CHT apps on your local machine. The necessary dependencies are pre-packaged in the Docker image.
36
36
 
37
- #### Building the image
38
-
39
- Install [Docker](https://www.docker.com/). If you are using Windows, you also need to enable the [Windows Subsystem for Linux (WSL2)](https://learn.microsoft.com/en-us/windows/wsl/install) to perform the following steps.
40
-
41
- Using the terminal (or the WLS shell on Windows: _Start > wsl_), run the following commands to create a new project directory and build the Docker image:
42
-
43
- ```shell
44
- mkdir -p ~/cht-project
45
- cd ~/cht-project
46
- curl https://raw.githubusercontent.com/medic/cht-conf/main/Dockerfile > Dockerfile
47
- docker build -t cht-ide .
48
- ```
49
-
50
37
  #### Using the image
51
38
 
52
- The resulting Docker image can be used as a [VSCode Development Container](https://code.visualstudio.com/docs/devcontainers/containers) (easiest) or as a standalone Docker utility.
53
-
54
- ##### VSCode Development Container
55
-
56
- If you want to develop CHT apps with VSCode, 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 VSCode (without needing to install dependencies like NodeJS on your host system).
57
-
58
- [Install VSCode](https://code.visualstudio.com/) if you do not have it already.
59
-
60
- Using the terminal (or the WLS shell on Windows: _Start > wsl_), run the following commands from within your project directory (created above) to download the `.devcontainer.json` config file, install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), and open the project directory in VSCode:
39
+ The Docker image can be used as a [VS Code Development Container](https://code.visualstudio.com/docs/devcontainers/containers) (easiest) or as a standalone Docker utility.
61
40
 
62
- ```shell
63
- cd ~/cht-project
64
- curl -s https://raw.githubusercontent.com/medic/cht-conf/main/devcontainer.cht-ide/.devcontainer.json > .devcontainer.json
65
- code --install-extension ms-vscode-remote.remote-containers
66
- code -n .
67
- ```
68
-
69
- When opening VSCode, you may be prompted with the question:
70
-
71
- > **Do you trust the authors of the files in this folder?**
72
-
73
- Choose, "Yes, I trust the authors".
74
-
75
- Open the Command Palette in VSCode (_Ctrl+Shift+P_ or _Cmd+Shift+P_) and select `Reopen in Container`. This will open your workspace inside a container based on the `cht-ide` image. You can use the `cht` commands by opening a terminal in VSCode (_Ctrl+Shift+\`_ or _Cmd+Shift+\`_). If prompted "Do you trust the authors..." choose "Trust Folder & Continue".
76
-
77
- Run the following command in the VSCode terminal to bootstrap your new CHT project:
78
-
79
- ```shell
80
- cht initialise-project-layout
81
- ```
41
+ Install [Docker](https://www.docker.com/). If you are using Windows, you also need to enable the [Windows Subsystem for Linux (WSL2)](https://learn.microsoft.com/en-us/windows/wsl/install) to perform the following steps.
82
42
 
83
- ###### Terminal environment
43
+ ##### VS Code Development Container
84
44
 
85
- When opening a terminal in VSCode in a development container, the terminal will be running on the _container environment_ by default. This is what gives you access to the various `cht` commands. However, this also means you do NOT have access, within the default VSCode terminal, to commands from your _host environment_. So, for example, you cannot run `docker` commands since Docker is not installed inside the container.
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).
86
46
 
87
- To open a terminal running on you _host environment_ in VSCode, open the Command Palette (_Ctrl+Shift+P_ or _Cmd+Shift+P_) and select `Create New Integrated Terminal (Local)`. Just remember that you will NOT be able to run `cht` commands from this terminal since cht-conf is not installed on your host machine.
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.
88
48
 
89
49
  ##### Standalone Docker utility
90
50
 
91
- If you are not using VSCode, you can use the Docker image as a standalone utility from the command line. Instead of using the `cht ...` command, you can run `docker run -it --rm -v "$PWD":/workdir cht-ide ...`. This will create an ephemeral container with access to your current directory that will run the given cht command. (Do not include the `cht` part of the command, just your desired actions/parameters.)
51
+ If you are not using VS Code, you can use the Docker image as a standalone utility from the command line. Instead of using the `cht ...` command, you can run `docker run -it --rm -v "$PWD":/workdir medicmobile/cht-app-ide ...`. This will create an ephemeral container with access to your current directory that will run the given cht command. (Do not include the `cht` part of the command, just your desired actions/parameters.)
92
52
 
93
53
  Run the following command inside the project directory to bootstrap your new CHT project:
94
54
 
95
55
  ```shell
96
- docker run -it --rm -v "$PWD":/workdir cht-ide initialise-project-layout
56
+ docker run -it --rm -v "$PWD":/workdir medicmobile/cht-app-ide initialise-project-layout
97
57
  ```
98
58
 
99
59
  #### Note on connecting to a local CHT instance
100
60
 
101
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").
102
62
 
103
- 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 VSCode terminal). (Just make sure the port your CHT instance is hosted on is not blocked by your firewall).
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).
104
64
 
105
65
  ## Bash completion
106
66
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "image": "cht-ide",
2
+ "image": "medicmobile/cht-app-ide:latest",
3
3
  // Required to run tests with Puppeteer
4
4
  // https://pptr.dev/guides/docker
5
5
  "capAdd": ["SYS_ADMIN"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cht-conf",
3
- "version": "3.16.2",
3
+ "version": "3.17.0",
4
4
  "description": "Configure CHT deployments",
5
5
  "main": "./src/lib/main.js",
6
6
  "engines": {
@@ -0,0 +1,41 @@
1
+ const environment = require('../lib/environment');
2
+ const pouch = require('../lib/db');
3
+ const log = require('../lib/log');
4
+ const attachmentsFromDir = require('../lib/attachments-from-dir');
5
+ const warnUploadOverwrite = require('../lib/warn-upload-overwrite');
6
+ const insertOrReplace = require('../lib/insert-or-replace');
7
+ const projectPaths = require('../lib/project-paths');
8
+
9
+ const DOC_ID = 'extension-libs';
10
+
11
+ module.exports = {
12
+ requiresInstance: true,
13
+ execute: async () => {
14
+ const configurationDir = `${environment.pathToProject}/${projectPaths.EXTENSION_LIBS_PATH}`;
15
+
16
+ const attachments = attachmentsFromDir(configurationDir);
17
+ if (!Object.keys(attachments).length) {
18
+ log.info(`No configuration found at "${configurationDir}" - not uploading extension-libs`);
19
+ return;
20
+ }
21
+
22
+ log.info(`Found extension-libs: ${Object.keys(attachments).join(', ')}`);
23
+ const doc = {
24
+ _id: DOC_ID,
25
+ _attachments: attachments
26
+ };
27
+
28
+ const db = pouch(environment.apiUrl);
29
+ const changes = await warnUploadOverwrite.preUploadDoc(db, doc);
30
+
31
+ if (!changes) {
32
+ log.info('Extension libs not uploaded as already up to date');
33
+ return;
34
+ }
35
+
36
+ await insertOrReplace(db, doc);
37
+ log.info('Extension libs upload complete');
38
+
39
+ return await warnUploadOverwrite.postUploadDoc(db, doc);
40
+ }
41
+ };
package/src/lib/main.js CHANGED
@@ -37,6 +37,7 @@ const defaultActions = [
37
37
  'upload-partners',
38
38
  'upload-custom-translations',
39
39
  'upload-privacy-policies',
40
+ 'upload-extension-libs',
40
41
  ];
41
42
  const defaultArchiveActions = [
42
43
  'compile-app-settings',
@@ -58,6 +59,7 @@ const defaultArchiveActions = [
58
59
  'upload-partners',
59
60
  'upload-custom-translations',
60
61
  'upload-privacy-policies',
62
+ 'upload-extension-libs',
61
63
  ];
62
64
 
63
65
  module.exports = async (argv, env) => {
@@ -1,13 +1,14 @@
1
1
  const path = require('path');
2
2
  // Paths Relative to the Project
3
3
  module.exports = {
4
- APP_SETTINGS_DIR_PATH: 'app_settings',
5
- APP_SETTINGS_JSON_PATH: 'app_settings.json',
6
- APP_FORMS_PATH: path.join('forms', 'app'),
7
- CONTACT_FORMS_PATH: path.join('forms', 'contact'),
8
- COLLECT_FORMS_PATH: path.join('forms', 'collect'),
9
- TRAINING_FORMS_PATH: path.join('forms', 'training'),
10
- TRANSLATIONS_DIR_PATH: 'translations',
11
- RESOURCE_CONFIG_PATH: 'resources.json',
12
- RESOURCES_DIR_PATH: 'resources'
13
- };
4
+ APP_SETTINGS_DIR_PATH: 'app_settings',
5
+ APP_SETTINGS_JSON_PATH: 'app_settings.json',
6
+ APP_FORMS_PATH: path.join('forms', 'app'),
7
+ CONTACT_FORMS_PATH: path.join('forms', 'contact'),
8
+ COLLECT_FORMS_PATH: path.join('forms', 'collect'),
9
+ TRAINING_FORMS_PATH: path.join('forms', 'training'),
10
+ TRANSLATIONS_DIR_PATH: 'translations',
11
+ RESOURCE_CONFIG_PATH: 'resources.json',
12
+ RESOURCES_DIR_PATH: 'resources',
13
+ EXTENSION_LIBS_PATH: 'extension-libs',
14
+ };