@commitlint/read 18.6.1 → 19.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -15
- package/lib/get-edit-commit.d.ts.map +1 -1
- package/lib/get-edit-commit.js +7 -14
- package/lib/get-edit-commit.js.map +1 -1
- package/lib/get-edit-file-path.js +9 -16
- package/lib/get-edit-file-path.js.map +1 -1
- package/lib/get-history-commits.d.ts.map +1 -1
- package/lib/get-history-commits.js +4 -11
- package/lib/get-history-commits.js.map +1 -1
- package/lib/read.d.ts.map +1 -1
- package/lib/read.js +7 -13
- package/lib/read.js.map +1 -1
- package/lib/stream-to-promise.d.ts +1 -1
- package/lib/stream-to-promise.js +1 -5
- package/lib/stream-to-promise.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
> Read commit messages from a specified range or last edit
|
|
2
|
-
|
|
3
1
|
# @commitlint/read
|
|
4
2
|
|
|
3
|
+
Read commit messages from a specified range or last edit
|
|
4
|
+
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
8
|
npm install --save @commitlint/read
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
const read = require('@commitlint/read').default;
|
|
11
|
+
## Documentation
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
read({edit: true}).then((messages) => console.log(messages));
|
|
18
|
-
// => ['I did something\n\n']
|
|
19
|
-
|
|
20
|
-
// Read from the third to second commit message from HEAD
|
|
21
|
-
read({from: 'HEAD~2', to: 'HEAD~1'}).then((messages) => console.log(messages));
|
|
22
|
-
// => ['Initial commit\n\n']
|
|
23
|
-
```
|
|
13
|
+
Consult [API docs](https://commitlint.js.org/api/read) for comprehensive documentation.
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
Documentation generated from [`docs` folder](../../docs/api/read.md).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-edit-commit.d.ts","sourceRoot":"","sources":["../src/get-edit-commit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-edit-commit.d.ts","sourceRoot":"","sources":["../src/get-edit-commit.ts"],"names":[],"mappings":"AAMA,wBAAsB,aAAa,CAClC,GAAG,CAAC,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GACrB,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
|
package/lib/get-edit-commit.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEditCommit = void 0;
|
|
7
|
-
const top_level_1 = __importDefault(require("@commitlint/top-level"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const get_edit_file_path_1 = require("./get-edit-file-path");
|
|
1
|
+
import toplevel from '@commitlint/top-level';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import { getEditFilePath } from './get-edit-file-path.js';
|
|
10
4
|
// Get recently edited commit message
|
|
11
|
-
async function getEditCommit(cwd, edit) {
|
|
12
|
-
const top = await (
|
|
5
|
+
export async function getEditCommit(cwd, edit) {
|
|
6
|
+
const top = await toplevel(cwd);
|
|
13
7
|
if (typeof top !== 'string') {
|
|
14
8
|
throw new TypeError(`Could not find git root from ${cwd}`);
|
|
15
9
|
}
|
|
16
|
-
const editFilePath = await
|
|
17
|
-
const editFile = await
|
|
10
|
+
const editFilePath = await getEditFilePath(top, edit);
|
|
11
|
+
const editFile = await fs.readFile(editFilePath);
|
|
18
12
|
return [`${editFile.toString('utf-8')}\n`];
|
|
19
13
|
}
|
|
20
|
-
exports.getEditCommit = getEditCommit;
|
|
21
14
|
//# sourceMappingURL=get-edit-commit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-edit-commit.js","sourceRoot":"","sources":["../src/get-edit-commit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-edit-commit.js","sourceRoot":"","sources":["../src/get-edit-commit.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAExD,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,GAAY,EACZ,IAAuB;IAEvB,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEhC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAW,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEzD,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEditFilePath = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs/promises';
|
|
9
3
|
// Get path to recently edited commit message file
|
|
10
|
-
async function getEditFilePath(top, edit) {
|
|
4
|
+
export async function getEditFilePath(top, edit) {
|
|
11
5
|
if (typeof edit === 'string') {
|
|
12
|
-
return
|
|
6
|
+
return path.resolve(top, edit);
|
|
13
7
|
}
|
|
14
|
-
const dotgitPath =
|
|
15
|
-
const dotgitStats = await
|
|
8
|
+
const dotgitPath = path.join(top, '.git');
|
|
9
|
+
const dotgitStats = await fs.lstat(dotgitPath);
|
|
16
10
|
if (dotgitStats.isDirectory()) {
|
|
17
|
-
return
|
|
11
|
+
return path.join(top, '.git/COMMIT_EDITMSG');
|
|
18
12
|
}
|
|
19
|
-
const gitFile = await
|
|
13
|
+
const gitFile = await fs.readFile(dotgitPath, {
|
|
20
14
|
encoding: 'utf-8',
|
|
21
15
|
});
|
|
22
16
|
const relativeGitPath = gitFile.replace('gitdir: ', '').replace('\n', '');
|
|
23
|
-
return
|
|
17
|
+
return path.resolve(top, relativeGitPath, 'COMMIT_EDITMSG');
|
|
24
18
|
}
|
|
25
|
-
exports.getEditFilePath = getEditFilePath;
|
|
26
19
|
//# sourceMappingURL=get-edit-file-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-edit-file-path.js","sourceRoot":"","sources":["../src/get-edit-file-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-edit-file-path.js","sourceRoot":"","sources":["../src/get-edit-file-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,kDAAkD;AAClD,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,GAAW,EACX,IAAuB;IAEvB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAU,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAEtD,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,OAAO,GAAW,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE;QACrD,QAAQ,EAAE,OAAO;KACjB,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-history-commits.d.ts","sourceRoot":"","sources":["../src/get-history-commits.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-history-commits.d.ts","sourceRoot":"","sources":["../src/get-history-commits.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAK5C,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,aAAa,CAAC,UAAU,EACjC,IAAI,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAM,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHistoryCommits = void 0;
|
|
7
|
-
const git_raw_commits_1 = __importDefault(require("git-raw-commits"));
|
|
8
|
-
const stream_to_promise_1 = require("./stream-to-promise");
|
|
1
|
+
import gitRawCommits from 'git-raw-commits';
|
|
2
|
+
import { streamToPromise } from './stream-to-promise.js';
|
|
9
3
|
// Get commit messages from history
|
|
10
|
-
async function getHistoryCommits(options, opts = {}) {
|
|
11
|
-
return
|
|
4
|
+
export async function getHistoryCommits(options, opts = {}) {
|
|
5
|
+
return streamToPromise(gitRawCommits(options, { cwd: opts.cwd }));
|
|
12
6
|
}
|
|
13
|
-
exports.getHistoryCommits = getHistoryCommits;
|
|
14
7
|
//# sourceMappingURL=get-history-commits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-history-commits.js","sourceRoot":"","sources":["../src/get-history-commits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-history-commits.js","sourceRoot":"","sources":["../src/get-history-commits.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD,mCAAmC;AACnC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAAiC,EACjC,OAAuB,EAAE;IAEzB,OAAO,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAC,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
package/lib/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAMA,UAAU,uBAAuB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAA8B,iBAAiB,CAC9C,QAAQ,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB"}
|
package/lib/read.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
7
|
-
const get_history_commits_1 = require("./get-history-commits");
|
|
8
|
-
const get_edit_commit_1 = require("./get-edit-commit");
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
import { getHistoryCommits } from './get-history-commits.js';
|
|
3
|
+
import { getEditCommit } from './get-edit-commit.js';
|
|
9
4
|
// Get commit messages
|
|
10
|
-
async function getCommitMessages(settings) {
|
|
5
|
+
export default async function getCommitMessages(settings) {
|
|
11
6
|
const { cwd, from, to, edit, gitLogArgs } = settings;
|
|
12
7
|
if (edit) {
|
|
13
|
-
return
|
|
8
|
+
return getEditCommit(cwd, edit);
|
|
14
9
|
}
|
|
15
10
|
let gitOptions = { from, to };
|
|
16
11
|
if (gitLogArgs) {
|
|
17
|
-
gitOptions = Object.assign(Object.assign({}, (
|
|
12
|
+
gitOptions = Object.assign(Object.assign({}, minimist(gitLogArgs.split(' '))), { from,
|
|
18
13
|
to });
|
|
19
14
|
}
|
|
20
|
-
return
|
|
15
|
+
return getHistoryCommits(gitOptions, { cwd });
|
|
21
16
|
}
|
|
22
|
-
exports.default = getCommitMessages;
|
|
23
17
|
//# sourceMappingURL=read.js.map
|
package/lib/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAUnD,sBAAsB;AACtB,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC9C,QAAiC;IAEjC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAC,GAAG,QAAQ,CAAC;IAEnD,IAAI,IAAI,EAAE,CAAC;QACV,OAAO,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,UAAU,GAAe,EAAC,IAAI,EAAE,EAAE,EAAC,CAAC;IACxC,IAAI,UAAU,EAAE,CAAC;QAChB,UAAU,mCACN,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAClC,IAAI;YACJ,EAAE,GACF,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAC,UAAU,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;AAC7C,CAAC"}
|
package/lib/stream-to-promise.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.streamToPromise = void 0;
|
|
4
|
-
function streamToPromise(stream) {
|
|
1
|
+
export function streamToPromise(stream) {
|
|
5
2
|
const data = [];
|
|
6
3
|
return new Promise((resolve, reject) => stream
|
|
7
4
|
.on('data', (chunk) => data.push(chunk.toString('utf-8')))
|
|
8
5
|
.on('error', reject)
|
|
9
6
|
.on('end', () => resolve(data)));
|
|
10
7
|
}
|
|
11
|
-
exports.streamToPromise = streamToPromise;
|
|
12
8
|
//# sourceMappingURL=stream-to-promise.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-promise.js","sourceRoot":"","sources":["../src/stream-to-promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream-to-promise.js","sourceRoot":"","sources":["../src/stream-to-promise.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,MAAgB;IAC/C,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CACtC,MAAM;SACJ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;SACnB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAChC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/read",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "19.0.0",
|
|
4
5
|
"description": "Read commit messages from a specified range or last edit",
|
|
5
6
|
"main": "lib/read.js",
|
|
6
7
|
"types": "lib/read.d.ts",
|
|
@@ -35,17 +36,17 @@
|
|
|
35
36
|
},
|
|
36
37
|
"license": "MIT",
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@commitlint/test": "^
|
|
39
|
-
"@commitlint/utils": "^
|
|
39
|
+
"@commitlint/test": "^19.0.0",
|
|
40
|
+
"@commitlint/utils": "^19.0.0",
|
|
40
41
|
"@types/git-raw-commits": "^2.0.3",
|
|
41
42
|
"@types/minimist": "^1.2.4",
|
|
42
|
-
"execa": "^
|
|
43
|
+
"execa": "^8.0.1"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@commitlint/top-level": "^
|
|
46
|
-
"@commitlint/types": "^
|
|
47
|
-
"git-raw-commits": "^
|
|
48
|
-
"minimist": "^1.2.
|
|
46
|
+
"@commitlint/top-level": "^19.0.0",
|
|
47
|
+
"@commitlint/types": "^19.0.0",
|
|
48
|
+
"git-raw-commits": "^4.0.0",
|
|
49
|
+
"minimist": "^1.2.8"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f1ff12159d627ee63bf8982ab02e6cca8f10b09f"
|
|
51
52
|
}
|