@meza/adr-tools 1.0.8 → 1.0.11

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 (109) hide show
  1. package/.gitattributes +40 -0
  2. package/.github/renovate.json +5 -0
  3. package/.github/workflows/ci-pr.yml +44 -0
  4. package/.github/workflows/ci.yml +21 -22
  5. package/.github/workflows/sync-deps-to-main.yml +25 -0
  6. package/.github/workflows/sync-to-deps.yml +26 -0
  7. package/.releaserc.json +2 -7
  8. package/CHANGELOG.md +84 -0
  9. package/LICENSE +674 -0
  10. package/README.md +64 -5
  11. package/biome.json +148 -0
  12. package/dist/index.js +105 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/lib/adr.js +177 -0
  15. package/dist/lib/adr.js.map +1 -0
  16. package/dist/lib/config.js +33 -0
  17. package/dist/lib/config.js.map +1 -0
  18. package/dist/lib/links.js +25 -0
  19. package/dist/lib/links.js.map +1 -0
  20. package/dist/lib/links.test.js +65 -0
  21. package/dist/lib/links.test.js.map +1 -0
  22. package/dist/lib/manipulator.js +84 -0
  23. package/dist/lib/manipulator.js.map +1 -0
  24. package/dist/lib/manipulator.test.js +76 -0
  25. package/dist/lib/manipulator.test.js.map +1 -0
  26. package/dist/lib/numbering.js +25 -0
  27. package/dist/lib/numbering.js.map +1 -0
  28. package/dist/lib/numbering.test.js +32 -0
  29. package/dist/lib/numbering.test.js.map +1 -0
  30. package/dist/lib/prompt.js +14 -0
  31. package/dist/lib/prompt.js.map +1 -0
  32. package/dist/lib/prompt.test.js +33 -0
  33. package/dist/lib/prompt.test.js.map +1 -0
  34. package/dist/lib/template.js +21 -0
  35. package/dist/lib/template.js.map +1 -0
  36. package/{doc/adr/0001-record-architecture-decisions.md → dist/templates/init.md} +2 -2
  37. package/dist/templates/template.md +19 -0
  38. package/dist/types/index.d.ts +3 -0
  39. package/dist/types/index.d.ts.map +1 -0
  40. package/dist/types/lib/adr.d.ts +18 -0
  41. package/dist/types/lib/adr.d.ts.map +1 -0
  42. package/dist/types/lib/config.d.ts +3 -0
  43. package/dist/types/lib/config.d.ts.map +1 -0
  44. package/dist/types/lib/links.d.ts +10 -0
  45. package/dist/types/lib/links.d.ts.map +1 -0
  46. package/dist/types/lib/links.test.d.ts +2 -0
  47. package/dist/types/lib/links.test.d.ts.map +1 -0
  48. package/dist/types/lib/manipulator.d.ts +11 -0
  49. package/dist/types/lib/manipulator.d.ts.map +1 -0
  50. package/dist/types/lib/manipulator.test.d.ts +2 -0
  51. package/dist/types/lib/manipulator.test.d.ts.map +1 -0
  52. package/dist/types/lib/numbering.d.ts +2 -0
  53. package/dist/types/lib/numbering.d.ts.map +1 -0
  54. package/dist/types/lib/numbering.test.d.ts +2 -0
  55. package/dist/types/lib/numbering.test.d.ts.map +1 -0
  56. package/dist/types/lib/prompt.d.ts +2 -0
  57. package/dist/types/lib/prompt.d.ts.map +1 -0
  58. package/dist/types/lib/prompt.test.d.ts +2 -0
  59. package/dist/types/lib/prompt.test.d.ts.map +1 -0
  60. package/dist/types/lib/template.d.ts +2 -0
  61. package/dist/types/lib/template.d.ts.map +1 -0
  62. package/dist/types/version.d.ts +2 -0
  63. package/dist/types/version.d.ts.map +1 -0
  64. package/dist/version.js +2 -0
  65. package/dist/version.js.map +1 -0
  66. package/doc/adr/.adr-sequence.lock +1 -0
  67. package/doc/adr/decisions.md +3 -0
  68. package/package.json +78 -48
  69. package/src/index.ts +52 -27
  70. package/src/lib/adr.ts +67 -72
  71. package/src/lib/config.ts +3 -3
  72. package/src/lib/links.test.ts +8 -24
  73. package/src/lib/links.ts +2 -2
  74. package/src/lib/manipulator.test.ts +44 -47
  75. package/src/lib/manipulator.ts +22 -10
  76. package/src/lib/numbering.test.ts +5 -9
  77. package/src/lib/numbering.ts +4 -5
  78. package/src/lib/prompt.test.ts +42 -0
  79. package/src/lib/prompt.ts +14 -0
  80. package/src/lib/template.ts +7 -3
  81. package/src/version.ts +1 -1
  82. package/tests/.adr-dir +1 -0
  83. package/tests/__snapshots__/generate-graph.e2e.test.ts.snap +23 -23
  84. package/tests/__snapshots__/init-adr-repository.e2e.test.ts.snap +1 -1
  85. package/tests/__snapshots__/linking-records.e2e.test.ts.snap +1 -1
  86. package/tests/__snapshots__/new-adr.e2e.test.ts.snap +1 -1
  87. package/tests/__snapshots__/superseding-records.e2e.test.ts.snap +1 -1
  88. package/tests/__snapshots__/toc-prefixing.e2e.test.ts.snap +1 -1
  89. package/tests/__snapshots__/use-template-override.e2e.test.ts.snap +1 -1
  90. package/tests/edit-on-create.e2e.test.ts +17 -12
  91. package/tests/funny-characters.e2e.test.ts +28 -21
  92. package/tests/generate-graph.e2e.test.ts +21 -13
  93. package/tests/init-adr-repository.e2e.test.ts +12 -8
  94. package/tests/linking-records.e2e.test.ts +21 -14
  95. package/tests/list-adrs.e2e.test.ts +23 -18
  96. package/tests/new-adr.e2e.test.ts +15 -12
  97. package/tests/superseding-records.e2e.test.ts +16 -11
  98. package/tests/toc-prefixing.e2e.test.ts +15 -11
  99. package/tests/use-template-override.e2e.test.ts +18 -10
  100. package/tests/work-form-other-directories.e2e.test.ts +14 -12
  101. package/tsconfig.json +9 -8
  102. package/vitest.config.e2e.ts +13 -0
  103. package/vitest.config.ts +8 -1
  104. package/.eslintignore +0 -2
  105. package/.eslintrc.json +0 -23
  106. package/.github/dependabot.yml +0 -14
  107. package/.github/workflows/auto-merge.yml +0 -14
  108. package/doc/adr/0002-using-heavy-e2e-tests.md +0 -20
  109. /package/src/{environment.d.ts → types/environment.d.ts} +0 -0
