azk-parser
can read a json and generate anAzkfile.js
azk-parser
can parse anAzkfile.js
and generate json
It uses recast
for parsing and generation of javascript.
Because parsing javascript returns an AST (not an CST), is not always easy to generate the right syntax tree. We can use the project bellow to test new ast compositions.
- https://github.com/azukiapp/azkfile-ast-history-compare/commits/master
- https://github.com/benjamn/ast-types
import Generator from '../../../src/generator';
import Systems from 'azk-parser/systems-list';
import System from 'azk-parser/system';
var systems = new Systems();
var system001 = new System({ name: 'system001' });
var system002 = new System({ name: 'system002' });
systems.add(system001);
systems.add(system002);
var generator = new Generator();
var code = generator.generate(systems.syntax);
- generates this code:
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
// Adds the systems that shape your system
systems({
system001: {},
system002: {}
});
system001.addDependency('system002');
var generator = new Generator();
var code = generator.generate(system001.syntax);
- generates this code:
system001: {
depends: ["system002"]
}
$ npm install
$ gulp
$ gulp test
$ gulp test-no-lint
$ npm run-script patch