Skip to content

Commit

Permalink
Base form upload on XML files, not XLSX
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jun 1, 2017
1 parent dc39648 commit 6452800
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-configurer-beta",
"version": "1.0.32",
"version": "1.0.33",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 7 additions & 7 deletions src/lib/upload-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module.exports = (project, couchUrl, subDirectory, options) => {

const formsDir = `${project}/forms/${subDirectory}`;
return Promise.all(fs.readdir(formsDir)
.filter(name => name.endsWith('.xlsx'))
.map(xls => {
const baseFileName = fs.withoutExtension(xls);
.filter(name => name.endsWith('.xml'))
.map(fileName => {
const baseFileName = fs.withoutExtension(fileName);
const mediaDir = `${formsDir}/${baseFileName}-media`;
const xformPath = `${formsDir}/${baseFileName}.xml`;
const expectedId = (options.id_prefix || '') + baseFileName.replace(/-/g, ':');
Expand All @@ -27,7 +27,7 @@ module.exports = (project, couchUrl, subDirectory, options) => {
const xml = fs.read(xformPath);

const id = readIdFrom(xml);
if(id !== expectedId) warn('DEPRECATED', 'Form:', xls, 'Bad ID set in XML. Expected:', expectedId, 'but saw:', id, ' Support for setting these values differently will be dropped. Please see https://github.com/medic/medic-webapp/issues/3342.');
if(id !== expectedId) warn('DEPRECATED', 'Form:', fileName, 'Bad ID set in XML. Expected:', expectedId, 'but saw:', id, ' Support for setting these values differently will be dropped. Please see https://github.com/medic/medic-webapp/issues/3342.');

const doc = {
_id: `form:${id}`,
Expand All @@ -42,7 +42,7 @@ module.exports = (project, couchUrl, subDirectory, options) => {
doc.context = properties.context;
doc.icon = properties.icon;
if(properties.internalId) {
warn('DEPRECATED', 'Form:', xls, 'Please do not manually set internalId in .properties.json for new projects. Support for configuring this value will be dropped. Please see https://github.com/medic/medic-webapp/issues/3342.');
warn('DEPRECATED', 'Form:', fileName, 'Please do not manually set internalId in .properties.json for new projects. Support for configuring this value will be dropped. Please see https://github.com/medic/medic-webapp/issues/3342.');
doc.internalId = properties.internalId;
}
}
Expand All @@ -51,9 +51,9 @@ module.exports = (project, couchUrl, subDirectory, options) => {
doc._attachments.xml = attachmentFromFile(xformPath);

return Promise.resolve()
.then(() => trace('Uploading form', `${formsDir}/${xls}`, 'to', id))
.then(() => trace('Uploading form', `${formsDir}/${fileName}`, 'to', id))
.then(() => insertOrReplace(db, doc))
.then(() => info('Uploaded form', `${formsDir}/${xls}`, 'to', id));
.then(() => info('Uploaded form', `${formsDir}/${fileName}`, 'to', id));
}));
};

Expand Down

0 comments on commit 6452800

Please sign in to comment.