Removed old API generator and fixed generator tests
diff --git a/views/ngXosLib/apigen/blueprintToNgResource.js b/views/ngXosLib/apigen/blueprintToNgResource.js
index 20f2869..2a3cde3 100644
--- a/views/ngXosLib/apigen/blueprintToNgResource.js
+++ b/views/ngXosLib/apigen/blueprintToNgResource.js
@@ -6,6 +6,8 @@
const _ = require('lodash');
const chalk = require('chalk');
const Handlebars = require('handlebars');
+const util = require('util');
+const path = require('path');
P.promisifyAll(fs);
P.promisifyAll(protagonist);
@@ -49,7 +51,7 @@
ngModule: angualarModuleName,
resources: loopApiEndpoint(d.content)
};
- fs.writeFileSync(`../xosHelpers/src/services/rest/${formatTitle(d.meta.title)}.js`, handlebarsTemplate(data));
+ fs.writeFileSync(path.join(__dirname, `../xosHelpers/src/services/rest/${formatTitle(d.meta.title)}.js`), handlebarsTemplate(data));
});
console.info(chalk.green.bold(`Api Generated`));
@@ -58,16 +60,17 @@
// Loop the top level definitions
const loopApiDefinitions = (defs) => {
+ // console.log(util.inspect(defs, false, null));
_.forEach(defs, d => loopApiGroups(d.content));
};
let handlebarsTemplate;
// read blueprint docs and parse
-fs.readFileAsync('./ngResourceTemplate.handlebars', 'utf8')
+fs.readFileAsync(path.join(__dirname, './ngResourceTemplate.handlebars'), 'utf8')
.then((template) => {
handlebarsTemplate = Handlebars.compile(template);
- return fs.readFileAsync('../../../xos/tests/api/apiary.apib', 'utf8')
+ return fs.readFileAsync(path.join(__dirname, '../../../xos/tests/api/apiary.apib'), 'utf8')
})
.then(data => protagonist.parseAsync(data))
.then(result => loopApiDefinitions(result.content))
diff --git a/views/ngXosLib/apigen/ngResourceTemplate.handlebars b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
index d326a51..6048669 100644
--- a/views/ngXosLib/apigen/ngResourceTemplate.handlebars
+++ b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
@@ -1,14 +1,16 @@
-'use strict';
-{{#if description}}
+(function() {
+ 'use strict';
+ {{#if description}}
-/*
- * {{description}}
- */
-{{/if}}
+ /*
+ * {{description}}
+ */
+ {{/if}}
-angular.module('{{ngModule}}')
-{{#each resources}}
-.service('{{name}}', function($resource){
- return $resource('{{param.href}}'{{#if param.name}}, { {{param.name}}: '@id' }{{/if}});
-})
-{{/each}}
\ No newline at end of file
+ angular.module('{{ngModule}}')
+ {{#each resources}}
+ .service('{{name}}', function($resource){
+ return $resource('{{param.href}}'{{#if param.name}}, { {{param.name}}: '@id' }{{/if}});
+ })
+ {{/each}}
+})();
\ No newline at end of file