@awarded/log4brains-init 0.0.0-stage → 2.0.0-beta.1

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,14 @@
1
- # Temporary Holding Version
1
+ # @awarded/log4brains-init
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
+ This package provides the initialization script of the [Log4brains](https://github.com/FreakinWard/log4brains) architecture knowledge base.
4
+ It is not meant to be used directly.
5
+
6
+ Install [the main log4brains package](https://www.npmjs.com/package/log4brains) instead:
7
+
8
+ ```bash
9
+ npm install -g @awarded/log4brains
10
+ ```
11
+
12
+ ## Documentation
13
+
14
+ - [Log4brains README](https://github.com/FreakinWard/log4brains/blob/develop/README.md)
@@ -0,0 +1,35 @@
1
+ # Architecture Decision Records
2
+
3
+ ADRs are automatically published to our Log4brains architecture knowledge base:
4
+
5
+ 🔗 **<http://INSERT-YOUR-LOG4BRAINS-URL>**
6
+
7
+ Please use this link to browse them.
8
+
9
+ ## Development
10
+
11
+ If not already done, install Log4brains:
12
+
13
+ ```bash
14
+ npm install -g @awarded/log4brains
15
+ ```
16
+
17
+ To preview the knowledge base locally, run:
18
+
19
+ ```bash
20
+ log4brains preview
21
+ ```
22
+
23
+ In preview mode, the Hot Reload feature is enabled: any change you make to a markdown file is applied live in the UI.
24
+
25
+ To create a new ADR interactively, run:
26
+
27
+ ```bash
28
+ log4brains adr new
29
+ ```
30
+
31
+ ## More information
32
+
33
+ - [Log4brains documentation](https://github.com/FreakinWard/log4brains/tree/develop#readme)
34
+ - [What is an ADR and why should you use them](https://github.com/FreakinWard/log4brains/tree/develop#-what-is-an-adr-and-why-should-you-use-them)
35
+ - [ADR GitHub organization](https://adr.github.io/)
@@ -0,0 +1,36 @@
1
+ <!-- This file is the homepage of your Log4brains knowledge base. You are free to edit it as you want -->
2
+
3
+ # Architecture knowledge base
4
+
5
+ Welcome 👋 to the architecture knowledge base of {PROJECT_NAME}.
6
+ You will find here all the Architecture Decision Records (ADR) of the project.
7
+
8
+ ## Definition and purpose
9
+
10
+ > An Architectural Decision (AD) is a software design choice that addresses a functional or non-functional requirement that is architecturally significant.
11
+ > An Architectural Decision Record (ADR) captures a single AD, such as often done when writing personal notes or meeting minutes; the collection of ADRs created and maintained in a project constitutes its decision log.
12
+
13
+ An ADR is immutable: only its status can change (i.e., become deprecated or superseded). That way, you can become familiar with the whole project history just by reading its decision log in chronological order.
14
+ Moreover, maintaining this documentation aims at:
15
+
16
+ - 🚀 Improving and speeding up the onboarding of a new team member
17
+ - 🔭 Avoiding blind acceptance/reversal of a past decision (cf [Michael Nygard's famous article on ADRs](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions.html))
18
+ - 🤝 Formalizing the decision process of the team
19
+
20
+ ## Usage
21
+
22
+ This website is automatically updated after a change on the `main` branch of the project's Git repository.
23
+ In fact, the developers manage this documentation directly with markdown files located next to their code, so it is more convenient for them to keep it up-to-date.
24
+ You can browse the ADRs by using the left menu or the search bar.
25
+
26
+ The typical workflow of an ADR is the following:
27
+
28
+ ![ADR workflow](/l4b-static/adr-workflow.png)
29
+
30
+ The decision process is entirely collaborative and backed by pull requests.
31
+
32
+ ## More information
33
+
34
+ - [Log4brains documentation](https://github.com/FreakinWard/log4brains/tree/develop#readme)
35
+ - [What is an ADR and why should you use them](https://github.com/FreakinWard/log4brains/tree/develop#-what-is-an-adr-and-why-should-you-use-them)
36
+ - [ADR GitHub organization](https://adr.github.io/)
@@ -0,0 +1,73 @@
1
+ # [short title of solved problem and solution]
2
+
3
+ - Status: [draft | proposed | rejected | accepted | deprecated | … | superseded by [xxx](yyyymmdd-xxx.md)] <!-- optional -->
4
+ - Deciders: [list everyone involved in the decision] <!-- optional -->
5
+ - Date: [YYYY-MM-DD when the decision was last updated] <!-- optional. To customize the ordering without relying on Git creation dates and filenames -->
6
+ - Tags: [space and/or comma separated list of tags] <!-- optional -->
7
+
8
+ Technical Story: [description | ticket/issue URL] <!-- optional -->
9
+
10
+ ## Context and Problem Statement
11
+
12
+ [Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]
13
+
14
+ ## Decision Drivers <!-- optional -->
15
+
16
+ - [driver 1, e.g., a force, facing concern, …]
17
+ - [driver 2, e.g., a force, facing concern, …]
18
+ - … <!-- numbers of drivers can vary -->
19
+
20
+ ## Considered Options
21
+
22
+ - [option 1]
23
+ - [option 2]
24
+ - [option 3]
25
+ - … <!-- numbers of options can vary -->
26
+
27
+ ## Decision Outcome
28
+
29
+ Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)].
30
+
31
+ ### Positive Consequences <!-- optional -->
32
+
33
+ - [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
34
+ - …
35
+
36
+ ### Negative Consequences <!-- optional -->
37
+
38
+ - [e.g., compromising quality attribute, follow-up decisions required, …]
39
+ - …
40
+
41
+ ## Pros and Cons of the Options <!-- optional -->
42
+
43
+ ### [option 1]
44
+
45
+ [example | description | pointer to more information | …] <!-- optional -->
46
+
47
+ - Good, because [argument a]
48
+ - Good, because [argument b]
49
+ - Bad, because [argument c]
50
+ - … <!-- numbers of pros and cons can vary -->
51
+
52
+ ### [option 2]
53
+
54
+ [example | description | pointer to more information | …] <!-- optional -->
55
+
56
+ - Good, because [argument a]
57
+ - Good, because [argument b]
58
+ - Bad, because [argument c]
59
+ - … <!-- numbers of pros and cons can vary -->
60
+
61
+ ### [option 3]
62
+
63
+ [example | description | pointer to more information | …] <!-- optional -->
64
+
65
+ - Good, because [argument a]
66
+ - Good, because [argument b]
67
+ - Bad, because [argument c]
68
+ - … <!-- numbers of pros and cons can vary -->
69
+
70
+ ## Links <!-- optional -->
71
+
72
+ - [Link type](link to adr) <!-- example: Refined by [xxx](yyyymmdd-xxx.md) -->
73
+ - … <!-- numbers of links can vary -->
@@ -0,0 +1,22 @@
1
+ # Use Log4brains to manage the ADRs
2
+
3
+ - Status: accepted
4
+ - Date: {DATE_YESTERDAY}
5
+ - Tags: dev-tools, doc
6
+
7
+ ## Context and Problem Statement
8
+
9
+ We want to record architectural decisions made in this project.
10
+ Which tool(s) should we use to manage these records?
11
+
12
+ ## Considered Options
13
+
14
+ - [Log4brains](https://github.com/FreakinWard/log4brains): architecture knowledge base (command-line + static site generator)
15
+ - [ADR Tools](https://github.com/npryce/adr-tools): command-line to create ADRs
16
+ - [ADR Tools Python](https://bitbucket.org/tinkerer_/adr-tools-python/src/master/): command-line to create ADRs
17
+ - [adr-viewer](https://github.com/mrwilson/adr-viewer): static site generator
18
+ - [adr-log](https://adr.github.io/adr-log/): command-line to create a TOC of ADRs
19
+
20
+ ## Decision Outcome
21
+
22
+ Chosen option: "Log4brains", because it includes the features of all the other tools, and even more.
@@ -0,0 +1,42 @@
1
+ # Use Markdown Architectural Decision Records
2
+
3
+ - Status: accepted
4
+ - Date: {DATE_YESTERDAY}
5
+ - Tags: doc
6
+
7
+ ## Context and Problem Statement
8
+
9
+ We want to record architectural decisions made in this project.
10
+ Which format and structure should these records follow?
11
+
12
+ ## Considered Options
13
+
14
+ - [MADR](https://adr.github.io/madr/) 2.1.2 with Log4brains patch
15
+ - [MADR](https://adr.github.io/madr/) 2.1.2 – The original Markdown Architectural Decision Records
16
+ - [Michael Nygard's template](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions) – The first incarnation of the term "ADR"
17
+ - [Sustainable Architectural Decisions](https://www.infoq.com/articles/sustainable-architectural-design-decisions) – The Y-Statements
18
+ - Other templates listed at <https://github.com/joelparkerhenderson/architecture_decision_record>
19
+ - Formless – No conventions for file format and structure
20
+
21
+ ## Decision Outcome
22
+
23
+ Chosen option: "MADR 2.1.2 with Log4brains patch", because
24
+
25
+ - Implicit assumptions should be made explicit.
26
+ Design documentation is important to enable people understanding the decisions later on.
27
+ See also [A rational design process: How and why to fake it](https://doi.org/10.1109/TSE.1986.6312940).
28
+ - The MADR format is lean and fits our development style.
29
+ - The MADR structure is comprehensible and facilitates usage & maintenance.
30
+ - The MADR project is vivid.
31
+ - Version 2.1.2 is the latest one available when starting to document ADRs.
32
+ - The Log4brains patch adds more features, like tags.
33
+
34
+ The "Log4brains patch" performs the following modifications to the original template:
35
+
36
+ - Change the ADR filenames format (`NNN-adr-name` becomes `YYYYMMDD-adr-name`), to avoid conflicts during Git merges.
37
+ - Add a `draft` status, to enable collaborative writing.
38
+ - Add a `Tags` field.
39
+
40
+ ## Links
41
+
42
+ - Relates to [Use Log4brains to manage the ADRs]({LOG4BRAINS_ADR_SLUG}.md)
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ import { AppConsole } from '@awarded/log4brains-cli-common';
3
+
4
+ type Deps = {
5
+ appConsole: AppConsole;
6
+ };
7
+ declare function createInitCli({ appConsole }: Deps): Command;
8
+
9
+ export { createInitCli };
package/dist/index.js ADDED
@@ -0,0 +1,334 @@
1
+ // src/cli.ts
2
+ import { Command } from "commander";
3
+
4
+ // src/commands/InitCommand.ts
5
+ import fs, { promises as fsP2 } from "fs";
6
+ import terminalLink from "terminal-link";
7
+ import chalk from "chalk";
8
+ import { execa } from "execa";
9
+ import yaml from "yaml";
10
+ import path from "path";
11
+ import { fileURLToPath } from "url";
12
+ import moment from "moment-timezone";
13
+ import { FailureExit } from "@awarded/log4brains-cli-common";
14
+
15
+ // src/utils.ts
16
+ import { promises as fsP } from "fs";
17
+ function escapeRegExp(str) {
18
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19
+ }
20
+ function replaceAll(str, search, replacement) {
21
+ return str.replace(new RegExp(escapeRegExp(search), "g"), replacement);
22
+ }
23
+ async function replaceAllInFile(path2, replacements) {
24
+ let content = await fsP.readFile(path2, "utf-8");
25
+ content = replacements.reduce((prevContent, replacement) => {
26
+ return replaceAll(prevContent, replacement[0], replacement[1]);
27
+ }, content);
28
+ await fsP.writeFile(path2, content, "utf-8");
29
+ }
30
+
31
+ // src/commands/InitCommand.ts
32
+ var assetsPath = fileURLToPath(new URL("../assets", import.meta.url));
33
+ var docLink = "https://github.com/FreakinWard/log4brains";
34
+ function forceUnixPath(p) {
35
+ return p.replace(/\\/g, "/");
36
+ }
37
+ var InitCommand = class {
38
+ constructor({ appConsole }) {
39
+ this.console = appConsole;
40
+ }
41
+ guessMainAdrFolderPath(cwd) {
42
+ const usualPaths = [
43
+ "./docs/adr",
44
+ "./docs/adrs",
45
+ "./docs/architecture-decisions",
46
+ "./doc/adr",
47
+ "./doc/adrs",
48
+ "./doc/architecture-decisions",
49
+ "./adr",
50
+ "./adrs",
51
+ "./architecture-decisions"
52
+ ];
53
+ for (const possiblePath of usualPaths) {
54
+ if (fs.existsSync(path.join(cwd, possiblePath))) {
55
+ return possiblePath;
56
+ }
57
+ }
58
+ return void 0;
59
+ }
60
+ // eslint-disable-next-line sonarjs/cognitive-complexity
61
+ async buildLog4brainsConfigInteractively(cwd, noInteraction) {
62
+ this.console.println(chalk.bold("\u{1F44B} Welcome to Log4brains!"));
63
+ this.console.println();
64
+ this.console.println(
65
+ "This interactive script will help you configure Log4brains for your project."
66
+ );
67
+ this.console.println(
68
+ `It will create the ${chalk.cyan(".log4brains.yml")} config file,`
69
+ );
70
+ this.console.println(" copy the default ADR template,");
71
+ this.console.println(" and create your first ADR for you!");
72
+ this.console.println();
73
+ this.console.println(
74
+ "Before going further, please check that you are running this command"
75
+ );
76
+ this.console.println(
77
+ "from the root folder of your project's git repository:"
78
+ );
79
+ this.console.println(chalk.cyan(cwd));
80
+ if (!noInteraction && !await this.console.askYesNoQuestion("Continue?", true)) {
81
+ process.exit(0);
82
+ }
83
+ this.console.println();
84
+ this.console.println(
85
+ "\u{1F44D} We will now ask you several questions to get you started:"
86
+ );
87
+ let name;
88
+ try {
89
+ const pkg = JSON.parse(
90
+ fs.readFileSync(path.join(cwd, "package.json"), "utf-8")
91
+ );
92
+ if (typeof pkg === "object" && pkg !== null && "name" in pkg && typeof pkg.name === "string") {
93
+ name = pkg.name;
94
+ }
95
+ } catch (e) {
96
+ }
97
+ name = noInteraction ? name || "untitled" : await this.console.askInputQuestionAndValidate(
98
+ "What is the name of your project?",
99
+ (answer) => !!answer.trim(),
100
+ name
101
+ );
102
+ const type = noInteraction ? "mono" : await this.console.askListQuestion(
103
+ "Which statement describes the best your project?",
104
+ [
105
+ {
106
+ name: "Simple project (only one ADR folder)",
107
+ value: "mono",
108
+ short: "Mono-package project"
109
+ },
110
+ {
111
+ name: "Multi-package project (one ADR folder per package + a global one)",
112
+ value: "multi",
113
+ short: "Multi-package project"
114
+ }
115
+ ]
116
+ );
117
+ let adrFolder = this.guessMainAdrFolderPath(cwd);
118
+ if (adrFolder) {
119
+ this.console.println();
120
+ this.console.println(
121
+ `${chalk.blue.bold(
122
+ "i We have detected a folder with existing ADRs:"
123
+ )} ${chalk.cyan(adrFolder)}`
124
+ );
125
+ adrFolder = noInteraction || await this.console.askYesNoQuestion(
126
+ "Do you want to use it? (existing ADRs will be kept)",
127
+ true
128
+ ) ? adrFolder : void 0;
129
+ }
130
+ if (!adrFolder) {
131
+ adrFolder = noInteraction ? "./docs/adr" : await this.console.askInputQuestionAndValidate(
132
+ `In which directory do you plan to store your ${type === "multi" ? "global " : ""}ADRs? (will be automatically created)`,
133
+ (answer) => !!answer.trim(),
134
+ "./docs/adr"
135
+ );
136
+ }
137
+ await fsP2.mkdir(path.join(cwd, adrFolder), { recursive: true });
138
+ this.console.println();
139
+ const packages = [];
140
+ if (type === "multi") {
141
+ this.console.println("We will now define your packages...");
142
+ this.console.println();
143
+ let oneMorePackage = false;
144
+ let packageNumber = 1;
145
+ do {
146
+ this.console.println();
147
+ this.console.println(
148
+ ` ${chalk.underline(`Package #${packageNumber}`)}:`
149
+ );
150
+ const pkgName = await this.console.askInputQuestionAndValidate(
151
+ "Name? (short, lowercase, without special characters, nor spaces)",
152
+ (answer) => !!answer.trim()
153
+ );
154
+ const pkgCodeFolder = await this.askPathWhileNotFound(
155
+ "Where is the source code of this package located?",
156
+ cwd,
157
+ `./packages/${pkgName}`
158
+ );
159
+ const pkgAdrFolder = await this.console.askInputQuestionAndValidate(
160
+ `In which directory do you plan to store the ADRs of this package? (will be automatically created)`,
161
+ (answer) => !!answer.trim(),
162
+ `${pkgCodeFolder}/docs/adr`
163
+ );
164
+ await fsP2.mkdir(path.join(cwd, pkgAdrFolder), { recursive: true });
165
+ packages.push({
166
+ name: pkgName,
167
+ path: forceUnixPath(pkgCodeFolder),
168
+ adrFolder: forceUnixPath(pkgAdrFolder)
169
+ });
170
+ oneMorePackage = await this.console.askYesNoQuestion(
171
+ `We are done with package #${packageNumber}. Do you want to add another one?`,
172
+ false
173
+ );
174
+ packageNumber += 1;
175
+ } while (oneMorePackage);
176
+ }
177
+ return {
178
+ project: {
179
+ name,
180
+ tz: moment.tz.guess(),
181
+ adrFolder: forceUnixPath(adrFolder),
182
+ packages
183
+ }
184
+ };
185
+ }
186
+ async createAdr(cwd, adrFolder, title, source, replacements = []) {
187
+ const slug = (await execa(
188
+ "log4brains",
189
+ [
190
+ "adr",
191
+ "new",
192
+ "--quiet",
193
+ "--from",
194
+ forceUnixPath(path.join(assetsPath, source)),
195
+ `"${title}"`
196
+ ],
197
+ { cwd }
198
+ )).stdout;
199
+ await replaceAllInFile(
200
+ forceUnixPath(path.join(cwd, adrFolder, `${slug}.md`)),
201
+ [
202
+ ["{DATE_YESTERDAY}", moment().subtract(1, "days").format("YYYY-MM-DD")],
203
+ // we use yesterday's date so that we are sure new ADRs will appear on top
204
+ ...replacements
205
+ ]
206
+ );
207
+ return slug;
208
+ }
209
+ async copyFileIfAbsent(cwd, adrFolder, filename, contentCb) {
210
+ const outPath = path.join(cwd, adrFolder, filename);
211
+ if (!fs.existsSync(outPath)) {
212
+ let content = await fsP2.readFile(
213
+ path.join(assetsPath, filename),
214
+ "utf-8"
215
+ );
216
+ if (contentCb) {
217
+ content = contentCb(content);
218
+ }
219
+ await fsP2.writeFile(outPath, content);
220
+ }
221
+ }
222
+ printSuccess() {
223
+ this.console.success("Log4brains is configured! \u{1F389}\u{1F389}\u{1F389}");
224
+ this.console.println();
225
+ this.console.println("You can now use the CLI to create a new ADR:");
226
+ this.console.println(` ${chalk.cyan(`log4brains adr new`)}`);
227
+ this.console.println("");
228
+ this.console.println(
229
+ "And start the web UI to preview your architecture knowledge base:"
230
+ );
231
+ this.console.println(` ${chalk.cyan(`log4brains preview`)}`);
232
+ this.console.println();
233
+ this.console.println(
234
+ "Do not forget to set up your CI/CD to automatically publish your knowledge base"
235
+ );
236
+ this.console.println(
237
+ `Check out the ${terminalLink(
238
+ "documentation",
239
+ docLink
240
+ )} to see some examples`
241
+ );
242
+ }
243
+ async askPathWhileNotFound(question, cwd, defaultValue) {
244
+ const p = await this.console.askInputQuestion(question, defaultValue);
245
+ if (!p.trim() || !fs.existsSync(path.join(cwd, p))) {
246
+ this.console.warn("This path does not exist. Please try again...");
247
+ return this.askPathWhileNotFound(question, cwd, defaultValue);
248
+ }
249
+ return p;
250
+ }
251
+ /**
252
+ * Command flow.
253
+ *
254
+ * @param options
255
+ * @param customCwd
256
+ */
257
+ async execute(options, customCwd) {
258
+ const noInteraction = options.defaults;
259
+ const cwd = customCwd ? path.resolve(customCwd) : process.cwd();
260
+ if (!fs.existsSync(cwd)) {
261
+ this.console.fatal(`The given path does not exist: ${chalk.cyan(cwd)}`);
262
+ throw new FailureExit();
263
+ }
264
+ if (fs.existsSync(path.join(cwd, ".log4brains.yml"))) {
265
+ this.console.warn(`${chalk.bold(".log4brains.yml")} already exists`);
266
+ this.console.warn(
267
+ "Please delete it and re-run this command if you want to configure it again"
268
+ );
269
+ this.console.println();
270
+ this.printSuccess();
271
+ return;
272
+ }
273
+ const config = await this.buildLog4brainsConfigInteractively(
274
+ cwd,
275
+ noInteraction
276
+ );
277
+ this.console.startSpinner("Writing config file...");
278
+ const { adrFolder } = config.project;
279
+ await fsP2.writeFile(
280
+ path.join(cwd, ".log4brains.yml"),
281
+ yaml.stringify(config),
282
+ "utf-8"
283
+ );
284
+ this.console.updateSpinner("Copying template files...");
285
+ await this.copyFileIfAbsent(cwd, adrFolder, "template.md");
286
+ await this.copyFileIfAbsent(
287
+ cwd,
288
+ adrFolder,
289
+ "index.md",
290
+ (content) => content.replace(/{PROJECT_NAME}/g, config.project.name)
291
+ );
292
+ await this.copyFileIfAbsent(cwd, adrFolder, "README.md");
293
+ this.console.updateSpinner("Creating your first ADRs...");
294
+ const adrListRes = await execa("log4brains", ["adr", "list", "--raw"], {
295
+ cwd
296
+ });
297
+ const l4bAdrSlug = await this.createAdr(
298
+ cwd,
299
+ adrFolder,
300
+ "Use Log4brains to manage the ADRs",
301
+ "use-log4brains-to-manage-the-adrs.md"
302
+ );
303
+ if (!adrListRes.stdout) {
304
+ await this.createAdr(
305
+ cwd,
306
+ adrFolder,
307
+ "Use Markdown Architectural Decision Records",
308
+ "use-markdown-architectural-decision-records.md",
309
+ [["{LOG4BRAINS_ADR_SLUG}", l4bAdrSlug]]
310
+ );
311
+ }
312
+ this.console.stopSpinner();
313
+ this.printSuccess();
314
+ }
315
+ };
316
+
317
+ // src/cli.ts
318
+ function createInitCli({ appConsole }) {
319
+ const program = new Command().allowExcessArguments();
320
+ program.command("init").argument("[path]", "Path of your project. Default: current directory").description("Configures Log4brains for your project").option(
321
+ "-d, --defaults",
322
+ "Run in non-interactive mode and use the common default options",
323
+ false
324
+ ).action(
325
+ (path2, options) => {
326
+ return new InitCommand({ appConsole }).execute(options, path2);
327
+ }
328
+ );
329
+ return program;
330
+ }
331
+ export {
332
+ createInitCli
333
+ };
334
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts","../src/commands/InitCommand.ts","../src/utils.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport type { AppConsole } from \"@awarded/log4brains-cli-common\";\nimport { InitCommand, InitCommandOpts } from \"./commands\";\n\ntype Deps = {\n appConsole: AppConsole;\n};\n\nexport function createInitCli({ appConsole }: Deps): Command {\n const program = new Command().allowExcessArguments(); // commander >=13 rejects extra arguments; keep the previous lenient behavior\n\n program\n .command(\"init\")\n .argument(\"[path]\", \"Path of your project. Default: current directory\")\n .description(\"Configures Log4brains for your project\")\n .option(\n \"-d, --defaults\",\n \"Run in non-interactive mode and use the common default options\",\n false\n )\n .action(\n (path: string | undefined, options: InitCommandOpts): Promise<void> => {\n return new InitCommand({ appConsole }).execute(options, path);\n }\n );\n\n return program;\n}\n","/* eslint-disable no-await-in-loop */\n/* eslint-disable class-methods-use-this */\nimport fs, { promises as fsP } from \"fs\";\nimport terminalLink from \"terminal-link\";\nimport chalk from \"chalk\";\nimport { execa } from \"execa\";\nimport yaml from \"yaml\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport moment from \"moment-timezone\";\nimport type { AppConsole } from \"@awarded/log4brains-cli-common\";\nimport { FailureExit } from \"@awarded/log4brains-cli-common\";\nimport { replaceAllInFile } from \"../utils\";\n\nconst assetsPath = fileURLToPath(new URL(\"../assets\", import.meta.url)); // only one level up because bundled into dist/index.js\nconst docLink = \"https://github.com/FreakinWard/log4brains\";\n\nfunction forceUnixPath(p: string): string {\n return p.replace(/\\\\/g, \"/\");\n}\n\nexport type InitCommandOpts = {\n defaults: boolean;\n};\n\ntype L4bYmlPackageConfig = {\n name: string;\n path: string;\n adrFolder: string;\n};\ntype L4bYmlConfig = {\n project: {\n name: string;\n tz: string;\n adrFolder: string;\n packages?: L4bYmlPackageConfig[];\n };\n};\n\ntype Deps = {\n appConsole: AppConsole;\n};\n\nexport class InitCommand {\n private readonly console: AppConsole;\n\n constructor({ appConsole }: Deps) {\n this.console = appConsole;\n }\n\n private guessMainAdrFolderPath(cwd: string): string | undefined {\n const usualPaths = [\n \"./docs/adr\",\n \"./docs/adrs\",\n \"./docs/architecture-decisions\",\n \"./doc/adr\",\n \"./doc/adrs\",\n \"./doc/architecture-decisions\",\n \"./adr\",\n \"./adrs\",\n \"./architecture-decisions\"\n ];\n\n for (const possiblePath of usualPaths) {\n if (fs.existsSync(path.join(cwd, possiblePath))) {\n return possiblePath;\n }\n }\n return undefined;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n private async buildLog4brainsConfigInteractively(\n cwd: string,\n noInteraction: boolean\n ): Promise<L4bYmlConfig> {\n this.console.println(chalk.bold(\"👋 Welcome to Log4brains!\"));\n this.console.println();\n this.console.println(\n \"This interactive script will help you configure Log4brains for your project.\"\n );\n this.console.println(\n `It will create the ${chalk.cyan(\".log4brains.yml\")} config file,`\n );\n this.console.println(\" copy the default ADR template,\");\n this.console.println(\" and create your first ADR for you!\");\n this.console.println();\n this.console.println(\n \"Before going further, please check that you are running this command\"\n );\n this.console.println(\n \"from the root folder of your project's git repository:\"\n );\n this.console.println(chalk.cyan(cwd));\n\n // Continue?\n if (\n !noInteraction &&\n !(await this.console.askYesNoQuestion(\"Continue?\", true))\n ) {\n process.exit(0);\n }\n\n this.console.println();\n this.console.println(\n \"👍 We will now ask you several questions to get you started:\"\n );\n\n // Name\n let name: string | undefined;\n try {\n const pkg: unknown = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\")\n );\n if (\n typeof pkg === \"object\" &&\n pkg !== null &&\n \"name\" in pkg &&\n typeof pkg.name === \"string\"\n ) {\n name = pkg.name;\n }\n } catch (e) {\n // ignore\n }\n\n name = noInteraction\n ? name || \"untitled\"\n : await this.console.askInputQuestionAndValidate(\n \"What is the name of your project?\",\n (answer) => !!answer.trim(),\n name\n );\n\n // Project type\n const type = noInteraction\n ? \"mono\"\n : await this.console.askListQuestion(\n \"Which statement describes the best your project?\",\n [\n {\n name: \"Simple project (only one ADR folder)\",\n value: \"mono\",\n short: \"Mono-package project\"\n },\n {\n name: \"Multi-package project (one ADR folder per package + a global one)\",\n value: \"multi\",\n short: \"Multi-package project\"\n }\n ]\n );\n\n // Main ADR folder location\n let adrFolder = this.guessMainAdrFolderPath(cwd);\n if (adrFolder) {\n this.console.println();\n this.console.println(\n `${chalk.blue.bold(\n \"i We have detected a folder with existing ADRs:\"\n )} ${chalk.cyan(adrFolder)}`\n );\n adrFolder =\n noInteraction ||\n (await this.console.askYesNoQuestion(\n \"Do you want to use it? (existing ADRs will be kept)\",\n true\n ))\n ? adrFolder\n : undefined;\n }\n if (!adrFolder) {\n adrFolder = noInteraction\n ? \"./docs/adr\"\n : await this.console.askInputQuestionAndValidate(\n `In which directory do you plan to store your ${\n type === \"multi\" ? \"global \" : \"\"\n }ADRs? (will be automatically created)`,\n (answer) => !!answer.trim(),\n \"./docs/adr\"\n );\n }\n await fsP.mkdir(path.join(cwd, adrFolder), { recursive: true });\n this.console.println();\n\n // Packages\n const packages = [];\n if (type === \"multi\") {\n this.console.println(\"We will now define your packages...\");\n this.console.println();\n\n let oneMorePackage = false;\n let packageNumber = 1;\n do {\n this.console.println();\n this.console.println(\n ` ${chalk.underline(`Package #${packageNumber}`)}:`\n );\n const pkgName = await this.console.askInputQuestionAndValidate(\n \"Name? (short, lowercase, without special characters, nor spaces)\",\n (answer) => !!answer.trim()\n );\n const pkgCodeFolder = await this.askPathWhileNotFound(\n \"Where is the source code of this package located?\",\n cwd,\n `./packages/${pkgName}`\n );\n const pkgAdrFolder = await this.console.askInputQuestionAndValidate(\n `In which directory do you plan to store the ADRs of this package? (will be automatically created)`,\n (answer) => !!answer.trim(),\n `${pkgCodeFolder}/docs/adr`\n );\n await fsP.mkdir(path.join(cwd, pkgAdrFolder), { recursive: true });\n packages.push({\n name: pkgName,\n path: forceUnixPath(pkgCodeFolder),\n adrFolder: forceUnixPath(pkgAdrFolder)\n });\n oneMorePackage = await this.console.askYesNoQuestion(\n `We are done with package #${packageNumber}. Do you want to add another one?`,\n false\n );\n packageNumber += 1;\n } while (oneMorePackage);\n }\n\n return {\n project: {\n name,\n tz: moment.tz.guess(),\n adrFolder: forceUnixPath(adrFolder),\n packages\n }\n };\n }\n\n private async createAdr(\n cwd: string,\n adrFolder: string,\n title: string,\n source: string,\n replacements: [string, string][] = []\n ): Promise<string> {\n const slug = (\n await execa(\n \"log4brains\",\n [\n \"adr\",\n \"new\",\n \"--quiet\",\n \"--from\",\n forceUnixPath(path.join(assetsPath, source)),\n `\"${title}\"`\n ],\n { cwd }\n )\n ).stdout;\n\n await replaceAllInFile(\n forceUnixPath(path.join(cwd, adrFolder, `${slug}.md`)),\n [\n [\"{DATE_YESTERDAY}\", moment().subtract(1, \"days\").format(\"YYYY-MM-DD\")], // we use yesterday's date so that we are sure new ADRs will appear on top\n ...replacements\n ]\n );\n\n return slug;\n }\n\n private async copyFileIfAbsent(\n cwd: string,\n adrFolder: string,\n filename: string,\n contentCb?: (content: string) => string\n ): Promise<void> {\n const outPath = path.join(cwd, adrFolder, filename);\n if (!fs.existsSync(outPath)) {\n let content = await fsP.readFile(\n path.join(assetsPath, filename),\n \"utf-8\"\n );\n if (contentCb) {\n content = contentCb(content);\n }\n await fsP.writeFile(outPath, content);\n }\n }\n\n private printSuccess(): void {\n this.console.success(\"Log4brains is configured! 🎉🎉🎉\");\n this.console.println();\n this.console.println(\"You can now use the CLI to create a new ADR:\");\n this.console.println(` ${chalk.cyan(`log4brains adr new`)}`);\n this.console.println(\"\");\n this.console.println(\n \"And start the web UI to preview your architecture knowledge base:\"\n );\n this.console.println(` ${chalk.cyan(`log4brains preview`)}`);\n this.console.println();\n this.console.println(\n \"Do not forget to set up your CI/CD to automatically publish your knowledge base\"\n );\n this.console.println(\n `Check out the ${terminalLink(\n \"documentation\",\n docLink\n )} to see some examples`\n );\n }\n\n private async askPathWhileNotFound(\n question: string,\n cwd: string,\n defaultValue?: string\n ): Promise<string> {\n const p = await this.console.askInputQuestion(question, defaultValue);\n if (!p.trim() || !fs.existsSync(path.join(cwd, p))) {\n this.console.warn(\"This path does not exist. Please try again...\");\n return this.askPathWhileNotFound(question, cwd, defaultValue);\n }\n return p;\n }\n\n /**\n * Command flow.\n *\n * @param options\n * @param customCwd\n */\n async execute(options: InitCommandOpts, customCwd?: string): Promise<void> {\n const noInteraction = options.defaults;\n\n const cwd = customCwd ? path.resolve(customCwd) : process.cwd();\n if (!fs.existsSync(cwd)) {\n this.console.fatal(`The given path does not exist: ${chalk.cyan(cwd)}`);\n throw new FailureExit();\n }\n\n // Terminate now if already configured\n if (fs.existsSync(path.join(cwd, \".log4brains.yml\"))) {\n this.console.warn(`${chalk.bold(\".log4brains.yml\")} already exists`);\n this.console.warn(\n \"Please delete it and re-run this command if you want to configure it again\"\n );\n this.console.println();\n this.printSuccess();\n return;\n }\n\n // Create .log4brains.yml interactively\n const config = await this.buildLog4brainsConfigInteractively(\n cwd,\n noInteraction\n );\n\n this.console.startSpinner(\"Writing config file...\");\n const { adrFolder } = config.project;\n await fsP.writeFile(\n path.join(cwd, \".log4brains.yml\"),\n yaml.stringify(config),\n \"utf-8\"\n );\n\n // Copy template, index and README if not already created\n this.console.updateSpinner(\"Copying template files...\");\n await this.copyFileIfAbsent(cwd, adrFolder, \"template.md\");\n await this.copyFileIfAbsent(cwd, adrFolder, \"index.md\", (content) =>\n content.replace(/{PROJECT_NAME}/g, config.project.name)\n );\n await this.copyFileIfAbsent(cwd, adrFolder, \"README.md\");\n\n // List existing ADRs\n this.console.updateSpinner(\"Creating your first ADRs...\");\n const adrListRes = await execa(\"log4brains\", [\"adr\", \"list\", \"--raw\"], {\n cwd\n });\n\n // Create Log4brains ADR\n const l4bAdrSlug = await this.createAdr(\n cwd,\n adrFolder,\n \"Use Log4brains to manage the ADRs\",\n \"use-log4brains-to-manage-the-adrs.md\"\n );\n\n // Create MADR ADR if there was no ADR in the repository\n if (!adrListRes.stdout) {\n await this.createAdr(\n cwd,\n adrFolder,\n \"Use Markdown Architectural Decision Records\",\n \"use-markdown-architectural-decision-records.md\",\n [[\"{LOG4BRAINS_ADR_SLUG}\", l4bAdrSlug]]\n );\n }\n\n // End\n this.console.stopSpinner();\n this.printSuccess();\n }\n}\n","import { promises as fsP } from \"fs\";\n\nfunction escapeRegExp(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"); // $& means the whole matched string\n}\n\n/**\n * string.replaceAll() polyfill\n * TODO: remove when support down to Node 15\n * @param str\n * @param search\n * @param replacement\n */\nfunction replaceAll(str: string, search: string, replacement: string): string {\n return str.replace(new RegExp(escapeRegExp(search), \"g\"), replacement);\n}\n\nexport async function replaceAllInFile(\n path: string,\n replacements: [string, string][]\n): Promise<void> {\n let content = await fsP.readFile(path, \"utf-8\");\n content = replacements.reduce((prevContent, replacement) => {\n return replaceAll(prevContent, replacement[0], replacement[1]);\n }, content);\n await fsP.writeFile(path, content, \"utf-8\");\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACExB,OAAO,MAAM,YAAYA,YAAW;AACpC,OAAO,kBAAkB;AACzB,OAAO,WAAW;AAClB,SAAS,aAAa;AACtB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,OAAO,YAAY;AAEnB,SAAS,mBAAmB;;;ACX5B,SAAS,YAAY,WAAW;AAEhC,SAAS,aAAa,KAAa;AACjC,SAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;AASA,SAAS,WAAW,KAAa,QAAgB,aAA6B;AAC5E,SAAO,IAAI,QAAQ,IAAI,OAAO,aAAa,MAAM,GAAG,GAAG,GAAG,WAAW;AACvE;AAEA,eAAsB,iBACpBC,OACA,cACe;AACf,MAAI,UAAU,MAAM,IAAI,SAASA,OAAM,OAAO;AAC9C,YAAU,aAAa,OAAO,CAAC,aAAa,gBAAgB;AAC1D,WAAO,WAAW,aAAa,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC;AAAA,EAC/D,GAAG,OAAO;AACV,QAAM,IAAI,UAAUA,OAAM,SAAS,OAAO;AAC5C;;;ADZA,IAAM,aAAa,cAAc,IAAI,IAAI,aAAa,YAAY,GAAG,CAAC;AACtE,IAAM,UAAU;AAEhB,SAAS,cAAc,GAAmB;AACxC,SAAO,EAAE,QAAQ,OAAO,GAAG;AAC7B;AAwBO,IAAM,cAAN,MAAkB;AAAA,EAGvB,YAAY,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A;AAAA,MACA;AAAA,IACF;AAGA,QAAI,CAAC,WAAW,QAAQ;AACtB,YAAM,KAAK;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,CAAC,CAAC,yBAAyB,UAAU,CAAC;AAAA,MACxC;AAAA,IACF;AAGA,SAAK,QAAQ,YAAY;AACzB,SAAK,aAAa;AAAA,EACpB;AACF;;;ADxYO,SAAS,cAAc,EAAE,WAAW,GAAkB;AAC3D,QAAM,UAAU,IAAI,QAAQ,EAAE,qBAAqB;AAEnD,UACG,QAAQ,MAAM,EACd,SAAS,UAAU,kDAAkD,EACrE,YAAY,wCAAwC,EACpD;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC,CAACC,OAA0B,YAA4C;AACrE,aAAO,IAAI,YAAY,EAAE,WAAW,CAAC,EAAE,QAAQ,SAASA,KAAI;AAAA,IAC9D;AAAA,EACF;AAEF,SAAO;AACT;","names":["fsP","path","fsP","path"]}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@awarded/log4brains-init",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0-beta.1",
4
+ "description": "Log4brains architecture knowledge base initialization CLI",
5
+ "keywords": [
6
+ "log4brains"
7
+ ],
8
+ "author": "Thomas Vaillant <thomvaill@bluebricks.dev>",
9
+ "license": "Apache-2.0",
10
+ "private": false,
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "homepage": "https://github.com/FreakinWard/log4brains",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/FreakinWard/log4brains",
18
+ "directory": "packages/init"
19
+ },
20
+ "engines": {
21
+ "node": "^22.22.2 || >=24.15.0"
22
+ },
23
+ "files": [
24
+ "assets",
25
+ "dist"
26
+ ],
27
+ "source": "./src/index.ts",
28
+ "main": "./dist/index.js",
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
36
+ "types": "./dist/index.d.ts",
37
+ "scripts": {
38
+ "dev": "tsup --watch",
39
+ "build": "tsup",
40
+ "clean": "rimraf ./dist",
41
+ "typescript": "tsc --noEmit",
42
+ "test": "exit 0",
43
+ "test-watch": "jest --watch",
44
+ "lint": "eslint . --max-warnings=0",
45
+ "prepublishOnly": "npm run build"
46
+ },
47
+ "dependencies": {
48
+ "@awarded/log4brains-cli-common": "2.0.0-beta.1",
49
+ "chalk": "^6.0.1",
50
+ "commander": "^15.1.0",
51
+ "execa": "^10.2.1",
52
+ "moment-timezone": "^0.6.6",
53
+ "terminal-link": "^5.0.0",
54
+ "yaml": "^2.9.1"
55
+ },
56
+ "devDependencies": {
57
+ "@types/edit-json-file": "^1.4.0",
58
+ "esm": "^3.2.25",
59
+ "ts-node": "^10.9.2"
60
+ }
61
+ }