refactor: introduce type-only imports (#5462)
This commit is contained in:
committed by
GitHub
parent
e4a29d5991
commit
fc07ce6854
@ -1,4 +1,11 @@
|
||||
import { flow, get } from 'lodash';
|
||||
import type {
|
||||
ApiRequest,
|
||||
AssetProxy,
|
||||
PersistOptions,
|
||||
FetchError,
|
||||
DataFile,
|
||||
} from 'netlify-cms-lib-util';
|
||||
import {
|
||||
localForage,
|
||||
unsentRequest,
|
||||
@ -7,9 +14,6 @@ import {
|
||||
basename,
|
||||
Cursor,
|
||||
APIError,
|
||||
ApiRequest,
|
||||
AssetProxy,
|
||||
PersistOptions,
|
||||
readFile,
|
||||
CMS_BRANCH_PREFIX,
|
||||
generateContentKey,
|
||||
@ -20,13 +24,11 @@ import {
|
||||
DEFAULT_PR_BODY,
|
||||
MERGE_COMMIT_MESSAGE,
|
||||
PreviewState,
|
||||
FetchError,
|
||||
parseContentKey,
|
||||
branchFromContentKey,
|
||||
requestWithBackoff,
|
||||
readFileMetadata,
|
||||
throwOnConflictingBranches,
|
||||
DataFile,
|
||||
} from 'netlify-cms-lib-util';
|
||||
import { dirname } from 'path';
|
||||
import { oneLine } from 'common-tags';
|
||||
@ -373,7 +375,6 @@ export default class API {
|
||||
const result: BitBucketSrcResult = await this.requestJSON({
|
||||
url: `${this.repoURL}/src/${node}/${path}`,
|
||||
params: {
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
max_depth: depth,
|
||||
pagelen,
|
||||
},
|
||||
@ -553,7 +554,6 @@ export default class API {
|
||||
},
|
||||
},
|
||||
description: DEFAULT_PR_BODY,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
close_source_branch: true,
|
||||
}),
|
||||
});
|
||||
@ -653,8 +653,8 @@ export default class API {
|
||||
params: {
|
||||
pagelen: 50,
|
||||
q: oneLine`
|
||||
source.repository.full_name = "${this.repo}"
|
||||
AND state = "${BitBucketPullRequestState.OPEN}"
|
||||
source.repository.full_name = "${this.repo}"
|
||||
AND state = "${BitBucketPullRequestState.OPEN}"
|
||||
AND destination.branch.name = "${this.branch}"
|
||||
AND comment_count > 0
|
||||
AND ${sourceQuery}
|
||||
@ -725,9 +725,7 @@ export default class API {
|
||||
headers: { 'Content-Type': APPLICATION_JSON },
|
||||
body: JSON.stringify({
|
||||
message: MERGE_COMMIT_MESSAGE,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
close_source_branch: true,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
merge_strategy: this.mergeStrategy,
|
||||
}),
|
||||
});
|
||||
@ -787,7 +785,6 @@ export default class API {
|
||||
state === BitBucketPullRequestStatusState.Successful
|
||||
? PreviewState.Success
|
||||
: PreviewState.Other,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
target_url: url,
|
||||
}));
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import minimatch from 'minimatch';
|
||||
import { ApiRequest, PointerFile, unsentRequest } from 'netlify-cms-lib-util';
|
||||
import type { ApiRequest, PointerFile } from 'netlify-cms-lib-util';
|
||||
import { unsentRequest } from 'netlify-cms-lib-util';
|
||||
|
||||
type MakeAuthorizedRequest = (req: ApiRequest) => Promise<Response>;
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
import semaphore, { Semaphore } from 'semaphore';
|
||||
import type { Semaphore } from 'semaphore';
|
||||
import semaphore from 'semaphore';
|
||||
import { trimStart } from 'lodash';
|
||||
import { stripIndent } from 'common-tags';
|
||||
import {
|
||||
CURSOR_COMPATIBILITY_SYMBOL,
|
||||
filterByExtension,
|
||||
unsentRequest,
|
||||
basename,
|
||||
getBlobSHA,
|
||||
import type {
|
||||
Entry,
|
||||
ApiRequest,
|
||||
Cursor,
|
||||
@ -14,23 +10,30 @@ import {
|
||||
PersistOptions,
|
||||
DisplayURL,
|
||||
Implementation,
|
||||
entriesByFolder,
|
||||
entriesByFiles,
|
||||
User,
|
||||
Credentials,
|
||||
getMediaDisplayURL,
|
||||
getMediaAsBlob,
|
||||
Config,
|
||||
ImplementationFile,
|
||||
AsyncLock,
|
||||
FetchError,
|
||||
} from 'netlify-cms-lib-util';
|
||||
import {
|
||||
CURSOR_COMPATIBILITY_SYMBOL,
|
||||
filterByExtension,
|
||||
unsentRequest,
|
||||
basename,
|
||||
getBlobSHA,
|
||||
entriesByFolder,
|
||||
entriesByFiles,
|
||||
getMediaDisplayURL,
|
||||
getMediaAsBlob,
|
||||
unpublishedEntries,
|
||||
runWithLock,
|
||||
AsyncLock,
|
||||
asyncLock,
|
||||
getPreviewStatus,
|
||||
getLargeMediaPatternsFromGitAttributesFile,
|
||||
getPointerFileForMediaFileObj,
|
||||
getLargeMediaFilteredMediaFiles,
|
||||
FetchError,
|
||||
blobToFileObj,
|
||||
contentKeyFromBranch,
|
||||
generateContentKey,
|
||||
@ -220,9 +223,7 @@ export default class BitbucketBackend implements Implementation {
|
||||
name: user.display_name,
|
||||
login: user.username,
|
||||
token: state.token,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
avatar_url: user.links.avatar.href,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
refresh_token: state.refresh_token,
|
||||
};
|
||||
}
|
||||
@ -238,27 +239,23 @@ export default class BitbucketBackend implements Implementation {
|
||||
// instantiating a new Authenticator on each refresh isn't ideal,
|
||||
if (!this.authenticator) {
|
||||
const cfg = {
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
base_url: this.baseUrl,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
site_id: this.siteId,
|
||||
};
|
||||
this.authenticator = new NetlifyAuthenticator(cfg);
|
||||
}
|
||||
|
||||
this.refreshedTokenPromise = this.authenticator! // eslint-disable-next-line @typescript-eslint/camelcase
|
||||
.refresh({ provider: 'bitbucket', refresh_token: this.refreshToken as string })
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
.then(({ token, refresh_token }) => {
|
||||
this.token = token;
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
this.refreshToken = refresh_token;
|
||||
this.refreshedTokenPromise = undefined;
|
||||
this.refreshedTokenPromise = this.authenticator!.refresh({
|
||||
provider: 'bitbucket',
|
||||
refresh_token: this.refreshToken as string,
|
||||
}).then(({ token, refresh_token }) => {
|
||||
this.token = token;
|
||||
this.refreshToken = refresh_token;
|
||||
this.refreshedTokenPromise = undefined;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
this.updateUserCredentials({ token, refresh_token });
|
||||
return token;
|
||||
});
|
||||
this.updateUserCredentials({ token, refresh_token });
|
||||
return token;
|
||||
});
|
||||
|
||||
return this.refreshedTokenPromise;
|
||||
}
|
||||
@ -320,7 +317,7 @@ export default class BitbucketBackend implements Implementation {
|
||||
API_NAME,
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
files[CURSOR_COMPATIBILITY_SYMBOL] = cursor;
|
||||
return files;
|
||||
|
Reference in New Issue
Block a user