mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-16 06:15:24 +00:00
remove error package
This commit is contained in:
parent
758acf14df
commit
174497d369
10 changed files with 17 additions and 128 deletions
|
|
@ -42,12 +42,10 @@ COPY package.json yarn.lock* .yarnrc.yml ./
|
||||||
COPY .yarn ./.yarn
|
COPY .yarn ./.yarn
|
||||||
COPY ./packages/db ./packages/db
|
COPY ./packages/db ./packages/db
|
||||||
COPY ./packages/schemas ./packages/schemas
|
COPY ./packages/schemas ./packages/schemas
|
||||||
COPY ./packages/error ./packages/error
|
|
||||||
COPY ./packages/shared ./packages/shared
|
COPY ./packages/shared ./packages/shared
|
||||||
|
|
||||||
RUN yarn workspace @sourcebot/db install
|
RUN yarn workspace @sourcebot/db install
|
||||||
RUN yarn workspace @sourcebot/schemas install
|
RUN yarn workspace @sourcebot/schemas install
|
||||||
RUN yarn workspace @sourcebot/error install
|
|
||||||
RUN yarn workspace @sourcebot/shared install
|
RUN yarn workspace @sourcebot/shared install
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
|
|
||||||
|
|
@ -93,7 +91,6 @@ COPY ./packages/web ./packages/web
|
||||||
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
||||||
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
||||||
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
||||||
COPY --from=shared-libs-builder /app/packages/error ./packages/error
|
|
||||||
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
||||||
|
|
||||||
# Fixes arm64 timeouts
|
# Fixes arm64 timeouts
|
||||||
|
|
@ -132,7 +129,6 @@ COPY ./packages/backend ./packages/backend
|
||||||
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
||||||
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
||||||
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
||||||
COPY --from=shared-libs-builder /app/packages/error ./packages/error
|
|
||||||
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
||||||
RUN yarn workspace @sourcebot/backend install
|
RUN yarn workspace @sourcebot/backend install
|
||||||
RUN yarn workspace @sourcebot/backend build
|
RUN yarn workspace @sourcebot/backend build
|
||||||
|
|
@ -217,7 +213,6 @@ COPY --from=backend-builder /app/packages/backend ./packages/backend
|
||||||
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
COPY --from=shared-libs-builder /app/node_modules ./node_modules
|
||||||
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
COPY --from=shared-libs-builder /app/packages/db ./packages/db
|
||||||
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
|
||||||
COPY --from=shared-libs-builder /app/packages/error ./packages/error
|
|
||||||
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
|
||||||
|
|
||||||
# Configure dependencies
|
# Configure dependencies
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env SKIP_ENV_VALIDATION=1 yarn workspaces foreach -A run build",
|
"build": "cross-env SKIP_ENV_VALIDATION=1 yarn workspaces foreach --all --topological run build",
|
||||||
"test": "yarn workspaces foreach -A run test",
|
"test": "yarn workspaces foreach --all --topological run test",
|
||||||
"dev": "concurrently --kill-others --names \"zoekt,worker,web,mcp,schemas\" 'yarn dev:zoekt' 'yarn dev:backend' 'yarn dev:web' 'yarn watch:mcp' 'yarn watch:schemas'",
|
"dev": "concurrently --kill-others --names \"zoekt,worker,web,mcp,schemas\" 'yarn dev:zoekt' 'yarn dev:backend' 'yarn dev:web' 'yarn watch:mcp' 'yarn watch:schemas'",
|
||||||
"with-env": "cross-env PATH=\"$PWD/bin:$PATH\" dotenv -e .env.development -c --",
|
"with-env": "cross-env PATH=\"$PWD/bin:$PATH\" dotenv -e .env.development -c --",
|
||||||
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
|
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"dev:prisma:studio": "yarn with-env yarn workspace @sourcebot/db prisma:studio",
|
"dev:prisma:studio": "yarn with-env yarn workspace @sourcebot/db prisma:studio",
|
||||||
"dev:prisma:migrate:reset": "yarn with-env yarn workspace @sourcebot/db prisma:migrate:reset",
|
"dev:prisma:migrate:reset": "yarn with-env yarn workspace @sourcebot/db prisma:migrate:reset",
|
||||||
"dev:prisma:db:push": "yarn with-env yarn workspace @sourcebot/db prisma:db:push",
|
"dev:prisma:db:push": "yarn with-env yarn workspace @sourcebot/db prisma:db:push",
|
||||||
"build:deps": "yarn workspaces foreach -R --from '{@sourcebot/schemas,@sourcebot/error,@sourcebot/db,@sourcebot/shared}' run build"
|
"build:deps": "yarn workspaces foreach --recursive --topological --from '{@sourcebot/schemas,@sourcebot/db,@sourcebot/shared}' run build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^9.2.1",
|
"concurrently": "^9.2.1",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
"@sentry/node": "^9.3.0",
|
"@sentry/node": "^9.3.0",
|
||||||
"@sentry/profiling-node": "^9.3.0",
|
"@sentry/profiling-node": "^9.3.0",
|
||||||
"@sourcebot/db": "workspace:*",
|
"@sourcebot/db": "workspace:*",
|
||||||
"@sourcebot/error": "workspace:*",
|
|
||||||
"@sourcebot/schemas": "workspace:*",
|
"@sourcebot/schemas": "workspace:*",
|
||||||
"@sourcebot/shared": "workspace:*",
|
"@sourcebot/shared": "workspace:*",
|
||||||
"@t3-oss/env-core": "^0.12.0",
|
"@t3-oss/env-core": "^0.12.0",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import { AzureDevOpsConnectionConfig } from "@sourcebot/schemas/v3/azuredevops.t
|
||||||
import { createLogger } from "@sourcebot/shared";
|
import { createLogger } from "@sourcebot/shared";
|
||||||
import { measure, fetchWithRetry } from "./utils.js";
|
import { measure, fetchWithRetry } from "./utils.js";
|
||||||
import micromatch from "micromatch";
|
import micromatch from "micromatch";
|
||||||
import { BackendException, BackendError } from "@sourcebot/error";
|
|
||||||
import { processPromiseResults, throwIfAnyFailed } from "./connectionUtils.js";
|
import { processPromiseResults, throwIfAnyFailed } from "./connectionUtils.js";
|
||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
import * as azdev from "azure-devops-node-api";
|
import * as azdev from "azure-devops-node-api";
|
||||||
|
|
@ -36,9 +35,7 @@ export const getAzureDevOpsReposFromConfig = async (
|
||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
const e = new BackendException(BackendError.CONNECTION_SYNC_INVALID_TOKEN, {
|
const e = new Error('Azure DevOps requires a Personal Access Token');
|
||||||
message: 'Azure DevOps requires a Personal Access Token',
|
|
||||||
});
|
|
||||||
Sentry.captureException(e);
|
Sentry.captureException(e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
import fetch from 'cross-fetch';
|
import { GerritConnectionConfig } from "@sourcebot/schemas/v3/index.type";
|
||||||
import { GerritConnectionConfig } from "@sourcebot/schemas/v3/index.type"
|
|
||||||
import { createLogger } from '@sourcebot/shared';
|
import { createLogger } from '@sourcebot/shared';
|
||||||
|
import fetch from 'cross-fetch';
|
||||||
import micromatch from "micromatch";
|
import micromatch from "micromatch";
|
||||||
import { measure, fetchWithRetry } from './utils.js';
|
import { fetchWithRetry, measure } from './utils.js';
|
||||||
import { BackendError } from '@sourcebot/error';
|
|
||||||
import { BackendException } from '@sourcebot/error';
|
|
||||||
import * as Sentry from "@sentry/node";
|
|
||||||
|
|
||||||
// https://gerrit-review.googlesource.com/Documentation/rest-api.html
|
// https://gerrit-review.googlesource.com/Documentation/rest-api.html
|
||||||
interface GerritProjects {
|
interface GerritProjects {
|
||||||
|
|
@ -39,26 +36,10 @@ export const getGerritReposFromConfig = async (config: GerritConnectionConfig):
|
||||||
const url = config.url.endsWith('/') ? config.url : `${config.url}/`;
|
const url = config.url.endsWith('/') ? config.url : `${config.url}/`;
|
||||||
|
|
||||||
let { durationMs, data: projects } = await measure(async () => {
|
let { durationMs, data: projects } = await measure(async () => {
|
||||||
try {
|
const fetchFn = () => fetchAllProjects(url);
|
||||||
const fetchFn = () => fetchAllProjects(url);
|
return fetchWithRetry(fetchFn, `projects from ${url}`, logger);
|
||||||
return fetchWithRetry(fetchFn, `projects from ${url}`, logger);
|
|
||||||
} catch (err) {
|
|
||||||
Sentry.captureException(err);
|
|
||||||
if (err instanceof BackendException) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.error(`Failed to fetch projects from ${url}`, err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!projects) {
|
|
||||||
const e = new Error(`Failed to fetch projects from ${url}`);
|
|
||||||
Sentry.captureException(e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// include repos by glob if specified in config
|
// include repos by glob if specified in config
|
||||||
if (config.projects) {
|
if (config.projects) {
|
||||||
projects = projects.filter((project) => {
|
projects = projects.filter((project) => {
|
||||||
|
|
@ -91,27 +72,9 @@ const fetchAllProjects = async (url: string): Promise<GerritProject[]> => {
|
||||||
logger.debug(`Fetching projects from Gerrit at ${endpointWithParams}`);
|
logger.debug(`Fetching projects from Gerrit at ${endpointWithParams}`);
|
||||||
|
|
||||||
let response: Response;
|
let response: Response;
|
||||||
try {
|
response = await fetch(endpointWithParams);
|
||||||
response = await fetch(endpointWithParams);
|
if (!response.ok) {
|
||||||
if (!response.ok) {
|
throw new Error(`Failed to fetch projects from Gerrit at ${endpointWithParams} with status ${response.status}`);
|
||||||
logger.error(`Failed to fetch projects from Gerrit at ${endpointWithParams} with status ${response.status}`);
|
|
||||||
const e = new BackendException(BackendError.CONNECTION_SYNC_FAILED_TO_FETCH_GERRIT_PROJECTS, {
|
|
||||||
status: response.status,
|
|
||||||
});
|
|
||||||
Sentry.captureException(e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
Sentry.captureException(err);
|
|
||||||
if (err instanceof BackendException) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const status = (err as any).code;
|
|
||||||
logger.error(`Failed to fetch projects from Gerrit at ${endpointWithParams} with status ${status}`);
|
|
||||||
throw new BackendException(BackendError.CONNECTION_SYNC_FAILED_TO_FETCH_GERRIT_PROJECTS, {
|
|
||||||
status: status,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
@ -151,11 +114,11 @@ const shouldExcludeProject = ({
|
||||||
|
|
||||||
const shouldExclude = (() => {
|
const shouldExclude = (() => {
|
||||||
if ([
|
if ([
|
||||||
'All-Projects',
|
'All-Projects',
|
||||||
'All-Users',
|
'All-Users',
|
||||||
'All-Avatars',
|
'All-Avatars',
|
||||||
'All-Archived-Projects'
|
'All-Archived-Projects'
|
||||||
].includes(project.name)) {
|
].includes(project.name)) {
|
||||||
reason = `Project is a special project.`;
|
reason = `Project is a special project.`;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@sourcebot/error",
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc",
|
|
||||||
"postinstall": "yarn build"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^22.7.5",
|
|
||||||
"typescript": "^5.7.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
export enum BackendError {
|
|
||||||
CONNECTION_SYNC_SECRET_DNE = 'CONNECTION_SYNC_SECRET_DNE',
|
|
||||||
CONNECTION_SYNC_INVALID_TOKEN = 'CONNECTION_SYNC_INVALID_TOKEN',
|
|
||||||
CONNECTION_SYNC_SYSTEM_ERROR = 'CONNECTION_SYNC_SYSTEM_ERROR',
|
|
||||||
CONNECTION_SYNC_FAILED_TO_FETCH_GERRIT_PROJECTS = 'CONNECTION_SYNC_FAILED_TO_FETCH_GERRIT_PROJECTS',
|
|
||||||
CONNECTION_SYNC_CONNECTION_NOT_FOUND = 'CONNECTION_SYNC_CONNECTION_NOT_FOUND',
|
|
||||||
}
|
|
||||||
|
|
||||||
export class BackendException extends Error {
|
|
||||||
constructor(
|
|
||||||
public readonly code: BackendError,
|
|
||||||
public readonly metadata: Record<string, unknown> = {}
|
|
||||||
) {
|
|
||||||
super(code);
|
|
||||||
this.name = 'BackendException';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES6",
|
|
||||||
"module": "CommonJS",
|
|
||||||
"lib": ["ES6"],
|
|
||||||
"outDir": "dist",
|
|
||||||
"rootDir": "src",
|
|
||||||
"declaration": true,
|
|
||||||
"declarationMap": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"strictNullChecks": true,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"isolatedModules": true
|
|
||||||
},
|
|
||||||
"include": ["src/**/*"],
|
|
||||||
"exclude": ["node_modules", "dist"]
|
|
||||||
}
|
|
||||||
|
|
@ -91,7 +91,6 @@
|
||||||
"@shopify/lang-jsonc": "^1.0.0",
|
"@shopify/lang-jsonc": "^1.0.0",
|
||||||
"@sourcebot/codemirror-lang-tcl": "^1.0.12",
|
"@sourcebot/codemirror-lang-tcl": "^1.0.12",
|
||||||
"@sourcebot/db": "workspace:*",
|
"@sourcebot/db": "workspace:*",
|
||||||
"@sourcebot/error": "workspace:*",
|
|
||||||
"@sourcebot/schemas": "workspace:*",
|
"@sourcebot/schemas": "workspace:*",
|
||||||
"@sourcebot/shared": "workspace:*",
|
"@sourcebot/shared": "workspace:*",
|
||||||
"@ssddanbrown/codemirror-lang-twig": "^1.0.0",
|
"@ssddanbrown/codemirror-lang-twig": "^1.0.0",
|
||||||
|
|
|
||||||
11
yarn.lock
11
yarn.lock
|
|
@ -7894,7 +7894,6 @@ __metadata:
|
||||||
"@sentry/node": "npm:^9.3.0"
|
"@sentry/node": "npm:^9.3.0"
|
||||||
"@sentry/profiling-node": "npm:^9.3.0"
|
"@sentry/profiling-node": "npm:^9.3.0"
|
||||||
"@sourcebot/db": "workspace:*"
|
"@sourcebot/db": "workspace:*"
|
||||||
"@sourcebot/error": "workspace:*"
|
|
||||||
"@sourcebot/schemas": "workspace:*"
|
"@sourcebot/schemas": "workspace:*"
|
||||||
"@sourcebot/shared": "workspace:*"
|
"@sourcebot/shared": "workspace:*"
|
||||||
"@t3-oss/env-core": "npm:^0.12.0"
|
"@t3-oss/env-core": "npm:^0.12.0"
|
||||||
|
|
@ -7959,15 +7958,6 @@ __metadata:
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
"@sourcebot/error@workspace:*, @sourcebot/error@workspace:packages/error":
|
|
||||||
version: 0.0.0-use.local
|
|
||||||
resolution: "@sourcebot/error@workspace:packages/error"
|
|
||||||
dependencies:
|
|
||||||
"@types/node": "npm:^22.7.5"
|
|
||||||
typescript: "npm:^5.7.3"
|
|
||||||
languageName: unknown
|
|
||||||
linkType: soft
|
|
||||||
|
|
||||||
"@sourcebot/mcp@workspace:packages/mcp":
|
"@sourcebot/mcp@workspace:packages/mcp":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@sourcebot/mcp@workspace:packages/mcp"
|
resolution: "@sourcebot/mcp@workspace:packages/mcp"
|
||||||
|
|
@ -8107,7 +8097,6 @@ __metadata:
|
||||||
"@shopify/lang-jsonc": "npm:^1.0.0"
|
"@shopify/lang-jsonc": "npm:^1.0.0"
|
||||||
"@sourcebot/codemirror-lang-tcl": "npm:^1.0.12"
|
"@sourcebot/codemirror-lang-tcl": "npm:^1.0.12"
|
||||||
"@sourcebot/db": "workspace:*"
|
"@sourcebot/db": "workspace:*"
|
||||||
"@sourcebot/error": "workspace:*"
|
|
||||||
"@sourcebot/schemas": "workspace:*"
|
"@sourcebot/schemas": "workspace:*"
|
||||||
"@sourcebot/shared": "workspace:*"
|
"@sourcebot/shared": "workspace:*"
|
||||||
"@ssddanbrown/codemirror-lang-twig": "npm:^1.0.0"
|
"@ssddanbrown/codemirror-lang-twig": "npm:^1.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue