@meza/adr-tools 2.0.3 → 2.0.4

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.
Files changed (122) hide show
  1. package/dist/types/version.d.ts +1 -1
  2. package/dist/version.js +1 -1
  3. package/package.json +19 -9
  4. package/.adr-dir +0 -1
  5. package/.editorconfig +0 -13
  6. package/.gitattributes +0 -40
  7. package/.github/renovate.json +0 -4
  8. package/.github/stale.yml +0 -18
  9. package/.github/workflows/ci-pr.yml +0 -48
  10. package/.github/workflows/ci.yml +0 -67
  11. package/.github/workflows/security.yml +0 -49
  12. package/.releaserc.json +0 -55
  13. package/.yarnrc.yml +0 -8
  14. package/AGENTS.engineer.md +0 -236
  15. package/AGENTS.md +0 -11
  16. package/AGENTS.reviewer.md +0 -115
  17. package/CHANGELOG.md +0 -7
  18. package/CONTRIBUTING.md +0 -102
  19. package/biome.json +0 -28
  20. package/dist/index.test.js +0 -219
  21. package/dist/index.test.js.map +0 -1
  22. package/dist/inject-version.test.js +0 -27
  23. package/dist/inject-version.test.js.map +0 -1
  24. package/dist/lib/adr.test.js +0 -319
  25. package/dist/lib/adr.test.js.map +0 -1
  26. package/dist/lib/config.test.js +0 -60
  27. package/dist/lib/config.test.js.map +0 -1
  28. package/dist/lib/links.test.js +0 -66
  29. package/dist/lib/links.test.js.map +0 -1
  30. package/dist/lib/manipulator-errors.test.js +0 -21
  31. package/dist/lib/manipulator-errors.test.js.map +0 -1
  32. package/dist/lib/manipulator.test.js +0 -96
  33. package/dist/lib/manipulator.test.js.map +0 -1
  34. package/dist/lib/numbering.test.js +0 -39
  35. package/dist/lib/numbering.test.js.map +0 -1
  36. package/dist/lib/opening.test.js +0 -81
  37. package/dist/lib/opening.test.js.map +0 -1
  38. package/dist/lib/prompt.test.js +0 -33
  39. package/dist/lib/prompt.test.js.map +0 -1
  40. package/dist/lib/template.test.js +0 -62
  41. package/dist/lib/template.test.js.map +0 -1
  42. package/dist/types/index.test.d.ts +0 -2
  43. package/dist/types/index.test.d.ts.map +0 -1
  44. package/dist/types/inject-version.test.d.ts +0 -2
  45. package/dist/types/inject-version.test.d.ts.map +0 -1
  46. package/dist/types/lib/adr.test.d.ts +0 -2
  47. package/dist/types/lib/adr.test.d.ts.map +0 -1
  48. package/dist/types/lib/config.test.d.ts +0 -2
  49. package/dist/types/lib/config.test.d.ts.map +0 -1
  50. package/dist/types/lib/links.test.d.ts +0 -2
  51. package/dist/types/lib/links.test.d.ts.map +0 -1
  52. package/dist/types/lib/manipulator-errors.test.d.ts +0 -2
  53. package/dist/types/lib/manipulator-errors.test.d.ts.map +0 -1
  54. package/dist/types/lib/manipulator.test.d.ts +0 -2
  55. package/dist/types/lib/manipulator.test.d.ts.map +0 -1
  56. package/dist/types/lib/numbering.test.d.ts +0 -2
  57. package/dist/types/lib/numbering.test.d.ts.map +0 -1
  58. package/dist/types/lib/opening.test.d.ts +0 -2
  59. package/dist/types/lib/opening.test.d.ts.map +0 -1
  60. package/dist/types/lib/prompt.test.d.ts +0 -2
  61. package/dist/types/lib/prompt.test.d.ts.map +0 -1
  62. package/dist/types/lib/template.test.d.ts +0 -2
  63. package/dist/types/lib/template.test.d.ts.map +0 -1
  64. package/doc/adr/.adr-sequence.lock +0 -1
  65. package/doc/adr/0001-record-architecture-decisions.md +0 -21
  66. package/doc/adr/0002-using-heavy-e2e-tests.md +0 -20
  67. package/doc/adr/0003-esm.md +0 -34
  68. package/doc/adr/0004-gate-editor-opening-behind---open-and---open-with.md +0 -55
  69. package/doc/adr/decisions.md +0 -6
  70. package/lefthook.yml +0 -14
  71. package/scripts/inject-version.mjs +0 -34
  72. package/src/index.test.ts +0 -247
  73. package/src/index.ts +0 -267
  74. package/src/inject-version.test.ts +0 -31
  75. package/src/lib/adr.test.ts +0 -389
  76. package/src/lib/adr.ts +0 -384
  77. package/src/lib/config.test.ts +0 -69
  78. package/src/lib/config.ts +0 -36
  79. package/src/lib/links.test.ts +0 -74
  80. package/src/lib/links.ts +0 -34
  81. package/src/lib/manipulator-errors.test.ts +0 -22
  82. package/src/lib/manipulator.test.ts +0 -109
  83. package/src/lib/manipulator.ts +0 -98
  84. package/src/lib/numbering.test.ts +0 -45
  85. package/src/lib/numbering.ts +0 -25
  86. package/src/lib/opening.test.ts +0 -96
  87. package/src/lib/prompt.test.ts +0 -42
  88. package/src/lib/prompt.ts +0 -14
  89. package/src/lib/template.test.ts +0 -74
  90. package/src/lib/template.ts +0 -22
  91. package/src/templates/init.md +0 -21
  92. package/src/templates/template.md +0 -19
  93. package/src/types/environment.d.ts +0 -14
  94. package/src/version.ts +0 -1
  95. package/tests/.adr-dir +0 -1
  96. package/tests/__snapshots__/generate-graph.e2e.test.ts.snap +0 -39
  97. package/tests/__snapshots__/init-adr-repository.e2e.test.ts.snap +0 -51
  98. package/tests/__snapshots__/linking-records.e2e.test.ts.snap +0 -155
  99. package/tests/__snapshots__/new-adr.e2e.test.ts.snap +0 -54
  100. package/tests/__snapshots__/superseding-records.e2e.test.ts.snap +0 -122
  101. package/tests/__snapshots__/toc-prefixing.e2e.test.ts.snap +0 -9
  102. package/tests/__snapshots__/use-template-override.e2e.test.ts.snap +0 -17
  103. package/tests/edit-on-create.e2e.test.ts +0 -90
  104. package/tests/fake-editor +0 -5
  105. package/tests/fake-editor.cmd +0 -4
  106. package/tests/fake-visual +0 -5
  107. package/tests/fake-visual.cmd +0 -4
  108. package/tests/funny-characters.e2e.test.ts +0 -51
  109. package/tests/generate-graph.e2e.test.ts +0 -49
  110. package/tests/helpers/adr-cli.ts +0 -24
  111. package/tests/init-adr-repository.e2e.test.ts +0 -58
  112. package/tests/linking-records.e2e.test.ts +0 -72
  113. package/tests/list-adrs.e2e.test.ts +0 -60
  114. package/tests/new-adr.e2e.test.ts +0 -62
  115. package/tests/open-with.e2e.test.ts +0 -53
  116. package/tests/superseding-records.e2e.test.ts +0 -64
  117. package/tests/toc-prefixing.e2e.test.ts +0 -43
  118. package/tests/use-template-override.e2e.test.ts +0 -52
  119. package/tests/work-form-other-directories.e2e.test.ts +0 -48
  120. package/tsconfig.json +0 -55
  121. package/vitest.config.e2e.ts +0 -18
  122. package/vitest.config.ts +0 -30
@@ -1,51 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Init an ADR Repository > should use an alternate directory 1`] = `
4
- "# 1. Record architecture decisions
5
-
6
- Date: 1992-01-12
7
-
8
- ## Status
9
-
10
- Accepted
11
-
12
- ## Context
13
-
14
- We need to record the architectural decisions made on this project.
15
-
16
- ## Decision
17
-
18
- We will use Architecture Decision Records, as [described by Michael Nygard](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions).
19
-
20
- ## Consequences
21
-
22
- See Michael Nygard's article, linked above.
23
- For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools).
24
- > For a node version of the same tooling, see Meza's [adr-tools](https://github.com/meza/adr-tools).
25
- "
26
- `;
27
-
28
- exports[`Init an ADR Repository > should use the default directory 1`] = `
29
- "# 1. Record architecture decisions
30
-
31
- Date: 1992-01-12
32
-
33
- ## Status
34
-
35
- Accepted
36
-
37
- ## Context
38
-
39
- We need to record the architectural decisions made on this project.
40
-
41
- ## Decision
42
-
43
- We will use Architecture Decision Records, as [described by Michael Nygard](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions).
44
-
45
- ## Consequences
46
-
47
- See Michael Nygard's article, linked above.
48
- For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools).
49
- > For a node version of the same tooling, see Meza's [adr-tools](https://github.com/meza/adr-tools).
50
- "
51
- `;
@@ -1,155 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Linking Adrs > should link adrs as expected with adr link 1`] = `
4
- "# 1. First Record
5
-
6
- Date: 1992-01-12
7
-
8
- ## Status
9
-
10
- Accepted
11
-
12
- Amended by [3. Third Record](0003-third-record.md)
13
-
14
- ## Context
15
-
16
- The issue motivating this decision, and any context that influences or constrains the decision.
17
-
18
- ## Decision
19
-
20
- The change that we're proposing or have agreed to implement.
21
-
22
- ## Consequences
23
-
24
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
25
- "
26
- `;
27
-
28
- exports[`Linking Adrs > should link adrs as expected with adr link 2`] = `
29
- "# 2. Second Record
30
-
31
- Date: 1992-01-12
32
-
33
- ## Status
34
-
35
- Accepted
36
-
37
- Clarified by [3. Third Record](0003-third-record.md)
38
-
39
- ## Context
40
-
41
- The issue motivating this decision, and any context that influences or constrains the decision.
42
-
43
- ## Decision
44
-
45
- The change that we're proposing or have agreed to implement.
46
-
47
- ## Consequences
48
-
49
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
50
- "
51
- `;
52
-
53
- exports[`Linking Adrs > should link adrs as expected with adr link 3`] = `
54
- "# 3. Third Record
55
-
56
- Date: 1992-01-12
57
-
58
- ## Status
59
-
60
- Accepted
61
-
62
- Amends [1. First Record](0001-first-record.md)
63
-
64
- Clarifies [2. Second Record](0002-second-record.md)
65
-
66
- ## Context
67
-
68
- The issue motivating this decision, and any context that influences or constrains the decision.
69
-
70
- ## Decision
71
-
72
- The change that we're proposing or have agreed to implement.
73
-
74
- ## Consequences
75
-
76
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
77
- "
78
- `;
79
-
80
- exports[`Linking Adrs > should link adrs as expected with adr new 1`] = `
81
- "# 1. First Record
82
-
83
- Date: 1992-01-12
84
-
85
- ## Status
86
-
87
- Accepted
88
-
89
- Amended by [3. Third Record](0003-third-record.md)
90
-
91
- ## Context
92
-
93
- The issue motivating this decision, and any context that influences or constrains the decision.
94
-
95
- ## Decision
96
-
97
- The change that we're proposing or have agreed to implement.
98
-
99
- ## Consequences
100
-
101
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
102
- "
103
- `;
104
-
105
- exports[`Linking Adrs > should link adrs as expected with adr new 2`] = `
106
- "# 2. Second Record
107
-
108
- Date: 1992-01-12
109
-
110
- ## Status
111
-
112
- Accepted
113
-
114
- Clarified by [3. Third Record](0003-third-record.md)
115
-
116
- ## Context
117
-
118
- The issue motivating this decision, and any context that influences or constrains the decision.
119
-
120
- ## Decision
121
-
122
- The change that we're proposing or have agreed to implement.
123
-
124
- ## Consequences
125
-
126
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
127
- "
128
- `;
129
-
130
- exports[`Linking Adrs > should link adrs as expected with adr new 3`] = `
131
- "# 3. Third Record
132
-
133
- Date: 1992-01-12
134
-
135
- ## Status
136
-
137
- Accepted
138
-
139
- Amends [1. First Record](0001-first-record.md)
140
-
141
- Clarifies [2. Second Record](0002-second-record.md)
142
-
143
- ## Context
144
-
145
- The issue motivating this decision, and any context that influences or constrains the decision.
146
-
147
- ## Decision
148
-
149
- The change that we're proposing or have agreed to implement.
150
-
151
- ## Consequences
152
-
153
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
154
- "
155
- `;
@@ -1,54 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`New Adrs > should create a new one even if no config exists 1`] = `
4
- "# 1. Example ADR
5
-
6
- Date: 1992-01-12
7
-
8
- ## Status
9
-
10
- Accepted
11
-
12
- ## Context
13
-
14
- The issue motivating this decision, and any context that influences or constrains the decision.
15
-
16
- ## Decision
17
-
18
- The change that we're proposing or have agreed to implement.
19
-
20
- ## Consequences
21
-
22
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
23
- "
24
- `;
25
-
26
- exports[`New Adrs > should create a new one normally 1`] = `
27
- "# 2. Example ADR
28
-
29
- Date: 1992-01-12
30
-
31
- ## Status
32
-
33
- Accepted
34
-
35
- ## Context
36
-
37
- The issue motivating this decision, and any context that influences or constrains the decision.
38
-
39
- ## Decision
40
-
41
- The change that we're proposing or have agreed to implement.
42
-
43
- ## Consequences
44
-
45
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
46
- "
47
- `;
48
-
49
- exports[`New Adrs > should create a table of contents upon creation 1`] = `
50
- "# Table of Contents
51
-
52
- - [1. Record architecture decisions](0001-record-architecture-decisions.md)
53
- - [2. Example ADR](0002-example-adr.md)"
54
- `;
@@ -1,122 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Superseding Adrs > should be able to supersede multiple records 1`] = `
4
- "# 1. First Record
5
-
6
- Date: 1992-01-12
7
-
8
- ## Status
9
-
10
- Superseded by [3. Third Record](0003-third-record.md)
11
-
12
- ## Context
13
-
14
- The issue motivating this decision, and any context that influences or constrains the decision.
15
-
16
- ## Decision
17
-
18
- The change that we're proposing or have agreed to implement.
19
-
20
- ## Consequences
21
-
22
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
23
- "
24
- `;
25
-
26
- exports[`Superseding Adrs > should be able to supersede multiple records 2`] = `
27
- "# 2. Second Record
28
-
29
- Date: 1992-01-12
30
-
31
- ## Status
32
-
33
- Superseded by [3. Third Record](0003-third-record.md)
34
-
35
- ## Context
36
-
37
- The issue motivating this decision, and any context that influences or constrains the decision.
38
-
39
- ## Decision
40
-
41
- The change that we're proposing or have agreed to implement.
42
-
43
- ## Consequences
44
-
45
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
46
- "
47
- `;
48
-
49
- exports[`Superseding Adrs > should be able to supersede multiple records 3`] = `
50
- "# 3. Third Record
51
-
52
- Date: 1992-01-12
53
-
54
- ## Status
55
-
56
- Accepted
57
-
58
- Supersedes [1. First Record](0001-first-record.md)
59
-
60
- Supersedes [2. Second Record](0002-second-record.md)
61
-
62
- ## Context
63
-
64
- The issue motivating this decision, and any context that influences or constrains the decision.
65
-
66
- ## Decision
67
-
68
- The change that we're proposing or have agreed to implement.
69
-
70
- ## Consequences
71
-
72
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
73
- "
74
- `;
75
-
76
- exports[`Superseding Adrs > should be able to supersede previous adrs 1`] = `
77
- "# 1. First Record
78
-
79
- Date: 1992-01-12
80
-
81
- ## Status
82
-
83
- Superseded by [2. Second Record](0002-second-record.md)
84
-
85
- ## Context
86
-
87
- The issue motivating this decision, and any context that influences or constrains the decision.
88
-
89
- ## Decision
90
-
91
- The change that we're proposing or have agreed to implement.
92
-
93
- ## Consequences
94
-
95
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
96
- "
97
- `;
98
-
99
- exports[`Superseding Adrs > should be able to supersede previous adrs 2`] = `
100
- "# 2. Second Record
101
-
102
- Date: 1992-01-12
103
-
104
- ## Status
105
-
106
- Accepted
107
-
108
- Supersedes [1. First Record](0001-first-record.md)
109
-
110
- ## Context
111
-
112
- The issue motivating this decision, and any context that influences or constrains the decision.
113
-
114
- ## Decision
115
-
116
- The change that we're proposing or have agreed to implement.
117
-
118
- ## Consequences
119
-
120
- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.
121
- "
122
- `;
@@ -1,9 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Generating TOC > should add a path prefix to the toc when there is one supplied 1`] = `
4
- "# Table of Contents
5
-
6
- - [1. First Record](foo/doc/adr/0001-first-record.md)
7
- - [2. Second Record](foo/doc/adr/0002-second-record.md)
8
- - [3. Third Record](foo/doc/adr/0003-third-record.md)"
9
- `;
@@ -1,17 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Overriding templates > should use an override template if one exists 1`] = `
4
- "# This is an override template
5
- Example ADR
6
- 1992-01-12
7
- 2
8
- Accepted"
9
- `;
10
-
11
- exports[`Overriding templates > should use an override template if one exists 2`] = `
12
- "# This is an override template
13
- Another Example ADR
14
- 1992-01-12
15
- 3
16
- Accepted"
17
- `;
@@ -1,90 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as os from 'os';
3
- import * as path from 'path';
4
- /* eslint-disable no-sync */
5
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
6
- import { createAdrCli } from './helpers/adr-cli';
7
-
8
- const waitForFile = async (filePath: string, timeoutMs: number) => {
9
- const startedAt = Date.now();
10
- while (Date.now() - startedAt < timeoutMs) {
11
- if (fs.existsSync(filePath)) {
12
- return;
13
- }
14
- await new Promise((r) => setTimeout(r, 25));
15
- }
16
- throw new Error(`Timed out waiting for file: ${filePath}`);
17
- };
18
-
19
- describe('Edit new Adrs on creation', () => {
20
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
21
- const cli = createAdrCli(adr);
22
- const visualHelper =
23
- process.platform === 'win32'
24
- ? path.resolve(path.dirname(__filename), './fake-visual.cmd')
25
- : path.resolve(path.dirname(__filename), './fake-visual');
26
- const editorHelper =
27
- process.platform === 'win32'
28
- ? path.resolve(path.dirname(__filename), './fake-editor.cmd')
29
- : path.resolve(path.dirname(__filename), './fake-editor');
30
-
31
- let adrDirectory: string;
32
- let workDir: string;
33
-
34
- beforeEach(() => {
35
- // @ts-ignore
36
- process.env.ADR_DATE = '1992-01-12';
37
- workDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-')));
38
- adrDirectory = path.resolve(path.join(workDir, 'doc/adr'));
39
- });
40
-
41
- afterEach(() => {
42
- fs.rmSync(workDir, {
43
- recursive: true,
44
- force: true,
45
- maxRetries: 3,
46
- retryDelay: 500
47
- });
48
- });
49
-
50
- it('should open a new ADR in the VISUAL', async () => {
51
- cli.run(['new', '--open', 'Example', 'ADR'], {
52
- cwd: workDir,
53
- env: { VISUAL: visualHelper }
54
- });
55
-
56
- const expectedNewFile: string = path.join(workDir, 'visual.out');
57
- await waitForFile(expectedNewFile, 2000);
58
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
59
- const reported = fileContents.trim().replace(/^VISUAL\s+/, '');
60
- expect(path.normalize(reported)).toEqual(path.normalize(`${adrDirectory}/0001-example-adr.md`));
61
- });
62
-
63
- it('should open a new ADR in the EDITOR', async () => {
64
- cli.run(['new', '--open', 'Example', 'ADR'], {
65
- cwd: workDir,
66
- env: { EDITOR: editorHelper }
67
- });
68
-
69
- const expectedNewFile: string = path.join(workDir, 'editor.out');
70
- await waitForFile(expectedNewFile, 2000);
71
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
72
- const reported = fileContents.trim().replace(/^EDITOR\s+/, '');
73
- expect(path.normalize(reported)).toEqual(path.normalize(`${adrDirectory}/0001-example-adr.md`));
74
- });
75
-
76
- it('should open a new ADR in the VISUAL if both VISUAL and EDITOR is supplied', async () => {
77
- cli.run(['new', '--open', 'Example', 'ADR'], {
78
- cwd: workDir,
79
- env: { EDITOR: editorHelper, VISUAL: visualHelper }
80
- });
81
-
82
- expect(fs.existsSync(path.join(workDir, 'editor.out'))).toBeFalsy();
83
-
84
- const expectedNewFile: string = path.join(workDir, 'visual.out');
85
- await waitForFile(expectedNewFile, 2000);
86
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
87
- const reported = fileContents.trim().replace(/^VISUAL\s+/, '');
88
- expect(path.normalize(reported)).toEqual(path.normalize(`${adrDirectory}/0001-example-adr.md`));
89
- });
90
- });
package/tests/fake-editor DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
-
3
- output="$PWD/editor.out"
4
- cd "${TMPDIR:-/tmp}"
5
- echo EDITOR "$@" > "$output"
@@ -1,4 +0,0 @@
1
- @echo off
2
- set "OUTPUT=%CD%\editor.out"
3
- cd /d "%TEMP%"
4
- echo EDITOR %~1 > "%OUTPUT%"
package/tests/fake-visual DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
-
3
- output="$PWD/visual.out"
4
- cd "${TMPDIR:-/tmp}"
5
- echo VISUAL "$@" > "$output"
@@ -1,4 +0,0 @@
1
- @echo off
2
- set "OUTPUT=%CD%\visual.out"
3
- cd /d "%TEMP%"
4
- echo VISUAL %~1 > "%OUTPUT%"
@@ -1,51 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import os from 'os';
4
- import * as path from 'path';
5
-
6
- /* eslint-disable no-sync */
7
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
8
- import { createAdrCli } from './helpers/adr-cli';
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
-
12
- describe('Funny Characters', () => {
13
- const adr: string = path.resolve(path.dirname(__filename), '../src/index.ts');
14
- const cli = createAdrCli(adr);
15
-
16
- let adrDirectory: string;
17
- let workDir: string;
18
-
19
- afterEach(() => {
20
- fs.rmSync(workDir, {
21
- recursive: true,
22
- force: true,
23
- maxRetries: 3,
24
- retryDelay: 500
25
- });
26
- });
27
-
28
- beforeEach(() => {
29
- workDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-')));
30
- adrDirectory = path.resolve(path.join(workDir, 'doc/adr'));
31
- cli.run(['init', adrDirectory], { cwd: workDir });
32
- });
33
-
34
- it('should handle titles with periods in them', async () => {
35
- cli.run(['new', 'Something', 'About', 'Node.JS'], { cwd: workDir });
36
- const expectedFile: string = path.join(adrDirectory, '0002-something-about-node-js.md');
37
- expect(fs.existsSync(expectedFile)).toBeTruthy();
38
- });
39
-
40
- it('should handle titles with slashes in them', async () => {
41
- cli.run(['new', 'Slash/Slash/Slash/'], { cwd: workDir });
42
- const expectedFile: string = path.join(adrDirectory, '0002-slash-slash-slash.md');
43
- expect(fs.existsSync(expectedFile)).toBeTruthy();
44
- });
45
-
46
- it('should handle titles with other weirdness in them', async () => {
47
- cli.run(['new', '--', '-Bar-'], { cwd: workDir });
48
- const expectedFile: string = path.join(adrDirectory, '0002-bar.md');
49
- expect(fs.existsSync(expectedFile)).toBeTruthy();
50
- });
51
- });
@@ -1,49 +0,0 @@
1
- import { realpathSync, rmSync } from 'node:fs';
2
- import * as fs from 'fs/promises';
3
- import * as os from 'os';
4
- import * as path from 'path';
5
- /* eslint-disable no-sync */
6
- import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Generating Graphs', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
- let workDir: string;
13
-
14
- beforeAll(async () => {
15
- // @ts-ignore
16
- process.env.ADR_DATE = '1992-01-12';
17
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
18
- cli.run(['init'], { cwd: workDir });
19
- cli.run(['new', 'An', 'idea', 'that', 'seems', 'good', 'at', 'the', 'time'], { cwd: workDir });
20
- cli.run(['new', '-s', '2', 'A', 'better', 'idea'], { cwd: workDir });
21
- cli.run(['new', 'This', 'will', 'work'], { cwd: workDir });
22
- cli.run(['new', '-s', '3', 'The', 'end'], { cwd: workDir });
23
- });
24
-
25
- afterEach(() => {
26
- vi.clearAllMocks();
27
- });
28
-
29
- afterAll(() => {
30
- rmSync(workDir, {
31
- recursive: true,
32
- force: true,
33
- maxRetries: 3,
34
- retryDelay: 500
35
- });
36
- });
37
-
38
- it('should generate a graph', async () => {
39
- const childContent = cli.run(['generate', 'graph'], { cwd: workDir });
40
-
41
- expect(childContent).toMatchSnapshot();
42
- });
43
-
44
- it('should generate a graph with specified route and extension ', async () => {
45
- const childContent = cli.run(['generate', 'graph', '-p', 'http://example.com/', '-e', '.xxx'], { cwd: workDir });
46
-
47
- expect(childContent).toMatchSnapshot();
48
- });
49
- });
@@ -1,24 +0,0 @@
1
- import childProcess, { type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
2
- import path from 'node:path';
3
-
4
- export interface AdrCli {
5
- run(args: string[], options?: { cwd?: string; env?: Record<string, string | undefined>; timeoutMs?: number }): string;
6
- }
7
-
8
- export const createAdrCli = (entrypoint: string): AdrCli => {
9
- const absoluteEntrypoint = path.resolve(entrypoint);
10
- const tsxCli = path.resolve(process.cwd(), 'node_modules', 'tsx', 'dist', 'cli.mjs');
11
-
12
- const run: AdrCli['run'] = (args, options) => {
13
- const result = childProcess.execFileSync(process.execPath, [tsxCli, absoluteEntrypoint, ...args], {
14
- cwd: options?.cwd,
15
- env: { ...process.env, ...options?.env },
16
- timeout: options?.timeoutMs ?? 20000,
17
- encoding: 'utf8'
18
- } satisfies SpawnSyncOptionsWithStringEncoding);
19
-
20
- return result.trimEnd();
21
- };
22
-
23
- return { run };
24
- };