@hyperfrontend/versioning 0.2.0 → 0.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 +14 -0
- package/README.md +8 -6
- package/changelog/index.cjs.js +15 -4
- package/changelog/index.cjs.js.map +1 -1
- package/changelog/index.esm.js +15 -4
- package/changelog/index.esm.js.map +1 -1
- package/changelog/parse/index.cjs.js +62 -4
- package/changelog/parse/index.cjs.js.map +1 -1
- package/changelog/parse/index.esm.js +62 -4
- package/changelog/parse/index.esm.js.map +1 -1
- package/changelog/parse/parser.d.ts +0 -6
- package/changelog/parse/parser.d.ts.map +1 -1
- package/commits/classify/index.cjs.js +8 -6
- package/commits/classify/index.cjs.js.map +1 -1
- package/commits/classify/index.d.ts +1 -1
- package/commits/classify/index.d.ts.map +1 -1
- package/commits/classify/index.esm.js +8 -7
- package/commits/classify/index.esm.js.map +1 -1
- package/commits/classify/project-scopes.d.ts +10 -0
- package/commits/classify/project-scopes.d.ts.map +1 -1
- package/commits/index.cjs.js +8 -6
- package/commits/index.cjs.js.map +1 -1
- package/commits/index.esm.js +8 -7
- package/commits/index.esm.js.map +1 -1
- package/flow/executor/index.cjs.js +12 -0
- package/flow/executor/index.cjs.js.map +1 -1
- package/flow/executor/index.esm.js +12 -0
- package/flow/executor/index.esm.js.map +1 -1
- package/flow/index.cjs.js +89 -36
- package/flow/index.cjs.js.map +1 -1
- package/flow/index.esm.js +88 -37
- package/flow/index.esm.js.map +1 -1
- package/flow/models/index.cjs.js +13 -0
- package/flow/models/index.cjs.js.map +1 -1
- package/flow/models/index.d.ts +1 -1
- package/flow/models/index.d.ts.map +1 -1
- package/flow/models/index.esm.js +13 -1
- package/flow/models/index.esm.js.map +1 -1
- package/flow/models/types.d.ts +33 -1
- package/flow/models/types.d.ts.map +1 -1
- package/flow/presets/index.cjs.js +84 -36
- package/flow/presets/index.cjs.js.map +1 -1
- package/flow/presets/index.esm.js +84 -36
- package/flow/presets/index.esm.js.map +1 -1
- package/flow/steps/analyze-commits.d.ts.map +1 -1
- package/flow/steps/generate-changelog.d.ts +5 -0
- package/flow/steps/generate-changelog.d.ts.map +1 -1
- package/flow/steps/index.cjs.js +85 -36
- package/flow/steps/index.cjs.js.map +1 -1
- package/flow/steps/index.d.ts +1 -1
- package/flow/steps/index.d.ts.map +1 -1
- package/flow/steps/index.esm.js +85 -37
- package/flow/steps/index.esm.js.map +1 -1
- package/index.cjs.js +9223 -9172
- package/index.cjs.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.d.ts.map +1 -1
- package/index.esm.js +9220 -9173
- package/index.esm.js.map +1 -1
- package/package.json +14 -1
- package/workspace/discovery/changelog-path.d.ts +3 -7
- package/workspace/discovery/changelog-path.d.ts.map +1 -1
- package/workspace/discovery/index.cjs.js +84 -5
- package/workspace/discovery/index.cjs.js.map +1 -1
- package/workspace/discovery/index.esm.js +84 -5
- package/workspace/discovery/index.esm.js.map +1 -1
- package/workspace/index.cjs.js +84 -5
- package/workspace/index.cjs.js.map +1 -1
- package/workspace/index.esm.js +84 -5
- package/workspace/index.esm.js.map +1 -1
package/flow/steps/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { FETCH_REGISTRY_STEP_ID, createFetchRegistryStep } from './fetch-registr
|
|
|
2
2
|
export { RESOLVE_REPOSITORY_STEP_ID, createResolveRepositoryStep } from './resolve-repository';
|
|
3
3
|
export { ANALYZE_COMMITS_STEP_ID, createAnalyzeCommitsStep } from './analyze-commits';
|
|
4
4
|
export { CALCULATE_BUMP_STEP_ID, createCalculateBumpStep, createCheckIdempotencyStep } from './calculate-bump';
|
|
5
|
-
export { GENERATE_CHANGELOG_STEP_ID, createGenerateChangelogStep, createWriteChangelogStep } from './generate-changelog';
|
|
5
|
+
export { DEFAULT_COMMIT_TYPE_TO_SECTION, GENERATE_CHANGELOG_STEP_ID, createGenerateChangelogStep, createWriteChangelogStep, } from './generate-changelog';
|
|
6
6
|
export { UPDATE_PACKAGES_STEP_ID, createUpdatePackageStep, createCascadeDependenciesStep } from './update-packages';
|
|
7
7
|
export { CREATE_COMMIT_STEP_ID, createGitCommitStep } from './create-commit';
|
|
8
8
|
export { CREATE_TAG_STEP_ID, createTagStep, createPushTagStep } from './create-tag';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/versioning/src/flow/steps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAC9F,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACrF,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC9G,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/versioning/src/flow/steps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAC9F,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACrF,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC9G,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACnH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
package/flow/steps/index.esm.js
CHANGED
|
@@ -2310,12 +2310,12 @@ function shouldPreserveScope(source) {
|
|
|
2310
2310
|
* // Returns: ['app-demo', 'demo']
|
|
2311
2311
|
*/
|
|
2312
2312
|
function deriveProjectScopes(options) {
|
|
2313
|
-
const { projectName, packageName, additionalScopes = [] } = options;
|
|
2313
|
+
const { projectName, packageName, additionalScopes = [], prefixes = DEFAULT_PROJECT_PREFIXES } = options;
|
|
2314
2314
|
const scopes = createSet();
|
|
2315
2315
|
// Always include the full project name
|
|
2316
2316
|
scopes.add(projectName);
|
|
2317
2317
|
// Add variations based on common prefixes
|
|
2318
|
-
const prefixVariations = extractPrefixVariations(projectName);
|
|
2318
|
+
const prefixVariations = extractPrefixVariations(projectName, prefixes);
|
|
2319
2319
|
for (const variation of prefixVariations) {
|
|
2320
2320
|
scopes.add(variation);
|
|
2321
2321
|
}
|
|
@@ -2335,18 +2335,19 @@ function deriveProjectScopes(options) {
|
|
|
2335
2335
|
return [...scopes];
|
|
2336
2336
|
}
|
|
2337
2337
|
/**
|
|
2338
|
-
*
|
|
2338
|
+
* Default project name prefixes that can be stripped for scope matching.
|
|
2339
2339
|
*/
|
|
2340
|
-
const
|
|
2340
|
+
const DEFAULT_PROJECT_PREFIXES = ['lib-', 'app-', 'e2e-', 'tool-', 'plugin-', 'feature-', 'package-'];
|
|
2341
2341
|
/**
|
|
2342
2342
|
* Generates scope variations by stripping recognized project prefixes.
|
|
2343
2343
|
*
|
|
2344
2344
|
* @param projectName - The project name to extract variations from
|
|
2345
|
+
* @param prefixes - Prefixes to check and strip
|
|
2345
2346
|
* @returns Array of scope name variations
|
|
2346
2347
|
*/
|
|
2347
|
-
function extractPrefixVariations(projectName) {
|
|
2348
|
+
function extractPrefixVariations(projectName, prefixes) {
|
|
2348
2349
|
const variations = [];
|
|
2349
|
-
for (const prefix of
|
|
2350
|
+
for (const prefix of prefixes) {
|
|
2350
2351
|
if (projectName.startsWith(prefix)) {
|
|
2351
2352
|
const withoutPrefix = projectName.slice(prefix.length);
|
|
2352
2353
|
if (withoutPrefix) {
|
|
@@ -3190,6 +3191,10 @@ function splitLines(message) {
|
|
|
3190
3191
|
return lines;
|
|
3191
3192
|
}
|
|
3192
3193
|
|
|
3194
|
+
/**
|
|
3195
|
+
* Default changelog filename.
|
|
3196
|
+
*/
|
|
3197
|
+
const DEFAULT_CHANGELOG_FILENAME = 'CHANGELOG.md';
|
|
3193
3198
|
/**
|
|
3194
3199
|
* Default scope filtering configuration.
|
|
3195
3200
|
*
|
|
@@ -3201,6 +3206,7 @@ const DEFAULT_SCOPE_FILTERING_CONFIG = {
|
|
|
3201
3206
|
includeScopes: [],
|
|
3202
3207
|
excludeScopes: DEFAULT_EXCLUDE_SCOPES,
|
|
3203
3208
|
trackDependencyChanges: false,
|
|
3209
|
+
projectPrefixes: DEFAULT_PROJECT_PREFIXES,
|
|
3204
3210
|
infrastructure: undefined,
|
|
3205
3211
|
infrastructureMatcher: undefined,
|
|
3206
3212
|
};
|
|
@@ -3227,6 +3233,7 @@ const ANALYZE_COMMITS_STEP_ID = 'analyze-commits';
|
|
|
3227
3233
|
function createAnalyzeCommitsStep() {
|
|
3228
3234
|
return createStep(ANALYZE_COMMITS_STEP_ID, 'Analyze Commits', async (ctx) => {
|
|
3229
3235
|
const { git, projectName, projectRoot, packageName, workspaceRoot, config, logger, state } = ctx;
|
|
3236
|
+
const maxFallback = config.maxCommitFallback ?? 500;
|
|
3230
3237
|
// Use publishedCommit from registry (set by fetch-registry step)
|
|
3231
3238
|
const { publishedCommit, isFirstRelease } = state;
|
|
3232
3239
|
let rawCommits;
|
|
@@ -3243,13 +3250,13 @@ function createAnalyzeCommitsStep() {
|
|
|
3243
3250
|
logger.warn(`Published commit ${publishedCommit.slice(0, 7)} not found in history. ` +
|
|
3244
3251
|
`This may indicate a rebase or force push occurred after publishing v${state.publishedVersion}. ` +
|
|
3245
3252
|
`Falling back to recent commit analysis.`);
|
|
3246
|
-
rawCommits = git.getCommitLog({ maxCount:
|
|
3253
|
+
rawCommits = git.getCommitLog({ maxCount: maxFallback });
|
|
3247
3254
|
// effectiveBaseCommit stays null - no compare URL will be generated
|
|
3248
3255
|
}
|
|
3249
3256
|
}
|
|
3250
3257
|
else {
|
|
3251
3258
|
// First release or no published version
|
|
3252
|
-
rawCommits = git.getCommitLog({ maxCount:
|
|
3259
|
+
rawCommits = git.getCommitLog({ maxCount: maxFallback });
|
|
3253
3260
|
logger.debug(`First release - analyzing up to ${rawCommits.length} commits`);
|
|
3254
3261
|
}
|
|
3255
3262
|
// Get scope filtering configuration
|
|
@@ -3291,7 +3298,7 @@ function createAnalyzeCommitsStep() {
|
|
|
3291
3298
|
const relativePath = getRelativePath(workspaceRoot, projectRoot);
|
|
3292
3299
|
const pathFilteredCommits = effectiveBaseCommit
|
|
3293
3300
|
? git.getCommitsSince(effectiveBaseCommit, { path: relativePath })
|
|
3294
|
-
: git.getCommitLog({ maxCount:
|
|
3301
|
+
: git.getCommitLog({ maxCount: maxFallback, path: relativePath });
|
|
3295
3302
|
fileCommitHashes = createSet(pathFilteredCommits.map((c) => c.hash));
|
|
3296
3303
|
logger.debug(`Found ${fileCommitHashes.size} commits touching ${relativePath}`);
|
|
3297
3304
|
}
|
|
@@ -3300,14 +3307,15 @@ function createAnalyzeCommitsStep() {
|
|
|
3300
3307
|
projectName,
|
|
3301
3308
|
packageName,
|
|
3302
3309
|
additionalScopes: scopeFilteringConfig.includeScopes,
|
|
3310
|
+
prefixes: scopeFilteringConfig.projectPrefixes,
|
|
3303
3311
|
});
|
|
3304
3312
|
logger.debug(`Project scopes: ${projectScopes.join(', ')}`);
|
|
3305
3313
|
// Build infrastructure commit hashes for file-based infrastructure detection
|
|
3306
|
-
const infrastructureCommitHashes = buildInfrastructureCommitHashes(git, effectiveBaseCommit, rawCommits, parsedCommits, scopeFilteringConfig, logger);
|
|
3314
|
+
const infrastructureCommitHashes = buildInfrastructureCommitHashes(git, effectiveBaseCommit, rawCommits, parsedCommits, scopeFilteringConfig, logger, maxFallback);
|
|
3307
3315
|
// Build dependency commit map if tracking is enabled (Phase 4)
|
|
3308
3316
|
let dependencyCommitMap;
|
|
3309
3317
|
if (scopeFilteringConfig.trackDependencyChanges) {
|
|
3310
|
-
dependencyCommitMap = buildDependencyCommitMap(git, workspaceRoot, projectName, effectiveBaseCommit, logger);
|
|
3318
|
+
dependencyCommitMap = buildDependencyCommitMap(git, workspaceRoot, projectName, effectiveBaseCommit, logger, maxFallback);
|
|
3311
3319
|
}
|
|
3312
3320
|
// Create classification context
|
|
3313
3321
|
const classificationContext = createClassificationContext(projectScopes, fileCommitHashes, {
|
|
@@ -3440,9 +3448,10 @@ function buildSummaryMessage(includedCount, totalCount, summary, strategy) {
|
|
|
3440
3448
|
* @param config - Scope filtering configuration
|
|
3441
3449
|
* @param logger - Logger with debug method for output
|
|
3442
3450
|
* @param logger.debug - Debug logging function
|
|
3451
|
+
* @param maxFallback - Maximum commits to query when baseCommit is null
|
|
3443
3452
|
* @returns Set of commit hashes classified as infrastructure
|
|
3444
3453
|
*/
|
|
3445
|
-
function buildInfrastructureCommitHashes(git, baseCommit, rawCommits, parsedCommits, config, logger) {
|
|
3454
|
+
function buildInfrastructureCommitHashes(git, baseCommit, rawCommits, parsedCommits, config, logger, maxFallback) {
|
|
3446
3455
|
// Collect all infrastructure commit hashes
|
|
3447
3456
|
let infraHashes = createSet();
|
|
3448
3457
|
// Method 1: Path-based detection (query git for commits touching infra paths)
|
|
@@ -3451,7 +3460,7 @@ function buildInfrastructureCommitHashes(git, baseCommit, rawCommits, parsedComm
|
|
|
3451
3460
|
for (const infraPath of infraPaths) {
|
|
3452
3461
|
const pathCommits = baseCommit
|
|
3453
3462
|
? git.getCommitsSince(baseCommit, { path: infraPath })
|
|
3454
|
-
: git.getCommitLog({ maxCount:
|
|
3463
|
+
: git.getCommitLog({ maxCount: maxFallback, path: infraPath });
|
|
3455
3464
|
for (const commit of pathCommits) {
|
|
3456
3465
|
infraHashes = infraHashes.add(commit.hash);
|
|
3457
3466
|
}
|
|
@@ -3519,9 +3528,10 @@ function combineMatcher(a, b) {
|
|
|
3519
3528
|
* @param baseCommit - Base commit hash for commit range (null for first release/fallback)
|
|
3520
3529
|
* @param logger - Logger with debug method for output
|
|
3521
3530
|
* @param logger.debug - Debug logging function
|
|
3531
|
+
* @param maxFallback - Maximum commits to query when baseCommit is null
|
|
3522
3532
|
* @returns Map of dependency names to commit hashes touching that dependency
|
|
3523
3533
|
*/
|
|
3524
|
-
function buildDependencyCommitMap(git, workspaceRoot, projectName, baseCommit, logger) {
|
|
3534
|
+
function buildDependencyCommitMap(git, workspaceRoot, projectName, baseCommit, logger, maxFallback) {
|
|
3525
3535
|
let dependencyMap = createMap();
|
|
3526
3536
|
try {
|
|
3527
3537
|
// Discover all projects in workspace using lib-project-scope
|
|
@@ -3546,7 +3556,7 @@ function buildDependencyCommitMap(git, workspaceRoot, projectName, baseCommit, l
|
|
|
3546
3556
|
// Query git for commits touching this dependency's path
|
|
3547
3557
|
const depCommits = baseCommit
|
|
3548
3558
|
? git.getCommitsSince(baseCommit, { path: depRoot })
|
|
3549
|
-
: git.getCommitLog({ maxCount:
|
|
3559
|
+
: git.getCommitLog({ maxCount: maxFallback, path: depRoot });
|
|
3550
3560
|
if (depCommits.length > 0) {
|
|
3551
3561
|
const hashSet = createSet(depCommits.map((c) => c.hash));
|
|
3552
3562
|
dependencyMap = dependencyMap.set(dep.target, hashSet);
|
|
@@ -5213,11 +5223,22 @@ function isWhitespace(char) {
|
|
|
5213
5223
|
}
|
|
5214
5224
|
|
|
5215
5225
|
/**
|
|
5216
|
-
*
|
|
5226
|
+
* Validates that a URL is actually a GitHub URL by parsing it properly.
|
|
5227
|
+
* This prevents SSRF attacks where 'github.com' could appear in path/query.
|
|
5217
5228
|
*
|
|
5218
|
-
*
|
|
5219
|
-
*
|
|
5229
|
+
* @param url - The URL string to validate
|
|
5230
|
+
* @returns True if the URL host is github.com or a subdomain
|
|
5220
5231
|
*/
|
|
5232
|
+
function isGitHubUrl(url) {
|
|
5233
|
+
try {
|
|
5234
|
+
const parsed = createURL(url);
|
|
5235
|
+
// Check that the host is exactly github.com or ends with .github.com
|
|
5236
|
+
return parsed.host === 'github.com' || parsed.host.endsWith('.github.com');
|
|
5237
|
+
}
|
|
5238
|
+
catch {
|
|
5239
|
+
return false;
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5221
5242
|
/**
|
|
5222
5243
|
* Parses a changelog markdown string into a Changelog object.
|
|
5223
5244
|
*
|
|
@@ -5285,7 +5306,7 @@ function parseHeader(state) {
|
|
|
5285
5306
|
description.push(`[${token.value}](${nextToken.value})`);
|
|
5286
5307
|
links.push({ label: token.value, url: nextToken.value });
|
|
5287
5308
|
// Try to detect repository URL
|
|
5288
|
-
if (!state.repositoryUrl && nextToken.value
|
|
5309
|
+
if (!state.repositoryUrl && isGitHubUrl(nextToken.value)) {
|
|
5289
5310
|
state.repositoryUrl = extractRepoUrl(nextToken.value);
|
|
5290
5311
|
}
|
|
5291
5312
|
advance(state); // skip link-text
|
|
@@ -6087,7 +6108,7 @@ const GENERATE_CHANGELOG_STEP_ID = 'generate-changelog';
|
|
|
6087
6108
|
/**
|
|
6088
6109
|
* Maps conventional commit types to changelog section types.
|
|
6089
6110
|
*/
|
|
6090
|
-
const
|
|
6111
|
+
const DEFAULT_COMMIT_TYPE_TO_SECTION = {
|
|
6091
6112
|
feat: 'features',
|
|
6092
6113
|
fix: 'fixes',
|
|
6093
6114
|
perf: 'performance',
|
|
@@ -6100,6 +6121,18 @@ const COMMIT_TYPE_TO_SECTION = {
|
|
|
6100
6121
|
chore: 'chores',
|
|
6101
6122
|
style: 'other',
|
|
6102
6123
|
};
|
|
6124
|
+
/**
|
|
6125
|
+
* Resolves the commit type to section mapping by merging config with defaults.
|
|
6126
|
+
*
|
|
6127
|
+
* @param configMapping - User-provided partial mapping from FlowConfig
|
|
6128
|
+
* @returns Resolved mapping with user overrides applied
|
|
6129
|
+
*/
|
|
6130
|
+
function resolveCommitTypeMapping(configMapping) {
|
|
6131
|
+
if (!configMapping) {
|
|
6132
|
+
return DEFAULT_COMMIT_TYPE_TO_SECTION;
|
|
6133
|
+
}
|
|
6134
|
+
return { ...DEFAULT_COMMIT_TYPE_TO_SECTION, ...configMapping };
|
|
6135
|
+
}
|
|
6103
6136
|
/**
|
|
6104
6137
|
* Checks if a commit source represents an indirect change.
|
|
6105
6138
|
*
|
|
@@ -6113,16 +6146,22 @@ function isIndirectSource(source) {
|
|
|
6113
6146
|
* Groups classified commits by their section type.
|
|
6114
6147
|
*
|
|
6115
6148
|
* @param commits - Array of classified commits
|
|
6149
|
+
* @param mapping - Commit type to section mapping
|
|
6116
6150
|
* @returns Record of section type to classified commits
|
|
6117
6151
|
*/
|
|
6118
|
-
function groupClassifiedCommitsBySection(commits) {
|
|
6152
|
+
function groupClassifiedCommitsBySection(commits, mapping) {
|
|
6119
6153
|
const groups = {};
|
|
6120
6154
|
for (const classified of commits) {
|
|
6121
|
-
const sectionType =
|
|
6122
|
-
if (
|
|
6123
|
-
|
|
6155
|
+
const sectionType = mapping[classified.commit.type ?? 'chore'];
|
|
6156
|
+
// Skip if explicitly excluded (null)
|
|
6157
|
+
if (sectionType === null)
|
|
6158
|
+
continue;
|
|
6159
|
+
// Fallback to 'chores' for unmapped types
|
|
6160
|
+
const resolvedSection = sectionType ?? 'chores';
|
|
6161
|
+
if (!groups[resolvedSection]) {
|
|
6162
|
+
groups[resolvedSection] = [];
|
|
6124
6163
|
}
|
|
6125
|
-
groups[
|
|
6164
|
+
groups[resolvedSection].push(classified);
|
|
6126
6165
|
}
|
|
6127
6166
|
return groups;
|
|
6128
6167
|
}
|
|
@@ -6130,16 +6169,22 @@ function groupClassifiedCommitsBySection(commits) {
|
|
|
6130
6169
|
* Groups commits by their section type.
|
|
6131
6170
|
*
|
|
6132
6171
|
* @param commits - Array of conventional commits
|
|
6172
|
+
* @param mapping - Commit type to section mapping
|
|
6133
6173
|
* @returns Record of section type to commits
|
|
6134
6174
|
*/
|
|
6135
|
-
function groupCommitsBySection(commits) {
|
|
6175
|
+
function groupCommitsBySection(commits, mapping) {
|
|
6136
6176
|
const groups = {};
|
|
6137
6177
|
for (const commit of commits) {
|
|
6138
|
-
const sectionType =
|
|
6139
|
-
if (
|
|
6140
|
-
|
|
6178
|
+
const sectionType = mapping[commit.type ?? 'chore'];
|
|
6179
|
+
// Skip if explicitly excluded (null)
|
|
6180
|
+
if (sectionType === null)
|
|
6181
|
+
continue;
|
|
6182
|
+
// Fallback to 'chores' for unmapped types
|
|
6183
|
+
const resolvedSection = sectionType ?? 'chores';
|
|
6184
|
+
if (!groups[resolvedSection]) {
|
|
6185
|
+
groups[resolvedSection] = [];
|
|
6141
6186
|
}
|
|
6142
|
-
groups[
|
|
6187
|
+
groups[resolvedSection].push(commit);
|
|
6143
6188
|
}
|
|
6144
6189
|
return groups;
|
|
6145
6190
|
}
|
|
@@ -6207,6 +6252,8 @@ function createGenerateChangelogStep() {
|
|
|
6207
6252
|
return createStep(GENERATE_CHANGELOG_STEP_ID, 'Generate Changelog Entry', async (ctx) => {
|
|
6208
6253
|
const { config, state } = ctx;
|
|
6209
6254
|
const { commits, nextVersion, bumpType } = state;
|
|
6255
|
+
// Resolve commit type to section mapping
|
|
6256
|
+
const commitTypeMapping = resolveCommitTypeMapping(config.commitTypeToSection);
|
|
6210
6257
|
// Skip if no bump needed
|
|
6211
6258
|
if (!nextVersion || bumpType === 'none') {
|
|
6212
6259
|
return createSkippedResult('No version bump, skipping changelog generation');
|
|
@@ -6268,7 +6315,7 @@ function createGenerateChangelogStep() {
|
|
|
6268
6315
|
})));
|
|
6269
6316
|
}
|
|
6270
6317
|
// Group direct commits by section
|
|
6271
|
-
const groupedDirect = groupClassifiedCommitsBySection(directCommits);
|
|
6318
|
+
const groupedDirect = groupClassifiedCommitsBySection(directCommits, commitTypeMapping);
|
|
6272
6319
|
// Add other sections in conventional order (direct commits only)
|
|
6273
6320
|
const sectionOrder = [
|
|
6274
6321
|
{ type: 'features', heading: 'Features' },
|
|
@@ -6296,7 +6343,7 @@ function createGenerateChangelogStep() {
|
|
|
6296
6343
|
}
|
|
6297
6344
|
else {
|
|
6298
6345
|
// Fallback: use commits without classification (backward compatibility)
|
|
6299
|
-
const grouped = groupCommitsBySection(commits);
|
|
6346
|
+
const grouped = groupCommitsBySection(commits, commitTypeMapping);
|
|
6300
6347
|
// Add breaking changes section first if any
|
|
6301
6348
|
const breakingCommits = commits.filter((c) => c.breaking);
|
|
6302
6349
|
if (breakingCommits.length > 0) {
|
|
@@ -6372,14 +6419,15 @@ function createWriteChangelogStep() {
|
|
|
6372
6419
|
if (!nextVersion || bumpType === 'none' || !changelogEntry || config.skipChangelog) {
|
|
6373
6420
|
return createSkippedResult('No changelog to write');
|
|
6374
6421
|
}
|
|
6375
|
-
const
|
|
6422
|
+
const changelogFileName = config.changelogFileName ?? DEFAULT_CHANGELOG_FILENAME;
|
|
6423
|
+
const changelogPath = `${projectRoot}/${changelogFileName}`;
|
|
6376
6424
|
let existingContent = '';
|
|
6377
6425
|
// Read existing changelog
|
|
6378
6426
|
try {
|
|
6379
6427
|
existingContent = tree.read(changelogPath, 'utf-8') ?? '';
|
|
6380
6428
|
}
|
|
6381
6429
|
catch {
|
|
6382
|
-
logger.debug(
|
|
6430
|
+
logger.debug(`No existing ${changelogFileName} found`);
|
|
6383
6431
|
}
|
|
6384
6432
|
// If no existing content, create new changelog
|
|
6385
6433
|
if (!existingContent.trim()) {
|
|
@@ -6397,7 +6445,7 @@ function createWriteChangelogStep() {
|
|
|
6397
6445
|
stateUpdates: {
|
|
6398
6446
|
modifiedFiles: [...(state.modifiedFiles ?? []), changelogPath],
|
|
6399
6447
|
},
|
|
6400
|
-
message: `Created
|
|
6448
|
+
message: `Created ${changelogFileName} with version ${nextVersion}`,
|
|
6401
6449
|
};
|
|
6402
6450
|
}
|
|
6403
6451
|
// Parse existing and add entry
|
|
@@ -6431,7 +6479,7 @@ function createWriteChangelogStep() {
|
|
|
6431
6479
|
stateUpdates: {
|
|
6432
6480
|
modifiedFiles: [...(state.modifiedFiles ?? []), changelogPath],
|
|
6433
6481
|
},
|
|
6434
|
-
message: `Updated
|
|
6482
|
+
message: `Updated ${changelogFileName} with version ${nextVersion}`,
|
|
6435
6483
|
};
|
|
6436
6484
|
}, {
|
|
6437
6485
|
dependsOn: ['generate-changelog'],
|
|
@@ -6784,5 +6832,5 @@ function createPushTagStep() {
|
|
|
6784
6832
|
});
|
|
6785
6833
|
}
|
|
6786
6834
|
|
|
6787
|
-
export { ANALYZE_COMMITS_STEP_ID, CALCULATE_BUMP_STEP_ID, CREATE_COMMIT_STEP_ID, CREATE_TAG_STEP_ID, FETCH_REGISTRY_STEP_ID, GENERATE_CHANGELOG_STEP_ID, RESOLVE_REPOSITORY_STEP_ID, UPDATE_PACKAGES_STEP_ID, createAnalyzeCommitsStep, createCalculateBumpStep, createCascadeDependenciesStep, createCheckIdempotencyStep, createFetchRegistryStep, createGenerateChangelogStep, createGitCommitStep, createPushTagStep, createResolveRepositoryStep, createTagStep, createUpdatePackageStep, createWriteChangelogStep };
|
|
6835
|
+
export { ANALYZE_COMMITS_STEP_ID, CALCULATE_BUMP_STEP_ID, CREATE_COMMIT_STEP_ID, CREATE_TAG_STEP_ID, DEFAULT_COMMIT_TYPE_TO_SECTION, FETCH_REGISTRY_STEP_ID, GENERATE_CHANGELOG_STEP_ID, RESOLVE_REPOSITORY_STEP_ID, UPDATE_PACKAGES_STEP_ID, createAnalyzeCommitsStep, createCalculateBumpStep, createCascadeDependenciesStep, createCheckIdempotencyStep, createFetchRegistryStep, createGenerateChangelogStep, createGitCommitStep, createPushTagStep, createResolveRepositoryStep, createTagStep, createUpdatePackageStep, createWriteChangelogStep };
|
|
6788
6836
|
//# sourceMappingURL=index.esm.js.map
|