@naturalcycles/dev-lib 20.45.1 → 20.46.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/dist/bin/dev-lib.js +1 -1
- package/dist/commitlint.command.d.ts +5 -0
- package/dist/commitlint.command.js +34 -0
- package/dist/{commitlint.d.ts → commitlint.util.d.ts} +0 -5
- package/dist/{commitlint.js → commitlint.util.js} +0 -33
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/readme.md +3 -5
package/dist/bin/dev-lib.js
CHANGED
|
@@ -3,7 +3,7 @@ import { _assert } from '@naturalcycles/js-lib/error/assert.js';
|
|
|
3
3
|
import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
|
|
4
4
|
import { runScript } from '@naturalcycles/nodejs-lib/runScript';
|
|
5
5
|
import { buildCopy, buildProd, eslintAll, lintStagedCommand, runCheck, runOxfmt, runOxlint, runTest, stylelintAll, typecheckWithTS, typecheckWithTSC, typecheckWithTSGO, } from '../check.util.js';
|
|
6
|
-
import { runCommitlint } from '../commitlint.js';
|
|
6
|
+
import { runCommitlint } from '../commitlint.command.js';
|
|
7
7
|
const commands = [
|
|
8
8
|
{ name: 'check', fn: runCheck, desc: '"Run all possible checks": lint, typecheck, then test.' },
|
|
9
9
|
{
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { _assert } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
|
|
3
|
+
import { validateCommitMessage } from './commitlint.util.js';
|
|
4
|
+
import { readDevLibConfigIfPresent } from './config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Validates the commit message,
|
|
7
|
+
* which is read from a file, passed as process.argv.at(-1)
|
|
8
|
+
*/
|
|
9
|
+
export async function runCommitlint() {
|
|
10
|
+
// || '.git/COMMIT_EDITMSG' // fallback is unnecessary, first argument should be always present
|
|
11
|
+
const arg1 = process.argv.at(-1);
|
|
12
|
+
_assert(arg1, 'dev-lib commitlint2 is called with $1 (first argument) missing');
|
|
13
|
+
console.log({ arg1 });
|
|
14
|
+
fs2.requireFileToExist(arg1);
|
|
15
|
+
const msg = fs2.readText(arg1);
|
|
16
|
+
console.log({ msg });
|
|
17
|
+
// Skip validation for merge commits (MERGE_HEAD exists during merge)
|
|
18
|
+
if (fs2.pathExists('.git/MERGE_HEAD')) {
|
|
19
|
+
console.log('✓ Merge commit - skipping validation');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const devLibCfg = await readDevLibConfigIfPresent();
|
|
23
|
+
console.log({ devLibCfg });
|
|
24
|
+
const { valid, errors } = validateCommitMessage(msg, devLibCfg.commitlint);
|
|
25
|
+
if (valid) {
|
|
26
|
+
console.log('✓ Valid commit message');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.error('✗ Invalid commit message:');
|
|
30
|
+
for (const err of errors) {
|
|
31
|
+
console.error(` - ${err}`);
|
|
32
|
+
}
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { DevLibCommitlintConfig } from './config.js';
|
|
2
|
-
/**
|
|
3
|
-
* Validates the commit message,
|
|
4
|
-
* which is read from a file, passed as process.argv.at(-1)
|
|
5
|
-
*/
|
|
6
|
-
export declare function runCommitlint(): Promise<void>;
|
|
7
2
|
/**
|
|
8
3
|
* Commit message validator following Conventional Commits specification.
|
|
9
4
|
* https://www.conventionalcommits.org/
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { _assert } from '@naturalcycles/js-lib/error';
|
|
2
|
-
import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
|
|
3
|
-
import { readDevLibConfigIfPresent } from './config.js';
|
|
4
1
|
const ALLOWED_TYPES = new Set([
|
|
5
2
|
'feat',
|
|
6
3
|
'fix',
|
|
@@ -15,36 +12,6 @@ const ALLOWED_TYPES = new Set([
|
|
|
15
12
|
'revert',
|
|
16
13
|
]);
|
|
17
14
|
const SUBJECT_MAX_LENGTH = 120; // Only applies to subject line (first line)
|
|
18
|
-
/**
|
|
19
|
-
* Validates the commit message,
|
|
20
|
-
* which is read from a file, passed as process.argv.at(-1)
|
|
21
|
-
*/
|
|
22
|
-
export async function runCommitlint() {
|
|
23
|
-
// || '.git/COMMIT_EDITMSG' // fallback is unnecessary, first argument should be always present
|
|
24
|
-
const arg1 = process.argv.at(-1);
|
|
25
|
-
_assert(arg1, 'dev-lib commitlint2 is called with $1 (first argument) missing');
|
|
26
|
-
console.log({ arg1 });
|
|
27
|
-
fs2.requireFileToExist(arg1);
|
|
28
|
-
const msg = fs2.readText(arg1);
|
|
29
|
-
console.log({ msg });
|
|
30
|
-
// Skip validation for merge commits (MERGE_HEAD exists during merge)
|
|
31
|
-
if (fs2.pathExists('.git/MERGE_HEAD')) {
|
|
32
|
-
console.log('✓ Merge commit - skipping validation');
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const devLibCfg = await readDevLibConfigIfPresent();
|
|
36
|
-
console.log({ devLibCfg });
|
|
37
|
-
const { valid, errors } = validateCommitMessage(msg, devLibCfg.commitlint);
|
|
38
|
-
if (valid) {
|
|
39
|
-
console.log('✓ Valid commit message');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
console.error('✗ Invalid commit message:');
|
|
43
|
-
for (const err of errors) {
|
|
44
|
-
console.error(` - ${err}`);
|
|
45
|
-
}
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
15
|
/**
|
|
49
16
|
* Commit message validator following Conventional Commits specification.
|
|
50
17
|
* https://www.conventionalcommits.org/
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED