@meza/adr-tools 2.0.2 → 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 (124) hide show
  1. package/dist/index.js +8 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/index.d.ts.map +1 -1
  4. package/dist/types/version.d.ts +1 -1
  5. package/dist/version.js +1 -1
  6. package/package.json +21 -9
  7. package/.adr-dir +0 -1
  8. package/.editorconfig +0 -13
  9. package/.gitattributes +0 -40
  10. package/.github/renovate.json +0 -4
  11. package/.github/stale.yml +0 -18
  12. package/.github/workflows/ci-pr.yml +0 -48
  13. package/.github/workflows/ci.yml +0 -67
  14. package/.github/workflows/security.yml +0 -49
  15. package/.releaserc.json +0 -49
  16. package/.yarnrc.yml +0 -8
  17. package/AGENTS.engineer.md +0 -236
  18. package/AGENTS.md +0 -11
  19. package/AGENTS.reviewer.md +0 -115
  20. package/CONTRIBUTING.md +0 -102
  21. package/biome.json +0 -28
  22. package/dist/index.test.js +0 -197
  23. package/dist/index.test.js.map +0 -1
  24. package/dist/inject-version.test.js +0 -27
  25. package/dist/inject-version.test.js.map +0 -1
  26. package/dist/lib/adr.test.js +0 -319
  27. package/dist/lib/adr.test.js.map +0 -1
  28. package/dist/lib/config.test.js +0 -60
  29. package/dist/lib/config.test.js.map +0 -1
  30. package/dist/lib/links.test.js +0 -66
  31. package/dist/lib/links.test.js.map +0 -1
  32. package/dist/lib/manipulator-errors.test.js +0 -21
  33. package/dist/lib/manipulator-errors.test.js.map +0 -1
  34. package/dist/lib/manipulator.test.js +0 -96
  35. package/dist/lib/manipulator.test.js.map +0 -1
  36. package/dist/lib/numbering.test.js +0 -39
  37. package/dist/lib/numbering.test.js.map +0 -1
  38. package/dist/lib/opening.test.js +0 -81
  39. package/dist/lib/opening.test.js.map +0 -1
  40. package/dist/lib/prompt.test.js +0 -33
  41. package/dist/lib/prompt.test.js.map +0 -1
  42. package/dist/lib/template.test.js +0 -62
  43. package/dist/lib/template.test.js.map +0 -1
  44. package/dist/types/index.test.d.ts +0 -2
  45. package/dist/types/index.test.d.ts.map +0 -1
  46. package/dist/types/inject-version.test.d.ts +0 -2
  47. package/dist/types/inject-version.test.d.ts.map +0 -1
  48. package/dist/types/lib/adr.test.d.ts +0 -2
  49. package/dist/types/lib/adr.test.d.ts.map +0 -1
  50. package/dist/types/lib/config.test.d.ts +0 -2
  51. package/dist/types/lib/config.test.d.ts.map +0 -1
  52. package/dist/types/lib/links.test.d.ts +0 -2
  53. package/dist/types/lib/links.test.d.ts.map +0 -1
  54. package/dist/types/lib/manipulator-errors.test.d.ts +0 -2
  55. package/dist/types/lib/manipulator-errors.test.d.ts.map +0 -1
  56. package/dist/types/lib/manipulator.test.d.ts +0 -2
  57. package/dist/types/lib/manipulator.test.d.ts.map +0 -1
  58. package/dist/types/lib/numbering.test.d.ts +0 -2
  59. package/dist/types/lib/numbering.test.d.ts.map +0 -1
  60. package/dist/types/lib/opening.test.d.ts +0 -2
  61. package/dist/types/lib/opening.test.d.ts.map +0 -1
  62. package/dist/types/lib/prompt.test.d.ts +0 -2
  63. package/dist/types/lib/prompt.test.d.ts.map +0 -1
  64. package/dist/types/lib/template.test.d.ts +0 -2
  65. package/dist/types/lib/template.test.d.ts.map +0 -1
  66. package/doc/adr/.adr-sequence.lock +0 -1
  67. package/doc/adr/0001-record-architecture-decisions.md +0 -21
  68. package/doc/adr/0002-using-heavy-e2e-tests.md +0 -20
  69. package/doc/adr/0003-esm.md +0 -34
  70. package/doc/adr/0004-gate-editor-opening-behind---open-and---open-with.md +0 -55
  71. package/doc/adr/decisions.md +0 -6
  72. package/lefthook.yml +0 -14
  73. package/scripts/inject-version.mjs +0 -34
  74. package/src/index.test.ts +0 -222
  75. package/src/index.ts +0 -261
  76. package/src/inject-version.test.ts +0 -31
  77. package/src/lib/adr.test.ts +0 -389
  78. package/src/lib/adr.ts +0 -384
  79. package/src/lib/config.test.ts +0 -69
  80. package/src/lib/config.ts +0 -36
  81. package/src/lib/links.test.ts +0 -74
  82. package/src/lib/links.ts +0 -34
  83. package/src/lib/manipulator-errors.test.ts +0 -22
  84. package/src/lib/manipulator.test.ts +0 -109
  85. package/src/lib/manipulator.ts +0 -98
  86. package/src/lib/numbering.test.ts +0 -45
  87. package/src/lib/numbering.ts +0 -25
  88. package/src/lib/opening.test.ts +0 -96
  89. package/src/lib/prompt.test.ts +0 -42
  90. package/src/lib/prompt.ts +0 -14
  91. package/src/lib/template.test.ts +0 -74
  92. package/src/lib/template.ts +0 -22
  93. package/src/templates/init.md +0 -21
  94. package/src/templates/template.md +0 -19
  95. package/src/types/environment.d.ts +0 -14
  96. package/src/version.ts +0 -1
  97. package/tests/.adr-dir +0 -1
  98. package/tests/__snapshots__/generate-graph.e2e.test.ts.snap +0 -39
  99. package/tests/__snapshots__/init-adr-repository.e2e.test.ts.snap +0 -51
  100. package/tests/__snapshots__/linking-records.e2e.test.ts.snap +0 -155
  101. package/tests/__snapshots__/new-adr.e2e.test.ts.snap +0 -54
  102. package/tests/__snapshots__/superseding-records.e2e.test.ts.snap +0 -122
  103. package/tests/__snapshots__/toc-prefixing.e2e.test.ts.snap +0 -9
  104. package/tests/__snapshots__/use-template-override.e2e.test.ts.snap +0 -17
  105. package/tests/edit-on-create.e2e.test.ts +0 -90
  106. package/tests/fake-editor +0 -5
  107. package/tests/fake-editor.cmd +0 -4
  108. package/tests/fake-visual +0 -5
  109. package/tests/fake-visual.cmd +0 -4
  110. package/tests/funny-characters.e2e.test.ts +0 -51
  111. package/tests/generate-graph.e2e.test.ts +0 -49
  112. package/tests/helpers/adr-cli.ts +0 -24
  113. package/tests/init-adr-repository.e2e.test.ts +0 -58
  114. package/tests/linking-records.e2e.test.ts +0 -72
  115. package/tests/list-adrs.e2e.test.ts +0 -60
  116. package/tests/new-adr.e2e.test.ts +0 -62
  117. package/tests/open-with.e2e.test.ts +0 -53
  118. package/tests/superseding-records.e2e.test.ts +0 -64
  119. package/tests/toc-prefixing.e2e.test.ts +0 -43
  120. package/tests/use-template-override.e2e.test.ts +0 -52
  121. package/tests/work-form-other-directories.e2e.test.ts +0 -48
  122. package/tsconfig.json +0 -55
  123. package/vitest.config.e2e.ts +0 -18
  124. package/vitest.config.ts +0 -30
