Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
Set up Buildifier (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts authored Oct 24, 2018
1 parent ae130a8 commit 5531dec
Show file tree
Hide file tree
Showing 49 changed files with 1,237 additions and 1,220 deletions.
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ jobs:
cd examples/react-app-javascript
yarn install
bazel build ...
buildifier-check:
docker:
- image: circleci/golang:1.9
working_directory: ~/repo
steps:
- checkout
- run:
name: Install Buildifier
command: |
go get github.com/bazelbuild/buildtools/buildifier
- run:
name: Buildifier check
command: |
buildifier -showlog -mode=check $(find . -type f \( -iname BUILD -or -iname BUILD.bazel -or -iname "*.bzl" \))
prettier-check:
<<: *job_configuration
steps:
Expand All @@ -94,4 +108,5 @@ workflows:
- build_react_examples
- build_react_app_with_node_modules_preinstalled
- build_dockerized_example
- buildifier-check
- prettier-check
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

exports_files([
"defs.bzl",
"defs.bzl",
])
4 changes: 2 additions & 2 deletions defs.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("//internal/js_library:rule.bzl", "js_library", "JsLibraryInfo")
load("//internal/js_library:rule.bzl", "JsLibraryInfo", "js_library")
load("//internal/ts_library:rule.bzl", "ts_library")
load("//internal/js_module:rule.bzl", "js_module")
load("//internal/js_binary:rule.bzl", "js_binary")
load("//internal/web_bundle:rule.bzl", "web_bundle")
load("//internal/js_script_and_test:rule.bzl", "js_script", "js_test")
load("//internal/npm_packages:rule.bzl", "npm_packages", "NpmPackagesInfo")
load("//internal/npm_packages:rule.bzl", "NpmPackagesInfo", "npm_packages")
load("//internal/npm_binary:rule.bzl", "npm_binary")
6 changes: 3 additions & 3 deletions examples/node-typescript-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports_files(["tsconfig.json"])
load("@bazel_javascript//:defs.bzl", "npm_packages")

npm_packages(
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
)
6 changes: 3 additions & 3 deletions examples/node-typescript-app/libs/shared-package/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "ts_library")

ts_library(
name = "shared-package",
srcs = glob(["**/*.ts"]),
tsconfig = "//:tsconfig.json",
name = "shared-package",
srcs = glob(["**/*.ts"]),
tsconfig = "//:tsconfig.json",
)
8 changes: 4 additions & 4 deletions examples/node-typescript-app/services/base-image/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_image", "cont

## The Backend Base Image
container_image(
name = "service",
base = "@node_alpine_image//image:image",
stamp = True,
workdir = "/app",
name = "service",
base = "@node_alpine_image//image:image",
stamp = True,
workdir = "/app",
)
60 changes: 30 additions & 30 deletions examples/node-typescript-app/services/my-service/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")

container_image(
name = "image",
base = "//services/base-image:service",
data_path = ".",
directory = "/app",
files = [
"//:packages",
"//services/my-service/server:server_compiled",
],
symlinks = {
"/app/node_modules": "/app/packages_installed_dir/node_modules",
},
cmd = [
"sh",
"-c",
# Rebuild packages such as node-sass, since they may not have been downloaded by Bazel with the right architecture.
# Ideally, this should be done when the image is built, not when it's run. Does rules_docker allow this?
"npm rebuild && " +
"node -r source-map-support/register server/server_compiled/services/my-service/server/server.js",
],
ports = [
"3000",
],
stamp = True,
name = "image",
base = "//services/base-image:service",
cmd = [
"sh",
"-c",
# Rebuild packages such as node-sass, since they may not have been downloaded by Bazel with the right architecture.
# Ideally, this should be done when the image is built, not when it's run. Does rules_docker allow this?
"npm rebuild && " +
"node -r source-map-support/register server/server_compiled/services/my-service/server/server.js",
],
data_path = ".",
directory = "/app",
files = [
"//:packages",
"//services/my-service/server:server_compiled",
],
ports = [
"3000",
],
stamp = True,
symlinks = {
"/app/node_modules": "/app/packages_installed_dir/node_modules",
},
)

container_push(
name = "publish",
format = "Docker",
image = ":image",
registry = "my.repo.com",
repository = "my-service",
stamp = True,
tag = "{BUILD_USER}",
name = "publish",
format = "Docker",
image = ":image",
registry = "my.repo.com",
repository = "my-service",
stamp = True,
tag = "{BUILD_USER}",
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "ts_library")

