@naturalcycles/dev-lib 20.18.0 → 20.18.2

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.
@@ -3,7 +3,7 @@ import { type DevLibCommitlintConfig } from './config.js';
3
3
  * Validates the commit message,
4
4
  * which is read from a file, passed as process.argv.at(-1)
5
5
  */
6
- export declare function runCommitlint(): void;
6
+ export declare function runCommitlint(): Promise<void>;
7
7
  /**
8
8
  * Commit message validator following Conventional Commits specification.
9
9
  * https://www.conventionalcommits.org/
@@ -19,7 +19,7 @@ const SUBJECT_MAX_LENGTH = 120; // Only applies to subject line (first line)
19
19
  * Validates the commit message,
20
20
  * which is read from a file, passed as process.argv.at(-1)
21
21
  */
22
- export function runCommitlint() {
22
+ export async function runCommitlint() {
23
23
  // || '.git/COMMIT_EDITMSG' // fallback is unnecessary, first argument should be always present
24
24
  const arg1 = process.argv.at(-1);
25
25
  _assert(arg1, 'dev-lib commitlint2 is called with $1 (first argument) missing');
@@ -27,7 +27,7 @@ export function runCommitlint() {
27
27
  fs2.requireFileToExist(arg1);
28
28
  const msg = fs2.readText(arg1);
29
29
  console.log({ msg });
30
- const devLibCfg = readDevLibConfigIfPresent();
30
+ const devLibCfg = await readDevLibConfigIfPresent();
31
31
  console.log({ devLibCfg });
32
32
  const { valid, errors } = validateCommitMessage(msg, devLibCfg.commitlint);
33
33
  if (valid) {
package/dist/config.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns an empty config if the file is absent.
3
3
  */
4
- export declare function readDevLibConfigIfPresent(): DevLibConfig;
4
+ export declare function readDevLibConfigIfPresent(cwd?: string): Promise<DevLibConfig>;
5
5
  export interface DevLibConfig {
6
6
  commitlint?: DevLibCommitlintConfig;
7
7
  }
package/dist/config.js CHANGED
@@ -1,11 +1,15 @@
1
1
  import { AjvSchema, j } from '@naturalcycles/nodejs-lib/ajv';
2
2
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
3
- const devLibConfigPath = 'dev-lib.config.js';
4
3
  /**
5
4
  * Returns an empty config if the file is absent.
6
5
  */
7
- export function readDevLibConfigIfPresent() {
8
- const cfg = fs2.pathExists(devLibConfigPath) ? fs2.readJson(devLibConfigPath) : {};
6
+ export async function readDevLibConfigIfPresent(cwd = process.cwd()) {
7
+ const devLibConfigPath = `${cwd}/dev-lib.config.js`;
8
+ let cfg = {};
9
+ if (fs2.pathExists(devLibConfigPath)) {
10
+ cfg = (await import(devLibConfigPath)).default;
11
+ console.log(`read ${devLibConfigPath}`);
12
+ }
9
13
  return devLibConfigSchema.validate(cfg);
10
14
  }
11
15
  const devLibConfigSchema = AjvSchema.create(j.object({
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export type {};
1
+ export * from './config.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export * from './config.js';
package/dist/paths.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const projectDir: string;
2
+ export declare const repoDir: string;
2
3
  export declare const srcDir: string;
3
4
  export declare const testDir: string;
4
5
  export declare const cfgDir: string;
package/dist/paths.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  export const projectDir = join(import.meta.dirname, '..');
3
+ export const repoDir = join(projectDir, '../..');
3
4
  export const srcDir = `${projectDir}/src`;
4
5
  export const testDir = `${srcDir}/test`;
5
6
  export const cfgDir = `${projectDir}/cfg`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.18.0",
4
+ "version": "20.18.2",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@eslint/js": "^9",
@@ -47,7 +47,6 @@
47
47
  "exports": {
48
48
  "./cfg/": "./cfg/",
49
49
  "./cfg/biome.jsonc": "./cfg/biome.jsonc",
50
- "./cfg/commitlint.config.js": "./cfg/commitlint.config.js",
51
50
  "./cfg/eslint.config.js": "./cfg/eslint.config.js",
52
51
  "./cfg/oxlint.config.json": "./cfg/oxlint.config.json",
53
52
  "./cfg/prettier.config.js": "./cfg/prettier.config.js",
@@ -1,9 +0,0 @@
1
- export default {
2
- extends: ['@commitlint/config-conventional'],
3
- rules: {
4
- // Overriding to allow 'start-case', 'upper-case', 'sentense-case', 'pascal-case'
5
- // Example to allow now (which weren't allowed before):
6
- // feat: POST /qa/smth
7
- 'subject-case': [0],
8
- },
9
- }
@@ -1,5 +0,0 @@
1
- import sharedConfig from '@naturalcycles/dev-lib/cfg/commitlint.config.js'
2
-
3
- export default {
4
- ...sharedConfig,
5
- }