@@ -1,58 +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
- describe('Init an ADR Repository', () => {
9
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const cli = createAdrCli(adr);
11
-
12
- let adrDirectory: string;
13
- let workDir: string;
14
-
15
- beforeEach(() => {
16
- // @ts-ignore
17
- process.env.ADR_DATE = '1992-01-12';
18
- workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
19
- adrDirectory = path.join(workDir, 'doc/adr');
20
- });
21
-
22
- afterEach(() => {
23
- fs.rmSync(workDir, {
24
- recursive: true,
25
- force: true,
26
- maxRetries: 3,
27
- retryDelay: 500
28
- });
29
- });
30
-
31
- it('should use the default directory', () => {
32
- cli.run(['init'], { cwd: workDir });
33
- const expectedFile: string = path.join(adrDirectory, '0001-record-architecture-decisions.md');
34
- const expectedLockFile: string = path.join(adrDirectory, '.adr-sequence.lock');
35
- expect(fs.existsSync(expectedFile)).toBeTruthy();
36
- expect(fs.existsSync(expectedLockFile)).toBeTruthy();
37
-
38
- const fileContents = fs.readFileSync(expectedFile, 'utf8');
39
- const lockFileContents = fs.readFileSync(expectedLockFile, 'utf8');
40
- expect(fileContents).toMatchSnapshot();
41
- expect(lockFileContents).toEqual('1');
42
- });
43
-
44
- it('should use an alternate directory', () => {
45
- const directory: string = path.resolve(path.join(workDir, 'tmp', 'alternative-dir'));
46
- cli.run(['init', directory], { cwd: workDir });
47
-
48
- const expectedInitFile: string = path.join(directory, '0001-record-architecture-decisions.md');
49
- const expectedLockFile: string = path.join(directory, '.adr-sequence.lock');
50
- expect(fs.existsSync(expectedInitFile)).toBeTruthy();
51
- expect(fs.existsSync(expectedLockFile)).toBeTruthy();
52
-
53
- const fileContents = fs.readFileSync(expectedInitFile, 'utf8');
54
- const lockFileContents = fs.readFileSync(expectedLockFile, 'utf8');
55
- expect(fileContents).toMatchSnapshot();
56
- expect(lockFileContents).toEqual('1');
57
- });
58
- });
@@ -1,72 +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 { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Linking Adrs', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
-
13
- let adrDirectory: string;
14
- let workDir: string;
15
-
16
- beforeEach(async () => {
17
- // @ts-ignore
18
- process.env.ADR_DATE = '1992-01-12';
19
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
20
- adrDirectory = path.join(workDir, 'doc/adr');
21
- });
22
-
23
- afterEach(() => {
24
- vi.clearAllMocks();
25
- rmSync(workDir, {
26
- recursive: true,
27
- force: true,
28
- maxRetries: 3,
29
- retryDelay: 500
30
- });
31
- });
32
-
33
- it('should link adrs as expected with adr new', async () => {
34
- cli.run(['new', 'First', 'Record'], { cwd: workDir });
35
- cli.run(['new', 'Second', 'Record'], { cwd: workDir });
36
- cli.run(['new', '-q', '-l', '1:Amends:Amended by', '-l', '2:Clarifies:Clarified by', 'Third', 'Record'], {
37
- cwd: workDir
38
- });
39
-
40
- const first: string = path.join(adrDirectory, '0001-first-record.md');
41
- const second: string = path.join(adrDirectory, '0002-second-record.md');
42
- const third: string = path.join(adrDirectory, '0003-third-record.md');
43
-
44
- const firstContent = await fs.readFile(first, 'utf8');
45
- const secondContent = await fs.readFile(second, 'utf8');
46
- const thirdContent = await fs.readFile(third, 'utf8');
47
-
48
- expect(firstContent).toMatchSnapshot();
49
- expect(secondContent).toMatchSnapshot();
50
- expect(thirdContent).toMatchSnapshot();
51
- });
52
-
53
- it('should link adrs as expected with adr link', async () => {
54
- cli.run(['new', 'First', 'Record'], { cwd: workDir });
55
- cli.run(['new', 'Second', 'Record'], { cwd: workDir });
56
- cli.run(['new', 'Third', 'Record'], { cwd: workDir });
57
- cli.run(['link', '3', 'Amends', '1', 'Amended by'], { cwd: workDir });
58
- cli.run(['link', '3', 'Clarifies', '2', 'Clarified by'], { cwd: workDir });
59
-
60
- const first: string = path.join(adrDirectory, '0001-first-record.md');
61
- const second: string = path.join(adrDirectory, '0002-second-record.md');
62
- const third: string = path.join(adrDirectory, '0003-third-record.md');
63
-
64
- const firstContent = await fs.readFile(first, 'utf8');
65
- const secondContent = await fs.readFile(second, 'utf8');
66
- const thirdContent = await fs.readFile(third, 'utf8');
67
-
68
- expect(firstContent).toMatchSnapshot();
69
- expect(secondContent).toMatchSnapshot();
70
- expect(thirdContent).toMatchSnapshot();
71
- });
72
- });
@@ -1,60 +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 { afterEach, beforeEach, describe, expect, it } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Listing', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
-
13
- let adrDirectory: string;
14
- let workDir: string;
15
-
16
- beforeEach(async () => {
17
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
18
- adrDirectory = 'doc/adr';
19
- cli.run(['init', adrDirectory], { cwd: workDir });
20
- });
21
-
22
- afterEach(() => {
23
- rmSync(workDir, {
24
- recursive: true,
25
- force: true,
26
- maxRetries: 3,
27
- retryDelay: 500
28
- });
29
- });
30
-
31
- it('should list an empty directory', async () => {
32
- const output = cli.run(['list'], { cwd: workDir }).replace(/\r\n/g, '\n');
33
- expect(output).toEqual(path.join('doc', 'adr', '0001-record-architecture-decisions.md'));
34
- });
35
-
36
- it('should list when there is an additional one', async () => {
37
- cli.run(['new', 'first'], { cwd: workDir });
38
- const output = cli.run(['list'], { cwd: workDir }).replace(/\r\n/g, '\n');
39
- expect(output).toEqual(
40
- [path.join('doc', 'adr', '0001-record-architecture-decisions.md'), path.join('doc', 'adr', '0002-first.md')].join(
41
- '\n'
42
- )
43
- );
44
- });
45
-
46
- it('should list when there are more', async () => {
47
- cli.run(['new', 'first'], { cwd: workDir });
48
- cli.run(['new', 'second'], { cwd: workDir });
49
- cli.run(['new', 'third'], { cwd: workDir });
50
- const output = cli.run(['list'], { cwd: workDir }).replace(/\r\n/g, '\n');
51
- expect(output).toEqual(
52
- [
53
- path.join('doc', 'adr', '0001-record-architecture-decisions.md'),
54
- path.join('doc', 'adr', '0002-first.md'),
55
- path.join('doc', 'adr', '0003-second.md'),
56
- path.join('doc', 'adr', '0004-third.md')
57
- ].join('\n')
58
- );
59
- });
60
- });
@@ -1,62 +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
- describe('New Adrs', () => {
9
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const cli = createAdrCli(adr);
11
-
12
- let adrDirectory: string;
13
- let workDir: string;
14
-
15
- beforeEach(() => {
16
- // @ts-ignore
17
- process.env.ADR_DATE = '1992-01-12';
18
- workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
19
- adrDirectory = path.join(workDir, 'doc/adr');
20
- });
21
-
22
- afterEach(() => {
23
- fs.rmSync(workDir, {
24
- recursive: true,
25
- force: true,
26
- maxRetries: 3,
27
- retryDelay: 500
28
- });
29
- });
30
-
31
- it('should create a new one normally', () => {
32
- cli.run(['init', adrDirectory], { cwd: workDir });
33
- cli.run(['new', 'Example', 'ADR'], { cwd: workDir });
34
-
35
- const expectedNewFile: string = path.join(adrDirectory, '0002-example-adr.md');
36
- expect(fs.existsSync(expectedNewFile)).toBeTruthy();
37
-
38
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
39
- expect(fileContents).toMatchSnapshot();
40
- });
41
-
42
- it('should create a new one even if no config exists', () => {
43
- cli.run(['new', 'Example', 'ADR'], { cwd: workDir });
44
-
45
- const expectedNewFile: string = path.join(adrDirectory, '0001-example-adr.md');
46
- expect(fs.existsSync(expectedNewFile)).toBeTruthy();
47
-
48
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
49
- expect(fileContents).toMatchSnapshot();
50
- });
51
-
52
- it('should create a table of contents upon creation', () => {
53
- cli.run(['init', adrDirectory], { cwd: workDir });
54
- cli.run(['new', 'Example', 'ADR'], { cwd: workDir });
55
-
56
- const expectedNewFile: string = path.join(adrDirectory, 'decisions.md');
57
- expect(fs.existsSync(expectedNewFile)).toBeTruthy();
58
-
59
- const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
60
- expect(fileContents).toMatchSnapshot();
61
- });
62
- });
@@ -1,53 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as os from 'node:os';
3
- import * as path from 'node:path';
4
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
5
- import { createAdrCli } from './helpers/adr-cli';
6
-
7
- const waitForFile = async (filePath: string, timeoutMs: number) => {
8
- const startedAt = Date.now();
9
- while (Date.now() - startedAt < timeoutMs) {
10
- if (fs.existsSync(filePath)) {
11
- return;
12
- }
13
- await new Promise((r) => setTimeout(r, 25));
14
- }
15
- throw new Error(`Timed out waiting for file: ${filePath}`);
16
- };
17
-
18
- describe('--open-with', () => {
19
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
20
- const cli = createAdrCli(adr);
21
- const visualHelper =
22
- process.platform === 'win32'
23
- ? path.resolve(path.dirname(__filename), './fake-visual.cmd')
24
- : path.resolve(path.dirname(__filename), './fake-visual');
25
-
26
- let workDir: string;
27
- let adrDirectory: string;
28
-
29
- beforeEach(() => {
30
- // @ts-ignore
31
- process.env.ADR_DATE = '1992-01-12';
32
- workDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-')));
33
- adrDirectory = path.resolve(path.join(workDir, 'doc/adr'));
34
- });
35
-
36
- afterEach(async () => {
37
- if (process.platform === 'win32') {
38
- await new Promise((r) => setTimeout(r, 500));
39
- }
40
- fs.rmSync(workDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 });
41
- });
42
-
43
- it('opens the created ADR with the provided command', async () => {
44
- cli.run(['new', '--open-with', visualHelper, 'Example', 'ADR'], { cwd: workDir });
45
-
46
- const expectedOpenMarker: string = path.join(workDir, 'visual.out');
47
- await waitForFile(expectedOpenMarker, 2000);
48
-
49
- const contents = fs.readFileSync(expectedOpenMarker, 'utf8').trim();
50
- const openedPath = contents.replace(/^VISUAL\s+/, '');
51
- expect(path.normalize(openedPath)).toEqual(path.normalize(`${adrDirectory}/0001-example-adr.md`));
52
- });
53
- });
@@ -1,64 +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 { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Superseding Adrs', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
-
13
- let adrDirectory: string;
14
- let workDir: string;
15
-
16
- beforeEach(async () => {
17
- // @ts-ignore
18
- process.env.ADR_DATE = '1992-01-12';
19
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
20
- adrDirectory = path.join(workDir, 'doc/adr');
21
- });
22
-
23
- afterEach(() => {
24
- vi.clearAllMocks();
25
- rmSync(workDir, {
26
- recursive: true,
27
- force: true,
28
- maxRetries: 3,
29
- retryDelay: 500
30
- });
31
- });
32
-
33
- it('should be able to supersede previous adrs', async () => {
34
- cli.run(['new', 'First', 'Record'], { cwd: workDir });
35
- cli.run(['new', '-s', '1', 'Second', 'Record'], { cwd: workDir });
36
-
37
- const first: string = path.join(adrDirectory, '0001-first-record.md');
38
- const second: string = path.join(adrDirectory, '0002-second-record.md');
39
-
40
- const firstContent = await fs.readFile(first, 'utf8');
41
- const secondContent = await fs.readFile(second, 'utf8');
42
-
43
- expect(firstContent).toMatchSnapshot();
44
- expect(secondContent).toMatchSnapshot();
45
- });
46
-
47
- it('should be able to supersede multiple records', async () => {
48
- cli.run(['new', 'First', 'Record'], { cwd: workDir });
49
- cli.run(['new', 'Second', 'Record'], { cwd: workDir });
50
- cli.run(['new', '-s', '1', '-s', '2', 'Third', 'Record'], { cwd: workDir });
51
-
52
- const first: string = path.join(adrDirectory, '0001-first-record.md');
53
- const second: string = path.join(adrDirectory, '0002-second-record.md');
54
- const third: string = path.join(adrDirectory, '0003-third-record.md');
55
-
56
- const firstContent = await fs.readFile(first, 'utf8');
57
- const secondContent = await fs.readFile(second, 'utf8');
58
- const thirdContent = await fs.readFile(third, 'utf8');
59
-
60
- expect(firstContent).toMatchSnapshot();
61
- expect(secondContent).toMatchSnapshot();
62
- expect(thirdContent).toMatchSnapshot();
63
- });
64
- });
@@ -1,43 +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 { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Generating TOC', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
-
13
- let adrDirectory: string;
14
- let workDir: string;
15
-
16
- beforeEach(async () => {
17
- // @ts-ignore
18
- process.env.ADR_DATE = '1992-01-12';
19
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
20
- adrDirectory = path.join(workDir, 'doc/adr');
21
- });
22
-
23
- afterEach(() => {
24
- vi.clearAllMocks();
25
- rmSync(workDir, {
26
- recursive: true,
27
- force: true,
28
- maxRetries: 3,
29
- retryDelay: 500
30
- });
31
- });
32
-
33
- it('should add a path prefix to the toc when there is one supplied', async () => {
34
- cli.run(['new', 'First', 'Record'], { cwd: workDir });
35
- cli.run(['new', 'Second', 'Record'], { cwd: workDir });
36
- cli.run(['new', 'Third', 'Record'], { cwd: workDir });
37
- cli.run(['generate', 'toc', '-p', 'foo/doc/adr/'], { cwd: workDir });
38
-
39
- const tocFilePath: string = path.join(adrDirectory, 'decisions.md');
40
- const tocContent = await fs.readFile(tocFilePath, 'utf8');
41
- expect(tocContent).toMatchSnapshot();
42
- });
43
- });
@@ -1,52 +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 { afterEach, beforeEach, describe, expect, it } from 'vitest';
7
- import { createAdrCli } from './helpers/adr-cli';
8
-
9
- describe('Overriding templates', () => {
10
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const cli = createAdrCli(adr);
12
-
13
- let adrDirectory: string;
14
- let workDir: string;
15
-
16
- beforeEach(async () => {
17
- // @ts-ignore
18
- process.env.ADR_DATE = '1992-01-12';
19
- workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
20
- adrDirectory = path.join(workDir, 'doc/adr');
21
- cli.run(['init', adrDirectory], { cwd: workDir });
22
- });
23
-
24
- afterEach(() => {
25
- rmSync(workDir, {
26
- recursive: true,
27
- force: true,
28
- maxRetries: 3,
29
- retryDelay: 500
30
- });
31
- });
32
-
33
- it('should use an override template if one exists', async () => {
34
- await fs.mkdir(path.join(adrDirectory, 'templates'), { recursive: true });
35
- await fs.writeFile(
36
- path.join(adrDirectory, 'templates', 'template.md'),
37
- '# This is an override template\nTITLE\nDATE\nNUMBER\nSTATUS'
38
- );
39
-
40
- cli.run(['new', 'Example', 'ADR'], { cwd: workDir });
41
- cli.run(['new', 'Another', 'Example', 'ADR'], { cwd: workDir });
42
-
43
- const expectedFile: string = path.join(adrDirectory, '0002-example-adr.md');
44
- const expectedFile2: string = path.join(adrDirectory, '0003-another-example-adr.md');
45
-
46
- const fileContents = await fs.readFile(expectedFile, 'utf8');
47
- const fileContents2 = await fs.readFile(expectedFile2, 'utf8');
48
-
49
- expect(fileContents).toMatchSnapshot();
50
- expect(fileContents2).toMatchSnapshot();
51
- });
52
- });
@@ -1,48 +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
- describe('deep directories', () => {
9
- const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const cli = createAdrCli(adr);
11
-
12
- let adrDirectory: string;
13
- let workDir: string;
14
-
15
- beforeEach(() => {
16
- workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
17
- adrDirectory = path.join(workDir, 'doc/adr');
18
- cli.run(['init', adrDirectory], { cwd: workDir });
19
- });
20
-
21
- afterEach(() => {
22
- fs.rmSync(workDir, {
23
- recursive: true,
24
- force: true,
25
- maxRetries: 3,
26
- retryDelay: 500
27
- });
28
- });
29
-
30
- it('can work', () => {
31
- const innerPath = path.join(fs.mkdtempSync(path.resolve(workDir) + '/'), 'inner');
32
- fs.mkdirSync(innerPath, { recursive: true });
33
- cli.run(['new', 'this', 'should', 'exist'], { cwd: innerPath });
34
- const expectedFile: string = path.join(adrDirectory, '0002-this-should-exist.md');
35
- expect(fs.existsSync(expectedFile)).toBeTruthy();
36
- });
37
-
38
- it('can work when there has been no config initiated', () => {
39
- fs.rmSync(adrDirectory, { recursive: true, force: true });
40
- fs.rmSync(path.join(workDir, '.adr-dir'), { force: true });
41
-
42
- const innerPath = path.join(fs.mkdtempSync(path.resolve(workDir) + '/'), 'inner');
43
- fs.mkdirSync(innerPath, { recursive: true });
44
- cli.run(['new', 'this', 'should', 'exist'], { cwd: innerPath });
45
- const expectedFile: string = path.join(innerPath, 'doc', 'adr', '0001-this-should-exist.md');
46
- expect(fs.existsSync(expectedFile)).toBeTruthy();
47
- });
48
- });
package/tsconfig.json DELETED
@@ -1,55 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "sourceMap": true,
7
- "incremental": true,
8
- "allowUnreachableCode": false,
9
- "allowUnusedLabels": false,
10
- "strict": true,
11
- "exactOptionalPropertyTypes": true,
12
- "noFallthroughCasesInSwitch": true,
13
- "noImplicitAny": true,
14
- "noImplicitOverride": true,
15
- "noImplicitReturns": true,
16
- "noImplicitThis": true,
17
- "noPropertyAccessFromIndexSignature": true,
18
- "noUncheckedIndexedAccess": false,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "strictBindCallApply": true,
22
- "strictFunctionTypes": true,
23
- "strictNullChecks": true,
24
- "strictPropertyInitialization": true,
25
- "useUnknownInCatchVariables": true,
26
- "allowUmdGlobalAccess": false,
27
- "resolveJsonModule": true,
28
- "allowJs": false,
29
- "checkJs": false,
30
- "allowSyntheticDefaultImports": true,
31
- "esModuleInterop": true,
32
- "forceConsistentCasingInFileNames": true,
33
- "emitDecoratorMetadata": false,
34
- "experimentalDecorators": false,
35
- "emitDeclarationOnly": false,
36
- "declaration": true,
37
- "declarationMap": true,
38
- "skipDefaultLibCheck": true,
39
- "skipLibCheck": true,
40
- "preserveSymlinks": true,
41
- "outDir": "./dist",
42
- "rootDir": "./src",
43
- "declarationDir": "./dist/types",
44
- "isolatedModules": true,
45
- "sourceRoot": "src",
46
- "typeRoots": ["./node_modules/@types", "./src/types"],
47
- "types": ["node"]
48
- },
49
- "include": ["src/**/*"],
50
- "exclude": ["node_modules", "tests/**/*"],
51
- "ts-node": {
52
- "files": true
53
- },
54
- "files": ["src/types/environment.d.ts"]
55
- }
@@ -1,18 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- dir: 'tests',
6
- testTimeout: 30000,
7
- hookTimeout: 30000,
8
- pool: 'threads',
9
- fileParallelism: false,
10
- maxWorkers: 1,
11
- minWorkers: 1,
12
- watch: false,
13
- coverage: {
14
- reportsDirectory: './reports/coverage/e2e',
15
- reporter: ['text', 'json', 'html']
16
- }
17
- }
18
- });
package/vitest.config.ts DELETED
@@ -1,30 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- dir: 'src',
6
- isolate: true,
7
- testTimeout: 30000,
8
- hookTimeout: 30000,
9
- pool: 'threads',
10
- watch: false,
11
- fileParallelism: false,
12
- maxWorkers: 1,
13
- minWorkers: 1,
14
- coverage: {
15
- include: ['src/**/*.ts'],
16
- exclude: ['**/node_modules/**', '**/*.d.ts'],
17
- all: false,
18
- processingConcurrency: 1,
19
- thresholds: {
20
- branches: 100,
21
- functions: 100,
22
- lines: 100,
23
- statements: 100,
24
- perFile: true
25
- },
26
- reportsDirectory: './reports/coverage/unit',
27
- reporter: ['text', 'json', 'html']
28
- }
29
- }
30
- });