@pubinfo/commitlint 2.0.6 → 2.0.8-beta.1

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/index.d.ts CHANGED
@@ -8,6 +8,9 @@ declare function loadCommitConfig(): UserConfig & {
8
8
  prompt?: any;
9
9
  };
10
10
  //#endregion
11
+ //#region src/config/commitlint.d.ts
12
+ declare function isCommitlintEnabled(): Promise<boolean>;
13
+ //#endregion
11
14
  //#region src/init/cz.config.d.ts
12
15
  declare function createCzConfig(cwd?: string): boolean;
13
16
  declare function runCzConfig(czConfigPath: string, cwd?: string): boolean;
@@ -36,4 +39,4 @@ declare function isInsideGitRepo(): boolean;
36
39
  declare function lintMessage(message: string): Promise<boolean>;
37
40
  declare function lintAndReturn(message: string): Promise<string>;
38
41
  //#endregion
39
- export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
42
+ export { commitPreset, createCzConfig, createGitMessage, isCommitlintEnabled, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-CZXQspF4.js";
1
+ import { commitPreset, createCzConfig, createGitMessage, isCommitlintEnabled, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-BDa4KShI.js";
2
2
 
3
- export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
3
+ export { commitPreset, createCzConfig, createGitMessage, isCommitlintEnabled, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { execSync, spawn } from "node:child_process";
3
+ import { loadConfig } from "unconfig";
3
4
  import { resolve } from "node:path";
4
5
  import process$1 from "node:process";
5
6
  import CZGPackage from "czg/package.json" with { type: "json" };
@@ -254,6 +255,31 @@ function loadCommitConfig() {
254
255
  return commitPreset;
255
256
  }
256
257
 
258
+ //#endregion
259
+ //#region src/config/commitlint.ts
260
+ let cachedState;
261
+ function resolveCommitlintEnabled(value) {
262
+ if (typeof value === "boolean") return value;
263
+ if (value && typeof value === "object") {
264
+ if (typeof value.enabled === "boolean") return value.enabled;
265
+ if (typeof value.disable === "boolean") return !value.disable;
266
+ }
267
+ }
268
+ async function isCommitlintEnabled() {
269
+ if (typeof cachedState === "boolean") return cachedState;
270
+ try {
271
+ const result = await loadConfig({
272
+ sources: [{ files: "pubinfo.config" }],
273
+ merge: false
274
+ });
275
+ const resolved = resolveCommitlintEnabled(result?.config?.commitlint);
276
+ cachedState = typeof resolved === "boolean" ? resolved : true;
277
+ } catch {
278
+ cachedState = true;
279
+ }
280
+ return cachedState;
281
+ }
282
+
257
283
  //#endregion
258
284
  //#region ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
259
285
  var require_universalify = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js": ((exports) => {
@@ -2338,6 +2364,7 @@ function isInsideGitRepo() {
2338
2364
  //#endregion
2339
2365
  //#region src/utils/lint.message.ts
2340
2366
  async function lintMessage(message) {
2367
+ if (!await isCommitlintEnabled()) return true;
2341
2368
  try {
2342
2369
  const result = await (await import("@commitlint/lint")).default(message, commitPreset.rules, commitPreset);
2343
2370
  if (!result.valid) {
@@ -2356,4 +2383,4 @@ async function lintAndReturn(message) {
2356
2383
  }
2357
2384
 
2358
2385
  //#endregion
2359
- export { commitPreset, createCzConfig, createGitMessage, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
2386
+ export { commitPreset, createCzConfig, createGitMessage, isCommitlintEnabled, isInsideGitRepo, lintAndReturn, lintMessage, loadCommitConfig, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks };
package/dist/run.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createCzConfig, createGitMessage, isInsideGitRepo, lintMessage, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-CZXQspF4.js";
1
+ import { createCzConfig, createGitMessage, isInsideGitRepo, lintMessage, runCzConfig, runGitMessage, runNpx, runPrompt, runSimpleGitHooks } from "./lint.message-BDa4KShI.js";
2
2
  import process from "node:process";
3
3
  import fs from "node:fs";
4
4
  import { defineCommand, runMain as runMain$1 } from "citty";
@@ -6,7 +6,7 @@ import { defineCommand, runMain as runMain$1 } from "citty";
6
6
  //#region package.json
7
7
  var name = "@pubinfo/commitlint";
8
8
  var type = "module";
9
- var version = "2.0.6";
9
+ var version = "2.0.8-beta.1";
10
10
  var description = "commitlint config for Pubinfo projects";
11
11
  var exports = { ".": "./dist/index.js" };
12
12
  var main$1 = "./dist/index.js";
@@ -25,7 +25,8 @@ var dependencies = {
25
25
  "@commitlint/lint": "catalog:commit",
26
26
  "@commitlint/load": "catalog:commit",
27
27
  "citty": "catalog:node",
28
- "czg": "catalog:commit"
28
+ "czg": "catalog:commit",
29
+ "unconfig": "catalog:node"
29
30
  };
30
31
  var package_default = {
31
32
  name,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/commitlint",
3
3
  "type": "module",
4
- "version": "2.0.6",
4
+ "version": "2.0.8-beta.1",
5
5
  "description": "commitlint config for Pubinfo projects",
6
6
  "exports": {
7
7
  ".": "./dist/index.js"
@@ -32,7 +32,8 @@
32
32
  "@commitlint/lint": "^19.8.1",
33
33
  "@commitlint/load": "^19.8.1",
34
34
  "citty": "^0.1.6",
35
- "czg": "^1.12.0"
35
+ "czg": "^1.12.0",
36
+ "unconfig": "^7.3.2"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "tsdown",