cht-conf 3.9.5 → 3.10.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 +7 -0
- package/package.json +1 -1
- package/src/lib/sync-fs.js +1 -0
- package/src/lib/upload-forms.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.10.0](https://github.com/medic/cht-conf/compare/v3.9.5...v3.10.0) (2022-02-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **#431:** track form version ([9d0b8d7](https://github.com/medic/cht-conf/commit/9d0b8d7df2c04140b9e84cd044d5583695c4e1c0)), closes [#431](https://github.com/medic/cht-conf/issues/431)
|
|
7
|
+
|
|
1
8
|
## [3.9.5](https://github.com/medic/cht-conf/compare/v3.9.4...v3.9.5) (2022-01-30)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/lib/sync-fs.js
CHANGED
|
@@ -97,6 +97,7 @@ module.exports = {
|
|
|
97
97
|
recurseFiles,
|
|
98
98
|
deleteFilesInFolder: folderPath => recurseFiles(folderPath).forEach(filePath => fs.unlinkSync(filePath)),
|
|
99
99
|
readdir: fs.readdirSync,
|
|
100
|
+
statSync: fs.statSync,
|
|
100
101
|
withoutExtension,
|
|
101
102
|
write: (path, data, options = 'utf8') => fs.writeFileSync(path, data, options),
|
|
102
103
|
writeBinary: (path, content) => fs.writeFileSync(path, content),
|
package/src/lib/upload-forms.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const argsFormFilter = require('./args-form-filter');
|
|
2
2
|
const attachmentsFromDir = require('./attachments-from-dir');
|
|
3
3
|
const attachmentFromFile = require('./attachment-from-file');
|
|
4
|
+
const crypto = require('crypto');
|
|
4
5
|
const fs = require('./sync-fs');
|
|
5
6
|
const log = require('./log');
|
|
6
7
|
const insertOrReplace = require('./insert-or-replace');
|
|
@@ -38,7 +39,13 @@ module.exports = async (projectDir, subDirectory, options) => {
|
|
|
38
39
|
log.info(`No media directory found at ${mediaDir} for form ${xformPath}`);
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
const hashSum = crypto.createHash('sha256');
|
|
41
43
|
const xml = fs.read(xformPath);
|
|
44
|
+
hashSum.update(xml);
|
|
45
|
+
const xmlVersion = {
|
|
46
|
+
time: Date.now(),
|
|
47
|
+
sha256: hashSum.digest('hex'),
|
|
48
|
+
};
|
|
42
49
|
|
|
43
50
|
const internalId = readIdFrom(xml);
|
|
44
51
|
if(internalId !== baseDocId) log.warn('DEPRECATED', 'Form:', fileName, 'Bad ID set in XML. Expected:', baseDocId, 'but saw:', internalId, ' Support for setting these values differently will be dropped. Please see https://github.com/medic/cht-core/issues/3342.');
|
|
@@ -48,6 +55,7 @@ module.exports = async (projectDir, subDirectory, options) => {
|
|
|
48
55
|
_id: docId,
|
|
49
56
|
type: 'form',
|
|
50
57
|
internalId: internalId,
|
|
58
|
+
xmlVersion: xmlVersion,
|
|
51
59
|
title: readTitleFrom(xml),
|
|
52
60
|
context: options.default_context,
|
|
53
61
|
};
|