Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit/core

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/core - npm Package Compare versions

Comparing version 2.4.2 to 2.4.3

17

dist-node/index.js

@@ -11,3 +11,3 @@ 'use strict';

const VERSION = "2.4.2";
const VERSION = "2.4.3";

@@ -99,8 +99,19 @@ class Octokit {

}
/**
* Attach a plugin (or many) to your Octokit instance.
*
* @example
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
*/
static plugin(pluginOrPlugins) {
static plugin(p1, ...p2) {
var _a;
if (p1 instanceof Array) {
console.warn(["Passing an array of plugins to Octokit.plugin() has been deprecated.", "Instead of:", " Octokit.plugin([plugin1, plugin2, ...])", "Use:", " Octokit.plugin(plugin1, plugin2, ...)"].join("\n"));
}
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins) ? pluginOrPlugins : [pluginOrPlugins];
let newPlugins = [...(p1 instanceof Array ? p1 : [p1]), ...p2];
const NewOctokit = (_a = class extends this {}, _a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))), _a);

@@ -107,0 +118,0 @@ return NewOctokit;

46

dist-src/index.js

@@ -14,8 +14,8 @@ import { getUserAgent } from "universal-user-agent";

request: Object.assign({}, options.request, {
hook: hook.bind(null, "request")
hook: hook.bind(null, "request"),
}),
mediaType: {
previews: [],
format: ""
}
format: "",
},
};

@@ -25,3 +25,3 @@ // prepend default user agent with `options.userAgent` if set

options.userAgent,
`octokit-core.js/${VERSION} ${getUserAgent()}`
`octokit-core.js/${VERSION} ${getUserAgent()}`,
]

@@ -45,3 +45,3 @@ .filter(Boolean)

warn: console.warn.bind(console),
error: console.error.bind(console)
error: console.error.bind(console),
}, options.log);

@@ -58,3 +58,3 @@ this.hook = hook;

this.auth = async () => ({
type: "unauthenticated"
type: "unauthenticated",
});

@@ -72,3 +72,3 @@ }

const auth = options.authStrategy(Object.assign({
request: this.request
request: this.request,
}, options.auth));

@@ -82,3 +82,3 @@ // @ts-ignore ¯\_(ツ)_/¯

const classConstructor = this.constructor;
classConstructor.plugins.forEach(plugin => {
classConstructor.plugins.forEach((plugin) => {
Object.assign(this, plugin(this, options));

@@ -93,3 +93,3 @@ });

? {
userAgent: `${options.userAgent} ${defaults.userAgent}`
userAgent: `${options.userAgent} ${defaults.userAgent}`,
}

@@ -101,11 +101,29 @@ : null));

}
static plugin(pluginOrPlugins) {
/**
* Attach a plugin (or many) to your Octokit instance.
*
* @example
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
*/
static plugin(p1, ...p2) {
var _a;
if (p1 instanceof Array) {
console.warn([
"Passing an array of plugins to Octokit.plugin() has been deprecated.",
"Instead of:",
" Octokit.plugin([plugin1, plugin2, ...])",
"Use:",
" Octokit.plugin(plugin1, plugin2, ...)",
].join("\n"));
}
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins)
? pluginOrPlugins
: [pluginOrPlugins];
let newPlugins = [
...(p1 instanceof Array
? p1
: [p1]),
...p2,
];
const NewOctokit = (_a = class extends this {
},
_a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))),
_a.plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin))),
_a);

@@ -112,0 +130,0 @@ return NewOctokit;

@@ -1,1 +0,1 @@

