commitlint-config-spellbookx 0.11.1 → 0.12.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.
Files changed (60) hide show
  1. package/.turbo/turbo-build.log +19 -7
  2. package/.turbo/turbo-test.log +59 -0
  3. package/README.md +211 -30
  4. package/__tests__/index.test.ts +47 -0
  5. package/__tests__/lint.test.ts +65 -0
  6. package/__tests__/scopes.test.ts +55 -0
  7. package/__tests__/workspaces.test.ts +76 -0
  8. package/dist/constants/commit-types.d.ts +13 -0
  9. package/dist/constants/commit-types.d.ts.map +1 -0
  10. package/dist/constants/commit-types.js +24 -0
  11. package/dist/get-scopes-D9bIfVqN.js +5698 -0
  12. package/dist/get-workspaces-raw-path-Cg196xaD.js +2043 -0
  13. package/dist/helpers.d.ts +8 -17
  14. package/dist/helpers.d.ts.map +1 -1
  15. package/dist/helpers.js +21 -0
  16. package/dist/index.d.ts +14 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +15 -7878
  19. package/dist/lib/find-git-root.d.ts +16 -0
  20. package/dist/lib/find-git-root.d.ts.map +1 -0
  21. package/dist/lib/find-git-root.js +30 -0
  22. package/dist/lib/get-scope-description.d.ts +21 -0
  23. package/dist/lib/get-scope-description.d.ts.map +1 -0
  24. package/dist/lib/get-scope-description.js +35 -0
  25. package/dist/lib/get-scopes.d.ts +16 -0
  26. package/dist/lib/get-scopes.d.ts.map +1 -0
  27. package/dist/lib/get-scopes.js +4 -0
  28. package/dist/lib/get-workspaces-raw-path.d.ts +19 -0
  29. package/dist/lib/get-workspaces-raw-path.d.ts.map +1 -0
  30. package/dist/lib/get-workspaces-raw-path.js +3 -0
  31. package/dist/lib/index.d.ts +10 -0
  32. package/dist/lib/index.d.ts.map +1 -0
  33. package/dist/lib/index.js +7 -0
  34. package/dist/lib/package-json.d.ts +14 -0
  35. package/dist/lib/package-json.d.ts.map +1 -0
  36. package/dist/lib/package-json.js +16 -0
  37. package/dist/prompt.d.ts +10 -0
  38. package/dist/prompt.d.ts.map +1 -0
  39. package/dist/prompt.js +99 -0
  40. package/dist/rules.d.ts +10 -0
  41. package/dist/rules.d.ts.map +1 -0
  42. package/dist/rules.js +45 -0
  43. package/dist/scopes.d.ts +23 -0
  44. package/dist/scopes.d.ts.map +1 -0
  45. package/dist/scopes.js +38 -0
  46. package/package.json +43 -9
  47. package/rolldown.config.ts +13 -1
  48. package/src/constants/commit-types.ts +26 -0
  49. package/src/index.ts +26 -153
  50. package/src/lib/find-git-root.ts +31 -0
  51. package/src/lib/get-scope-description.ts +38 -0
  52. package/src/lib/get-scopes.ts +89 -0
  53. package/src/lib/get-workspaces-raw-path.ts +53 -0
  54. package/src/lib/index.ts +10 -0
  55. package/src/lib/package-json.ts +22 -0
  56. package/src/prompt.ts +99 -0
  57. package/src/rules.ts +22 -0
  58. package/src/scopes.ts +40 -0
  59. package/tsconfig.json +1 -0
  60. package/src/helpers.ts +0 -123
