/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { VersionBumpType } from "@fluid-tools/version-tools"; import type { Logger } from "@fluidframework/build-tools"; import type { ReleaseNotesSectionName } from "../config.js"; import type { ReleasePackage } from "../releaseGroups.js"; export declare const DEFAULT_CHANGESET_PATH = ".changeset"; /** * The section name used for changesets that do not match any defined sections. */ export declare const UNKNOWN_SECTION = "_unknown"; /** * Additional metadata that can be used inside a changeset. This metadata should be set in a second front matter * section. * @example * * ```markdown * --- * "package-a": minor * --- * --- * section: fix * --- * * Changeset summary. * * Changeset details * ``` */ export interface FluidCustomChangesetMetadata { /** * The section in release notes in which this changeset should be included. If a value is not provided, the changeset * is considered part of the "unknown section". */ section?: ReleaseNotesSectionName; /** * If false, the changeset will not be included in release notes. * * @defaultValue `true` */ includeInReleaseNotes?: boolean; /** * If true, the changeset will be ordered before the other changes in that section. If multiple changesets are * highlighted they will be internally sorted by date. * * @defaultValue `false` */ highlight?: boolean; } /** * A utility type that makes all the keys in a type required, but allows those keys to be set to undefined explicitly. * This is useful when creating objects that are the "default values" for an interface. If you want to ensure there are * explicit defaults for every value in the interface, this type ensures that at compile time. */ type RequiredKeysAllowUndefined = { [K in keyof T]: T[K] | undefined; }; /** * Default values used when additional changeset metadata is omitted. */ export declare const fluidCustomChangeSetMetadataDefaults: RequiredKeysAllowUndefined>; /** * A type representing a changeset file's contents. */ export interface Changeset { /** * The first section of front matter in the changeset, which is a mapping of package names to release types. */ metadata: { [pkg: string]: VersionBumpType; }; /** * The main package for the changeset is the first one listed in the front matter. */ mainPackage: ReleasePackage; /** * An array of all the release types (patch, minor, major) contained in the front matter. */ changeTypes: VersionBumpType[]; /** * The first markdown paragraph of the changeset is considered the summary. */ summary: string; /** * The body of the changeset after processing. Front matter sections are removed and white space is trimmed from the * beginning and end of the string. Note that the first markdown paragraph of the changeset is not considered * part of the body; it's the summary. */ body: string; /** * The git commit that added the changeset. For uncommitted changesets some commit data may be undefined. */ commit: GitCommit; /** * Additional Fluid-specific metadata that can be added to a changeset in a secondary front matter section. This is * undefined if no second front matter section was present. */ additionalMetadata?: FluidCustomChangesetMetadata; /** * The absolute path to the source file for this changeset. */ sourceFile: string; } /** * A git commit associated with a changeset. If the changeset is not committed (i.e. it's being added in the current * changes) then some values will be undefined. */ interface GitCommit { /** * The full SHA for the commit. This will be undefined for uncommitted changesets. */ sha?: string; /** * The date that the commit was made. This is not nullable because uncommitted changesets still need to be sortable by * commit date, so this value will default to `Date.now()` in ISO format for uncommitted changesets. */ date: Date; /** * The GitHub pull request number parsed from the commit data. This will be undefined if the parsing did not find a * PR. */ githubPullRequest?: string; } /** * A ChangesetEntry is an object containing flattened content and file metadata from a changesets file. Changeset files * themselves include a mapping of package to version bump type. This object includes the change type and a single * package, effectively flattening the changesets. */ export type ChangesetEntry = Omit & { /** * The name of the package this ChangesetEntry applies to. */ pkg: string; /** * This will be true if the package in this ChangesetEntry is the main package for the changeset. */ isMainPackage: boolean; /** * The type of release this changeset represents. */ changeType: VersionBumpType; /** * The original full changeset that was the source for this ChangesetEntry. */ fullChangeset: Readonly; }; /** * Removes any custom metadata from all changesets and writes the resulting changes back to the source files. This * metadata needs to be removed prior to running `changeset version` from the \@changesets/cli package. If it is not, * then the custom metadata is interpreted as change metadata and the changeset tools fail. * * For more information about the custom metadata we use in our changesets, see * https://github.com/microsoft/FluidFramework/wiki/Changesets#custom-metadata * * **Note that this is a lossy action!** The metadata is completely removed. Changesets are typically in source * control so changes can usually be reverted. * * @param releaseGroupRootDir - The root of the release group whose changesets are to be canonicalized. * @param logger - An optional logger. * * @returns The version bump represented by the changesets. */ export declare function canonicalizeChangesets(releaseGroupRootDir: string, logger?: Logger): Promise; /** * Loads changeset files into an array of {@link Changeset}s. * * @param dir - The directory containing changesets. * @param log - An optional logger. * @returns An array containing the changesets. */ export declare function loadChangesets(dir: string, log?: Logger): Promise; /** * Creates a map of package names to an array of all the changesets that apply to the package. The entries are sorted * oldest-to-newest (that is, index 0 is the earliest changeset, and the last changeset in the array is the newest). * * @param changesets - An array of changesets to be grouped. * @returns a Map of package names to an array of all the changesets that apply to the package. */ export declare function groupByPackage(changesets: Changeset[]): Map; /** * Creates a map of package names to an array of all the changesets that apply to the package. Only the "main" package * is considered. The returned array of changesets is sorted oldest-to-newest (that is, index 0 is the earliest * changeset, and the last changeset in the array is the newest). * * @param changesets - An array of changesets to be grouped. * @returns a Map of package names to an array of all the changesets that apply to the package. */ export declare function groupByMainPackage(changesets: Changeset[]): ReadonlyMap; /** * Creates a map of section names to an array of all the changesets that belong in that section. * * The returned array of changesets are sorted oldest-to-newest (that is, index 0 is the earliest changeset, and the * last changeset in the array is the newest). * * Any changesets that do not belong to a section will be in the {@link UNKNOWN_SECTION} (`_unknown`) key in the * returned map, so callers should check the contents of that key to ensure all changesets were mapped to sections as * expected. * * Note that this groups by the section values in the changesets. Callers are expected to validate tha section names or * adjust them depending on their needs. This function does not adjust section names _except_ for those with no * specified section. * * @param changesets - An array of changesets to be grouped. * @returns a Map of section names to an array of all the changesets that apply to that section. */ export declare function groupBySection(changesets: Changeset[]): ReadonlyMap; /** * Given an array of changesets, flattens the changesets into an array of {@link ChangesetEntry} objects. * * Changesets themselves include a mapping of package to release type. This function returns an array with an entry * per-package-changeset, effectively flattening the changesets. */ export declare function flattenChangesets(changesets: readonly Changeset[]): readonly ChangesetEntry[]; export {}; //# sourceMappingURL=changesets.d.ts.map