mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Update prettier to latest. Remove tslint (#1641)
* Rev up prettier * Reformat * Remove deprecated tslint * Remove call to tslint and update package-lock.json
This commit is contained in:
@@ -278,7 +278,7 @@ export class GitHubClient {
|
||||
owner: string,
|
||||
repo: string,
|
||||
pageSize: number,
|
||||
endCursor?: string
|
||||
endCursor?: string,
|
||||
): Promise<IGitHubResponse<IGitHubBranch[]>> {
|
||||
try {
|
||||
const response = (await this.ocktokit.graphql(branchesQuery, {
|
||||
@@ -307,7 +307,7 @@ export class GitHubClient {
|
||||
owner: string,
|
||||
repo: string,
|
||||
branch: string,
|
||||
path?: string
|
||||
path?: string,
|
||||
): Promise<IGitHubResponse<IGitHubFile | IGitHubFile[]>> {
|
||||
try {
|
||||
const response = (await this.ocktokit.graphql(contentsQuery, {
|
||||
@@ -338,8 +338,8 @@ export class GitHubClient {
|
||||
(path && UrlUtility.createUri(path, entry.name)) || entry.name,
|
||||
gitHubRepo,
|
||||
gitHubBranch,
|
||||
gitHubCommit
|
||||
)
|
||||
gitHubCommit,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
data = GitHubClient.toGitHubFile(
|
||||
@@ -351,7 +351,7 @@ export class GitHubClient {
|
||||
path,
|
||||
gitHubRepo,
|
||||
gitHubBranch,
|
||||
gitHubCommit
|
||||
gitHubCommit,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ export class GitHubClient {
|
||||
path: string,
|
||||
message: string,
|
||||
content: string,
|
||||
sha?: string
|
||||
sha?: string,
|
||||
): Promise<IGitHubResponse<IGitHubCommit>> {
|
||||
const response = await this.ocktokit.repos.createOrUpdateFile({
|
||||
owner,
|
||||
@@ -401,7 +401,7 @@ export class GitHubClient {
|
||||
branch: string,
|
||||
message: string,
|
||||
oldPath: string,
|
||||
newPath: string
|
||||
newPath: string,
|
||||
): Promise<IGitHubResponse<IGitHubCommit>> {
|
||||
const ref = `heads/${branch}`;
|
||||
const currentRef = await this.ocktokit.git.getRef({
|
||||
@@ -562,7 +562,7 @@ export class GitHubClient {
|
||||
path: string,
|
||||
repo: IGitHubRepo,
|
||||
branch: IGitHubBranch,
|
||||
commit: IGitHubCommit
|
||||
commit: IGitHubCommit,
|
||||
): IGitHubFile {
|
||||
if (entry.type !== "blob" && entry.type !== "tree") {
|
||||
throw new Error(`Unsupported file type: ${entry.type}`);
|
||||
|
||||
@@ -20,7 +20,7 @@ window.addEventListener("load", async () => {
|
||||
} as IGitHubConnectorParams,
|
||||
{
|
||||
domain: window.location.origin,
|
||||
}
|
||||
},
|
||||
);
|
||||
window.close();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ const sampleGitHubUri = GitHubUtils.toContentUri(
|
||||
sampleFile.repo.owner,
|
||||
sampleFile.repo.name,
|
||||
sampleFile.branch.name,
|
||||
sampleFile.path
|
||||
sampleFile.path,
|
||||
);
|
||||
const sampleNotebookModel: IContent<"notebook"> = {
|
||||
name: sampleFile.name,
|
||||
@@ -73,7 +73,7 @@ describe("GitHubContentProvider remove", () => {
|
||||
|
||||
it("errors on failed delete", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "deleteFileAsync").and.returnValue(Promise.resolve({ status: 888 }));
|
||||
|
||||
@@ -86,10 +86,10 @@ describe("GitHubContentProvider remove", () => {
|
||||
|
||||
it("removes notebook", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "deleteFileAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }),
|
||||
);
|
||||
|
||||
const response = await gitHubContentProvider.remove(undefined, sampleGitHubUri).toPromise();
|
||||
@@ -121,7 +121,7 @@ describe("GitHubContentProvider get", () => {
|
||||
|
||||
it("reads notebook", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
|
||||
const response = await gitHubContentProvider.get(undefined, sampleGitHubUri, {}).toPromise();
|
||||
@@ -153,7 +153,7 @@ describe("GitHubContentProvider update", () => {
|
||||
|
||||
it("errors on failed rename", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "renameFileAsync").and.returnValue(Promise.resolve({ status: 888 }));
|
||||
|
||||
@@ -166,10 +166,10 @@ describe("GitHubContentProvider update", () => {
|
||||
|
||||
it("updates notebook", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "renameFileAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }),
|
||||
);
|
||||
|
||||
const response = await gitHubContentProvider.update(undefined, sampleGitHubUri, sampleNotebookModel).toPromise();
|
||||
@@ -205,7 +205,7 @@ describe("GitHubContentProvider create", () => {
|
||||
|
||||
it("creates notebook", async () => {
|
||||
spyOn(GitHubClient.prototype, "createOrUpdateFileAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.Created, data: gitHubCommit })
|
||||
Promise.resolve({ status: HttpStatusCodes.Created, data: gitHubCommit }),
|
||||
);
|
||||
|
||||
const response = await gitHubContentProvider.create(undefined, sampleGitHubUri, sampleNotebookModel).toPromise();
|
||||
@@ -240,7 +240,7 @@ describe("GitHubContentProvider save", () => {
|
||||
|
||||
it("errors on failed update", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "createOrUpdateFileAsync").and.returnValue(Promise.resolve({ status: 888 }));
|
||||
|
||||
@@ -253,10 +253,10 @@ describe("GitHubContentProvider save", () => {
|
||||
|
||||
it("saves notebook", async () => {
|
||||
spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }),
|
||||
);
|
||||
spyOn(GitHubClient.prototype, "createOrUpdateFileAsync").and.returnValue(
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit })
|
||||
Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }),
|
||||
);
|
||||
|
||||
const response = await gitHubContentProvider.save(undefined, sampleGitHubUri, sampleNotebookModel).toPromise();
|
||||
|
||||
@@ -17,7 +17,10 @@ export interface GitHubContentProviderParams {
|
||||
}
|
||||
|
||||
class GitHubContentProviderError extends Error {
|
||||
constructor(error: string, public errno: number = GitHubContentProvider.SelfErrorCode) {
|
||||
constructor(
|
||||
error: string,
|
||||
public errno: number = GitHubContentProvider.SelfErrorCode,
|
||||
) {
|
||||
super(error);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +47,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
Logger.logError(getErrorMessage(error), "GitHubContentProvider/remove", error.errno);
|
||||
return this.createErrorAjaxResponse(error);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,14 +71,14 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
Logger.logError(getErrorMessage(error), "GitHubContentProvider/get", error.errno);
|
||||
return this.createErrorAjaxResponse(error);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public update<FT extends FileType>(
|
||||
_: ServerConfig,
|
||||
uri: string,
|
||||
model: Partial<IContent<FT>>
|
||||
model: Partial<IContent<FT>>,
|
||||
): Observable<AjaxResponse> {
|
||||
return from(
|
||||
this.getContent(uri).then(async (content: IGitHubResponse<IGitHubFile | IGitHubFile[]>) => {
|
||||
@@ -90,7 +93,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
gitHubFile.branch.name,
|
||||
commitMsg,
|
||||
gitHubFile.path,
|
||||
newPath
|
||||
newPath,
|
||||
);
|
||||
if (response.status !== HttpStatusCodes.OK) {
|
||||
throw new GitHubContentProviderError("Failed to rename", response.status);
|
||||
@@ -102,20 +105,20 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
|
||||
return this.createSuccessAjaxResponse(
|
||||
HttpStatusCodes.OK,
|
||||
this.createContentModel(newUri, gitHubFile, { content: 0 })
|
||||
this.createContentModel(newUri, gitHubFile, { content: 0 }),
|
||||
);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "GitHubContentProvider/update", error.errno);
|
||||
return this.createErrorAjaxResponse(error);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public create<FT extends FileType>(
|
||||
_: ServerConfig,
|
||||
uri: string,
|
||||
model: Partial<IContent<FT>> & { type: FT }
|
||||
model: Partial<IContent<FT>> & { type: FT },
|
||||
): Observable<AjaxResponse> {
|
||||
return from(
|
||||
this.params.promptForCommitMsg("Create New Notebook", "Create").then(async (commitMsg: string) => {
|
||||
@@ -155,7 +158,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
contentInfo.branch,
|
||||
path,
|
||||
commitMsg,
|
||||
content
|
||||
content,
|
||||
);
|
||||
if (response.status !== HttpStatusCodes.Created) {
|
||||
throw new GitHubContentProviderError("Failed to create", response.status);
|
||||
@@ -179,20 +182,20 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
|
||||
return this.createSuccessAjaxResponse(
|
||||
HttpStatusCodes.Created,
|
||||
this.createContentModel(newUri, newGitHubFile, { content: 0 })
|
||||
this.createContentModel(newUri, newGitHubFile, { content: 0 }),
|
||||
);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "GitHubContentProvider/create", error.errno);
|
||||
return this.createErrorAjaxResponse(error);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public save<FT extends FileType>(
|
||||
_: ServerConfig,
|
||||
uri: string,
|
||||
model: Partial<IContent<FT>>
|
||||
model: Partial<IContent<FT>>,
|
||||
): Observable<AjaxResponse> {
|
||||
return from(
|
||||
this.getContent(uri).then(async (content: IGitHubResponse<IGitHubFile | IGitHubFile[]>) => {
|
||||
@@ -233,7 +236,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
contentInfo.path,
|
||||
commitMsg,
|
||||
updatedContent,
|
||||
gitHubFile?.sha
|
||||
gitHubFile?.sha,
|
||||
);
|
||||
if (response.status !== HttpStatusCodes.OK && response.status !== HttpStatusCodes.Created) {
|
||||
throw new GitHubContentProviderError("Failed to create or update", response.status);
|
||||
@@ -246,7 +249,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
contentInfo.owner,
|
||||
contentInfo.repo,
|
||||
contentInfo.branch,
|
||||
contentInfo.path
|
||||
contentInfo.path,
|
||||
);
|
||||
if (contentResponse.status !== HttpStatusCodes.OK) {
|
||||
throw new GitHubContentProviderError("Failed to get content", response.status);
|
||||
@@ -257,13 +260,13 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
|
||||
return this.createSuccessAjaxResponse(
|
||||
HttpStatusCodes.OK,
|
||||
this.createContentModel(uri, gitHubFile, { content: 0 })
|
||||
this.createContentModel(uri, gitHubFile, { content: 0 }),
|
||||
);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "GitHubContentProvider/update", error.errno);
|
||||
return this.createErrorAjaxResponse(error);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -294,7 +297,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
private async validateContentAndGetCommitMsg(
|
||||
content: IGitHubResponse<IGitHubFile | IGitHubFile[]>,
|
||||
promptTitle: string,
|
||||
promptPrimaryButtonLabel: string
|
||||
promptPrimaryButtonLabel: string,
|
||||
): Promise<string> {
|
||||
if (content.status !== HttpStatusCodes.OK) {
|
||||
throw new GitHubContentProviderError("Failed to get content", content.status);
|
||||
@@ -325,7 +328,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
private createContentModel(
|
||||
uri: string,
|
||||
content: IGitHubFile | IGitHubFile[],
|
||||
params: Partial<IGetParams>
|
||||
params: Partial<IGetParams>,
|
||||
): IContent<FileType> {
|
||||
if (Array.isArray(content)) {
|
||||
return this.createDirectoryModel(uri, content);
|
||||
@@ -358,8 +361,8 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
file,
|
||||
{
|
||||
content: 0,
|
||||
}
|
||||
) as IEmptyContent<FileType>
|
||||
},
|
||||
) as IEmptyContent<FileType>,
|
||||
),
|
||||
format: "json",
|
||||
};
|
||||
@@ -373,7 +376,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
gitHubFile.repo.owner,
|
||||
gitHubFile.repo.name,
|
||||
gitHubFile.branch.name,
|
||||
gitHubFile.path
|
||||
gitHubFile.path,
|
||||
),
|
||||
type: "notebook",
|
||||
writable: true, // TODO: tamitta: we don't know this info here
|
||||
@@ -393,7 +396,7 @@ export class GitHubContentProvider implements IContentProvider {
|
||||
gitHubFile.repo.owner,
|
||||
gitHubFile.repo.name,
|
||||
gitHubFile.branch.name,
|
||||
gitHubFile.path
|
||||
gitHubFile.path,
|
||||
),
|
||||
type: "file",
|
||||
writable: true, // TODO: tamitta: we don't know this info here
|
||||
|
||||
@@ -18,7 +18,7 @@ postRobot.on(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const params = (event as any).data as IGitHubConnectorParams;
|
||||
window.dataExplorer.notebookManager?.gitHubOAuthService.finishOAuth(params);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export interface IGitHubOAuthToken {
|
||||
|
||||
Reference in New Issue
Block a user