Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/refactor to files #2

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 5 additions & 30 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as vscode from 'vscode';
import { Octokit } from "@octokit/core";
import { GitExtension } from '../git';
import { Credentials } from './credentials';
import getWebviewOptions from './utils/getWebViewOptions';
import getNonce from './utils/getNonce';

//@ts-ignore
//console.log(git?.getRepository(vscode.Uri.file(vscode.workspace?.workspaceFolders[0].uri.path)))
Expand Down Expand Up @@ -54,16 +56,6 @@ export async function activate(context: vscode.ExtensionContext) {

}

function getWebviewOptions(extensionUri: vscode.Uri): vscode.WebviewOptions {
return {
// Enable javascript in the webview
enableScripts: true,

// And restrict the webview to only loading content from our extension's `media` directory.
localResourceRoots: [vscode.Uri.joinPath(extensionUri, 'media')]
};
}

/**
* Manages cat coding webview panels
*/
Expand Down Expand Up @@ -262,27 +254,10 @@ class watermelonPanel {
}
}

function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}

const gitExtension = vscode.extensions.getExtension<GitExtension>('vscode.git')
let git
console.log("gitEXTPRE", gitExtension?.isActive)
gitExtension?.activate()
console.log("gitEXT", gitExtension?.isActive)
let git;
gitExtension?.activate();

if (gitExtension?.isActive) {
git = gitExtension?.exports?.getAPI(1)
console.log("ACTIVEgit", git)
git = gitExtension?.exports?.getAPI(1);
};
while (!gitExtension?.isActive) {
console.log("gitEXT", gitExtension?.isActive)

}
console.log("git", git)
8 changes: 8 additions & 0 deletions src/utils/getNonce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
11 changes: 11 additions & 0 deletions src/utils/getWebViewOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as vscode from 'vscode';

export default function getWebviewOptions(extensionUri: vscode.Uri): vscode.WebviewOptions {
return {
// Enable javascript in the webview
enableScripts: true,

// And restrict the webview to only loading content from our extension's `media` directory.
localResourceRoots: [vscode.Uri.joinPath(extensionUri, 'media')]
};
}