feat(xod-cli): add migrating command into xod-cli (xodc m /path/to/old/bundle.xodball /path/to/save/new/bundle.xodball)

This commit is contained in:
Kirill Shumilov
2017-02-14 19:08:59 +03:00
parent a9f8fefd61
commit d8ad6fa5cc
3 changed files with 36 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
"cli-color": "^1.1.0",
"docopt": "^0.6.2",
"xod-arduino-builder": "^0.0.1",
"xod-project": "^0.0.1",
"xod-doc": "^0.0.1",
"xod-fs": "^0.0.1",
"xod-js": "^0.0.1"

View File

@@ -0,0 +1,33 @@
// migrate|m <input> <output> Migrate old xodball into new version
import { readJSON, writeJSON } from 'xod-fs';
import { toV2 } from 'xod-project';
import * as msg from './messages';
const outputToFile = (output, xodball) => {
if (output) {
return writeJSON(output, xodball)
.then(() => {
msg.success(`Successfully migrated and saved to ${output}`);
process.exit(0);
})
.catch((err) => {
msg.error(err);
process.exit(1);
});
}
return xodball;
};
export default (input, output) => {
msg.notice(`Migrating ${input} into ${output} ...`);
readJSON(input)
.then(toV2)
.then(v2 => outputToFile(output, v2))
.catch((err) => {
msg.error(err);
process.exit(1);
});
};

View File

@@ -6,6 +6,8 @@ import doc from './xodc-doc';
import pack from './xodc-pack';
import transpile from './xodc-transpile';
import unpack from './xodc-unpack';
import transpile from './xodc-transpile';
import migrate from './xodc-migrate';
function match(options, programs) {
for (const [command, program] of Object.entries(programs)) {