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,GAChB,GAAI,EACF,SAAS,KAAK,QAAQ,UAAW,gBAAgB,SAAU,GACzD,IAAI,EAAQ,KAAK,MAAM,GAEnB,EAAI,EAAM,KAAK,QAAQ,IAChB,IAAP,GAAU,EAAM,KAAK,OAAO,EAAG,GACnC,UAAU,KAAK,QAAQ,UAAW,eAAgB,KAAK,UAAU,IACjE,QAAQ,UAAW,EACrB,SACK,GAAI,QAAQ,KAAM,CAErB,MAAM,EAAa,CAAC,CACd,KAAM,OACN,QAAS,iBACT,KAAM,MACN,QALK,QAAQ,UAAU,OAO3B,SAAS,OAAO,GAAY,MAAK,IAC/B,EAAM,EAAQ,IACd,SAAS,KAAK,QAAQ,UAAW,gBAAgB,SAAU,GACvD,IAAI,EAAQ,KAAK,MAAM,GACnB,EAAI,EAAM,KAAK,QAAQ,IAChB,IAAP,GAAU,EAAM,KAAK,OAAO,EAAG,GACnC,UAAU,KAAK,QAAQ,UAAW,eAAgB,KAAK,UAAU,IACjE,QAAQ,UAAW,EACrB,GAAC,GAEX,MACE,IAAI,2BAER,IAEF,QAAQ,MAAM,QAAQ","file":"/npm/proxy-switcher@0.0.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/proxy-switcher@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","#!/usr/bin/env node\n\nconst program = require('commander')\nconst exec = require('child_process').exec\nconst os = require('os')\nconst inquirer = require('inquirer')\nconst {\n  success,\n  warning,\n  err\n} = require('./util/log')\nconst {\n  readFile,\n  appendFile,\n  writeFile\n} = require('./util/fileHandle')\nconst fullText = require('./util/fullText')\nconst deleteProxy = require('./util/deleteProxy')\nconst bashProfile = os.homedir() + '/.bash_profile'\nlet conf = require('./conf')\nconst path = require('path')\nconst pkg = require('./package')\nfunction isWin () {\n  return os.type() === 'Windows_NT'\n}\nprogram\n  .version(pkg.version, '-v, --version')\n  .option('-l, --list', '从配置文件列出已存储的列表')\n  .option('-y, --yes', '默认yes')\n\n// 清除所有代理\nprogram\n  .command('clean')\n  .description('清除代理')\n  .action(function () {\n    readFile(bashProfile, data => {\n      if (!isWin) {\n        var str = deleteProxy(data)\n        writeFile(bashProfile, str, () => {\n          exec('source ' + bashProfile, function (err, stdout, stderr) {\n            if (err) throw err\n            if (stderr) throw stderr\n            success('代理清除成功...')\n          })\n        })\n      }\n    })\n  })\n\n\n// 显示代理\nprogram\n.command('show')\n.description('显示当前代理')\n.action(function () {\n  readFile(bashProfile, data => {\n      var url = showProxy(data)\n      success('当前代理设置为:',url)\n  })\n})\n\n// 初始化或生成默认代理\nprogram\n  .command('init')\n  .description('初始化')\n  .action(function () {\n    readFile(bashProfile, data => {\n      var str = deleteProxy(data)\n      writeFile(bashProfile, str, () => {\n        success('代理清除...')\n\n        inquirer.prompt([{\n          type: 'confirm',\n          name: 'confirm',\n          message: '是否生成默认代理127.0.0.1:1087（使用shawdowsocks的可以直接翻墙）',\n          default: true\n        }]).then((answers) => {\n          if (answers.confirm) {\n            appendFile(bashProfile, fullText(conf.defaultProxy), () => {\n              exec('source ' + bashProfile, function (err, stdout, stderr) {\n                if (err) throw err\n                if (stderr) throw stderr\n                success('成功写入默认代理...')\n              })\n            })\n          } else {\n            warning('取消设置')\n          }\n        })\n      })\n    })\n  })\n\n// 设置代理\nprogram\n  .command('add [url]')\n  .description('设置url为代理,并存储到配置文件')\n  .action(function (url) {\n    if (url) {\n      readFile(path.resolve(__dirname, './conf.json'), function (data) {\n        let data2 = JSON.parse(data)\n        data2.list.push(url)\n        writeFile(path.resolve(__dirname, './conf.json'), JSON.stringify(data2))\n      })\n\n      readFile(bashProfile, data => {\n        var str = deleteProxy(data)\n        writeFile(bashProfile, str, () => {\n          success('代理清除成功...')\n          appendFile(bashProfile, fullText(url), () => {\n            exec('source ' + bashProfile, function (err, stdout, stderr) {\n              if (err) throw err\n              if (stderr) throw stderr\n              success('成功写入代理 %s', url)\n              // console.log('rmdir %s', oDir);\n            })\n          })\n        })\n      })\n    } else if (program.list) {\n      let list = require('./conf').list  \n      const promptList = [{\n            type: 'list',\n            message: '选中你想要设置的代理:',\n            name: 'url',\n            choices: list\n        }];\n        inquirer.prompt(promptList).then(answers => {\n            let url = answers.url\n            readFile(bashProfile, data => {\n                let str = deleteProxy(data)\n                writeFile(bashProfile, str, () => {\n                    success('代理清除成功...')\n                    appendFile(bashProfile, fullText(url), () => {\n                        exec('source ' + bashProfile, function (err, stdout, stderr) {\n                        if (err) throw err\n                        if (stderr) throw stderr\n                        success('成功写入代理 %s', url)\n                        // console.log('rmdir %s', oDir);\n                        })\n                    })\n                })\n            })\n        })\n    } else {\n      err('缺少参数，使用proxys --help查看帮助')\n    }\n    // success('成功设置 \"%s\" 为当前代理', url)\n  })\n\n// 删除代理\nprogram\n  .command('rm [url]')\n  .description('设置url为代理')\n  .action(function (url) {\n    if (url) {\n      readFile(path.resolve(__dirname, './conf.json'), function (data) {\n        let data2 = JSON.parse(data)\n\n        let i = data2.list.indexOf(url)\n        if (i !== -1) data2.list.splice(i, 1)\n        writeFile(path.resolve(__dirname, './conf.json'), JSON.stringify(data2))\n        success('删除成功 %s', url)\n      })\n    } else if (program.list) {\n        let list = require('./conf').list  \n        const promptList = [{\n              type: 'list',\n              message: '选中你想要从列表删除的代理:',\n              name: 'url',\n              choices: list\n          }];\n          inquirer.prompt(promptList).then(answers => {\n            url = answers.url\n            readFile(path.resolve(__dirname, './conf.json'), function (data) {\n                let data2 = JSON.parse(data)       \n                let i = data2.list.indexOf(url)\n                if (i !== -1) data2.list.splice(i, 1)\n                writeFile(path.resolve(__dirname, './conf.json'), JSON.stringify(data2))\n                success('删除成功 %s', url)\n              })\n        })\n    } else {\n      err('缺少参数，使用proxys --help查看帮助')\n    }\n  })\n\nprogram.parse(process.argv)\n\n\nfunction showProxy(data){\n    let arr = data.split('\\n')\n    let index = arr.length\n    while (index--) {\n      let e = arr[index].toLowerCase()\n      if (e.includes('http_proxy') || e.includes('https_proxy')) {\n        let current  = arr[index].split('=')[1]\n        return current\n      }\n    }\n    return '空'\n}\n  "]}