refactor: Update Copilot configuration for local development

This commit is contained in:
Simon Larsen
2024-07-08 14:05:09 +01:00
parent 74c2de8adc
commit 6eef29e4a3
6 changed files with 45 additions and 9 deletions

2
.vscode/launch.json vendored
View File

@@ -149,7 +149,7 @@
},
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/Realtime",
"localRoot": "${workspaceFolder}/Copilot",
"name": "Copilot: Debug with Docker",
"port": 9985,
"remoteRoot": "/usr/src/app",

View File

@@ -235,6 +235,32 @@ export default class CodeRepositoryUtil {
return hash;
}
public static async listFilesInDirectory(data: {
directoryPath: string;
repoPath: string;
}): Promise<Array<string>> {
if (!data.directoryPath.startsWith("/")) {
data.directoryPath = "/" + data.directoryPath;
}
if (!data.repoPath.startsWith("/")) {
data.repoPath = "/" + data.repoPath;
}
const { directoryPath, repoPath } = data;
let totalPath: string = `${repoPath}/${directoryPath}`;
totalPath = LocalFile.sanitizeFilePath(totalPath); // clean up the path
const output: string = await Execute.executeCommand(`ls ${totalPath}`);
const fileNames: Array<string> = output.split("\n");
return fileNames;
}
public static async getFilesInDirectory(data: {
directoryPath: string;
repoPath: string;

View File

@@ -18,7 +18,7 @@ export const GetRepositorySecretKey: GetStringOrNullFunction = ():
};
export const GetLocalRepositoryPath: GetStringFunction = (): string => {
return process.env["ONEUPTIME_LOCAL_REPOSITORY_PATH"] || "/repository";
return "/repository";
};
export const GetGitHubToken: GetStringOrNullFunction = (): string | null => {

View File

@@ -3,7 +3,7 @@
#
# Pull base image nodejs image.
FROM node:21.7.3-alpine3.18
FROM node:22.3.0
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
ARG GIT_SHA
@@ -18,17 +18,16 @@ RUN if [ -z "$APP_VERSION" ]; then export APP_VERSION=1.0.0; fi
# Install bash.
RUN apk add bash && apk add curl
RUN apt-get install bash -y && apt-get install curl -y
# Install python
RUN apk update && apk add --no-cache --virtual .gyp python3 make g++
RUN apt-get update && apt-get install -y .gyp python3 make g++
#Use bash shell by default
SHELL ["/bin/bash", "-c"]
RUN mkdir /usr/src
RUN mkdir -p /usr/src
WORKDIR /usr/src/Common
COPY ./Common/package*.json /usr/src/Common/
@@ -46,7 +45,6 @@ RUN npm install
COPY ./Model /usr/src/Model
WORKDIR /usr/src/CommonServer
COPY ./CommonServer/package*.json /usr/src/CommonServer/
# Set version in ./CommonServer/package.json to the APP_VERSION

View File

@@ -24,7 +24,10 @@ import CopilotActionProcessingException from "./Exceptions/CopilotActionProcessi
let currentFixCount: number = 1;
const init: PromiseVoidFunction = async (): Promise<void> => {
const codeRepositoryResult: CodeRepositoryResult = await InitUtil.init();
debugger;
const codeRepositoryResult: CodeRepositoryResult = await InitUtil.init()
for (const serviceToImrove of codeRepositoryResult.servicesToImprove) {
checkIfCurrentFixCountIsLessThanFixNumberOfCodeEventsInEachRun();

View File

@@ -59,6 +59,15 @@ export default class CodeRepositoryUtil {
return pullRequests;
}
public static async listFilesInDirectory(data: {
directoryPath: string;
}): Promise<Array<string>> {
return await CodeRepositoryServerUtil.listFilesInDirectory({
repoPath: GetLocalRepositoryPath(),
directoryPath: data.directoryPath,
});
}
public static getGitHubUtil(): GitHubUtil {
if (!this.gitHubUtil) {
const gitHubToken: string | null = GetGitHubToken();