History

Add self-host custom tools source UI

Rhys Sullivan committed 4 months ago

Commit 2a35fef1 parent 9e77e3420 files · +1014 −50Browse files

Showing the changes to packages/plugins/apps/src/source/github-source.ts (1 of 20 files). Show all

Unified · Split

packages/plugins/apps/src/source/github-source.ts+7−7
@@ -2,7 +2,7 @@ import { Data, Effect, Result } from "effect"; · 1 unmodified line
2 2
3import { PublishError, type FileDiagnostic } from "../pipeline/discover";3import { PublishError, type FileDiagnostic } from "../pipeline/discover";
4import { PUBLISH_LIMITS, enforcePublishLimits } from "../pipeline/publish";4import { PUBLISH_LIMITS, enforcePublishLimits } from "../pipeline/publish";
5import type { AppSourceRef } from "../pipeline/descriptor";5import type { AppSourceRef, SourceSkippedArtifact } from "../pipeline/descriptor";
6import type { AppsRuntime } from "../plugin/runtime";6import type { AppsRuntime } from "../plugin/runtime";
7import type { FileSet, SnapshotId } from "../seams/artifact-store";7import type { FileSet, SnapshotId } from "../seams/artifact-store";
8 8
@@ -36,10 +36,7 @@ export interface SyncErrorData { · 27 unmodified lines
36 readonly diagnostics?: readonly FileDiagnostic[];36 readonly diagnostics?: readonly FileDiagnostic[];
37}37}
38 38
39export interface GitHubSkippedArtifact {39export type GitHubSkippedArtifact = SourceSkippedArtifact;
40 readonly path: string;
41 readonly reason: "not supported yet" | "unsupported file type" | "ignored";
42}
43 40
44export type GitHubSyncResult =41export type GitHubSyncResult =
45 | {42 | {
@@ -69,6 +66,7 @@ export interface SyncGitHubSourceInput extends GitHubSourceInput { · 23 unmodified lines
69 readonly runtime: AppsRuntime;66 readonly runtime: AppsRuntime;
70 readonly tenant?: string;67 readonly tenant?: string;
71 readonly scope: string;68 readonly scope: string;
69 readonly connection?: string;
72}70}
73 71
74const TOOL_RE = /^tools\/([a-z0-9][a-z0-9-]*)\.(ts|tsx|js|jsx)$/;72const TOOL_RE = /^tools\/([a-z0-9][a-z0-9-]*)\.(ts|tsx|js|jsx)$/;
@@ -374,11 +372,13 @@ const sourceErrorToSyncError = (error: GitHubSourceError): SyncErrorData => ({ · 299 unmodified lines
374 diagnostics: error.path ? [{ path: error.path, message: error.message }] : [],372 diagnostics: error.path ? [{ path: error.path, message: error.message }] : [],
375});373});
376 374
377const sourceRef = (snapshot: GitHubSourceSnapshot): AppSourceRef => ({375const sourceRef = (snapshot: GitHubSourceSnapshot, connection?: string): AppSourceRef => ({
378 kind: "github",376 kind: "github",
379 repo: snapshot.repo,377 repo: snapshot.repo,
380 ref: snapshot.ref,378 ref: snapshot.ref,
381 upstreamSha: snapshot.upstreamSha,379 upstreamSha: snapshot.upstreamSha,
380 ...(connection ? { connection } : {}),
381 skipped: snapshot.skipped,
382});382});
383 383
384export const syncGitHubSource = (input: SyncGitHubSourceInput): Effect.Effect<GitHubSyncResult> =>384export const syncGitHubSource = (input: SyncGitHubSourceInput): Effect.Effect<GitHubSyncResult> =>
@@ -420,7 +420,7 @@ export const syncGitHubSource = (input: SyncGitHubSourceInput): Effect.Effect<Gi · 35 unmodified lines
420 scope: input.scope,420 scope: input.scope,
421 files: snapshot.files,421 files: snapshot.files,
422 description: snapshot.description,422 description: snapshot.description,
423 source: sourceRef(snapshot),423 source: sourceRef(snapshot, input.connection),
424 message: `sync ${snapshot.repo}@${snapshot.upstreamSha}`,424 message: `sync ${snapshot.repo}@${snapshot.upstreamSha}`,
425 })425 })
426 .pipe(Effect.result);426 .pipe(Effect.result);