index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const { requestLog } = require("@octokit/plugin-request-log");
  2. const {
  3. restEndpointMethods
  4. } = require("@octokit/plugin-rest-endpoint-methods");
  5. const Core = require("./lib/core");
  6. const CORE_PLUGINS = [
  7. require("./plugins/authentication"),
  8. require("./plugins/authentication-deprecated"), // deprecated: remove in v17
  9. requestLog,
  10. require("./plugins/pagination"),
  11. restEndpointMethods,
  12. require("./plugins/validate"),
  13. require("octokit-pagination-methods") // deprecated: remove in v17
  14. ];
  15. const OctokitRest = Core.plugin(CORE_PLUGINS);
  16. function DeprecatedOctokit(options) {
  17. const warn =
  18. options && options.log && options.log.warn
  19. ? options.log.warn
  20. : console.warn;
  21. warn(
  22. '[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead'
  23. );
  24. return new OctokitRest(options);
  25. }
  26. const Octokit = Object.assign(DeprecatedOctokit, {
  27. Octokit: OctokitRest
  28. });
  29. Object.keys(OctokitRest).forEach(key => {
  30. /* istanbul ignore else */
  31. if (OctokitRest.hasOwnProperty(key)) {
  32. Octokit[key] = OctokitRest[key];
  33. }
  34. });
  35. module.exports = Octokit;