Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/public-zebras-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@changesets/get-version-range-type": minor
"@changesets/assemble-release-plan": minor
"@changesets/get-dependents-graph": minor
"@changesets/apply-release-plan": minor
"@changesets/changelog-github": minor
"@changesets/get-release-plan": minor
"@changesets/changelog-git": minor
"@changesets/release-utils": minor
"@changesets/parse": minor
"@changesets/write": minor
"@changesets/read": minor
"@changesets/cli": minor
"@changesets/git": minor
---

Add a named export that mirrors the current `default` export

The `default` export is slated for removal in the next major release, so this ensures a smoother transition path.
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ export default defineConfig(
{ ignores: ["fs/promises.cp", "import.meta.dirname"] },
],

"import-lite/no-default-export": "error",
"import-lite/no-mutable-exports": "off", // TODO enable and fix errors
},
},
{
files: [
"**/index.ts", // to be removed in next release (v4) when we are dropping default export
"**/vitest.config.mts",
"**/eslint.config.mjs",
],
rules: {
"import-lite/no-default-export": "off",
},
},
{
files: ["**/*.{js,mjs}"],
...tseslint.configs.disableTypeChecked,
Expand Down
2 changes: 1 addition & 1 deletion packages/apply-release-plan/src/get-changelog-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateChangesForVersionTypeMarkdown(
}

// release is the package and version we are releasing
export default async function getChangelogEntry(
export async function getChangelogEntry(
cwd: string,
release: ModCompWithPackage,
releases: ModCompWithPackage[],
Expand Down
10 changes: 7 additions & 3 deletions packages/apply-release-plan/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import fs from "node:fs/promises";
import path from "path";
import prettier from "prettier";
import { resolve } from "import-meta-resolve";
import getChangelogEntry from "./get-changelog-entry.ts";
import versionPackage from "./version-package.ts";
import { getChangelogEntry } from "./get-changelog-entry.ts";
import { versionPackage } from "./version-package.ts";
import { createRequire } from "node:module";
import { pathToFileURL } from "node:url";

Expand Down Expand Up @@ -72,7 +72,7 @@ async function getCommitsThatAddChangesets(
return commits;
}

export default async function applyReleasePlan(
export async function applyReleasePlan(
releasePlan: ReleasePlan,
packages: Packages,
config: Config = defaultConfig,
Expand Down Expand Up @@ -378,6 +378,10 @@ async function updatePackageJson(
return fs.writeFile(pkgJsonPath, stringified);
}

/** @deprecated Use named export `applyReleasePlan` instead */
const applyReleasePlanDefault = applyReleasePlan;
export default applyReleasePlanDefault;

async function writeFormattedMarkdownFile(
filePath: string,
content: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// plugin, must have a default export
/* eslint-disable import-lite/no-default-export */

import type { ChangelogFunctions } from "@changesets/types";

export default {
getReleaseLine: () => {
throw new Error("no chance");
},
getDependencyReleaseLine: () => {
throw new Error("no chance");
},
};
} satisfies ChangelogFunctions;
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ async function getReleaseLines(
return `### ${capitalize(type)} Changes\n\n${resolvedLines.join("")}`;
}

// plugin, needs default export
// eslint-disable-next-line import-lite/no-default-export
export default async function defaultChangelogGetter(
release: ComprehensiveRelease,
relevantChangesets: RelevantChangesets,
Expand Down
4 changes: 2 additions & 2 deletions packages/apply-release-plan/src/version-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
PackageJSON,
VersionType,
} from "@changesets/types";
import getVersionRangeType from "@changesets/get-version-range-type";
import { getVersionRangeType } from "@changesets/get-version-range-type";
import Range from "semver/classes/range.js";
import semverPrerelease from "semver/functions/prerelease.js";
import validRange from "semver/ranges/valid.js";
Expand All @@ -16,7 +16,7 @@ const DEPENDENCY_TYPES = [
"optionalDependencies",
] as const;

export default function versionPackage(
export function versionPackage(
release: ComprehensiveRelease & {
changelog: string | null;
packageJson: PackageJSON;
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Usage

```ts
import assembleReleasePlan from "@changesets/assemble-release-plan";
import readChangesets from "@changesets/read";
import { readChangesets } from "@changesets/read";
import { read } from "@changesets/config";
import { getPackages } from "@manypkg/get-packages";
import { readPreState } from "@changesets/pre";
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/src/apply-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getCurrentHighestVersion, getHighestReleaseType } from "./utils.ts";
We could solve this by inlining this function, or by returning a deep-cloned then
modified array, but we decided both of those are worse than this solution.
*/
export default function applyLinks(
export function applyLinks(
releases: Map<string, InternalRelease>,
packagesByName: Map<string, Package>,
linked: Linked,
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/src/determine-dependents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { mapGetOrThrowInternal } from "./utils.ts";
We could solve this by inlining this function, or by returning a deep-cloned then
modified array, but we decided both of those are worse than this solution.
*/
export default function determineDependents({
export function determineDependents({
releases,
packagesByName,
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/src/flatten-releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Config, NewChangeset, Package } from "@changesets/types";
import type { InternalRelease } from "./types.ts";
import { mapGetOrThrowInternal } from "./utils.ts";

export default function flattenReleases(
export function flattenReleases(
changesets: NewChangeset[],
packagesByName: Map<string, Package>,
config: Config,
Expand Down
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it } from "vitest";
import { defaultConfig } from "@changesets/config";
import assembleReleasePlan from "./index.ts";
import FakeFullState from "./test-utils.ts";
import { assembleReleasePlan } from "./index.ts";
import { FakeFullState } from "./test-utils.ts";

describe("assemble-release-plan", () => {
let setup: FakeFullState;
Expand Down
14 changes: 8 additions & 6 deletions packages/assemble-release-plan/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import type {
Packages,
} from "@changesets/types";
import semverParse from "semver/functions/parse.js";
import applyLinks from "./apply-links.ts";
import determineDependents from "./determine-dependents.ts";
import flattenReleases from "./flatten-releases.ts";
import { applyLinks } from "./apply-links.ts";
import { determineDependents } from "./determine-dependents.ts";
import { flattenReleases } from "./flatten-releases.ts";
import { incrementVersion } from "./increment.ts";
import matchFixedConstraint from "./match-fixed-constraint.ts";
import { matchFixedConstraint } from "./match-fixed-constraint.ts";
import type { InternalRelease, PreInfo } from "./types.ts";
import { mapGetOrThrow, mapGetOrThrowInternal } from "./utils.ts";

Expand Down Expand Up @@ -120,7 +120,7 @@ function getNewVersion(
return incrementVersion(release, preInfo);
}

function assembleReleasePlan(
export function assembleReleasePlan(
changesets: NewChangeset[],
packages: Packages,
config: Config,
Expand Down Expand Up @@ -373,4 +373,6 @@ function getPreInfo(
};
}

export default assembleReleasePlan;
/** @deprecated Use named export `assembleReleasePlan` instead */
const assembleReleasePlanDefault = assembleReleasePlan;
export default assembleReleasePlanDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
mapGetOrThrowInternal,
} from "./utils.ts";

export default function matchFixedConstraint(
export function matchFixedConstraint(
releases: Map<string, InternalRelease>,
packagesByName: Map<string, Package>,
config: Config,
Expand Down
4 changes: 1 addition & 3 deletions packages/assemble-release-plan/src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const getSimpleSetup = () => ({
] satisfies Array<NewChangeset>,
});

class FakeFullState {
export class FakeFullState {
packages: Packages;
changesets: NewChangeset[];

Expand Down Expand Up @@ -141,5 +141,3 @@ class FakeFullState {
pkg.packageJson.version = version;
}
}

export default FakeFullState;
1 change: 1 addition & 0 deletions packages/changelog-git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ const defaultChangelogFunctions = {
getDependencyReleaseLine,
} satisfies ChangelogFunctions;

// ChangelogFunctions require a default export
export default defaultChangelogFunctions;
1 change: 1 addition & 0 deletions packages/changelog-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@ const changelogFunctions: ChangelogFunctions = {
},
};

// ChangelogFunctions require a default export
export default changelogFunctions;
1 change: 1 addition & 0 deletions packages/cli/src/changelog.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line import-lite/no-default-export
export { default } from "@changesets/changelog-git";
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add/__tests__/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import getChangesets from "@changesets/read";
import { exec } from "tinyexec";

import * as utils from "../../../utils/cli-utilities.ts";
import addChangeset from "../index.ts";
import { add as addChangeset } from "../index.ts";

vi.mock("../../../utils/cli-utilities");
const mockedUtils = vi.mocked(utils);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add/createChangeset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function formatPkgNameAndVersion(pkgName: string, version: string) {
return `${bold(pkgName)}@${bold(version)}`;
}

export default async function createChangeset(
export async function createChangeset(
changedPackages: Array<string>,
allPackages: Array<Package>,
messageFromCli?: string,
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import * as git from "@changesets/git";
import { error, info, log, warn } from "@changesets/logger";
import { shouldSkipPackage } from "@changesets/should-skip-package";
import type { Config } from "@changesets/types";
import writeChangeset from "@changesets/write";
import { writeChangeset } from "@changesets/write";
import { ExitError } from "@changesets/errors";
import { getPackages } from "@manypkg/get-packages";
import { ExternalEditor } from "@inquirer/external-editor";
import { getCommitFunctions } from "../../commit/getCommitFunctions.ts";
import * as cli from "../../utils/cli-utilities.ts";
import { getVersionableChangedPackages } from "../../utils/versionablePackages.ts";
import createChangeset from "./createChangeset.ts";
import printConfirmationMessage from "./messages.ts";
import { createChangeset } from "./createChangeset.ts";
import { printConfirmationMessage } from "./messages.ts";
import { fileURLToPath } from "node:url";

export default async function add(
export async function add(
cwd: string,
{
empty,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import pc from "picocolors";
import { log } from "@changesets/logger";
import type { Release, VersionType } from "@changesets/types";

export default function printConfirmationMessage(
export function printConfirmationMessage(
changeset: {
releases: Array<Release>;
summary: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/init/__tests__/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from "path";
import { defaultWrittenConfig } from "@changesets/config";
import { silenceLogsInBlock, testdir } from "@changesets/test-utils";

import initializeCommand from "../index.ts";
import { init as initializeCommand } from "../index.ts";

const getPaths = (cwd: string) => ({
readmePath: path.join(cwd, ".changeset/README.md"),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const pkgPath = path.dirname(require.resolve("@changesets/cli/package.json"));

const defaultConfig = `${JSON.stringify(defaultWrittenConfig, null, 2)}\n`;

export default async function init(cwd: string) {
export async function init(cwd: string) {
const changesetBase = path.resolve(cwd, ".changeset");

if (existsSync(changesetBase)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/pre/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
testdir,
} from "@changesets/test-utils";

import pre from "./index.ts";
import { pre } from "./index.ts";

silenceLogsInBlock();

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/pre/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ExitError,
} from "@changesets/errors";

export default async function pre(
export async function pre(
rootDir: string,
options:
| { command: "enter"; tag: string }
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import publishCommand from "../index.ts";
import { publish as publishCommand } from "../index.ts";
import { defaultConfig } from "@changesets/config";
import * as path from "path";
import type { Config } from "@changesets/types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import publishPackages from "../publishPackages.ts";
import { publishPackages } from "../publishPackages.ts";
import * as npmUtils from "../npm-utils.ts";
import { getPackages } from "@manypkg/get-packages";
import { silenceLogsInBlock, testdir } from "@changesets/test-utils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import publishPackages from "../publishPackages.ts";
import { publishPackages } from "../publishPackages.ts";
import * as git from "@changesets/git";
import { defaultConfig } from "@changesets/config";
import { silenceLogsInBlock, testdir } from "@changesets/test-utils";
import runRelease from "../index.ts";
import { publish as runRelease } from "../index.ts";

vi.mock("../../../utils/cli-utilities");
vi.mock("@changesets/git");
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/publish/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import publishPackages from "./publishPackages.ts";
import { publishPackages } from "./publishPackages.ts";
import { ExitError } from "@changesets/errors";
import { error, log, success, warn } from "@changesets/logger";
import * as git from "@changesets/git";
Expand Down Expand Up @@ -38,7 +38,7 @@ function showNonLatestTagWarning(tag?: string, preState?: PreState) {
warn(importantEnd);
}

export default async function publish(
export async function publish(
cwd: string,
{ otp, tag, gitTag = true }: { otp?: string; tag?: string; gitTag?: boolean },
config: Config,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish/publishPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const requiresDelegatedAuth = (twoFactorState: TwoFactorState) => {
);
};

export default async function publishPackages({
export async function publishPackages({
packages,
access,
otp,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/status/__tests__/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { read } from "@changesets/config";
import * as git from "@changesets/git";
import { gitdir, outputFile, silenceLogsInBlock } from "@changesets/test-utils";
import type { ReleasePlan } from "@changesets/types";
import writeChangeset from "@changesets/write";
import { writeChangeset } from "@changesets/write";
import { getPackages } from "@manypkg/get-packages";
import fs from "node:fs/promises";
import path from "path";
import { exec } from "tinyexec";
import status from "../index.ts";
import { status } from "../index.ts";

async function readConfig(cwd: string) {
const packages = await getPackages(cwd);
Expand Down
Loading
Loading