Skip to content

Commit 35f2cab

Browse files
alexeaglejbedard
authored andcommitted
docs: start of docs for configure (#1094)
Co-authored-by: Jason Bedard <jason@aspect.dev> GitOrigin-RevId: 46a28e0d5d104e5638c70c209ebc60e890c05dbb
1 parent 4ea4abe commit 35f2cab

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

cmd/aspect/configure/configure.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,26 @@ func NewCmd(streams ioutils.Streams, languages map[string]language.Language) *co
3434
v := configure.New(streams, languages)
3535

3636
cmd := &cobra.Command{
37-
Use: "configure",
38-
Short: "Update BUILD files for JavaScript, TypeScript, Go and Protobuf",
39-
Long: "Generates and updates BUILD files from sources for JavaScript, TypeScript, Go and Protobuf.",
37+
Use: "configure",
38+
Short: "Auto-configure Bazel by updating BUILD files",
39+
Long: `configure generates and updates BUILD files from source code.
40+
41+
It is named after the "make configure" workflow which is typical in C++ projects, using
42+
[autoconf](https://www.gnu.org/software/autoconf/).
43+
44+
configure is non-destructive: hand-edits to BUILD files are generally preserved.
45+
You can use a ` + "`#keep`" + ` directive to force the tool to leave existing BUILD contents alone.
46+
Run 'aspect help directives' for more documentation on directives.
47+
48+
So far these languages are supported:
49+
- Go and Protocol Buffers, thanks to code from [gazelle]
50+
- JavaScript (including TypeScript)
51+
52+
configure is based on [gazelle]. We are very grateful to the authors of that software.
53+
The advantage of configure in Aspect CLI is that you don't need to compile the tooling before running it.
54+
55+
[gazelle]: https://github.com/bazelbuild/bazel-gazelle
56+
`,
4057
GroupID: "aspect",
4158
RunE: interceptors.Run(
4259
[]interceptors.Interceptor{

cmd/aspect/root/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ func NewCmd(
154154
Short: "Conventions for tags which are special.",
155155
Long: mustReadFile("tags.md"),
156156
})
157+
cmd.AddCommand(&cobra.Command{
158+
Use: "directives",
159+
Short: "Special comments in BUILD files which instruct Aspect CLI behaviors",
160+
Long: mustReadFile("directives.md"),
161+
})
157162

158163
return cmd
159164
}

docs/help/topics/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go_library(
44
name = "topics",
55
srcs = ["doc.go"],
66
embedsrcs = [
7+
"directives.md",
78
"info-keys.md",
89
"tags.md",
910
"target-syntax.md",

docs/help/topics/directives.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Directives
2+
3+
You can configure Aspect CLI using directives, which are just specially-formatted
4+
comments in `BUILD` files that govern behavior of the tool when visiting files
5+
within the Bazel package rooted at that file.
6+
7+
## JavaScript
8+
9+
JavaScript directives follow the same format as [gazelle](https://github.com/bazelbuild/bazel-gazelle#directives).
10+
11+
Directives specific to JavaScript (and TypeScript) are as follows:
12+
13+
| **Directive** | **Default value** | **Param(s)** |
14+
| ------------------------------- | --------------------------- | ------------------- |
15+
| `js` | `enabled` | `enabled\|disabled` |
16+
| `js_generation_mode` | `directory` | `none\|directory` |
17+
| `js_pnpm_lockfile` | `pnpm-lock.yaml` | _lockfile_ |
18+
| `js_ignore_imports` | | _glob_ |
19+
| `js_resolve` | | _glob_ _target_ |
20+
| `js_validate_import_statements` | `true` | `true\|false` |
21+
| `js_project_naming_convention` | `$package_name$` | _name_ |
22+
| `js_tests_naming_convention` | `$package_name$_tests` | _name_ |
23+
| `js_files` | `**/*.{ts,tsx}` | _glob_ |
24+
| `js_test_files` | `**/*.{spec,test}.{ts,tsx}` | _glob_ |
25+
26+
All JavaScript directives are specified via `gazelle` such as:
27+
28+
```
29+
# gazelle:js enabled
30+
```

0 commit comments

Comments
 (0)