package/src/helpers.ts DELETED
@@ -1,123 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- import fg from 'fast-glob';
6
- import { load } from 'js-yaml';
7
-
8
- const packagePath = fileURLToPath(new URL('../package.json', import.meta.url));
9
- export const packageJson = JSON.parse(readFileSync(packagePath, 'utf8')) as {
10
- name: string;
11
- version: string;
12
- peerDependencies: Record<string, string>;
13
- };
14
-
15
- /**
16
- * Reads workspace paths from configuration files (JSON or YAML).
17
- * @param configPath The path to the config file (e.g., package.json, pnpm-workspace.yaml).
18
- * @param parser The parser type to use for reading the file.
19
- * @param [property] The property name in the config containing workspace paths.
20
- * @returns Array of raw workspace path patterns.
21
- * @example
22
- * getWorkspacesRawPath('package.json', 'json', 'workspaces');
23
- */
24
- export function getWorkspacesRawPath(
25
- configPath: string,
26
- parser: 'json' | 'yaml',
27
- property: string = 'workspaces'
28
- ): string[] {
29
- const rawWorkspacesPaths: string[] = [];
30
-
31
- if (existsSync(configPath)) {
32
- const asString = readFileSync(configPath, 'utf8');
33
-
34
- let parsed: Record<string, unknown>;
35
-
36
- if (parser === 'json') {
37
- parsed = JSON.parse(asString);
38
- } else if (parser === 'yaml') {
39
- parsed = load(asString) as Record<string, unknown>;
40
- } else {
41
- throw new Error(`Unsupported parser type: ${parser}`);
42
- }
43
-
44
- const workspaces = parsed[property];
45
-
46
- if (Array.isArray(workspaces)) {
47
- for (const project of workspaces) {
48
- rawWorkspacesPaths.push(project);
49
- }
50
- }
51
- }
52
-
53
- return rawWorkspacesPaths;
54
- }
55
-
56
- /**
57
- * Retrieves a list of scopes (workspace paths) from various configuration files.
58
- * @returns An array of absolute workspace paths.
59
- * @example
60
- * const scopes = getScopes();
61
- */
62
- export function getScopes(): string[] {
63
- const cwd = process.cwd();
64
-
65
- const gitDir = path.resolve(cwd, '.git');
66
-
67
- if (!existsSync(gitDir)) {
68
- throw new Error('[FATAL] Not a repository.');
69
- }
70
-
71
- const rawWorkspaces: string[] = [];
72
-
73
- const packageJsonPath = path.join(cwd, 'package.json');
74
- rawWorkspaces.push(
75
- ...getWorkspacesRawPath(packageJsonPath, 'json', 'workspaces')
76
- );
77
-
78
- const pnpmWorkspaceYamlPath = path.join(cwd, 'pnpm-workspace.yaml');
79
- rawWorkspaces.push(
80
- ...getWorkspacesRawPath(pnpmWorkspaceYamlPath, 'yaml', 'packages')
81
- );
82
-
83
- const pnpmWorkspaceYmlPath = path.join(cwd, 'pnpm-workspace.yml');
84
- rawWorkspaces.push(
85
- ...getWorkspacesRawPath(pnpmWorkspaceYmlPath, 'yaml', 'packages')
86
- );
87
-
88
- const lernaJsonPath = path.join(cwd, 'lerna.json');
89
- rawWorkspaces.push(
90
- ...getWorkspacesRawPath(lernaJsonPath, 'json', 'packages')
91
- );
92
-
93
- const workspaces = new Set<string>();
94
-
95
- const rootPackageJsonPath = path.join(cwd, 'package.json');
96
- if (existsSync(rootPackageJsonPath) && !rawWorkspaces.includes('.')) {
97
- rawWorkspaces.push('.');
98
- }
99
-
100
- for (const pattern of rawWorkspaces) {
101
- const entries = fg.sync(pattern, { onlyDirectories: true, absolute: true });
102
-
103
- for (const dirPath of entries) {
104
- const packageJsonPath = path.join(dirPath, 'package.json');
105
-
106
- if (existsSync(packageJsonPath)) {
107
- try {
108
- const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
109
- name?: string;
110
- };
111
-
112
- if (pkg.name) {
113
- workspaces.add(pkg.name);
114
- }
115
- } catch {
116
- // ignore invalid package.json files
117
- }
118
- }
119
- }
120
- }
121
-
122
- return [...workspaces];
123
- }