bazel: build cody-ui and cody-shared (#50285)

## Context

Build `cody-ui` and `cody-shared` packages with Bazel.

## Test plan

bazel build locally.

## App preview:

- [Web](https://sg-web-vb-bazel-cody.onrender.com/search)

Check out the [client app preview
documentation](https://docs.sourcegraph.com/dev/how-to/client_pr_previews)
to learn more.

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
This commit is contained in:
Valery Bugakov 2023-04-03 07:13:21 -07:00 committed by GitHub
parent 0789320fe2
commit 46b8fb252a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 164 additions and 6 deletions

View File

@ -7,10 +7,9 @@ client/build-config/node_modules
client/client-api/node_modules
client/codeintellify/node_modules
client/cody/node_modules
client/cody/common/node_modules
client/cody/server/node_modules
client/cody-shared/node_modules
client/cody/vscode-codegen/node_modules
client/cody-ui/node_modules
client/cody-web/node_modules
client/common/node_modules
client/eslint-plugin-wildcard/node_modules
client/extension-api/node_modules
@ -48,4 +47,3 @@ cmd/sitemap
internal/cmd/progress-bot
client/cody
client/cody-shared

95
client/cody-shared/BUILD.bazel generated Normal file
View File

@ -0,0 +1,95 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/common:tsconfig",
],
)
ts_project(
name = "cody-shared_lib",
srcs = [
"src/chat/chat.ts",
"src/chat/client.ts",
"src/chat/markdown.ts",
"src/chat/preamble.ts",
"src/chat/recipes/chat-question.ts",
"src/chat/recipes/explain-code-detailed.ts",
"src/chat/recipes/explain-code-high-level.ts",
"src/chat/recipes/generate-docstring.ts",
"src/chat/recipes/generate-test.ts",
"src/chat/recipes/git-log.ts",
"src/chat/recipes/helpers.ts",
"src/chat/recipes/improve-variable-names.ts",
"src/chat/recipes/index.ts",
"src/chat/recipes/langs.ts",
"src/chat/recipes/recipe.ts",
"src/chat/recipes/translate.ts",
"src/chat/transcript/index.ts",
"src/chat/transcript/interaction.ts",
"src/chat/transcript/messages.ts",
"src/chat/viewHelpers.ts",
"src/codebase-context/index.ts",
"src/codebase-context/messages.ts",
"src/configuration.ts",
"src/editor/index.ts",
"src/embeddings/client.ts",
"src/embeddings/index.ts",
"src/intent-detector/client.ts",
"src/intent-detector/index.ts",
"src/keyword-context/index.ts",
"src/prompt/constants.ts",
"src/prompt/templates.ts",
"src/prompt/truncation.ts",
"src/sourcegraph-api/completions/browserClient.ts",
"src/sourcegraph-api/completions/client.ts",
"src/sourcegraph-api/completions/nodeClient.ts",
"src/sourcegraph-api/completions/parse.ts",
"src/sourcegraph-api/completions/types.ts",
"src/sourcegraph-api/graphql/client.ts",
"src/sourcegraph-api/graphql/index.ts",
"src/sourcegraph-api/graphql/queries.ts",
"src/sourcegraph-api/index.ts",
"src/timestamp.ts",
"src/utils.ts",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/common",
"//:node_modules/@microsoft/fetch-event-source",
"//:node_modules/@types/isomorphic-fetch",
"//:node_modules/@types/node",
"//:node_modules/isomorphic-fetch",
],
)
npm_package(
name = "cody-shared_pkg",
srcs = [
"package.json",
":cody-shared_lib",
],
)
ts_project(
name = "cody-shared_tests",
testonly = True,
srcs = [
"src/chat/transcript/transcript.test.ts",
"src/test/mocks.ts",
],
tsconfig = ":tsconfig",
deps = [
":cody-shared_lib",
"//:node_modules/@types/node",
],
)

55
client/cody-ui/BUILD.bazel generated Normal file
View File

@ -0,0 +1,55 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//dev:defs.bzl", "jest_test", "npm_package", "ts_project")
# gazelle:js_ignore_imports **/*.css
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//client:__subpackages__"],
deps = [
"//:tsconfig",
"//client/cody-shared:tsconfig",
],
)
filegroup(
name = "cody-ui_styles",
srcs = glob(["**/*.css"]),
)
ts_project(
name = "cody-ui_lib",
srcs = [
"src/Chat.tsx",
"src/Terms.tsx",
"src/Tips.tsx",
"src/chat/CodeBlocks.tsx",
"src/chat/ContextFiles.tsx",
"src/index.ts",
"src/utils/icons.tsx",
],
data = [
":cody-ui_styles",
],
tsconfig = ":tsconfig",
# TODO(bazel): "#keep"s required for type-only imports
deps = [
":node_modules/@sourcegraph/cody-shared",
"//:node_modules/@types/classnames",
"//:node_modules/@types/react",
"//:node_modules/classnames",
"//:node_modules/react",
],
)
npm_package(
name = "cody-ui_pkg",
srcs = [
"package.json",
":cody-ui_lib",
],
)