export const VERSION = "2.4.2";
export const VERSION = "2.4.3";
import { HookCollection } from "before-after-hook";
import { request } from "@octokit/request";
import { graphql } from "@octokit/graphql";
import { Constructor, OctokitOptions, OctokitPlugin, ReturnTypeOf } from "./types";
import { Constructor, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types";
export declare class Octokit {

@@ -13,5 +13,11 @@ static VERSION: string;

static plugins: OctokitPlugin[];
/**
* Attach a plugin (or many) to your Octokit instance.
*
* @example
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
*/
static plugin<S extends Constructor<any> & {
plugins: any[];
}, T extends OctokitPlugin | OctokitPlugin[]>(this: S, pluginOrPlugins: T): {
}, T1 extends OctokitPlugin | OctokitPlugin[], T2 extends OctokitPlugin[]>(this: S, p1: T1, ...p2: T2): {
new (...args: any[]): {

@@ -21,3 +27,3 @@ [x: string]: any;

plugins: any[];
} & S & Constructor<ReturnTypeOf<T>>;
} & S & Constructor<UnionToIntersection<ReturnTypeOf<T1> & ReturnTypeOf<T2>>>;
constructor(options?: OctokitOptions);

@@ -24,0 +30,0 @@ request: typeof request;

@@ -17,3 +17,3 @@ import * as OctokitTypes from "@octokit/types";

*/
declare type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
export declare type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
declare type AnyFunction = (...args: any) => any;

@@ -20,0 +20,0 @@ export declare type OctokitPlugin = (octokit: Octokit, options: OctokitOptions) => {

@@ -1,1 +0,1 @@

export declare const VERSION = "2.4.2";
export declare const VERSION = "2.4.3";

@@ -7,3 +7,3 @@ import { getUserAgent } from 'universal-user-agent';

const VERSION = "2.4.2";
const VERSION = "2.4.3";

@@ -17,8 +17,8 @@ class Octokit {

request: Object.assign({}, options.request, {
hook: hook.bind(null, "request")
hook: hook.bind(null, "request"),
}),
mediaType: {
previews: [],
format: ""
}
format: "",
},
};

@@ -28,3 +28,3 @@ // prepend default user agent with `options.userAgent` if set

options.userAgent,
`octokit-core.js/${VERSION} ${getUserAgent()}`
`octokit-core.js/${VERSION} ${getUserAgent()}`,
]

@@ -48,3 +48,3 @@ .filter(Boolean)

warn: console.warn.bind(console),
error: console.error.bind(console)
error: console.error.bind(console),
}, options.log);

@@ -61,3 +61,3 @@ this.hook = hook;

this.auth = async () => ({
type: "unauthenticated"
type: "unauthenticated",
});

@@ -75,3 +75,3 @@ }

const auth = options.authStrategy(Object.assign({
request: this.request
request: this.request,
}, options.auth));

@@ -85,3 +85,3 @@ // @ts-ignore ¯\_(ツ)_/¯

const classConstructor = this.constructor;
classConstructor.plugins.forEach(plugin => {
classConstructor.plugins.forEach((plugin) => {
Object.assign(this, plugin(this, options));

@@ -96,3 +96,3 @@ });

? {
userAgent: `${options.userAgent} ${defaults.userAgent}`
userAgent: `${options.userAgent} ${defaults.userAgent}`,
}

@@ -104,11 +104,29 @@ : null));

}
static plugin(pluginOrPlugins) {
/**
* Attach a plugin (or many) to your Octokit instance.
*
* @example
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
*/
static plugin(p1, ...p2) {
var _a;
if (p1 instanceof Array) {
console.warn([
"Passing an array of plugins to Octokit.plugin() has been deprecated.",
"Instead of:",
" Octokit.plugin([plugin1, plugin2, ...])",
"Use:",
" Octokit.plugin(plugin1, plugin2, ...)",
].join("\n"));
}
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins)
? pluginOrPlugins
: [pluginOrPlugins];
let newPlugins = [
...(p1 instanceof Array
? p1
: [p1]),
...p2,
];
const NewOctokit = (_a = class extends this {
},
_a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))),
_a.plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin))),
_a);

@@ -115,0 +133,0 @@ return NewOctokit;

