Skip to content

Commit

Permalink
feat: add ibazel and prettier fmt (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored May 11, 2024
1 parent 20f84ad commit cdc17b0
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 17 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# Scaffold for basic Aspect Build workspace
# Scaffold for basic Aspect Workflows project

Create a new project from scratch on macos:

```shell
% brew install scaffold
% scaffold new https://github.com/alexeagle/aspect-workflows-template.git
```
28 changes: 15 additions & 13 deletions scaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
messages:
pre: |
# Welcome to Aspect
# Welcome to Aspect, the multi-language monorepo dev platform
Generate boilerplate code for a new Bazel project using Aspect CLI and Aspect Workflows.
post: |
# Get Started
# Next Steps
1. Read the developer guide in {{ .ProjectSnake }}/README.bazel.md
2. Try out some commands, such as:
```sh
cd {{ .ProjectSnake }}
1. `cd {{ .ProjectSnake }}`, or open that folder in your editor.
2. Read the developer guide in `/README.bazel.md`.
3. Try out some commands, such as:
{{- if .Scaffold.lint }}
aspect run format
- Format: `aspect run format`
- Lint: `aspect lint ...`
{{- end }}
aspect test ...
```
- Run all tests: `aspect test ...`
- Watch mode: `./tools/ibazel run //my:devserver`
4. Add source code and run `aspect configure` to create
additional `BUILD.bazel` files.
questions:
- name: lint
prompt:
confirm: "Setup format and linting?"
- name: langs
prompt:
multi: true
message: "Languages to be used in the project"
options:
- JavaScript & TypeScript
- Python
- name: lint
prompt:
confirm: "Setup format and linting?"

features:
- value: "{{ .Scaffold.lint }}"
Expand Down
8 changes: 8 additions & 0 deletions {{ .ProjectSnake }}/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import %workspace%/.aspect/bazelrc/performance.bazelrc

### YOUR PROJECT SPECIFIC OPTIONS GO HERE ###

{{ if eq .Computed.javascript "true" }}
# for speed, passes an argument `--skipLibCheck` to *every* spawn of tsc
common --@aspect_rules_ts//ts:skipLibCheck=always
# use `tsc` for transpiling, even though it's slow.
# TODO(alex): change to SWC by default
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
{{ end }}

# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
# should be last statement in this config so the user configuration is able to overwrite flags from
Expand Down
4 changes: 4 additions & 0 deletions {{ .ProjectSnake }}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ MODULE.bazel.lock

# Symlinks created by Bazel into the output tree
/bazel-*

{{ if eq .Computed.javascript "true" }}
node_modules/
{{ end }}
2 changes: 1 addition & 1 deletion {{ .ProjectSnake }}/README.bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For developers to be able to run a CLI tool without needing manual installation:

See https://blog.aspect.build/run-tools-installed-by-bazel for details.

{{- if eq .Computed.javascript "true" }}
{{ if eq .Computed.javascript "true" }}
## Working with npm packages

To install a `node_modules` tree locally for the editor or other tooling outside of Bazel:
Expand Down
17 changes: 16 additions & 1 deletion {{ .ProjectSnake }}/tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ we don't want to trigger eager fetches of these for builds that don't want to ru
"""

load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
{{ if eq .Computed.javascript "true" }}
load("@npm//:prettier/package_json.bzl", prettier = "bin")
{{ end }}

package(default_visibility = ["//:__subpackages__"])

format_multirun(name = "format")
{{ if eq .Computed.javascript "true" }}
prettier.prettier_binary(
name = "prettier",
env = {"BAZEL_BINDIR": "."},
)
{{ end }}

format_multirun(
name = "format",
{{ if eq .Computed.javascript "true" }}
javascript = ":prettier",
{{ end }}
)
1 change: 1 addition & 0 deletions {{ .ProjectSnake }}/tools/ibazel
27 changes: 26 additions & 1 deletion {{ .ProjectSnake }}/tools/tools.lock.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/theoremlp/rules_multitool/main/lockfile.schema.json"
"$schema": "https://raw.githubusercontent.com/theoremlp/rules_multitool/main/lockfile.schema.json",
"ibazel": {
"binaries": [
{
"kind": "file",
"url": "https://github.com/bazelbuild/bazel-watcher/releases/download/v0.25.2/ibazel_darwin_arm64",
"os": "macos",
"cpu": "arm64",
"sha256": "e4d5e04a2a0e4dda21350ffe26623469a85ab8786570aea962b058a954dcd3f1"
},
{
"kind": "file",
"url": "https://github.com/bazelbuild/bazel-watcher/releases/download/v0.25.2/ibazel_linux_amd64",
"os": "linux",
"cpu": "x86_64",
"sha256": "1377caf887a7a239106ad6408fca1e14dfb239b3072b3abddbb660ff994b62aa"
},
{
"kind": "file",
"url": "https://github.com/bazelbuild/bazel-watcher/releases/download/v0.25.2/ibazel_linux_arm64",
"os": "linux",
"cpu": "arm64",
"sha256": "3c15af15ffe77f7c4ed799a6a7c539541922a4811b8b9f4fbac044060ef89b64"
}
]
}
}

0 comments on commit cdc17b0

Please sign in to comment.