react-gui-builder
Version:
Structor - React UI Builder
1 lines • 3.67 kB
JavaScript
;function _interopRequireWildcard(t){if(t&&t.__esModule)return t;var o={};if(null!=t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e]);return o.default=t,o}function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function checkMetaFolderVersion(t,o){var e=_path2.default.join(t,_structorCommons.config.SERVICE_DIR);return _structorCommons.commons.isExisting(e).then(function(){return _structorCommons.commons.readJson(_path2.default.join(e,"version.json")).catch(function(t){return{}})}).then(function(t){return t&&t.version===o})}function setMetaFolderVersion(t,o){return _structorCommons.commons.writeJson(_path2.default.join(t,_structorCommons.config.SERVICE_DIR,"version.json"),{version:o})}function downloadMetaDistr(t,o){return client.download(t).then(function(e){var r=_path2.default.join(o,"__metaDistr.tar.gz").replace(/\\/g,"/"),n=_path2.default.join(o,"___metaDistr").replace(/\\/g,"/");return _structorCommons.commons.writeBinaryFile(r,e).then(function(){return _structorCommons.commons.unpackTarGz(r,n)}).then(function(){return _structorCommons.commons.readDirectoryFlat(n).then(function(o){if(o){var e=o.dirs;if(e&&1===e.length)return e[0].path}throw Error("Downloaded tarball has different structure. Check the ulr: "+t)})}).then(function(t){return _structorCommons.commons.removeFile(r).then(function(){return{innerDirPath:t,tempDirPath:n}})})})}function createMetaFolder(t,o,e){var r=_path2.default.join(o,_structorCommons.config.SERVICE_DIR),n=_path2.default.join(t,_structorCommons.config.SERVICE_DIR);return _structorCommons.commons.copyFile(n,r).then(function(){var o=_path2.default.join(t,configTplPath);return _structorCommons.commons.readFile(o)}).then(function(t){return(0,_lodash.template)(t)(e)}).then(function(t){var o=_path2.default.join(r,configFilePath);return _structorCommons.commons.writeFile(o,t)}).then(function(){var t=_path2.default.join(o,"package.json");return _structorCommons.commons.readJson(t).then(function(o){return o.scripts=o.scripts||{},o.scripts.structor="structor",_structorCommons.commons.writeJson(t,o)})})}function updateMetaFolder(t,o){var e=[],r=_path2.default.join(t,_structorCommons.config.SERVICE_DIR),n=_path2.default.join(o,_structorCommons.config.SERVICE_DIR);return applicationFiles.forEach(function(t){e.push({srcFilePath:_path2.default.join(n,t),destFilePath:_path2.default.join(r,t)})}),_structorCommons.commons.copyFilesNoError(e).then(function(){return _structorCommons.commons.removeFile(n)}).then(function(){return _structorCommons.commons.copyFile(r,n)})}function removeFile(t){return _structorCommons.commons.removeFile(t)}function ensureFileStructure(t,o){var e=_path2.default.join(t,o.srcPath);return _structorCommons.commons.ensureDirPath(e).then(function(){var t=_path2.default.join(e,"assets");return _structorCommons.commons.ensureDirPath(t)})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkMetaFolderVersion=checkMetaFolderVersion,exports.setMetaFolderVersion=setMetaFolderVersion,exports.downloadMetaDistr=downloadMetaDistr,exports.createMetaFolder=createMetaFolder,exports.updateMetaFolder=updateMetaFolder,exports.removeFile=removeFile,exports.ensureFileStructure=ensureFileStructure;var _path=require("path"),_path2=_interopRequireDefault(_path),_lodash=require("lodash"),_structorCommons=require("structor-commons"),_clientGH=require("../commons/clientGH.js"),client=_interopRequireWildcard(_clientGH),applicationFiles=["app/components.js","app/reducers.js","app/sagas.js","app/store.js","defaults","desk/model.json","docs","config.js","webpack.app.js"],configTplPath="templates/config.js.tpl",configFilePath="config.js";