View File

@ -251,7 +251,6 @@ ts_project(
"src/react-shortcuts/ShortcutProvider.tsx",
"src/react-shortcuts/index.ts",
"src/react-shortcuts/keys.ts",
"src/schema.ts",
"src/schema/extensionSchema.ts",
"src/schema/settings.schema.d.ts", #keep
"src/search/backend.ts",

View File

@ -31,6 +31,8 @@ ts_config(
"//client/build-config:tsconfig",
"//client/client-api:tsconfig",
"//client/codeintellify:tsconfig",
"//client/cody-shared:tsconfig",
"//client/cody-ui:tsconfig",
"//client/common:tsconfig",
"//client/extension-api-types:tsconfig",
"//client/http-client:tsconfig",
@ -1243,6 +1245,7 @@ ts_project(
"src/repo/repoContainerRoutes.tsx",
"src/repo/repoHeaderActionButtons.tsx",
"src/repo/repoRevisionContainerRoutes.tsx",
"src/repo/repoRevisionSidebar/cody/RepoRevisionSidebarCody.tsx",
"src/repo/settings/RepoSettingsArea.tsx",
"src/repo/settings/RepoSettingsIndexPage.tsx",
"src/repo/settings/RepoSettingsMirrorPage.tsx",
@ -1592,6 +1595,8 @@ ts_project(
":node_modules/@sourcegraph/branded",
":node_modules/@sourcegraph/client-api", #keep
":node_modules/@sourcegraph/codeintellify",
":node_modules/@sourcegraph/cody-shared",
":node_modules/@sourcegraph/cody-ui",
":node_modules/@sourcegraph/common",
":node_modules/@sourcegraph/extension-api-types", #keep
":node_modules/@sourcegraph/http-client",
@ -1816,6 +1821,7 @@ ts_project(
"src/user/index.test.ts",
"src/user/settings/profile/UserSettingsProfilePage.test.tsx",
"src/user/settings/research/ProductResearch.test.tsx",
"src/util/checkRequestAccessAllowed.test.ts",
"src/util/codeStatsUtils.test.ts",
"src/util/getReactElements.test.tsx",
"src/util/prettyBytesBigint.test.ts",

View File

@ -288,6 +288,7 @@ go_library(
"//internal/usagestats",
"//internal/users",
"//internal/version",
"//internal/version/upgradestore",
"//internal/webhooks/outbound",
"//lib/batches",
"//lib/errors",

View File

@ -31,6 +31,7 @@ go_library(
"//internal/database/connections/live",
"//internal/debugserver",
"//internal/env",
"//internal/errcode",
"//internal/gitserver",
"//internal/goroutine",
"//internal/honey",

View File

@ -38,12 +38,14 @@ go_test(
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/testing",
"//enterprise/internal/batches/types",
"//enterprise/internal/batches/webhooks",
"//internal/database",
"//internal/database/basestore",
"//internal/database/dbtest",
"//internal/errcode",
"//internal/extsvc",
"//internal/extsvc/github",
"//internal/httpcli",
"//internal/observation",
"@com_github_sourcegraph_log//logtest",
],

View File

@ -54,6 +54,7 @@ go_test(
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/testing",
"//enterprise/internal/batches/types",
"//enterprise/internal/batches/webhooks",
"//internal/actor",
"//internal/database",
"//internal/database/dbtest",
@ -65,6 +66,7 @@ go_test(
"//internal/gitserver",
"//internal/gitserver/gitdomain",
"//internal/gitserver/protocol",
"//internal/httpcli",
"//internal/observation",
"//internal/repos",
"//internal/repoupdater/protocol",

View File

@ -880,7 +880,6 @@ go_library(
"frontend/1680088638_add_is_partial_success_to_permission_sync_jobs/down.sql",
"frontend/1680088638_add_is_partial_success_to_permission_sync_jobs/metadata.yaml",
"frontend/1680088638_add_is_partial_success_to_permission_sync_jobs/up.sql",
"codeinsights/pbcopy",
],
importpath = "github.com/sourcegraph/sourcegraph/migrations",
visibility = ["//visibility:public"],