This commit is contained in:
312
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js
generated
vendored
Normal file
312
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
23
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js.LICENSE.txt
generated
vendored
Normal file
23
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js.LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <https://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||
1
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js.map
generated
vendored
Normal file
1
node_modules/decap-cms-backend-github/dist/decap-cms-backend-github.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1219
node_modules/decap-cms-backend-github/dist/esm/API.js
generated
vendored
Normal file
1219
node_modules/decap-cms-backend-github/dist/esm/API.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
192
node_modules/decap-cms-backend-github/dist/esm/AuthenticationPage.js
generated
vendored
Normal file
192
node_modules/decap-cms-backend-github/dist/esm/AuthenticationPage.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
804
node_modules/decap-cms-backend-github/dist/esm/GraphQLAPI.js
generated
vendored
Normal file
804
node_modules/decap-cms-backend-github/dist/esm/GraphQLAPI.js
generated
vendored
Normal file
@@ -0,0 +1,804 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _trimStart2 = _interopRequireDefault(require("lodash/trimStart"));
|
||||
var _trim2 = _interopRequireDefault(require("lodash/trim"));
|
||||
var _apolloClient = require("apollo-client");
|
||||
var _apolloCacheInmemory = require("apollo-cache-inmemory");
|
||||
var _apolloLinkHttp = require("apollo-link-http");
|
||||
var _apolloLinkContext = require("apollo-link-context");
|
||||
var _decapCmsLibUtil = require("decap-cms-lib-util");
|
||||
var _fragmentTypes = _interopRequireDefault(require("./fragmentTypes"));
|
||||
var _API = _interopRequireWildcard(require("./API"));
|
||||
var queries = _interopRequireWildcard(require("./queries"));
|
||||
var mutations = _interopRequireWildcard(require("./mutations"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
const NO_CACHE = 'no-cache';
|
||||
const CACHE_FIRST = 'cache-first';
|
||||
const fragmentMatcher = new _apolloCacheInmemory.IntrospectionFragmentMatcher({
|
||||
introspectionQueryResultData: _fragmentTypes.default
|
||||
});
|
||||
function transformPullRequest(pr) {
|
||||
return _objectSpread(_objectSpread({}, pr), {}, {
|
||||
labels: pr.labels.nodes,
|
||||
head: {
|
||||
ref: pr.headRefName,
|
||||
sha: pr.headRefOid,
|
||||
repo: {
|
||||
fork: pr.repository.isFork
|
||||
}
|
||||
},
|
||||
base: {
|
||||
ref: pr.baseRefName,
|
||||
sha: pr.baseRefOid
|
||||
}
|
||||
});
|
||||
}
|
||||
class GraphQLAPI extends _API.default {
|
||||
constructor(config) {
|
||||
super(config);
|
||||
_defineProperty(this, "client", void 0);
|
||||
this.client = this.getApolloClient();
|
||||
}
|
||||
getApolloClient() {
|
||||
const authLink = (0, _apolloLinkContext.setContext)((_, {
|
||||
headers
|
||||
}) => {
|
||||
return {
|
||||
headers: _objectSpread(_objectSpread({
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
}, headers), {}, {
|
||||
authorization: this.token ? `${this.tokenKeyword} ${this.token}` : ''
|
||||
})
|
||||
};
|
||||
});
|
||||
const httpLink = (0, _apolloLinkHttp.createHttpLink)({
|
||||
uri: `${this.apiRoot}/graphql`
|
||||
});
|
||||
return new _apolloClient.ApolloClient({
|
||||
link: authLink.concat(httpLink),
|
||||
cache: new _apolloCacheInmemory.InMemoryCache({
|
||||
fragmentMatcher
|
||||
}),
|
||||
defaultOptions: {
|
||||
watchQuery: {
|
||||
fetchPolicy: NO_CACHE,
|
||||
errorPolicy: 'ignore'
|
||||
},
|
||||
query: {
|
||||
fetchPolicy: NO_CACHE,
|
||||
errorPolicy: 'all'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
reset() {
|
||||
return this.client.resetStore();
|
||||
}
|
||||
async getRepository(owner, name) {
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.repository,
|
||||
variables: {
|
||||
owner,
|
||||
name
|
||||
},
|
||||
fetchPolicy: CACHE_FIRST // repository id doesn't change
|
||||
});
|
||||
return data.repository;
|
||||
}
|
||||
query(options) {
|
||||
return this.client.query(options).catch(error => {
|
||||
throw new _decapCmsLibUtil.APIError(error.message, 500, 'GitHub');
|
||||
});
|
||||
}
|
||||
async mutate(options) {
|
||||
try {
|
||||
const result = await this.client.mutate(options);
|
||||
return result;
|
||||
} catch (error) {
|
||||
const errors = error.graphQLErrors;
|
||||
if (Array.isArray(errors) && errors.some(e => e.message === 'Ref cannot be created.')) {
|
||||
var _options$variables, _options$variables$cr;
|
||||
const refName = (options === null || options === void 0 ? void 0 : (_options$variables = options.variables) === null || _options$variables === void 0 ? void 0 : (_options$variables$cr = _options$variables.createRefInput) === null || _options$variables$cr === void 0 ? void 0 : _options$variables$cr.name) || '';
|
||||
const branchName = (0, _trimStart2.default)(refName, 'refs/heads/');
|
||||
if (branchName) {
|
||||
await (0, _decapCmsLibUtil.throwOnConflictingBranches)(branchName, name => this.getBranch(name), _API.API_NAME);
|
||||
}
|
||||
} else if (Array.isArray(errors) && errors.some(e => new RegExp(`A ref named "refs/heads/${_decapCmsLibUtil.CMS_BRANCH_PREFIX}/.+?" already exists in the repository.`).test(e.message))) {
|
||||
var _options$variables2, _options$variables2$c, _options$variables3, _options$variables3$c;
|
||||
const refName = (options === null || options === void 0 ? void 0 : (_options$variables2 = options.variables) === null || _options$variables2 === void 0 ? void 0 : (_options$variables2$c = _options$variables2.createRefInput) === null || _options$variables2$c === void 0 ? void 0 : _options$variables2$c.name) || '';
|
||||
const sha = (options === null || options === void 0 ? void 0 : (_options$variables3 = options.variables) === null || _options$variables3 === void 0 ? void 0 : (_options$variables3$c = _options$variables3.createRefInput) === null || _options$variables3$c === void 0 ? void 0 : _options$variables3$c.oid) || '';
|
||||
const branchName = (0, _trimStart2.default)(refName, 'refs/heads/');
|
||||
if (branchName && branchName.startsWith(`${_decapCmsLibUtil.CMS_BRANCH_PREFIX}/`) && sha) {
|
||||
try {
|
||||
// this can happen if the branch wasn't deleted when the PR was merged
|
||||
// we backup the existing branch just in case an re-run the mutation
|
||||
await this.backupBranch(branchName);
|
||||
await this.deleteBranch(branchName);
|
||||
const result = await this.client.mutate(options);
|
||||
return result;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new _decapCmsLibUtil.APIError(error.message, 500, 'GitHub');
|
||||
}
|
||||
}
|
||||
async hasWriteAccess() {
|
||||
const {
|
||||
repoOwner: owner,
|
||||
repoName: name
|
||||
} = this;
|
||||
try {
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.repoPermission,
|
||||
variables: {
|
||||
owner,
|
||||
name
|
||||
},
|
||||
fetchPolicy: CACHE_FIRST // we can assume permission doesn't change often
|
||||
});
|
||||
// https://developer.github.com/v4/enum/repositorypermission/
|
||||
const {
|
||||
viewerPermission
|
||||
} = data.repository;
|
||||
return ['ADMIN', 'MAINTAIN', 'WRITE'].includes(viewerPermission);
|
||||
} catch (error) {
|
||||
console.error('Problem fetching repo data from GitHub');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async user() {
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.user,
|
||||
fetchPolicy: CACHE_FIRST // we can assume user details don't change often
|
||||
});
|
||||
return data.viewer;
|
||||
}
|
||||
async retrieveBlobObject(owner, name, expression, options = {}) {
|
||||
const {
|
||||
data
|
||||
} = await this.query(_objectSpread({
|
||||
query: queries.blob,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
expression
|
||||
}
|
||||
}, options));
|
||||
// https://developer.github.com/v4/object/blob/
|
||||
if (data.repository.object) {
|
||||
const {
|
||||
is_binary: isBinary,
|
||||
text
|
||||
} = data.repository.object;
|
||||
return {
|
||||
isNull: false,
|
||||
isBinary,
|
||||
text
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
isNull: true
|
||||
};
|
||||
}
|
||||
}
|
||||
getOwnerAndNameFromRepoUrl(repoURL) {
|
||||
let {
|
||||
repoOwner: owner,
|
||||
repoName: name
|
||||
} = this;
|
||||
if (repoURL === this.originRepoURL) {
|
||||
({
|
||||
originRepoOwner: owner,
|
||||
originRepoName: name
|
||||
} = this);
|
||||
}
|
||||
return {
|
||||
owner,
|
||||
name
|
||||
};
|
||||
}
|
||||
async readFile(path, sha, {
|
||||
branch = this.branch,
|
||||
repoURL = this.repoURL,
|
||||
parseText = true
|
||||
} = {}) {
|
||||
if (!sha) {
|
||||
sha = await this.getFileSha(path, {
|
||||
repoURL,
|
||||
branch
|
||||
});
|
||||
}
|
||||
const fetchContent = () => this.fetchBlobContent({
|
||||
sha: sha,
|
||||
repoURL,
|
||||
parseText
|
||||
});
|
||||
const content = await (0, _decapCmsLibUtil.readFile)(sha, fetchContent, _decapCmsLibUtil.localForage, parseText);
|
||||
return content;
|
||||
}
|
||||
async fetchBlobContent({
|
||||
sha,
|
||||
repoURL,
|
||||
parseText
|
||||
}) {
|
||||
if (!parseText) {
|
||||
return super.fetchBlobContent({
|
||||
sha,
|
||||
repoURL,
|
||||
parseText
|
||||
});
|
||||
}
|
||||
const {
|
||||
owner,
|
||||
name
|
||||
} = this.getOwnerAndNameFromRepoUrl(repoURL);
|
||||
const {
|
||||
isNull,
|
||||
isBinary,
|
||||
text
|
||||
} = await this.retrieveBlobObject(owner, name, sha, {
|
||||
fetchPolicy: CACHE_FIRST
|
||||
} // blob sha is derived from file content
|
||||
);
|
||||
if (isNull) {
|
||||
throw new _decapCmsLibUtil.APIError('Not Found', 404, 'GitHub');
|
||||
} else if (!isBinary) {
|
||||
return text;
|
||||
} else {
|
||||
return super.fetchBlobContent({
|
||||
sha,
|
||||
repoURL,
|
||||
parseText
|
||||
});
|
||||
}
|
||||
}
|
||||
async getPullRequestAuthor(pullRequest) {
|
||||
const user = pullRequest.user;
|
||||
return (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.login);
|
||||
}
|
||||
async getPullRequests(head, state, predicate) {
|
||||
const {
|
||||
originRepoOwner: owner,
|
||||
originRepoName: name
|
||||
} = this;
|
||||
let states;
|
||||
if (state === _API.PullRequestState.Open) {
|
||||
states = ['OPEN'];
|
||||
} else if (state === _API.PullRequestState.Closed) {
|
||||
states = ['CLOSED', 'MERGED'];
|
||||
} else {
|
||||
states = ['OPEN', 'CLOSED', 'MERGED'];
|
||||
}
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.pullRequests,
|
||||
variables: _objectSpread(_objectSpread({
|
||||
owner,
|
||||
name
|
||||
}, head ? {
|
||||
head
|
||||
} : {}), {}, {
|
||||
states
|
||||
})
|
||||
});
|
||||
const {
|
||||
pullRequests
|
||||
} = data.repository;
|
||||
const mapped = pullRequests.nodes.map(transformPullRequest);
|
||||
return mapped.filter(pr => pr.head.ref.startsWith(`${_decapCmsLibUtil.CMS_BRANCH_PREFIX}/`) && predicate(pr));
|
||||
}
|
||||
async getOpenAuthoringBranches() {
|
||||
const {
|
||||
repoOwner: owner,
|
||||
repoName: name
|
||||
} = this;
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.openAuthoringBranches,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
refPrefix: `refs/heads/cms/${this.repo}/`
|
||||
}
|
||||
});
|
||||
return data.repository.refs.nodes.map(({
|
||||
name,
|
||||
prefix
|
||||
}) => ({
|
||||
ref: `${prefix}${name}`
|
||||
}));
|
||||
}
|
||||
async getStatuses(collectionName, slug) {
|
||||
const contentKey = this.generateContentKey(collectionName, slug);
|
||||
const branch = (0, _decapCmsLibUtil.branchFromContentKey)(contentKey);
|
||||
const pullRequest = await this.getBranchPullRequest(branch);
|
||||
const sha = pullRequest.head.sha;
|
||||
const {
|
||||
originRepoOwner: owner,
|
||||
originRepoName: name
|
||||
} = this;
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.statues,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
sha
|
||||
}
|
||||
});
|
||||
if (data.repository.object) {
|
||||
const {
|
||||
status
|
||||
} = data.repository.object;
|
||||
const {
|
||||
contexts
|
||||
} = status || {
|
||||
contexts: []
|
||||
};
|
||||
return contexts;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
getAllFiles(entries, path) {
|
||||
const allFiles = entries.reduce((acc, item) => {
|
||||
if (item.type === 'tree') {
|
||||
var _item$object;
|
||||
const entries = ((_item$object = item.object) === null || _item$object === void 0 ? void 0 : _item$object.entries) || [];
|
||||
return [...acc, ...this.getAllFiles(entries, `${path}/${item.name}`)];
|
||||
} else if (item.type === 'blob') {
|
||||
return [...acc, {
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
id: item.sha,
|
||||
path: `${path}/${item.name}`,
|
||||
size: item.blob ? item.blob.size : 0
|
||||
}];
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
return allFiles;
|
||||
}
|
||||
async listFiles(path, {
|
||||
repoURL = this.repoURL,
|
||||
branch = this.branch,
|
||||
depth = 1
|
||||
} = {}) {
|
||||
const {
|
||||
owner,
|
||||
name
|
||||
} = this.getOwnerAndNameFromRepoUrl(repoURL);
|
||||
const folder = (0, _trim2.default)(path, '/');
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.files(depth),
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
expression: `${branch}:${folder}`
|
||||
}
|
||||
});
|
||||
if (data.repository.object) {
|
||||
const allFiles = this.getAllFiles(data.repository.object.entries, folder);
|
||||
return allFiles;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
getBranchQualifiedName(branch) {
|
||||
return `refs/heads/${branch}`;
|
||||
}
|
||||
getBranchQuery(branch, owner, name) {
|
||||
return {
|
||||
query: queries.branch,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
qualifiedName: this.getBranchQualifiedName(branch)
|
||||
}
|
||||
};
|
||||
}
|
||||
async getDefaultBranch() {
|
||||
const {
|
||||
data
|
||||
} = await this.query(_objectSpread({}, this.getBranchQuery(this.branch, this.originRepoOwner, this.originRepoName)));
|
||||
return data.repository.branch;
|
||||
}
|
||||
async getBranch(branch) {
|
||||
const {
|
||||
data
|
||||
} = await this.query(_objectSpread(_objectSpread({}, this.getBranchQuery(branch, this.repoOwner, this.repoName)), {}, {
|
||||
fetchPolicy: CACHE_FIRST
|
||||
}));
|
||||
if (!data.repository.branch) {
|
||||
throw new _decapCmsLibUtil.APIError('Branch not found', 404, _API.API_NAME);
|
||||
}
|
||||
return data.repository.branch;
|
||||
}
|
||||
async patchRef(type, name, sha, opts = {}) {
|
||||
if (type !== 'heads') {
|
||||
return super.patchRef(type, name, sha, opts);
|
||||
}
|
||||
const force = opts.force || false;
|
||||
const branch = await this.getBranch(name);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.updateBranch,
|
||||
variables: {
|
||||
input: {
|
||||
oid: sha,
|
||||
refId: branch.id,
|
||||
force
|
||||
}
|
||||
}
|
||||
});
|
||||
return data.updateRef.branch;
|
||||
}
|
||||
async deleteBranch(branchName) {
|
||||
const branch = await this.getBranch(branchName);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.deleteBranch,
|
||||
variables: {
|
||||
deleteRefInput: {
|
||||
refId: branch.id
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
update: store => store.data.delete((0, _apolloCacheInmemory.defaultDataIdFromObject)(branch))
|
||||
});
|
||||
return data.deleteRef;
|
||||
}
|
||||
getPullRequestQuery(number) {
|
||||
const {
|
||||
originRepoOwner: owner,
|
||||
originRepoName: name
|
||||
} = this;
|
||||
return {
|
||||
query: queries.pullRequest,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
number
|
||||
}
|
||||
};
|
||||
}
|
||||
async getPullRequest(number) {
|
||||
const {
|
||||
data
|
||||
} = await this.query(_objectSpread(_objectSpread({}, this.getPullRequestQuery(number)), {}, {
|
||||
fetchPolicy: CACHE_FIRST
|
||||
}));
|
||||
|
||||
// https://developer.github.com/v4/enum/pullrequeststate/
|
||||
// GraphQL state: [CLOSED, MERGED, OPEN]
|
||||
// REST API state: [closed, open]
|
||||
const state = data.repository.pullRequest.state === 'OPEN' ? _API.PullRequestState.Open : _API.PullRequestState.Closed;
|
||||
return _objectSpread(_objectSpread({}, data.repository.pullRequest), {}, {
|
||||
state
|
||||
});
|
||||
}
|
||||
getPullRequestAndBranchQuery(branch, number) {
|
||||
const {
|
||||
repoOwner: owner,
|
||||
repoName: name
|
||||
} = this;
|
||||
const {
|
||||
originRepoOwner,
|
||||
originRepoName
|
||||
} = this;
|
||||
return {
|
||||
query: queries.pullRequestAndBranch,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
originRepoOwner,
|
||||
originRepoName,
|
||||
number,
|
||||
qualifiedName: this.getBranchQualifiedName(branch)
|
||||
}
|
||||
};
|
||||
}
|
||||
async getPullRequestAndBranch(branch, number) {
|
||||
const {
|
||||
data
|
||||
} = await this.query(_objectSpread(_objectSpread({}, this.getPullRequestAndBranchQuery(branch, number)), {}, {
|
||||
fetchPolicy: CACHE_FIRST
|
||||
}));
|
||||
const {
|
||||
repository,
|
||||
origin
|
||||
} = data;
|
||||
return {
|
||||
branch: repository.branch,
|
||||
pullRequest: origin.pullRequest
|
||||
};
|
||||
}
|
||||
async openPR(number) {
|
||||
const pullRequest = await this.getPullRequest(number);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.reopenPullRequest,
|
||||
variables: {
|
||||
reopenPullRequestInput: {
|
||||
pullRequestId: pullRequest.id
|
||||
}
|
||||
},
|
||||
update: (store, {
|
||||
data: mutationResult
|
||||
}) => {
|
||||
const {
|
||||
pullRequest
|
||||
} = mutationResult.reopenPullRequest;
|
||||
const pullRequestData = {
|
||||
repository: _objectSpread(_objectSpread({}, pullRequest.repository), {}, {
|
||||
pullRequest
|
||||
})
|
||||
};
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getPullRequestQuery(pullRequest.number)), {}, {
|
||||
data: pullRequestData
|
||||
}));
|
||||
}
|
||||
});
|
||||
return data.reopenPullRequest;
|
||||
}
|
||||
async closePR(number) {
|
||||
const pullRequest = await this.getPullRequest(number);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.closePullRequest,
|
||||
variables: {
|
||||
closePullRequestInput: {
|
||||
pullRequestId: pullRequest.id
|
||||
}
|
||||
},
|
||||
update: (store, {
|
||||
data: mutationResult
|
||||
}) => {
|
||||
const {
|
||||
pullRequest
|
||||
} = mutationResult.closePullRequest;
|
||||
const pullRequestData = {
|
||||
repository: _objectSpread(_objectSpread({}, pullRequest.repository), {}, {
|
||||
pullRequest
|
||||
})
|
||||
};
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getPullRequestQuery(pullRequest.number)), {}, {
|
||||
data: pullRequestData
|
||||
}));
|
||||
}
|
||||
});
|
||||
return data.closePullRequest;
|
||||
}
|
||||
async deleteUnpublishedEntry(collectionName, slug) {
|
||||
try {
|
||||
const contentKey = this.generateContentKey(collectionName, slug);
|
||||
const branchName = (0, _decapCmsLibUtil.branchFromContentKey)(contentKey);
|
||||
const pr = await this.getBranchPullRequest(branchName);
|
||||
if (pr.number !== _API.MOCK_PULL_REQUEST) {
|
||||
const {
|
||||
branch,
|
||||
pullRequest
|
||||
} = await this.getPullRequestAndBranch(branchName, pr.number);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.closePullRequestAndDeleteBranch,
|
||||
variables: {
|
||||
deleteRefInput: {
|
||||
refId: branch.id
|
||||
},
|
||||
closePullRequestInput: {
|
||||
pullRequestId: pullRequest.id
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
update: store => {
|
||||
store.data.delete((0, _apolloCacheInmemory.defaultDataIdFromObject)(branch));
|
||||
store.data.delete((0, _apolloCacheInmemory.defaultDataIdFromObject)(pullRequest));
|
||||
}
|
||||
});
|
||||
return data.closePullRequest;
|
||||
} else {
|
||||
return await this.deleteBranch(branchName);
|
||||
}
|
||||
} catch (e) {
|
||||
const {
|
||||
graphQLErrors
|
||||
} = e;
|
||||
if (graphQLErrors && graphQLErrors.length > 0) {
|
||||
const branchNotFound = graphQLErrors.some(e => e.type === 'NOT_FOUND');
|
||||
if (branchNotFound) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async createPR(title, head) {
|
||||
const [repository, headReference] = await Promise.all([this.getRepository(this.originRepoOwner, this.originRepoName), this.useOpenAuthoring ? `${(await this.user()).login}:${head}` : head]);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.createPullRequest,
|
||||
variables: {
|
||||
createPullRequestInput: {
|
||||
baseRefName: this.branch,
|
||||
body: _decapCmsLibUtil.DEFAULT_PR_BODY,
|
||||
title,
|
||||
headRefName: headReference,
|
||||
repositoryId: repository.id
|
||||
}
|
||||
},
|
||||
update: (store, {
|
||||
data: mutationResult
|
||||
}) => {
|
||||
const {
|
||||
pullRequest
|
||||
} = mutationResult.createPullRequest;
|
||||
const pullRequestData = {
|
||||
repository: _objectSpread(_objectSpread({}, pullRequest.repository), {}, {
|
||||
pullRequest
|
||||
})
|
||||
};
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getPullRequestQuery(pullRequest.number)), {}, {
|
||||
data: pullRequestData
|
||||
}));
|
||||
}
|
||||
});
|
||||
const {
|
||||
pullRequest
|
||||
} = data.createPullRequest;
|
||||
return _objectSpread(_objectSpread({}, pullRequest), {}, {
|
||||
head: {
|
||||
sha: pullRequest.headRefOid
|
||||
}
|
||||
});
|
||||
}
|
||||
async createBranch(branchName, sha) {
|
||||
const owner = this.repoOwner;
|
||||
const name = this.repoName;
|
||||
const repository = await this.getRepository(owner, name);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.createBranch,
|
||||
variables: {
|
||||
createRefInput: {
|
||||
name: this.getBranchQualifiedName(branchName),
|
||||
oid: sha,
|
||||
repositoryId: repository.id
|
||||
}
|
||||
},
|
||||
update: (store, {
|
||||
data: mutationResult
|
||||
}) => {
|
||||
const {
|
||||
branch
|
||||
} = mutationResult.createRef;
|
||||
const branchData = {
|
||||
repository: _objectSpread(_objectSpread({}, branch.repository), {}, {
|
||||
branch
|
||||
})
|
||||
};
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getBranchQuery(branchName, owner, name)), {}, {
|
||||
data: branchData
|
||||
}));
|
||||
}
|
||||
});
|
||||
const {
|
||||
branch
|
||||
} = data.createRef;
|
||||
return _objectSpread(_objectSpread({}, branch), {}, {
|
||||
ref: `${branch.prefix}${branch.name}`
|
||||
});
|
||||
}
|
||||
async createBranchAndPullRequest(branchName, sha, title) {
|
||||
const owner = this.originRepoOwner;
|
||||
const name = this.originRepoName;
|
||||
const repository = await this.getRepository(owner, name);
|
||||
const {
|
||||
data
|
||||
} = await this.mutate({
|
||||
mutation: mutations.createBranchAndPullRequest,
|
||||
variables: {
|
||||
createRefInput: {
|
||||
name: this.getBranchQualifiedName(branchName),
|
||||
oid: sha,
|
||||
repositoryId: repository.id
|
||||
},
|
||||
createPullRequestInput: {
|
||||
baseRefName: this.branch,
|
||||
body: _decapCmsLibUtil.DEFAULT_PR_BODY,
|
||||
title,
|
||||
headRefName: branchName,
|
||||
repositoryId: repository.id
|
||||
}
|
||||
},
|
||||
update: (store, {
|
||||
data: mutationResult
|
||||
}) => {
|
||||
const {
|
||||
branch
|
||||
} = mutationResult.createRef;
|
||||
const {
|
||||
pullRequest
|
||||
} = mutationResult.createPullRequest;
|
||||
const branchData = {
|
||||
repository: _objectSpread(_objectSpread({}, branch.repository), {}, {
|
||||
branch
|
||||
})
|
||||
};
|
||||
const pullRequestData = {
|
||||
repository: _objectSpread(_objectSpread({}, pullRequest.repository), {}, {
|
||||
branch
|
||||
}),
|
||||
origin: _objectSpread(_objectSpread({}, pullRequest.repository), {}, {
|
||||
pullRequest
|
||||
})
|
||||
};
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getBranchQuery(branchName, owner, name)), {}, {
|
||||
data: branchData
|
||||
}));
|
||||
store.writeQuery(_objectSpread(_objectSpread({}, this.getPullRequestAndBranchQuery(branchName, pullRequest.number)), {}, {
|
||||
data: pullRequestData
|
||||
}));
|
||||
}
|
||||
});
|
||||
const {
|
||||
pullRequest
|
||||
} = data.createPullRequest;
|
||||
return transformPullRequest(pullRequest);
|
||||
}
|
||||
async getFileSha(path, {
|
||||
repoURL = this.repoURL,
|
||||
branch = this.branch
|
||||
} = {}) {
|
||||
const {
|
||||
owner,
|
||||
name
|
||||
} = this.getOwnerAndNameFromRepoUrl(repoURL);
|
||||
const {
|
||||
data
|
||||
} = await this.query({
|
||||
query: queries.fileSha,
|
||||
variables: {
|
||||
owner,
|
||||
name,
|
||||
expression: `${branch}:${path}`
|
||||
}
|
||||
});
|
||||
if (data.repository.file) {
|
||||
return data.repository.file.sha;
|
||||
}
|
||||
throw new _decapCmsLibUtil.APIError('Not Found', 404, _API.API_NAME);
|
||||
}
|
||||
}
|
||||
exports.default = GraphQLAPI;
|
||||
947
node_modules/decap-cms-backend-github/dist/esm/fragmentTypes.js
generated
vendored
Normal file
947
node_modules/decap-cms-backend-github/dist/esm/fragmentTypes.js
generated
vendored
Normal file
@@ -0,0 +1,947 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"__schema": {
|
||||
"types": [{
|
||||
"kind": "INTERFACE",
|
||||
"name": "Node",
|
||||
"possibleTypes": [{
|
||||
"name": "AddedToProjectEvent"
|
||||
}, {
|
||||
"name": "App"
|
||||
}, {
|
||||
"name": "AssignedEvent"
|
||||
}, {
|
||||
"name": "BaseRefChangedEvent"
|
||||
}, {
|
||||
"name": "BaseRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "Blob"
|
||||
}, {
|
||||
"name": "Bot"
|
||||
}, {
|
||||
"name": "BranchProtectionRule"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "CodeOfConduct"
|
||||
}, {
|
||||
"name": "CommentDeletedEvent"
|
||||
}, {
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "CommitCommentThread"
|
||||
}, {
|
||||
"name": "ConvertedNoteToIssueEvent"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "DemilestonedEvent"
|
||||
}, {
|
||||
"name": "DeployKey"
|
||||
}, {
|
||||
"name": "DeployedEvent"
|
||||
}, {
|
||||
"name": "Deployment"
|
||||
}, {
|
||||
"name": "DeploymentEnvironmentChangedEvent"
|
||||
}, {
|
||||
"name": "DeploymentStatus"
|
||||
}, {
|
||||
"name": "ExternalIdentity"
|
||||
}, {
|
||||
"name": "Gist"
|
||||
}, {
|
||||
"name": "GistComment"
|
||||
}, {
|
||||
"name": "HeadRefDeletedEvent"
|
||||
}, {
|
||||
"name": "HeadRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "HeadRefRestoredEvent"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "Label"
|
||||
}, {
|
||||
"name": "LabeledEvent"
|
||||
}, {
|
||||
"name": "Language"
|
||||
}, {
|
||||
"name": "License"
|
||||
}, {
|
||||
"name": "LockedEvent"
|
||||
}, {
|
||||
"name": "Mannequin"
|
||||
}, {
|
||||
"name": "MarketplaceCategory"
|
||||
}, {
|
||||
"name": "MarketplaceListing"
|
||||
}, {
|
||||
"name": "MentionedEvent"
|
||||
}, {
|
||||
"name": "MergedEvent"
|
||||
}, {
|
||||
"name": "Milestone"
|
||||
}, {
|
||||
"name": "MilestonedEvent"
|
||||
}, {
|
||||
"name": "MovedColumnsInProjectEvent"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "OrganizationIdentityProvider"
|
||||
}, {
|
||||
"name": "OrganizationInvitation"
|
||||
}, {
|
||||
"name": "PinnedEvent"
|
||||
}, {
|
||||
"name": "Project"
|
||||
}, {
|
||||
"name": "ProjectCard"
|
||||
}, {
|
||||
"name": "ProjectColumn"
|
||||
}, {
|
||||
"name": "PublicKey"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestCommit"
|
||||
}, {
|
||||
"name": "PullRequestCommitCommentThread"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}, {
|
||||
"name": "PullRequestReviewThread"
|
||||
}, {
|
||||
"name": "PushAllowance"
|
||||
}, {
|
||||
"name": "Reaction"
|
||||
}, {
|
||||
"name": "ReadyForReviewEvent"
|
||||
}, {
|
||||
"name": "Ref"
|
||||
}, {
|
||||
"name": "ReferencedEvent"
|
||||
}, {
|
||||
"name": "RegistryPackage"
|
||||
}, {
|
||||
"name": "RegistryPackageDependency"
|
||||
}, {
|
||||
"name": "RegistryPackageFile"
|
||||
}, {
|
||||
"name": "RegistryPackageTag"
|
||||
}, {
|
||||
"name": "RegistryPackageVersion"
|
||||
}, {
|
||||
"name": "Release"
|
||||
}, {
|
||||
"name": "ReleaseAsset"
|
||||
}, {
|
||||
"name": "RemovedFromProjectEvent"
|
||||
}, {
|
||||
"name": "RenamedTitleEvent"
|
||||
}, {
|
||||
"name": "ReopenedEvent"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "RepositoryInvitation"
|
||||
}, {
|
||||
"name": "RepositoryTopic"
|
||||
}, {
|
||||
"name": "ReviewDismissalAllowance"
|
||||
}, {
|
||||
"name": "ReviewDismissedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequest"
|
||||
}, {
|
||||
"name": "ReviewRequestRemovedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequestedEvent"
|
||||
}, {
|
||||
"name": "SavedReply"
|
||||
}, {
|
||||
"name": "SecurityAdvisory"
|
||||
}, {
|
||||
"name": "SponsorsListing"
|
||||
}, {
|
||||
"name": "Sponsorship"
|
||||
}, {
|
||||
"name": "Status"
|
||||
}, {
|
||||
"name": "StatusContext"
|
||||
}, {
|
||||
"name": "SubscribedEvent"
|
||||
}, {
|
||||
"name": "Tag"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}, {
|
||||
"name": "Topic"
|
||||
}, {
|
||||
"name": "TransferredEvent"
|
||||
}, {
|
||||
"name": "Tree"
|
||||
}, {
|
||||
"name": "UnassignedEvent"
|
||||
}, {
|
||||
"name": "UnlabeledEvent"
|
||||
}, {
|
||||
"name": "UnlockedEvent"
|
||||
}, {
|
||||
"name": "UnpinnedEvent"
|
||||
}, {
|
||||
"name": "UnsubscribedEvent"
|
||||
}, {
|
||||
"name": "User"
|
||||
}, {
|
||||
"name": "UserBlockedEvent"
|
||||
}, {
|
||||
"name": "UserContentEdit"
|
||||
}, {
|
||||
"name": "UserStatus"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "UniformResourceLocatable",
|
||||
"possibleTypes": [{
|
||||
"name": "Bot"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "Gist"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "Mannequin"
|
||||
}, {
|
||||
"name": "MergedEvent"
|
||||
}, {
|
||||
"name": "Milestone"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestCommit"
|
||||
}, {
|
||||
"name": "ReadyForReviewEvent"
|
||||
}, {
|
||||
"name": "Release"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "RepositoryTopic"
|
||||
}, {
|
||||
"name": "ReviewDismissedEvent"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Actor",
|
||||
"possibleTypes": [{
|
||||
"name": "Bot"
|
||||
}, {
|
||||
"name": "Mannequin"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "RegistryPackageOwner",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "ProjectOwner",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Closable",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "Milestone"
|
||||
}, {
|
||||
"name": "Project"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Updatable",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "GistComment"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "Project"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "ProjectCardItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Assignable",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Comment",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "GistComment"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "UpdatableComment",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "GistComment"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Labelable",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Lockable",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "RegistryPackageSearch",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "RepositoryOwner",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "MemberStatusable",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "ProfileOwner",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "PinnableItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Gist"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Starrable",
|
||||
"possibleTypes": [{
|
||||
"name": "Gist"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "Topic"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "RepositoryInfo",
|
||||
"possibleTypes": [{
|
||||
"name": "Repository"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "GitObject",
|
||||
"possibleTypes": [{
|
||||
"name": "Blob"
|
||||
}, {
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "Tag"
|
||||
}, {
|
||||
"name": "Tree"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "RepositoryNode",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "CommitCommentThread"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestCommitCommentThread"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Subscribable",
|
||||
"possibleTypes": [{
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Deletable",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "GistComment"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Reactable",
|
||||
"possibleTypes": [{
|
||||
"name": "CommitComment"
|
||||
}, {
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "GitSignature",
|
||||
"possibleTypes": [{
|
||||
"name": "GpgSignature"
|
||||
}, {
|
||||
"name": "SmimeSignature"
|
||||
}, {
|
||||
"name": "UnknownSignature"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "RequestedReviewer",
|
||||
"possibleTypes": [{
|
||||
"name": "User"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}, {
|
||||
"name": "Mannequin"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "PullRequestTimelineItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "CommitCommentThread"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewThread"
|
||||
}, {
|
||||
"name": "PullRequestReviewComment"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "ReopenedEvent"
|
||||
}, {
|
||||
"name": "SubscribedEvent"
|
||||
}, {
|
||||
"name": "UnsubscribedEvent"
|
||||
}, {
|
||||
"name": "MergedEvent"
|
||||
}, {
|
||||
"name": "ReferencedEvent"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "AssignedEvent"
|
||||
}, {
|
||||
"name": "UnassignedEvent"
|
||||
}, {
|
||||
"name": "LabeledEvent"
|
||||
}, {
|
||||
"name": "UnlabeledEvent"
|
||||
}, {
|
||||
"name": "MilestonedEvent"
|
||||
}, {
|
||||
"name": "DemilestonedEvent"
|
||||
}, {
|
||||
"name": "RenamedTitleEvent"
|
||||
}, {
|
||||
"name": "LockedEvent"
|
||||
}, {
|
||||
"name": "UnlockedEvent"
|
||||
}, {
|
||||
"name": "DeployedEvent"
|
||||
}, {
|
||||
"name": "DeploymentEnvironmentChangedEvent"
|
||||
}, {
|
||||
"name": "HeadRefDeletedEvent"
|
||||
}, {
|
||||
"name": "HeadRefRestoredEvent"
|
||||
}, {
|
||||
"name": "HeadRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "BaseRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequestedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequestRemovedEvent"
|
||||
}, {
|
||||
"name": "ReviewDismissedEvent"
|
||||
}, {
|
||||
"name": "UserBlockedEvent"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "Closer",
|
||||
"possibleTypes": [{
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "ReferencedSubject",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "Assignee",
|
||||
"possibleTypes": [{
|
||||
"name": "Bot"
|
||||
}, {
|
||||
"name": "Mannequin"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "MilestoneItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "RenamedTitleSubject",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "PullRequestTimelineItems",
|
||||
"possibleTypes": [{
|
||||
"name": "PullRequestCommit"
|
||||
}, {
|
||||
"name": "PullRequestCommitCommentThread"
|
||||
}, {
|
||||
"name": "PullRequestReview"
|
||||
}, {
|
||||
"name": "PullRequestReviewThread"
|
||||
}, {
|
||||
"name": "PullRequestRevisionMarker"
|
||||
}, {
|
||||
"name": "BaseRefChangedEvent"
|
||||
}, {
|
||||
"name": "BaseRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "DeployedEvent"
|
||||
}, {
|
||||
"name": "DeploymentEnvironmentChangedEvent"
|
||||
}, {
|
||||
"name": "HeadRefDeletedEvent"
|
||||
}, {
|
||||
"name": "HeadRefForcePushedEvent"
|
||||
}, {
|
||||
"name": "HeadRefRestoredEvent"
|
||||
}, {
|
||||
"name": "MergedEvent"
|
||||
}, {
|
||||
"name": "ReviewDismissedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequestedEvent"
|
||||
}, {
|
||||
"name": "ReviewRequestRemovedEvent"
|
||||
}, {
|
||||
"name": "ReadyForReviewEvent"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "AddedToProjectEvent"
|
||||
}, {
|
||||
"name": "AssignedEvent"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "CommentDeletedEvent"
|
||||
}, {
|
||||
"name": "ConvertedNoteToIssueEvent"
|
||||
}, {
|
||||
"name": "DemilestonedEvent"
|
||||
}, {
|
||||
"name": "LabeledEvent"
|
||||
}, {
|
||||
"name": "LockedEvent"
|
||||
}, {
|
||||
"name": "MentionedEvent"
|
||||
}, {
|
||||
"name": "MilestonedEvent"
|
||||
}, {
|
||||
"name": "MovedColumnsInProjectEvent"
|
||||
}, {
|
||||
"name": "PinnedEvent"
|
||||
}, {
|
||||
"name": "ReferencedEvent"
|
||||
}, {
|
||||
"name": "RemovedFromProjectEvent"
|
||||
}, {
|
||||
"name": "RenamedTitleEvent"
|
||||
}, {
|
||||
"name": "ReopenedEvent"
|
||||
}, {
|
||||
"name": "SubscribedEvent"
|
||||
}, {
|
||||
"name": "TransferredEvent"
|
||||
}, {
|
||||
"name": "UnassignedEvent"
|
||||
}, {
|
||||
"name": "UnlabeledEvent"
|
||||
}, {
|
||||
"name": "UnlockedEvent"
|
||||
}, {
|
||||
"name": "UserBlockedEvent"
|
||||
}, {
|
||||
"name": "UnpinnedEvent"
|
||||
}, {
|
||||
"name": "UnsubscribedEvent"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "IssueOrPullRequest",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "IssueTimelineItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Commit"
|
||||
}, {
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "ReopenedEvent"
|
||||
}, {
|
||||
"name": "SubscribedEvent"
|
||||
}, {
|
||||
"name": "UnsubscribedEvent"
|
||||
}, {
|
||||
"name": "ReferencedEvent"
|
||||
}, {
|
||||
"name": "AssignedEvent"
|
||||
}, {
|
||||
"name": "UnassignedEvent"
|
||||
}, {
|
||||
"name": "LabeledEvent"
|
||||
}, {
|
||||
"name": "UnlabeledEvent"
|
||||
}, {
|
||||
"name": "UserBlockedEvent"
|
||||
}, {
|
||||
"name": "MilestonedEvent"
|
||||
}, {
|
||||
"name": "DemilestonedEvent"
|
||||
}, {
|
||||
"name": "RenamedTitleEvent"
|
||||
}, {
|
||||
"name": "LockedEvent"
|
||||
}, {
|
||||
"name": "UnlockedEvent"
|
||||
}, {
|
||||
"name": "TransferredEvent"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "IssueTimelineItems",
|
||||
"possibleTypes": [{
|
||||
"name": "IssueComment"
|
||||
}, {
|
||||
"name": "CrossReferencedEvent"
|
||||
}, {
|
||||
"name": "AddedToProjectEvent"
|
||||
}, {
|
||||
"name": "AssignedEvent"
|
||||
}, {
|
||||
"name": "ClosedEvent"
|
||||
}, {
|
||||
"name": "CommentDeletedEvent"
|
||||
}, {
|
||||
"name": "ConvertedNoteToIssueEvent"
|
||||
}, {
|
||||
"name": "DemilestonedEvent"
|
||||
}, {
|
||||
"name": "LabeledEvent"
|
||||
}, {
|
||||
"name": "LockedEvent"
|
||||
}, {
|
||||
"name": "MentionedEvent"
|
||||
}, {
|
||||
"name": "MilestonedEvent"
|
||||
}, {
|
||||
"name": "MovedColumnsInProjectEvent"
|
||||
}, {
|
||||
"name": "PinnedEvent"
|
||||
}, {
|
||||
"name": "ReferencedEvent"
|
||||
}, {
|
||||
"name": "RemovedFromProjectEvent"
|
||||
}, {
|
||||
"name": "RenamedTitleEvent"
|
||||
}, {
|
||||
"name": "ReopenedEvent"
|
||||
}, {
|
||||
"name": "SubscribedEvent"
|
||||
}, {
|
||||
"name": "TransferredEvent"
|
||||
}, {
|
||||
"name": "UnassignedEvent"
|
||||
}, {
|
||||
"name": "UnlabeledEvent"
|
||||
}, {
|
||||
"name": "UnlockedEvent"
|
||||
}, {
|
||||
"name": "UserBlockedEvent"
|
||||
}, {
|
||||
"name": "UnpinnedEvent"
|
||||
}, {
|
||||
"name": "UnsubscribedEvent"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "ReviewDismissalAllowanceActor",
|
||||
"possibleTypes": [{
|
||||
"name": "User"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "PushAllowanceActor",
|
||||
"possibleTypes": [{
|
||||
"name": "User"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "PermissionGranter",
|
||||
"possibleTypes": [{
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "Team"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Sponsorable",
|
||||
"possibleTypes": [{
|
||||
"name": "User"
|
||||
}]
|
||||
}, {
|
||||
"kind": "INTERFACE",
|
||||
"name": "Contribution",
|
||||
"possibleTypes": [{
|
||||
"name": "CreatedCommitContribution"
|
||||
}, {
|
||||
"name": "CreatedIssueContribution"
|
||||
}, {
|
||||
"name": "CreatedPullRequestContribution"
|
||||
}, {
|
||||
"name": "CreatedPullRequestReviewContribution"
|
||||
}, {
|
||||
"name": "CreatedRepositoryContribution"
|
||||
}, {
|
||||
"name": "JoinedGitHubContribution"
|
||||
}, {
|
||||
"name": "RestrictedContribution"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "CreatedRepositoryOrRestrictedContribution",
|
||||
"possibleTypes": [{
|
||||
"name": "CreatedRepositoryContribution"
|
||||
}, {
|
||||
"name": "RestrictedContribution"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "CreatedIssueOrRestrictedContribution",
|
||||
"possibleTypes": [{
|
||||
"name": "CreatedIssueContribution"
|
||||
}, {
|
||||
"name": "RestrictedContribution"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "CreatedPullRequestOrRestrictedContribution",
|
||||
"possibleTypes": [{
|
||||
"name": "CreatedPullRequestContribution"
|
||||
}, {
|
||||
"name": "RestrictedContribution"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "SearchResultItem",
|
||||
"possibleTypes": [{
|
||||
"name": "Issue"
|
||||
}, {
|
||||
"name": "PullRequest"
|
||||
}, {
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "User"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "MarketplaceListing"
|
||||
}, {
|
||||
"name": "App"
|
||||
}]
|
||||
}, {
|
||||
"kind": "UNION",
|
||||
"name": "CollectionItemContent",
|
||||
"possibleTypes": [{
|
||||
"name": "Repository"
|
||||
}, {
|
||||
"name": "Organization"
|
||||
}, {
|
||||
"name": "User"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
};
|
||||
91
node_modules/decap-cms-backend-github/dist/esm/fragments.js
generated
vendored
Normal file
91
node_modules/decap-cms-backend-github/dist/esm/fragments.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.treeEntry = exports.repository = exports.pullRequest = exports.object = exports.fileEntry = exports.branch = exports.blobWithText = void 0;
|
||||
var _graphqlTag = require("graphql-tag");
|
||||
const repository = exports.repository = (0, _graphqlTag.gql)`
|
||||
fragment RepositoryParts on Repository {
|
||||
id
|
||||
isFork
|
||||
}
|
||||
`;
|
||||
const blobWithText = exports.blobWithText = (0, _graphqlTag.gql)`
|
||||
fragment BlobWithTextParts on Blob {
|
||||
id
|
||||
text
|
||||
is_binary: isBinary
|
||||
}
|
||||
`;
|
||||
const object = exports.object = (0, _graphqlTag.gql)`
|
||||
fragment ObjectParts on GitObject {
|
||||
id
|
||||
sha: oid
|
||||
}
|
||||
`;
|
||||
const branch = exports.branch = (0, _graphqlTag.gql)`
|
||||
fragment BranchParts on Ref {
|
||||
commit: target {
|
||||
...ObjectParts
|
||||
}
|
||||
id
|
||||
name
|
||||
prefix
|
||||
repository {
|
||||
...RepositoryParts
|
||||
}
|
||||
}
|
||||
${object}
|
||||
${repository}
|
||||
`;
|
||||
const pullRequest = exports.pullRequest = (0, _graphqlTag.gql)`
|
||||
fragment PullRequestParts on PullRequest {
|
||||
id
|
||||
baseRefName
|
||||
baseRefOid
|
||||
body
|
||||
headRefName
|
||||
headRefOid
|
||||
number
|
||||
state
|
||||
title
|
||||
merged_at: mergedAt
|
||||
updated_at: updatedAt
|
||||
user: author {
|
||||
login
|
||||
... on User {
|
||||
name
|
||||
}
|
||||
}
|
||||
repository {
|
||||
...RepositoryParts
|
||||
}
|
||||
labels(last: 100) {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
${repository}
|
||||
`;
|
||||
const treeEntry = exports.treeEntry = (0, _graphqlTag.gql)`
|
||||
fragment TreeEntryParts on TreeEntry {
|
||||
path: name
|
||||
sha: oid
|
||||
type
|
||||
mode
|
||||
}
|
||||
`;
|
||||
const fileEntry = exports.fileEntry = (0, _graphqlTag.gql)`
|
||||
fragment FileEntryParts on TreeEntry {
|
||||
name
|
||||
sha: oid
|
||||
type
|
||||
blob: object {
|
||||
... on Blob {
|
||||
size: byteSize
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
633
node_modules/decap-cms-backend-github/dist/esm/implementation.js
generated
vendored
Normal file
633
node_modules/decap-cms-backend-github/dist/esm/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,633 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _semaphore = _interopRequireDefault(require("semaphore"));
|
||||
var _trimStart = _interopRequireDefault(require("lodash/trimStart"));
|
||||
var _commonTags = require("common-tags");
|
||||
var _decapCmsLibUtil = require("decap-cms-lib-util");
|
||||
var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
|
||||
var _API = _interopRequireWildcard(require("./API"));
|
||||
var _GraphQLAPI = _interopRequireDefault(require("./GraphQLAPI"));
|
||||
var _react2 = require("@emotion/react");
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
const MAX_CONCURRENT_DOWNLOADS = 10;
|
||||
const {
|
||||
fetchWithTimeout: fetch
|
||||
} = _decapCmsLibUtil.unsentRequest;
|
||||
const STATUS_PAGE = 'https://www.githubstatus.com';
|
||||
const GITHUB_STATUS_ENDPOINT = `${STATUS_PAGE}/api/v2/components.json`;
|
||||
const GITHUB_OPERATIONAL_UNITS = ['API Requests', 'Issues, Pull Requests, Projects'];
|
||||
class GitHub {
|
||||
constructor(config, options = {}) {
|
||||
var _config$backend$branc;
|
||||
_defineProperty(this, "lock", void 0);
|
||||
_defineProperty(this, "api", void 0);
|
||||
_defineProperty(this, "options", void 0);
|
||||
_defineProperty(this, "originRepo", void 0);
|
||||
_defineProperty(this, "isBranchConfigured", void 0);
|
||||
_defineProperty(this, "repo", void 0);
|
||||
_defineProperty(this, "openAuthoringEnabled", void 0);
|
||||
_defineProperty(this, "useOpenAuthoring", void 0);
|
||||
_defineProperty(this, "alwaysForkEnabled", void 0);
|
||||
_defineProperty(this, "branch", void 0);
|
||||
_defineProperty(this, "apiRoot", void 0);
|
||||
_defineProperty(this, "mediaFolder", void 0);
|
||||
_defineProperty(this, "previewContext", void 0);
|
||||
_defineProperty(this, "token", void 0);
|
||||
_defineProperty(this, "tokenKeyword", void 0);
|
||||
_defineProperty(this, "squashMerges", void 0);
|
||||
_defineProperty(this, "cmsLabelPrefix", void 0);
|
||||
_defineProperty(this, "useGraphql", void 0);
|
||||
_defineProperty(this, "baseUrl", void 0);
|
||||
_defineProperty(this, "bypassWriteAccessCheckForAppTokens", false);
|
||||
_defineProperty(this, "_currentUserPromise", void 0);
|
||||
_defineProperty(this, "_userIsOriginMaintainerPromises", void 0);
|
||||
_defineProperty(this, "_mediaDisplayURLSem", void 0);
|
||||
_defineProperty(this, "getCursorAndFiles", (files, page) => {
|
||||
const pageSize = 20;
|
||||
const count = files.length;
|
||||
const pageCount = Math.ceil(files.length / pageSize);
|
||||
const actions = [];
|
||||
if (page > 1) {
|
||||
actions.push('prev');
|
||||
actions.push('first');
|
||||
}
|
||||
if (page < pageCount) {
|
||||
actions.push('next');
|
||||
actions.push('last');
|
||||
}
|
||||
const cursor = _decapCmsLibUtil.Cursor.create({
|
||||
actions,
|
||||
meta: {
|
||||
page,
|
||||
count,
|
||||
pageSize,
|
||||
pageCount
|
||||
},
|
||||
data: {
|
||||
files
|
||||
}
|
||||
});
|
||||
const pageFiles = files.slice((page - 1) * pageSize, page * pageSize);
|
||||
return {
|
||||
cursor,
|
||||
files: pageFiles
|
||||
};
|
||||
});
|
||||
this.options = _objectSpread({
|
||||
proxied: false,
|
||||
API: null,
|
||||
initialWorkflowStatus: ''
|
||||
}, options);
|
||||
if (!this.options.proxied && (config.backend.repo === null || config.backend.repo === undefined)) {
|
||||
throw new Error('The GitHub backend needs a "repo" in the backend configuration.');
|
||||
}
|
||||
this.api = this.options.API || null;
|
||||
this.isBranchConfigured = config.backend.branch ? true : false;
|
||||
this.openAuthoringEnabled = config.backend.open_authoring || false;
|
||||
if (this.openAuthoringEnabled) {
|
||||
if (!this.options.useWorkflow) {
|
||||
throw new Error('backend.open_authoring is true but publish_mode is not set to editorial_workflow.');
|
||||
}
|
||||
this.originRepo = config.backend.repo || '';
|
||||
} else {
|
||||
this.repo = this.originRepo = config.backend.repo || '';
|
||||
}
|
||||
this.alwaysForkEnabled = config.backend.always_fork || false;
|
||||
this.branch = ((_config$backend$branc = config.backend.branch) === null || _config$backend$branc === void 0 ? void 0 : _config$backend$branc.trim()) || 'master';
|
||||
this.apiRoot = config.backend.api_root || 'https://api.github.com';
|
||||
this.token = '';
|
||||
this.tokenKeyword = 'token';
|
||||
this.baseUrl = config.backend.base_url;
|
||||
this.squashMerges = config.backend.squash_merges || false;
|
||||
this.cmsLabelPrefix = config.backend.cms_label_prefix || '';
|
||||
this.useGraphql = config.backend.use_graphql || false;
|
||||
this.mediaFolder = config.media_folder;
|
||||
this.previewContext = config.backend.preview_context || '';
|
||||
this.lock = (0, _decapCmsLibUtil.asyncLock)();
|
||||
}
|
||||
isGitBackend() {
|
||||
return true;
|
||||
}
|
||||
async status() {
|
||||
const api = await fetch(GITHUB_STATUS_ENDPOINT).then(res => res.json()).then(res => {
|
||||
return res['components'].filter(statusComponent => GITHUB_OPERATIONAL_UNITS.includes(statusComponent.name)).every(statusComponent => statusComponent.status === 'operational');
|
||||
}).catch(e => {
|
||||
console.warn('Failed getting GitHub status', e);
|
||||
return true;
|
||||
});
|
||||
let auth = false;
|
||||
// no need to check auth if api is down
|
||||
if (api) {
|
||||
var _this$api, _this$token;
|
||||
auth = (await ((_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.getUser({
|
||||
token: (_this$token = this.token) !== null && _this$token !== void 0 ? _this$token : ''
|
||||
}).then(user => !!user).catch(e => {
|
||||
console.warn('Failed getting GitHub user', e);
|
||||
return false;
|
||||
}))) || false;
|
||||
}
|
||||
return {
|
||||
auth: {
|
||||
status: auth
|
||||
},
|
||||
api: {
|
||||
status: api,
|
||||
statusPage: STATUS_PAGE
|
||||
}
|
||||
};
|
||||
}
|
||||
authComponent() {
|
||||
const wrappedAuthenticationPage = props => (0, _react2.jsx)(_AuthenticationPage.default, _extends({}, props, {
|
||||
backend: this
|
||||
}));
|
||||
wrappedAuthenticationPage.displayName = 'AuthenticationPage';
|
||||
return wrappedAuthenticationPage;
|
||||
}
|
||||
restoreUser(user) {
|
||||
return this.openAuthoringEnabled ? this.authenticateWithFork({
|
||||
userData: user,
|
||||
getPermissionToFork: () => true
|
||||
}).then(() => this.authenticate(user)) : this.authenticate(user);
|
||||
}
|
||||
async pollUntilForkExists({
|
||||
repo,
|
||||
token
|
||||
}) {
|
||||
const pollDelay = 250; // milliseconds
|
||||
let repoExists = false;
|
||||
while (!repoExists) {
|
||||
repoExists = await fetch(`${this.apiRoot}/repos/${repo}`, {
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
}
|
||||
}).then(() => true).catch(err => {
|
||||
if (err && err.status === 404) {
|
||||
console.log('This 404 was expected and handled appropriately.');
|
||||
return false;
|
||||
} else {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
});
|
||||
// wait between polls
|
||||
if (!repoExists) {
|
||||
await new Promise(resolve => setTimeout(resolve, pollDelay));
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
async currentUser({
|
||||
token
|
||||
}) {
|
||||
if (!this._currentUserPromise) {
|
||||
this._currentUserPromise = fetch(`${this.apiRoot}/user`, {
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
}
|
||||
}).then(res => res.json());
|
||||
}
|
||||
return this._currentUserPromise;
|
||||
}
|
||||
async userIsOriginMaintainer({
|
||||
username: usernameArg,
|
||||
token
|
||||
}) {
|
||||
const username = usernameArg || (await this.currentUser({
|
||||
token
|
||||
})).login;
|
||||
this._userIsOriginMaintainerPromises = this._userIsOriginMaintainerPromises || {};
|
||||
if (!this._userIsOriginMaintainerPromises[username]) {
|
||||
this._userIsOriginMaintainerPromises[username] = fetch(`${this.apiRoot}/repos/${this.originRepo}/collaborators/${username}/permission`, {
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
}
|
||||
}).then(res => res.json()).then(({
|
||||
permission
|
||||
}) => permission === 'admin' || permission === 'write');
|
||||
}
|
||||
return this._userIsOriginMaintainerPromises[username];
|
||||
}
|
||||
async forkExists({
|
||||
token
|
||||
}) {
|
||||
try {
|
||||
const currentUser = await this.currentUser({
|
||||
token
|
||||
});
|
||||
const repoName = this.originRepo.split('/')[1];
|
||||
const repo = await fetch(`${this.apiRoot}/repos/${currentUser.login}/${repoName}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
}
|
||||
}).then(res => res.json());
|
||||
|
||||
// https://developer.github.com/v3/repos/#get
|
||||
// The parent and source objects are present when the repository is a fork.
|
||||
// parent is the repository this repository was forked from, source is the ultimate source for the network.
|
||||
const forkExists = repo.fork === true && repo.parent && repo.parent.full_name.toLowerCase() === this.originRepo.toLowerCase();
|
||||
return forkExists;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async authenticateWithFork({
|
||||
userData,
|
||||
getPermissionToFork
|
||||
}) {
|
||||
if (!this.openAuthoringEnabled) {
|
||||
throw new Error('Cannot authenticate with fork; Open Authoring is turned off.');
|
||||
}
|
||||
const token = userData.token;
|
||||
|
||||
// Origin maintainers should be able to use the CMS normally. If alwaysFork
|
||||
// is enabled we always fork (and avoid the origin maintainer check)
|
||||
if (!this.alwaysForkEnabled && (await this.userIsOriginMaintainer({
|
||||
token
|
||||
}))) {
|
||||
this.repo = this.originRepo;
|
||||
this.useOpenAuthoring = false;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// If a fork exists merge it with upstream
|
||||
// otherwise create a new fork.
|
||||
const currentUser = await this.currentUser({
|
||||
token
|
||||
});
|
||||
const repoName = this.originRepo.split('/')[1];
|
||||
this.repo = `${currentUser.login}/${repoName}`;
|
||||
this.useOpenAuthoring = true;
|
||||
if (await this.forkExists({
|
||||
token
|
||||
})) {
|
||||
return fetch(`${this.apiRoot}/repos/${this.repo}/merge-upstream`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
branch: this.branch
|
||||
})
|
||||
});
|
||||
} else {
|
||||
await getPermissionToFork();
|
||||
const fork = await fetch(`${this.apiRoot}/repos/${this.originRepo}/forks`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `${this.tokenKeyword} ${token}`
|
||||
}
|
||||
}).then(res => res.json());
|
||||
return this.pollUntilForkExists({
|
||||
repo: fork.full_name,
|
||||
token
|
||||
});
|
||||
}
|
||||
}
|
||||
async authenticate(state) {
|
||||
this.token = state.token;
|
||||
// Query the default branch name when the `branch` property is missing
|
||||
// in the config file
|
||||
if (!this.isBranchConfigured) {
|
||||
const repoInfo = await fetch(`${this.apiRoot}/repos/${this.originRepo}`, {
|
||||
headers: {
|
||||
Authorization: `token ${this.token}`
|
||||
}
|
||||
}).then(res => res.json()).catch(() => null);
|
||||
if (repoInfo && repoInfo.default_branch) {
|
||||
this.branch = repoInfo.default_branch;
|
||||
}
|
||||
}
|
||||
const apiCtor = this.useGraphql ? _GraphQLAPI.default : _API.default;
|
||||
this.api = new apiCtor({
|
||||
token: this.token,
|
||||
tokenKeyword: this.tokenKeyword,
|
||||
branch: this.branch,
|
||||
repo: this.repo,
|
||||
originRepo: this.originRepo,
|
||||
apiRoot: this.apiRoot,
|
||||
squashMerges: this.squashMerges,
|
||||
cmsLabelPrefix: this.cmsLabelPrefix,
|
||||
useOpenAuthoring: this.useOpenAuthoring,
|
||||
initialWorkflowStatus: this.options.initialWorkflowStatus,
|
||||
baseUrl: this.baseUrl,
|
||||
getUser: this.currentUser
|
||||
});
|
||||
const user = await this.api.user();
|
||||
const isCollab = await this.api.hasWriteAccess().catch(error => {
|
||||
error.message = (0, _commonTags.stripIndent)`
|
||||
Repo "${this.repo}" not found.
|
||||
|
||||
Please ensure the repo information is spelled correctly.
|
||||
|
||||
If the repo is private, make sure you're logged into a GitHub account with access.
|
||||
|
||||
If your repo is under an organization, ensure the organization has granted access to Decap CMS.
|
||||
`;
|
||||
throw error;
|
||||
});
|
||||
|
||||
// Unauthorized user
|
||||
if (!isCollab && !this.bypassWriteAccessCheckForAppTokens) {
|
||||
throw new Error('Your GitHub user account does not have access to this repo.');
|
||||
}
|
||||
|
||||
// if (!this.isBranchConfigured) {
|
||||
// const defaultBranchName = await this.api.getDefaultBranchName()
|
||||
// if (defaultBranchName) {
|
||||
// this.branch = defaultBranchName;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Authorized user
|
||||
return _objectSpread(_objectSpread({}, user), {}, {
|
||||
token: state.token,
|
||||
useOpenAuthoring: this.useOpenAuthoring
|
||||
});
|
||||
}
|
||||
logout() {
|
||||
this.token = null;
|
||||
if (this.api && this.api.reset && typeof this.api.reset === 'function') {
|
||||
return this.api.reset();
|
||||
}
|
||||
}
|
||||
getToken() {
|
||||
return Promise.resolve(this.token);
|
||||
}
|
||||
async entriesByFolder(folder, extension, depth) {
|
||||
const repoURL = this.api.originRepoURL;
|
||||
let cursor;
|
||||
const listFiles = () => this.api.listFiles(folder, {
|
||||
repoURL,
|
||||
depth
|
||||
}).then(files => {
|
||||
const filtered = files.filter(file => (0, _decapCmsLibUtil.filterByExtension)(file, extension));
|
||||
const result = this.getCursorAndFiles(filtered, 1);
|
||||
cursor = result.cursor;
|
||||
return result.files;
|
||||
});
|
||||
const readFile = (path, id) => this.api.readFile(path, id, {
|
||||
repoURL
|
||||
});
|
||||
const files = await (0, _decapCmsLibUtil.entriesByFolder)(listFiles, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
files[_decapCmsLibUtil.CURSOR_COMPATIBILITY_SYMBOL] = cursor;
|
||||
return files;
|
||||
}
|
||||
async allEntriesByFolder(folder, extension, depth, pathRegex) {
|
||||
const repoURL = this.api.originRepoURL;
|
||||
const listFiles = () => this.api.listFiles(folder, {
|
||||
repoURL,
|
||||
depth
|
||||
}).then(files => files.filter(file => (!pathRegex || pathRegex.test(file.path)) && (0, _decapCmsLibUtil.filterByExtension)(file, extension)));
|
||||
const readFile = (path, id) => {
|
||||
return this.api.readFile(path, id, {
|
||||
repoURL
|
||||
});
|
||||
};
|
||||
const files = await (0, _decapCmsLibUtil.entriesByFolder)(listFiles, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
|
||||
return files;
|
||||
}
|
||||
entriesByFiles(files) {
|
||||
const repoURL = this.useOpenAuthoring ? this.api.originRepoURL : this.api.repoURL;
|
||||
const readFile = (path, id) => this.api.readFile(path, id, {
|
||||
repoURL
|
||||
}).catch(() => '');
|
||||
return (0, _decapCmsLibUtil.entriesByFiles)(files, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
|
||||
}
|
||||
|
||||
// Fetches a single entry.
|
||||
getEntry(path) {
|
||||
const repoURL = this.api.originRepoURL;
|
||||
return this.api.readFile(path, null, {
|
||||
repoURL
|
||||
}).then(data => ({
|
||||
file: {
|
||||
path,
|
||||
id: null
|
||||
},
|
||||
data: data
|
||||
})).catch(() => ({
|
||||
file: {
|
||||
path,
|
||||
id: null
|
||||
},
|
||||
data: ''
|
||||
}));
|
||||
}
|
||||
getMedia(mediaFolder = this.mediaFolder) {
|
||||
return this.api.listFiles(mediaFolder).then(files => files.map(({
|
||||
id,
|
||||
name,
|
||||
size,
|
||||
path
|
||||
}) => {
|
||||
// load media using getMediaDisplayURL to avoid token expiration with GitHub raw content urls
|
||||
// for private repositories
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
size,
|
||||
displayURL: {
|
||||
id,
|
||||
path
|
||||
},
|
||||
path
|
||||
};
|
||||
}));
|
||||
}
|
||||
async getMediaFile(path) {
|
||||
const blob = await (0, _decapCmsLibUtil.getMediaAsBlob)(path, null, this.api.readFile.bind(this.api));
|
||||
const name = (0, _decapCmsLibUtil.basename)(path);
|
||||
const fileObj = (0, _decapCmsLibUtil.blobToFileObj)(name, blob);
|
||||
const url = URL.createObjectURL(fileObj);
|
||||
const id = await (0, _decapCmsLibUtil.getBlobSHA)(blob);
|
||||
return {
|
||||
id,
|
||||
displayURL: url,
|
||||
path,
|
||||
name,
|
||||
size: fileObj.size,
|
||||
file: fileObj,
|
||||
url
|
||||
};
|
||||
}
|
||||
getMediaDisplayURL(displayURL) {
|
||||
this._mediaDisplayURLSem = this._mediaDisplayURLSem || (0, _semaphore.default)(MAX_CONCURRENT_DOWNLOADS);
|
||||
return (0, _decapCmsLibUtil.getMediaDisplayURL)(displayURL, this.api.readFile.bind(this.api), this._mediaDisplayURLSem);
|
||||
}
|
||||
persistEntry(entry, options) {
|
||||
// persistEntry is a transactional operation
|
||||
return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.persistFiles(entry.dataFiles, entry.assets, options), 'Failed to acquire persist entry lock');
|
||||
}
|
||||
async persistMedia(mediaFile, options) {
|
||||
try {
|
||||
await this.api.persistFiles([], [mediaFile], options);
|
||||
const {
|
||||
sha,
|
||||
path,
|
||||
fileObj
|
||||
} = mediaFile;
|
||||
const displayURL = fileObj ? URL.createObjectURL(fileObj) : '';
|
||||
return {
|
||||
id: sha,
|
||||
name: fileObj.name,
|
||||
size: fileObj.size,
|
||||
displayURL,
|
||||
path: (0, _trimStart.default)(path, '/')
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
deleteFiles(paths, commitMessage) {
|
||||
return this.api.deleteFiles(paths, commitMessage);
|
||||
}
|
||||
async traverseCursor(cursor, action) {
|
||||
const meta = cursor.meta;
|
||||
const files = cursor.data.get('files').toJS();
|
||||
let result;
|
||||
switch (action) {
|
||||
case 'first':
|
||||
{
|
||||
result = this.getCursorAndFiles(files, 1);
|
||||
break;
|
||||
}
|
||||
case 'last':
|
||||
{
|
||||
result = this.getCursorAndFiles(files, meta.get('pageCount'));
|
||||
break;
|
||||
}
|
||||
case 'next':
|
||||
{
|
||||
result = this.getCursorAndFiles(files, meta.get('page') + 1);
|
||||
break;
|
||||
}
|
||||
case 'prev':
|
||||
{
|
||||
result = this.getCursorAndFiles(files, meta.get('page') - 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
result = this.getCursorAndFiles(files, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const readFile = (path, id) => this.api.readFile(path, id, {
|
||||
repoURL: this.api.originRepoURL
|
||||
}).catch(() => '');
|
||||
const entries = await (0, _decapCmsLibUtil.entriesByFiles)(result.files, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
|
||||
return {
|
||||
entries,
|
||||
cursor: result.cursor
|
||||
};
|
||||
}
|
||||
async loadMediaFile(branch, file) {
|
||||
const readFile = (path, id, {
|
||||
parseText
|
||||
}) => this.api.readFile(path, id, {
|
||||
branch,
|
||||
parseText
|
||||
});
|
||||
const blob = await (0, _decapCmsLibUtil.getMediaAsBlob)(file.path, file.id, readFile);
|
||||
const name = (0, _decapCmsLibUtil.basename)(file.path);
|
||||
const fileObj = (0, _decapCmsLibUtil.blobToFileObj)(name, blob);
|
||||
return {
|
||||
id: file.id,
|
||||
displayURL: URL.createObjectURL(fileObj),
|
||||
path: file.path,
|
||||
name,
|
||||
size: fileObj.size,
|
||||
file: fileObj
|
||||
};
|
||||
}
|
||||
async unpublishedEntries() {
|
||||
const listEntriesKeys = () => this.api.listUnpublishedBranches().then(branches => branches.map(branch => (0, _decapCmsLibUtil.contentKeyFromBranch)(branch)));
|
||||
const ids = await (0, _decapCmsLibUtil.unpublishedEntries)(listEntriesKeys);
|
||||
return ids;
|
||||
}
|
||||
async unpublishedEntry({
|
||||
id,
|
||||
collection,
|
||||
slug
|
||||
}) {
|
||||
if (id) {
|
||||
const data = await this.api.retrieveUnpublishedEntryData(id);
|
||||
return data;
|
||||
} else if (collection && slug) {
|
||||
const entryId = this.api.generateContentKey(collection, slug);
|
||||
const data = await this.api.retrieveUnpublishedEntryData(entryId);
|
||||
return data;
|
||||
} else {
|
||||
throw new Error('Missing unpublished entry id or collection and slug');
|
||||
}
|
||||
}
|
||||
getBranch(collection, slug) {
|
||||
const contentKey = this.api.generateContentKey(collection, slug);
|
||||
const branch = (0, _decapCmsLibUtil.branchFromContentKey)(contentKey);
|
||||
return branch;
|
||||
}
|
||||
async unpublishedEntryDataFile(collection, slug, path, id) {
|
||||
const branch = this.getBranch(collection, slug);
|
||||
const data = await this.api.readFile(path, id, {
|
||||
branch
|
||||
});
|
||||
return data;
|
||||
}
|
||||
async unpublishedEntryMediaFile(collection, slug, path, id) {
|
||||
const branch = this.getBranch(collection, slug);
|
||||
const mediaFile = await this.loadMediaFile(branch, {
|
||||
path,
|
||||
id
|
||||
});
|
||||
return mediaFile;
|
||||
}
|
||||
async getDeployPreview(collection, slug) {
|
||||
try {
|
||||
const statuses = await this.api.getStatuses(collection, slug);
|
||||
const deployStatus = (0, _decapCmsLibUtil.getPreviewStatus)(statuses, this.previewContext);
|
||||
if (deployStatus) {
|
||||
const {
|
||||
target_url: url,
|
||||
state
|
||||
} = deployStatus;
|
||||
return {
|
||||
url,
|
||||
status: state
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
updateUnpublishedEntryStatus(collection, slug, newStatus) {
|
||||
// updateUnpublishedEntryStatus is a transactional operation
|
||||
return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.updateUnpublishedEntryStatus(collection, slug, newStatus), 'Failed to acquire update entry status lock');
|
||||
}
|
||||
deleteUnpublishedEntry(collection, slug) {
|
||||
// deleteUnpublishedEntry is a transactional operation
|
||||
return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.deleteUnpublishedEntry(collection, slug), 'Failed to acquire delete entry lock');
|
||||
}
|
||||
publishUnpublishedEntry(collection, slug) {
|
||||
// publishUnpublishedEntry is a transactional operation
|
||||
return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.publishUnpublishedEntry(collection, slug), 'Failed to acquire publish entry lock');
|
||||
}
|
||||
}
|
||||
exports.default = GitHub;
|
||||
33
node_modules/decap-cms-backend-github/dist/esm/index.js
generated
vendored
Normal file
33
node_modules/decap-cms-backend-github/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "API", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _API.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "AuthenticationPage", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _AuthenticationPage.default;
|
||||
}
|
||||
});
|
||||
exports.DecapCmsBackendGithub = void 0;
|
||||
Object.defineProperty(exports, "GitHubBackend", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _implementation.default;
|
||||
}
|
||||
});
|
||||
var _implementation = _interopRequireDefault(require("./implementation"));
|
||||
var _API = _interopRequireDefault(require("./API"));
|
||||
var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
const DecapCmsBackendGithub = exports.DecapCmsBackendGithub = {
|
||||
GitHubBackend: _implementation.default,
|
||||
API: _API.default,
|
||||
AuthenticationPage: _AuthenticationPage.default
|
||||
};
|
||||
109
node_modules/decap-cms-backend-github/dist/esm/mutations.js
generated
vendored
Normal file
109
node_modules/decap-cms-backend-github/dist/esm/mutations.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.updateBranch = exports.reopenPullRequest = exports.deleteBranch = exports.createPullRequest = exports.createBranchAndPullRequest = exports.createBranch = exports.closePullRequestAndDeleteBranch = exports.closePullRequest = void 0;
|
||||
var _graphqlTag = require("graphql-tag");
|
||||
var fragments = _interopRequireWildcard(require("./fragments"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
// updateRef only works for branches at the moment
|
||||
const updateBranch = exports.updateBranch = (0, _graphqlTag.gql)`
|
||||
mutation updateRef($input: UpdateRefInput!) {
|
||||
updateRef(input: $input) {
|
||||
branch: ref {
|
||||
...BranchParts
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.branch}
|
||||
`;
|
||||
|
||||
// deleteRef only works for branches at the moment
|
||||
const deleteRefMutationPart = `
|
||||
deleteRef(input: $deleteRefInput) {
|
||||
clientMutationId
|
||||
}
|
||||
`;
|
||||
const deleteBranch = exports.deleteBranch = (0, _graphqlTag.gql)`
|
||||
mutation deleteRef($deleteRefInput: DeleteRefInput!) {
|
||||
${deleteRefMutationPart}
|
||||
}
|
||||
`;
|
||||
const closePullRequestMutationPart = `
|
||||
closePullRequest(input: $closePullRequestInput) {
|
||||
clientMutationId
|
||||
pullRequest {
|
||||
...PullRequestParts
|
||||
}
|
||||
}
|
||||
`;
|
||||
const closePullRequest = exports.closePullRequest = (0, _graphqlTag.gql)`
|
||||
mutation closePullRequestAndDeleteBranch($closePullRequestInput: ClosePullRequestInput!) {
|
||||
${closePullRequestMutationPart}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const closePullRequestAndDeleteBranch = exports.closePullRequestAndDeleteBranch = (0, _graphqlTag.gql)`
|
||||
mutation closePullRequestAndDeleteBranch(
|
||||
$closePullRequestInput: ClosePullRequestInput!
|
||||
$deleteRefInput: DeleteRefInput!
|
||||
) {
|
||||
${closePullRequestMutationPart}
|
||||
${deleteRefMutationPart}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const createPullRequestMutationPart = `
|
||||
createPullRequest(input: $createPullRequestInput) {
|
||||
clientMutationId
|
||||
pullRequest {
|
||||
...PullRequestParts
|
||||
}
|
||||
}
|
||||
`;
|
||||
const createPullRequest = exports.createPullRequest = (0, _graphqlTag.gql)`
|
||||
mutation createPullRequest($createPullRequestInput: CreatePullRequestInput!) {
|
||||
${createPullRequestMutationPart}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const createBranch = exports.createBranch = (0, _graphqlTag.gql)`
|
||||
mutation createBranch($createRefInput: CreateRefInput!) {
|
||||
createRef(input: $createRefInput) {
|
||||
branch: ref {
|
||||
...BranchParts
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.branch}
|
||||
`;
|
||||
|
||||
// createRef only works for branches at the moment
|
||||
const createBranchAndPullRequest = exports.createBranchAndPullRequest = (0, _graphqlTag.gql)`
|
||||
mutation createBranchAndPullRequest(
|
||||
$createRefInput: CreateRefInput!
|
||||
$createPullRequestInput: CreatePullRequestInput!
|
||||
) {
|
||||
createRef(input: $createRefInput) {
|
||||
branch: ref {
|
||||
...BranchParts
|
||||
}
|
||||
}
|
||||
${createPullRequestMutationPart}
|
||||
}
|
||||
${fragments.branch}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const reopenPullRequest = exports.reopenPullRequest = (0, _graphqlTag.gql)`
|
||||
mutation reopenPullRequest($reopenPullRequestInput: ReopenPullRequestInput!) {
|
||||
reopenPullRequest(input: $reopenPullRequestInput) {
|
||||
clientMutationId
|
||||
pullRequest {
|
||||
...PullRequestParts
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
201
node_modules/decap-cms-backend-github/dist/esm/queries.js
generated
vendored
Normal file
201
node_modules/decap-cms-backend-github/dist/esm/queries.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.fileSha = exports.branch = exports.blob = void 0;
|
||||
exports.files = files;
|
||||
exports.user = exports.statues = exports.repository = exports.repoPermission = exports.pullRequests = exports.pullRequestAndBranch = exports.pullRequest = exports.openAuthoringBranches = void 0;
|
||||
var _graphqlTag = require("graphql-tag");
|
||||
var _commonTags = require("common-tags");
|
||||
var fragments = _interopRequireWildcard(require("./fragments"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
const repoPermission = exports.repoPermission = (0, _graphqlTag.gql)`
|
||||
query repoPermission($owner: String!, $name: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
viewerPermission
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
`;
|
||||
const user = exports.user = (0, _graphqlTag.gql)`
|
||||
query {
|
||||
viewer {
|
||||
id
|
||||
avatar_url: avatarUrl
|
||||
name
|
||||
login
|
||||
}
|
||||
}
|
||||
`;
|
||||
const blob = exports.blob = (0, _graphqlTag.gql)`
|
||||
query blob($owner: String!, $name: String!, $expression: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
object(expression: $expression) {
|
||||
... on Blob {
|
||||
...BlobWithTextParts
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.blobWithText}
|
||||
`;
|
||||
const statues = exports.statues = (0, _graphqlTag.gql)`
|
||||
query statues($owner: String!, $name: String!, $sha: GitObjectID!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
object(oid: $sha) {
|
||||
...ObjectParts
|
||||
... on Commit {
|
||||
status {
|
||||
id
|
||||
contexts {
|
||||
id
|
||||
context
|
||||
state
|
||||
target_url: targetUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.object}
|
||||
`;
|
||||
function buildFilesQuery(depth = 1) {
|
||||
const PLACE_HOLDER = 'PLACE_HOLDER';
|
||||
let query = (0, _commonTags.oneLine)`
|
||||
...ObjectParts
|
||||
... on Tree {
|
||||
entries {
|
||||
...FileEntryParts
|
||||
${PLACE_HOLDER}
|
||||
}
|
||||
}
|
||||
`;
|
||||
for (let i = 0; i < depth - 1; i++) {
|
||||
query = query.replace(PLACE_HOLDER, (0, _commonTags.oneLine)`
|
||||
object {
|
||||
... on Tree {
|
||||
entries {
|
||||
...FileEntryParts
|
||||
${PLACE_HOLDER}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
}
|
||||
query = query.replace(PLACE_HOLDER, '');
|
||||
return query;
|
||||
}
|
||||
function files(depth) {
|
||||
return (0, _graphqlTag.gql)`
|
||||
query files($owner: String!, $name: String!, $expression: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
object(expression: $expression) {
|
||||
${buildFilesQuery(depth)}
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.object}
|
||||
${fragments.fileEntry}
|
||||
`;
|
||||
}
|
||||
const branchQueryPart = `
|
||||
branch: ref(qualifiedName: $qualifiedName) {
|
||||
...BranchParts
|
||||
}
|
||||
`;
|
||||
const branch = exports.branch = (0, _graphqlTag.gql)`
|
||||
query branch($owner: String!, $name: String!, $qualifiedName: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
${branchQueryPart}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.branch}
|
||||
`;
|
||||
const openAuthoringBranches = exports.openAuthoringBranches = (0, _graphqlTag.gql)`
|
||||
query openAuthoringBranches($owner: String!, $name: String!, $refPrefix: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
refs(refPrefix: $refPrefix, last: 100) {
|
||||
nodes {
|
||||
...BranchParts
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.branch}
|
||||
`;
|
||||
const repository = exports.repository = (0, _graphqlTag.gql)`
|
||||
query repository($owner: String!, $name: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
`;
|
||||
const pullRequestQueryPart = `
|
||||
pullRequest(number: $number) {
|
||||
...PullRequestParts
|
||||
}
|
||||
`;
|
||||
const pullRequest = exports.pullRequest = (0, _graphqlTag.gql)`
|
||||
query pullRequest($owner: String!, $name: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
id
|
||||
${pullRequestQueryPart}
|
||||
}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const pullRequests = exports.pullRequests = (0, _graphqlTag.gql)`
|
||||
query pullRequests($owner: String!, $name: String!, $head: String, $states: [PullRequestState!]) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
id
|
||||
pullRequests(last: 100, headRefName: $head, states: $states) {
|
||||
nodes {
|
||||
...PullRequestParts
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const pullRequestAndBranch = exports.pullRequestAndBranch = (0, _graphqlTag.gql)`
|
||||
query pullRequestAndBranch($owner: String!, $name: String!, $originRepoOwner: String!, $originRepoName: String!, $qualifiedName: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
${branchQueryPart}
|
||||
}
|
||||
origin: repository(owner: $originRepoOwner, name: $originRepoName) {
|
||||
...RepositoryParts
|
||||
${pullRequestQueryPart}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.branch}
|
||||
${fragments.pullRequest}
|
||||
`;
|
||||
const fileSha = exports.fileSha = (0, _graphqlTag.gql)`
|
||||
query fileSha($owner: String!, $name: String!, $expression: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
...RepositoryParts
|
||||
file: object(expression: $expression) {
|
||||
...ObjectParts
|
||||
}
|
||||
}
|
||||
}
|
||||
${fragments.repository}
|
||||
${fragments.object}
|
||||
`;
|
||||
1
node_modules/decap-cms-backend-github/dist/esm/types/semaphore.d.js
generated
vendored
Normal file
1
node_modules/decap-cms-backend-github/dist/esm/types/semaphore.d.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";
|
||||
Reference in New Issue
Block a user