cluedin-widget
Version:
This is the project for creating and managing widgets in CluedIn.
46 lines (35 loc) • 1.08 kB
JavaScript
var fs = require( 'fs' );
var path = require( 'path' );
const coreImport = "import '../core/components/bootstrap.jsx';";
const partialPath = "import '../widget/";
var mainFile = fs.readFileSync( path.join( __dirname, "../dist/cluedin_widget.js" ) );
var buildContent = function( widgets ) {
var content = '';
widgets.forEach( function( w ) {
content += (partialPath + w + "/index.jsx';");
} );
content += coreImport;
return content;
};
/**
* build, create the necessary file to generate a valid React App.
* @param options { org: 'cluedin', code: 'unique code representing a page, tab, widget', widgets }
* @param cb
*/
var build = ( options, cb ) => {
var fileName = options.fileName;
var content = buildContent( options.widgets );
fs.writeFile( fileName, content, function( err ) {
if ( err ) {
return cb( err );
}
cb( null, fileName );
}
);
};
module.exports = {
build: build,
buildFullFile: function() {
return mainFile.toString();
}
};