commitlint-config-spellbookx 1.1.2 → 1.3.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 +15 -0
- package/README.md +91 -60
- package/__tests__/index.test.ts +3 -29
- package/dist/{get-scopes-D9bIfVqN.js → git-C5S_9pJT.js} +2166 -276
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/lib/index.d.ts +1 -5
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -5
- package/dist/prompt.js +8 -10
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +1 -4
- package/package.json +3 -15
- package/rolldown.config.ts +0 -6
- package/src/index.ts +2 -9
- package/src/lib/index.ts +1 -5
- package/src/prompt.ts +8 -8
- package/src/rules.ts +1 -2
- package/__tests__/scopes.test.ts +0 -42
- package/__tests__/workspaces.test.ts +0 -137
- package/dist/constants/commit-types.d.ts +0 -13
- package/dist/constants/commit-types.d.ts.map +0 -1
- package/dist/constants/commit-types.js +0 -24
- package/dist/get-workspaces-raw-path-Cg196xaD.js +0 -2043
- package/dist/lib/find-git-root.d.ts +0 -16
- package/dist/lib/find-git-root.d.ts.map +0 -1
- package/dist/lib/find-git-root.js +0 -30
- package/dist/lib/get-scope-description.d.ts +0 -21
- package/dist/lib/get-scope-description.d.ts.map +0 -1
- package/dist/lib/get-scope-description.js +0 -35
- package/dist/lib/get-scopes.d.ts +0 -16
- package/dist/lib/get-scopes.d.ts.map +0 -1
- package/dist/lib/get-scopes.js +0 -4
- package/dist/lib/get-workspaces-raw-path.d.ts +0 -19
- package/dist/lib/get-workspaces-raw-path.d.ts.map +0 -1
- package/dist/lib/get-workspaces-raw-path.js +0 -3
- package/dist/scopes.d.ts +0 -23
- package/dist/scopes.d.ts.map +0 -1
- package/dist/scopes.js +0 -38
- package/src/constants/commit-types.ts +0 -26
- package/src/lib/find-git-root.ts +0 -31
- package/src/lib/get-scope-description.ts +0 -38
- package/src/lib/get-scopes.ts +0 -89
- package/src/lib/get-workspaces-raw-path.ts +0 -53
- package/src/scopes.ts +0 -40
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file find-git-root.ts
|
|
3
|
-
* Utility to locate the root directory of a git repository.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Finds the git root directory by traversing upwards from startDir.
|
|
7
|
-
*
|
|
8
|
-
* @param startDir - Directory to start searching from (defaults to process.cwd()).
|
|
9
|
-
* @returns Path to git root directory, or null if not within a git repository.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const root = findGitRoot();
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function findGitRoot(startDir?: string): string | null;
|
|
16
|
-
//# sourceMappingURL=find-git-root.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-git-root.d.ts","sourceRoot":"","sources":["../../src/lib/find-git-root.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAY3E"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/find-git-root.ts
|
|
5
|
-
/**
|
|
6
|
-
* @file find-git-root.ts
|
|
7
|
-
* Utility to locate the root directory of a git repository.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Finds the git root directory by traversing upwards from startDir.
|
|
11
|
-
*
|
|
12
|
-
* @param startDir - Directory to start searching from (defaults to process.cwd()).
|
|
13
|
-
* @returns Path to git root directory, or null if not within a git repository.
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const root = findGitRoot();
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
function findGitRoot(startDir = process.cwd()) {
|
|
20
|
-
let current = path.resolve(startDir);
|
|
21
|
-
while (true) {
|
|
22
|
-
if (existsSync(path.join(current, ".git"))) return current;
|
|
23
|
-
const parent = path.dirname(current);
|
|
24
|
-
if (parent === current) return null;
|
|
25
|
-
current = parent;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { findGitRoot };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-scope-description.ts
|
|
3
|
-
* Formats user-facing description strings for commit scopes.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Returns a human-readable description for a given commit scope.
|
|
7
|
-
*
|
|
8
|
-
* @param scope - The scope identifier.
|
|
9
|
-
* @returns The description string for the scope.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* getScopeDescription('workspace');
|
|
13
|
-
* // 'workspace scope - root files such as config files, root package.json, etc'
|
|
14
|
-
* getScopeDescription('release');
|
|
15
|
-
* // 'Special scope for release commits'
|
|
16
|
-
* getScopeDescription('my-package');
|
|
17
|
-
* // 'my-package scope'
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function getScopeDescription(scope: string): string;
|
|
21
|
-
//# sourceMappingURL=get-scope-description.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-scope-description.d.ts","sourceRoot":"","sources":["../../src/lib/get-scope-description.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOzD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/lib/get-scope-description.ts
|
|
2
|
-
/**
|
|
3
|
-
* @file get-scope-description.ts
|
|
4
|
-
* Formats user-facing description strings for commit scopes.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Scope identifier for workspace-level changes.
|
|
8
|
-
*/
|
|
9
|
-
const SCOPE_WORKSPACE = "workspace";
|
|
10
|
-
/**
|
|
11
|
-
* Scope identifier for release commits.
|
|
12
|
-
*/
|
|
13
|
-
const SCOPE_RELEASE = "release";
|
|
14
|
-
/**
|
|
15
|
-
* Returns a human-readable description for a given commit scope.
|
|
16
|
-
*
|
|
17
|
-
* @param scope - The scope identifier.
|
|
18
|
-
* @returns The description string for the scope.
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* getScopeDescription('workspace');
|
|
22
|
-
* // 'workspace scope - root files such as config files, root package.json, etc'
|
|
23
|
-
* getScopeDescription('release');
|
|
24
|
-
* // 'Special scope for release commits'
|
|
25
|
-
* getScopeDescription('my-package');
|
|
26
|
-
* // 'my-package scope'
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
function getScopeDescription(scope) {
|
|
30
|
-
if (scope === SCOPE_WORKSPACE) return "workspace scope - root files such as config files, root package.json, etc";
|
|
31
|
-
return scope === SCOPE_RELEASE ? "Special scope for release commits" : `${scope} scope`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { getScopeDescription };
|
package/dist/lib/get-scopes.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-scopes.ts
|
|
3
|
-
* Discovers and gathers workspace package scopes in a monorepo or standard repository.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves a list of package scope names from monorepo configuration files (npm, pnpm, lerna).
|
|
7
|
-
*
|
|
8
|
-
* @param cwd - Working directory to start git root discovery from (defaults to process.cwd()).
|
|
9
|
-
* @returns An array of package scope names found in the repository.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const scopes = getScopes();
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function getScopes(cwd?: string): string[];
|
|
16
|
-
//# sourceMappingURL=get-scopes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-scopes.d.ts","sourceRoot":"","sources":["../../src/lib/get-scopes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,EAAE,CAiE/D"}
|
package/dist/lib/get-scopes.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-workspaces-raw-path.ts
|
|
3
|
-
* Parser for extracting workspace path globs from JSON and YAML configuration files.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Reads workspace paths from configuration files (JSON or YAML).
|
|
7
|
-
*
|
|
8
|
-
* @param configPath - The path to the config file (e.g., package.json, pnpm-workspace.yaml).
|
|
9
|
-
* @param parser - The parser type to use for reading the file ('json' or 'yaml').
|
|
10
|
-
* @param property - The property name in the config containing workspace paths (defaults to 'workspaces').
|
|
11
|
-
* @returns Array of raw workspace path patterns.
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* getWorkspacesRawPath('package.json', 'json', 'workspaces');
|
|
15
|
-
* getWorkspacesRawPath('pnpm-workspace.yaml', 'yaml', 'packages');
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function getWorkspacesRawPath(configPath: string, parser: 'json' | 'yaml', property?: string): string[];
|
|
19
|
-
//# sourceMappingURL=get-workspaces-raw-path.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-workspaces-raw-path.d.ts","sourceRoot":"","sources":["../../src/lib/get-workspaces-raw-path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,QAAQ,GAAE,MAAqB,GAC9B,MAAM,EAAE,CA0BV"}
|
package/dist/scopes.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file scopes.ts
|
|
3
|
-
* Scopes constants and scope enumeration generator for commitlint and commitizen.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Scope identifier for repository-wide or workspace-level changes.
|
|
7
|
-
*/
|
|
8
|
-
export declare const SCOPE_WORKSPACE = "workspace";
|
|
9
|
-
/**
|
|
10
|
-
* Scope identifier for release and versioning commits.
|
|
11
|
-
*/
|
|
12
|
-
export declare const SCOPE_RELEASE = "release";
|
|
13
|
-
/**
|
|
14
|
-
* Array of all valid commit scopes, including workspace, release, and discovered monorepo packages.
|
|
15
|
-
*/
|
|
16
|
-
export declare const scopesArray: string[];
|
|
17
|
-
/**
|
|
18
|
-
* Record of scopes mapped to their human-readable descriptions for Commitizen interactive prompt.
|
|
19
|
-
*/
|
|
20
|
-
export declare const scopesEnum: Record<string, {
|
|
21
|
-
description: string;
|
|
22
|
-
}>;
|
|
23
|
-
//# sourceMappingURL=scopes.d.ts.map
|
package/dist/scopes.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,EAI/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAM,CAAC"}
|
package/dist/scopes.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { t as getScopes } from "./get-scopes-D9bIfVqN.js";
|
|
2
|
-
import { getScopeDescription } from "./lib/get-scope-description.js";
|
|
3
|
-
import "./get-workspaces-raw-path-Cg196xaD.js";
|
|
4
|
-
|
|
5
|
-
//#region src/scopes.ts
|
|
6
|
-
/**
|
|
7
|
-
* @file scopes.ts
|
|
8
|
-
* Scopes constants and scope enumeration generator for commitlint and commitizen.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Scope identifier for repository-wide or workspace-level changes.
|
|
12
|
-
*/
|
|
13
|
-
const SCOPE_WORKSPACE = "workspace";
|
|
14
|
-
/**
|
|
15
|
-
* Scope identifier for release and versioning commits.
|
|
16
|
-
*/
|
|
17
|
-
const SCOPE_RELEASE = "release";
|
|
18
|
-
/**
|
|
19
|
-
* Array of all valid commit scopes, including workspace, release, and discovered monorepo packages.
|
|
20
|
-
*/
|
|
21
|
-
const scopesArray = [
|
|
22
|
-
SCOPE_WORKSPACE,
|
|
23
|
-
SCOPE_RELEASE,
|
|
24
|
-
...getScopes()
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Record of scopes mapped to their human-readable descriptions for Commitizen interactive prompt.
|
|
28
|
-
*/
|
|
29
|
-
const scopesEnum = {};
|
|
30
|
-
for (const scope of scopesArray) Object.defineProperty(scopesEnum, scope, {
|
|
31
|
-
value: { description: getScopeDescription(scope) },
|
|
32
|
-
enumerable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
export { SCOPE_RELEASE, SCOPE_WORKSPACE, scopesArray, scopesEnum };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file commit-types.ts
|
|
3
|
-
* Standard Conventional Commit types supported by Spellbookx.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* List of allowed commit types based on the Conventional Commits specification.
|
|
8
|
-
*/
|
|
9
|
-
export const COMMIT_TYPES = [
|
|
10
|
-
'feat',
|
|
11
|
-
'fix',
|
|
12
|
-
'docs',
|
|
13
|
-
'style',
|
|
14
|
-
'refactor',
|
|
15
|
-
'perf',
|
|
16
|
-
'test',
|
|
17
|
-
'chore',
|
|
18
|
-
'ci',
|
|
19
|
-
'build',
|
|
20
|
-
'revert',
|
|
21
|
-
] as const;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Valid Conventional Commit type string.
|
|
25
|
-
*/
|
|
26
|
-
export type CommitType = (typeof COMMIT_TYPES)[number];
|
package/src/lib/find-git-root.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file find-git-root.ts
|
|
3
|
-
* Utility to locate the root directory of a git repository.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync } from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Finds the git root directory by traversing upwards from startDir.
|
|
11
|
-
*
|
|
12
|
-
* @param startDir - Directory to start searching from (defaults to process.cwd()).
|
|
13
|
-
* @returns Path to git root directory, or null if not within a git repository.
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const root = findGitRoot();
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function findGitRoot(startDir: string = process.cwd()): string | null {
|
|
20
|
-
let current = path.resolve(startDir);
|
|
21
|
-
while (true) {
|
|
22
|
-
if (existsSync(path.join(current, '.git'))) {
|
|
23
|
-
return current;
|
|
24
|
-
}
|
|
25
|
-
const parent = path.dirname(current);
|
|
26
|
-
if (parent === current) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
current = parent;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-scope-description.ts
|
|
3
|
-
* Formats user-facing description strings for commit scopes.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Scope identifier for workspace-level changes.
|
|
8
|
-
*/
|
|
9
|
-
const SCOPE_WORKSPACE = 'workspace';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Scope identifier for release commits.
|
|
13
|
-
*/
|
|
14
|
-
const SCOPE_RELEASE = 'release';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Returns a human-readable description for a given commit scope.
|
|
18
|
-
*
|
|
19
|
-
* @param scope - The scope identifier.
|
|
20
|
-
* @returns The description string for the scope.
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* getScopeDescription('workspace');
|
|
24
|
-
* // 'workspace scope - root files such as config files, root package.json, etc'
|
|
25
|
-
* getScopeDescription('release');
|
|
26
|
-
* // 'Special scope for release commits'
|
|
27
|
-
* getScopeDescription('my-package');
|
|
28
|
-
* // 'my-package scope'
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function getScopeDescription(scope: string): string {
|
|
32
|
-
if (scope === SCOPE_WORKSPACE) {
|
|
33
|
-
return 'workspace scope - root files such as config files, root package.json, etc';
|
|
34
|
-
}
|
|
35
|
-
return scope === SCOPE_RELEASE
|
|
36
|
-
? 'Special scope for release commits'
|
|
37
|
-
: `${scope} scope`;
|
|
38
|
-
}
|
package/src/lib/get-scopes.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-scopes.ts
|
|
3
|
-
* Discovers and gathers workspace package scopes in a monorepo or standard repository.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
import fg from 'fast-glob';
|
|
10
|
-
|
|
11
|
-
import { findGitRoot } from './find-git-root.js';
|
|
12
|
-
import { getWorkspacesRawPath } from './get-workspaces-raw-path.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves a list of package scope names from monorepo configuration files (npm, pnpm, lerna).
|
|
16
|
-
*
|
|
17
|
-
* @param cwd - Working directory to start git root discovery from (defaults to process.cwd()).
|
|
18
|
-
* @returns An array of package scope names found in the repository.
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* const scopes = getScopes();
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function getScopes(cwd: string = process.cwd()): string[] {
|
|
25
|
-
const root = findGitRoot(cwd);
|
|
26
|
-
|
|
27
|
-
if (!root) {
|
|
28
|
-
throw new Error('[FATAL] Not a repository.');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const rawWorkspaces: string[] = [];
|
|
32
|
-
|
|
33
|
-
const packageJsonPath = path.join(root, 'package.json');
|
|
34
|
-
rawWorkspaces.push(
|
|
35
|
-
...getWorkspacesRawPath(packageJsonPath, 'json', 'workspaces')
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const pnpmWorkspaceYamlPath = path.join(root, 'pnpm-workspace.yaml');
|
|
39
|
-
rawWorkspaces.push(
|
|
40
|
-
...getWorkspacesRawPath(pnpmWorkspaceYamlPath, 'yaml', 'packages')
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const pnpmWorkspaceYmlPath = path.join(root, 'pnpm-workspace.yml');
|
|
44
|
-
rawWorkspaces.push(
|
|
45
|
-
...getWorkspacesRawPath(pnpmWorkspaceYmlPath, 'yaml', 'packages')
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const lernaJsonPath = path.join(root, 'lerna.json');
|
|
49
|
-
rawWorkspaces.push(
|
|
50
|
-
...getWorkspacesRawPath(lernaJsonPath, 'json', 'packages')
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const workspaces = new Set<string>();
|
|
54
|
-
|
|
55
|
-
const rootPackageJsonPath = path.join(root, 'package.json');
|
|
56
|
-
if (existsSync(rootPackageJsonPath) && !rawWorkspaces.includes('.')) {
|
|
57
|
-
rawWorkspaces.push('.');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
for (const pattern of rawWorkspaces) {
|
|
61
|
-
const entries = fg.sync(pattern, {
|
|
62
|
-
cwd: root,
|
|
63
|
-
onlyDirectories: true,
|
|
64
|
-
absolute: true,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
for (const dirPath of entries) {
|
|
68
|
-
const packageJsonPath = path.join(dirPath, 'package.json');
|
|
69
|
-
|
|
70
|
-
if (existsSync(packageJsonPath)) {
|
|
71
|
-
try {
|
|
72
|
-
const package_ = JSON.parse(
|
|
73
|
-
readFileSync(packageJsonPath, 'utf8')
|
|
74
|
-
) as {
|
|
75
|
-
name?: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
if (package_.name) {
|
|
79
|
-
workspaces.add(package_.name);
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
// ignore invalid package.json files
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return [...workspaces];
|
|
89
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file get-workspaces-raw-path.ts
|
|
3
|
-
* Parser for extracting workspace path globs from JSON and YAML configuration files.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
-
|
|
8
|
-
import { load } from 'js-yaml';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Reads workspace paths from configuration files (JSON or YAML).
|
|
12
|
-
*
|
|
13
|
-
* @param configPath - The path to the config file (e.g., package.json, pnpm-workspace.yaml).
|
|
14
|
-
* @param parser - The parser type to use for reading the file ('json' or 'yaml').
|
|
15
|
-
* @param property - The property name in the config containing workspace paths (defaults to 'workspaces').
|
|
16
|
-
* @returns Array of raw workspace path patterns.
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* getWorkspacesRawPath('package.json', 'json', 'workspaces');
|
|
20
|
-
* getWorkspacesRawPath('pnpm-workspace.yaml', 'yaml', 'packages');
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export function getWorkspacesRawPath(
|
|
24
|
-
configPath: string,
|
|
25
|
-
parser: 'json' | 'yaml',
|
|
26
|
-
property: string = 'workspaces'
|
|
27
|
-
): string[] {
|
|
28
|
-
const rawWorkspacesPaths: string[] = [];
|
|
29
|
-
|
|
30
|
-
if (existsSync(configPath)) {
|
|
31
|
-
const asString = readFileSync(configPath, 'utf8');
|
|
32
|
-
|
|
33
|
-
let parsed: Record<string, unknown>;
|
|
34
|
-
|
|
35
|
-
if (parser === 'json') {
|
|
36
|
-
parsed = JSON.parse(asString);
|
|
37
|
-
} else if (parser === 'yaml') {
|
|
38
|
-
parsed = load(asString) as Record<string, unknown>;
|
|
39
|
-
} else {
|
|
40
|
-
throw new Error(`Unsupported parser type: ${parser}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const workspaces = parsed[property];
|
|
44
|
-
|
|
45
|
-
if (Array.isArray(workspaces)) {
|
|
46
|
-
for (const project of workspaces) {
|
|
47
|
-
rawWorkspacesPaths.push(project);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return rawWorkspacesPaths;
|
|
53
|
-
}
|
package/src/scopes.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file scopes.ts
|
|
3
|
-
* Scopes constants and scope enumeration generator for commitlint and commitizen.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { getScopeDescription } from './lib/get-scope-description.js';
|
|
7
|
-
import { getScopes } from './lib/get-scopes.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Scope identifier for repository-wide or workspace-level changes.
|
|
11
|
-
*/
|
|
12
|
-
export const SCOPE_WORKSPACE = 'workspace';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Scope identifier for release and versioning commits.
|
|
16
|
-
*/
|
|
17
|
-
export const SCOPE_RELEASE = 'release';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Array of all valid commit scopes, including workspace, release, and discovered monorepo packages.
|
|
21
|
-
*/
|
|
22
|
-
export const scopesArray: string[] = [
|
|
23
|
-
SCOPE_WORKSPACE,
|
|
24
|
-
SCOPE_RELEASE,
|
|
25
|
-
...getScopes(),
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Record of scopes mapped to their human-readable descriptions for Commitizen interactive prompt.
|
|
30
|
-
*/
|
|
31
|
-
export const scopesEnum: Record<string, { description: string }> = {};
|
|
32
|
-
|
|
33
|
-
for (const scope of scopesArray) {
|
|
34
|
-
Object.defineProperty(scopesEnum, scope, {
|
|
35
|
-
value: { description: getScopeDescription(scope) },
|
|
36
|
-
enumerable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
});
|
|
40
|
-
}
|