@ljharb/coauthors 1.0.0 → 2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [v2.0.0](https://github.com/ljharb/coauthors/compare/v1.0.0...v2.0.0) - 2025-10-29
9
+
10
+ ### Commits
11
+
12
+ - [Refactor] use `pargs` package [`4b46ee9`](https://github.com/ljharb/coauthors/commit/4b46ee9f6ddefe5b936190d32bff54bd46eb45f2)
13
+ - [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig@latest`, `@types/node`, `@types/tape`, `auto-changelog`, `c8`, `esmock`, `tape` [`caede0a`](https://github.com/ljharb/coauthors/commit/caede0a44cc1ce0076e8ac01d5a5d75c92e43234)
14
+ - [Dev Deps] update `@types/node`, `esmock` [`09becac`](https://github.com/ljharb/coauthors/commit/09becacad05b12e30206f82f95a2f052789a05d7)
15
+ - [meta] fix binary name [`9db7fac`](https://github.com/ljharb/coauthors/commit/9db7fac087158cc3b5fe9476c670e04aa9546f76)
16
+ - [Tests] replace `aud` with `npm audit` [`59ad63a`](https://github.com/ljharb/coauthors/commit/59ad63aaeafb10492ba1ea010809b314e3942a8a)
17
+ - [Dev Deps] update `@types/node` [`00ffe27`](https://github.com/ljharb/coauthors/commit/00ffe270c1c21fceecb79424eeedc122a8ade21b)
18
+ - [Breaking] tighten engines requirements [`e33b6b0`](https://github.com/ljharb/coauthors/commit/e33b6b0e188aff796d7bc75ec7e62d804b759811)
19
+ - [Dev Deps] add missing peer dep [`5c5483b`](https://github.com/ljharb/coauthors/commit/5c5483b245b47e39beb5ff8e6799039442ba0a28)
20
+
8
21
  ## v1.0.0 - 2024-07-16
9
22
 
10
23
  ### Commits
package/README.md CHANGED
@@ -20,7 +20,7 @@ coauthors # if installed and in the PATH
20
20
  ```sh
21
21
  $ coauthors --help
22
22
  Usage:
23
- commit-to-co-authors <remote>
23
+ co-authors <remote>
24
24
 
25
25
  `remote` defaults to `origin`.
26
26
  ```
package/bin.mjs CHANGED
@@ -1,30 +1,15 @@
1
1
  #! /usr/bin/env node
2
2
 
3
- import { readFile } from 'fs/promises';
4
- import path from 'path';
5
-
6
3
  import validateRemote from './validateRemote.mjs';
7
4
  import getResults from './results.mjs';
8
5
 
9
- import pargs from './pargs.mjs';
10
-
11
- async function getHelpText() {
12
- return `${await readFile(path.join(import.meta.dirname, './help.txt'), 'utf-8')}`;
13
- }
6
+ import pargs from 'pargs';
14
7
 
15
8
  const {
16
- values: { help },
9
+ help,
17
10
  positionals,
18
11
  errors,
19
- } = await pargs(
20
- import.meta.filename,
21
- {
22
- options: {
23
- help: { type: 'boolean' },
24
- },
25
- allowPositionals: 1,
26
- },
27
- );
12
+ } = await pargs(import.meta.filename, { allowPositionals: 1 });
28
13
 
29
14
  const remote = validateRemote(positionals[0] ?? 'origin');
30
15
 
@@ -32,19 +17,7 @@ if (typeof remote !== 'string') {
32
17
  errors.push(remote.error);
33
18
  }
34
19
 
35
- if (help || errors.length > 0) {
36
- const helpText = await getHelpText();
37
- if (errors.length === 0) {
38
- console.log(helpText);
39
- } else {
40
- console.error(`${helpText}${errors.length === 0 ? '' : '\n'}`);
41
-
42
- process.exitCode ||= parseInt('1'.repeat(errors.length), 2);
43
- errors.forEach((error) => console.error(error));
44
- }
45
-
46
- process.exit();
47
- }
20
+ await help();
48
21
 
49
22
  // eslint-disable-next-line no-extra-parens
50
23
  const results = Array.from(getResults(/** @type {string} */ (remote)), (x) => `Co-authored-by: ${x}`);
package/help.txt CHANGED
@@ -1,4 +1,4 @@
1
1
  Usage:
2
- commit-to-co-authors <remote>
2
+ co-authors <remote>
3
3
 
4
4
  `remote` defaults to `origin`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ljharb/coauthors",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "A cli to generate a complete git co-authors list, including existing co-authors, for use in a commit message.",
5
5
  "bin": "./bin.mjs",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  "pretest": "npm run lint",
17
17
  "tests-only": "c8 tape 'test/**/*.*js'",
18
18
  "test": "npm run tests-only",
19
- "posttest": "aud --production",
19
+ "posttest": "npx npm@\">= 10.2\" audit --production",
20
20
  "version": "auto-changelog && git add CHANGELOG.md",
21
21
  "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
22
22
  },
@@ -38,25 +38,26 @@
38
38
  },
39
39
  "homepage": "https://github.com/ljharb/coauthors#readme",
40
40
  "dependencies": {
41
- "commit-to-co-authors": "^0.1.0"
41
+ "commit-to-co-authors": "^0.1.0",
42
+ "pargs": "^1.0.0"
42
43
  },
43
44
  "engines": {
44
- "node": ">= 22.4"
45
+ "node": "^22.20 || ^24.10 || >= 25"
45
46
  },
46
47
  "devDependencies": {
47
- "@ljharb/eslint-config": "^21.1.1",
48
- "@ljharb/tsconfig": "^0.2.0",
49
- "@types/node": "^20.14.10",
50
- "@types/tape": "^5.6.4",
51
- "aud": "^2.0.4",
52
- "auto-changelog": "^2.4.0",
53
- "c8": "^10.1.2",
48
+ "@ljharb/eslint-config": "^21.2.0",
49
+ "@ljharb/tsconfig": "^0.3.2",
50
+ "@types/node": "^22.18.13",
51
+ "@types/tape": "^5.8.1",
52
+ "auto-changelog": "^2.5.0",
53
+ "c8": "^10.1.3",
54
+ "encoding": "^0.1.13",
54
55
  "eslint": "^8.8.0",
55
- "esmock": "^2.6.6",
56
+ "esmock": "^2.7.3",
56
57
  "in-publish": "^2.0.1",
57
58
  "npmignore": "^0.3.1",
58
59
  "safe-publish-latest": "^2.0.0",
59
- "tape": "^5.8.1",
60
+ "tape": "^5.9.0",
60
61
  "typescript": "next"
61
62
  },
62
63
  "c8": {
package/pargs.mjs DELETED
@@ -1,119 +0,0 @@
1
- import { parseArgs } from 'util';
2
- import { realpathSync } from 'fs';
3
-
4
- /** @typedef {import('util').ParseArgsConfig} ParseArgsConfig */
5
-
6
- /** @typedef {(Error | TypeError) & { code: 'ERR_PARSE_ARGS_UNKNOWN_OPTION' | 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE' | 'ERR_INVALID_ARG_TYPE' | 'ERR_INVALID_ARG_VALUE' | 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL'}} ParseArgsError */
7
-
8
- /** @type {(e: unknown) => e is ParseArgsError} */
9
- function isParseArgsError(e) {
10
- return !!e
11
- && typeof e === 'object'
12
- && 'code' in e
13
- && (
14
- e.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION'
15
- || e.code === 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE'
16
- || e.code === 'ERR_INVALID_ARG_TYPE'
17
- || e.code === 'ERR_INVALID_ARG_VALUE'
18
- || e.code === 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL'
19
- );
20
- }
21
- /** @typedef {Omit<ParseArgsConfig, 'args' | 'strict' | 'allowPositionals'> & { allowPositionals?: boolean | number }} PargsConfig */
22
-
23
- /** @type {(entrypointPath: ImportMeta['filename'], obj: PargsConfig) => Promise<{ errors: string[] } & ReturnType<typeof parseArgs>>} */
24
- export default async function pargs(entrypointPath, obj) {
25
- const argv = process.argv.flatMap((arg) => {
26
- try {
27
- const realpathedArg = realpathSync(arg);
28
- if (
29
- realpathedArg === process.execPath
30
- || realpathedArg === entrypointPath
31
- ) {
32
- return [];
33
- }
34
- } catch (e) { /**/ }
35
- return arg;
36
- });
37
-
38
- if ('help' in obj) {
39
- throw new TypeError('The "help" option is reserved');
40
- }
41
-
42
- /** @type {ParseArgsConfig & { tokens: true }} */
43
- const newObj = {
44
- args: argv,
45
- ...obj,
46
- options: {
47
- ...obj.options,
48
- help: {
49
- default: false,
50
- type: 'boolean',
51
- },
52
- },
53
- tokens: true,
54
- // @ts-expect-error blocked on @types/node v22
55
- allowNegative: true,
56
- allowPositionals: typeof obj.allowPositionals !== 'undefined',
57
- strict: true,
58
- };
59
-
60
- const errors = [];
61
-
62
- try {
63
- const { tokens, ...results } = parseArgs(newObj);
64
-
65
- const posCount = typeof obj.allowPositionals === 'number' ? obj.allowPositionals : obj.allowPositionals ? Infinity : 0;
66
- if (results.positionals.length > posCount) {
67
- errors.push(`Only ${posCount} positional arguments allowed; got ${results.positionals.length}`);
68
- }
69
-
70
- /** @typedef {Extract<typeof tokens[number], { kind: 'option' }>} OptionToken */
71
- const optionTokens = tokens.filter(/** @type {(token: typeof tokens[number]) => token is OptionToken} */ (token) => token.kind === 'option');
72
-
73
- const bools = obj.options ? Object.entries(obj.options).filter(([, { type }]) => type === 'boolean') : [];
74
- const boolMap = new Map(bools);
75
- for (let i = 0; i < optionTokens.length; i += 1) {
76
- const { name, value } = optionTokens[i];
77
- if (boolMap.has(name) && typeof value !== 'boolean' && typeof value !== 'undefined') {
78
- errors.push(`Error: Argument --${name} must be a boolean`);
79
- }
80
- }
81
-
82
- const passedArgs = new Set(optionTokens.map(({ name, rawName }) => (rawName === '--no-help' ? rawName : name)));
83
-
84
- const groups = Object.groupBy(passedArgs, (x) => x.replace(/^no-/, ''));
85
- for (let i = 0; i < bools.length; i++) {
86
- const [key] = bools[i];
87
- if ((groups[key]?.length ?? 0) > 1) {
88
- errors.push(`Error: Arguments \`--${key}\` and \`--no-${key}\` are mutually exclusive`);
89
- }
90
- if (passedArgs.has(`no-${key}`)) {
91
- // @ts-expect-error
92
- results.values[key] = !results.values[`no-${key}`];
93
- }
94
- // @ts-expect-error
95
- delete results.values[`no-${key}`];
96
- }
97
-
98
- const knownOptions = obj.options ? Object.keys(obj.options) : [];
99
- const unknownArgs = knownOptions.length > 0 ? passedArgs.difference(new Set(knownOptions)) : passedArgs;
100
- if (unknownArgs.size > 0) {
101
- errors.push(`Error: Unknown option(s): ${Array.from(unknownArgs, (x) => `\`${x}\``).join(', ')}`);
102
- }
103
-
104
- return {
105
- errors,
106
- ...results,
107
- ...obj.tokens && { tokens },
108
- };
109
- } catch (e) {
110
- if (isParseArgsError(e)) {
111
- return {
112
- values: {},
113
- positionals: [],
114
- errors: [`Error: ${e.message}`],
115
- };
116
- }
117
- throw e;
118
- }
119
- }