Socket
Socket
Sign inDemoInstall

@octokit/plugin-enterprise-compatibility

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/plugin-enterprise-compatibility - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

63

dist-node/index.js

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

const VERSION = "1.2.7";
const VERSION = "1.2.8";

@@ -25,25 +25,2 @@ function isIssueLabelsUpdateOrReplace({

const REGEX_IS_GET_REFERENCE_PATH = /\/repos\/[^/]+\/[^/]+\/git\/ref\//;
const REGEX_IS_LIST_REFERENCES_PATH = /\/repos\/[^/]+\/[^/]+\/git\/matching-refs\//;
function isGetReference({
method,
url
}) {
if (!["GET", "HEAD"].includes(method)) {
return false;
}
return REGEX_IS_GET_REFERENCE_PATH.test(url);
}
function isListReferences({
method,
url
}) {
if (!["GET", "HEAD"].includes(method)) {
return false;
}
return REGEX_IS_LIST_REFERENCES_PATH.test(url);
}
function enterpriseCompatibility(octokit) {

@@ -63,38 +40,2 @@ octokit.hook.wrap("request", async (request, options) => {

return request(options);
}
const isGetReferenceRequest = isGetReference(options);
const isListReferencesRequest = isListReferences(options);
if (isGetReferenceRequest || isListReferencesRequest) {
options.url = options.url.replace(/\/repos\/([^/]+)\/([^/]+)\/git\/(ref|matching-refs)\/(.*)$/, "/repos/$1/$2/git/refs/$4");
return request(options).then(response => {
if (isGetReferenceRequest) {
if (Array.isArray(response.data)) {
throw new requestError.RequestError(`More than one reference found at "${options.url}"`, 404, {
request: options
});
} // ✅ received single reference
return response;
} // make sure that
if (!Array.isArray(response.data)) {
response.data = [response.data];
}
return response;
}).catch(error => {
if (isListReferencesRequest && error.status === 404) {
return {
status: 200,
headers: error.headers,
data: []
};
}
throw error;
});
} // TODO: implement fix for #62 here

@@ -116,3 +57,3 @@ // https://github.com/octokit/plugin-enterprise-compatibility.js/issues/60

const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/:team_id");
const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/{team_id}");
throw new requestError.RequestError(`"${options.method} ${options.url}" is not supported in your GitHub Enterprise Server version. Please replace with octokit.request("${options.method} ${deprecatedUrl}", { team_id })`, 404, {

@@ -119,0 +60,0 @@ request: options

import { RequestError } from "@octokit/request-error";
import { VERSION } from "./version";
import { isIssueLabelsUpdateOrReplace } from "./is-issue-labels-update-or-replace";
import { isGetReference, isListReferences, } from "./is-get-reference-or-list-references";
export function enterpriseCompatibility(octokit) {

@@ -18,34 +17,2 @@ octokit.hook.wrap("request", async (request, options) => {

}
const isGetReferenceRequest = isGetReference(options);
const isListReferencesRequest = isListReferences(options);
if (isGetReferenceRequest || isListReferencesRequest) {
options.url = options.url.replace(/\/repos\/([^/]+)\/([^/]+)\/git\/(ref|matching-refs)\/(.*)$/, "/repos/$1/$2/git/refs/$4");
return request(options)
.then((response) => {
if (isGetReferenceRequest) {
if (Array.isArray(response.data)) {
throw new RequestError(`More than one reference found at "${options.url}"`, 404, {
request: options,
});
}
// ✅ received single reference
return response;
}
// make sure that
if (!Array.isArray(response.data)) {
response.data = [response.data];
}
return response;
})
.catch((error) => {
if (isListReferencesRequest && error.status === 404) {
return {
status: 200,
headers: error.headers,
data: [],
};
}
throw error;
});
}
// TODO: implement fix for #62 here

@@ -64,3 +31,3 @@ // https://github.com/octokit/plugin-enterprise-compatibility.js/issues/60

}
const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/:team_id");
const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/{team_id}");
throw new RequestError(`"${options.method} ${options.url}" is not supported in your GitHub Enterprise Server version. Please replace with octokit.request("${options.method} ${deprecatedUrl}", { team_id })`, 404, {

@@ -67,0 +34,0 @@ request: options,

2

dist-src/version.js

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

export const VERSION = "1.2.7";
export const VERSION = "1.2.8";

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

export declare const VERSION = "1.2.7";
export declare const VERSION = "1.2.8";
import { RequestError } from '@octokit/request-error';
const VERSION = "1.2.7";
const VERSION = "1.2.8";

@@ -15,17 +15,2 @@ function isIssueLabelsUpdateOrReplace({ method, url }) {

const REGEX_IS_GET_REFERENCE_PATH = /\/repos\/[^/]+\/[^/]+\/git\/ref\//;
const REGEX_IS_LIST_REFERENCES_PATH = /\/repos\/[^/]+\/[^/]+\/git\/matching-refs\//;
function isGetReference({ method, url }) {
if (!["GET", "HEAD"].includes(method)) {
return false;
}
return REGEX_IS_GET_REFERENCE_PATH.test(url);
}
function isListReferences({ method, url }) {
if (!["GET", "HEAD"].includes(method)) {
return false;
}
return REGEX_IS_LIST_REFERENCES_PATH.test(url);
}
function enterpriseCompatibility(octokit) {

@@ -44,34 +29,2 @@ octokit.hook.wrap("request", async (request, options) => {

}
const isGetReferenceRequest = isGetReference(options);
const isListReferencesRequest = isListReferences(options);
if (isGetReferenceRequest || isListReferencesRequest) {
options.url = options.url.replace(/\/repos\/([^/]+)\/([^/]+)\/git\/(ref|matching-refs)\/(.*)$/, "/repos/$1/$2/git/refs/$4");
return request(options)
.then((response) => {
if (isGetReferenceRequest) {
if (Array.isArray(response.data)) {
throw new RequestError(`More than one reference found at "${options.url}"`, 404, {
request: options,
});
}
// ✅ received single reference
return response;
}
// make sure that
if (!Array.isArray(response.data)) {
response.data = [response.data];
}
return response;
})
.catch((error) => {
if (isListReferencesRequest && error.status === 404) {
return {
status: 200,
headers: error.headers,
data: [],
};
}
throw error;
});
}
// TODO: implement fix for #62 here

@@ -90,3 +43,3 @@ // https://github.com/octokit/plugin-enterprise-compatibility.js/issues/60

}
const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/:team_id");
const deprecatedUrl = options.url.replace(/\/orgs\/[^/]+\/teams\/[^/]+/, "/teams/{team_id}");
throw new RequestError(`"${options.method} ${options.url}" is not supported in your GitHub Enterprise Server version. Please replace with octokit.request("${options.method} ${deprecatedUrl}", { team_id })`, 404, {

@@ -93,0 +46,0 @@ request: options,

{
"name": "@octokit/plugin-enterprise-compatibility",
"description": "Octokit plugin for improving GHE compatibility",
"version": "1.2.7",
"version": "1.2.8",
"license": "MIT",

@@ -22,4 +22,4 @@ "files": [

"dependencies": {
"@octokit/request-error": "^2.0.0",
"@octokit/types": "^6.0.0"
"@octokit/request-error": "^2.0.4",
"@octokit/types": "^6.0.3"
},

@@ -26,0 +26,0 @@ "devDependencies": {

@@ -55,3 +55,3 @@ # plugin-enterprise-compatibility.js

octokit.request("POST /repos/:owner/:repo/issues/:issue_number/labels", {
octokit.request("POST /repos/{owner}/{repo}/issues/{issue_number}/labels", {
owner,

@@ -58,0 +58,0 @@ repo,

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