@commitlint/read
Advanced tools
Comparing version 18.6.1 to 19.0.0
@@ -1,21 +0,14 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEditCommit = void 0; | ||
const top_level_1 = __importDefault(require("@commitlint/top-level")); | ||
const promises_1 = __importDefault(require("fs/promises")); | ||
const get_edit_file_path_1 = require("./get-edit-file-path"); | ||
import toplevel from '@commitlint/top-level'; | ||
import fs from 'fs/promises'; | ||
import { getEditFilePath } from './get-edit-file-path.js'; | ||
// Get recently edited commit message | ||
async function getEditCommit(cwd, edit) { | ||
const top = await (0, top_level_1.default)(cwd); | ||
export async function getEditCommit(cwd, edit) { | ||
const top = await toplevel(cwd); | ||
if (typeof top !== 'string') { | ||
throw new TypeError(`Could not find git root from ${cwd}`); | ||
} | ||
const editFilePath = await (0, get_edit_file_path_1.getEditFilePath)(top, edit); | ||
const editFile = await promises_1.default.readFile(editFilePath); | ||
const editFilePath = await getEditFilePath(top, edit); | ||
const editFile = await fs.readFile(editFilePath); | ||
return [`${editFile.toString('utf-8')}\n`]; | ||
} | ||
exports.getEditCommit = getEditCommit; | ||
//# sourceMappingURL=get-edit-commit.js.map |
@@ -1,26 +0,19 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEditFilePath = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
const promises_1 = __importDefault(require("fs/promises")); | ||
import path from 'path'; | ||
import fs from 'fs/promises'; | ||
// Get path to recently edited commit message file | ||
async function getEditFilePath(top, edit) { | ||
export async function getEditFilePath(top, edit) { | ||
if (typeof edit === 'string') { | ||
return path_1.default.resolve(top, edit); | ||
return path.resolve(top, edit); | ||
} | ||
const dotgitPath = path_1.default.join(top, '.git'); | ||
const dotgitStats = await promises_1.default.lstat(dotgitPath); | ||
const dotgitPath = path.join(top, '.git'); | ||
const dotgitStats = await fs.lstat(dotgitPath); | ||
if (dotgitStats.isDirectory()) { | ||
return path_1.default.join(top, '.git/COMMIT_EDITMSG'); | ||
return path.join(top, '.git/COMMIT_EDITMSG'); | ||
} | ||
const gitFile = await promises_1.default.readFile(dotgitPath, { | ||
const gitFile = await fs.readFile(dotgitPath, { | ||
encoding: 'utf-8', | ||
}); | ||
const relativeGitPath = gitFile.replace('gitdir: ', '').replace('\n', ''); | ||
return path_1.default.resolve(top, relativeGitPath, 'COMMIT_EDITMSG'); | ||
return path.resolve(top, relativeGitPath, 'COMMIT_EDITMSG'); | ||
} | ||
exports.getEditFilePath = getEditFilePath; | ||
//# sourceMappingURL=get-edit-file-path.js.map |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHistoryCommits = void 0; | ||
const git_raw_commits_1 = __importDefault(require("git-raw-commits")); | ||
const stream_to_promise_1 = require("./stream-to-promise"); | ||
import gitRawCommits from 'git-raw-commits'; | ||
import { streamToPromise } from './stream-to-promise.js'; | ||
// Get commit messages from history | ||
async function getHistoryCommits(options, opts = {}) { | ||
return (0, stream_to_promise_1.streamToPromise)((0, git_raw_commits_1.default)(options, { cwd: opts.cwd })); | ||
export async function getHistoryCommits(options, opts = {}) { | ||
return streamToPromise(gitRawCommits(options, { cwd: opts.cwd })); | ||
} | ||
exports.getHistoryCommits = getHistoryCommits; | ||
//# sourceMappingURL=get-history-commits.js.map |
@@ -1,23 +0,17 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const minimist_1 = __importDefault(require("minimist")); | ||
const get_history_commits_1 = require("./get-history-commits"); | ||
const get_edit_commit_1 = require("./get-edit-commit"); | ||
import minimist from 'minimist'; | ||
import { getHistoryCommits } from './get-history-commits.js'; | ||
import { getEditCommit } from './get-edit-commit.js'; | ||
// Get commit messages | ||
async function getCommitMessages(settings) { | ||
export default async function getCommitMessages(settings) { | ||
const { cwd, from, to, edit, gitLogArgs } = settings; | ||
if (edit) { | ||
return (0, get_edit_commit_1.getEditCommit)(cwd, edit); | ||
return getEditCommit(cwd, edit); | ||
} | ||
let gitOptions = { from, to }; | ||
if (gitLogArgs) { | ||
gitOptions = Object.assign(Object.assign({}, (0, minimist_1.default)(gitLogArgs.split(' '))), { from, | ||
gitOptions = Object.assign(Object.assign({}, minimist(gitLogArgs.split(' '))), { from, | ||
to }); | ||
} | ||
return (0, get_history_commits_1.getHistoryCommits)(gitOptions, { cwd }); | ||
return getHistoryCommits(gitOptions, { cwd }); | ||
} | ||
exports.default = getCommitMessages; | ||
//# sourceMappingURL=read.js.map |
@@ -1,4 +0,4 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Readable } from 'stream'; | ||
export declare function streamToPromise(stream: Readable): Promise<string[]>; | ||
//# sourceMappingURL=stream-to-promise.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.streamToPromise = void 0; | ||
function streamToPromise(stream) { | ||
export function streamToPromise(stream) { | ||
const data = []; | ||
@@ -11,3 +8,2 @@ return new Promise((resolve, reject) => stream | ||
} | ||
exports.streamToPromise = streamToPromise; | ||
//# sourceMappingURL=stream-to-promise.js.map |
{ | ||
"name": "@commitlint/read", | ||
"version": "18.6.1", | ||
"type": "module", | ||
"version": "19.0.0", | ||
"description": "Read commit messages from a specified range or last edit", | ||
@@ -38,15 +39,15 @@ "main": "lib/read.js", | ||
"devDependencies": { | ||
"@commitlint/test": "^18.0.0", | ||
"@commitlint/utils": "^18.6.1", | ||
"@commitlint/test": "^19.0.0", | ||
"@commitlint/utils": "^19.0.0", | ||
"@types/git-raw-commits": "^2.0.3", | ||
"@types/minimist": "^1.2.4", | ||
"execa": "^5.0.0" | ||
"execa": "^8.0.1" | ||
}, | ||
"dependencies": { | ||
"@commitlint/top-level": "^18.6.1", | ||
"@commitlint/types": "^18.6.1", | ||
"git-raw-commits": "^2.0.11", | ||
"minimist": "^1.2.6" | ||
"@commitlint/top-level": "^19.0.0", | ||
"@commitlint/types": "^19.0.0", | ||
"git-raw-commits": "^4.0.0", | ||
"minimist": "^1.2.8" | ||
}, | ||
"gitHead": "89f5bf91d1c11b1f457a6f0d99b8ea34583a9311" | ||
"gitHead": "f1ff12159d627ee63bf8982ab02e6cca8f10b09f" | ||
} |
@@ -1,5 +0,5 @@ | ||
> Read commit messages from a specified range or last edit | ||
# @commitlint/read | ||
Read commit messages from a specified range or last edit | ||
## Getting started | ||
@@ -11,16 +11,6 @@ | ||
## Example | ||
## Documentation | ||
```js | ||
const read = require('@commitlint/read').default; | ||
Consult [API docs](https://commitlint.js.org/api/read) for comprehensive documentation. | ||
// Read last edited commit message | ||
read({edit: true}).then((messages) => console.log(messages)); | ||
// => ['I did something\n\n'] | ||
// Read from the third to second commit message from HEAD | ||
read({from: 'HEAD~2', to: 'HEAD~1'}).then((messages) => console.log(messages)); | ||
// => ['Initial commit\n\n'] | ||
``` | ||
Consult [docs/api](https://conventional-changelog.github.io/commitlint/#/reference-api) for comprehensive documentation. | ||
Documentation generated from [`docs` folder](../../docs/api/read.md). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Yes
10654
78
16
+ Added@commitlint/top-level@19.5.0(transitive)
+ Added@commitlint/types@19.5.0(transitive)
+ Added@types/conventional-commits-parser@5.0.0(transitive)
+ Added@types/node@22.9.0(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addeddargs@8.1.0(transitive)
+ Addedfind-up@7.0.0(transitive)
+ Addedgit-raw-commits@4.0.0(transitive)
+ Addedlocate-path@7.2.0(transitive)
+ Addedmeow@12.1.1(transitive)
+ Addedp-limit@4.0.0(transitive)
+ Addedp-locate@6.0.0(transitive)
+ Addedpath-exists@5.0.0(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedunicorn-magic@0.1.0(transitive)
+ Addedyocto-queue@1.1.1(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@commitlint/top-level@18.6.1(transitive)
- Removed@commitlint/types@18.6.1(transitive)
- Removed@types/minimist@1.2.5(transitive)
- Removed@types/normalize-package-data@2.4.4(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedarrify@1.0.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcamelcase-keys@6.2.2(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removeddargs@7.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddecamelize-keys@1.1.1(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@4.1.05.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedgit-raw-commits@2.0.11(transitive)
- Removedhard-rejection@2.1.0(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.94.1.0(transitive)
- Removedindent-string@4.0.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedlocate-path@5.0.06.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlru-cache@6.0.0(transitive)
- Removedmap-obj@1.0.14.3.0(transitive)
- Removedmeow@8.1.2(transitive)
- Removedmin-indent@1.0.1(transitive)
- Removedminimist-options@4.1.0(transitive)
- Removednormalize-package-data@2.5.03.0.3(transitive)
- Removedp-limit@2.3.03.1.0(transitive)
- Removedp-locate@4.1.05.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedquick-lru@4.0.1(transitive)
- Removedread-pkg@5.2.0(transitive)
- Removedread-pkg-up@7.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedredent@3.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.27.6.3(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsplit2@3.2.2(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedstrip-indent@3.0.0(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedthrough2@4.0.2(transitive)
- Removedtrim-newlines@3.0.1(transitive)
- Removedtype-fest@0.18.10.6.00.8.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedyallist@4.0.0(transitive)
- Removedyargs-parser@20.2.9(transitive)
- Removedyocto-queue@0.1.0(transitive)
Updated@commitlint/types@^19.0.0
Updatedgit-raw-commits@^4.0.0
Updatedminimist@^1.2.8