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Aa,EAAQ,MACzB,EAAM,MAAK,SAAS,GAChB,IAAI,EAAU,UAAU,OACxB,EAAK,MAAQ,EAAK,MAClB,EAAK,MAAQ,EAAK,MAClB,EAAE,OAAO,EAAU,EAAK,EAAgB,EAAM,KAAK,QAAQ,GAAO,WAAW,GAAO,GAAM,SAAS,GAC/F,GAAI,EACA,GAAoB,SAAhB,EAAM,OAAoC,SAAhB,EAAM,MAAkB,CAGlD,IAAK,IAAY,EACb,MAAM,IAAI,MAAM,wDAGhB,EAAK,OACL,QAAQ,MAAM,uBAAwB,EAAM,OAAQ,MAGxD,EAAE,aAAa,EAAS,EAAa,GAAM,SAAS,GAChD,GAAI,EACA,MAAM,IAAI,MAAM,gBAAkB,EAAM,QAExC,EAAQ,EAEhB,GACJ,KAAO,IAAI,EAAQ,WAAY,EAC3B,MAAM,IAAI,MAAM,EAAM,QAAU,GAEhC,EAAQ,EACZ,MAEA,GAER,GACJ,GACJ,IAGA,EAAE,YAAY,GAAO,SAAS,EAAM,GAChC,OAAO,WACH,EAAQ,EACZ,CACJ,GAAG,EAJH,EAKJ,CArHA,OAAO,QAEP,OAAO,QAAU,SAAS,EAAQ,EAAU,GACxC,IAAK,IAAW,EACZ,MAAM,IAAI,MAAM,qCAGpB,IAAI,EAAY,GAChB,EAAO,SAAQ,SAAS,GACpB,EAAU,KAAK,WAAW,KAAK,KAAM,EAAU,EAAW,KAAM,EAAO,EAAW,IACtF,IAEA,EAAU,QAAO,SAAS,EAAe,GACrC,OAAO,EAAc,KAAK,IAC9B,GAAG,EAAE,MAAM,GACf,EAwGA,OAAO,QAAQ,QAAU,CAErB,MAAO","file":"/npm/eden-remote-deploy@0.0.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/eden-remote-deploy@0.0.5/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * remote release for Eden\n */\n\nvar path = require('path');\nvar prompt = require('prompt');\nvar Q = require('q');\nvar fs = require('fs');\nvar glob = require('glob');\nvar _ = require('./lib/util.js');\n\nprompt.start();\n\nmodule.exports = function(deploy, receiver, root) {\n    if (!deploy || !receiver) {\n        throw new Error('deploy and receiver are required!');\n    }\n\n    var pushArray = [];\n    deploy.forEach(function(deployItem) {\n        pushArray.push(pushConfig.bind(null, receiver, deployItem.from, root + deployItem.to))\n    })\n\n    pushArray.reduce(function(previousValue, currentValue) {\n        return previousValue.then(currentValue())\n    }, Q.delay(0))\n}\n\nfunction getContent (str) {\n    return _.read(str, _.isTextFile(str))\n}\n\nfunction pushConfig(receiver, from , to) {\n    var deferred = new Q.defer();\n    glob(from, function (er, files) {\n        var newfiles = files.filter(function(item) {\n            return item.indexOf('\\.') > -1\n        })\n\n        push({\n            receiver: receiver,\n            from: from,\n            to: to\n        }, newfiles, function() {\n            deferred.resolve()\n        });\n    });\n    return deferred.promise;\n}\n\nfunction push(options, modified, callback) {\n    if (!options.to) {\n        throw new Error('options.to is required!');\n    }\n\n    var info = _.deployInfo() || {};\n    var to = options.to;\n    var from = options.from;\n    var biu = false;\n    if (from && from.indexOf('/**') > -1) {\n        from = from.substring(0, from.indexOf('/**') + 1);\n        biu = true;\n    }\n\n    var receiver = options.receiver;\n    var authApi = options.authApi;\n    var validateApi = options.validateApi;\n    var data = options.data || {};\n\n    if (options.host) {\n        receiver = options.receiver = options.host + '/v1/upload';\n        authApi = options.authApi = options.host + '/v1/authorize';\n        validateApi = options.validateApi = options.host + '/v1/validate';\n    }\n\n    if (!options.receiver) {\n        throw new Error('options.receiver is required!');\n    }\n\n    var steps = [];\n    modified.forEach(function(file) {\n        var additionalpath = '';\n        if (biu) {\n            additionalpath = file.substring(from.length, file.lastIndexOf('\\/') + 1);\n        }\n        var reTryCount = options.retry;\n        steps.push(function(next) {\n            var _upload = arguments.callee;\n            data.email = info.email;\n            data.token = info.token;\n            _.upload(receiver, to + additionalpath, data, path.dirname(file), getContent(file), file, function(error) {\n                if (error) {\n                    if (error.errno === 100302 || error.errno === 100305) {\n                        // 检测到后端限制了上传，要求用户输入信息再继续。\n\n                        if (!authApi || !validateApi) {\n                            throw new Error('options.authApi and options.validateApi is required!');\n                        }\n\n                        if (info.email) {\n                            console.error('\\nToken is invalid: ', error.errmsg, '\\n');\n                        }\n\n                        _.requireEmail(authApi, validateApi, info, function(error) {\n                            if (error) {\n                                throw new Error('Auth failed! ' + error.errmsg);\n                            } else {\n                                _upload(next);\n                            }\n                        });\n                    } else if (options.retry && !--reTryCount) {\n                        throw new Error(error.errmsg || error);\n                    } else {\n                        _upload(next);\n                    }\n                } else {\n                    next();\n                }\n            });\n        });\n    });\n\n\n    _.reduceRight(steps, function(next, current) {\n        return function() {\n            current(next);\n        };\n    }, callback)();\n};\n\nmodule.exports.options = {\n    // 允许重试两次。\n    retry: 2\n};"]}