ts_library(
name = "server",
srcs = glob(["**/*.ts"]),
tsconfig = "//:tsconfig.json",
deps = [
"//:packages",
"//libs/shared-package",
],
name = "server",
srcs = glob(["**/*.ts"]),
tsconfig = "//:tsconfig.json",
deps = [
"//:packages",
"//libs/shared-package",
],
)
26 changes: 13 additions & 13 deletions examples/react-app-javascript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "npm_packages", "web_bundle")

web_bundle(
name = "app-bundle-dev",
lib = "//src",
entry = "index.js",
mode = "development",
html_template = "//public:index.html",
name = "app-bundle-dev",
entry = "index.js",
html_template = "//public:index.html",
lib = "//src",
mode = "development",
)

web_bundle(
name = "app-bundle-prod",
lib = "//src",
entry = "index.js",
mode = "production",
html_template = "//public:index.html",
name = "app-bundle-prod",
entry = "index.js",
html_template = "//public:index.html",
lib = "//src",
mode = "production",
)

npm_packages(
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
)
2 changes: 1 addition & 1 deletion examples/react-app-javascript/public/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports_files([
"index.html",
"index.html",
])
20 changes: 10 additions & 10 deletions examples/react-app-javascript/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "js_library")

js_library(
name = "src",
srcs = glob([
"*.js",
"*.jsx",
"*.css",
"*.svg",
]),
deps = [
"//:packages",
],
name = "src",
srcs = glob([
"*.js",
"*.jsx",
"*.css",
"*.svg",
]),
deps = [
"//:packages",
],
)
26 changes: 13 additions & 13 deletions examples/react-app-typescript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ load("@bazel_javascript//:defs.bzl", "npm_packages", "web_bundle")
exports_files(["tsconfig.json"])

web_bundle(
name = "app-bundle-dev",
lib = "//src",
entry = "index.js",
mode = "development",
html_template = "//public:index.html",
name = "app-bundle-dev",
entry = "index.js",
html_template = "//public:index.html",
lib = "//src",
mode = "development",
)

web_bundle(
name = "app-bundle-prod",
lib = "//src",
entry = "index.js",
mode = "production",
html_template = "//public:index.html",
name = "app-bundle-prod",
entry = "index.js",
html_template = "//public:index.html",
lib = "//src",
mode = "production",
)

npm_packages(
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
)
2 changes: 1 addition & 1 deletion examples/react-app-typescript/public/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports_files([
"index.html",
"index.html",
])
22 changes: 11 additions & 11 deletions examples/react-app-typescript/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "ts_library")

ts_library(
name = "src",
srcs = glob([
"*.ts",
"*.tsx",
"*.css",
"*.svg",
]),
tsconfig = "//:tsconfig.json",
deps = [
"//:packages",
],
name = "src",
srcs = glob([
"*.ts",
"*.tsx",
"*.css",
"*.svg",
]),
tsconfig = "//:tsconfig.json",
deps = [
"//:packages",
],
)
14 changes: 7 additions & 7 deletions examples/react-storybook-typescript/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package(default_visibility = ["//visibility:public"])

load("@bazel_javascript//:defs.bzl", "npm_packages", "js_script")
load("@bazel_javascript//:defs.bzl", "js_script", "npm_packages")

exports_files(["tsconfig.json"])

js_script(
name = "storybook-run",
cmd = "start-storybook -p 9001 -c $LIB_DIR/.storybook",
lib = "//src:storybook",
name = "storybook-run",
cmd = "start-storybook -p 9001 -c $LIB_DIR/.storybook",
lib = "//src:storybook",
)

npm_packages(
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
name = "packages",
package_json = ":package.json",
yarn_lock = ":yarn.lock",
)
52 changes: 26 additions & 26 deletions examples/react-storybook-typescript/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ package(default_visibility = ["//visibility:public"])
load("@bazel_javascript//:defs.bzl", "ts_library")

ts_library(
name = "storybook",
srcs = [
".storybook/config.ts",
],
deps = [
":component_story",
"//:packages",
],
name = "storybook",
srcs = [
".storybook/config.ts",
],
deps = [
":component_story",
"//:packages",
],
)

ts_library(
name = "component_story",
srcs = [
"component.story.tsx",
],
deps = [
":component",
"//:packages",
],
name = "component_story",
srcs = [
"component.story.tsx",
],
deps = [
":component",
"//:packages",
],
)

ts_library(
name = "component",
srcs = [
"component1.tsx",
"component1.css",
"component2.tsx",
"component2.css",
],
deps = [
"//:packages",
],
name = "component",
srcs = [
"component1.css",
"component1.tsx",
"component2.css",
"component2.tsx",
],
deps = [
"//:packages",
],
)
Loading

0 comments on commit 5531dec

Please sign in to comment.