mirror of
https://github.com/xodio/xod.git
synced 2026-03-13 20:26:55 +01:00
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:
@@ -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"
|
||||
|
||||
33
packages/xod-cli/src/xodc-migrate.js
Normal file
33
packages/xod-cli/src/xodc-migrate.js
Normal 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);
|
||||
});
|
||||
};
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user