-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final beta release to deprecate the beta
- Loading branch information
Showing
110 changed files
with
10 additions
and
18,505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,177 +1,6 @@ | ||
Medic Project Configurer | ||
======================== | ||
|
||
<a href="https://travis-ci.org/medic/medic-conf"><img src="https://travis-ci.org/medic/medic-conf.svg?branch=master"/></a> | ||
# Deprecation Warning | ||
|
||
# Requirements | ||
|
||
* nodejs 6 | ||
* python 2.7 | ||
|
||
|
||
# Installation | ||
|
||
## Ubuntu | ||
|
||
npm install -g medic-conf | ||
sudo python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.5#egg=pyxform-medic | ||
|
||
## OSX | ||
|
||
npm install -g medic-conf | ||
pip install git+https://github.com/medic/pyxform.git@medic-conf-1.5#egg=pyxform-medic | ||
|
||
## Windows | ||
|
||
As Administrator: | ||
|
||
npm install -g medic-conf | ||
python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.5#egg=pyxform-medic --upgrade | ||
|
||
## Bash completion | ||
|
||
To enable tab completion in bash, add the following to your `.bashrc`/`.bash_profile`: | ||
|
||
eval "$(medic-conf --shell-completion bash)" | ||
|
||
## Upgrading | ||
|
||
To upgrade to the latest version | ||
|
||
npm install -g medic-conf | ||
|
||
# Use | ||
|
||
`medic-conf` will upload the configuration **_from your current directory_**. | ||
|
||
## Upload all config | ||
|
||
### To localhost | ||
|
||
medic-conf --local | ||
|
||
### To a specific Medic instance | ||
|
||
medic-conf --instance username:password@instance-name.dev | ||
|
||
### To an arbitrary URL | ||
|
||
medic-conf --url https://username:password@example.com:12345 | ||
|
||
## Perform specific action(s) | ||
|
||
medic-conf <--local|--instance instance-name|--url url> <...action> | ||
|
||
The list of available actions can be seen in [`supported-actions.js`](https://github.com/medic/medic-conf/blob/master/src/cli/supported-actions.js). | ||
|
||
## Perform actions for specific forms | ||
|
||
medic-conf <--local|--instance instance-name|--url url> <...action> -- <...form> | ||
|
||
# Project Layout | ||
|
||
This tool expects a project to be sctructured as follows: | ||
|
||
example-project/ | ||
app_settings.json | ||
contact-summary.js | ||
resources.json | ||
resources/ | ||
icon-one.png | ||
… | ||
rules.nools.js | ||
targets.json | ||
tasks.json | ||
forms/ | ||
app/ | ||
my_project_form.xlsx | ||
my_project_form.xml | ||
my_project_form.properties.json | ||
my_project_form-media/ | ||
[extra files] | ||
… | ||
contact/ | ||
person-create.xlsx | ||
person-create.xml | ||
person-create-media/ | ||
[extra files] | ||
… | ||
… | ||
… | ||
translations/ | ||
messages-xx.properties | ||
… | ||
|
||
|
||
# Currently supported | ||
|
||
## App Settings | ||
|
||
* compile from: | ||
- tasks | ||
- rules | ||
- schedules | ||
- contact-summary | ||
* backup from server | ||
* upload to server | ||
|
||
## Forms | ||
|
||
* backup from server | ||
* delete from server | ||
* upload to server | ||
|
||
## Resources | ||
|
||
* upload to server | ||
|
||
## Translations | ||
|
||
* upload of custom translations to the server | ||
|
||
# TODO | ||
|
||
* support Google Sheets forms | ||
* add PNGout as somehow part of the form conversion step. But make sure it's cleanly separated from XML processing step | ||
|
||
## Wishlist | ||
|
||
* only upload things which have changed (this could be a separate mode - e.g. `update` vs `configure`) | ||
|
||
# csv-to-docs | ||
|
||
To convert CSV to JSON docs, use the `csv-to-docs` action. | ||
|
||
By default, values are parsed as strings. To parse a CSV column as a JSON type, prefix a data type to the column definition, e.g. | ||
|
||
column_1,bool:column_2,int:column_3,date:column_4 | ||
|
||
To reference other docs, there are a number of options: | ||
|
||
## Reference to a row of CSV | ||
|
||
1. `_id` of doc at row `N` of csv file `F` | ||
|
||
csv:F:id>target_property_name | ||
|
||
2. entire doc at row `N` of csv file `F` | ||
|
||
csv:F:doc>target_property_name | ||
|
||
3. value of field `some_field` of doc at row `N` of csv file `F` | ||
|
||
csv:F:.some_field>target_property_name | ||
|
||
## Reference to a doc by matching properties | ||
|
||
1. `_id` of doc with properties X=a and Y=b where property P matches this column's value | ||
|
||
match=P:X=a&Y=y:id>target_property_name | ||
|
||
2. entire doc with properties X=a and Y=b where property P matches this column's value | ||
|
||
match=P:X=a&Y=y:doc>target_property_name | ||
|
||
3. value of field `some_field` of doc with properties X=a and Y=b where property P matches this column's value | ||
|
||
match=P:X=a&Y=y:.some_field>target_property_name | ||
## This tool has been re-released as `medic-conf`. Please visit [https://www.npmjs.com/package/medic-conf](https://www.npmjs.com/package/medic-conf) for the latest version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../src/cli/check-node-version'); | ||
console.log(`\x1b[31m | ||
This tool is no longer in beta! | ||
const checkForUpdates = require('../src/lib/check-for-updates'); | ||
const error = require('../src/lib/log').error; | ||
const fs = require('../src/lib/sync-fs'); | ||
const info = require('../src/lib/log').info; | ||
const log = require('../src/lib/log'); | ||
const readline = require('readline-sync'); | ||
const redactBasicAuth = require('redact-basic-auth'); | ||
const supportedActions = require('../src/cli/supported-actions'); | ||
const usage = require('../src/cli/usage'); | ||
const warn = require('../src/lib/log').warn; | ||
Please upgrade to 'medic-conf': | ||
let args = process.argv.slice(2); | ||
const shift = n => args = args.slice(n || 1); | ||
npm install -g medic-conf\x1b[0m`); | ||
|
||
if(!args.length) { | ||
return checkForUpdates({ nonFatal:true }) | ||
.then(() => usage(0)); | ||
} | ||
|
||
let instanceUrl, skipCheckForUpdates; | ||
|
||
switch(args[0]) { | ||
case '--silent': log.level = log.LEVEL_NONE; shift(); break; | ||
case '--verbose': log.level = log.LEVEL_TRACE; shift(); break; | ||
default: log.level = log.LEVEL_INFO; | ||
} | ||
|
||
switch(args[0]) { | ||
|
||
//> instance URL handling: | ||
case '--instance': | ||
instanceUrl = `https://${args[1]}.medicmobile.org`; | ||
shift(2); | ||
break; | ||
case '--local': | ||
instanceUrl = 'http://admin:pass@localhost:5988'; | ||
shift(); | ||
break; | ||
case '--url': | ||
instanceUrl = args[1]; | ||
shift(2); | ||
break; | ||
|
||
//> general option handling: | ||
case '--help': return usage(0); | ||
case '--shell-completion': | ||
return require('../src/cli/shell-completion-setup')(args[1]); | ||
case '--supported-actions': | ||
console.log('Supported actions:\n ', supportedActions.join('\n ')); | ||
return process.exit(0); | ||
case '--version': | ||
console.log(require('../package.json').version); | ||
return process.exit(0); | ||
} | ||
|
||
if(args[0] === '--no-check') { | ||
skipCheckForUpdates = true; | ||
shift(); | ||
} | ||
|
||
const projectName = fs.path.basename(fs.path.resolve('.')); | ||
const couchUrl = instanceUrl && `${instanceUrl}/medic`; | ||
|
||
if(instanceUrl) { | ||
if(instanceUrl.match('/medic$')) warn('Supplied URL ends in "/medic". This is probably incorrect.'); | ||
|
||
const productionUrlMatch = instanceUrl.match(/^https:\/\/(?:[^@]*@)?(.*)\.(app|dev)\.medicmobile\.org(?:$|\/)/); | ||
if(productionUrlMatch && | ||
productionUrlMatch[1] !== projectName && | ||
productionUrlMatch[1] !== 'alpha') { | ||
warn(`Attempting to upload configuration for \x1b[31m${projectName}\x1b[33m`, | ||
`to non-matching instance: \x1b[31m${redactBasicAuth(instanceUrl)}\x1b[33m`); | ||
if(!readline.keyInYN()) { | ||
error('User failed to confirm action.'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
let actions = args; | ||
let extraArgs; | ||
|
||
const argDivider = actions.indexOf('--'); | ||
if(argDivider !== -1) { | ||
extraArgs = actions.slice(argDivider + 1); | ||
actions = actions.slice(0, argDivider); | ||
} | ||
|
||
if(!actions.length) { | ||
actions = [ | ||
'compile-app-settings', | ||
'backup-app-settings', | ||
'upload-app-settings', | ||
'convert-app-forms', | ||
'convert-collect-forms', | ||
'convert-contact-forms', | ||
'backup-all-forms', | ||
'delete-all-forms', | ||
'upload-app-forms', | ||
'upload-collect-forms', | ||
'upload-contact-forms', | ||
'upload-resources', | ||
'upload-custom-translations', | ||
'csv-to-docs', | ||
'upload-docs', | ||
]; | ||
} | ||
|
||
const unsupported = actions.filter(a => !supportedActions.includes(a)); | ||
if(unsupported.length) { | ||
error(`Unsupported action(s): ${unsupported.join(' ')}`); | ||
process.exit(1); | ||
} | ||
|
||
info(`Processing config in ${projectName} for ${instanceUrl}.`); | ||
info('Actions:\n -', actions.join('\n - ')); | ||
info('Extra args:', extraArgs); | ||
|
||
const initialPromise = actions.includes('check-for-updates') || skipCheckForUpdates ? | ||
Promise.resolve() : checkForUpdates({ nonFatal:true }); | ||
|
||
return actions.reduce((promiseChain, action) => | ||
promiseChain | ||
.then(() => info(`Starting action: ${action}…`)) | ||
.then(() => require(`../src/fn/${action}`)('.', couchUrl, extraArgs)) | ||
.then(() => info(`${action} complete.`)), | ||
initialPromise) | ||
.then(() => { if(actions.length > 1) info('All actions completed.'); }) | ||
.catch(e => { | ||
error(e); | ||
process.exit(1); | ||
}); | ||
process.exit(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.