From 26e110f22e8cce2d1e8c407938e66d33118211a5 Mon Sep 17 00:00:00 2001 From: Cooper Bills Date: Thu, 24 Mar 2022 14:30:49 -0700 Subject: [PATCH] Add example --- example/.bazelignore | 6 + example/.bazelrc | 94 ++++++ example/.bazelversion | 2 + example/.gitignore | 4 + example/BUILD.bazel | 4 + example/WORKSPACE | 40 +++ example/package-lock.json | 586 +++++++++++++++++++++++++++++++++++ example/package.json | 21 ++ example/prisma/BUILD.bazel | 7 + example/prisma/schema.prisma | 15 + example/server/BUILD.bazel | 34 ++ example/server/MyServer.ts | 10 + example/tools/BUILD.bazel | 1 + example/tools/bazel_deps.bzl | 13 + example/tsconfig.json | 22 ++ 15 files changed, 859 insertions(+) create mode 100644 example/.bazelignore create mode 100644 example/.bazelrc create mode 100644 example/.bazelversion create mode 100644 example/.gitignore create mode 100644 example/BUILD.bazel create mode 100644 example/WORKSPACE create mode 100644 example/package-lock.json create mode 100644 example/package.json create mode 100644 example/prisma/BUILD.bazel create mode 100644 example/prisma/schema.prisma create mode 100644 example/server/BUILD.bazel create mode 100644 example/server/MyServer.ts create mode 100644 example/tools/BUILD.bazel create mode 100644 example/tools/bazel_deps.bzl create mode 100644 example/tsconfig.json diff --git a/example/.bazelignore b/example/.bazelignore new file mode 100644 index 0000000..63ecdb2 --- /dev/null +++ b/example/.bazelignore @@ -0,0 +1,6 @@ +# NB: semantics here are not the same as .gitignore +# see https://github.com/bazelbuild/bazel/issues/8106 +# For example, every nested node_modules directory needs to be listed here. +node_modules +dist +bazel-out diff --git a/example/.bazelrc b/example/.bazelrc new file mode 100644 index 0000000..201bf8e --- /dev/null +++ b/example/.bazelrc @@ -0,0 +1,94 @@ +# Common Bazel settings for JavaScript/NodeJS workspaces +# This rc file is automatically discovered when Bazel is run in this workspace, +# see https://docs.bazel.build/versions/master/guide.html#bazelrc +# +# The full list of Bazel options: https://docs.bazel.build/versions/master/command-line-reference.html + +# Cache action outputs on disk so they persist across output_base and bazel shutdown (eg. changing branches) +build --disk_cache=~/.cache/bazel-disk-cache + +# Bazel picks up host-OS-specific config lines from bazelrc files +build --enable_platform_specific_config + +# Bazel will create symlinks from the workspace directory to output artifacts. +# Build results will be placed in a directory called "dist/bin" +# Other directories will be created like "dist/testlogs" +# Be aware that this will still create a bazel-out symlink in +# your project directory, which you must exclude from version control and your +# editor's search path. +build --symlink_prefix=dist/ +# To disable the symlinks altogether (including bazel-out) you can use +# build --symlink_prefix=/ +# however this makes it harder to find outputs. + +# Specifies desired output mode for running tests. +# Valid values are +# 'summary' to output only test status summary +# 'errors' to also print test logs for failed tests +# 'all' to print logs for all tests +# 'streamed' to output logs for all tests in real time +# (this will force tests to be executed locally one at a time regardless of --test_strategy value). +test --test_output=errors + +# Support for debugging NodeJS tests +# Add the Bazel option `--config=debug` to enable this +# --test_output=streamed +# Stream stdout/stderr output from each test in real-time. +# See https://docs.bazel.build/versions/master/user-manual.html#flag--test_output for more details. +# --test_strategy=exclusive +# Run one test at a time. +# --test_timeout=9999 +# Prevent long running tests from timing out +# See https://docs.bazel.build/versions/master/user-manual.html#flag--test_timeout for more details. +# --nocache_test_results +# Always run tests +# --node_options=--inspect-brk +# Pass the --inspect-brk option to all tests which enables the node inspector agent. +# See https://nodejs.org/de/docs/guides/debugging-getting-started/#command-line-options for more details. +# --define=VERBOSE_LOGS=1 +# Rules will output verbose logs if the VERBOSE_LOGS environment variable is set. `VERBOSE_LOGS` will be passed to +# `nodejs_binary` and `nodejs_test` via the default value of the `default_env_vars` attribute of those rules. +# --compilation_mode=dbg +# Rules may change their build outputs if the compilation mode is set to dbg. For example, +# mininfiers such as terser may make their output more human readable when this is set. Rules will pass `COMPILATION_MODE` +# to `nodejs_binary` executables via the actions.run env attribute. +# See https://docs.bazel.build/versions/master/user-manual.html#flag--compilation_mode for more details. +test:debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results --define=VERBOSE_LOGS=1 +# Use bazel run with `--config=debug` to turn on the NodeJS inspector agent. +# The node process will break before user code starts and wait for the debugger to connect. +run:debug --define=VERBOSE_LOGS=1 -- --node_options=--inspect-brk +# The following option will change the build output of certain rules such as terser and may not be desirable in all cases +build:debug --compilation_mode=dbg + +# Turn off legacy external runfiles +# This prevents accidentally depending on this feature, which Bazel will remove. +build --nolegacy_external_runfiles + +# Workaround for: https://github.com/bazelbuild/bazel/issues/4327. +# The Chromium browser archive for macOS and Windows contain files with spaces that +# will break runfile tree creation for browser tests relying on `rules_webtesting`. +build:macos --experimental_inprocess_symlink_creation +build:windows --experimental_inprocess_symlink_creation + +# Turn on --incompatible_strict_action_env which was on by default +# in Bazel 0.21.0 but turned off again in 0.22.0. Follow +# https://github.com/bazelbuild/bazel/issues/7026 for more details. +# This flag is needed to so that the bazel cache is not invalidated +# when running bazel via `yarn bazel`. +# See https://github.com/angular/angular/issues/27514. +build --incompatible_strict_action_env +run --incompatible_strict_action_env + +# When running `bazel coverage` --instrument_test_targets needs to be set in order to +# collect coverage information from test targets +coverage --instrument_test_targets + +# Load any settings specific to the current user. +# .bazelrc.user should appear in .gitignore so that settings are not shared with team members +# This needs to be last statement in this +# config, as the user configuration should be able to overwrite flags from this file. +# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc +# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing, +# rather than user.bazelrc as suggested in the Bazel docs) +try-import %workspace%/.bazelrc.user + diff --git a/example/.bazelversion b/example/.bazelversion new file mode 100644 index 0000000..f98169a --- /dev/null +++ b/example/.bazelversion @@ -0,0 +1,2 @@ +5.0.0 + diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..4082c70 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,4 @@ +.bazelrc.user +dist +bazel-out +node_modules diff --git a/example/BUILD.bazel b/example/BUILD.bazel new file mode 100644 index 0000000..e77bb36 --- /dev/null +++ b/example/BUILD.bazel @@ -0,0 +1,4 @@ +# Add rules here to build your software +# See https://docs.bazel.build/versions/main/build-ref.html#BUILD_files + +exports_files(["tsconfig.json"]) diff --git a/example/WORKSPACE b/example/WORKSPACE new file mode 100644 index 0000000..1ac6661 --- /dev/null +++ b/example/WORKSPACE @@ -0,0 +1,40 @@ +# Bazel workspace created by @bazel/create 5.3.0 + +# Declares that this directory is the root of a Bazel workspace. +# See https://docs.bazel.build/versions/main/build-ref.html#workspace +workspace( + # How this workspace would be referenced with absolute labels from another workspace + name = "example", +) + +load("//tools:bazel_deps.bzl", "fetch_dependencies") + +fetch_dependencies() + +load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") + +build_bazel_rules_nodejs_dependencies() + +# The npm_install rule runs yarn anytime the package.json or package-lock.json file changes. +# It also extracts any Bazel rules distributed in an npm package. +load("@build_bazel_rules_nodejs//:index.bzl", "npm_install") + +npm_install( + # Name this npm so that Bazel Label references look like @npm//package + name = "npm", + package_json = "//:package.json", + package_lock_json = "//:package-lock.json", +) + +load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") + +esbuild_repositories(npm_repository = "npm") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rules_prisma", +# sha256 = '8feef60d3ac0faf369868bef3794677a7fc2f09fda00a6a70bf073e0400b8307', + strip_prefix = "rules_prisma-master", + url = "https://github.com/CooperBills/rules_prisma/archive/refs/heads/master.zip", +) diff --git a/example/package-lock.json b/example/package-lock.json new file mode 100644 index 0000000..0f85aaf --- /dev/null +++ b/example/package-lock.json @@ -0,0 +1,586 @@ +{ + "name": "example", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "example", + "version": "0.1.0", + "devDependencies": { + "@bazel/bazelisk": "latest", + "@bazel/buildifier": "latest", + "@bazel/esbuild": "^5.3.0", + "@bazel/ibazel": "latest", + "@bazel/typescript": "^5.3.0", + "@prisma/client": "^3.11.0", + "@prisma/engines": "^3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7", + "@types/node": "^17.0.23", + "prisma": "^3.11.0", + "typescript": "^4.6.2" + } + }, + "node_modules/@bazel/bazelisk": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@bazel/bazelisk/-/bazelisk-1.11.0.tgz", + "integrity": "sha512-lxiQzVqSGDG0PIDQGJdVDjp7T+50p5NnM4EnRJa76mkZp6u5ul19GJNKhPKi81TZQALZEZDxAgxVqQKkWTUOxA==", + "dev": true, + "bin": { + "bazel": "bazelisk.js", + "bazelisk": "bazelisk.js" + } + }, + "node_modules/@bazel/buildifier": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@bazel/buildifier/-/buildifier-5.0.1.tgz", + "integrity": "sha512-3eMWxdFtcQf+Jw55PZqD/I9N785wp6QQ2k/SZst7R64KAGrS8Ke1EhPXaZHZBkXao5GXrm6SNLDV287xg2kguA==", + "dev": true, + "bin": { + "buildifier": "buildifier.js" + } + }, + "node_modules/@bazel/esbuild": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/esbuild/-/esbuild-5.3.0.tgz", + "integrity": "sha512-UshiI+YFQmSoYW4ej2IxLNnZ2hceIsggTMYTpr16sx0FMOaFQuI3zV0w1/wu+coT18cco0bV/5AZBPV0I0f+Ug==", + "dev": true, + "hasInstallScript": true + }, + "node_modules/@bazel/ibazel": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@bazel/ibazel/-/ibazel-0.16.2.tgz", + "integrity": "sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA==", + "dev": true, + "bin": { + "ibazel": "index.js" + } + }, + "node_modules/@bazel/typescript": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/typescript/-/typescript-5.3.0.tgz", + "integrity": "sha512-n49HdHo/qFqXGYnNlzol203MKb5EytvC1GChroBzqoT6woWpb+p4e/xEatiMOEKWnlyPT/ZUAMQ8Ve/6yv1Dig==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@bazel/worker": "5.3.0", + "protobufjs": "6.8.8", + "semver": "5.6.0", + "source-map-support": "0.5.9", + "tsutils": "3.21.0" + }, + "bin": { + "ts_project_options_validator": "internal/ts_project_options_validator.js" + }, + "peerDependencies": { + "typescript": ">=3.0.0" + } + }, + "node_modules/@bazel/worker": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/worker/-/worker-5.3.0.tgz", + "integrity": "sha512-Tgyaud2/6mtYeaH+uCFQuuIVd/VRDvbUDFJgz8b+/LxTcXaDCb8OSI0ZnrEzLV7FJizMCam3/vWE2x9Ul4SOJw==", + "dev": true, + "dependencies": { + "google-protobuf": "^3.6.1" + } + }, + "node_modules/@prisma/client": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.11.0.tgz", + "integrity": "sha512-d42o/tlalaWMmNOR4r5BiR6YYTYEV82eZ2lNKOm5ht3WyYwI9e+zy2MyZnNO4Fx5e08RAhW+GRVcEgKl5faUaQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@prisma/engines-version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b" + }, + "engines": { + "node": ">=12.6" + }, + "peerDependencies": { + "prisma": "*" + }, + "peerDependenciesMeta": { + "prisma": { + "optional": true + } + } + }, + "node_modules/@prisma/engines": { + "version": "3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7.tgz", + "integrity": "sha512-Q1WgHmhFneaOCayGNQ21tauNt7qo6yTzUvLC/0ykvc75MV4mEDat96gIhzcCYroToIcdQ3+k7tniaFGZ/UwRQw==", + "dev": true, + "hasInstallScript": true + }, + "node_modules/@prisma/engines-version": { + "version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b.tgz", + "integrity": "sha512-bhMW1XybXZyqCf+9QqjP7Oi7xgVHcISVyOZNMm51qeZsy12M1RtHaCcXUFeMMV0JOCZZuPFVr3+0KVpQqK35CQ==", + "dev": true + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=", + "dev": true + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "dev": true + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==", + "dev": true + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=", + "dev": true + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "dev": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=", + "dev": true + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=", + "dev": true + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=", + "dev": true + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=", + "dev": true + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=", + "dev": true + }, + "node_modules/@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==", + "dev": true + }, + "node_modules/@types/node": { + "version": "17.0.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz", + "integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==", + "dev": true + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/google-protobuf": { + "version": "3.19.4", + "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.19.4.tgz", + "integrity": "sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg==", + "dev": true + }, + "node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "dev": true + }, + "node_modules/prisma": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-3.11.0.tgz", + "integrity": "sha512-8SdsLPhKR3mOfoo2o73h9mNn3v5kA/RqGA26Sv6qDS78Eh2uepPqt5e8/nwj5EOblYm5HEGuitaXQrOCLb6uTw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@prisma/engines": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b" + }, + "bin": { + "prisma": "build/index.js", + "prisma2": "build/index.js" + }, + "engines": { + "node": ">=12.6" + } + }, + "node_modules/prisma/node_modules/@prisma/engines": { + "version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b.tgz", + "integrity": "sha512-m9iZd5F5vP6A2IvKWfHpOO/qK8OOO9nbsV/pdyEkF/1WNe0E8SIWFBKb+HcMLkG9OFbDDBy8QItXmp/mIULuwQ==", + "dev": true, + "hasInstallScript": true + }, + "node_modules/protobufjs": { + "version": "6.8.8", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz", + "integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.0", + "@types/node": "^10.1.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, + "node_modules/protobufjs/node_modules/@types/node": { + "version": "10.17.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", + "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "dev": true + }, + "node_modules/semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/typescript": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", + "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "@bazel/bazelisk": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@bazel/bazelisk/-/bazelisk-1.11.0.tgz", + "integrity": "sha512-lxiQzVqSGDG0PIDQGJdVDjp7T+50p5NnM4EnRJa76mkZp6u5ul19GJNKhPKi81TZQALZEZDxAgxVqQKkWTUOxA==", + "dev": true + }, + "@bazel/buildifier": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@bazel/buildifier/-/buildifier-5.0.1.tgz", + "integrity": "sha512-3eMWxdFtcQf+Jw55PZqD/I9N785wp6QQ2k/SZst7R64KAGrS8Ke1EhPXaZHZBkXao5GXrm6SNLDV287xg2kguA==", + "dev": true + }, + "@bazel/esbuild": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/esbuild/-/esbuild-5.3.0.tgz", + "integrity": "sha512-UshiI+YFQmSoYW4ej2IxLNnZ2hceIsggTMYTpr16sx0FMOaFQuI3zV0w1/wu+coT18cco0bV/5AZBPV0I0f+Ug==", + "dev": true + }, + "@bazel/ibazel": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@bazel/ibazel/-/ibazel-0.16.2.tgz", + "integrity": "sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA==", + "dev": true + }, + "@bazel/typescript": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/typescript/-/typescript-5.3.0.tgz", + "integrity": "sha512-n49HdHo/qFqXGYnNlzol203MKb5EytvC1GChroBzqoT6woWpb+p4e/xEatiMOEKWnlyPT/ZUAMQ8Ve/6yv1Dig==", + "dev": true, + "requires": { + "@bazel/worker": "5.3.0", + "protobufjs": "6.8.8", + "semver": "5.6.0", + "source-map-support": "0.5.9", + "tsutils": "3.21.0" + } + }, + "@bazel/worker": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@bazel/worker/-/worker-5.3.0.tgz", + "integrity": "sha512-Tgyaud2/6mtYeaH+uCFQuuIVd/VRDvbUDFJgz8b+/LxTcXaDCb8OSI0ZnrEzLV7FJizMCam3/vWE2x9Ul4SOJw==", + "dev": true, + "requires": { + "google-protobuf": "^3.6.1" + } + }, + "@prisma/client": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.11.0.tgz", + "integrity": "sha512-d42o/tlalaWMmNOR4r5BiR6YYTYEV82eZ2lNKOm5ht3WyYwI9e+zy2MyZnNO4Fx5e08RAhW+GRVcEgKl5faUaQ==", + "dev": true, + "requires": { + "@prisma/engines-version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b" + } + }, + "@prisma/engines": { + "version": "3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7.tgz", + "integrity": "sha512-Q1WgHmhFneaOCayGNQ21tauNt7qo6yTzUvLC/0ykvc75MV4mEDat96gIhzcCYroToIcdQ3+k7tniaFGZ/UwRQw==", + "dev": true + }, + "@prisma/engines-version": { + "version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b.tgz", + "integrity": "sha512-bhMW1XybXZyqCf+9QqjP7Oi7xgVHcISVyOZNMm51qeZsy12M1RtHaCcXUFeMMV0JOCZZuPFVr3+0KVpQqK35CQ==", + "dev": true + }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=", + "dev": true + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "dev": true + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==", + "dev": true + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=", + "dev": true + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "dev": true, + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=", + "dev": true + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=", + "dev": true + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=", + "dev": true + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=", + "dev": true + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=", + "dev": true + }, + "@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==", + "dev": true + }, + "@types/node": { + "version": "17.0.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz", + "integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "google-protobuf": { + "version": "3.19.4", + "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.19.4.tgz", + "integrity": "sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg==", + "dev": true + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "dev": true + }, + "prisma": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-3.11.0.tgz", + "integrity": "sha512-8SdsLPhKR3mOfoo2o73h9mNn3v5kA/RqGA26Sv6qDS78Eh2uepPqt5e8/nwj5EOblYm5HEGuitaXQrOCLb6uTw==", + "dev": true, + "requires": { + "@prisma/engines": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b" + }, + "dependencies": { + "@prisma/engines": { + "version": "3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b.tgz", + "integrity": "sha512-m9iZd5F5vP6A2IvKWfHpOO/qK8OOO9nbsV/pdyEkF/1WNe0E8SIWFBKb+HcMLkG9OFbDDBy8QItXmp/mIULuwQ==", + "dev": true + } + } + }, + "protobufjs": { + "version": "6.8.8", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz", + "integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==", + "dev": true, + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.0", + "@types/node": "^10.1.0", + "long": "^4.0.0" + }, + "dependencies": { + "@types/node": { + "version": "10.17.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", + "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "dev": true + } + } + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", + "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", + "dev": true + } + } +} diff --git a/example/package.json b/example/package.json new file mode 100644 index 0000000..d414881 --- /dev/null +++ b/example/package.json @@ -0,0 +1,21 @@ +{ + "name": "example", + "version": "0.1.0", + "private": true, + "devDependencies": { + "@bazel/bazelisk": "latest", + "@bazel/buildifier": "latest", + "@bazel/esbuild": "^5.3.0", + "@bazel/ibazel": "latest", + "@bazel/typescript": "^5.3.0", + "@prisma/client": "^3.11.0", + "@prisma/engines": "^3.12.0-20.174bb836d2319c0d24528304ed22866e180574c7", + "@types/node": "^17.0.23", + "prisma": "^3.11.0", + "typescript": "^4.6.2" + }, + "scripts": { + "build": "bazel build //...", + "test": "bazel test //..." + } +} diff --git a/example/prisma/BUILD.bazel b/example/prisma/BUILD.bazel new file mode 100644 index 0000000..2ba789f --- /dev/null +++ b/example/prisma/BUILD.bazel @@ -0,0 +1,7 @@ +load("@rules_prisma//prisma:prisma.bzl", "prisma_js_library") + +prisma_js_library( + name = "myclient", + schema = ":schema.prisma", + visibility = ["//:__subpackages__"], +) diff --git a/example/prisma/schema.prisma b/example/prisma/schema.prisma new file mode 100644 index 0000000..47620b0 --- /dev/null +++ b/example/prisma/schema.prisma @@ -0,0 +1,15 @@ +generator client { + provider = "prisma-client-js" + output = "./myclient" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + email String @unique + name String? +} diff --git a/example/server/BUILD.bazel b/example/server/BUILD.bazel new file mode 100644 index 0000000..c27d14b --- /dev/null +++ b/example/server/BUILD.bazel @@ -0,0 +1,34 @@ +load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") +load("@npm//@bazel/typescript:index.bzl", "ts_project") +load("@npm//@bazel/esbuild:index.bzl", "esbuild") + +ts_project( + name = "server_sources", + srcs = glob(["**/*.ts"]), + declaration = True, + tsconfig = "//:tsconfig.json", + deps = [ + "//prisma:myclient", + "@npm//@types/node", + ], +) + +esbuild( + name = "server_bundle", + entry_point = "MyServer.ts", + platform = "node", + sources_content = True, + deps = [":server_sources"], +) + +nodejs_binary( + name = "server", + data = [ + ":server_bundle", + "//prisma:myclient", + ], + entry_point = ":server_bundle.js", + env = { + "DATABASE_DIR": "postgresql://johndoe:mypassword@localhost:5432/mydb?schema=public", + }, +) diff --git a/example/server/MyServer.ts b/example/server/MyServer.ts new file mode 100644 index 0000000..1229f5d --- /dev/null +++ b/example/server/MyServer.ts @@ -0,0 +1,10 @@ +import { PrismaClient } from "../prisma/myclient"; +import { copyFileSync } from "fs"; +import {join} from "path"; + +copyFileSync(join(__dirname, "../prisma/myclient/schema.prisma"), "./schema.prisma"); + +const client = new PrismaClient(); + +console.log("Example server started!") +console.log(client) diff --git a/example/tools/BUILD.bazel b/example/tools/BUILD.bazel new file mode 100644 index 0000000..065db89 --- /dev/null +++ b/example/tools/BUILD.bazel @@ -0,0 +1 @@ +# Currently there are no targets in this Bazel package diff --git a/example/tools/bazel_deps.bzl b/example/tools/bazel_deps.bzl new file mode 100644 index 0000000..c082d6f --- /dev/null +++ b/example/tools/bazel_deps.bzl @@ -0,0 +1,13 @@ +# Third-party dependencies fetched by Bazel +# Unlike WORKSPACE, the content of this file is unordered. +# We keep them separate to make the WORKSPACE file more maintainable. + +# Install the nodejs "bootstrap" package +# This provides the basic tools for running and packaging nodejs programs in Bazel +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +def fetch_dependencies(): + http_archive( + name = "build_bazel_rules_nodejs", + sha256 = "3ceb1e5b5dcad5fa2ad8870a20201cfbb9c9c63cac4055c9ab370034c765297f", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.3.0/rules_nodejs-5.3.0.tar.gz"], + ) diff --git a/example/tsconfig.json b/example/tsconfig.json new file mode 100644 index 0000000..88bf834 --- /dev/null +++ b/example/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES6", + "moduleResolution": "Node", + "strict": true, + "jsx": "react", + "esModuleInterop": true, + "lib": ["dom", "dom.iterable", "esnext"], + "declaration": true, + "rootDirs": [ + ".", + "bazel-out/host/bin", + "bazel-out/darwin-fastbuild/bin", + "bazel-out/darwin_arm64-fastbuild/bin", + "bazel-out/k8-fastbuild/bin", + "bazel-out/x64_windows-fastbuild/bin", + "bazel-out/darwin-dbg/bin", + "bazel-out/k8-dbg/bin", + "bazel-out/x64_windows-dbg/bin" + ] + } +}