@meza/adr-tools 1.0.10 → 1.0.12
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/.gitattributes +40 -0
- package/.github/renovate.json +5 -0
- package/.github/workflows/ci-pr.yml +50 -0
- package/.github/workflows/ci.yml +28 -20
- package/.github/workflows/sync-deps-to-main.yml +25 -0
- package/.github/workflows/sync-to-deps.yml +26 -0
- package/.releaserc.json +1 -13
- package/CHANGELOG.md +76 -0
- package/LICENSE +674 -0
- package/README.md +64 -5
- package/biome.json +148 -0
- package/dist/index.js +52 -82
- package/dist/index.js.map +1 -1
- package/dist/lib/adr.js +100 -126
- package/dist/lib/adr.js.map +1 -1
- package/dist/lib/config.js +20 -37
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/links.js +8 -25
- package/dist/lib/links.js.map +1 -1
- package/dist/lib/links.test.js +35 -64
- package/dist/lib/links.test.js.map +1 -1
- package/dist/lib/manipulator.js +22 -23
- package/dist/lib/manipulator.js.map +1 -1
- package/dist/lib/manipulator.test.js +59 -63
- package/dist/lib/manipulator.test.js.map +1 -1
- package/dist/lib/numbering.js +9 -48
- package/dist/lib/numbering.js.map +1 -1
- package/dist/lib/numbering.test.js +27 -44
- package/dist/lib/numbering.test.js.map +1 -1
- package/dist/lib/prompt.js +14 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/prompt.test.js +33 -0
- package/dist/lib/prompt.test.js.map +1 -0
- package/dist/lib/template.js +13 -26
- package/dist/lib/template.js.map +1 -1
- package/dist/types/lib/adr.d.ts.map +1 -1
- package/dist/types/lib/config.d.ts.map +1 -1
- package/dist/types/lib/links.d.ts.map +1 -1
- package/dist/types/lib/manipulator.d.ts.map +1 -1
- package/dist/types/lib/numbering.d.ts.map +1 -1
- package/dist/types/lib/prompt.d.ts +2 -0
- package/dist/types/lib/prompt.d.ts.map +1 -0
- package/dist/types/lib/prompt.test.d.ts +2 -0
- package/dist/types/lib/prompt.test.d.ts.map +1 -0
- package/dist/types/lib/template.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/version.js +1 -4
- package/dist/version.js.map +1 -1
- package/doc/adr/.adr-sequence.lock +1 -0
- package/doc/adr/decisions.md +3 -0
- package/package.json +73 -47
- package/src/index.ts +52 -27
- package/src/lib/adr.ts +68 -73
- package/src/lib/config.ts +3 -3
- package/src/lib/links.test.ts +8 -24
- package/src/lib/links.ts +2 -2
- package/src/lib/manipulator.test.ts +44 -47
- package/src/lib/manipulator.ts +22 -10
- package/src/lib/numbering.test.ts +5 -9
- package/src/lib/numbering.ts +4 -5
- package/src/lib/prompt.test.ts +42 -0
- package/src/lib/prompt.ts +14 -0
- package/src/lib/template.ts +7 -3
- package/src/version.ts +1 -1
- package/tests/.adr-dir +1 -0
- package/tests/__snapshots__/generate-graph.e2e.test.ts.snap +23 -23
- package/tests/__snapshots__/init-adr-repository.e2e.test.ts.snap +1 -1
- package/tests/__snapshots__/linking-records.e2e.test.ts.snap +1 -1
- package/tests/__snapshots__/new-adr.e2e.test.ts.snap +1 -1
- package/tests/__snapshots__/superseding-records.e2e.test.ts.snap +1 -1
- package/tests/__snapshots__/toc-prefixing.e2e.test.ts.snap +1 -1
- package/tests/__snapshots__/use-template-override.e2e.test.ts.snap +1 -1
- package/tests/edit-on-create.e2e.test.ts +17 -12
- package/tests/funny-characters.e2e.test.ts +28 -21
- package/tests/generate-graph.e2e.test.ts +21 -13
- package/tests/init-adr-repository.e2e.test.ts +12 -8
- package/tests/linking-records.e2e.test.ts +21 -14
- package/tests/list-adrs.e2e.test.ts +23 -18
- package/tests/new-adr.e2e.test.ts +15 -12
- package/tests/superseding-records.e2e.test.ts +16 -11
- package/tests/toc-prefixing.e2e.test.ts +15 -11
- package/tests/use-template-override.e2e.test.ts +18 -10
- package/tests/work-form-other-directories.e2e.test.ts +14 -12
- package/tsconfig.json +9 -8
- package/vitest.config.e2e.ts +13 -0
- package/vitest.config.ts +8 -1
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -23
- package/.github/dependabot.yml +0 -14
- package/.github/workflows/auto-merge.yml +0 -14
- package/doc/adr/0001-record-architecture-decisions.md +0 -21
- package/doc/adr/0002-using-heavy-e2e-tests.md +0 -20
- /package/src/{environment.d.ts → types/environment.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { askForClarification } from './prompt.js';
|
|
5
|
+
vi.mock('inquirer');
|
|
6
|
+
vi.mock('chalk', () => ({
|
|
7
|
+
default: {
|
|
8
|
+
blue: (str) => {
|
|
9
|
+
return `BLUE[${str}]`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
13
|
+
describe('The prompt helper', () => {
|
|
14
|
+
it('calls inquirer correctly', async () => {
|
|
15
|
+
const prompt = vi.mocked(inquirer.prompt);
|
|
16
|
+
prompt.mockResolvedValueOnce({ target: 'does not matter' });
|
|
17
|
+
const randomChoices = [faker.system.filePath(), faker.system.filePath(), faker.system.filePath()];
|
|
18
|
+
await askForClarification('this is the search string', randomChoices);
|
|
19
|
+
expect(prompt).toHaveBeenCalledOnce();
|
|
20
|
+
const calledWith = prompt.mock.calls[0][0];
|
|
21
|
+
expect(calledWith[0].type).toEqual('list');
|
|
22
|
+
expect(calledWith[0].choices).toEqual(randomChoices);
|
|
23
|
+
expect(calledWith[0].message).toMatchInlineSnapshot('"Which file do you want to link to for BLUE[this is the search string]?"');
|
|
24
|
+
});
|
|
25
|
+
it('returns the selected choice', async () => {
|
|
26
|
+
const prompt = vi.mocked(inquirer.prompt);
|
|
27
|
+
const randomResult = faker.system.filePath();
|
|
28
|
+
prompt.mockResolvedValueOnce({ target: randomResult });
|
|
29
|
+
const result = await askForClarification('this is the search string', ['does not matter']);
|
|
30
|
+
expect(result).toEqual(randomResult);
|
|
31
|
+
});
|
|
32
|
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,CAAC,CAAC,CAAe,CAAC;QACzD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAE,UAAU,CAAC,CAAC,CAAkB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,qBAAqB,CACjD,0EAA0E,CAC3E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAE1C,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAE7C,MAAM,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;QAEvD,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,2BAA2B,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAE3F,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/lib/template.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.template = void 0;
|
|
16
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const config_1 = require("./config");
|
|
19
|
-
const template = (templateFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import { getDir } from './config.js';
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
export const template = async (templateFile) => {
|
|
20
8
|
if (templateFile) {
|
|
21
|
-
return
|
|
9
|
+
return await fs.readFile(path.resolve(templateFile), 'utf8');
|
|
22
10
|
}
|
|
23
11
|
if (process.env.ADR_TEMPLATE) {
|
|
24
|
-
return
|
|
12
|
+
return await fs.readFile(path.resolve(process.env.ADR_TEMPLATE), 'utf8');
|
|
25
13
|
}
|
|
26
14
|
try {
|
|
27
|
-
return
|
|
15
|
+
return await fs.readFile(path.join(await getDir(), 'templates/template.md'), 'utf8');
|
|
28
16
|
}
|
|
29
|
-
catch (
|
|
30
|
-
return
|
|
17
|
+
catch (_e) {
|
|
18
|
+
return await fs.readFile(path.resolve(path.join(__dirname, '../templates/template.md')), 'utf8');
|
|
31
19
|
}
|
|
32
|
-
}
|
|
33
|
-
exports.template = template;
|
|
20
|
+
};
|
|
34
21
|
//# sourceMappingURL=template.js.map
|
package/dist/lib/template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"src/","sources":["lib/template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"src/","sources":["lib/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;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E,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AA6GD,eAAO,MAAM,WAAW,GAAU,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,kBAc9D,CAAC;AAEF,eAAO,MAAM,MAAM,GAAU,OAAO,MAAM,EAAE,SAAS,UAAU,kBAuC9D,CAAC;AAEF,eAAO,MAAM,IAAI,GAAU,YAAY,MAAM,kBAQ5C,CAAC;AAEF,eAAO,MAAM,IAAI,GACf,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,aAAa,MAAM,EACnB,UAAU;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,kBAqB9B,CAAC;AAEF,eAAO,MAAM,QAAQ,yBAapB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"src/","sources":["lib/config.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,cAAsB,CAAC;AAyB9C,eAAO,MAAM,MAAM,QAAa,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"src/","sources":["lib/config.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,cAAsB,CAAC;AAyB9C,eAAO,MAAM,MAAM,QAAa,OAAO,CAAC,MAAM,CAI7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"src/","sources":["lib/links.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"src/","sources":["lib/links.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,oBAAoB,GAAU,SAAS,MAAM,sBAGzD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,EAAE,cAAa,OAAe,KAAG,OAAO,CAAC,WAAW,CAiB1G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manipulator.d.ts","sourceRoot":"src/","sources":["lib/manipulator.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"manipulator.d.ts","sourceRoot":"src/","sources":["lib/manipulator.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM;;;;;;GAmB5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,WAOvC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,EAAE,MAAM,MAAM,WA+BvD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,EAAE,MAAM,MAAM,WA4BxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbering.d.ts","sourceRoot":"src/","sources":["lib/numbering.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"numbering.d.ts","sourceRoot":"src/","sources":["lib/numbering.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,uBAoBrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"src/","sources":["lib/prompt.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,GAAU,cAAc,MAAM,EAAE,SAAS,MAAM,EAAE,iBAUhF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.test.d.ts","sourceRoot":"src/","sources":["lib/prompt.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"src/","sources":["lib/template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"src/","sources":["lib/template.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,MAAM,CAapE,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "1.0.
|
|
1
|
+
export declare const LIB_VERSION = "1.0.12";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"src/","sources":["version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"src/","sources":["version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meza/adr-tools",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"import": {
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"default": "dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
5
12
|
"bin": {
|
|
6
13
|
"adr": "dist/index.js"
|
|
7
14
|
},
|
|
15
|
+
"license": "GPL-3.0",
|
|
16
|
+
"type": "module",
|
|
8
17
|
"types": "dist/index.d.ts",
|
|
9
18
|
"private": false,
|
|
10
19
|
"scripts": {
|
|
@@ -13,30 +22,30 @@
|
|
|
13
22
|
"copy": "copyfiles -u 1 ./src/templates/** ./dist",
|
|
14
23
|
"build": "tsc && yarn copy",
|
|
15
24
|
"start": "ts-node src/index.ts",
|
|
16
|
-
"commit": "
|
|
17
|
-
"ci": "npm set editor '' &&
|
|
25
|
+
"commit": "cz",
|
|
26
|
+
"ci": "npm set editor 'true' && npm-run-all --parallel lint test",
|
|
18
27
|
"ci:dev": "exit 0",
|
|
19
28
|
"clean": "rimraf dist .cache/tsbuildinfo",
|
|
20
29
|
"clean:all": "yarn clean && rm -rf node_modules .cache",
|
|
21
|
-
"lint:
|
|
30
|
+
"lint:ci": "biome ci --reporter=github",
|
|
22
31
|
"lint:tsc": "tsc --noEmit",
|
|
23
|
-
"lint
|
|
24
|
-
"
|
|
25
|
-
"test": "vitest",
|
|
32
|
+
"lint": "npm-run-all --parallel lint:*",
|
|
33
|
+
"test": "npm-run-all --parallel test:*",
|
|
34
|
+
"test:unit": "vitest",
|
|
35
|
+
"test:e2e": "vitest --config vitest.config.e2e.ts",
|
|
26
36
|
"prepare": "is-ci || husky install",
|
|
27
37
|
"report": "exit 0",
|
|
28
38
|
"semantic-release": "semantic-release",
|
|
29
39
|
"release": "semantic-release"
|
|
30
40
|
},
|
|
31
41
|
"dependencies": {
|
|
32
|
-
"@types/inquirer": "
|
|
33
|
-
"@types/
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"marked": "^4.0.17"
|
|
42
|
+
"@types/inquirer": "9.0.8",
|
|
43
|
+
"@types/node": "22.15.21",
|
|
44
|
+
"chalk": "5.4.1",
|
|
45
|
+
"commander": "12.1.0",
|
|
46
|
+
"core-js": "3.42.0",
|
|
47
|
+
"inquirer": "9.3.7",
|
|
48
|
+
"marked": "4.3.0"
|
|
40
49
|
},
|
|
41
50
|
"commitlint": {
|
|
42
51
|
"extends": [
|
|
@@ -52,37 +61,39 @@
|
|
|
52
61
|
}
|
|
53
62
|
},
|
|
54
63
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@commitlint/
|
|
57
|
-
"@commitlint/
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@semantic-release/
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"mock-cwd": "
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
64
|
+
"@biomejs/biome": "1.9.4",
|
|
65
|
+
"@commitlint/cli": "19.8.1",
|
|
66
|
+
"@commitlint/config-conventional": "19.8.1",
|
|
67
|
+
"@commitlint/prompt-cli": "19.8.1",
|
|
68
|
+
"@faker-js/faker": "9.8.0",
|
|
69
|
+
"@meza/adr-tools": "1.0.10",
|
|
70
|
+
"@meza/tsconfig-base": "1.1.0",
|
|
71
|
+
"@ryansonshine/commitizen": "4.2.8",
|
|
72
|
+
"@ryansonshine/cz-conventional-changelog": "3.3.4",
|
|
73
|
+
"@semantic-release/changelog": "6.0.3",
|
|
74
|
+
"@semantic-release/commit-analyzer": "13.0.1",
|
|
75
|
+
"@semantic-release/git": "10.0.1",
|
|
76
|
+
"@semantic-release/github": "11.0.2",
|
|
77
|
+
"@semantic-release/npm": "12.0.1",
|
|
78
|
+
"@semantic-release/release-notes-generator": "14.0.3",
|
|
79
|
+
"@types/uuid": "10.0.0",
|
|
80
|
+
"@vitest/ui": "3.1.4",
|
|
81
|
+
"copyfiles": "2.4.1",
|
|
82
|
+
"cross-env": "7.0.3",
|
|
83
|
+
"husky": "9.1.7",
|
|
84
|
+
"install-deps-postmerge": "2.0.1",
|
|
85
|
+
"is-ci": "4.1.0",
|
|
86
|
+
"lint-staged": "16.0.0",
|
|
87
|
+
"mock-cwd": "1.0.0",
|
|
88
|
+
"npm-run-all2": "8.0.3",
|
|
89
|
+
"rimraf": "6.0.1",
|
|
90
|
+
"semantic-release": "24.2.4",
|
|
91
|
+
"ts-node": "10.9.2",
|
|
92
|
+
"tsx": "^4.19.4",
|
|
93
|
+
"typescript": "5.8.3",
|
|
94
|
+
"uuid": "11.1.0",
|
|
95
|
+
"vitest": "3.1.4",
|
|
96
|
+
"yarn": "1.22.22"
|
|
86
97
|
},
|
|
87
98
|
"repository": {
|
|
88
99
|
"type": "git",
|
|
@@ -90,5 +101,20 @@
|
|
|
90
101
|
},
|
|
91
102
|
"publishConfig": {
|
|
92
103
|
"access": "public"
|
|
104
|
+
},
|
|
105
|
+
"config": {
|
|
106
|
+
"commitizen": {
|
|
107
|
+
"path": "./node_modules/@ryansonshine/cz-conventional-changelog"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"lint-staged": {
|
|
111
|
+
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
|
|
112
|
+
"biome check --files-ignore-unknown=true",
|
|
113
|
+
"biome check --write --no-errors-on-unmatched",
|
|
114
|
+
"biome check --write --organize-imports-enabled=false --no-errors-on-unmatched",
|
|
115
|
+
"biome check --write --unsafe --no-errors-on-unmatched",
|
|
116
|
+
"biome format --write --no-errors-on-unmatched",
|
|
117
|
+
"biome lint --write --no-errors-on-unmatched"
|
|
118
|
+
]
|
|
93
119
|
}
|
|
94
120
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { LIB_VERSION } from './version';
|
|
5
|
-
import { generateToc, init, link, listAdrs, newAdr } from './lib/adr';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import { workingDir } from './lib/config';
|
|
8
3
|
import * as path from 'path';
|
|
9
|
-
import
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { Command } from 'commander';
|
|
10
6
|
import fs from 'fs/promises';
|
|
7
|
+
import { generateToc, init, link, listAdrs, newAdr } from './lib/adr.js';
|
|
8
|
+
import { workingDir } from './lib/config.js';
|
|
9
|
+
import { getLinksFrom, getTitleFrom } from './lib/manipulator.js';
|
|
10
|
+
import { LIB_VERSION } from './version.js';
|
|
11
11
|
|
|
12
12
|
const program = new Command();
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ const collectSupersedes = (val: string, memo: string[]) => {
|
|
|
21
21
|
return memo;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const generateGraph = async (options?: {prefix: string
|
|
24
|
+
const generateGraph = async (options?: { prefix: string; extension: string }) => {
|
|
25
25
|
let text = 'digraph {\n';
|
|
26
26
|
text += ' node [shape=plaintext];\n';
|
|
27
27
|
text += ' subgraph {\n';
|
|
@@ -49,7 +49,6 @@ const generateGraph = async (options?: {prefix: string, extension :string}) => {
|
|
|
49
49
|
text += ` _${n} -> _${linksInADR[j].targetNumber} [label="${linksInADR[j].label}", weight=0]\n`;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
text += '}\n';
|
|
@@ -58,16 +57,30 @@ const generateGraph = async (options?: {prefix: string, extension :string}) => {
|
|
|
58
57
|
|
|
59
58
|
program.name('adr').version(LIB_VERSION).description('Manage Architecture Decision Logs');
|
|
60
59
|
|
|
61
|
-
program
|
|
60
|
+
program
|
|
61
|
+
.command('new')
|
|
62
62
|
.argument('<title...>', 'The title of the decision')
|
|
63
|
-
.option(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.option(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
.option(
|
|
64
|
+
'-q, --quiet',
|
|
65
|
+
'Do not ask for clarification. If multiple files match the search pattern, an error will be thrown.'
|
|
66
|
+
)
|
|
67
|
+
.option(
|
|
68
|
+
'-s, --supersede <SUPERSEDE>',
|
|
69
|
+
'A reference (number or partial filename) of a previous decision that the new decision supercedes.\n' +
|
|
70
|
+
'A Markdown link to the superceded ADR is inserted into the Status section.\n' +
|
|
71
|
+
'The status of the superceded ADR is changed to record that it has been superceded by the new ADR.',
|
|
72
|
+
collectSupersedes,
|
|
73
|
+
[]
|
|
74
|
+
)
|
|
75
|
+
.option(
|
|
76
|
+
'-l, --link "<TARGET:LINK:REVERSE-LINK>"',
|
|
77
|
+
'Links the new ADR to a previous ADR.\n' +
|
|
78
|
+
`${chalk.bold('TARGET')} is a reference (number or partial filename) of a previous decision.\n` +
|
|
79
|
+
`${chalk.bold('LINK')} is the description of the link created in the new ADR.\n` +
|
|
80
|
+
`${chalk.bold('REVERSE-LINK')} is the description of the link created in the existing ADR that will refer to the new ADR`,
|
|
81
|
+
collectLinks,
|
|
82
|
+
[]
|
|
83
|
+
)
|
|
71
84
|
.action(async (title: string[], options) => {
|
|
72
85
|
try {
|
|
73
86
|
await newAdr(title.join(' '), {
|
|
@@ -83,33 +96,45 @@ program.command('new')
|
|
|
83
96
|
|
|
84
97
|
const generate = program.command('generate');
|
|
85
98
|
|
|
86
|
-
generate
|
|
99
|
+
generate
|
|
100
|
+
.command('toc')
|
|
87
101
|
.option('-p, --prefix <PREFIX>', 'The prefix to use for each file link in the generated TOC.')
|
|
88
102
|
.action((options) => generateToc(options));
|
|
89
103
|
|
|
90
|
-
generate
|
|
104
|
+
generate
|
|
105
|
+
.command('graph')
|
|
91
106
|
.option('-p, --prefix <PREFIX>', 'Prefix each decision file link with PREFIX.')
|
|
92
|
-
.option(
|
|
107
|
+
.option(
|
|
108
|
+
'-e, --extension <EXTENSION>',
|
|
109
|
+
'the file extension of the documents to which generated links refer. Defaults to .html',
|
|
110
|
+
'.html'
|
|
111
|
+
)
|
|
93
112
|
.action(async (options) => {
|
|
94
113
|
await generateGraph(options);
|
|
95
114
|
});
|
|
96
115
|
|
|
97
|
-
program
|
|
116
|
+
program
|
|
117
|
+
.command('link')
|
|
98
118
|
.argument('<SOURCE>', 'Full or Partial reference number to an ADR')
|
|
99
119
|
.argument('<LINK>', 'The description of the link created in the SOURCE')
|
|
100
120
|
.argument('<TARGET>', 'Full or Partial reference number to an ADR')
|
|
101
121
|
.argument('<REVERSE-LINK>', 'The description of the link created in the TARGET')
|
|
102
|
-
.option(
|
|
122
|
+
.option(
|
|
123
|
+
'-q, --quiet',
|
|
124
|
+
'Do not ask for clarification. If multiple files match the search pattern, an error will be thrown.'
|
|
125
|
+
)
|
|
103
126
|
.action(link);
|
|
104
127
|
|
|
105
|
-
program
|
|
106
|
-
|
|
107
|
-
|
|
128
|
+
program
|
|
129
|
+
.command('init')
|
|
130
|
+
.argument('[directory]', 'Initialize a new ADR directory')
|
|
131
|
+
.action(async (directory?: string) => {
|
|
132
|
+
await init(directory);
|
|
133
|
+
});
|
|
108
134
|
|
|
109
135
|
program.command('list').action(async () => {
|
|
110
136
|
const adrs = await listAdrs();
|
|
111
|
-
console.log(adrs.map(adr => path.relative(workingDir(), adr)).join('\n'));
|
|
137
|
+
console.log(adrs.map((adr) => path.relative(workingDir(), adr)).join('\n'));
|
|
112
138
|
});
|
|
113
139
|
|
|
114
140
|
program.parse();
|
|
115
|
-
|