MCPcopy Index your code
hub / github.com/changesets/changesets / createChangeset

Function createChangeset

packages/cli/src/commands/add/createChangeset.ts:109–284  ·  view source on GitHub ↗
(
  changedPackages: Array<string>,
  allPackages: Package[],
  messageFromCli?: string
)

Source from the content-addressed store, hash-verified

107}
108
109export default async function createChangeset(
110 changedPackages: Array<string>,
111 allPackages: Package[],
112 messageFromCli?: string
113): Promise<{ confirmed: boolean; summary: string; releases: Array<Release> }> {
114 const releases: Array<Release> = [];
115
116 if (allPackages.length > 1) {
117 const packagesToRelease = await getPackagesToRelease(
118 changedPackages,
119 allPackages
120 );
121
122 let pkgJsonsByName = getPkgJsonsByName(allPackages);
123
124 let pkgsLeftToGetBumpTypeFor = new Set(packagesToRelease);
125
126 let pkgsThatShouldBeMajorBumped = (
127 await cli.askCheckboxPlus(
128 bold(`Which packages should have a ${red("major")} bump?`),
129 [
130 {
131 name: "all packages",
132 choices: packagesToRelease.map((pkgName) => {
133 return {
134 name: pkgName,
135 message: formatPkgNameAndVersion(
136 pkgName,
137 pkgJsonsByName.get(pkgName)!.version
138 ),
139 };
140 }),
141 },
142 ],
143 (x) => {
144 // this removes changed packages and unchanged packages from the list
145 // of packages shown after selection
146 if (Array.isArray(x)) {
147 return x
148 .filter((x) => x !== "all packages")
149 .map((x) => cyan(x))
150 .join(", ");
151 }
152 return x;
153 }
154 )
155 ).filter((x) => x !== "all packages");
156
157 for (const pkgName of pkgsThatShouldBeMajorBumped) {
158 // for packages that are under v1, we want to make sure major releases are intended,
159 // as some repo-wide sweeping changes have mistakenly release first majors
160 // of packages.
161 let pkgJson = pkgJsonsByName.get(pkgName)!;
162
163 let shouldReleaseFirstMajor = await confirmMajorRelease(pkgJson);
164 if (shouldReleaseFirstMajor) {
165 pkgsLeftToGetBumpTypeFor.delete(pkgName);
166

Callers 1

addFunction · 0.85

Calls 5

logFunction · 0.90
getPackagesToReleaseFunction · 0.85
getPkgJsonsByNameFunction · 0.85
formatPkgNameAndVersionFunction · 0.85
confirmMajorReleaseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…