{
"name": "@octokit/core",
"description": "Extendable client for GitHub's REST & GraphQL APIs",
"version": "2.4.2",
"version": "2.4.3",
"license": "MIT",

@@ -29,3 +29,3 @@ "files": [

"devDependencies": {
"@octokit/auth": "^1.1.0",
"@octokit/auth": "^2.0.0",
"@pika/pack": "^0.5.0",

@@ -40,7 +40,7 @@ "@pika/plugin-build-node": "^0.9.0",

"@types/node-fetch": "^2.5.0",
"fetch-mock": "^8.3.2",
"fetch-mock": "^9.0.0",
"http-proxy-agent": "^4.0.1",
"jest": "^25.1.0",
"lolex": "^6.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.0",
"proxy": "^1.0.1",

@@ -47,0 +47,0 @@ "semantic-release": "^17.0.0",

@@ -68,3 +68,3 @@ # core.js

org: "octokit",
type: "private"
type: "private",
});

@@ -146,3 +146,3 @@ ```

const octokit = new Octokit({
baseUrl: "https://github.acme-inc.com/api/v3"
baseUrl: "https://github.acme-inc.com/api/v3",
});

@@ -167,3 +167,3 @@ ```

mediaType: {
previews: ["shadow-cat"]
previews: ["shadow-cat"],
},

@@ -175,3 +175,3 @@ owner,

head: "my-feature",
draft: true
draft: true,
});

@@ -184,3 +184,3 @@ ```

const octokit = new Octokit({
previews: ["shadow-cat"]
previews: ["shadow-cat"],
});

@@ -217,3 +217,3 @@ ```

const octokit = new Octokit({
timeZone: "America/Los_Angeles"
timeZone: "America/Los_Angeles",
});

@@ -238,3 +238,3 @@ ```

const octokit = new Octokit({
userAgent: "my-app/v1.2.3"
userAgent: "my-app/v1.2.3",
});

@@ -255,3 +255,3 @@ ```

baseUrl: "https://github.acme-inc.com/api/v3",
userAgent: "my-app/v1.2.3"
userAgent: "my-app/v1.2.3",
});

@@ -272,3 +272,3 @@ const octokit1 = new MyOctokit();

const octokit = new Octokit({
auth: "mypersonalaccesstoken123"
auth: "mypersonalaccesstoken123",
});

@@ -289,4 +289,4 @@

id: 123,
privateKey: process.env.PRIVATE_KEY
}
privateKey: process.env.PRIVATE_KEY,
},
});

@@ -302,3 +302,3 @@

type: "installation",
installationId: 123
installationId: 123,
});

@@ -324,3 +324,3 @@ ```

const octokit = new Octokit({
log: require("console-log-level")({ level: "info" })
log: require("console-log-level")({ level: "info" }),
});

@@ -334,3 +334,3 @@ ```

```js
octokit.hook.before("request", async options => {
octokit.hook.before("request", async (options) => {
validate(options);

@@ -358,3 +358,3 @@ });

Octokit’s functionality can be extended using plugins. THe `Octokit.plugin()` method accepts a function or an array of functions and returns a new constructor.
Octokit’s functionality can be extended using plugins. The `Octokit.plugin()` method accepts a plugin (or many) and returns a new constructor.

@@ -370,6 +370,6 @@ A plugin is a function which gets two arguments:

// index.js
const MyOctokit = require("@octokit/core").plugin([
const MyOctokit = require("@octokit/core").plugin(
require("./lib/my-plugin"),
require("octokit-plugin-example")
]);
);

@@ -406,10 +406,10 @@ const octokit = new MyOctokit({ greeting: "Moin moin" });

const MyActionOctokit = require("@octokit/core")
.plugin([
.plugin(
require("@octokit/plugin-paginate"),
require("@octokit/plugin-throttle"),
require("@octokit/plugin-retry")
])
)
.defaults({
authStrategy: require("@octokit/auth-action"),
userAgent: `my-octokit-action/v1.2.3`
userAgent: `my-octokit-action/v1.2.3`,
});

@@ -416,0 +416,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc