sugar-generate
Version:
Auto generate OAS 3.0 REST + GraphQL APIs (Node + MongoDB)
37 lines (33 loc) • 1.08 kB
JavaScript
const fs = require('fs');
const beautify = require('js-beautify').js;
const { uppercase } = require('../api/utils');
const uuid = require('uuid').v4;
module.exports = async ({ schema, destination }) => {
const fileName = `${destination}/${uppercase(schema.name)}/${uppercase(schema.name)}Table.js`;
const componentName = `${uppercase(schema.name)}Table`;
const host = "http://localhost:8080";
console.log('what to do about HOST', host)
const code = [`
window.${componentName} = zoid.create({
// The html tag used to render my component
tag: '${schema.name}-table',
// The url that will be loaded in the iframe or popup, when someone includes my component on their page
url: '${host}/${componentName}.html',
autoResize: {
height: true,
width: false,
},
dimensions: {
width: '100%',
height: '100%'
},
attributes: {
iframe: {
scrolling: "no"
}
},
});
`];
const pretty = beautify(code.join("\n"), { indent_size: 2, space_in_empty_paren: true });
fs.writeFileSync(fileName, pretty);
};