var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.rnvApiOffline=exports.rnvApiDeploy=exports.rnvApiAdd=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _path=_interopRequireDefault(require("path"));
var _fs=_interopRequireDefault(require("fs"));

var _config=_interopRequireDefault(require("../config"));
var _common=require("../common");
var _exec=require("../systemTools/exec");

var rnvApiAdd=function rnvApiAdd(){var _Config$getConfig,paths,buildConfig,slsPath,webpackConfigPath,apiDirPath,defaultHandlerPath;return _regenerator.default.async(function rnvApiAdd$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('serverless','1.67.0','devDependencies',false,true));case 2:_context.next=4;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('serverless-webpack','5.3.1','devDependencies',true,true));case 4:_context.next=6;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('serverless-pseudo-parameters','2.5.0','devDependencies',true,true));case 6:_context.next=8;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('serverless-dotenv-plugin','2.3.2','devDependencies',true,true));case 8:_context.next=10;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('serverless-offline','6.0.0','devDependencies',true,true));case 10:_context.next=12;return _regenerator.default.awrap(
_config.default.checkRequiredPackage('webpack-node-externals','1.7.2','devDependencies',true));case 12:_Config$getConfig=
_config.default.getConfig(),paths=_Config$getConfig.paths,buildConfig=_Config$getConfig.buildConfig;

console.log('[',buildConfig);
slsPath=_path.default.join(paths.project.dir,'serverless.json');
webpackConfigPath=_path.default.join(paths.project.dir,'webpack.serverless.config.js');
apiDirPath=_path.default.join(paths.project.dir,'src/api');
defaultHandlerPath=_path.default.join(apiDirPath,'handler.js');


if(!_fs.default.existsSync(slsPath)){
(0,_common.writeCleanFile)(_path.default.join(paths.rnv.dir,'src/backendTools/template/serverless.json'),slsPath,[
{pattern:'{{PROJECT_NAME}}',override:buildConfig.id}]);

}

if(!_fs.default.existsSync(webpackConfigPath)){
(0,_common.writeCleanFile)(_path.default.join(paths.rnv.dir,'src/backendTools/template/webpack.serverless.config.js'),webpackConfigPath);
}

if(!_fs.default.existsSync(apiDirPath))_fs.default.mkdirSync(apiDirPath);
if(!_fs.default.existsSync(defaultHandlerPath)){
(0,_common.writeCleanFile)(_path.default.join(paths.rnv.dir,'src/backendTools/template/handler.js'),defaultHandlerPath);
}case 22:case"end":return _context.stop();}}},null,null,null,Promise);};exports.rnvApiAdd=rnvApiAdd;


var rnvApiDeploy=function rnvApiDeploy(){
throw new Error('not implemented');
};exports.rnvApiDeploy=rnvApiDeploy;

var rnvApiOffline=function rnvApiOffline(){return(0,_exec.executeAsync)('npx serverless offline',{interactive:true});};exports.rnvApiOffline=rnvApiOffline;
//# sourceMappingURL=index.js.map