@deltabox/toolchain 1.11.4 → 2.1.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 +336 -4
- package/README.md +21 -14
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/changelog.d.ts +10 -6
- package/dist/changelog.js +1 -1
- package/dist/cli/commands/index.js +1 -1
- package/dist/cli/commands/providers.js +1 -1
- package/dist/cli/commands/reset.js +1 -1
- package/dist/cli/commands/shared.js +1 -1
- package/dist/cli/commands/sync.js +1 -1
- package/dist/cli/commands/watch.js +1 -1
- package/dist/cli/config-selection.d.ts +23 -0
- package/dist/cli/config-selection.js +1 -0
- package/dist/cli/context.js +1 -1
- package/dist/cli/index.d.ts +5 -3
- package/dist/cli/index.js +1 -1
- package/dist/cli/register.js +1 -1
- package/dist/config.d.ts +8 -8
- package/dist/config.js +1 -1
- package/dist/core.d.ts +7 -6
- package/dist/core.js +1 -1
- package/dist/globals.d.ts +31 -0
- package/dist/globals.js +1 -0
- package/dist/index.d.ts +33 -11
- package/dist/index.js +1 -1
- package/dist/migrate.d.ts +3 -2
- package/dist/migrate.js +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/biome/src/index.d.ts +2 -1
- package/dist/packages/biome/src/index.js +1 -1
- package/dist/packages/changelog/src/cli/index.js +1 -1
- package/dist/packages/changelog/src/index.d.ts +11 -7
- package/dist/packages/changelog/src/index.js +1 -1
- package/dist/packages/changelog/src/run-workflows.d.ts +19 -4
- package/dist/packages/changelog/src/run-workflows.js +1 -1
- package/dist/packages/changelog/src/run.d.ts +4 -3
- package/dist/packages/changelog/src/run.js +1 -1
- package/dist/packages/changelog/src/sync.d.ts +7 -4
- package/dist/packages/changelog/src/sync.js +1 -1
- package/dist/packages/changelog/src/utils/args.js +1 -1
- package/dist/packages/changelog/src/utils/breaking.d.ts +16 -0
- package/dist/packages/changelog/src/utils/breaking.js +1 -0
- package/dist/packages/changelog/src/utils/format.d.ts +2 -1
- package/dist/packages/changelog/src/utils/format.js +5 -5
- package/dist/packages/changelog/src/utils/git.d.ts +3 -1
- package/dist/packages/changelog/src/utils/git.js +1 -1
- package/dist/packages/changelog/src/utils/reformat.d.ts +4 -1
- package/dist/packages/changelog/src/utils/reformat.js +4 -4
- package/dist/packages/changelog/src/utils/release-notes.d.ts +18 -0
- package/dist/packages/changelog/src/utils/release-notes.js +1 -0
- package/dist/packages/changelog/src/utils/summary.d.ts +29 -2
- package/dist/packages/changelog/src/utils/summary.js +3 -1
- package/dist/packages/changelog/src/utils/types.d.ts +39 -2
- package/dist/packages/changelog/src/utils/version.d.ts +1 -0
- package/dist/packages/changelog/src/utils/versioning.d.ts +30 -4
- package/dist/packages/changelog/src/utils/versioning.js +1 -1
- package/dist/packages/changelog/src/utils/write.js +1 -1
- package/dist/packages/changelog/src/workflows.d.ts +27 -7
- package/dist/packages/changelog/src/workflows.js +5 -5
- package/dist/packages/config/src/cli/index.js +1 -1
- package/dist/packages/config/src/collect.d.ts +10 -8
- package/dist/packages/config/src/collect.js +1 -1
- package/dist/packages/config/src/config-json.d.ts +4 -4
- package/dist/packages/config/src/config-json.js +1 -1
- package/dist/packages/config/src/engine.d.ts +14 -25
- package/dist/packages/config/src/engine.js +1 -1
- package/dist/packages/config/src/env-file.d.ts +4 -4
- package/dist/packages/config/src/env-file.js +2 -2
- package/dist/packages/config/src/env.d.ts +4 -6
- package/dist/packages/config/src/env.js +1 -1
- package/dist/packages/config/src/generators/cli.d.ts +6 -6
- package/dist/packages/config/src/generators/cli.js +1 -1
- package/dist/packages/config/src/generators/env.d.ts +9 -9
- package/dist/packages/config/src/generators/env.js +2 -2
- package/dist/packages/config/src/generators/index.d.ts +4 -4
- package/dist/packages/config/src/generators/index.js +1 -1
- package/dist/packages/config/src/generators/json.d.ts +5 -7
- package/dist/packages/config/src/generators/json.js +1 -1
- package/dist/packages/config/src/generators/markdown.d.ts +57 -35
- package/dist/packages/config/src/generators/markdown.js +18 -19
- package/dist/packages/config/src/generators/types.d.ts +28 -23
- package/dist/packages/config/src/generators/types.js +3 -3
- package/dist/packages/config/src/index.d.ts +9 -9
- package/dist/packages/config/src/index.js +1 -1
- package/dist/packages/config/src/schema.d.ts +31 -3
- package/dist/packages/config/src/schema.js +1 -1
- package/dist/packages/config/src/types.d.ts +134 -28
- package/dist/packages/core/src/editor-config.d.ts +14 -0
- package/dist/packages/core/src/editor-config.js +1 -0
- package/dist/packages/core/src/graph.js +1 -1
- package/dist/packages/core/src/index.d.ts +8 -7
- package/dist/packages/core/src/index.js +1 -1
- package/dist/packages/core/src/loader.d.ts +20 -2
- package/dist/packages/core/src/loader.js +1 -1
- package/dist/packages/core/src/manifest.d.ts +20 -1
- package/dist/packages/core/src/manifest.js +1 -1
- package/dist/packages/core/src/provider-registry.d.ts +48 -3
- package/dist/packages/core/src/provider-registry.js +1 -1
- package/dist/packages/core/src/reset.d.ts +15 -0
- package/dist/packages/core/src/reset.js +1 -1
- package/dist/packages/core/src/sync.d.ts +10 -0
- package/dist/packages/core/src/sync.js +1 -1
- package/dist/packages/core/src/watch.d.ts +9 -0
- package/dist/packages/core/src/watch.js +1 -1
- package/dist/packages/migrate/src/cli/index.js +1 -1
- package/dist/packages/migrate/src/index.d.ts +3 -2
- package/dist/packages/migrate/src/index.js +1 -1
- package/dist/packages/migrate/src/oxc.d.ts +13 -0
- package/dist/packages/migrate/src/oxc.js +1 -0
- package/dist/packages/migrate/src/registry.js +1 -1
- package/dist/packages/migrate/src/vite-target.js +1 -1
- package/dist/packages/migrate/src/vite.d.ts +25 -3
- package/dist/packages/migrate/src/vite.js +7 -2
- package/dist/packages/project/src/catalogs.d.ts +7 -0
- package/dist/packages/project/src/catalogs.js +1 -1
- package/dist/packages/project/src/cli/index.js +1 -1
- package/dist/packages/project/src/config.d.ts +6 -0
- package/dist/packages/project/src/config.js +1 -1
- package/dist/packages/project/src/index.d.ts +5 -4
- package/dist/packages/project/src/index.js +1 -1
- package/dist/packages/project/src/sync.js +1 -1
- package/dist/packages/project/src/typescript.d.ts +64 -12
- package/dist/packages/project/src/typescript.js +12 -7
- package/dist/packages/shared/src/changelog-breaking.d.ts +31 -0
- package/dist/packages/shared/src/changelog-groups.d.ts +59 -0
- package/dist/packages/shared/src/config-schema/biome.d.ts +10 -0
- package/dist/packages/shared/src/config-schema/biome.js +1 -0
- package/dist/packages/shared/src/config-schema/catalogs.d.ts +14 -0
- package/dist/packages/shared/src/config-schema/catalogs.js +1 -0
- package/dist/packages/shared/src/config-schema/changelog.d.ts +248 -0
- package/dist/packages/shared/src/config-schema/changelog.js +1 -0
- package/dist/packages/shared/src/config-schema/ci.d.ts +390 -0
- package/dist/packages/shared/src/config-schema/ci.js +1 -0
- package/dist/packages/shared/src/config-schema/format.d.ts +38 -0
- package/dist/packages/shared/src/config-schema/format.js +1 -0
- package/dist/packages/shared/src/config-schema/index.d.ts +1654 -0
- package/dist/packages/shared/src/config-schema/index.js +1 -0
- package/dist/packages/shared/src/config-schema/logger.d.ts +19 -0
- package/dist/packages/shared/src/config-schema/logger.js +1 -0
- package/dist/packages/shared/src/config-schema/meta.d.ts +16 -0
- package/dist/packages/shared/src/config-schema/meta.js +1 -0
- package/dist/packages/shared/src/config-schema/project.d.ts +35 -0
- package/dist/packages/shared/src/config-schema/project.js +1 -0
- package/dist/packages/shared/src/config-schema/providers.d.ts +9 -0
- package/dist/packages/shared/src/config-schema/providers.js +1 -0
- package/dist/packages/shared/src/config-schema/registry.d.ts +21 -0
- package/dist/packages/shared/src/config-schema/registry.js +1 -0
- package/dist/packages/shared/src/config-schema/templates.d.ts +81 -0
- package/dist/packages/shared/src/config-schema/templates.js +1 -0
- package/dist/packages/shared/src/config-schema/tsconfig.d.ts +30 -0
- package/dist/packages/shared/src/config-schema/tsconfig.js +1 -0
- package/dist/packages/shared/src/config-schema/vite.d.ts +26 -0
- package/dist/packages/shared/src/config-schema/vite.js +1 -0
- package/dist/packages/shared/src/config-schema/watch.d.ts +11 -0
- package/dist/packages/shared/src/config-schema/watch.js +1 -0
- package/dist/packages/shared/src/config-schema/workflow.d.ts +590 -0
- package/dist/packages/shared/src/config-schema/workflow.js +1 -0
- package/dist/packages/shared/src/config-types.d.ts +295 -90
- package/dist/packages/shared/src/fs-utils.js +1 -1
- package/dist/packages/shared/src/index.d.ts +27 -7
- package/dist/packages/shared/src/index.js +1 -1
- package/dist/packages/shared/src/logger.d.ts +26 -3
- package/dist/packages/shared/src/logger.js +1 -1
- package/dist/packages/shared/src/messages.d.ts +36 -0
- package/dist/packages/shared/src/messages.js +1 -0
- package/dist/packages/shared/src/object-utils.d.ts +5 -0
- package/dist/packages/shared/src/object-utils.js +1 -1
- package/dist/packages/shared/src/registry-policy.d.ts +17 -0
- package/dist/packages/shared/src/registry-policy.js +1 -0
- package/dist/packages/shared/src/toolchain.d.ts +90 -11
- package/dist/packages/shared/src/toolchain.js +1 -1
- package/dist/packages/shared/src/types.d.ts +6 -0
- package/dist/packages/shared/src/vite-defaults.d.ts +29 -0
- package/dist/packages/shared/src/vite-defaults.js +1 -0
- package/dist/packages/template/src/builtin.js +1 -1
- package/dist/packages/template/src/cli/index.js +1 -1
- package/dist/packages/template/src/global.d.ts +130 -0
- package/dist/packages/template/src/global.js +3 -0
- package/dist/packages/template/src/index.d.ts +3 -2
- package/dist/packages/template/src/index.js +1 -1
- package/dist/packages/template/src/online.d.ts +13 -4
- package/dist/packages/template/src/online.js +1 -1
- package/dist/packages/template/src/registry.d.ts +2 -1
- package/dist/packages/template/src/registry.js +1 -1
- package/dist/packages/template/src/scaffold.d.ts +5 -1
- package/dist/packages/template/src/scaffold.js +1 -1
- package/dist/packages/tsconfig/src/cli/generate/index.d.ts +3 -0
- package/dist/packages/tsconfig/src/cli/generate/index.js +1 -1
- package/dist/packages/tsconfig/src/cli/generate/utils.d.ts +10 -1
- package/dist/packages/tsconfig/src/cli/generate/utils.js +1 -1
- package/dist/packages/tsconfig/src/cli/index.js +1 -1
- package/dist/packages/tsconfig/src/index.d.ts +7 -4
- package/dist/packages/tsconfig/src/index.js +1 -1
- package/dist/packages/tsconfig/src/overrides.d.ts +74 -0
- package/dist/packages/tsconfig/src/overrides.js +1 -0
- package/dist/packages/tsconfig/src/resolve.d.ts +62 -0
- package/dist/packages/tsconfig/src/resolve.js +3 -0
- package/dist/packages/tsconfig/src/snapshots.d.ts +50 -0
- package/dist/packages/tsconfig/src/snapshots.js +1 -0
- package/dist/packages/tsconfig/src/sync.d.ts +14 -5
- package/dist/packages/tsconfig/src/sync.js +1 -1
- package/dist/packages/tsconfig/src/templates/tsconfig.default.js +1 -1
- package/dist/packages/tsconfig/src/templates.d.ts +12 -4
- package/dist/packages/tsconfig/src/templates.js +1 -1
- package/dist/packages/vite/src/index.d.ts +2 -2
- package/dist/packages/vite/src/index.js +1 -1
- package/dist/packages/vite/src/resolve.d.ts +13 -3
- package/dist/packages/vite/src/resolve.js +1 -1
- package/dist/packages/vite/src/sync.d.ts +46 -5
- package/dist/packages/vite/src/sync.js +5 -2
- package/dist/project.d.ts +4 -3
- package/dist/project.js +1 -1
- package/dist/providers.d.ts +11 -4
- package/dist/providers.js +1 -1
- package/dist/shared.d.ts +26 -6
- package/dist/shared.js +1 -1
- package/dist/sync.js +1 -1
- package/dist/template.d.ts +3 -2
- package/dist/template.js +1 -1
- package/dist/tooling.d.ts +21 -0
- package/dist/tooling.js +1 -0
- package/dist/tsconfig.d.ts +6 -3
- package/dist/tsconfig.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +28 -23
- package/dist/packages/config/src/types.js +0 -1
- package/dist/packages/shared/src/config-schema.d.ts +0 -3928
- package/dist/packages/shared/src/config-schema.js +0 -1
|
@@ -7,17 +7,28 @@ import { WorkflowId } from "./workflows.js";
|
|
|
7
7
|
export interface RunWorkflowsOptions {
|
|
8
8
|
/** The project root the workflows live under. */
|
|
9
9
|
cwd: string;
|
|
10
|
-
/** Workflow ids or file names to run (default: every enabled workflow). */
|
|
10
|
+
/** Workflow ids, custom ids, or file names to run (default: every enabled workflow). */
|
|
11
11
|
workflows?: string[];
|
|
12
12
|
/** Git ref to run the workflow on (eg. `main`). */
|
|
13
13
|
ref?: string;
|
|
14
|
-
/** The loaded tooling config, used to check `
|
|
14
|
+
/** The loaded tooling config, used to check the `ci` workflows. */
|
|
15
15
|
config?: ToolchainConfig;
|
|
16
16
|
/** The `gh` executable (default `gh`). */
|
|
17
17
|
gh?: string;
|
|
18
18
|
}
|
|
19
|
+
/** One enabled workflow as it is generated on disk. */
|
|
20
|
+
export interface WorkflowTarget {
|
|
21
|
+
/** The workflow id (`ci`, `release`, ...) or the custom workflow key. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Whether the target comes from `ci.custom`. */
|
|
24
|
+
custom: boolean;
|
|
25
|
+
/** The workflow file's basename. */
|
|
26
|
+
file: string;
|
|
27
|
+
/** The repo-relative workflow file path (custom dir/filename included). */
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
19
30
|
export interface RanWorkflow {
|
|
20
|
-
id:
|
|
31
|
+
id: string;
|
|
21
32
|
file: string;
|
|
22
33
|
/** The `gh` exit code (0 = triggered). */
|
|
23
34
|
code: number;
|
|
@@ -25,8 +36,12 @@ export interface RanWorkflow {
|
|
|
25
36
|
export interface RunWorkflowsResult {
|
|
26
37
|
ran: RanWorkflow[];
|
|
27
38
|
}
|
|
28
|
-
/** Resolve a workflow id or file name (`ci` / `ci.yml`) to a known id. */
|
|
39
|
+
/** Resolve a workflow id or file name (`ci` / `ci.yml`) to a known built-in id. */
|
|
29
40
|
export declare function resolveWorkflowId(name: string): WorkflowId | undefined;
|
|
41
|
+
/** Every enabled workflow target for a config (built-ins + `ci.custom`). */
|
|
42
|
+
export declare function workflowTargets(config?: ToolchainConfig): WorkflowTarget[];
|
|
43
|
+
/** Find an enabled workflow by id, custom id, file basename, or relative path. */
|
|
44
|
+
export declare function resolveWorkflowTarget(name: string, targets: WorkflowTarget[]): WorkflowTarget | undefined;
|
|
30
45
|
/**
|
|
31
46
|
* Trigger the requested workflows (all enabled ones when none are named).
|
|
32
47
|
* Throws when a workflow is unknown, disabled in the config or not generated.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{sectionConfig as t,sectionEnabled as n}from"../../shared/src/toolchain.js";import"../../shared/src/index.js";import{WORKFLOW_FILENAMES as r,isEnabled as i}from"./workflows.js";import
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{sectionConfig as t,sectionEnabled as n}from"../../shared/src/toolchain.js";import"../../shared/src/index.js";import{WORKFLOW_FILENAMES as r,isEnabled as i,workflowFilePath as a}from"./workflows.js";import o from"node:fs";import{spawn as s}from"node:child_process";function c(e){let t=e.trim().replace(/\.ya?ml$/i,``).toLowerCase();return Object.keys(r).find(e=>e===t)}function l(e){let o=n(e?.ci)?t(e?.ci):void 0;if(!o)return[];let s=[];for(let e of Object.keys(r)){let t=o[e];if(!i(t))continue;let n=a(e,t,r[e]);s.push({id:e,custom:!1,file:n.split(`/`).pop()??n,path:n})}for(let[e,t]of Object.entries(o.custom??{})){if(!i(t))continue;let n=a(e,t);s.push({id:e,custom:!0,file:n.split(`/`).pop()??n,path:n})}return s}function u(e,t){let n=e.trim(),r=n.replace(/\.ya?ml$/i,``).toLowerCase();return t.find(e=>e.id===n||e.id.toLowerCase()===n.toLowerCase()||e.file===n||e.path===n||e.file.replace(/\.ya?ml$/i,``).toLowerCase()===r)}function d(e,t,n){return new Promise(r=>{let i=s(n,e,{cwd:t,stdio:`inherit`});i.on(`error`,()=>r(1)),i.on(`exit`,e=>r(e??0))})}async function f(t){let{cwd:n}=t,r=l(t.config),i=(t.workflows??[]).map(e=>e.trim()).filter(Boolean),a;if(i.length===0){if(r.length===0)throw Error(`No workflows are enabled in dbx.config.* (ci.<workflow>).`);a=r}else{a=[];for(let e of i){let t=u(e,r);if(!t){let t=r.map(e=>e.id).join(`, `);throw Error(`Unknown or disabled workflow "${e}". Enabled workflows: ${t||`none`}.`)}a.some(e=>e.path===t.path)||a.push(t)}}let s=t.gh??`gh`,c=[];for(let r of a){let i=e.resolve(n,r.path);if(!o.existsSync(i))throw Error(`Workflow file not found: ${r.path}. Run \`dbx sync\` first.`);let a=[`workflow`,`run`,r.file];t.ref&&a.push(`--ref`,t.ref),c.push({id:r.id,file:r.file,code:await d(a,n,s)})}return{ran:c}}export{c as resolveWorkflowId,u as resolveWorkflowTarget,f as runWorkflows,l as workflowTargets};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import {
|
|
3
|
+
import { ChangelogConfig } from "../../shared/src/config-types.js";
|
|
4
4
|
import "../../shared/src/index.js";
|
|
5
5
|
import { parseArgsCli } from "./utils/args.js";
|
|
6
|
+
import { isBreakingCommit } from "./utils/breaking.js";
|
|
6
7
|
import { formatBody, groupItems, parseCcSubject, renderGroups, ruleTitle, splitInlineDescription } from "./utils/format.js";
|
|
7
8
|
import { deriveBump, readCommits } from "./utils/git.js";
|
|
8
9
|
import { parseExistingChangelog, reformatChangelogContent } from "./utils/reformat.js";
|
|
@@ -11,10 +12,10 @@ import { renderChangelogEntry } from "./utils/version.js";
|
|
|
11
12
|
//#region packages/changelog/src/run.d.ts
|
|
12
13
|
/**
|
|
13
14
|
* Run the changelog pipeline (bump versions + write changelogs). `changelog` is
|
|
14
|
-
* the consumer's `toolchain.changelog`
|
|
15
|
+
* the consumer's `toolchain.ci.changelog` config (threaded from `dbx changelog`);
|
|
15
16
|
* the standalone bin runs with the defaults (`versioning: true`, uniform).
|
|
16
17
|
*/
|
|
17
|
-
export declare function runChangelog(argv?: string[], changelog?:
|
|
18
|
+
export declare function runChangelog(argv?: string[], changelog?: ChangelogConfig): void;
|
|
18
19
|
/** Alias kept for backwards compatibility. */
|
|
19
20
|
export declare const main: typeof runChangelog;
|
|
20
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import{fileURLToPath as t}from"node:url";import.meta.url;import{logger as n}from"../../shared/src/logger.js";import"../../shared/src/index.js";import{parseArgsCli as
|
|
1
|
+
import{resolve as e}from"node:path";import{fileURLToPath as t}from"node:url";import.meta.url;import{logger as n}from"../../shared/src/logger.js";import{resolveCommitlintEnabled as r}from"../../shared/src/toolchain.js";import"../../shared/src/index.js";import{parseArgsCli as i}from"./utils/args.js";import"./utils/breaking.js";import{readCommits as a}from"./utils/git.js";import{changelogFiles as o,readRootVersion as s,repoRoot as c,writeVersion as l}from"./utils/repo.js";import{packageChangesForCurrent as u}from"./utils/packages.js";import"./utils/format.js";import{insertNewEntry as d,renderChangelogEntry as f,retagChangelogs as p}from"./utils/version.js";import{formatExistingChangelogs as m,parseExistingChangelog as h,reformatRootChangelog as g}from"./utils/reformat.js";import{releaseNotesFromGit as _}from"./utils/release-notes.js";import{buildSummary as v}from"./utils/summary.js";import{deriveCustomBump as y,planVersions as b,resolveVersioning as x,writePackageVersion as S}from"./utils/versioning.js";import{writeChangelogs as C}from"./utils/write.js";import{existsSync as w,readFileSync as T,realpathSync as E,writeFileSync as D}from"node:fs";import{spawnSync as O}from"node:child_process";function k(t=process.argv.slice(2),E){let k=i(t),A=E?.groups,j=E?.breaking;if(k.releaseNotes){n.raw(_(k.releaseNotes));return}if(k.formatOnly){n.info(`[format-only] Reformatting ${o().length} changelog file(s)${k.dryRun?` (dry run)`:``}.`),m(k.dryRun,k.packageChanges,A,j);return}let M=s();if(k.version){let e=k.version.trim();if(!/^\d+\.\d+\.\d+$/.test(e))throw Error(`Invalid version: ${e}`);if(e===M){n.info(`Version is already ${e}; nothing to do.`);return}l(e),p(M,e),n.info(`Retagged versions ${M} -> ${e}.`);return}let N=M;if(k.baseVersion){if(!/^\d+\.\d+\.\d+$/.test(k.baseVersion.trim()))throw Error(`Invalid base version: ${k.baseVersion}`);N=k.baseVersion.trim()}let P=k.processingMethod,F=P===`all`,I=P!==`latest`&&P!==`all`?P:k.range,L=a(I),R=x(E),z=R.provider;if(!k.dryRun&&z===`changesets`){if(O(`npx`,[`--yes`,`changeset`,`version`],{cwd:c(),stdio:`inherit`,shell:process.platform===`win32`}).status!==0)throw Error(`changesets provider failed.`);n.info(`Ran the changesets provider; changesets owns the changelog/version output.`);return}let B=y(L,R.bump,R.allowOverBump,{env:process.env,logger:n,...j===void 0?{}:{breaking:j}}),V=r(E),H=v(L,{commitlint:V,range:I,...A?{groups:A}:{},...j===void 0?{}:{breaking:j},...R.commit?{commit:R.commit}:{}});if(z&&typeof z==`object`&&typeof z.run==`function`){let e=z.run({cwd:c(),changelog:E,records:L});typeof e==`string`&&(H=e)}else if(typeof z==`function`){let e=z({cwd:c(),changelog:E,records:L});typeof e==`string`&&(H=e)}let U=b({versioning:R,rootVersion:N,bump:B,range:I,...R.bump?{bumpRules:R.bump}:{},...R.allowOverBump?{allowOverBump:!0}:{},...j===void 0?{}:{breaking:j}}),W=U.rootVersion;if(k.dryRun){let t=c(),r=e(t,`CHANGELOG.md`),i=w(r)?T(r,`utf8`):``,a=h(i)[0]?.version,o=k.packageChanges&&a?u(a):``,s=f(W,H,/* @__PURE__ */ new Date,!0,o);n.info(`[DRY-RUN] Range: ${I}`),n.info(`[DRY-RUN] Processing method: ${P}${F?` (backward reformat)`:``}`),n.info(`[DRY-RUN] Bump: ${B} (\`${N}\` -> \`${W}\`)`),n.info(`[DRY-RUN] Versioning: ${R.enabled?R.target:`disabled`}`),n.info(`[DRY-RUN] ${L.length} commit(s) scanned. Project files untouched.`),n.info(``),n.info(`Proposed new CHANGELOG.md entry (new version only):`),n.info(``),n.raw(s),n.info(`--- end of proposed entry ---`);let l=F?g(k.packageChanges,A,j):i,p=d(l,s),m=e(t,`CHANGELOG.proposed.md`);D(m,p,`utf8`),n.info(`Wrote ${m}`)}else{for(let[e,t]of U.writes)S(e,t);C(W,I,L,H,F,k.packageChanges,U.entries,V,A,j),R.enabled?n.info(`Bumped ${N} -> ${W} (${B}) from ${L.length} commit(s).`):n.info(`Wrote changelogs for ${W} (${B}) from ${L.length} commit(s); versioning disabled.`)}}const A=k,j=t(import.meta.url);process.argv[1]&&/[\\/]run\.[cm]?[jt]s$/.test(j)&&M(process.argv[1])===j&&k();function M(e){try{return E(e)}catch{return e}}export{A as main,k as runChangelog};
|
|
@@ -19,12 +19,15 @@ export declare const HOOK_HEADER = "# Generated by @deltabox/toolchain — edit
|
|
|
19
19
|
export declare function commitMsgHook(commitlintPath?: string): string;
|
|
20
20
|
/** The default husky `commit-msg` hook body (config at the project root). */
|
|
21
21
|
export declare const COMMIT_MSG_HOOK: string;
|
|
22
|
-
/** The workflow file
|
|
22
|
+
/** The workflow file paths produced for a config. */
|
|
23
|
+
export declare function workflowFilePaths(config: ToolchainConfig): string[];
|
|
24
|
+
/** The workflow file names (basenames) produced for a config. */
|
|
23
25
|
export declare function workflowFilenames(config: ToolchainConfig): string[];
|
|
24
26
|
/**
|
|
25
|
-
* The changelog sync task: writes the GitHub workflows, the
|
|
26
|
-
* and the husky `commit-msg` hook from the loaded
|
|
27
|
-
* triggers, steps, jobs and per-workflow tokens are
|
|
27
|
+
* The CI/changelog sync task: writes the opted-in GitHub workflows, the
|
|
28
|
+
* commitlint config and the husky `commit-msg` hook from the loaded
|
|
29
|
+
* `dbx.config.*`. Branches, triggers, steps, jobs and per-workflow tokens are
|
|
30
|
+
* all taken from the config.
|
|
28
31
|
*/
|
|
29
32
|
export declare function changelogSyncTask(): SyncTask;
|
|
30
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{resolveChangelogBranches as
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{changelogSectionEnabled as t,resolveChangelogBranches as n,resolveChangelogConfig as r,resolveCommitlintEnabled as i,sectionConfig as a,sectionEnabled as o}from"../../shared/src/toolchain.js";import"../../shared/src/index.js";import{WORKFLOW_FILENAMES as s,isEnabled as c,renderCustomWorkflow as l,renderWorkflow as u,workflowFilePath as d}from"./workflows.js";import{renderCommitlintConfig as f}from"./templates.js";import p from"node:fs";function m(e,t){return e===!1?{enabled:!1}:typeof e==`string`?e:e===!0||e===void 0?{pushBranches:t}:{pushBranches:t,...e}}function h(e){let t=o(e.ci)?a(e.ci)??{}:{};return{ci:t.ci,changelog:t.changelog,release:t.release,issues:t.issues,sync:t.sync}}function g(e,t){let n={...e},r=(e,t)=>{n[e]!==void 0&&(n[e]=m(n[e],t))};return r(`ci`,t.main),r(`release`,t.main),r(`changelog`,t.dev),r(`sync`,[.../* @__PURE__ */ new Set([...t.main,...t.dev])]),n}const _="# Generated by @deltabox/toolchain — edit dbx.config.* and run `dbx sync`.",v="// Generated by @deltabox/toolchain — edit dbx.config.* and run `dbx sync`.",y="# Generated by @deltabox/toolchain — edit dbx.config.* and run `dbx sync`.";function b(e){let t=`npx --no -- commitlint --edit "$1"`;return e?`${t} --config ${e}`:t}const x=b();function S(e){return e?e.replace(/\\/g,`/`).replace(/^\.?\//,``).replace(/\/+$/,``):``}function C(e){let t=h(e),n=[];for(let[e,r]of Object.entries(s)){let i=t[e];c(i)&&n.push(d(e,i,r))}let r=o(e.ci)?a(e.ci)?.custom??{}:{};for(let[e,t]of Object.entries(r)){let r=t;c(r)&&n.push(d(e,r))}return[...new Set(n)]}function w(e){return[...new Set(C(e).map(e=>e.split(`/`).pop()??e))]}function T(){return{name:`changelog`,projectTypes:[`monorepo-root`,`project`],enabled:e=>o(e.ci),run:m=>{let x=r(m.config)??{},C=a(x.commitlint),w=t(m.config)&&i(x),T=[],E=/* @__PURE__ */ new Set,D={},O=new Set(m.managedFiles??[]),k=t=>{if(O.has(t))return!0;let n=e.resolve(m.cwd,t);if(!p.existsSync(n))return!0;try{return p.readFileSync(n,`utf-8`).replace(/^\uFEFF/,``).startsWith(_)}catch{return!1}},A=(e,t,n,r=!1)=>{if(E.has(t))m.warn(`changelog: workflow path "${t}" is declared more than once; skipping the duplicate.`);else if(k(t))E.add(t),T.push({path:t,content:n});else{let n=r?`ci.custom.${e}`:`ci.${e}`;D[t]=n,m.warn(`changelog: ${t} already exists and is not managed by dbx; leaving it untouched. Set \`${n}: { enabled: false }\` in dbx.config to keep it explicit.`,`changelog.existing-workflow`)}},j=S(C?.dir),M=j?`${j}/commitlint.config.mjs`:`commitlint.config.mjs`,N=g(h(m.config),n(x)),P={...m.tokens,commitlintConfig:M};for(let[e,t]of Object.entries(s)){let n=N[e];if(!c(n))continue;let r=typeof n==`string`,i=r?n:u(e,{tokens:P,config:typeof n==`object`?n:{},commitlint:w});i&&A(e,d(e,n,t),r?i:`${_}\n${i}`)}let F=o(m.config.ci)?a(m.config.ci)?.custom??{}:{};for(let[e,t]of Object.entries(F)){let n=t;if(!c(n))continue;let r=typeof n==`string`,i=r?n:l(e,{tokens:P,config:typeof n==`object`?n:{},commitlint:w});i&&A(e,d(e,n),r?i:`${_}\n${i}`,!0)}return w&&(T.push({path:M,content:`${v}\n${f({...C?.types?{types:C.types}:{},...C?.scopes?{scopes:C.scopes}:{}})}`}),T.push({path:`.husky/commit-msg`,content:`${y}\n${b(j?M:void 0)}\n`})),m.manifest&&(Object.keys(D).length>0?m.manifest.workflowConflicts=D:delete m.manifest.workflowConflicts),T}}}export{v as COMMITLINT_HEADER,x as COMMIT_MSG_HOOK,y as HOOK_HEADER,_ as WORKFLOW_HEADER,T as changelogSyncTask,b as commitMsgHook,C as workflowFilePaths,w as workflowFilenames};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{parseArgs as e}from"node:util";function t(t){let{values:n,positionals:r}=e({args:t,allowPositionals:!0,options:{range:{type:`string`},"dry-run":{type:`boolean`,default:!1},version:{type:`string`},"base-version":{type:`string`},"processing-method":{type:`string`},"format-only":{type:`boolean`,default:!1},"no-package-changes-section":{type:`boolean`,default:!1}}}),i=n[`processing-method`]?.trim()||process.env.CHANGELOG_PROCESSING_METHOD?.trim()||`latest`;return{range:n.range??r[0]??`HEAD`,dryRun:n[`dry-run`]??!1,version:n.version,baseVersion:n[`base-version`],processingMethod:i,formatOnly:n[`format-only`]??!1,packageChanges:!(n[`no-package-changes-section`]??!1)}}export{t as parseArgsCli};
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{parseArgs as e}from"node:util";function t(t){let{values:n,positionals:r}=e({args:t,allowPositionals:!0,options:{range:{type:`string`},"dry-run":{type:`boolean`,default:!1},version:{type:`string`},"base-version":{type:`string`},"release-notes":{type:`string`},"processing-method":{type:`string`},"format-only":{type:`boolean`,default:!1},"no-package-changes-section":{type:`boolean`,default:!1}}}),i=n[`processing-method`]?.trim()||process.env.CHANGELOG_PROCESSING_METHOD?.trim()||`latest`;return{range:n.range??r[0]??`HEAD`,dryRun:n[`dry-run`]??!1,version:n.version,baseVersion:n[`base-version`],releaseNotes:n[`release-notes`],processingMethod:i,formatOnly:n[`format-only`]??!1,packageChanges:!(n[`no-package-changes-section`]??!1)}}export{t as parseArgsCli};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import "../../../shared/src/index.js";
|
|
5
|
+
//#region packages/changelog/src/utils/breaking.d.ts
|
|
6
|
+
/** The commit fields breaking detection needs. */
|
|
7
|
+
export interface BreakingCommit {
|
|
8
|
+
subject: string;
|
|
9
|
+
body: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether a commit is breaking, using the Conventional-Commits rules by default.
|
|
13
|
+
* The `setting` lets a changelog config override the detection strategy.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isBreakingCommit(commit: BreakingCommit, setting?: ChangelogBreakingSetting): boolean;
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;const e=/^[a-zA-Z][a-zA-Z0-9]*(\([^)]*\))?!:/,t=/^BREAKING[ -]CHANGE:/m,n=/BREAKING[ -]CHANGE/i;function r(r,i){if(i===!1)return!1;if(i===void 0||i===!0||i===`conventional`)return e.test(r.subject)||t.test(r.body);if(i===`any`)return n.test(`${r.subject}\n${r.body}`);if(typeof i==`function`)return!!i({subject:r.subject,body:r.body});if(i&&typeof i==`object`){let e=`${r.subject}\n${r.body}`;if(typeof i.pattern==`string`)try{return new RegExp(i.pattern,`m`).test(e)}catch{return!1}if(typeof i.match==`string`)return e.includes(i.match)}return!1}export{r as isBreakingCommit};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogGroupsSetting } from "../../../shared/src/changelog-groups.js";
|
|
3
4
|
import { GroupedItem, GroupedRule, ParsedCommit } from "./types.js";
|
|
4
5
|
//#region packages/changelog/src/utils/format.d.ts
|
|
5
6
|
export declare function ruleTitle(type: string): string;
|
|
6
7
|
/** Parse a Conventional-Commits subject into its parts. */
|
|
7
8
|
export declare function parseCcSubject(subject: string): ParsedCommit;
|
|
8
9
|
/** Group a list of parsed commits by CC rule, then by scope. */
|
|
9
|
-
export declare function groupItems(items: GroupedItem[]): GroupedRule[];
|
|
10
|
+
export declare function groupItems(items: GroupedItem[], setting?: ChangelogGroupsSetting): GroupedRule[];
|
|
10
11
|
export declare function renderGroups(groups: GroupedRule[]): string;
|
|
11
12
|
/**
|
|
12
13
|
* Split a changelog bullet's trailing inline content (after the commit credit
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{logger as e}from"../../../shared/src/logger.js";import{sanitizeText as t}from"../../../shared/src/string-utils.js";import"../../../shared/src/index.js";import{readFileSync as n,writeFileSync as r}from"node:fs";const i={feat:`New features`,fix:`Bug fixes`,refactor:`Refactors`,docs:`Documentation`,style:`Styles`,chore:`Chores`,test:`Tests`,perf:`Performance`,build:`Build system`,ci:`CI`,revert:`Reverts`,breaking:`Breaking
|
|
2
|
-
`)}function
|
|
3
|
-
`)){let e=t(i.trim());if(!e){r.length>0&&(n.push(r),r=[]);continue}if(e.startsWith(`-`)||e.startsWith(`*`)||/^[0-9]+[.)]/.test(e)||!e.replace(/(?:close[sd]?|fixe?s|fixed|resolves?|resolved)\b\s*:?\s*#\d+\s*[,;]?\s*/gi,``).trim())continue;let a=/^(BREAKING CHANGE|Reviewed-by|Signed-off-by|Co-authored-by|Acked-by|Co-developed-by|Helped-by|Reported-by|Suggested-by|Tested-by|Cc):\s+(.+)$/i.exec(e);a&&!/^(http|https)\b/.test(e)?(r.length>0&&(n.push(r),r=[]),n.push([`**${(a[1]??``).trim()}:** ${(a[2]??``).trim()}`])):r.push(e)}return r.length>0&&n.push(r),n}function
|
|
4
|
-
`).map(e=>
|
|
5
|
-
`);o!==a&&(r(t,o,`utf8`),e.info(` formatted ${t}`))}export{
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{logger as e}from"../../../shared/src/logger.js";import{sanitizeText as t}from"../../../shared/src/string-utils.js";import"../../../shared/src/index.js";import{readFileSync as n,writeFileSync as r}from"node:fs";const i={feat:`New features`,fix:`Bug fixes`,refactor:`Refactors`,docs:`Documentation`,style:`Styles`,chore:`Chores`,test:`Tests`,perf:`Performance`,build:`Build system`,ci:`CI`,revert:`Reverts`,breaking:`Breaking Changes`},a=[`breaking`,`feat`,`fix`,`perf`,`refactor`,`docs`,`style`,`test`,`build`,`ci`,`chore`,`revert`];function o(e){return i[e]??i[e.toLowerCase()]??`Other changes`}function s(e){let t=/^([a-zA-Z][a-zA-Z0-9]*)(\(([^)]*)\))?(!)?:\s*(.*)$/.exec(e);return t?{type:t[1].toLowerCase(),scope:t[3]?.trim()||void 0,breaking:!!t[4],rest:t[5]??``}:{type:`chore`,breaking:!1,rest:e}}function c(e,t){if(typeof e==`function`){let n=e(t);return typeof n==`function`?void 0:n}return e}function l(e){if(!e)return[];if(Array.isArray(e)){let t=[];for(let[n,r]of e.entries())typeof r==`string`?t.push({type:r.toLowerCase(),index:n}):r&&typeof r==`object`&&r.type&&t.push({type:r.type.toLowerCase(),...r.title===void 0?{}:{title:r.title},...r.order===void 0?{}:{order:r.order},...r.hidden===void 0?{}:{hidden:r.hidden},index:n});return t}if(typeof e!=`object`)return[];let t=[];for(let[n,[r,i]]of Object.entries(e).entries()){let e=i===!1?{hidden:!0}:i===!0||i==null?{}:typeof i==`string`?{title:i}:i;t.push({type:r.toLowerCase(),...e.title===void 0?{}:{title:e.title},...e.order===void 0?{}:{order:e.order},...e.hidden===void 0?{}:{hidden:e.hidden},index:n})}return t}function u(e,t){if(typeof e==`function`){let n=e(t);return typeof n==`string`&&n.length>0?n:t.defaultTitle}return e??t.defaultTitle}function d(e,t,n){let r=typeof e==`function`?e(n):e;return typeof r==`number`&&Number.isFinite(r)?r:t}function f(e,t){return typeof e==`function`?!!e(t):e===!0}function p(e){let t=a.indexOf(e);return t===-1?a.length:t}function m(e,t){let n=/* @__PURE__ */ new Map;for(let t of e){let{parsed:e}=t,r=t.breaking||e.breaking?`breaking`:e.type,i=n.get(r)??{title:o(r),ungrouped:[],scopes:/* @__PURE__ */ new Map};if(e.scope){let n=i.scopes.get(e.scope)??[];n.push(t),i.scopes.set(e.scope,n)}else i.ungrouped.push(t);n.set(r,i)}let r=[...n.keys()],i={types:r,items:e},a=l(c(t,i)),s=[],m=/* @__PURE__ */ new Set,h=-1;for(let e of a){if(m.has(e.type))continue;let t=n.get(e.type);if(!t)continue;m.add(e.type);let r=[...t.ungrouped,...[...t.scopes.values()].flat()],a={...i,type:e.type,defaultTitle:o(e.type),index:e.index,groupItems:r},c=d(e.order,e.index,a);h=Math.max(h,c),!f(e.hidden,a)&&s.push({rule:{...t,title:u(e.title,a)},order:c,seq:e.index})}let g=r.filter(e=>!m.has(e)).sort((e,t)=>p(e)-p(t));for(let[e,t]of g.entries()){let r=n.get(t);s.push({rule:r,order:h+1+p(t),seq:a.length+e})}return s.sort((e,t)=>e.order-t.order||e.seq-t.seq).map(e=>e.rule)}function h(e){if(e.length===0)return`- No description provided.`;let t=[];for(let n of e){t.push(`### ${n.title}`);for(let e of n.ungrouped)t.push(e.text),t.push(...g(e.bodyParagraphs));for(let[e,r]of n.scopes){t.push(`#### ${_(e)}`);for(let e of r)t.push(e.text),t.push(...g(e.bodyParagraphs))}}return t.join(`
|
|
2
|
+
`)}function g(e){let t=[];for(let n of e){let[e,...r]=n;e&&(t.push(` - ${e}`),t.push(...r.map(e=>` ${e}`)))}return t}function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}function v(e){return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):e}function y(e){let t=e.lastIndexOf(`([#`);if(t===-1)return{main:e,inline:``};let n=e.slice(t),r=/^(\(\[#[^\]]+\]\([^)]*\) by [^)]*\)\)?)(?:\(fixes [^)]*\)\)?)?/.exec(n);if(!r)return{main:e,inline:``};let i=r[0]??``;return{main:e.slice(0,t)+i,inline:e.slice(t+i.length).trim()}}function b(e){let n=[],r=[];for(let i of e.split(`
|
|
3
|
+
`)){let e=t(i.trim());if(!e){r.length>0&&(n.push(r),r=[]);continue}if(e.startsWith(`-`)||e.startsWith(`*`)||/^[0-9]+[.)]/.test(e)||!e.replace(/(?:close[sd]?|fixe?s|fixed|resolves?|resolved)\b\s*:?\s*#\d+\s*[,;]?\s*/gi,``).trim())continue;let a=/^(BREAKING CHANGE|Reviewed-by|Signed-off-by|Co-authored-by|Acked-by|Co-developed-by|Helped-by|Reported-by|Suggested-by|Tested-by|Cc):\s+(.+)$/i.exec(e);a&&!/^(http|https)\b/.test(e)?(r.length>0&&(n.push(r),r=[]),n.push([`**${(a[1]??``).trim()}:** ${(a[2]??``).trim()}`])):r.push(e)}return r.length>0&&n.push(r),n}function x(e,t){return`https://github.com/${e}/commit/${t}`}function S(e,t){return`https://github.com/${e}/issues/${t}`}function C(e,t){return e.replace(/\[(#[0-9a-fA-F]{6,40})\]\(([^)]*)\)/g,(e,n)=>{let r=n.replace(`#`,``).slice(0,7);return`[#${r}](${x(t,r)})`}).replace(/(^|[^\w[])#([0-9a-fA-F]{7,40})(?![0-9a-fA-F])(?=[)\].,;:\s]|$)/g,(e,n,r)=>{let i=r.slice(0,7);return`${n}[#${i}](${x(t,i)})`})}function w(e,t){return e.replace(/\[#(\d+)(?=[ \]])(?:[^\]]*)\]\([^)]*\)/g,(e,n)=>`[#${n}](${S(t,n)})`).replace(/(^|[^\w[])#(\d+)(?=[)\].,;:\s]|$)/g,(e,n,r)=>`${n}[#${r}](${S(t,r)})`)}function T(e,t){if(!t)return e;let n=C(e,t);return n=w(n,t),n}function E(t,i){if(!i)return;let a=n(t,`utf8`),o=a.split(`
|
|
4
|
+
`).map(e=>T(e,i)).join(`
|
|
5
|
+
`);o!==a&&(r(t,o,`utf8`),e.info(` formatted ${t}`))}export{v as capitalize,b as formatBody,E as formatChangelogFile,T as formatLine,m as groupItems,s as parseCcSubject,h as renderGroups,o as ruleTitle,y as splitInlineDescription};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import "../../../shared/src/index.js";
|
|
3
5
|
import { BumpType, CommitRecord } from "./types.js";
|
|
4
6
|
//#region packages/changelog/src/utils/git.d.ts
|
|
5
7
|
/** Read the commits in a git range (optionally limited to path(s)), newest first. */
|
|
6
8
|
export declare function readCommits(range: string, path?: string | string[]): CommitRecord[];
|
|
7
9
|
/** Derive the semver bump from the commits (major > minor > patch). */
|
|
8
|
-
export declare function deriveBump(records: CommitRecord[]): BumpType;
|
|
10
|
+
export declare function deriveBump(records: CommitRecord[], breaking?: ChangelogBreakingSetting): BumpType;
|
|
9
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{sanitizeText as t}from"../../../shared/src/string-utils.js";import"../../../shared/src/index.js";import n from"node:fs";import{execFileSync as
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{sanitizeText as t}from"../../../shared/src/string-utils.js";import"../../../shared/src/index.js";import{isBreakingCommit as n}from"./breaking.js";import r from"node:fs";import{execFileSync as i}from"node:child_process";function a(e,n){let r=n===void 0?[]:Array.isArray(n)?n:[n],a=[`log`,`--no-merges`,`--pretty=format:%H%x1f%s%x1f%b%x1f%an%x1f%ae%x1e`,e];return r.length>0&&a.push(`--`,...r),i(`git`,a,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`pipe`]}).split(``).filter(e=>e.length>0).map(e=>{let[n,r,i,a,o]=e.split(``);return{hash:n.trim(),subject:t((r??``).trim()),body:t((i??``).trim()),author:(a??``).trim(),authorEmail:(o??``).trim()}}).filter(e=>e.subject.length>0)}function o(e){let t=e.match(/(?:github\.com[/:])([^/]+)\/([^/.]+?)(?:\.git)?$/);if(t?.[1]&&t[2])return`${t[1]}/${t[2]}`}function s(){try{let e=o(i(`git`,[`remote`,`get-url`,`origin`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim());if(e)return e}catch{}try{let t=r.readFileSync(e.join(process.cwd(),`package.json`),`utf8`),n=JSON.parse(t),i=typeof n.repository==`string`?n.repository:n.repository?.url;if(i)return o(i)}catch{}}let c;function l(){if(process.env.DBX_NO_GH)return c=!1,!1;if(c!==void 0)return c;try{i(`gh`,[`auth`,`status`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:2e3}),c=!0}catch{c=!1}return c}const u=/* @__PURE__ */ new Map;function d(e,t,n){if(!l())return;let r=`repos/${e}${t}::${n}`;if(u.has(r))return u.get(r);let a;try{let r=i(`gh`,[`api`,`repos/${e}${t}`,`--jq`,n],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3}).trim();a=r&&r!==`null`?r:void 0}catch{a=void 0}return u.set(r,a),a}function f(e){return/^(\d+)\+([^@]+)@users\.noreply\.github\.com$/.exec(e.trim())?.[2]}function p(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function m(e,t){let n;t&&(n=d(t,`/commits/${e.hash}/pulls`,`.[0].user.login`),n||=d(t,`/commits/${e.hash}`,`.author.login`)),n||=f(e.authorEmail);let r=n??e.author;return p(r)&&(r=f(r)??r.split(`@`)[0]??r),{name:r,url:n?`https://github.com/${n}`:void 0}}function h(e){return e.url?`[${e.name}](${e.url})`:e.name}function g(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:close[sd]?|fixe?s|fixed|resolves?|resolved)\b\s*:?\s*#(\d+)/gi)){let e=Number(n[1]);Number.isInteger(e)&&t.add(e)}return[...t]}function _(e,t){let n={number:t},r=d(e,`/issues/${t}`,`[.title,.html_url]`);if(r)try{let e=JSON.parse(r);n.title=e[0]||void 0,n.url=e[1]||void 0}catch{}return n}function v(e,t){let n=g(`${e.subject}\n${e.body}`);return n.length===0?[]:t?n.map(e=>_(t,e)):n.map(e=>({number:e}))}function y(e){return e.length===0?``:` (fixes ${e.map(e=>e.url&&e.title?`[#${e.number} ${e.title}](${e.url})`:e.url?`[#${e.number}](${e.url})`:`#${e.number}`).join(`, `)})`}const b=/* @__PURE__ */ new Map;function x(e,t){let n=`${e}::${t??``}`;if(b.has(n))return b.get(n);let r=e.trim(),a=(r.includes(`..`)?(r.split(`..`)[0]??``).trim():``)||(t?`${t}^`:void 0);if(!a){b.set(n,void 0);return}let o;try{o=i(`git`,[`log`,`--no-merges`,`--format=%ae%x1f%an%x1e`,a],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`],maxBuffer:134217728})}catch{b.set(n,void 0);return}let s=/* @__PURE__ */ new Set;for(let e of o.split(``)){if(!e.trim())continue;let[t=``,n=``]=e.split(``);for(let e of[t,n]){let t=e.trim().toLowerCase();t&&s.add(t)}}return b.set(n,s),s}function S(e){return/\[(#[0-9a-fA-F]{6,40})\]\([^)]*\)/.exec(e)?.[1]?.replace(`#`,``)}function C(e){try{return i(`git`,[`log`,`-1`,`--format=%aI`,e],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return}}function w(e){for(let t of[`v${e}`,e])try{let e=i(`git`,[`log`,`-1`,`--format=%aI`,t],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();if(e)return e}catch{}}function T(e,t){let n=w(e);if(n)return new Date(n);for(let e of t){let t=S(e);if(t){let e=C(t);if(e)return new Date(e)}}}let E;function D(){if(E)return E;let e=/* @__PURE__ */ new Map;try{let t=i(`git`,[`log`,`--no-merges`,`--all`,`--format=%H%x1f%s%x1f%b%x1e`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`],maxBuffer:134217728});for(let n of t.split(``)){if(!n.trim())continue;let[t=``,r=``,i=``]=n.split(``);if(!t)continue;let a={subject:r.trim(),body:i.trim()};e.set(t.trim(),a),e.set(t.trim().slice(0,7),a)}}catch{}return E=e,e}function O(e){return D().get(e)}function k(e,t){let r=`patch`;for(let i of e)n(i,t)?r=`major`:r!==`major`&&/^feat(\([^)]*\))?:/i.test(i.subject)&&(r=`minor`);return r}export{S as bulletHash,k as deriveBump,T as deriveVersionDate,O as readCommit,a as readCommits,x as readPriorAuthors,v as recordIssues,h as renderAuthor,y as renderIssues,s as repoSlug,m as resolveAuthorInfo};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import { ChangelogGroupsSetting } from "../../../shared/src/changelog-groups.js";
|
|
5
|
+
import "../../../shared/src/index.js";
|
|
3
6
|
import { ExistingEntry } from "./types.js";
|
|
4
7
|
//#region packages/changelog/src/utils/reformat.d.ts
|
|
5
8
|
/** Split a changelog into `## <version>` sections with their bullet lines. */
|
|
6
9
|
export declare function parseExistingChangelog(content: string): ExistingEntry[];
|
|
7
10
|
/** Backward-reformat an entire changelog file's content (all versions). */
|
|
8
|
-
export declare function reformatChangelogContent(content: string, repo: string | undefined, markersOnNewest?: boolean, includePackageChanges?: boolean): string;
|
|
11
|
+
export declare function reformatChangelogContent(content: string, repo: string | undefined, markersOnNewest?: boolean, includePackageChanges?: boolean, groups?: ChangelogGroupsSetting, breaking?: ChangelogBreakingSetting): string;
|
|
9
12
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{bulletHash as
|
|
2
|
-
`)){let e=/^##\s+([0-9]+\.[0-9]+\.[0-9]+)(?:\s*\(.*\))?\s*$/.exec(r);e?(n={version:e[1],bullets:[]},t.push(n)):n&&(r.includes(`<!-- release:`)||r.startsWith(`- `)&&n.bullets.push(r))}return t}function
|
|
3
|
-
`)[0]??`# Changelog`;return`${
|
|
1
|
+
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{isBreakingCommit as n}from"./breaking.js";import{bulletHash as r,deriveVersionDate as i,readCommit as a,repoSlug as o}from"./git.js";import{changelogFiles as s,repoRoot as c}from"./repo.js";import{packageChangesForVersion as l}from"./packages.js";import{capitalize as u,formatBody as d,formatLine as f,groupItems as p,parseCcSubject as m,renderGroups as h}from"./format.js";import{renderChangelogEntry as g}from"./version.js";import{existsSync as _,readFileSync as v,writeFileSync as y}from"node:fs";function b(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=/^##\s+([0-9]+\.[0-9]+\.[0-9]+)(?:\s*\(.*\))?\s*$/.exec(r);e?(n={version:e[1],bullets:[]},t.push(n)):n&&(r.includes(`<!-- release:`)||r.startsWith(`- `)&&n.bullets.push(r))}return t}function x(e){let t=e.lastIndexOf(`([#`);if(t===-1)return``;let n=e.slice(t);return/^(\(\[#[^\]]+\]\([^)]*\) by [^)]*\)\)?)(?:\(fixes [^)]*\)\)?)?/.exec(n)?.[0]??``}function S(e,t,o=!1,s=``,c,l){let _=[];for(let i of e.bullets){let e=i.replace(/^-\s+/,``),o=r(i),s=o?a(o):void 0,c=s?.subject??e.replace(/\*\*/g,``),p=m(c),h=x(e),g=`- ${[f(u(p.rest),t),h].filter(Boolean).join(` `)}`,v=s?d(s.body):[],y=n({subject:c,body:s?.body??``},l);_.push({parsed:p,breaking:y,text:g,bodyParagraphs:v})}let v=i(e.version,e.bullets);return g(e.version,h(p(_,c)),v,o,s)}function C(e,t,n=!1,r=!1,i,a){let o=b(e);if(o.length===0)return e;let s=e.split(`
|
|
3
|
+
`)[0]??`# Changelog`;return`${s.startsWith(`# `)?s:`# Changelog`}\n\n${o.map((e,s)=>{let c=o[s+1],u=r&&c?l(e.version,c.version):``;return S(e,t,n&&s===0,u,i,a)}).filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
`)}\n`}function
|
|
6
|
+
`)}\n`}function w(t=!1,n,r){let i=c(),a=e(i,`CHANGELOG.md`);return _(a)?C(v(a,`utf8`),o(),!1,t,n,r):``}function T(n,r=!1,i,a){let l=e(c(),`CHANGELOG.md`);for(let e of s()){let s=C(v(e,`utf8`),o(),!0,r&&e===l,i,a);if(n){let n=e.replace(/CHANGELOG\.md$/,`CHANGELOG.proposed.md`);y(n,s,`utf8`),t.info(`[DRY-RUN] Wrote ${n}`)}else y(e,s,`utf8`),t.info(` formatted ${e}`)}}export{T as formatExistingChangelogs,b as parseExistingChangelog,C as reformatChangelogContent,w as reformatRootChangelog};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/changelog/src/utils/release-notes.d.ts
|
|
4
|
+
/** Normalize a tag to its semver version (`v1.2.3`, `@scope/pkg@1.2.3` -> `1.2.3`). */
|
|
5
|
+
export declare function normalizeReleaseVersion(tag: string): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Build the release body from a changelog and its candidate tag versions.
|
|
8
|
+
*
|
|
9
|
+
* - Finds the newest tag version that exists in the changelog (excluding the
|
|
10
|
+
* version being released) and returns everything above it.
|
|
11
|
+
* - If there is no prior released version (first release), returns only the
|
|
12
|
+
* newest changelog entry instead of the entire file.
|
|
13
|
+
* - Returns '' when the changelog has no version headings.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildReleaseNotes(changelog: string, tagVersions: string[], currentVersion?: string): string;
|
|
16
|
+
/** Read the release body from the repo's changelog + tags (with a first-release guard). */
|
|
17
|
+
export declare function releaseNotesFromGit(currentVersion: string, cwd?: string): string;
|
|
18
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{repoRoot as t}from"./repo.js";import{existsSync as n,readFileSync as r}from"node:fs";import{spawnSync as i}from"node:child_process";function a(e){return/(?:^|@)v?(\d+\.\d+\.\d+)$/.exec(e.trim())?.[1]}function o(e){let t=[];for(let n of e.matchAll(/^##\s+(\d+\.\d+\.\d+)(?:\s|$)/gm))n.index!==void 0&&t.push({version:n[1],index:n.index});return t}function s(e,t,n){let r=o(e);if(r.length===0)return``;let i=r[0].index,s=new Set(t.map(a).filter(e=>e!==void 0)),c=r.find(e=>e.version!==n&&s.has(e.version)),l=c?c.index:r[1]?.index??e.length;return l<=i?``:e.slice(i,l).trimEnd()}function c(a,o=t()){let c=e(o,`CHANGELOG.md`),l=``;if(n(c))try{l=r(c,`utf8`).replace(/^\uFEFF/,``)}catch{l=``}let u=(i(`git`,[`tag`,`--merged`,`HEAD`,`--sort=-v:refname`],{cwd:o,encoding:`utf8`}).stdout??``).split(/\r?\n/).filter(Boolean);return s(l,u,a)||`Release ${a}`}export{s as buildReleaseNotes,a as normalizeReleaseVersion,c as releaseNotesFromGit};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import {
|
|
3
|
+
import { ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import { ChangelogGroupsSetting } from "../../../shared/src/changelog-groups.js";
|
|
5
|
+
import "../../../shared/src/index.js";
|
|
6
|
+
import { CommitFormatOptions, CommitRecord } from "./types.js";
|
|
4
7
|
//#region packages/changelog/src/utils/summary.d.ts
|
|
5
8
|
/**
|
|
6
9
|
* Render a commit reference for a changelog bullet. With a resolvable repo slug
|
|
@@ -9,6 +12,30 @@ import { CommitRecord } from "./types.js";
|
|
|
9
12
|
* short hash rather than a broken `github.com/undefined/...` link.
|
|
10
13
|
*/
|
|
11
14
|
export declare function renderCommitRef(repo: string | undefined, hash: string): string;
|
|
15
|
+
export interface BuildSummaryOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Use the Conventional-Commits grouping (default true). When commitlint is
|
|
18
|
+
* disabled, commits are hoisted into coarse Major/Minor/Patch buckets
|
|
19
|
+
* instead, so a non-CC history still produces a readable changelog.
|
|
20
|
+
*/
|
|
21
|
+
commitlint?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The scanned git range. Used to detect first-time contributors by looking
|
|
24
|
+
* for their authors before the range starts.
|
|
25
|
+
*/
|
|
26
|
+
range?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Explicit prior-contributor keys (author name/email), for tests or callers
|
|
29
|
+
* that already know the history. When omitted, the range is inspected.
|
|
30
|
+
*/
|
|
31
|
+
priorAuthors?: Iterable<string>;
|
|
32
|
+
/** Commit line formatting/credit options. */
|
|
33
|
+
commit?: CommitFormatOptions;
|
|
34
|
+
/** Conventional-Commits group order/titles/hiding. */
|
|
35
|
+
groups?: ChangelogGroupsSetting;
|
|
36
|
+
/** How breaking changes are detected (default: Conventional Commits). */
|
|
37
|
+
breaking?: ChangelogBreakingSetting;
|
|
38
|
+
}
|
|
12
39
|
/** Render the grouped changelog summary for a set of commits. */
|
|
13
|
-
export declare function buildSummary(records: CommitRecord[]): string;
|
|
40
|
+
export declare function buildSummary(records: CommitRecord[], options?: BuildSummaryOptions): string;
|
|
14
41
|
//#endregion
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{isBreakingCommit as e}from"./breaking.js";import{readPriorAuthors as t,recordIssues as n,renderAuthor as r,renderIssues as i,repoSlug as a,resolveAuthorInfo as o}from"./git.js";import{capitalize as s,formatBody as c,groupItems as l,parseCcSubject as u,renderGroups as d}from"./format.js";function f(e,t){let n=t.slice(0,7);return e?`[#${n}](https://github.com/${e}/commit/${t})`:`#${n}`}const p=[`major`,`minor`,`patch`],m={major:`Major changes`,minor:`Minor changes`,patch:`Patch changes`};function h(t,n){let r=u(t.subject);return e(t,n)?`major`:r.type===`feat`?`minor`:`patch`}function g(t,a,l={}){let d=u(t.subject),p=o(t,a),m=n(t,a),h;if(l.format)h=`- ${l.format({commit:t,repo:a,author:p,issues:m,options:l})}`;else{let e=[];if(l.commitSha!==!1&&e.push(f(a,t.hash)),l.author!==!1){let t=l.authorAvatar&&p.url?` `:``;e.push(`by ${t}${r(p)}`)}let n=e.length>0?` (${e.join(` `)})`:``,o=l.issues===!1?``:i(m);h=`- ${s(d.rest)}${n}${o}`}return{parsed:d,breaking:e(t,l.breaking),text:h,bodyParagraphs:l.body===!1?[]:c(t.body)}}function _(e){let t=[e.text];for(let n of e.bodyParagraphs){let[e,...r]=n;e&&(t.push(` - ${e}`),t.push(...r.map(e=>` ${e}`)))}return t}function v(e,t,n){let r=a(),i=/* @__PURE__ */ new Map;for(let a of e){let e=h(a,n),o=i.get(e)??[];o.push(g(a,r,{...t,breaking:n})),i.set(e,o)}if(i.size===0)return`- No description provided.`;let o=[];for(let e of p){let t=i.get(e);if(t&&t.length!==0){o.push(`### ${m[e]}`);for(let e of t)o.push(..._(e))}}return o.join(`
|
|
2
|
+
`)}function y(e){return e.trim().toLowerCase()}function b(e){return[e.authorEmail,e.author].map(y).filter(e=>e.length>0)}function x(e,n,r){let i;if(r.priorAuthors!==void 0)i=new Set([...r.priorAuthors].map(y));else if(r.range){let n=e[e.length-1]?.hash;i=t(r.range,n)}if(!i)return[];let a=/* @__PURE__ */ new Map;for(let t of e){let e=b(t);if(e.length===0||e.some(e=>i.has(e)))continue;let r=e[0],s=a.get(r);s?s.commits.push(t):a.set(r,{key:r,author:o(t,n),commits:[t]})}return[...a.values()].sort((e,t)=>e.author.name.localeCompare(t.author.name))}function S(e,t,n){let i=x(e,t,n);if(i.length===0)return``;let a=[`### New contributors`];for(let e of i){a.push(`- ${r(e.author)}`);for(let n of e.commits)a.push(..._(g(n,t,{author:!1,body:!1})).map(e=>` ${e}`))}return a.join(`
|
|
3
|
+
`)}function C(e,t={}){let n=a(),r=t.commitlint===!1?v(e,t.commit,t.breaking):d(l(e.map(e=>g(e,n,{...t.commit,...t.breaking===void 0?{}:{breaking:t.breaking}})),t.groups)),i=S(e,n,t);return i?`${r}\n\n${i}`:r}export{C as buildSummary,f as renderCommitRef};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ChangelogBreakingCommit, ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import { ChangelogGroupConfig, ChangelogGroupContext, ChangelogGroupEntry, ChangelogGroupHidden, ChangelogGroupItem, ChangelogGroupOrder, ChangelogGroupTitle, ChangelogGroupsContext, ChangelogGroupsSetting } from "../../../shared/src/changelog-groups.js";
|
|
5
|
+
import "../../../shared/src/index.js";
|
|
3
6
|
//#region packages/changelog/src/utils/types.d.ts
|
|
4
|
-
/** Shared types for the changelog pipeline. */
|
|
5
7
|
export type BumpType = 'major' | 'minor' | 'patch';
|
|
6
8
|
export type ProcessingMethod = 'latest' | 'all' | string;
|
|
7
9
|
export interface CommitRecord {
|
|
@@ -25,6 +27,8 @@ export interface CliOptions {
|
|
|
25
27
|
dryRun: boolean;
|
|
26
28
|
version?: string;
|
|
27
29
|
baseVersion?: string;
|
|
30
|
+
/** Print the release body for this version (and exit). */
|
|
31
|
+
releaseNotes?: string;
|
|
28
32
|
processingMethod: ProcessingMethod;
|
|
29
33
|
formatOnly: boolean;
|
|
30
34
|
/** Include the `### Package changes` footer (disable with --no-package-changes-section). */
|
|
@@ -46,13 +50,46 @@ export interface GroupedRule {
|
|
|
46
50
|
}
|
|
47
51
|
export interface GroupedItem {
|
|
48
52
|
parsed: ParsedCommit;
|
|
53
|
+
/** Whether this commit is breaking (subject `!` or a BREAKING CHANGE footer). */
|
|
54
|
+
breaking?: boolean;
|
|
49
55
|
text: string;
|
|
50
56
|
/** Description paragraphs; each becomes one nested bullet with wrapped continuations. */
|
|
51
57
|
bodyParagraphs: string[][];
|
|
52
58
|
}
|
|
59
|
+
/** Options for rendering a commit bullet/credit line. */
|
|
60
|
+
export interface CommitFormatOptions {
|
|
61
|
+
/** Include the `by <author>` credit (default true). */
|
|
62
|
+
author?: boolean;
|
|
63
|
+
/** Include the commit hash link (default true). */
|
|
64
|
+
commitSha?: boolean;
|
|
65
|
+
/** Include issue/fixes links (default true). */
|
|
66
|
+
issues?: boolean;
|
|
67
|
+
/** Prefix the author with their GitHub avatar (default false). */
|
|
68
|
+
authorAvatar?: boolean;
|
|
69
|
+
/** Fully custom commit line formatter. */
|
|
70
|
+
format?: (ctx: CommitFormatContext) => string;
|
|
71
|
+
}
|
|
72
|
+
export interface CommitFormatContext {
|
|
73
|
+
commit: CommitRecord;
|
|
74
|
+
repo?: string;
|
|
75
|
+
author: AuthorInfo;
|
|
76
|
+
issues: IssueInfo[];
|
|
77
|
+
options: CommitFormatOptions;
|
|
78
|
+
}
|
|
79
|
+
/** A custom changelog provider. */
|
|
80
|
+
export interface ChangelogProviderContext {
|
|
81
|
+
cwd: string;
|
|
82
|
+
changelog?: unknown;
|
|
83
|
+
records: CommitRecord[];
|
|
84
|
+
}
|
|
85
|
+
export interface ChangelogProvider {
|
|
86
|
+
id: string;
|
|
87
|
+
run: (ctx: ChangelogProviderContext) => string | void;
|
|
88
|
+
}
|
|
53
89
|
/** A `## <version>` section parsed out of an existing changelog. */
|
|
54
90
|
export interface ExistingEntry {
|
|
55
91
|
version: string;
|
|
56
92
|
bullets: string[];
|
|
57
93
|
}
|
|
58
|
-
//#endregion
|
|
94
|
+
//#endregion
|
|
95
|
+
export type { ChangelogBreakingCommit, ChangelogBreakingSetting, ChangelogGroupConfig, ChangelogGroupContext, ChangelogGroupEntry, ChangelogGroupHidden, ChangelogGroupItem, ChangelogGroupOrder, ChangelogGroupTitle, ChangelogGroupsContext, ChangelogGroupsSetting };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import "./types.js";
|
|
3
4
|
//#region packages/changelog/src/utils/version.d.ts
|
|
4
5
|
/** Render a `## <version> (Month Year)` heading + summary, optionally marked. */
|
|
5
6
|
export declare function renderChangelogEntry(version: string, summary: string, date?: Date, withMarkers?: boolean, packageChanges?: string): string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import {
|
|
3
|
+
import { ChangelogBreakingSetting } from "../../../shared/src/changelog-breaking.js";
|
|
4
|
+
import { logger } from "../../../shared/src/logger.js";
|
|
5
|
+
import { ChangelogConfig } from "../../../shared/src/config-types.js";
|
|
4
6
|
import "../../../shared/src/index.js";
|
|
5
7
|
import { BumpType, CommitRecord } from "./types.js";
|
|
6
8
|
//#region packages/changelog/src/utils/versioning.d.ts
|
|
7
9
|
/** How/where a changelog run applies its version bump. */
|
|
8
10
|
export type VersioningTarget = 'uniform' | 'root-only' | 'individual';
|
|
9
|
-
/** The normalized `changelog.versioning` config. */
|
|
11
|
+
/** The normalized `ci.changelog.versioning` config. */
|
|
10
12
|
export interface ResolvedVersioning {
|
|
11
13
|
/** Whether versions are written to `package.json` at all. */
|
|
12
14
|
enabled: boolean;
|
|
@@ -14,13 +16,21 @@ export interface ResolvedVersioning {
|
|
|
14
16
|
target: VersioningTarget;
|
|
15
17
|
/** Explicit workspace globs (when configured). */
|
|
16
18
|
workspaces?: string[];
|
|
19
|
+
/** Custom bump rules keyed by version index. */
|
|
20
|
+
bump?: Record<string, unknown>;
|
|
21
|
+
/** Apply a bump per matching change instead of once. */
|
|
22
|
+
allowOverBump?: boolean;
|
|
23
|
+
/** Changelog provider id, callback, or custom provider object. */
|
|
24
|
+
provider?: unknown;
|
|
25
|
+
/** Commit formatting options. */
|
|
26
|
+
commit?: unknown;
|
|
17
27
|
}
|
|
18
28
|
/**
|
|
19
|
-
* Normalize the `changelog.versioning` union (`boolean | { target, workspaces }`)
|
|
29
|
+
* Normalize the `ci.changelog.versioning` union (`boolean | { target, workspaces }`)
|
|
20
30
|
* into a concrete plan input. `true`/absent means uniform with defaults; `false`
|
|
21
31
|
* disables writing versions while still generating changelog entries.
|
|
22
32
|
*/
|
|
23
|
-
export declare function resolveVersioning(changelog?:
|
|
33
|
+
export declare function resolveVersioning(changelog?: ChangelogConfig): ResolvedVersioning;
|
|
24
34
|
/** The packages a changelog run versions. */
|
|
25
35
|
export interface VersionPackages {
|
|
26
36
|
/** The repository root. */
|
|
@@ -41,6 +51,16 @@ export declare function writePackageVersion(dir: string, version: string): void;
|
|
|
41
51
|
* workspace is found, so a broken checkout can't wedge a release.
|
|
42
52
|
*/
|
|
43
53
|
export declare function discoverVersionPackages(workspaces?: string[], root?: string): VersionPackages;
|
|
54
|
+
/** Context handed to custom bump callbacks. */
|
|
55
|
+
export interface BumpRuleContext {
|
|
56
|
+
env: NodeJS.ProcessEnv;
|
|
57
|
+
logger: typeof logger;
|
|
58
|
+
packageJson?: Record<string, unknown>;
|
|
59
|
+
/** How breaking changes are detected (default: Conventional Commits). */
|
|
60
|
+
breaking?: ChangelogBreakingSetting;
|
|
61
|
+
}
|
|
62
|
+
/** Resolve a bump from custom rules, falling back to Conventional Commits. */
|
|
63
|
+
export declare function deriveCustomBump(records: CommitRecord[], rules?: Record<string, unknown>, allowOverBump?: boolean, context?: BumpRuleContext): BumpType;
|
|
44
64
|
/** The version bump plan for a changelog run. */
|
|
45
65
|
export interface VersionPlan {
|
|
46
66
|
/** The version heading for the root changelog. */
|
|
@@ -56,6 +76,12 @@ export interface PlanVersionsOptions {
|
|
|
56
76
|
rootVersion: string;
|
|
57
77
|
/** The bump derived from all scanned commits. */
|
|
58
78
|
bump: BumpType;
|
|
79
|
+
/** Custom bump rules (used for per-workspace derivation). */
|
|
80
|
+
bumpRules?: Record<string, unknown>;
|
|
81
|
+
/** Allow over-bumping (default false). */
|
|
82
|
+
allowOverBump?: boolean;
|
|
83
|
+
/** How breaking changes are detected (default: Conventional Commits). */
|
|
84
|
+
breaking?: ChangelogBreakingSetting;
|
|
59
85
|
/** The git revision range the commits were read from. */
|
|
60
86
|
range: string;
|
|
61
87
|
/** The repository root (default: resolved from cwd). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{deriveBump as
|
|
1
|
+
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{isBreakingCommit as n}from"./breaking.js";import{deriveBump as r,readCommits as i}from"./git.js";import{repoRoot as a}from"./repo.js";import{parseCcSubject as o}from"./format.js";import{bumpVersion as s}from"./version.js";import{relatedWorkspacePaths as c}from"./graph.js";import{existsSync as l,globSync as u,readFileSync as d,writeFileSync as f}from"node:fs";function p(e){let t=e?.versioning;return t===!1?{enabled:!1,target:`uniform`}:t===void 0||t===!0?{enabled:!0,target:`uniform`}:{enabled:!0,target:t.target??`uniform`,...t.workspaces?{workspaces:t.workspaces}:{},...t.bump?{bump:t.bump}:{},...t.allowOverBump?{allowOverBump:!0}:{},...t.provider?{provider:t.provider}:{},...t.commit?{commit:t.commit}:{}}}function m(t){try{let n=JSON.parse(d(e(t,`package.json`),`utf8`));return typeof n.version==`string`?n.version:void 0}catch{return}}function h(n,r){let i=e(n,`package.json`),a=d(i,`utf8`),o=a.replace(/("version"\s*:\s*)"[^"]*"/,`$1"${r}"`);o!==a&&(f(i,o,`utf8`),t.info(` bumped ${i}`))}function g(n,r=a()){let i=l(e(r,`package.json`)),o=n;if(o===void 0&&i)try{let t=JSON.parse(d(e(r,`package.json`),`utf8`)).workspaces;o=Array.isArray(t)?t.filter(e=>typeof e==`string`):t&&typeof t==`object`&&Array.isArray(t.packages)?t.packages.filter(e=>typeof e==`string`):void 0}catch{o=void 0}let s=/* @__PURE__ */ new Set;for(let t of o??[])if(t===`.`)s.add(r);else for(let n of u(t,{cwd:r})){let t=e(r,n);l(e(t,`package.json`))&&s.add(t)}return s.delete(r),!i&&s.size===0&&t.warn(`[changelog] versioning: no root package.json and no matching workspaces — nothing to version.`),{root:r,rootHasPackage:i,workspaces:[...s]}}function _(e,t,r){if(e===!0)return!0;if(e===!1||e==null)return!1;if(typeof e==`string`){if(e.startsWith(`/`)&&e.lastIndexOf(`/`)>0){let n=e.lastIndexOf(`/`);try{return new RegExp(e.slice(1,n),e.slice(n+1)).test(`${t.subject}\n${t.body}`)}catch{return!1}}return`${t.subject}\n${t.body}`.includes(e)}if(Array.isArray(e))return e.some(e=>_(e,t,r));if(typeof e==`function`)return!!e({...r,commit:t});if(typeof e==`object`){let i=e,a=o(t.subject);return!(i.breaking===!0&&!n(t,r.breaking)||typeof i.type==`string`&&a.type!==i.type||Array.isArray(i.types)&&!i.types.includes(a.type)||typeof i.scope==`string`&&a.scope!==i.scope||Array.isArray(i.scopes)&&!i.scopes.includes(a.scope)||typeof i.pattern==`string`&&!new RegExp(i.pattern).test(`${t.subject}\n${t.body}`)||typeof i.match==`string`&&!`${t.subject}\n${t.body}`.includes(i.match))}return!1}const v=[`patch`,`minor`,`major`];function y(e,n,i=!1,a={env:process.env,logger:t}){if(!n||Object.keys(n).length===0)return r(e,a.breaking);let o=`patch`,s=0;for(let t of v){let r=n[t];for(let n of e)(typeof r==`function`?(()=>{let e=r({...a,commit:n,level:t});return typeof e==`string`?e===t:!!e})():_(r,n,a))&&(s+=1,v.indexOf(t)>v.indexOf(o)&&(o=t))}if(i&&s>1)for(let e=1;e<s&&o!==`major`;e+=1)o=o===`patch`?`minor`:`major`;return o}function b(e){let{versioning:n,bump:r,range:o}=e,l=e.root??a(),{rootHasPackage:u,workspaces:d}=g(n.workspaces,l),f=e.commitsFor??(e=>i(o,c(e,l))),p=s(e.rootVersion,r),h=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Map,v=n.enabled?n.target:`uniform`;if(u&&n.enabled&&h.set(l,p),v===`individual`)for(let r of d){let i=f(r);if(i.length===0)continue;let a=s(m(r)??`0.0.0`,y(i,e.bumpRules,e.allowOverBump,{env:process.env,logger:t,...e.breaking===void 0?{}:{breaking:e.breaking}}));_.set(r,a),n.enabled&&h.set(r,a)}else if(v===`uniform`)for(let e of d)_.set(e,p),n.enabled&&h.set(e,p);return{rootVersion:p,writes:h,entries:_}}export{y as deriveCustomBump,g as discoverVersionPackages,b as planVersions,m as readPackageVersion,p as resolveVersioning,h as writePackageVersion};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{readCommits as n,repoSlug as r}from"./git.js";import{discoverWorkspaceDirs as i,repoRoot as a}from"./repo.js";import{packageChangesForCurrent as o}from"./packages.js";import{formatChangelogFile as s}from"./format.js";import{prependChangelogEntry as c,renderChangelogEntry as l}from"./version.js";import{parseExistingChangelog as u,reformatRootChangelog as d}from"./reformat.js";import{buildSummary as f}from"./summary.js";import{relatedWorkspacePaths as p}from"./graph.js";import{existsSync as m,readFileSync as h,writeFileSync as g}from"node:fs";function _(_,v,y,b,x,S=!1,C){let
|
|
1
|
+
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{readCommits as n,repoSlug as r}from"./git.js";import{discoverWorkspaceDirs as i,repoRoot as a}from"./repo.js";import{packageChangesForCurrent as o}from"./packages.js";import{formatChangelogFile as s}from"./format.js";import{prependChangelogEntry as c,renderChangelogEntry as l}from"./version.js";import{parseExistingChangelog as u,reformatRootChangelog as d}from"./reformat.js";import{buildSummary as f}from"./summary.js";import{relatedWorkspacePaths as p}from"./graph.js";import{existsSync as m,readFileSync as h,writeFileSync as g}from"node:fs";function _(_,v,y,b,x,S=!1,C,w=!0,T,E){let D=a(),O=r(),k=e(D,`CHANGELOG.md`),A=``;if(S&&m(k)){let e=u(h(k,`utf8`))[0];e&&(A=o(e.version))}if(x){let e=d(S,T,E);e&&(g(k,e,`utf8`),t.info(` reformatted ${k}`))}let j=l(_,b,/* @__PURE__ */ new Date,!0,A);c(k,j),t.info(` updated ${k}`);let M=C??new Map(i().filter(t=>e(t)!==e(D)).map(e=>[e,_]));for(let[r,i]of M){let a=e(r,`CHANGELOG.md`),o=n(v,p(r,D));if(o.length===0){t.info(` skipped ${a} (no related commits)`);continue}let s=!m(a),u=f(o,{commitlint:w,range:v,...T?{groups:T}:{},...E===void 0?{}:{breaking:E}});c(a,l(i,u,/* @__PURE__ */ new Date)),t.info(` ${s?`created`:`updated`} ${a}`)}let N=/* @__PURE__ */ new Set([...i(),...M.keys()]);for(let t of N){let n=e(t,`CHANGELOG.md`);m(n)&&s(n,O)}}export{_ as writeChangelogs};
|