@awarded/log4brains 0.0.0-stage → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,493 @@
1
- # Temporary Holding Version
1
+ # Log4brains <!-- omit in toc -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ <a href="#readme">
5
+ <img src="https://github.com/FreakinWard/log4brains/raw/develop/docs/Log4brains-logo-full.png" alt="Log4brains logo" width="276" />
6
+ </a>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/FreakinWard/log4brains/blob/develop/LICENSE">
11
+ <img src="https://img.shields.io/badge/license-Apache%202-blue" alt="License" />
12
+ </a>
13
+ <a href="https://github.com/FreakinWard/log4brains/actions/workflows/on-merge-to-develop.yml">
14
+ <img src="https://github.com/FreakinWard/log4brains/actions/workflows/on-merge-to-develop.yml/badge.svg" alt="Build Status" />
15
+ </a>
16
+ <a href="https://github.com/FreakinWard/log4brains/releases">
17
+ <img src="https://img.shields.io/npm/v/@awarded/log4brains?label=%40awarded%2Flog4brains" alt="@awarded/log4brains latest version" />
18
+ </a>
19
+ <a href="https://freakinward.github.io/log4brains/adr/">
20
+ <img src="https://freakinward.github.io/log4brains/adr/badge.svg" alt="Log4brains ADRs" />
21
+ </a>
22
+ </p>
23
+
24
+ > **Maintained fork.** This is a community-maintained fork of [thomvaill/log4brains](https://github.com/thomvaill/log4brains), originally created by Thomas Vaillant.
25
+ > It is published to npm as [`@awarded/log4brains`](https://www.npmjs.com/package/@awarded/log4brains). The CLI command is still `log4brains`.
26
+
27
+ Log4brains is a docs-as-code knowledge base for your development and infrastructure projects.
28
+ It enables you to log [Architecture Decision Records](https://adr.github.io/) (ADR) right from your IDE and to publish them automatically as a static website.
29
+
30
+ By logging your decisions chronologically, you will be able to:
31
+
32
+ - Understand past technical decisions and their context
33
+ - Take new decisions with confidence
34
+ - Always have a up-to-date technical documentation and training material available
35
+ - Onboard new developers quicker
36
+ - Set up a collaborative decision process thanks to pull requests
37
+
38
+ <details>
39
+ <summary>Features</summary>
40
+ <p>
41
+
42
+ - Docs-as-code: ADRs are written in markdown, stored in your git repository, close to your code
43
+ - Local preview with Hot Reload
44
+ - Interactive ADR creation from the CLI
45
+ - Static site generation to publish to GitHub/GitLab Pages or S3
46
+ - Timeline menu
47
+ - Searchable
48
+ - ADR metadata automatically guessed from its raw text and git logs
49
+ - No enforced markdown structure: you are free to write however you want
50
+ - No required file numbering schema (i.e., `adr-0001.md`, `adr-0002.md`...): avoids git merge issues
51
+ - Customizable template (default: [MADR](https://adr.github.io/madr/))
52
+ - Multi-package projects support (mono or multi repo): notion of global and package-specific ADRs
53
+
54
+ **Coming soon**:
55
+
56
+ - Local images and diagrams support
57
+ - RSS feed to be notified of new ADRs
58
+ - Decision backlog
59
+ - `@adr` annotation to include code references in ADRs
60
+ - ADR creation/edition from the UI
61
+ - Create a new GitHub/GitLab issue from the UI
62
+ - ... let's [suggest a new feature](https://github.com/FreakinWard/log4brains/issues/new?labels=feature&template=feature.md) if you have other needs!
63
+
64
+ </p>
65
+ </details>
66
+
67
+ <br />
68
+ <p align="center">
69
+ <a href="https://www.youtube.com/watch?v=HDEwOCn9T0w" title="Click to watch the full screencast">
70
+ <img src="https://github.com/FreakinWard/log4brains/raw/develop/docs/demo.gif" alt="Log4brains demo" width="838" />
71
+ </a>
72
+ </p>
73
+ <p align="center"><a href="https://www.youtube.com/watch?v=HDEwOCn9T0w">🎞️ Watch the full screencast</a> - <a href="https://freakinward.github.io/log4brains/adr/">⚡ See an example (Log4brains' own ADRs)</a></p>
74
+
75
+ ## Table of contents <!-- omit in toc -->
76
+
77
+ - [🚀 Getting started](#-getting-started)
78
+ - [🤔 What is an ADR and why should you use them](#-what-is-an-adr-and-why-should-you-use-them)
79
+ - [📨 CI/CD configuration examples](#-cicd-configuration-examples)
80
+ - [❓ FAQ](#-faq)
81
+ - [What are the prerequisites?](#what-are-the-prerequisites)
82
+ - [Is Log4brains only for JS projects?](#is-log4brains-only-for-js-projects)
83
+ - [What about multi-package projects?](#what-about-multi-package-projects)
84
+ - [How to configure `.log4brains.yml`?](#how-to-configure-log4brainsyml)
85
+ - [Is Log4brains also available as a Docker image?](#is-log4brains-also-available-as-a-docker-image)
86
+ - [📣 Your feedback is welcome!](#-your-feedback-is-welcome)
87
+ - [Contributing](#contributing)
88
+ - [Acknowledgments](#acknowledgments)
89
+ - [License](#license)
90
+
91
+ ## 🚀 Getting started
92
+
93
+ We recommend storing your Architecture Decision Records (ADR) next to the source code of your project,
94
+ in the same git repository, to keep them in sync.
95
+
96
+ To get started, run these commands inside your project root folder:
97
+
98
+ ```bash
99
+ npm install -g @awarded/log4brains # if you want to install the latest beta version, run `npm install -g @awarded/log4brains@beta` instead
100
+ log4brains init
101
+ ```
102
+
103
+ It will ask you several questions to get Log4brains properly configured. It will also create the required template files and your first ADR as well.
104
+ Then, you can start the web UI to preview your knowledge base locally:
105
+
106
+ ```bash
107
+ log4brains preview
108
+ ```
109
+
110
+ In this mode, the Hot Reload feature is enabled: any change
111
+ you make to a markdown file from your IDE is applied live.
112
+
113
+ To create a new ADR from your template, run this command:
114
+
115
+ ```bash
116
+ log4brains adr new
117
+ ```
118
+
119
+ Get all the available commands and options by running `log4brains --help`.
120
+
121
+ Finally, do not forget to [set up your CI/CD pipeline](#-cicd-configuration-examples) to automatically publish your knowledge base on a static website service like GitHub/GitLab Pages or S3.
122
+
123
+ ## 🤔 What is an ADR and why should you use them
124
+
125
+ The term ADR became popular in 2011 with Michael Nygard's article: [documenting architecture decisions](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions). He aimed to reconcile Agile methods with software documentation by creating a very concise template
126
+ to record functional or non-functional "architecturally significant" decisions in a lightweight format like markdown.
127
+ The original template had only a few parts:
128
+
129
+ - **Title**: Which sums up the solved problem and its solution
130
+ - **Context**: Probably the essential part, which describes "the forces at play, including technological, political, social, and project local"
131
+ - **Decision**
132
+ - **Status**: Proposed, accepted, deprecated, superseded...
133
+ - **Consequences**: The positive and negative ones for the future of the project
134
+
135
+ There are other ADR templates like [Y-Statements](https://medium.com/olzzio/y-statements-10eb07b5a177) or [MADR](https://adr.github.io/madr/), which is the default one that is shipped with Log4brains.
136
+
137
+ As you can guess from the template above, an ADR is immutable. Only its status can change.
138
+ Thanks to this, your documentation is never out-of-date! Yes, an ADR can be deprecated or superseded by another one, but it was at least true one day!
139
+ And even if it's not the case anymore, it is still a precious piece of information.
140
+
141
+ This leads us to the main goals of this methodology:
142
+
143
+ - Avoid blind acceptance and blind reversal when you face past decisions
144
+ - Speed up the onboarding of new developers on a project
145
+ - Formalize a collaborative decision-making process
146
+
147
+ To learn more on this topic, I recommend you to read these great resources:
148
+
149
+ - [Documenting architecture decisions](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions), by Michael Nygard
150
+ - [ADR GitHub organization](https://adr.github.io/), home of the [MADR](https://adr.github.io/madr/) template, by [Oliver Kopp](https://github.com/koppor/) and [Olaf Zimmermann](https://ozimmer.ch/)
151
+ - [Collection of ADR templates and examples](https://github.com/joelparkerhenderson/architecture_decision_record) by [Joel Parker Henderson](https://github.com/joelparkerhenderson)
152
+
153
+ ## 📨 CI/CD configuration examples
154
+
155
+ Log4brains lets you publish automatically your knowledge base on the static hosting service of your choice, thanks to the `log4brains-web build` command.
156
+ Here are some configuration examples for the most common hosting services / CI runners.
157
+
158
+ <details>
159
+ <summary>Publish to GitHub Pages with GitHub Actions</summary>
160
+ <p>
161
+
162
+ First, create `.github/workflows/publish-log4brains.yml` and adapt it to your case:
163
+
164
+ ```yml
165
+ name: Publish Log4brains
166
+ on:
167
+ push:
168
+ branches:
169
+ - main
170
+ jobs:
171
+ build-and-publish:
172
+ runs-on: ubuntu-latest
173
+ steps:
174
+ - uses: actions/checkout@v4
175
+ with:
176
+ persist-credentials: false # required by JamesIves/github-pages-deploy-action
177
+ fetch-depth: 0 # required by Log4brains to work correctly (needs the whole Git history)
178
+ - uses: actions/setup-node@v4
179
+ with:
180
+ node-version: lts/*
181
+ - name: Install and Build Log4brains
182
+ run: |
183
+ npm install -g @awarded/log4brains
184
+ log4brains build --basePath /${GITHUB_REPOSITORY#*/}/log4brains
185
+ - name: Deploy
186
+ uses: JamesIves/github-pages-deploy-action@3.7.1
187
+ with:
188
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189
+ BRANCH: gh-pages
190
+ FOLDER: .log4brains/out
191
+ TARGET_FOLDER: log4brains
192
+ ```
193
+
194
+ After the first run, this workflow will create a `gh-pages` branch in your repository containing the generated static files to serve.
195
+ Then, we have to tell GitHub that we [don't want to use Jekyll](https://github.com/vercel/next.js/issues/2029), otherwise, you will get a 404 error:
196
+
197
+ ```bash
198
+ git checkout gh-pages
199
+ touch .nojekyll
200
+ git add .nojekyll
201
+ git commit -m "Add .nojekyll for Log4brains"
202
+ git push
203
+ ```
204
+
205
+ Finally, you can [enable your GitHub page](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site):
206
+
207
+ - On GitHub, go to `Settings > GitHub Pages`
208
+ - Select the `gh-pages` branch as the "Source"
209
+ - Then, select the `/ (root)` folder
210
+
211
+ You should now be able to see your knowledge base at `https://<username>.github.io/<repository>/log4brains/`.
212
+ It will be re-built and published every time you push on `main`.
213
+
214
+ </p>
215
+ </details>
216
+
217
+ <details>
218
+ <summary>Publish to GitLab Pages with GitLab CI</summary>
219
+ <p>
220
+
221
+ Create your `.gitlab-ci.yml` and adapt it to your case:
222
+
223
+ ```yml
224
+ image: node:lts-alpine
225
+ pages:
226
+ stage: deploy
227
+ variables:
228
+ GIT_DEPTH: 0 # required by Log4brains to work correctly (needs the whole Git history)
229
+ script:
230
+ - mkdir -p public
231
+ - npm install -g --unsafe-perm @awarded/log4brains
232
+ - log4brains build --basePath /$CI_PROJECT_NAME/log4brains --out public/log4brains
233
+ artifacts:
234
+ paths:
235
+ - public
236
+ rules:
237
+ - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
238
+ ```
239
+
240
+ You should now be able to see your knowledge base at `https://<username>.gitlab.io/<repository>/log4brains/`.
241
+ It will be re-built and published every time you push on `main`.
242
+
243
+ </p>
244
+ </details>
245
+
246
+ <details>
247
+ <summary>Publish to S3</summary>
248
+ <p>
249
+
250
+ First, create a bucket with the "Static website hosting" feature enabled:
251
+
252
+ ```bash
253
+ # This is an example: replace with the bucket name of your choice
254
+ export BUCKET_NAME=yourcompany-yourproject-log4brains
255
+
256
+ aws s3api create-bucket --acl public-read --bucket ${BUCKET_NAME}
257
+ read -r -d '' BUCKET_POLICY << EOP
258
+ {
259
+ "Statement": [
260
+ {
261
+ "Effect": "Allow",
262
+ "Principal": "*",
263
+ "Action": "s3:GetObject",
264
+ "Resource": "arn:aws:s3:::${BUCKET_NAME}/*"
265
+ }
266
+ ]
267
+ }
268
+ EOP
269
+ aws s3api put-bucket-policy --bucket ${BUCKET_NAME} --policy "$BUCKET_POLICY"
270
+ aws s3 website s3://${BUCKET_NAME} --index-document index.html
271
+ ```
272
+
273
+ Then, configure your CI to run these commands:
274
+
275
+ - Install Node and the AWS CLI
276
+ - Checkout your Git repository **with the full history**. Otherwise, Log4brains won't work correctly (see previous examples)
277
+ - `npm install -g @awarded/log4brains`
278
+ - `log4brains build`
279
+ - `aws s3 sync .log4brains/out s3://<YOUR BUCKET> --delete`
280
+
281
+ Your knowledge base will be available on `http://<YOUR BUCKET>.s3-website-<YOUR REGION>.amazonaws.com/`.
282
+ You can get some inspiration on implementing this workflow for GitHub Actions or GitLab CI by looking at the previous examples.
283
+
284
+ </p>
285
+ </details>
286
+
287
+ Finally, you can add the ADR badge to your `README.md`!
288
+
289
+ <table>
290
+ <tbody>
291
+ <tr>
292
+ <td><a href="https://freakinward.github.io/log4brains/adr/"><img src="https://freakinward.github.io/log4brains/adr/badge.svg" alt="Log4brains ADRs" /></a></td>
293
+ <td><code>[![Log4brains ADRs](http://URL-of-your-knowledge-base/badge.svg)](http://URL-of-your-knowledge-base/)</code></td>
294
+ </tr>
295
+ </tbody>
296
+ </table>
297
+
298
+ ## ❓ FAQ
299
+
300
+ ### What are the prerequisites?
301
+
302
+ - Node.js: active or maintenance LTS version (see [Node.js release schedule](https://github.com/nodejs/release#release-schedule); versions outside of this range are not guaranteed to work; "current" version is supported in a best effort mode)
303
+ - NPM or Yarn
304
+ - Git
305
+
306
+ ### Is Log4brains only for JS projects?
307
+
308
+ Of course not! Log4brains is developed with TypeScript and use NPM as a package manager.
309
+ You need Node and NPM to be installed globally to run Log4brains, but it is designed to work for all kind of projects.
310
+
311
+ ### What about multi-package projects?
312
+
313
+ Log4brains supports both mono and multi packages projects. The `log4brains init` command will prompt you regarding this.
314
+
315
+ In the case of a multi-package project, you have two options:
316
+
317
+ - Mono-repository: in this case, just install Log4brains in the root folder. It will manage "global ADRs", for example in `docs/adr` and "package-specific ADRs", for example in `packages/<package name>/docs/adr`.
318
+ - One repository per package: in the future, Log4brains will handle this case with a central repository for the "global ADRs" while fetching "package-specifics ADRs" directly from each package repository. For the moment, all the ADRs have to be stored in a central repository.
319
+
320
+ Here is an example of a typical file structure for each case:
321
+
322
+ <details>
323
+ <summary>Simple mono-package project</summary>
324
+ <p>
325
+
326
+ ```
327
+ project-root
328
+ ├── docs
329
+ | └── adr
330
+ | ├── 20200101-your-first-adr.md
331
+ | ├── 20200115-your-second-adr.md
332
+ | ├── [...]
333
+ | ├── index.md
334
+ | └── template.md
335
+ [...]
336
+ ```
337
+
338
+ </p>
339
+ </details>
340
+
341
+ <details>
342
+ <summary>Multi-package project in a mono-repository</summary>
343
+ <p>
344
+
345
+ ```
346
+ project-root
347
+ ├── docs
348
+ | └── adr
349
+ | ├── 20200101-your-first-global-adr.md
350
+ | ├── 20200115-your-second-global-adr.md
351
+ | ├── [...]
352
+ | ├── index.md
353
+ | └── template.md
354
+ ├── packages
355
+ | ├── package1
356
+ | | ├── docs
357
+ | | | └── adr
358
+ | | | ├── 20200102-your-first-package-specific-adr.md
359
+ | | | ├── 20200116-your-second-package-specific-adr.md
360
+ | | | [...]
361
+ | | [...]
362
+ | ├── package2
363
+ | | ├── docs
364
+ | | | └── adr
365
+ | | | ├── [...]
366
+ | | | [...]
367
+ | | [...]
368
+ | [...]
369
+ [...]
370
+ ```
371
+
372
+ </p>
373
+ </details>
374
+
375
+ <details>
376
+ <summary>Multi-package with one repository per package</summary>
377
+ <p>
378
+
379
+ For the moment in one central repository (specific for the docs, or not):
380
+
381
+ ```
382
+ project-docs
383
+ ├── adr
384
+ | ├── global
385
+ | | ├── 20200101-your-first-global-adr.md
386
+ | | ├── 20200115-your-second-global-adr.md
387
+ | | ├── [...]
388
+ | | ├── index.md
389
+ | | └── template.md
390
+ | ├── package1
391
+ | | ├── 20200102-your-first-package-specific-adr.md
392
+ | | ├── 20200116-your-second-package-specific-adr.md
393
+ | | [...]
394
+ | ├── package2
395
+ | | ├── [...]
396
+ | | [...]
397
+ | [...]
398
+ [...]
399
+ ```
400
+
401
+ In the future:
402
+
403
+ ```
404
+ project-docs
405
+ ├── adr
406
+ | ├── 20200101-your-first-global-adr.md
407
+ | ├── 20200115-your-second-global-adr.md
408
+ | ├── [...]
409
+ | ├── index.md
410
+ | └── template.md
411
+ [...]
412
+
413
+ repo1
414
+ ├── docs
415
+ | └── adr
416
+ | ├── 20200102-your-first-package-specific-adr.md
417
+ | ├── 20200116-your-second-package-specific-adr.md
418
+ | [...]
419
+ [...]
420
+
421
+ repo2
422
+ ├── docs
423
+ | └── adr
424
+ | ├── [...]
425
+ | [...]
426
+ [...]
427
+ ```
428
+
429
+ </p>
430
+ </details>
431
+
432
+ ### How to configure `.log4brains.yml`?
433
+
434
+ This file is automatically created when you run `log4brains init` (cf [getting started](#-getting-started)), but you may need to configure it manually.
435
+
436
+ Here is an example with just the required fields:
437
+
438
+ ```yaml
439
+ project:
440
+ name: Foo Bar # The name that should be displayed in the UI
441
+ tz: Europe/Paris # The timezone that you use for the dates in your ADR files
442
+ adrFolder: ./docs/adr # The location of your ADR files
443
+ ```
444
+
445
+ If you have multiple packages in your project, you may want to support package-specific ADRs by setting the optional `project.packages` field:
446
+
447
+ ```yaml
448
+ project:
449
+ # [...]
450
+ packages:
451
+ - name: backend # The name (unique identifier) of the package
452
+ path: ./packages/backend # The location of its codebase
453
+ adrFolder: ./packages/backend/docs/adr # The location of its ADR files
454
+ # - ...
455
+ ```
456
+
457
+ Another optional field is `project.repository`, which is normally automatically guessed by Log4brains to create links to GitHub, GitLab, etc. But in some cases, like for GitHub or GitLab enterprise, you have to configure it manually:
458
+
459
+ ```yaml
460
+ project:
461
+ # [...]
462
+ repository:
463
+ url: https://github.com/foo/bar # Absolute URL of your repository
464
+ provider: github # Supported providers: github, gitlab, bitbucket. Use `generic` if yours is not supported
465
+ viewFileUriPattern: /blob/%branch/%path # Only required for `generic` providers
466
+ ```
467
+
468
+ ### Is Log4brains also available as a Docker image?
469
+
470
+ Yes! <https://hub.docker.com/r/awarded/log4brains>
471
+
472
+ ## 📣 Your feedback is welcome!
473
+
474
+ I had the idea of Log4brains based on my needs and my past experiences with ADRs, but it is now constantly evolving with your precious feedback.
475
+ You are very welcome to [create a new feedback in the Discussions](https://github.com/FreakinWard/log4brains/discussions/new?category=Feedback). Thanks a lot 🙏
476
+
477
+ ## Contributing
478
+
479
+ Pull Requests are more than welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for more details. You can also [create a new issue](https://github.com/FreakinWard/log4brains/issues/new/choose) or [give your feedback](https://github.com/FreakinWard/log4brains/discussions/new?category=Feedback).
480
+
481
+ ## Acknowledgments
482
+
483
+ - [Next.js](https://github.com/vercel/next.js/), which is used under the hood to provide the web UI and the static site generation capability (look for `#NEXTJS-HACK` in the code to see the custom adaptations we had to make)
484
+ - Michael Nygard for all his work on [Architecture Decision Records](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions)
485
+ - [Oliver Kopp](https://github.com/koppor/) and [Olaf Zimmermann](https://ozimmer.ch/) for the [MADR](https://adr.github.io/madr/) template
486
+ - [Joel Parker Henderson](https://github.com/joelparkerhenderson) for his [Collection of ADR templates and examples](https://github.com/joelparkerhenderson/architecture_decision_record) repository
487
+ - [Tippawan Sookruay](https://thenounproject.com/wanny4/) for the Log4brains logo
488
+ - @npryce, who inspired me for the CLI part with his [adr-tools](https://github.com/npryce/adr-tools) bash CLI
489
+ - @mrwilson, who inspired me for the static site generation part with his [adr-viewer](https://github.com/mrwilson/adr-viewer)
490
+
491
+ ## License
492
+
493
+ This project is licensed under the Apache 2.0 license, Copyright (c) 2020 Thomas Vaillant. See the [LICENSE](LICENSE) file for more information.
package/bin/log4brains ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/index.js";
@@ -0,0 +1,2 @@
1
+
2
+ export { };
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ // src/index.ts
2
+ import { readFileSync } from "fs";
3
+ import chalk from "chalk";
4
+ import { AppConsole, FailureExit } from "@awarded/log4brains-cli-common";
5
+ import { Log4brainsConfigNotFoundError } from "@awarded/log4brains-core";
6
+
7
+ // src/cli.ts
8
+ import { Command } from "commander";
9
+ import { createInitCli } from "@awarded/log4brains-init";
10
+ import { createCli } from "@awarded/log4brains-cli";
11
+ import { createWebCli } from "@awarded/log4brains-web";
12
+ function createGlobalCli({ appConsole: appConsole2, version }) {
13
+ const program = new Command().allowExcessArguments();
14
+ program.version(version).description(
15
+ "Log4brains CLI to preview and build your architecture knowledge base.\nYou can also manage your ADRs from here (see `log4brains adr --help`).\n\nAll the commands should be run from your project's root folder.\n\nAdd the `--help` option to any command to see its detailed documentation."
16
+ );
17
+ const initCli = createInitCli({ appConsole: appConsole2 });
18
+ const cli = createCli({ appConsole: appConsole2 });
19
+ const webCli = createWebCli({ appConsole: appConsole2 });
20
+ [...initCli.commands, ...cli.commands, ...webCli.commands].forEach((cmd) => {
21
+ program.addCommand(cmd);
22
+ });
23
+ return program;
24
+ }
25
+
26
+ // src/index.ts
27
+ var debug = !!process.env.DEBUG;
28
+ var dev = process.env.NODE_ENV === "development";
29
+ var appConsole = new AppConsole({ debug, traces: debug || dev });
30
+ function handleError(err) {
31
+ if (appConsole.isSpinning()) {
32
+ appConsole.stopSpinner(true);
33
+ }
34
+ if (err instanceof FailureExit) {
35
+ process.exit(1);
36
+ }
37
+ if (err instanceof Log4brainsConfigNotFoundError) {
38
+ appConsole.fatal(`Cannot find ${chalk.bold(".log4brains.yml")}`);
39
+ appConsole.printlnErr(
40
+ chalk.red(
41
+ `You are in the wrong directory or you need to run ${chalk.cyan(
42
+ "log4brains init"
43
+ )}`
44
+ )
45
+ );
46
+ process.exit(1);
47
+ }
48
+ appConsole.fatal(err);
49
+ process.exit(1);
50
+ }
51
+ try {
52
+ const pkgVersion = JSON.parse(
53
+ readFileSync(new URL("../package.json", import.meta.url), "utf8")
54
+ ).version;
55
+ const cli = createGlobalCli({ version: pkgVersion, appConsole });
56
+ cli.parseAsync(process.argv).catch(handleError);
57
+ } catch (e) {
58
+ handleError(e);
59
+ }
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/cli.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\nimport chalk from \"chalk\";\nimport { AppConsole, FailureExit } from \"@awarded/log4brains-cli-common\";\nimport { Log4brainsConfigNotFoundError } from \"@awarded/log4brains-core\";\nimport { createGlobalCli } from \"./cli\";\n\nconst debug = !!process.env.DEBUG;\nconst dev = process.env.NODE_ENV === \"development\";\nconst appConsole = new AppConsole({ debug, traces: debug || dev });\n\nfunction handleError(err: unknown): void {\n if (appConsole.isSpinning()) {\n appConsole.stopSpinner(true);\n }\n\n if (err instanceof FailureExit) {\n process.exit(1);\n }\n\n if (err instanceof Log4brainsConfigNotFoundError) {\n appConsole.fatal(`Cannot find ${chalk.bold(\".log4brains.yml\")}`);\n appConsole.printlnErr(\n chalk.red(\n `You are in the wrong directory or you need to run ${chalk.cyan(\n \"log4brains init\"\n )}`\n )\n );\n process.exit(1);\n }\n\n appConsole.fatal(err as Error);\n process.exit(1);\n}\n\ntry {\n const pkgVersion = (\n JSON.parse(\n readFileSync(new URL(\"../package.json\", import.meta.url), \"utf8\")\n ) as { version: string }\n ).version;\n\n const cli = createGlobalCli({ version: pkgVersion, appConsole });\n cli.parseAsync(process.argv).catch(handleError);\n} catch (e) {\n handleError(e);\n}\n","import { Command } from \"commander\";\nimport type { AppConsole } from \"@awarded/log4brains-cli-common\";\nimport { createInitCli } from \"@awarded/log4brains-init\";\nimport { createCli } from \"@awarded/log4brains-cli\";\nimport { createWebCli } from \"@awarded/log4brains-web\";\n\ntype Deps = {\n appConsole: AppConsole;\n version: string;\n};\n\nexport function createGlobalCli({ appConsole, version }: Deps): Command {\n const program = new Command().allowExcessArguments(); // commander >=13 rejects extra arguments; keep the previous lenient behavior\n program\n .version(version)\n .description(\n \"Log4brains CLI to preview and build your architecture knowledge base.\\n\" +\n \"You can also manage your ADRs from here (see `log4brains adr --help`).\\n\\n\" +\n \"All the commands should be run from your project's root folder.\\n\\n\" +\n \"Add the `--help` option to any command to see its detailed documentation.\"\n );\n\n const initCli = createInitCli({ appConsole });\n const cli = createCli({ appConsole });\n const webCli = createWebCli({ appConsole });\n\n [...initCli.commands, ...cli.commands, ...webCli.commands].forEach((cmd) => {\n program.addCommand(cmd);\n });\n\n return program;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAClB,SAAS,YAAY,mBAAmB;AACxC,SAAS,qCAAqC;;;ACH9C,SAAS,eAAe;AAExB,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAOtB,SAAS,gBAAgB,EAAE,YAAAA,aAAY,QAAQ,GAAkB;AACtE,QAAM,UAAU,IAAI,QAAQ,EAAE,qBAAqB;AACnD,UACG,QAAQ,OAAO,EACf;AAAA,IACC;AAAA,EAIF;AAEF,QAAM,UAAU,cAAc,EAAE,YAAAA,YAAW,CAAC;AAC5C,QAAM,MAAM,UAAU,EAAE,YAAAA,YAAW,CAAC;AACpC,QAAM,SAAS,aAAa,EAAE,YAAAA,YAAW,CAAC;AAE1C,GAAC,GAAG,QAAQ,UAAU,GAAG,IAAI,UAAU,GAAG,OAAO,QAAQ,EAAE,QAAQ,CAAC,QAAQ;AAC1E,YAAQ,WAAW,GAAG;AAAA,EACxB,CAAC;AAED,SAAO;AACT;;;ADzBA,IAAM,QAAQ,CAAC,CAAC,QAAQ,IAAI;AAC5B,IAAM,MAAM,QAAQ,IAAI,aAAa;AACrC,IAAM,aAAa,IAAI,WAAW,EAAE,OAAO,QAAQ,SAAS,IAAI,CAAC;AAEjE,SAAS,YAAY,KAAoB;AACvC,MAAI,WAAW,WAAW,GAAG;AAC3B,eAAW,YAAY,IAAI;AAAA,EAC7B;AAEA,MAAI,eAAe,aAAa;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,eAAe,+BAA+B;AAChD,eAAW,MAAM,eAAe,MAAM,KAAK,iBAAiB,CAAC,EAAE;AAC/D,eAAW;AAAA,MACT,MAAM;AAAA,QACJ,qDAAqD,MAAM;AAAA,UACzD;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,aAAW,MAAM,GAAY;AAC7B,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI;AACF,QAAM,aACJ,KAAK;AAAA,IACH,aAAa,IAAI,IAAI,mBAAmB,YAAY,GAAG,GAAG,MAAM;AAAA,EAClE,EACA;AAEF,QAAM,MAAM,gBAAgB,EAAE,SAAS,YAAY,WAAW,CAAC;AAC/D,MAAI,WAAW,QAAQ,IAAI,EAAE,MAAM,WAAW;AAChD,SAAS,GAAG;AACV,cAAY,CAAC;AACf;","names":["appConsole"]}
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@awarded/log4brains",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0-beta.0",
4
+ "description": "Log and publish your architecture decisions (ADR) with Log4brains",
5
+ "keywords": [
6
+ "log4brains",
7
+ "architecture decision records",
8
+ "adr",
9
+ "architecture",
10
+ "knowledge base",
11
+ "documentation",
12
+ "docs-as-code",
13
+ "markdown",
14
+ "static site generator",
15
+ "documentation generator",
16
+ "tooling"
17
+ ],
18
+ "author": "Thomas Vaillant <thomvaill@bluebricks.dev>",
19
+ "license": "Apache-2.0",
20
+ "private": false,
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "homepage": "https://github.com/FreakinWard/log4brains",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/FreakinWard/log4brains",
28
+ "directory": "packages/global-cli"
29
+ },
30
+ "engines": {
31
+ "node": "^22.22.2 || >=24.15.0"
32
+ },
33
+ "files": [
34
+ "bin",
35
+ "dist"
36
+ ],
37
+ "source": "./src/index.ts",
38
+ "main": "./dist/index.js",
39
+ "type": "module",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
+ }
45
+ },
46
+ "types": "./dist/index.d.ts",
47
+ "bin": {
48
+ "log4brains": "./bin/log4brains"
49
+ },
50
+ "scripts": {
51
+ "dev": "tsup --watch",
52
+ "build": "tsup",
53
+ "clean": "rimraf ./dist",
54
+ "typescript": "tsc --noEmit",
55
+ "lint": "eslint . --max-warnings=0",
56
+ "prepublishOnly": "cp ../../README.md . && npm run build",
57
+ "link": "npm link",
58
+ "unlink": "npm unlink"
59
+ },
60
+ "dependencies": {
61
+ "@awarded/log4brains-cli": "2.0.0-beta.0",
62
+ "@awarded/log4brains-cli-common": "2.0.0-beta.0",
63
+ "@awarded/log4brains-core": "2.0.0-beta.0",
64
+ "@awarded/log4brains-init": "2.0.0-beta.0",
65
+ "@awarded/log4brains-web": "2.0.0-beta.0",
66
+ "chalk": "^6.0.1",
67
+ "commander": "^15.1.0"
68
+ }
69
+ }