@@ -1,24 +1,25 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterAll, beforeAll, vi, afterEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
7
8
 
8
9
  describe('Generating Graphs', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
  let workDir: string;
12
13
 
13
14
  beforeAll(async () => {
14
15
  // @ts-ignore
15
16
  process.env.ADR_DATE = '1992-01-12';
16
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
17
- childProcess.execSync(`${command} init`, { cwd: workDir });
18
- childProcess.execSync(`${command} new An idea that seems good at the time`, { cwd: workDir });
19
- childProcess.execSync(`${command} new -s 2 A better idea`, { cwd: workDir });
20
- childProcess.execSync(`${command} new This will work`, { cwd: workDir });
21
- childProcess.execSync(`${command} new -s 3 The end`, { cwd: workDir });
17
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
18
+ childProcess.execSync(`${command} init`, { timeout: 10000, cwd: workDir });
19
+ childProcess.execSync(`${command} new An idea that seems good at the time`, { timeout: 10000, cwd: workDir });
20
+ childProcess.execSync(`${command} new -s 2 A better idea`, { timeout: 10000, cwd: workDir });
21
+ childProcess.execSync(`${command} new This will work`, { timeout: 10000, cwd: workDir });
22
+ childProcess.execSync(`${command} new -s 3 The end`, { timeout: 10000, cwd: workDir });
22
23
  });
23
24
 
24
25
  afterEach(() => {
@@ -26,18 +27,25 @@ describe('Generating Graphs', () => {
26
27
  });
27
28
 
28
29
  afterAll(() => {
29
- childProcess.execSync(`rm -rf ${workDir}`);
30
+ rmdirSync(workDir, {
31
+ recursive: true,
32
+ maxRetries: 3,
33
+ retryDelay: 500
34
+ });
30
35
  });
31
36
 
32
37
  it('should generate a graph', async () => {
33
- const child = childProcess.execSync(`${command} generate graph`, { cwd: workDir });
38
+ const child = childProcess.execSync(`${command} generate graph`, { timeout: 10000, cwd: workDir });
34
39
  const childContent = child.toString().trim();
35
40
 
36
41
  expect(childContent).toMatchSnapshot();
37
42
  });
38
43
 
39
44
  it('should generate a graph with specified route and extension ', async () => {
40
- const child = childProcess.execSync(`${command} generate graph -p http://example.com/ -e .xxx`, { cwd: workDir });
45
+ const child = childProcess.execSync(`${command} generate graph -p http://example.com/ -e .xxx`, {
46
+ timeout: 10000,
47
+ cwd: workDir
48
+ });
41
49
  const childContent = child.toString().trim();
42
50
 
43
51
  expect(childContent).toMatchSnapshot();
@@ -1,13 +1,13 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
4
- import * as path from 'path';
5
2
  import * as fs from 'fs';
6
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
7
 
8
8
  describe('Init an ADR Repository', () => {
9
9
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
10
+ const command = `npx tsx ${adr}`;
11
11
 
12
12
  let adrDirectory: string;
13
13
  let workDir: string;
@@ -15,16 +15,20 @@ describe('Init an ADR Repository', () => {
15
15
  beforeEach(() => {
16
16
  // @ts-ignore
17
17
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'));
18
+ workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
19
19
  adrDirectory = path.join(workDir, 'doc/adr');
20
20
  });
21
21
 
22
22
  afterEach(() => {
23
- childProcess.execSync(`rm -rf ${workDir}`);
23
+ fs.rmdirSync(workDir, {
24
+ recursive: true,
25
+ maxRetries: 3,
26
+ retryDelay: 500
27
+ });
24
28
  });
25
29
 
26
30
  it('should use the default directory', () => {
27
- childProcess.execSync(`${command} init`, { cwd: workDir });
31
+ childProcess.execSync(`${command} init`, { timeout: 10000, cwd: workDir });
28
32
  const expectedFile: string = path.join(adrDirectory, '0001-record-architecture-decisions.md');
29
33
  const expectedLockFile: string = path.join(adrDirectory, '.adr-sequence.lock');
30
34
  expect(fs.existsSync(expectedFile)).toBeTruthy();
@@ -38,7 +42,7 @@ describe('Init an ADR Repository', () => {
38
42
 
39
43
  it('should use an alternate directory', () => {
40
44
  const directory: string = path.resolve(path.join(workDir, 'tmp', 'alternative-dir'));
41
- childProcess.execSync(`${command} init ${directory}`, { cwd: workDir });
45
+ childProcess.execSync(`${command} init ${directory}`, { timeout: 10000, cwd: workDir });
42
46
 
43
47
  const expectedInitFile: string = path.join(directory, '0001-record-architecture-decisions.md');
44
48
  const expectedLockFile: string = path.join(directory, '.adr-sequence.lock');
@@ -1,13 +1,14 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
8
 
8
9
  describe('Linking Adrs', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
 
12
13
  let adrDirectory: string;
13
14
  let workDir: string;
@@ -15,19 +16,25 @@ describe('Linking Adrs', () => {
15
16
  beforeEach(async () => {
16
17
  // @ts-ignore
17
18
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
19
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
19
20
  adrDirectory = path.join(workDir, 'doc/adr');
20
21
  });
21
22
 
22
23
  afterEach(() => {
23
24
  vi.clearAllMocks();
24
- childProcess.execSync(`rm -rf ${workDir}`);
25
+ rmdirSync(workDir, {
26
+ recursive: true,
27
+ maxRetries: 3,
28
+ retryDelay: 500
29
+ });
25
30
  });
26
31
 
27
32
  it('should link adrs as expected with adr new', async () => {
28
- childProcess.execSync(`${command} new First Record`, { cwd: workDir });
29
- childProcess.execSync(`${command} new Second Record`, { cwd: workDir });
30
- childProcess.execSync(`${command} new -q -l "1:Amends:Amended by" -l "2:Clarifies:Clarified by" Third Record`, { cwd: workDir });
33
+ childProcess.execSync(`${command} new First Record`, { timeout: 10000, cwd: workDir });
34
+ childProcess.execSync(`${command} new Second Record`, { timeout: 10000, cwd: workDir });
35
+ childProcess.execSync(`${command} new -q -l "1:Amends:Amended by" -l "2:Clarifies:Clarified by" Third Record`, {
36
+ cwd: workDir
37
+ });
31
38
 
32
39
  const first: string = path.join(adrDirectory, '0001-first-record.md');
33
40
  const second: string = path.join(adrDirectory, '0002-second-record.md');
@@ -43,11 +50,11 @@ describe('Linking Adrs', () => {
43
50
  });
44
51
 
45
52
  it('should link adrs as expected with adr link', async () => {
46
- childProcess.execSync(`${command} new First Record`, { cwd: workDir });
47
- childProcess.execSync(`${command} new Second Record`, { cwd: workDir });
48
- childProcess.execSync(`${command} new Third Record`, { cwd: workDir });
49
- childProcess.execSync(`${command} link 3 Amends 1 "Amended by"`, { cwd: workDir });
50
- childProcess.execSync(`${command} link 3 Clarifies 2 "Clarified by"`, { cwd: workDir });
53
+ childProcess.execSync(`${command} new First Record`, { timeout: 10000, cwd: workDir });
54
+ childProcess.execSync(`${command} new Second Record`, { timeout: 10000, cwd: workDir });
55
+ childProcess.execSync(`${command} new Third Record`, { timeout: 10000, cwd: workDir });
56
+ childProcess.execSync(`${command} link 3 Amends 1 "Amended by"`, { timeout: 10000, cwd: workDir });
57
+ childProcess.execSync(`${command} link 3 Clarifies 2 "Clarified by"`, { timeout: 10000, cwd: workDir });
51
58
 
52
59
  const first: string = path.join(adrDirectory, '0001-first-record.md');
53
60
  const second: string = path.join(adrDirectory, '0002-second-record.md');
@@ -1,48 +1,53 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
7
8
 
8
9
  describe('Listing', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
 
12
13
  let adrDirectory: string;
13
14
  let workDir: string;
14
15
 
15
16
  beforeEach(async () => {
16
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
17
- adrDirectory = path.join(workDir, 'doc/adr');
18
- childProcess.execSync(`${command} init ${adrDirectory}`, { cwd: workDir });
17
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
18
+ adrDirectory = 'doc/adr';
19
+ childProcess.execSync(`${command} init ${adrDirectory}`, { timeout: 10000, cwd: workDir });
19
20
  });
20
21
 
21
22
  afterEach(() => {
22
- childProcess.execSync(`rm -rf ${workDir}`);
23
+ rmdirSync(workDir, {
24
+ recursive: true,
25
+ maxRetries: 3,
26
+ retryDelay: 500
27
+ });
23
28
  });
24
29
 
25
30
  it('should list an empty directory', async () => {
26
- const child = childProcess.execSync(`${command} list`, { cwd: workDir });
31
+ const child = childProcess.execSync(`${command} list`, { timeout: 10000, cwd: workDir });
27
32
  const output = child.toString().trim();
28
33
  expect(output).toEqual('doc/adr/0001-record-architecture-decisions.md');
29
34
  });
30
35
 
31
36
  it('should list when there is an additional one', async () => {
32
- childProcess.execSync(`${command} new first`, { cwd: workDir });
33
- const child = childProcess.execSync(`${command} list`, { cwd: workDir });
37
+ childProcess.execSync(`${command} new first`, { timeout: 10000, cwd: workDir });
38
+ const child = childProcess.execSync(`${command} list`, { timeout: 10000, cwd: workDir });
34
39
  const output = child.toString().trim();
35
40
  expect(output).toEqual('doc/adr/0001-record-architecture-decisions.md\ndoc/adr/0002-first.md');
36
41
  });
37
42
 
38
43
  it('should list when there are more', async () => {
39
- childProcess.execSync(`${command} new first`, { cwd: workDir });
40
- childProcess.execSync(`${command} new second`, { cwd: workDir });
41
- childProcess.execSync(`${command} new third`, { cwd: workDir });
42
- const child = childProcess.execSync(`${command} list`, { cwd: workDir });
44
+ childProcess.execSync(`${command} new first`, { timeout: 10000, cwd: workDir });
45
+ childProcess.execSync(`${command} new second`, { timeout: 10000, cwd: workDir });
46
+ childProcess.execSync(`${command} new third`, { timeout: 10000, cwd: workDir });
47
+ const child = childProcess.execSync(`${command} list`, { timeout: 10000, cwd: workDir });
43
48
  const output = child.toString().trim();
44
- expect(output).toEqual('doc/adr/0001-record-architecture-decisions.md\ndoc/adr/0002-first.md\ndoc/adr/0003-second.md\ndoc/adr/0004-third.md');
49
+ expect(output).toEqual(
50
+ 'doc/adr/0001-record-architecture-decisions.md\ndoc/adr/0002-first.md\ndoc/adr/0003-second.md\ndoc/adr/0004-third.md'
51
+ );
45
52
  });
46
-
47
53
  });
48
-
@@ -1,13 +1,13 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
4
- import * as path from 'path';
5
2
  import * as fs from 'fs';
6
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
7
 
8
8
  describe('New Adrs', () => {
9
9
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
10
+ const command = `npx tsx ${adr}`;
11
11
 
12
12
  let adrDirectory: string;
13
13
  let workDir: string;
@@ -15,17 +15,21 @@ describe('New Adrs', () => {
15
15
  beforeEach(() => {
16
16
  // @ts-ignore
17
17
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'));
18
+ workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
19
19
  adrDirectory = path.join(workDir, 'doc/adr');
20
20
  });
21
21
 
22
22
  afterEach(() => {
23
- childProcess.execSync(`rm -rf ${workDir}`);
23
+ fs.rmdirSync(workDir, {
24
+ recursive: true,
25
+ maxRetries: 3,
26
+ retryDelay: 500
27
+ });
24
28
  });
25
29
 
26
30
  it('should create a new one normally', () => {
27
- childProcess.execSync(`${command} init ${adrDirectory}`, { cwd: workDir });
28
- childProcess.execSync(`${command} new Example ADR`, { cwd: workDir });
31
+ childProcess.execSync(`${command} init ${adrDirectory}`, { timeout: 10000, cwd: workDir });
32
+ childProcess.execSync(`${command} new Example ADR`, { timeout: 10000, cwd: workDir });
29
33
 
30
34
  const expectedNewFile: string = path.join(adrDirectory, '0002-example-adr.md');
31
35
  expect(fs.existsSync(expectedNewFile)).toBeTruthy();
@@ -35,7 +39,7 @@ describe('New Adrs', () => {
35
39
  });
36
40
 
37
41
  it('should create a new one even if no config exists', () => {
38
- childProcess.execSync(`${command} new Example ADR`, { cwd: workDir });
42
+ childProcess.execSync(`${command} new Example ADR`, { timeout: 10000, cwd: workDir });
39
43
 
40
44
  const expectedNewFile: string = path.join(adrDirectory, '0001-example-adr.md');
41
45
  expect(fs.existsSync(expectedNewFile)).toBeTruthy();
@@ -45,8 +49,8 @@ describe('New Adrs', () => {
45
49
  });
46
50
 
47
51
  it('should create a table of contents upon creation', () => {
48
- childProcess.execSync(`${command} init ${adrDirectory}`, { cwd: workDir });
49
- childProcess.execSync(`${command} new Example ADR`, { cwd: workDir });
52
+ childProcess.execSync(`${command} init ${adrDirectory}`, { timeout: 10000, cwd: workDir });
53
+ childProcess.execSync(`${command} new Example ADR`, { timeout: 10000, cwd: workDir });
50
54
 
51
55
  const expectedNewFile: string = path.join(adrDirectory, 'decisions.md');
52
56
  expect(fs.existsSync(expectedNewFile)).toBeTruthy();
@@ -54,5 +58,4 @@ describe('New Adrs', () => {
54
58
  const fileContents = fs.readFileSync(expectedNewFile, 'utf8');
55
59
  expect(fileContents).toMatchSnapshot();
56
60
  });
57
-
58
61
  });
@@ -1,13 +1,14 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
8
 
8
9
  describe('Superseding Adrs', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
 
12
13
  let adrDirectory: string;
13
14
  let workDir: string;
@@ -15,18 +16,22 @@ describe('Superseding Adrs', () => {
15
16
  beforeEach(async () => {
16
17
  // @ts-ignore
17
18
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
19
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
19
20
  adrDirectory = path.join(workDir, 'doc/adr');
20
21
  });
21
22
 
22
23
  afterEach(() => {
23
24
  vi.clearAllMocks();
24
- childProcess.execSync(`rm -rf ${workDir}`);
25
+ rmdirSync(workDir, {
26
+ recursive: true,
27
+ maxRetries: 3,
28
+ retryDelay: 500
29
+ });
25
30
  });
26
31
 
27
32
  it('should be able to supersede previous adrs', async () => {
28
- childProcess.execSync(`${command} new First Record`, { cwd: workDir });
29
- childProcess.execSync(`${command} new -s 1 Second Record`, { cwd: workDir });
33
+ childProcess.execSync(`${command} new First Record`, { timeout: 10000, cwd: workDir });
34
+ childProcess.execSync(`${command} new -s 1 Second Record`, { timeout: 10000, cwd: workDir });
30
35
 
31
36
  const first: string = path.join(adrDirectory, '0001-first-record.md');
32
37
  const second: string = path.join(adrDirectory, '0002-second-record.md');
@@ -39,9 +44,9 @@ describe('Superseding Adrs', () => {
39
44
  });
40
45
 
41
46
  it('should be able to supersede multiple records', async () => {
42
- childProcess.execSync(`${command} new First Record`, { cwd: workDir });
43
- childProcess.execSync(`${command} new Second Record`, { cwd: workDir });
44
- childProcess.execSync(`${command} new -s 1 -s 2 Third Record`, { cwd: workDir });
47
+ childProcess.execSync(`${command} new First Record`, { timeout: 10000, cwd: workDir });
48
+ childProcess.execSync(`${command} new Second Record`, { timeout: 10000, cwd: workDir });
49
+ childProcess.execSync(`${command} new -s 1 -s 2 Third Record`, { timeout: 10000, cwd: workDir });
45
50
 
46
51
  const first: string = path.join(adrDirectory, '0001-first-record.md');
47
52
  const second: string = path.join(adrDirectory, '0002-second-record.md');
@@ -1,13 +1,14 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
8
 
8
9
  describe('Generating TOC', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
 
12
13
  let adrDirectory: string;
13
14
  let workDir: string;
@@ -15,24 +16,27 @@ describe('Generating TOC', () => {
15
16
  beforeEach(async () => {
16
17
  // @ts-ignore
17
18
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
19
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
19
20
  adrDirectory = path.join(workDir, 'doc/adr');
20
21
  });
21
22
 
22
23
  afterEach(() => {
23
24
  vi.clearAllMocks();
24
- childProcess.execSync(`rm -rf ${workDir}`);
25
+ rmdirSync(workDir, {
26
+ recursive: true,
27
+ maxRetries: 3,
28
+ retryDelay: 500
29
+ });
25
30
  });
26
31
 
27
32
  it('should add a path prefix to the toc when there is one supplied', async () => {
28
- childProcess.execSync(`${command} new First Record`, { cwd: workDir });
29
- childProcess.execSync(`${command} new Second Record`, { cwd: workDir });
30
- childProcess.execSync(`${command} new Third Record`, { cwd: workDir });
31
- childProcess.execSync(`${command} generate toc -p foo/doc/adr/`, { cwd: workDir });
33
+ childProcess.execSync(`${command} new First Record`, { timeout: 10000, cwd: workDir });
34
+ childProcess.execSync(`${command} new Second Record`, { timeout: 10000, cwd: workDir });
35
+ childProcess.execSync(`${command} new Third Record`, { timeout: 10000, cwd: workDir });
36
+ childProcess.execSync(`${command} generate toc -p foo/doc/adr/`, { timeout: 10000, cwd: workDir });
32
37
 
33
38
  const tocFilePath: string = path.join(adrDirectory, 'decisions.md');
34
39
  const tocContent = await fs.readFile(tocFilePath, 'utf8');
35
40
  expect(tocContent).toMatchSnapshot();
36
41
  });
37
-
38
42
  });
@@ -1,13 +1,14 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
2
+ import { realpathSync, rmdirSync } from 'node:fs';
3
+ import * as os from 'os';
4
4
  import * as path from 'path';
5
5
  import * as fs from 'fs/promises';
6
- import * as os from 'os';
6
+ /* eslint-disable no-sync */
7
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
7
8
 
8
9
  describe('Overriding templates', () => {
9
10
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
10
- const command = `npx ts-node ${adr}`;
11
+ const command = `npx tsx ${adr}`;
11
12
 
12
13
  let adrDirectory: string;
13
14
  let workDir: string;
@@ -15,21 +16,28 @@ describe('Overriding templates', () => {
15
16
  beforeEach(async () => {
16
17
  // @ts-ignore
17
18
  process.env.ADR_DATE = '1992-01-12';
18
- workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'));
19
+ workDir = path.resolve(realpathSync(await fs.mkdtemp(path.join(os.tmpdir(), 'adr-'))));
19
20
  adrDirectory = path.join(workDir, 'doc/adr');
20
- childProcess.execSync(`${command} init ${adrDirectory}`, { cwd: workDir });
21
+ childProcess.execSync(`${command} init ${adrDirectory}`, { timeout: 10000, cwd: workDir });
21
22
  });
22
23
 
23
24
  afterEach(() => {
24
- childProcess.execSync(`rm -rf ${workDir}`);
25
+ rmdirSync(workDir, {
26
+ recursive: true,
27
+ maxRetries: 3,
28
+ retryDelay: 500
29
+ });
25
30
  });
26
31
 
27
32
  it('should use an override template if one exists', async () => {
28
33
  await fs.mkdir(path.join(adrDirectory, 'templates'), { recursive: true });
29
- await fs.writeFile(path.join(adrDirectory, 'templates', 'template.md'), '# This is an override template\nTITLE\nDATE\nNUMBER\nSTATUS');
34
+ await fs.writeFile(
35
+ path.join(adrDirectory, 'templates', 'template.md'),
36
+ '# This is an override template\nTITLE\nDATE\nNUMBER\nSTATUS'
37
+ );
30
38
 
31
- childProcess.execSync(`${command} new Example ADR`, { cwd: workDir });
32
- childProcess.execSync(`${command} new Another Example ADR`, { cwd: workDir });
39
+ childProcess.execSync(`${command} new Example ADR`, { timeout: 10000, cwd: workDir });
40
+ childProcess.execSync(`${command} new Another Example ADR`, { timeout: 10000, cwd: workDir });
33
41
 
34
42
  const expectedFile: string = path.join(adrDirectory, '0002-example-adr.md');
35
43
  const expectedFile2: string = path.join(adrDirectory, '0003-another-example-adr.md');
@@ -1,44 +1,46 @@
1
- /* eslint-disable no-sync */
2
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
3
1
  import * as childProcess from 'child_process';
4
- import * as path from 'path';
5
2
  import * as fs from 'fs';
6
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
7
 
8
8
  describe('deep directories', () => {
9
-
10
9
  const adr = path.resolve(path.dirname(__filename), '../src/index.ts');
11
- const command = `npx ts-node ${adr}`;
10
+ const command = `npx tsx ${adr}`;
12
11
 
13
12
  let adrDirectory: string;
14
13
  let workDir: string;
15
14
 
16
15
  beforeEach(() => {
17
- workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'));
16
+ workDir = path.resolve(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'adr-'))));
18
17
  adrDirectory = path.join(workDir, 'doc/adr');
19
- childProcess.execSync(`${command} init ${adrDirectory}`, { cwd: workDir });
18
+ childProcess.execSync(`${command} init ${adrDirectory}`, { timeout: 10000, cwd: workDir });
20
19
  });
21
20
 
22
21
  afterEach(() => {
23
- childProcess.execSync(`rm -rf ${workDir}`);
22
+ fs.rmdirSync(workDir, {
23
+ recursive: true,
24
+ maxRetries: 3,
25
+ retryDelay: 500
26
+ });
24
27
  });
25
28
 
26
29
  it('can work', () => {
27
30
  const innerPath = path.join(fs.mkdtempSync(path.resolve(workDir) + '/'), 'inner');
28
31
  fs.mkdirSync(innerPath, { recursive: true });
29
- childProcess.execSync(`${command} new this should exist`, { cwd: innerPath });
32
+ childProcess.execSync(`${command} new this should exist`, { timeout: 10000, cwd: innerPath });
30
33
  const expectedFile: string = path.join(adrDirectory, '0002-this-should-exist.md');
31
34
  expect(fs.existsSync(expectedFile)).toBeTruthy();
32
35
  });
33
36
 
34
37
  it('can work when there has been no config initiated', () => {
35
- childProcess.execSync(`rm -rf ${adrDirectory} ${workDir}/.adr-dir`);
38
+ childProcess.execSync(`rimraf ${adrDirectory} ${workDir}/.adr-dir`);
36
39
 
37
40
  const innerPath = path.join(fs.mkdtempSync(path.resolve(workDir) + '/'), 'inner');
38
41
  fs.mkdirSync(innerPath, { recursive: true });
39
- childProcess.execSync(`${command} new this should exist`, { cwd: innerPath });
42
+ childProcess.execSync(`${command} new this should exist`, { timeout: 10000, cwd: innerPath });
40
43
  const expectedFile: string = path.join(innerPath, 'doc', 'adr', '0001-this-should-exist.md');
41
44
  expect(fs.existsSync(expectedFile)).toBeTruthy();
42
45
  });
43
46
  });
44
-
package/tsconfig.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "extends": "@meza/tsconfig-base",
3
3
  "compilerOptions": {
4
- "target": "es6",
5
- "module": "commonjs",
4
+ "target": "ES2020",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "esModuleInterop": true,
6
8
  "emitDeclarationOnly": false,
7
9
  "skipDefaultLibCheck": true,
8
10
  "skipLibCheck": true,
9
11
  "outDir": "./dist",
10
12
  "declarationDir": "./dist/types",
11
13
  "isolatedModules": true,
12
- "sourceRoot": "src"
14
+ "sourceRoot": "src",
15
+ "typeRoots": ["./node_modules/@types", "./src/types"]
13
16
  },
14
17
  "include": ["src/**/*"],
15
18
  "exclude": ["node_modules", "tests/**/*"],
16
19
  "ts-node": {
17
- "compilerOptions": {
18
- "module": "commonjs",
19
- "noPropertyAccessFromIndexSignature": false
20
- }
21
- }
20
+ "files": true
21
+ },
22
+ "files": ["src/types/environment.d.ts"]
22
23
  }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ dir: 'tests',
6
+ testTimeout: 10000,
7
+ watch: false,
8
+ coverage: {
9
+ reportsDirectory: './reports/coverage/e2e',
10
+ reporter: ['text', 'json', 'html']
11
+ }
12
+ }
13
+ });
package/vitest.config.ts CHANGED
@@ -2,10 +2,17 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
+ dir: 'src',
5
6
  testTimeout: 10000,
6
7
  watch: false,
8
+ poolOptions: {
9
+ forks: {
10
+ singleFork: true,
11
+ isolate: true
12
+ }
13
+ },
7
14
  coverage: {
8
- reportsDirectory: './reports/coverage',
15
+ reportsDirectory: './reports/coverage/unit',
9
16
  reporter: ['text', 'json', 'html']
10
17
  }
11
18
  }
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- dist
package/.eslintrc.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": [
3
- "tailored-tunes",
4
- "plugin:json/recommended",
5
- "plugin:security/recommended"
6
- ],
7
- "root": true,
8
- "parser": "@typescript-eslint/parser",
9
- "plugins": [
10
- "json",
11
- "@typescript-eslint"
12
- ],
13
- "rules": {
14
- "no-console": "off",
15
- "security/detect-object-injection": 0,
16
- "security/detect-non-literal-fs-filename": 0
17
- },
18
- "env": {
19
- "commonjs": false,
20
- "es6": true,
21
- "node": true
22
- }
23
- }