diff --git a/.changeset/lovely-suits-obey.md b/.changeset/lovely-suits-obey.md new file mode 100644 index 000000000..c52e2418e --- /dev/null +++ b/.changeset/lovely-suits-obey.md @@ -0,0 +1,6 @@ +--- +"@changesets/apply-release-plan": minor +"@changesets/write": minor +--- + +The local version of Prettier is going to be preferred from now on when writing formatted `.md` files back to disk. At the same time the version of Prettier that we depend on has been upgraded. diff --git a/babel.config.js b/babel.config.js index cfe1bd761..e63b6c255 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,9 +3,9 @@ module.exports = { [ "@babel/preset-env", { - targets: { node: 8 } - } - ] + targets: { node: 8 }, + }, + ], ], - overrides: [{ test: "**/*.ts", presets: ["@babel/preset-typescript"] }] + overrides: [{ test: "**/*.ts", presets: ["@babel/preset-typescript"] }], }; diff --git a/docs/modifying-changelog-format.md b/docs/modifying-changelog-format.md index 3de22ac23..19b576ea4 100644 --- a/docs/modifying-changelog-format.md +++ b/docs/modifying-changelog-format.md @@ -35,7 +35,7 @@ async function getDependencyReleaseLine() {} module.exports = { getReleaseLine, - getDependencyReleaseLine + getDependencyReleaseLine, }; ``` @@ -52,7 +52,7 @@ async function getDependencyReleaseLine() {} const defaultChangelogFunctions: ChangelogFunctions = { getReleaseLine, - getDependencyReleaseLine + getDependencyReleaseLine, }; export default defaultChangelogFunctions; diff --git a/jest.config.js b/jest.config.js index 7e4b7726a..63254f211 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,6 +2,6 @@ module.exports = { clearMocks: true, watchPlugins: [ "jest-watch-typeahead/filename", - "jest-watch-typeahead/testname" - ] + "jest-watch-typeahead/testname", + ], }; diff --git a/package.json b/package.json index b74d6d598..bc0aa67ec 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@types/js-yaml": "^3.12.1", "@types/lodash": "^4.14.136", "@types/meow": "^5.0.0", - "@types/prettier": "^1.19.1", + "@types/prettier": "^2.7.0", "@types/semver": "^6.0.0", "@typescript-eslint/eslint-plugin": "^3.5.0", "@typescript-eslint/parser": "^3.5.0", @@ -63,7 +63,7 @@ "jest": "^25.1.0", "jest-junit": "^6.4.0", "jest-watch-typeahead": "^0.4.2", - "prettier": "^1.19.1", + "prettier": "^2.7.1", "typescript": "^4.5.2" }, "preconstruct": { diff --git a/packages/apply-release-plan/package.json b/packages/apply-release-plan/package.json index 9f1926b36..09039b175 100644 --- a/packages/apply-release-plan/package.json +++ b/packages/apply-release-plan/package.json @@ -17,7 +17,7 @@ "fs-extra": "^7.0.1", "lodash.startcase": "^4.4.0", "outdent": "^0.5.0", - "prettier": "^1.19.1", + "prettier": "^2.7.1", "resolve-from": "^5.0.0", "semver": "^5.4.1" }, diff --git a/packages/apply-release-plan/src/get-changelog-entry.ts b/packages/apply-release-plan/src/get-changelog-entry.ts index 3d859ee53..1f07982de 100644 --- a/packages/apply-release-plan/src/get-changelog-entry.ts +++ b/packages/apply-release-plan/src/get-changelog-entry.ts @@ -15,7 +15,7 @@ async function generateChangesForVersionTypeMarkdown( type: keyof ChangelogLines ) { let releaseLines = await Promise.all(obj[type]); - releaseLines = releaseLines.filter(x => x); + releaseLines = releaseLines.filter((x) => x); if (releaseLines.length) { return `### ${startCase(type)} Changes\n\n${releaseLines.join("\n")}\n`; } @@ -30,7 +30,7 @@ export default async function getChangelogEntry( changelogOpts: any, { updateInternalDependencies, - onlyUpdatePeerDependentsWhenOutOfRange + onlyUpdatePeerDependentsWhenOutOfRange, }: { updateInternalDependencies: "patch" | "minor"; onlyUpdatePeerDependentsWhenOutOfRange: boolean; @@ -41,22 +41,22 @@ export default async function getChangelogEntry( const changelogLines: ChangelogLines = { major: [], minor: [], - patch: [] + patch: [], }; // I sort of feel we can do better, as ComprehensiveReleases have an array // of the relevant changesets but since we need the version type for the // release in the changeset, I don't know if we can // We can filter here, but that just adds another iteration over this list - changesets.forEach(cs => { - const rls = cs.releases.find(r => r.name === release.name); + changesets.forEach((cs) => { + const rls = cs.releases.find((r) => r.name === release.name); if (rls && rls.type !== "none") { changelogLines[rls.type].push( changelogFuncs.getReleaseLine(cs, rls.type, changelogOpts) ); } }); - let dependentReleases = releases.filter(rel => { + let dependentReleases = releases.filter((rel) => { const dependencyVersionRange = release.packageJson.dependencies?.[rel.name]; const peerDependencyVersionRange = release.packageJson.peerDependencies?.[rel.name]; @@ -68,11 +68,11 @@ export default async function getChangelogEntry( { type: rel.type, version: rel.newVersion }, { depVersionRange: versionRange, - depType: dependencyVersionRange ? "dependencies" : "peerDependencies" + depType: dependencyVersionRange ? "dependencies" : "peerDependencies", }, { minReleaseType: updateInternalDependencies, - onlyUpdatePeerDependentsWhenOutOfRange + onlyUpdatePeerDependentsWhenOutOfRange, } ) ); @@ -80,13 +80,13 @@ export default async function getChangelogEntry( let relevantChangesetIds: Set = new Set(); - dependentReleases.forEach(rel => { - rel.changesets.forEach(cs => { + dependentReleases.forEach((rel) => { + rel.changesets.forEach((cs) => { relevantChangesetIds.add(cs); }); }); - let relevantChangesets = changesets.filter(cs => + let relevantChangesets = changesets.filter((cs) => relevantChangesetIds.has(cs.id) ); @@ -102,8 +102,8 @@ export default async function getChangelogEntry( `## ${release.newVersion}`, await generateChangesForVersionTypeMarkdown(changelogLines, "major"), await generateChangesForVersionTypeMarkdown(changelogLines, "minor"), - await generateChangesForVersionTypeMarkdown(changelogLines, "patch") + await generateChangesForVersionTypeMarkdown(changelogLines, "patch"), ] - .filter(line => line) + .filter((line) => line) .join("\n"); } diff --git a/packages/apply-release-plan/src/index.test.ts b/packages/apply-release-plan/src/index.test.ts index d7ede0296..a0facff7c 100644 --- a/packages/apply-release-plan/src/index.test.ts +++ b/packages/apply-release-plan/src/index.test.ts @@ -3,7 +3,7 @@ import { ReleasePlan, Config, NewChangeset, - ComprehensiveRelease + ComprehensiveRelease, } from "@changesets/types"; import * as git from "@changesets/git"; import fs from "fs-extra"; @@ -31,14 +31,14 @@ class FakeReleasePlan { const baseChangeset: NewChangeset = { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }; const baseRelease: ComprehensiveRelease = { name: "pkg-a", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }; this.config = { changelog: false, @@ -51,13 +51,13 @@ class FakeReleasePlan { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null + prereleaseTemplate: null, }, - ...config + ...config, }; this.changesets = [baseChangeset, ...changesets]; @@ -68,7 +68,7 @@ class FakeReleasePlan { return { changesets: this.changesets, releases: this.releases, - preState: undefined + preState: undefined, }; } } @@ -92,12 +92,12 @@ async function testSetup( ignore: [], snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null + prereleaseTemplate: null, }, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" - } + updateInternalDependents: "out-of-range", + }, }; } let tempDir = await f.copy(fixtureName); @@ -118,7 +118,7 @@ async function testSetup( config, snapshot ), - tempDir + tempDir, }; } @@ -132,7 +132,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => a.endsWith(`package.json`)); + let pkgPath = changedFiles.find((a) => a.endsWith(`package.json`)); if (!pkgPath) throw new Error(`could not find an updated package json`); let pkgJSON = await fs.readFile(pkgPath, { encoding: "utf-8" }); @@ -153,7 +153,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => a.endsWith(`package.json`)); + let pkgPath = changedFiles.find((a) => a.endsWith(`package.json`)); if (!pkgPath) throw new Error(`could not find an updated package json`); let pkgJSON = await fs.readFile(pkgPath, { encoding: "utf-8" }); @@ -171,7 +171,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => a.endsWith(`package.json`)); + let pkgPath = changedFiles.find((a) => a.endsWith(`package.json`)); if (!pkgPath) throw new Error(`could not find an updated package json`); let pkgJSON = await fs.readFile(pkgPath, { encoding: "utf-8" }); @@ -190,7 +190,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -199,7 +199,7 @@ describe("apply release plan", () => { expect(pkgJSON).toMatchObject({ name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }); }); it("should not update ranges set to *", async () => { @@ -208,8 +208,8 @@ describe("apply release plan", () => { { id: "some-id", releases: [{ name: "pkg-b", type: "minor" }], - summary: "a very useful summary" - } + summary: "a very useful summary", + }, ], [ { @@ -217,8 +217,8 @@ describe("apply release plan", () => { name: "pkg-b", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" - } + type: "minor", + }, ] ); let { changedFiles } = await testSetup( @@ -226,7 +226,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -237,8 +237,8 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "*" - } + "pkg-b": "*", + }, }); }); it("should update workspace ranges", async () => { @@ -247,8 +247,8 @@ describe("apply release plan", () => { { id: "some-id", releases: [{ name: "pkg-b", type: "minor" }], - summary: "a very useful summary" - } + summary: "a very useful summary", + }, ], [ { @@ -256,8 +256,8 @@ describe("apply release plan", () => { name: "pkg-b", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" - } + type: "minor", + }, ] ); let { changedFiles } = await testSetup( @@ -265,7 +265,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -276,8 +276,8 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "workspace:1.1.0" - } + "pkg-b": "workspace:1.1.0", + }, }); }); it("should not update workspace version aliases", async () => { @@ -286,18 +286,18 @@ describe("apply release plan", () => { { id: "some-id", releases: [{ name: "pkg-b", type: "minor" }], - summary: "a very useful summary" + summary: "a very useful summary", }, { id: "some-id", releases: [{ name: "pkg-c", type: "minor" }], - summary: "a very useful summary" + summary: "a very useful summary", }, { id: "some-id", releases: [{ name: "pkg-d", type: "minor" }], - summary: "a very useful summary" - } + summary: "a very useful summary", + }, ], [ { @@ -305,22 +305,22 @@ describe("apply release plan", () => { name: "pkg-b", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" + type: "minor", }, { changesets: ["some-id"], name: "pkg-c", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" + type: "minor", }, { changesets: ["some-id"], name: "pkg-d", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" - } + type: "minor", + }, ] ); let { changedFiles } = await testSetup( @@ -328,7 +328,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -341,8 +341,8 @@ describe("apply release plan", () => { dependencies: { "pkg-b": "workspace:*", "pkg-c": "workspace:^", - "pkg-d": "workspace:~" - } + "pkg-d": "workspace:~", + }, }); }); it("should update workspace ranges only with bumpVersionsWithWorkspaceProtocolOnly", async () => { @@ -352,10 +352,10 @@ describe("apply release plan", () => { id: "some-id", releases: [ { name: "pkg-b", type: "minor" }, - { name: "pkg-c", type: "minor" } + { name: "pkg-c", type: "minor" }, ], - summary: "a very useful summary" - } + summary: "a very useful summary", + }, ], [ { @@ -363,18 +363,18 @@ describe("apply release plan", () => { name: "pkg-b", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" + type: "minor", }, { changesets: ["some-id"], name: "pkg-c", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" - } + type: "minor", + }, ], { - bumpVersionsWithWorkspaceProtocolOnly: true + bumpVersionsWithWorkspaceProtocolOnly: true, } ); let { changedFiles } = await testSetup( @@ -382,7 +382,7 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgAPath = changedFiles.find(a => + let pkgAPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -393,11 +393,11 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "workspace:1.1.0" - } + "pkg-b": "workspace:1.1.0", + }, }); - let pkgCPath = changedFiles.find(a => + let pkgCPath = changedFiles.find((a) => a.endsWith(`pkg-c${path.sep}package.json`) ); @@ -408,8 +408,8 @@ describe("apply release plan", () => { name: "pkg-c", version: "1.1.0", dependencies: { - "pkg-b": "1.0.0" - } + "pkg-b": "1.0.0", + }, }); }); it("should update a version for two packages with different new versions", async () => { @@ -421,8 +421,8 @@ describe("apply release plan", () => { type: "major", oldVersion: "1.0.0", newVersion: "2.0.0", - changesets: [] - } + changesets: [], + }, ] ); @@ -431,10 +431,10 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), releasePlan.config ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -446,11 +446,11 @@ describe("apply release plan", () => { expect(pkgJSONA).toMatchObject({ name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", - version: "2.0.0" + version: "2.0.0", }); }); it("should not update the version of the dependent package if the released dep is a dev dep", async () => { @@ -463,9 +463,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "none" }, - { name: "pkg-b", type: "minor" } - ] - } + { name: "pkg-b", type: "minor" }, + ], + }, ], releases: [ { @@ -473,17 +473,17 @@ describe("apply release plan", () => { type: "none", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -496,18 +496,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -521,12 +521,12 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.0.0", devDependencies: { - "pkg-b": "1.1.0" - } + "pkg-b": "1.1.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", - version: "1.1.0" + version: "1.1.0", }); }); it("should skip dependencies that have the same name as the package", async () => { @@ -537,8 +537,8 @@ describe("apply release plan", () => { { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", - releases: [{ name: "self-referenced", type: "minor" }] - } + releases: [{ name: "self-referenced", type: "minor" }], + }, ], releases: [ { @@ -546,10 +546,10 @@ describe("apply release plan", () => { type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -562,15 +562,15 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`self-referenced${path.sep}package.json`) ); @@ -581,8 +581,8 @@ describe("apply release plan", () => { name: "self-referenced", version: "1.1.0", devDependencies: { - "self-referenced": "file:" - } + "self-referenced": "file:", + }, }); }); it("should not update dependent versions when a package has a changeset type of none", async () => { @@ -593,8 +593,8 @@ describe("apply release plan", () => { { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", - releases: [{ name: "pkg-b", type: "none" }] - } + releases: [{ name: "pkg-b", type: "none" }], + }, ], releases: [ { @@ -602,17 +602,17 @@ describe("apply release plan", () => { type: "none", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { ...defaultConfig, changelog: false } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -623,7 +623,7 @@ describe("apply release plan", () => { expect(pkgJSONB).toMatchObject({ name: "pkg-b", - version: "1.0.0" + version: "1.0.0", }); }); it("should not update workspace dependent versions when a package has a changeset type of none", async () => { @@ -634,8 +634,8 @@ describe("apply release plan", () => { { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", - releases: [{ name: "pkg-b", type: "none" }] - } + releases: [{ name: "pkg-b", type: "none" }], + }, ], releases: [ { @@ -643,17 +643,17 @@ describe("apply release plan", () => { type: "none", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { ...defaultConfig, changelog: false } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -664,7 +664,7 @@ describe("apply release plan", () => { expect(pkgJSONB).toMatchObject({ name: "pkg-b", - version: "1.0.0" + version: "1.0.0", }); }); it("should use exact versioning when snapshot release is applied, and ignore any range modifiers", async () => { @@ -673,8 +673,8 @@ describe("apply release plan", () => { { id: "some-id", releases: [{ name: "pkg-b", type: "minor" }], - summary: "a very useful summary" - } + summary: "a very useful summary", + }, ], [ { @@ -682,8 +682,8 @@ describe("apply release plan", () => { name: "pkg-b", newVersion: "1.1.0", oldVersion: "1.0.0", - type: "minor" - } + type: "minor", + }, ] ); let { changedFiles } = await testSetup( @@ -693,7 +693,7 @@ describe("apply release plan", () => { "canary" ); - let pkgPath = changedFiles.find(a => + let pkgPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); @@ -704,8 +704,8 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "1.1.0" - } + "pkg-b": "1.1.0", + }, }); }); @@ -722,9 +722,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "patch" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -732,17 +732,17 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -755,18 +755,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -780,16 +780,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.0.4", dependencies: { - "pkg-b": "~1.2.1" - } + "pkg-b": "~1.2.1", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^1.0.4" - } + "pkg-a": "^1.0.4", + }, }); }); it("should still update min version ranges of patch bumped internal dependencies that have left semver range", async () => { @@ -803,9 +803,9 @@ describe("apply release plan", () => { releases: [ { name: "pkg-a", type: "patch" }, { name: "pkg-b", type: "patch" }, - { name: "pkg-c", type: "patch" } - ] - } + { name: "pkg-c", type: "patch" }, + ], + }, ], releases: [ { @@ -813,24 +813,24 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "none", oldVersion: "1.2.0", newVersion: "1.2.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-c", type: "patch", oldVersion: "2.0.0", newVersion: "2.0.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -843,18 +843,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -868,16 +868,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.0.4", dependencies: { - "pkg-b": "~1.2.0" - } + "pkg-b": "~1.2.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.0", dependencies: { "pkg-c": "2.0.1", - "pkg-a": "^1.0.4" - } + "pkg-a": "^1.0.4", + }, }); }); it("should update min version ranges of minor bumped internal dependencies", async () => { @@ -890,9 +890,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -900,17 +900,17 @@ describe("apply release plan", () => { type: "minor", oldVersion: "1.0.3", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -923,18 +923,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -948,16 +948,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "~1.2.1" - } + "pkg-b": "~1.2.1", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^1.1.0" - } + "pkg-a": "^1.1.0", + }, }); }); it("should update min version ranges of major bumped internal dependencies", async () => { @@ -970,9 +970,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "major" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -980,17 +980,17 @@ describe("apply release plan", () => { type: "major", oldVersion: "1.0.3", newVersion: "2.0.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1003,18 +1003,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -1028,16 +1028,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "2.0.0", dependencies: { - "pkg-b": "~1.2.1" - } + "pkg-b": "~1.2.1", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^2.0.0" - } + "pkg-a": "^2.0.0", + }, }); }); }); @@ -1053,9 +1053,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "patch" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -1063,17 +1063,17 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1086,18 +1086,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -1111,16 +1111,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.0.4", dependencies: { - "pkg-b": "~1.2.0" - } + "pkg-b": "~1.2.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^1.0.3" - } + "pkg-a": "^1.0.3", + }, }); }); it("should still update min version ranges of patch bumped internal dependencies that have left semver range", async () => { @@ -1134,9 +1134,9 @@ describe("apply release plan", () => { releases: [ { name: "pkg-a", type: "patch" }, { name: "pkg-b", type: "patch" }, - { name: "pkg-c", type: "patch" } - ] - } + { name: "pkg-c", type: "patch" }, + ], + }, ], releases: [ { @@ -1144,24 +1144,24 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-c", type: "patch", oldVersion: "2.0.0", newVersion: "2.0.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1174,18 +1174,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -1199,16 +1199,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.0.4", dependencies: { - "pkg-b": "~1.2.0" - } + "pkg-b": "~1.2.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.1", - "pkg-a": "^1.0.3" - } + "pkg-a": "^1.0.3", + }, }); }); it("should update min version ranges of minor bumped internal dependencies", async () => { @@ -1221,9 +1221,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -1231,17 +1231,17 @@ describe("apply release plan", () => { type: "minor", oldVersion: "1.0.3", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1254,18 +1254,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -1279,16 +1279,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "~1.2.0" - } + "pkg-b": "~1.2.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^1.1.0" - } + "pkg-a": "^1.1.0", + }, }); }); it("should update min version ranges of major bumped internal dependencies", async () => { @@ -1301,9 +1301,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "major" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -1311,17 +1311,17 @@ describe("apply release plan", () => { type: "major", oldVersion: "1.0.3", newVersion: "2.0.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1334,18 +1334,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathA = changedFiles.find(a => + let pkgPathA = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}package.json`) ); - let pkgPathB = changedFiles.find(b => + let pkgPathB = changedFiles.find((b) => b.endsWith(`pkg-b${path.sep}package.json`) ); @@ -1359,16 +1359,16 @@ describe("apply release plan", () => { name: "pkg-a", version: "2.0.0", dependencies: { - "pkg-b": "~1.2.0" - } + "pkg-b": "~1.2.0", + }, }); expect(pkgJSONB).toMatchObject({ name: "pkg-b", version: "1.2.1", dependencies: { "pkg-c": "2.0.0", - "pkg-a": "^2.0.0" - } + "pkg-a": "^2.0.0", + }, }); }); }); @@ -1385,9 +1385,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "has-peer-dep", type: "patch" }, - { name: "depended-upon", type: "patch" } - ] - } + { name: "depended-upon", type: "patch" }, + ], + }, ], releases: [ { @@ -1395,17 +1395,17 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.0", newVersion: "1.0.1", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "depended-upon", type: "patch", oldVersion: "1.0.0", newVersion: "1.0.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: false, @@ -1418,18 +1418,18 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: true, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgPathDependent = changedFiles.find(a => + let pkgPathDependent = changedFiles.find((a) => a.endsWith(`has-peer-dep${path.sep}package.json`) ); - let pkgPathDepended = changedFiles.find(b => + let pkgPathDepended = changedFiles.find((b) => b.endsWith(`depended-upon${path.sep}package.json`) ); @@ -1443,12 +1443,12 @@ describe("apply release plan", () => { name: "has-peer-dep", version: "1.0.1", peerDependencies: { - "depended-upon": "^1.0.0" - } + "depended-upon": "^1.0.0", + }, }); expect(pkgJSONDepended).toMatchObject({ name: "depended-upon", - version: "1.0.1" + version: "1.0.1", }); }); }); @@ -1461,12 +1461,12 @@ describe("apply release plan", () => { releasePlan.getReleasePlan(), { ...releasePlan.config, - changelog: false + changelog: false, } ); expect( - changedFiles.find(a => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`)) + changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`)) ).toBeUndefined(); }); it("should update a changelog for one package", async () => { @@ -1478,12 +1478,12 @@ describe("apply release plan", () => { ...releasePlan.config, changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null - ] + null, + ], } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); @@ -1507,8 +1507,8 @@ describe("apply release plan", () => { type: "major", oldVersion: "1.0.0", newVersion: "2.0.0", - changesets: [] - } + changesets: [], + }, ] ); @@ -1519,15 +1519,15 @@ describe("apply release plan", () => { ...releasePlan.config, changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null - ] + null, + ], } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); - let readmePathB = changedFiles.find(a => + let readmePathB = changedFiles.find((a) => a.endsWith(`pkg-b${path.sep}CHANGELOG.md`) ); @@ -1562,9 +1562,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "none" }, - { name: "pkg-b", type: "minor" } - ] - } + { name: "pkg-b", type: "minor" }, + ], + }, ], releases: [ { @@ -1572,17 +1572,17 @@ describe("apply release plan", () => { type: "none", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: [] + changesets: [], }, { name: "pkg-b", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { commit: false, @@ -1592,21 +1592,21 @@ describe("apply release plan", () => { baseBranch: "main", changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null + null, ], updateInternalDependencies: "patch", ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let pkgAChangelogPath = changedFiles.find(a => + let pkgAChangelogPath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); @@ -1618,13 +1618,13 @@ describe("apply release plan", () => { { id: "some-id-1", summary: "Random stuff\n\nget it while it's hot!", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }, { id: "some-id-2", summary: "New feature, much wow\n\nlook at this shiny stuff!", - releases: [{ name: "pkg-a", type: "minor" }] - } + releases: [{ name: "pkg-a", type: "minor" }], + }, ]); releasePlan.releases[0].changesets.push("some-id-1", "some-id-2"); @@ -1635,12 +1635,12 @@ describe("apply release plan", () => { ...releasePlan.config, changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null - ] + null, + ], } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); @@ -1655,7 +1655,7 @@ describe("apply release plan", () => { "- Random stuff\n", " get it while it's hot!\n", "- New feature, much wow\n", - " look at this shiny stuff!" + " look at this shiny stuff!", ].join("\n") ); }); @@ -1670,9 +1670,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "patch" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -1680,22 +1680,22 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null + null, ], commit: false, fixed: [], @@ -1706,19 +1706,19 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); - let readmePathB = changedFiles.find(a => + let readmePathB = changedFiles.find((a) => a.endsWith(`pkg-b${path.sep}CHANGELOG.md`) ); @@ -1758,9 +1758,9 @@ describe("apply release plan", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "patch" }, - { name: "pkg-b", type: "patch" } - ] - } + { name: "pkg-b", type: "patch" }, + ], + }, ], releases: [ { @@ -1768,22 +1768,22 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null + null, ], commit: false, fixed: [], @@ -1794,19 +1794,19 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); - let readmePathB = changedFiles.find(a => + let readmePathB = changedFiles.find((a) => a.endsWith(`pkg-b${path.sep}CHANGELOG.md`) ); @@ -1843,9 +1843,9 @@ describe("apply release plan", () => { releases: [ { name: "pkg-a", type: "patch" }, { name: "pkg-b", type: "patch" }, - { name: "pkg-c", type: "minor" } - ] - } + { name: "pkg-c", type: "minor" }, + ], + }, ], releases: [ { @@ -1853,29 +1853,29 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-c", type: "minor", oldVersion: "2.0.0", newVersion: "2.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null + null, ], commit: false, fixed: [], @@ -1886,22 +1886,22 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); - let readmePathB = changedFiles.find(a => + let readmePathB = changedFiles.find((a) => a.endsWith(`pkg-b${path.sep}CHANGELOG.md`) ); - let readmePathC = changedFiles.find(a => + let readmePathC = changedFiles.find((a) => a.endsWith(`pkg-c${path.sep}CHANGELOG.md`) ); @@ -1949,9 +1949,9 @@ describe("apply release plan", () => { releases: [ { name: "pkg-a", type: "patch" }, { name: "pkg-b", type: "patch" }, - { name: "pkg-c", type: "patch" } - ] - } + { name: "pkg-c", type: "patch" }, + ], + }, ], releases: [ { @@ -1959,29 +1959,29 @@ describe("apply release plan", () => { type: "patch", oldVersion: "1.0.3", newVersion: "1.0.4", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "patch", oldVersion: "1.2.0", newVersion: "1.2.1", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-c", type: "patch", oldVersion: "2.0.0", newVersion: "2.0.1", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null + null, ], commit: false, fixed: [], @@ -1992,22 +1992,22 @@ describe("apply release plan", () => { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - let readmePath = changedFiles.find(a => + let readmePath = changedFiles.find((a) => a.endsWith(`pkg-a${path.sep}CHANGELOG.md`) ); - let readmePathB = changedFiles.find(a => + let readmePathB = changedFiles.find((a) => a.endsWith(`pkg-b${path.sep}CHANGELOG.md`) ); - let readmePathC = changedFiles.find(a => + let readmePathC = changedFiles.find((a) => a.endsWith(`pkg-c${path.sep}CHANGELOG.md`) ); @@ -2055,8 +2055,8 @@ describe("apply release plan", () => { { id: "quick-lions-devour", summary: "Hey, let's have fun with testing!", - releases: [{ name: "pkg-a", type: "minor" }] - } + releases: [{ name: "pkg-a", type: "minor" }], + }, ], releases: [ { @@ -2064,17 +2064,17 @@ describe("apply release plan", () => { type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-a", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }); changedFiles = testResults.changedFiles; } catch (e) { @@ -2098,8 +2098,8 @@ describe("apply release plan", () => { type: "minor", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: [] - } + changesets: [], + }, ] ); @@ -2151,8 +2151,8 @@ describe("apply release plan", () => { ...releasePlan.config, changelog: [ path.resolve(__dirname, "test-utils/failing-functions"), - null - ] + null, + ], } ); } catch (e) { @@ -2320,12 +2320,12 @@ describe("apply release plan", () => { ...releasePlan.config, commit: [ path.resolve(__dirname, "test-utils/simple-get-commit-entry"), - null + null, ], changelog: [ path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), - null - ] + null, + ], }, undefined, setupFunc @@ -2335,7 +2335,7 @@ describe("apply release plan", () => { let commits = thing.stdout .toString("utf8") .split("\n") - .filter(x => x); + .filter((x) => x); let lastCommit = commits[commits.length - 1].substring(0, 7); @@ -2365,8 +2365,8 @@ describe("apply release plan", () => { ...releasePlan.config, commit: [ path.resolve(__dirname, "test-utils/simple-get-commit-entry"), - null - ] + null, + ], } ); @@ -2407,8 +2407,8 @@ describe("apply release plan", () => { ...releasePlan.config, commit: [ path.resolve(__dirname, "test-utils/simple-get-commit-entry"), - null - ] + null, + ], }, undefined, setupFunc diff --git a/packages/apply-release-plan/src/index.ts b/packages/apply-release-plan/src/index.ts index 9ef29eb7a..18132cd3f 100644 --- a/packages/apply-release-plan/src/index.ts +++ b/packages/apply-release-plan/src/index.ts @@ -3,7 +3,7 @@ import { Config, ChangelogFunctions, NewChangeset, - ModCompWithPackage + ModCompWithPackage, } from "@changesets/types"; import { defaultConfig } from "@changesets/config"; @@ -19,6 +19,17 @@ import prettier from "prettier"; import versionPackage from "./version-package"; import getChangelogEntry from "./get-changelog-entry"; +function getPrettierInstance(cwd: string): typeof prettier { + try { + return require(require.resolve("prettier", { paths: [cwd] })); + } catch (err) { + if (!err || (err as any).code !== "MODULE_NOT_FOUND") { + throw err; + } + return prettier; + } +} + function stringDefined(s: string | undefined): s is string { return !!s; } @@ -26,7 +37,7 @@ async function getCommitsThatAddChangesets( changesetIds: string[], cwd: string ) { - const paths = changesetIds.map(id => `.changeset/${id}.md`); + const paths = changesetIds.map((id) => `.changeset/${id}.md`); const commits = await git.getCommitsThatAddFiles(paths, cwd); if (commits.every(stringDefined)) { @@ -39,7 +50,7 @@ async function getCommitsThatAddChangesets( .map((id, i) => (commits[i] ? undefined : id)) .filter(stringDefined); - const legacyPaths = missingIds.map(id => `.changeset/${id}/changes.json`); + const legacyPaths = missingIds.map((id) => `.changeset/${id}/changes.json`); const commitsForLegacyPaths = await git.getCommitsThatAddFiles( legacyPaths, cwd @@ -67,12 +78,12 @@ export default async function applyReleasePlan( let touchedFiles = []; const packagesByName = new Map( - packages.packages.map(x => [x.packageJson.name, x]) + packages.packages.map((x) => [x.packageJson.name, x]) ); let { releases, changesets } = releasePlan; - let releasesWithPackage = releases.map(release => { + let releasesWithPackage = releases.map((release) => { let pkg = packagesByName.get(release.name); if (!pkg) throw new Error( @@ -80,7 +91,7 @@ export default async function applyReleasePlan( ); return { ...release, - ...pkg + ...pkg, }; }); @@ -106,11 +117,11 @@ export default async function applyReleasePlan( let versionsToUpdate = releases.map(({ name, newVersion, type }) => ({ name, version: newVersion, - type + type, })); // iterate over releases updating packages - let finalisedRelease = releaseWithChangelogs.map(release => { + let finalisedRelease = releaseWithChangelogs.map((release) => { return versionPackage(release, versionsToUpdate, { updateInternalDependencies: config.updateInternalDependencies, onlyUpdatePeerDependentsWhenOutOfRange: @@ -118,11 +129,12 @@ export default async function applyReleasePlan( .onlyUpdatePeerDependentsWhenOutOfRange, bumpVersionsWithWorkspaceProtocolOnly: config.bumpVersionsWithWorkspaceProtocolOnly, - snapshot + snapshot, }); }); - let prettierConfig = await prettier.resolveConfig(cwd); + let prettierInstance = getPrettierInstance(cwd); + let prettierConfig = await prettierInstance.resolveConfig(cwd); for (let release of finalisedRelease) { let { changelog, packageJson, dir, name } = release; @@ -133,7 +145,13 @@ export default async function applyReleasePlan( if (changelog && changelog.length > 0) { const changelogPath = path.resolve(dir, "CHANGELOG.md"); - await updateChangelog(changelogPath, changelog, name, prettierConfig); + await updateChangelog( + changelogPath, + changelog, + name, + prettierInstance, + prettierConfig + ); touchedFiles.push(changelogPath); } } @@ -144,7 +162,7 @@ export default async function applyReleasePlan( ) { let changesetFolder = path.resolve(cwd, ".changeset"); await Promise.all( - changesets.map(async changeset => { + changesets.map(async (changeset) => { let changesetPath = path.resolve(changesetFolder, `${changeset.id}.md`); let changesetFolderPath = path.resolve(changesetFolder, changeset.id); if (await fs.pathExists(changesetPath)) { @@ -154,7 +172,7 @@ export default async function applyReleasePlan( // so we just check if any ignored package exists in this changeset, and only remove it if none exists // Ignored list is added in v2, so we don't need to do it for v1 changesets if ( - !changeset.releases.find(release => + !changeset.releases.find((release) => config.ignore.includes(release.name) ) ) { @@ -182,16 +200,16 @@ async function getNewChangelogEntry( ) { if (!config.changelog) { return Promise.resolve( - releasesWithPackage.map(release => ({ + releasesWithPackage.map((release) => ({ ...release, - changelog: null + changelog: null, })) ); } let getChangelogFuncs: ChangelogFunctions = { getReleaseLine: () => Promise.resolve(""), - getDependencyReleaseLine: () => Promise.resolve("") + getDependencyReleaseLine: () => Promise.resolve(""), }; const changelogOpts = config.changelog[1]; @@ -212,16 +230,16 @@ async function getNewChangelogEntry( } let commits = await getCommitsThatAddChangesets( - changesets.map(cs => cs.id), + changesets.map((cs) => cs.id), cwd ); let moddedChangesets = changesets.map((cs, i) => ({ ...cs, - commit: commits[i] + commit: commits[i], })); return Promise.all( - releasesWithPackage.map(async release => { + releasesWithPackage.map(async (release) => { let changelog = await getChangelogEntry( release, releasesWithPackage, @@ -232,16 +250,16 @@ async function getNewChangelogEntry( updateInternalDependencies: config.updateInternalDependencies, onlyUpdatePeerDependentsWhenOutOfRange: config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH - .onlyUpdatePeerDependentsWhenOutOfRange + .onlyUpdatePeerDependentsWhenOutOfRange, } ); return { ...release, - changelog + changelog, }; }) - ).catch(e => { + ).catch((e) => { console.error( "The following error was encountered while generating changelog entries" ); @@ -256,17 +274,25 @@ async function updateChangelog( changelogPath: string, changelog: string, name: string, + prettierInstance: typeof prettier, prettierConfig: prettier.Options | null ) { let templateString = `\n\n${changelog.trim()}\n`; try { if (fs.existsSync(changelogPath)) { - await prependFile(changelogPath, templateString, name, prettierConfig); + await prependFile( + changelogPath, + templateString, + name, + prettierInstance, + prettierConfig + ); } else { await writeFormattedMarkdownFile( changelogPath, `# ${name}${templateString}`, + prettierInstance, prettierConfig ); } @@ -291,7 +317,8 @@ async function prependFile( filePath: string, data: string, name: string, - prettierConfig?: prettier.Options | null + prettierInstance: typeof prettier, + prettierConfig: prettier.Options | null ) { const fileData = fs.readFileSync(filePath).toString(); // if the file exists but doesn't have the header, we'll add it in @@ -300,26 +327,33 @@ async function prependFile( await writeFormattedMarkdownFile( filePath, completelyNewChangelog, + prettierInstance, prettierConfig ); return; } const newChangelog = fileData.replace("\n", data); - await writeFormattedMarkdownFile(filePath, newChangelog, prettierConfig); + await writeFormattedMarkdownFile( + filePath, + newChangelog, + prettierInstance, + prettierConfig + ); } async function writeFormattedMarkdownFile( filePath: string, content: string, - prettierConfig?: prettier.Options | null + prettierInstance: typeof prettier, + prettierConfig: prettier.Options | null ) { await fs.writeFile( filePath, - prettier.format(content, { + prettierInstance.format(content, { ...prettierConfig, filepath: filePath, - parser: "markdown" + parser: "markdown", }) ); } diff --git a/packages/apply-release-plan/src/test-utils/failing-functions.ts b/packages/apply-release-plan/src/test-utils/failing-functions.ts index 863ad751e..f208a4be3 100644 --- a/packages/apply-release-plan/src/test-utils/failing-functions.ts +++ b/packages/apply-release-plan/src/test-utils/failing-functions.ts @@ -4,5 +4,5 @@ export default { }, getDependencyReleaseLine: () => { throw new Error("no chance"); - } + }, }; diff --git a/packages/apply-release-plan/src/test-utils/get-changelog-entry-with-git-hash.ts b/packages/apply-release-plan/src/test-utils/get-changelog-entry-with-git-hash.ts index 8923d863d..0b86cc28a 100644 --- a/packages/apply-release-plan/src/test-utils/get-changelog-entry-with-git-hash.ts +++ b/packages/apply-release-plan/src/test-utils/get-changelog-entry-with-git-hash.ts @@ -8,7 +8,7 @@ import { RelevantChangesets } from "../types"; async function getReleaseLine(changeset: NewChangeset, cwd: string) { const [firstLine, ...futureLines] = changeset.summary .split("\n") - .map(l => l.trimRight()); + .map((l) => l.trimRight()); const commitThatAddsFile = await getCommitThatAddsFile( `.changeset/${changeset.id}.md`, @@ -16,7 +16,7 @@ async function getReleaseLine(changeset: NewChangeset, cwd: string) { ); return `- [${commitThatAddsFile}] ${firstLine}\n${futureLines - .map(l => ` ${l}`) + .map((l) => ` ${l}`) .join("\n")}`; } @@ -25,7 +25,7 @@ async function getReleaseLines( type: keyof RelevantChangesets, cwd: string ) { - const releaseLines = obj[type].map(changeset => + const releaseLines = obj[type].map((changeset) => getReleaseLine(changeset, cwd) ); if (!releaseLines.length) return ""; @@ -62,8 +62,8 @@ export default async function defaultChangelogGetter( `## ${release.newVersion}`, majorReleaseLines, minorReleaseLines, - patchReleaseLines + patchReleaseLines, ] - .filter(line => line) + .filter((line) => line) .join("\n"); } diff --git a/packages/apply-release-plan/src/utils.ts b/packages/apply-release-plan/src/utils.ts index 5a0131ea2..331996d6c 100644 --- a/packages/apply-release-plan/src/utils.ts +++ b/packages/apply-release-plan/src/utils.ts @@ -19,7 +19,7 @@ export function shouldUpdateDependencyBasedOnConfig( release: { version: string; type: VersionType }, { depVersionRange, - depType + depType, }: { depVersionRange: string; depType: @@ -30,7 +30,7 @@ export function shouldUpdateDependencyBasedOnConfig( }, { minReleaseType, - onlyUpdatePeerDependentsWhenOutOfRange + onlyUpdatePeerDependentsWhenOutOfRange, }: { minReleaseType: "patch" | "minor"; onlyUpdatePeerDependentsWhenOutOfRange: boolean; diff --git a/packages/apply-release-plan/src/version-package.ts b/packages/apply-release-plan/src/version-package.ts index 14cff8101..a5087e8f2 100644 --- a/packages/apply-release-plan/src/version-package.ts +++ b/packages/apply-release-plan/src/version-package.ts @@ -1,7 +1,7 @@ import { ComprehensiveRelease, PackageJSON, - VersionType + VersionType, } from "@changesets/types"; import getVersionRangeType from "@changesets/get-version-range-type"; import semver from "semver"; @@ -11,7 +11,7 @@ const DEPENDENCY_TYPES = [ "dependencies", "devDependencies", "peerDependencies", - "optionalDependencies" + "optionalDependencies", ] as const; export default function versionPackage( @@ -25,7 +25,7 @@ export default function versionPackage( updateInternalDependencies, onlyUpdatePeerDependentsWhenOutOfRange, bumpVersionsWithWorkspaceProtocolOnly, - snapshot + snapshot, }: { updateInternalDependencies: "patch" | "minor"; onlyUpdatePeerDependentsWhenOutOfRange: boolean; @@ -50,11 +50,11 @@ export default function versionPackage( { version, type }, { depVersionRange: depCurrentVersion, - depType + depType, }, { minReleaseType: updateInternalDependencies, - onlyUpdatePeerDependentsWhenOutOfRange + onlyUpdatePeerDependentsWhenOutOfRange, } ) ) { diff --git a/packages/assemble-release-plan/src/apply-links.ts b/packages/assemble-release-plan/src/apply-links.ts index 4cea53e27..e954f65ee 100644 --- a/packages/assemble-release-plan/src/apply-links.ts +++ b/packages/assemble-release-plan/src/apply-links.ts @@ -26,7 +26,7 @@ export default function applyLinks( for (let linkedPackages of linked) { // First we filter down to all the relevant releases for one set of linked packages let releasingLinkedPackages = [...releases.values()].filter( - release => + (release) => linkedPackages.includes(release.name) && release.type !== "none" ); diff --git a/packages/assemble-release-plan/src/determine-dependents.ts b/packages/assemble-release-plan/src/determine-dependents.ts index 7a5d9e3d4..da355cff8 100644 --- a/packages/assemble-release-plan/src/determine-dependents.ts +++ b/packages/assemble-release-plan/src/determine-dependents.ts @@ -4,7 +4,7 @@ import { DependencyType, PackageJSON, VersionType, - Config + Config, } from "@changesets/types"; import { Package } from "@manypkg/get-packages"; import { InternalRelease, PreInfo } from "./types"; @@ -27,7 +27,7 @@ export default function determineDependents({ packagesByName, dependencyGraph, preInfo, - config + config, }: { releases: Map; packagesByName: Map; @@ -51,7 +51,7 @@ export default function determineDependents({ ); } pkgDependents - .map(dependent => { + .map((dependent) => { let type: VersionType | undefined; const dependentPackage = packagesByName.get(dependent); @@ -76,7 +76,7 @@ export default function determineDependents({ preInfo, onlyUpdatePeerDependentsWhenOutOfRange: config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH - .onlyUpdatePeerDependentsWhenOutOfRange + .onlyUpdatePeerDependentsWhenOutOfRange, }) ) { type = "major"; @@ -121,7 +121,7 @@ export default function determineDependents({ return { name: dependent, type, - pkgJSON: dependentPackage.packageJson + pkgJSON: dependentPackage.packageJson, }; }) .filter(({ type }) => type) @@ -146,7 +146,7 @@ export default function determineDependents({ name, type, oldVersion: pkgJSON.version, - changesets: [] + changesets: [], }; pkgsToSearch.push(newDependent); @@ -175,7 +175,7 @@ function getDependencyVersionRanges( "dependencies", "devDependencies", "peerDependencies", - "optionalDependencies" + "optionalDependencies", ] as const; const dependencyVersionRanges: { depType: DependencyType; @@ -194,12 +194,12 @@ function getDependencyVersionRanges( versionRange === "workspace:*" ? // workspace:* actually means the current exact version, and not a wildcard similar to a reguler * range dependencyRelease.oldVersion - : versionRange.replace(/^workspace:/, "") + : versionRange.replace(/^workspace:/, ""), }); } else { dependencyVersionRanges.push({ depType: type, - versionRange + versionRange, }); } } @@ -213,7 +213,7 @@ function shouldBumpMajor({ releases, nextRelease, preInfo, - onlyUpdatePeerDependentsWhenOutOfRange + onlyUpdatePeerDependentsWhenOutOfRange, }: { dependent: string; depType: DependencyType; diff --git a/packages/assemble-release-plan/src/flatten-releases.ts b/packages/assemble-release-plan/src/flatten-releases.ts index d02dcb069..0055c1279 100644 --- a/packages/assemble-release-plan/src/flatten-releases.ts +++ b/packages/assemble-release-plan/src/flatten-releases.ts @@ -12,7 +12,7 @@ export default function flattenReleases( ): Map { let releases: Map = new Map(); - changesets.forEach(changeset => { + changesets.forEach((changeset) => { changeset.releases // Filter out ignored packages because they should not trigger a release // If their dependencies need updates, they will be added to releases by `determineDependents()` with release type `none` @@ -30,7 +30,7 @@ export default function flattenReleases( name, type, oldVersion: pkg.packageJson.version, - changesets: [changeset.id] + changesets: [changeset.id], }; } else { if ( diff --git a/packages/assemble-release-plan/src/increment.test.ts b/packages/assemble-release-plan/src/increment.test.ts index ac474cca2..130878111 100644 --- a/packages/assemble-release-plan/src/increment.test.ts +++ b/packages/assemble-release-plan/src/increment.test.ts @@ -8,7 +8,7 @@ describe("incrementVersion", () => { name: "pkg-a", type: "none", changesets: [], - oldVersion: "1.0.0" + oldVersion: "1.0.0", }; const fakePreInfo: PreInfo = { @@ -17,8 +17,8 @@ describe("incrementVersion", () => { mode: "pre", tag: "next", initialVersions: {}, - changesets: [] - } + changesets: [], + }, }; const nextVersion = incrementVersion(fakeRelease, fakePreInfo); diff --git a/packages/assemble-release-plan/src/index.test.ts b/packages/assemble-release-plan/src/index.test.ts index d7c958601..7fbc6c7b3 100644 --- a/packages/assemble-release-plan/src/index.test.ts +++ b/packages/assemble-release-plan/src/index.test.ts @@ -27,7 +27,7 @@ describe("assemble-release-plan", () => { type: "patch", newVersion: "1.0.1", oldVersion: "1.0.0", - changesets: ["strange-words-combine"] + changesets: ["strange-words-combine"], }); }); @@ -38,7 +38,7 @@ describe("assemble-release-plan", () => { defaultConfig, undefined, { - tag: undefined + tag: undefined, } ); @@ -53,7 +53,7 @@ describe("assemble-release-plan", () => { defaultConfig, undefined, { - tag: "foo" + tag: "foo", } ); @@ -67,8 +67,8 @@ describe("assemble-release-plan", () => { releases: [ { name: "pkg-b", type: "patch" }, { name: "pkg-c", type: "patch" }, - { name: "pkg-d", type: "major" } - ] + { name: "pkg-d", type: "major" }, + ], }); let { releases } = assembleReleasePlan( @@ -91,7 +91,7 @@ describe("assemble-release-plan", () => { it("should handle two changesets for a package", () => { setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -112,24 +112,24 @@ describe("assemble-release-plan", () => { releases: [ { name: "pkg-a", type: "none" }, { name: "pkg-b", type: "none" }, - { name: "pkg-c", type: "none" } - ] + { name: "pkg-c", type: "none" }, + ], }); setup.addChangeset({ id: "big-cats-wonder", releases: [ { name: "pkg-a", type: "patch" }, { name: "pkg-b", type: "minor" }, - { name: "pkg-c", type: "major" } - ] + { name: "pkg-c", type: "major" }, + ], }); setup.addChangeset({ id: "big-cats-yelp", releases: [ { name: "pkg-a", type: "none" }, { name: "pkg-b", type: "none" }, - { name: "pkg-c", type: "none" } - ] + { name: "pkg-c", type: "none" }, + ], }); let { releases } = assembleReleasePlan( @@ -157,7 +157,7 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-b", "pkg-a", "^1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -216,7 +216,7 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-b", "pkg-a", "*"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -236,7 +236,7 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-c", "pkg-a", "workspace:^1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -244,7 +244,7 @@ describe("assemble-release-plan", () => { setup.packages, { ...defaultConfig, - bumpVersionsWithWorkspaceProtocolOnly: true + bumpVersionsWithWorkspaceProtocolOnly: true, }, undefined ); @@ -261,7 +261,7 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-c", "pkg-a", "workspace:^"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -269,7 +269,7 @@ describe("assemble-release-plan", () => { setup.packages, { ...defaultConfig, - bumpVersionsWithWorkspaceProtocolOnly: true + bumpVersionsWithWorkspaceProtocolOnly: true, }, undefined ); @@ -291,7 +291,7 @@ describe("assemble-release-plan", () => { setup.updateDevDependency("pkg-b", "pkg-a", "^1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -314,8 +314,8 @@ describe("assemble-release-plan", () => { id: "big-cats-delight", releases: [ { name: "pkg-a", type: "major" }, - { name: "pkg-c", type: "major" } - ] + { name: "pkg-c", type: "major" }, + ], }); let { releases } = assembleReleasePlan( @@ -338,7 +338,7 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-c", "pkg-b", "^1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-b", type: "none" }] + releases: [{ name: "pkg-b", type: "none" }], }); let { releases } = assembleReleasePlan( @@ -358,7 +358,7 @@ describe("assemble-release-plan", () => { setup.updateDevDependency("pkg-b", "pkg-a", "link:../pkg-a"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -376,7 +376,7 @@ describe("assemble-release-plan", () => { setup.updateDevDependency("pkg-b", "pkg-a", "file:../pkg-a"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -394,7 +394,7 @@ describe("assemble-release-plan", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "~1.0.0"); setup.addChangeset({ id: "nonsense-words-combine", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -413,18 +413,18 @@ describe("assemble-release-plan", () => { it("should assemble release plan without ignored packages", () => { setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); setup.addChangeset({ id: "small-dogs-sad", - releases: [{ name: "pkg-b", type: "minor" }] + releases: [{ name: "pkg-b", type: "minor" }], }); const { releases } = assembleReleasePlan( setup.changesets, setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, undefined ); @@ -437,18 +437,18 @@ describe("assemble-release-plan", () => { setup.updateDependency("pkg-b", "pkg-a", "1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); setup.addChangeset({ id: "small-dogs-sad", - releases: [{ name: "pkg-b", type: "minor" }] + releases: [{ name: "pkg-b", type: "minor" }], }); const { releases } = assembleReleasePlan( setup.changesets, setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, undefined ); @@ -464,18 +464,18 @@ describe("assemble-release-plan", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); setup.addChangeset({ id: "small-dogs-sad", - releases: [{ name: "pkg-b", type: "minor" }] + releases: [{ name: "pkg-b", type: "minor" }], }); const { releases } = assembleReleasePlan( setup.changesets, setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, undefined ); @@ -491,18 +491,18 @@ describe("assemble-release-plan", () => { setup.updateDevDependency("pkg-b", "pkg-a", "1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); setup.addChangeset({ id: "small-dogs-sad", - releases: [{ name: "pkg-b", type: "minor" }] + releases: [{ name: "pkg-b", type: "minor" }], }); const { releases } = assembleReleasePlan( setup.changesets, setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, undefined ); @@ -520,8 +520,8 @@ describe("assemble-release-plan", () => { id: "big-cats-delight", releases: [ { name: "pkg-a", type: "major" }, - { name: "pkg-b", type: "minor" } - ] + { name: "pkg-b", type: "minor" }, + ], }); expect(() => @@ -530,7 +530,7 @@ describe("assemble-release-plan", () => { setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, undefined ) @@ -546,7 +546,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo it("should assemble release plan for fixed packages", () => { setup.addChangeset({ id: "just-some-umbrellas", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -554,7 +554,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - fixed: [["pkg-a", "pkg-b"]] + fixed: [["pkg-a", "pkg-b"]], }, undefined ); @@ -568,8 +568,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo id: "just-some-umbrellas", releases: [ { name: "pkg-b", type: "minor" }, - { name: "pkg-a", type: "patch" } - ] + { name: "pkg-a", type: "patch" }, + ], }); setup.updatePackage("pkg-c", "2.0.0"); @@ -579,7 +579,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - fixed: [["pkg-a", "pkg-b", "pkg-c"]] + fixed: [["pkg-a", "pkg-b", "pkg-c"]], }, undefined ); @@ -598,11 +598,11 @@ Mixed changesets that contain both ignored and not ignored packages are not allo // - fixed are checked, pkg-c is aligned with pkg-d setup.addChangeset({ id: "just-some-umbrellas", - releases: [{ name: "pkg-b", type: "major" }] + releases: [{ name: "pkg-b", type: "major" }], }); setup.addChangeset({ id: "totally-average-verbiage", - releases: [{ name: "pkg-d", type: "minor" }] + releases: [{ name: "pkg-d", type: "minor" }], }); setup.updateDependency("pkg-c", "pkg-a", "^1.0.0"); @@ -614,8 +614,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo ...defaultConfig, fixed: [ ["pkg-a", "pkg-b"], - ["pkg-c", "pkg-d"] - ] + ["pkg-c", "pkg-d"], + ], }, undefined ); @@ -633,11 +633,11 @@ Mixed changesets that contain both ignored and not ignored packages are not allo it("should assemble release plan where a fixed constraint causes a dependency to need changing which causes a second fixed group to update 2", () => { setup.addChangeset({ id: "just-some-umbrellas", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); setup.addChangeset({ id: "totally-average-verbiage", - releases: [{ name: "pkg-d", type: "minor" }] + releases: [{ name: "pkg-d", type: "minor" }], }); setup.updateDependency("pkg-c", "pkg-b", "^1.0.0"); @@ -649,8 +649,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo ...defaultConfig, fixed: [ ["pkg-a", "pkg-b"], - ["pkg-c", "pkg-d"] - ] + ["pkg-c", "pkg-d"], + ], }, undefined ); @@ -673,8 +673,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo ...defaultConfig, fixed: [ ["pkg-a", "pkg-b"], - ["pkg-c", "pkg-d"] - ] + ["pkg-c", "pkg-d"], + ], }, undefined ); @@ -687,7 +687,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.addChangeset({ id: "some-id", - releases: [{ type: "minor", name: "pkg-a" }] + releases: [{ type: "minor", name: "pkg-a" }], }); let { releases } = assembleReleasePlan( @@ -695,7 +695,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - fixed: [["pkg-a", "pkg-c"]] + fixed: [["pkg-a", "pkg-c"]], }, undefined ); @@ -703,16 +703,16 @@ Mixed changesets that contain both ignored and not ignored packages are not allo expect(releases).toMatchObject([ { name: "pkg-a", - newVersion: "1.1.0" + newVersion: "1.1.0", }, { name: "pkg-c", - newVersion: "1.1.0" + newVersion: "1.1.0", }, { name: "pkg-b", - newVersion: "2.0.0" - } + newVersion: "2.0.0", + }, ]); }); }); @@ -721,7 +721,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo it("should assemble release plan for linked packages", () => { setup.addChangeset({ id: "just-some-umbrellas", - releases: [{ name: "pkg-b", type: "major" }] + releases: [{ name: "pkg-b", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -729,7 +729,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }, undefined ); @@ -743,8 +743,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo id: "just-some-umbrellas", releases: [ { name: "pkg-b", type: "minor" }, - { name: "pkg-a", type: "patch" } - ] + { name: "pkg-a", type: "patch" }, + ], }); setup.updatePackage("pkg-c", "2.0.0"); @@ -754,7 +754,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - linked: [["pkg-a", "pkg-b", "pkg-c"]] + linked: [["pkg-a", "pkg-b", "pkg-c"]], }, undefined ); @@ -773,11 +773,11 @@ Mixed changesets that contain both ignored and not ignored packages are not allo */ setup.addChangeset({ id: "just-some-umbrellas", - releases: [{ name: "pkg-b", type: "major" }] + releases: [{ name: "pkg-b", type: "major" }], }); setup.addChangeset({ id: "totally-average-verbiage", - releases: [{ name: "pkg-d", type: "minor" }] + releases: [{ name: "pkg-d", type: "minor" }], }); setup.updateDependency("pkg-c", "pkg-a", "^1.0.0"); @@ -789,8 +789,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo ...defaultConfig, linked: [ ["pkg-a", "pkg-b"], - ["pkg-c", "pkg-d"] - ] + ["pkg-c", "pkg-d"], + ], }, undefined ); @@ -809,8 +809,8 @@ Mixed changesets that contain both ignored and not ignored packages are not allo ...defaultConfig, linked: [ ["pkg-a", "pkg-b"], - ["pkg-c", "pkg-d"] - ] + ["pkg-c", "pkg-d"], + ], }, undefined ); @@ -822,7 +822,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.addChangeset({ id: "some-id", - releases: [{ type: "minor", name: "pkg-c" }] + releases: [{ type: "minor", name: "pkg-c" }], }); let { releases } = assembleReleasePlan( @@ -830,7 +830,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - linked: [["pkg-a", "pkg-c"]] + linked: [["pkg-a", "pkg-c"]], }, undefined ); @@ -838,16 +838,16 @@ Mixed changesets that contain both ignored and not ignored packages are not allo expect(releases).toMatchObject([ { name: "pkg-a", - newVersion: "1.1.0" + newVersion: "1.1.0", }, { name: "pkg-c", - newVersion: "1.1.0" + newVersion: "1.1.0", }, { name: "pkg-b", - newVersion: "2.0.0" - } + newVersion: "2.0.0", + }, ]); }); }); @@ -858,13 +858,13 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.changesets, setup.packages, { - ...defaultConfig + ...defaultConfig, }, { changesets: [], tag: "next", initialVersions: {}, - mode: "exit" + mode: "exit", } ); @@ -882,16 +882,16 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.changesets, setup.packages, { - ...defaultConfig + ...defaultConfig, }, { changesets: ["strange-words-combine"], tag: "next", initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, - mode: "exit" + mode: "exit", } ); @@ -912,16 +912,16 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.packages, { ...defaultConfig, - ignore: ["pkg-b"] + ignore: ["pkg-b"], }, { changesets: ["strange-words-combine"], tag: "next", initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, - mode: "exit" + mode: "exit", } ); @@ -939,9 +939,9 @@ Mixed changesets that contain both ignored and not ignored packages are not allo releases: [ { name: "pkg-a", - type: "major" - } - ] + type: "major", + }, + ], }); setup.updatePackage("pkg-a", "2.0.0-next.0"); @@ -951,15 +951,15 @@ Mixed changesets that contain both ignored and not ignored packages are not allo releases: [ { name: "pkg-a", - type: "minor" - } - ] + type: "minor", + }, + ], }); const { releases } = assembleReleasePlan( setup.changesets, setup.packages, { - ...defaultConfig + ...defaultConfig, }, { changesets: ["major-bumping-one"], @@ -967,9 +967,9 @@ Mixed changesets that contain both ignored and not ignored packages are not allo initialVersions: { "pkg-a": "1.0.0", "pkg-b": "1.0.0", - "pkg-c": "1.0.0" + "pkg-c": "1.0.0", }, - mode: "pre" + mode: "pre", } ); @@ -985,7 +985,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.updateDependency("pkg-c", "pkg-b", "workspace:^1.0.0"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-b", type: "none" }] + releases: [{ name: "pkg-b", type: "none" }], }); let { releases } = assembleReleasePlan( @@ -1005,7 +1005,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo setup.updateDependency("pkg-c", "pkg-b", "workspace:*"); setup.addChangeset({ id: "big-cats-delight", - releases: [{ name: "pkg-b", type: "none" }] + releases: [{ name: "pkg-b", type: "none" }], }); let { releases } = assembleReleasePlan( @@ -1069,7 +1069,7 @@ describe("version update thoroughness", () => { it("should path a pinned and tilde dependents when minor versioning", () => { setup.addChangeset({ id: "stuff-and-nonsense", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -1090,7 +1090,7 @@ describe("version update thoroughness", () => { it("should patch pinned, tilde and caret dependents when a major versioning", () => { setup.addChangeset({ id: "stuff-and-nonsense", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -1140,7 +1140,7 @@ describe("bumping peerDeps", () => { setup.changesets = []; setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "none" }] + releases: [{ name: "pkg-a", type: "none" }], }); let { releases } = assembleReleasePlan( @@ -1172,7 +1172,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "~1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -1192,7 +1192,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "~1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -1213,7 +1213,7 @@ describe("bumping peerDeps", () => { setup.changesets = []; setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "none" }] + releases: [{ name: "pkg-a", type: "none" }], }); let { releases } = assembleReleasePlan( @@ -1245,7 +1245,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "^1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -1265,7 +1265,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "^1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "major" }] + releases: [{ name: "pkg-a", type: "major" }], }); let { releases } = assembleReleasePlan( @@ -1287,7 +1287,7 @@ describe("bumping peerDeps", () => { setup.updateDependency("pkg-c", "pkg-b", "^1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -1300,15 +1300,15 @@ describe("bumping peerDeps", () => { expect(releases.length).toBe(3); expect(releases[0]).toMatchObject({ name: "pkg-a", - newVersion: "1.1.0" + newVersion: "1.1.0", }); expect(releases[1]).toMatchObject({ name: "pkg-b", - newVersion: "2.0.0" + newVersion: "2.0.0", }); expect(releases[2]).toMatchObject({ name: "pkg-c", - newVersion: "1.0.1" + newVersion: "1.0.1", }); }); @@ -1317,7 +1317,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "^1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( setup.changesets, @@ -1326,8 +1326,8 @@ describe("bumping peerDeps", () => { ...defaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - onlyUpdatePeerDependentsWhenOutOfRange: true - } + onlyUpdatePeerDependentsWhenOutOfRange: true, + }, }, undefined ); @@ -1348,8 +1348,8 @@ describe("bumping peerDeps", () => { ...defaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - updateInternalDependents: "always" - } + updateInternalDependents: "always", + }, }, undefined ); @@ -1373,8 +1373,8 @@ describe("bumping peerDeps", () => { ...defaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - updateInternalDependents: "always" - } + updateInternalDependents: "always", + }, }, undefined ); @@ -1393,7 +1393,7 @@ describe("bumping peerDeps", () => { setup.updatePeerDependency("pkg-b", "pkg-a", "~1.0.0"); setup.addChangeset({ id: "anyway-the-windblows", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }); let { releases } = assembleReleasePlan( @@ -1403,8 +1403,8 @@ describe("bumping peerDeps", () => { ...defaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - onlyUpdatePeerDependentsWhenOutOfRange: true - } + onlyUpdatePeerDependentsWhenOutOfRange: true, + }, }, undefined ); diff --git a/packages/assemble-release-plan/src/index.ts b/packages/assemble-release-plan/src/index.ts index d68adf10f..3ffb6fa77 100644 --- a/packages/assemble-release-plan/src/index.ts +++ b/packages/assemble-release-plan/src/index.ts @@ -3,7 +3,7 @@ import { Config, NewChangeset, PreState, - PackageGroup + PackageGroup, } from "@changesets/types"; import determineDependents from "./determine-dependents"; import flattenReleases from "./flatten-releases"; @@ -45,7 +45,7 @@ function getSnapshotSuffix( datetime: snapshotRefDate .toISOString() .replace(/\.\d{3}Z$/, "") - .replace(/[^\d]/g, "") + .replace(/[^\d]/g, ""), }; // We need a special handling because we need to handle a case where `--snapshot` is used without any template, @@ -138,9 +138,10 @@ function assembleReleasePlan( ...config, snapshot: { prereleaseTemplate: null, - useCalculatedVersion: (config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH as any) - .useCalculatedVersionForSnapshots - } + useCalculatedVersion: ( + config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH as any + ).useCalculatedVersionForSnapshots, + }, }; const refinedSnapshot: SnapshotReleaseParameters | undefined = typeof snapshot === "string" @@ -150,7 +151,7 @@ function assembleReleasePlan( : snapshot; let packagesByName = new Map( - packages.packages.map(x => [x.packageJson.name, x]) + packages.packages.map((x) => [x.packageJson.name, x]) ); const relevantChangesets = getRelevantChangesets( @@ -177,7 +178,7 @@ function assembleReleasePlan( let dependencyGraph = getDependentsGraph(packages, { bumpVersionsWithWorkspaceProtocolOnly: - refinedConfig.bumpVersionsWithWorkspaceProtocolOnly + refinedConfig.bumpVersionsWithWorkspaceProtocolOnly, }); let releasesValidated = false; @@ -188,7 +189,7 @@ function assembleReleasePlan( packagesByName, dependencyGraph, preInfo, - config: refinedConfig + config: refinedConfig, }); // `releases` might get mutated here @@ -219,7 +220,7 @@ function assembleReleasePlan( name: pkg.packageJson.name, type: "patch", oldVersion: pkg.packageJson.version, - changesets: [] + changesets: [], }); } else if ( existingRelease.type === "none" && @@ -241,7 +242,7 @@ function assembleReleasePlan( return { changesets: relevantChangesets, - releases: [...releases.values()].map(incompleteRelease => { + releases: [...releases.values()].map((incompleteRelease) => { return { ...incompleteRelease, newVersion: snapshotSuffix @@ -251,10 +252,10 @@ function assembleReleasePlan( refinedConfig.snapshot.useCalculatedVersion, snapshotSuffix ) - : getNewVersion(incompleteRelease, preInfo) + : getNewVersion(incompleteRelease, preInfo), }; }), - preState: preInfo?.state + preState: preInfo?.state, }; } @@ -270,7 +271,9 @@ function getRelevantChangesets( const notIgnoredPackages = []; for (const release of changeset.releases) { if ( - ignored.find(ignoredPackageName => ignoredPackageName === release.name) + ignored.find( + (ignoredPackageName) => ignoredPackageName === release.name + ) ) { ignoredPackages.push(release.name); } else { @@ -290,7 +293,9 @@ function getRelevantChangesets( if (preState && preState.mode !== "exit") { let usedChangesetIds = new Set(preState.changesets); - return changesets.filter(changeset => !usedChangesetIds.has(changeset.id)); + return changesets.filter( + (changeset) => !usedChangesetIds.has(changeset.id) + ); } return changesets; @@ -322,10 +327,10 @@ function getPreInfo( let updatedPreState = { ...preState, - changesets: changesets.map(changeset => changeset.id), + changesets: changesets.map((changeset) => changeset.id), initialVersions: { - ...preState.initialVersions - } + ...preState.initialVersions, + }, }; for (const [, pkg] of packagesByName) { @@ -358,7 +363,7 @@ function getPreInfo( return { state: updatedPreState, - preVersions + preVersions, }; } diff --git a/packages/assemble-release-plan/src/match-fixed-constraint.ts b/packages/assemble-release-plan/src/match-fixed-constraint.ts index 672a4eefb..40ea445b4 100644 --- a/packages/assemble-release-plan/src/match-fixed-constraint.ts +++ b/packages/assemble-release-plan/src/match-fixed-constraint.ts @@ -12,7 +12,8 @@ export default function matchFixedConstraint( for (let fixedPackages of config.fixed) { let releasingFixedPackages = [...releases.values()].filter( - release => fixedPackages.includes(release.name) && release.type !== "none" + (release) => + fixedPackages.includes(release.name) && release.type !== "none" ); if (releasingFixedPackages.length === 0) continue; @@ -36,7 +37,7 @@ export default function matchFixedConstraint( name: pkgName, type: highestReleaseType, oldVersion: highestVersion, - changesets: [] + changesets: [], }); continue; } diff --git a/packages/assemble-release-plan/src/test-utils.ts b/packages/assemble-release-plan/src/test-utils.ts index 9645ff20a..2bd16710e 100644 --- a/packages/assemble-release-plan/src/test-utils.ts +++ b/packages/assemble-release-plan/src/test-utils.ts @@ -3,7 +3,7 @@ import { Package, Packages } from "@manypkg/get-packages"; function getPackage({ name, - version + version, }: { name: string; version: string; @@ -11,9 +11,9 @@ function getPackage({ return { packageJson: { name, - version + version, }, - dir: "this-shouldn't-matter" + dir: "this-shouldn't-matter", }; } @@ -30,13 +30,13 @@ function getChangeset( return { id, summary, - releases + releases, }; } function getRelease({ name, - type + type, }: { name: string; type: VersionType; @@ -49,16 +49,16 @@ let getSimpleSetup = () => ({ root: { packageJson: { name: "root", - version: "0.0.0" + version: "0.0.0", }, - dir: "/" + dir: "/", }, packages: [getPackage({ name: "pkg-a", version: "1.0.0" })], - tool: "yarn" as const + tool: "yarn" as const, }, changesets: [ - getChangeset({ releases: [getRelease({ name: "pkg-a", type: "patch" })] }) - ] + getChangeset({ releases: [getRelease({ name: "pkg-a", type: "patch" })] }), + ], }); class FakeFullState { @@ -79,7 +79,7 @@ class FakeFullState { } = {} ) { let changeset = getChangeset(data); - if (this.changesets.find(c => c.id === changeset.id)) { + if (this.changesets.find((c) => c.id === changeset.id)) { throw new Error( `tried to add a second changeset with same id: ${changeset.id}` ); @@ -88,7 +88,7 @@ class FakeFullState { } updateDependency(pkgA: string, pkgB: string, versionRange: string) { - let pkg = this.packages.packages.find(a => a.packageJson.name === pkgA); + let pkg = this.packages.packages.find((a) => a.packageJson.name === pkgA); if (!pkg) throw new Error(`No "${pkgA}" package`); if (!pkg.packageJson.dependencies) { pkg.packageJson.dependencies = {}; @@ -96,7 +96,7 @@ class FakeFullState { pkg.packageJson.dependencies[pkgB] = versionRange; } updateDevDependency(pkgA: string, pkgB: string, versionRange: string) { - let pkg = this.packages.packages.find(a => a.packageJson.name === pkgA); + let pkg = this.packages.packages.find((a) => a.packageJson.name === pkgA); if (!pkg) throw new Error(`No "${pkgA}" package`); if (!pkg.packageJson.devDependencies) { pkg.packageJson.devDependencies = {}; @@ -104,7 +104,7 @@ class FakeFullState { pkg.packageJson.devDependencies[pkgB] = versionRange; } updatePeerDependency(pkgA: string, pkgB: string, versionRange: string) { - let pkg = this.packages.packages.find(a => a.packageJson.name === pkgA); + let pkg = this.packages.packages.find((a) => a.packageJson.name === pkgA); if (!pkg) throw new Error(`No "${pkgA}" package`); if (!pkg.packageJson.peerDependencies) { pkg.packageJson.peerDependencies = {}; @@ -116,7 +116,7 @@ class FakeFullState { let pkg = getPackage({ name, version }); if ( this.packages.packages.find( - c => c.packageJson.name === pkg.packageJson.name + (c) => c.packageJson.name === pkg.packageJson.name ) ) { throw new Error( @@ -126,7 +126,7 @@ class FakeFullState { this.packages.packages.push(pkg); } updatePackage(name: string, version: string) { - let pkg = this.packages.packages.find(c => c.packageJson.name === name); + let pkg = this.packages.packages.find((c) => c.packageJson.name === name); if (!pkg) { throw new Error( `could not update package ${name} because it doesn't exist - try addWorskpace` diff --git a/packages/changelog-git/src/index.ts b/packages/changelog-git/src/index.ts index 263d71fb8..421df904f 100644 --- a/packages/changelog-git/src/index.ts +++ b/packages/changelog-git/src/index.ts @@ -2,7 +2,7 @@ import { NewChangesetWithCommit, VersionType, ChangelogFunctions, - ModCompWithPackage + ModCompWithPackage, } from "@changesets/types"; const getReleaseLine = async ( @@ -11,14 +11,14 @@ const getReleaseLine = async ( ) => { const [firstLine, ...futureLines] = changeset.summary .split("\n") - .map(l => l.trimRight()); + .map((l) => l.trimRight()); let returnVal = `- ${ changeset.commit ? `${changeset.commit}: ` : "" }${firstLine}`; if (futureLines.length > 0) { - returnVal += `\n${futureLines.map(l => ` ${l}`).join("\n")}`; + returnVal += `\n${futureLines.map((l) => ` ${l}`).join("\n")}`; } return returnVal; @@ -31,14 +31,14 @@ const getDependencyReleaseLine = async ( if (dependenciesUpdated.length === 0) return ""; const changesetLinks = changesets.map( - changeset => + (changeset) => `- Updated dependencies${ changeset.commit ? ` [${changeset.commit}]` : "" }` ); const updatedDepenenciesList = dependenciesUpdated.map( - dependency => ` - ${dependency.name}@${dependency.newVersion}` + (dependency) => ` - ${dependency.name}@${dependency.newVersion}` ); return [...changesetLinks, ...updatedDepenenciesList].join("\n"); @@ -46,7 +46,7 @@ const getDependencyReleaseLine = async ( const defaultChangelogFunctions: ChangelogFunctions = { getReleaseLine, - getDependencyReleaseLine + getDependencyReleaseLine, }; export default defaultChangelogFunctions; diff --git a/packages/changelog-github/src/index.test.ts b/packages/changelog-github/src/index.test.ts index fe5b3a40c..a5904a22d 100644 --- a/packages/changelog-github/src/index.test.ts +++ b/packages/changelog-github/src/index.test.ts @@ -11,12 +11,12 @@ jest.mock( commit: "a085003", user: "Andarist", pull: 1613, - repo: "emotion-js/emotion" + repo: "emotion-js/emotion", }; const links = { user: `[@${data.user}](https://github.com/${data.user})`, pull: `[#${data.pull}](https://github.com/${data.repo}/pull/${data.pull})`, - commit: `[\`${data.commit}\`](https://github.com/${data.repo}/commit/${data.commit})` + commit: `[\`${data.commit}\`](https://github.com/${data.repo}/commit/${data.commit})`, }; return { async getInfo({ commit, repo }) { @@ -25,7 +25,7 @@ jest.mock( return { pull: data.pull, user: data.user, - links + links, }; }, async getInfoFromPullRequest({ pull, repo }) { @@ -34,9 +34,9 @@ jest.mock( return { commit: data.commit, user: data.user, - links + links, }; - } + }, }; } ); @@ -54,10 +54,10 @@ const getChangeset = (content: string, commit: string | undefined) => { ` ), id: "some-id", - commit + commit, }, "minor", - { repo: data.repo } + { repo: data.repo }, ] as const; }; @@ -65,16 +65,16 @@ const data = { commit: "a085003", user: "Andarist", pull: 1613, - repo: "emotion-js/emotion" + repo: "emotion-js/emotion", }; describe.each([data.commit, "wrongcommit", undefined])( "with commit from changeset of %s", - commitFromChangeset => { + (commitFromChangeset) => { describe.each(["pr", "pull request", "pull"])( "override pr with %s keyword", - keyword => { - test.each(["with #", "without #"] as const)("%s", async kind => { + (keyword) => { + test.each(["with #", "without #"] as const)("%s", async (kind) => { expect( await getReleaseLine( ...getChangeset( @@ -102,8 +102,8 @@ describe.each([data.commit, "wrongcommit", undefined])( describe.each(["author", "user"])( "override author with %s keyword", - keyword => { - test.each(["with @", "without @"] as const)("%s", async kind => { + (keyword) => { + test.each(["with @", "without @"] as const)("%s", async (kind) => { expect( await getReleaseLine( ...getChangeset( diff --git a/packages/changelog-github/src/index.ts b/packages/changelog-github/src/index.ts index c973c698a..6b9092e5a 100644 --- a/packages/changelog-github/src/index.ts +++ b/packages/changelog-github/src/index.ts @@ -20,22 +20,22 @@ const changelogFunctions: ChangelogFunctions = { const changesetLink = `- Updated dependencies [${( await Promise.all( - changesets.map(async cs => { + changesets.map(async (cs) => { if (cs.commit) { let { links } = await getInfo({ repo: options.repo, - commit: cs.commit + commit: cs.commit, }); return links.commit; } }) ) ) - .filter(_ => _) + .filter((_) => _) .join(", ")}]:`; const updatedDepenenciesList = dependenciesUpdated.map( - dependency => ` - ${dependency.name}@${dependency.newVersion}` + (dependency) => ` - ${dependency.name}@${dependency.newVersion}` ); return [changesetLink, ...updatedDepenenciesList].join("\n"); @@ -69,18 +69,18 @@ const changelogFunctions: ChangelogFunctions = { const [firstLine, ...futureLines] = replacedChangelog .split("\n") - .map(l => l.trimRight()); + .map((l) => l.trimRight()); const links = await (async () => { if (prFromSummary !== undefined) { let { links } = await getInfoFromPullRequest({ repo: options.repo, - pull: prFromSummary + pull: prFromSummary, }); if (commitFromSummary) { links = { ...links, - commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})` + commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`, }; } return links; @@ -89,21 +89,21 @@ const changelogFunctions: ChangelogFunctions = { if (commitToFetchFrom) { let { links } = await getInfo({ repo: options.repo, - commit: commitToFetchFrom + commit: commitToFetchFrom, }); return links; } return { commit: null, pull: null, - user: null + user: null, }; })(); const users = usersFromSummary.length ? usersFromSummary .map( - userFromSummary => + (userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})` ) .join(", ") @@ -112,13 +112,13 @@ const changelogFunctions: ChangelogFunctions = { const prefix = [ links.pull === null ? "" : ` ${links.pull}`, links.commit === null ? "" : ` ${links.commit}`, - users === null ? "" : ` Thanks ${users}!` + users === null ? "" : ` Thanks ${users}!`, ].join(""); return `\n\n-${prefix ? `${prefix} -` : ""} ${firstLine}\n${futureLines - .map(l => ` ${l}`) + .map((l) => ` ${l}`) .join("\n")}`; - } + }, }; export default changelogFunctions; diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 0c0fef2c6..9882b6042 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1194,7 +1194,7 @@ meaning within the community, even though these commands do slightly more than t const getReleaseLine = async (changeset, versionType) => { const indentedSummary = changeset.summary .split("\n") - .map(l => ` ${l}`.trimRight()) + .map((l) => ` ${l}`.trimRight()) .join("\n"); return `- [${versionType}] ${changeset.commit}:\n\n${indentedSummary}`; @@ -1207,10 +1207,10 @@ meaning within the community, even though these commands do slightly more than t const getReleaseLine = async (changeset, type) => { const [firstLine, ...futureLines] = changeset.summary .split("\n") - .map(l => l.trimRight()); + .map((l) => l.trimRight()); return `- ${changeset.commit}: ${firstLine}\n${futureLines - .map(l => ` ${l}`) + .map((l) => ` ${l}`) .join("\n")}`; }; ``` diff --git a/packages/cli/src/commands/add/__tests__/add.ts b/packages/cli/src/commands/add/__tests__/add.ts index b12d4260e..78f8d8138 100644 --- a/packages/cli/src/commands/add/__tests__/add.ts +++ b/packages/cli/src/commands/add/__tests__/add.ts @@ -11,7 +11,7 @@ import { askConfirm, askQuestionWithEditor, askQuestion, - askList + askList, } from "../../../utils/cli-utilities"; import addChangeset from ".."; @@ -32,7 +32,7 @@ git.getChangedPackagesSinceRef.mockImplementation(({ ref }) => { }); // @ts-ignore -const mockUserResponses = mockResponses => { +const mockUserResponses = (mockResponses) => { const summary = mockResponses.summary || "summary message mock"; let majorReleases: Array = []; let minorReleases: Array = []; @@ -47,7 +47,7 @@ const mockUserResponses = mockResponses => { let returnValues = [ Object.keys(mockResponses.releases), majorReleases, - minorReleases + minorReleases, ]; // @ts-ignore askCheckboxPlus.mockImplementation(() => { @@ -58,7 +58,7 @@ const mockUserResponses = mockResponses => { }); let confirmAnswers = { - "Is this your desired changeset?": true + "Is this your desired changeset?": true, }; if (mockResponses.consoleSummaries && mockResponses.editorSummaries) { @@ -76,7 +76,7 @@ const mockUserResponses = mockResponses => { } // @ts-ignore - askConfirm.mockImplementation(question => { + askConfirm.mockImplementation((question) => { question = stripAnsi(question); // @ts-ignore if (confirmAnswers[question]) { @@ -101,7 +101,7 @@ describe("Changesets", () => { expect(call).toEqual( expect.objectContaining({ summary: "summary message mock", - releases: [{ name: "pkg-a", type: "patch" }] + releases: [{ name: "pkg-a", type: "patch" }], }) ); }); @@ -121,7 +121,7 @@ describe("Changesets", () => { mockUserResponses({ releases: { "pkg-a": "patch" }, consoleSummaries, - editorSummaries + editorSummaries, }); await addChangeset(cwd, { empty: false }, defaultConfig); @@ -130,7 +130,7 @@ describe("Changesets", () => { expect(call).toEqual( expect.objectContaining({ summary: expectedSummary, - releases: [{ name: "pkg-a", type: "patch" }] + releases: [{ name: "pkg-a", type: "patch" }], }) ); } @@ -145,14 +145,14 @@ describe("Changesets", () => { askList.mockReturnValueOnce(Promise.resolve("minor")); let confirmAnswers = { - "Is this your desired changeset?": true + "Is this your desired changeset?": true, }; // @ts-ignore askQuestion.mockReturnValueOnce(""); // @ts-ignore askQuestionWithEditor.mockReturnValueOnce(summary); // @ts-ignore - askConfirm.mockImplementation(question => { + askConfirm.mockImplementation((question) => { question = stripAnsi(question); // @ts-ignore if (confirmAnswers[question]) { @@ -169,7 +169,7 @@ describe("Changesets", () => { expect(call).toEqual( expect.objectContaining({ summary: "summary message mock", - releases: [{ name: "single-package", type: "minor" }] + releases: [{ name: "single-package", type: "minor" }], }) ); }); @@ -183,7 +183,7 @@ describe("Changesets", () => { { empty: false }, { ...defaultConfig, - commit: [path.resolve(__dirname, "..", "..", "..", "commit"), null] + commit: [path.resolve(__dirname, "..", "..", "..", "commit"), null], } ); expect(git.add).toHaveBeenCalledTimes(1); @@ -200,7 +200,7 @@ describe("Changesets", () => { expect(call).toEqual( expect.objectContaining({ releases: [], - summary: "" + summary: "", }) ); }); diff --git a/packages/cli/src/commands/add/createChangeset.ts b/packages/cli/src/commands/add/createChangeset.ts index 3f6aab493..f5898b8f2 100644 --- a/packages/cli/src/commands/add/createChangeset.ts +++ b/packages/cli/src/commands/add/createChangeset.ts @@ -44,13 +44,15 @@ async function getPackagesToRelease( // TODO: take objects and be fancy with matching `Which packages would you like to include?`, defaultChoiceList, - x => { + (x) => { // this removes changed packages and unchanged packages from the list // of packages shown after selection if (Array.isArray(x)) { return x - .filter(x => x !== "changed packages" && x !== "unchanged packages") - .map(x => cyan(x)) + .filter( + (x) => x !== "changed packages" && x !== "unchanged packages" + ) + .map((x) => cyan(x)) .join(", "); } return x; @@ -61,17 +63,17 @@ async function getPackagesToRelease( if (allPackages.length > 1) { const unchangedPackagesNames = allPackages .map(({ packageJson }) => packageJson.name) - .filter(name => !changedPackages.includes(name)); + .filter((name) => !changedPackages.includes(name)); const defaultChoiceList = [ { name: "changed packages", - choices: changedPackages + choices: changedPackages, }, { name: "unchanged packages", - choices: unchangedPackagesNames - } + choices: unchangedPackagesNames, + }, ].filter(({ choices }) => choices.length !== 0); let packagesToRelease = await askInitialReleaseQuestion(defaultChoiceList); @@ -85,7 +87,7 @@ async function getPackagesToRelease( } while (packagesToRelease.length === 0); } return packagesToRelease.filter( - pkgName => + (pkgName) => pkgName !== "changed packages" && pkgName !== "unchanged packages" ); } @@ -124,30 +126,30 @@ export default async function createChangeset( [ { name: "all packages", - choices: packagesToRelease.map(pkgName => { + choices: packagesToRelease.map((pkgName) => { return { name: pkgName, message: formatPkgNameAndVersion( pkgName, pkgJsonsByName.get(pkgName)!.version - ) + ), }; - }) - } + }), + }, ], - x => { + (x) => { // this removes changed packages and unchanged packages from the list // of packages shown after selection if (Array.isArray(x)) { return x - .filter(x => x !== "all packages") - .map(x => cyan(x)) + .filter((x) => x !== "all packages") + .map((x) => cyan(x)) .join(", "); } return x; } ) - ).filter(x => x !== "all packages"); + ).filter((x) => x !== "all packages"); for (const pkgName of pkgsThatShouldBeMajorBumped) { // for packages that are under v1, we want to make sure major releases are intended, @@ -170,30 +172,30 @@ export default async function createChangeset( [ { name: "all packages", - choices: [...pkgsLeftToGetBumpTypeFor].map(pkgName => { + choices: [...pkgsLeftToGetBumpTypeFor].map((pkgName) => { return { name: pkgName, message: formatPkgNameAndVersion( pkgName, pkgJsonsByName.get(pkgName)!.version - ) + ), }; - }) - } + }), + }, ], - x => { + (x) => { // this removes changed packages and unchanged packages from the list // of packages shown after selection if (Array.isArray(x)) { return x - .filter(x => x !== "all packages") - .map(x => cyan(x)) + .filter((x) => x !== "all packages") + .map((x) => cyan(x)) .join(", "); } return x; } ) - ).filter(x => x !== "all packages"); + ).filter((x) => x !== "all packages"); for (const pkgName of pkgsThatShouldBeMinorBumped) { pkgsLeftToGetBumpTypeFor.delete(pkgName); @@ -204,7 +206,7 @@ export default async function createChangeset( if (pkgsLeftToGetBumpTypeFor.size !== 0) { log(`The following packages will be ${blue("patch")} bumped:`); - pkgsLeftToGetBumpTypeFor.forEach(pkgName => { + pkgsLeftToGetBumpTypeFor.forEach((pkgName) => { log( formatPkgNameAndVersion(pkgName, pkgJsonsByName.get(pkgName)!.version) ); @@ -246,7 +248,7 @@ export default async function createChangeset( return { confirmed: true, summary, - releases + releases, }; } } catch (err) { @@ -266,6 +268,6 @@ export default async function createChangeset( return { confirmed: false, summary, - releases + releases, }; } diff --git a/packages/cli/src/commands/add/index.ts b/packages/cli/src/commands/add/index.ts index 7a128791b..c15b90f2e 100644 --- a/packages/cli/src/commands/add/index.ts +++ b/packages/cli/src/commands/add/index.ts @@ -27,7 +27,7 @@ export default async function add( { empty, open }: { empty?: boolean; open?: boolean }, config: Config ) { - const packages = (await getPackages(cwd)).packages.filter(pkg => + const packages = (await getPackages(cwd)).packages.filter((pkg) => isListablePackage(config, pkg.packageJson) ); const changesetBase = path.resolve(cwd, ".changeset"); @@ -37,16 +37,16 @@ export default async function add( newChangeset = { confirmed: true, releases: [], - summary: `` + summary: ``, }; } else { const changedPackages = await git.getChangedPackagesSinceRef({ cwd, - ref: config.baseBranch + ref: config.baseBranch, }); const changedPackagesName = changedPackages - .filter(pkg => isListablePackage(config, pkg.packageJson)) - .map(pkg => pkg.packageJson.name); + .filter((pkg) => isListablePackage(config, pkg.packageJson)) + .map((pkg) => pkg.packageJson.name); newChangeset = await createChangeset(changedPackagesName, packages); printConfirmationMessage(newChangeset, packages.length > 1); @@ -54,7 +54,7 @@ export default async function add( if (!newChangeset.confirmed) { newChangeset = { ...newChangeset, - confirmed: await cli.askConfirm("Is this your desired changeset?") + confirmed: await cli.askConfirm("Is this your desired changeset?"), }; } } @@ -78,7 +78,7 @@ export default async function add( } let hasMajorChange = [...newChangeset.releases].find( - c => c.type === "major" + (c) => c.type === "major" ); if (hasMajorChange) { @@ -107,7 +107,7 @@ export default async function add( externalEditor.editor.args.concat([changesetPath]), { detached: true, - stdio: "inherit" + stdio: "inherit", } ); } diff --git a/packages/cli/src/commands/add/messages.ts b/packages/cli/src/commands/add/messages.ts index 2bb83af09..3ebd582b4 100644 --- a/packages/cli/src/commands/add/messages.ts +++ b/packages/cli/src/commands/add/messages.ts @@ -12,8 +12,8 @@ export default function printConfirmationMessage( ) { function getReleasesOfType(type: VersionType) { return changeset.releases - .filter(release => release.type === type) - .map(release => release.name); + .filter((release) => release.type === type) + .map((release) => release.name); } log("\n=== Summary of changesets ==="); const majorReleases = getReleasesOfType("major"); diff --git a/packages/cli/src/commands/init/__tests__/command.ts b/packages/cli/src/commands/init/__tests__/command.ts index 11e6ecd4c..65f460255 100644 --- a/packages/cli/src/commands/init/__tests__/command.ts +++ b/packages/cli/src/commands/init/__tests__/command.ts @@ -10,7 +10,7 @@ const f = fixtures(__dirname); const getPaths = (cwd: string) => ({ readmePath: path.join(cwd, ".changeset/README.md"), - configPath: path.join(cwd, ".changeset/config.json") + configPath: path.join(cwd, ".changeset/config.json"), }); describe("init", () => { @@ -33,14 +33,14 @@ describe("init", () => { true ); await initializeCommand(cwd); - expect( - await fs.readJson(path.join(cwd, ".changeset/config.json")) - ).toEqual({ ...defaultWrittenConfig, baseBranch: "main" }); + expect(await fs.readJson(path.join(cwd, ".changeset/config.json"))).toEqual( + { ...defaultWrittenConfig, baseBranch: "main" } + ); }); it("shouldn't overwrite a config if it does exist", async () => { const cwd = await f.copy("simple-project"); await fs.writeJson(path.join(cwd, ".changeset/config.json"), { - changelog: false + changelog: false, }); expect(fs.pathExistsSync(path.join(cwd, ".changeset/README.md"))).toBe( @@ -49,7 +49,7 @@ describe("init", () => { await initializeCommand(cwd); expect(await fs.readJson(path.join(cwd, ".changeset/config.json"))).toEqual( { - changelog: false + changelog: false, } ); }); diff --git a/packages/cli/src/commands/pre/index.test.ts b/packages/cli/src/commands/pre/index.test.ts index 3f0c43053..fb476cf0d 100644 --- a/packages/cli/src/commands/pre/index.test.ts +++ b/packages/cli/src/commands/pre/index.test.ts @@ -14,20 +14,20 @@ let preStateForSimpleProject: PreState = { changesets: [], initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, mode: "pre", - tag: "next" + tag: "next", }; let preStateForExited: PreState = { changesets: ["slimy-dingos-whisper"], initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, mode: "exit", - tag: "beta" + tag: "beta", }; jest.mock("@changesets/logger"); @@ -73,7 +73,7 @@ describe("enterPre", () => { { ...preStateForExited, mode: "pre", - tag: "next" + tag: "next", } ); expect(mockedLogger.success).toBeCalledWith( @@ -91,9 +91,9 @@ describe("exitPre", () => { ); await pre(cwd, { command: "exit" }); - expect( - await fs.readJson(path.join(cwd, ".changeset", "pre.json")) - ).toEqual({ ...preStateForSimpleProject, mode: "exit" }); + expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( + { ...preStateForSimpleProject, mode: "exit" } + ); }); it("should throw if not in pre", async () => { let cwd = f.copy("simple-project"); diff --git a/packages/cli/src/commands/pre/index.ts b/packages/cli/src/commands/pre/index.ts index 52779c2c0..a4ae4ede1 100644 --- a/packages/cli/src/commands/pre/index.ts +++ b/packages/cli/src/commands/pre/index.ts @@ -4,7 +4,7 @@ import { exitPre, enterPre } from "@changesets/pre"; import { PreExitButNotInPreModeError, PreEnterButInPreModeError, - ExitError + ExitError, } from "@changesets/errors"; export default async function pre( diff --git a/packages/cli/src/commands/publish/__tests__/index.test.ts b/packages/cli/src/commands/publish/__tests__/index.test.ts index e4069a432..f12c2d627 100644 --- a/packages/cli/src/commands/publish/__tests__/index.test.ts +++ b/packages/cli/src/commands/publish/__tests__/index.test.ts @@ -9,7 +9,7 @@ import { silenceLogsInBlock } from "@changesets/test-utils"; let changelogPath = path.resolve(__dirname, "../../changelog"); let modifiedDefaultConfig: Config = { ...defaultConfig, - changelog: [changelogPath, null] + changelog: [changelogPath, null], }; const f = fixtures(__dirname); diff --git a/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts b/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts index 8761e9eb6..29ca9eb41 100644 --- a/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts +++ b/packages/cli/src/commands/publish/__tests__/publishPackages.test.ts @@ -21,13 +21,13 @@ describe("publishPackages", () => { npmUtils.infoAllow404.mockImplementation(() => ({ published: false, pkgInfo: { - version: "1.0.0" - } + version: "1.0.0", + }, })); // @ts-ignore npmUtils.publish.mockImplementation(() => ({ - published: true + published: true, })); }); @@ -40,7 +40,7 @@ describe("publishPackages", () => { await publishPackages({ packages: (await getPackages(cwd)).packages, access: "public", - preState: undefined + preState: undefined, }); expect(npmUtils.getTokenIsRequired).not.toHaveBeenCalled(); }); diff --git a/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts b/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts index c518941bd..4e4aecad0 100644 --- a/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts +++ b/packages/cli/src/commands/publish/__tests__/releaseCommand.test.ts @@ -24,7 +24,7 @@ git.tag.mockImplementation(() => Promise.resolve(true)); publishPackages.mockImplementation(() => Promise.resolve([ { name: "pkg-a", newVersion: "1.1.0", published: true }, - { name: "pkg-b", newVersion: "1.0.1", published: true } + { name: "pkg-b", newVersion: "1.0.1", published: true }, ]) ); diff --git a/packages/cli/src/commands/publish/index.ts b/packages/cli/src/commands/publish/index.ts index 82a20001c..377d5e47c 100644 --- a/packages/cli/src/commands/publish/index.ts +++ b/packages/cli/src/commands/publish/index.ts @@ -8,7 +8,7 @@ import { getPackages } from "@manypkg/get-packages"; import chalk from "chalk"; function logReleases(pkgs: Array<{ name: string; newVersion: string }>) { - const mappedPkgs = pkgs.map(p => `${p.name}@${p.newVersion}`).join("\n"); + const mappedPkgs = pkgs.map((p) => `${p.name}@${p.newVersion}`).join("\n"); log(mappedPkgs); } @@ -63,11 +63,11 @@ export default async function run( access: config.access, otp, preState, - tag: releaseTag + tag: releaseTag, }); - const successful = response.filter(p => p.published); - const unsuccessful = response.filter(p => !p.published); + const successful = response.filter((p) => p.published); + const unsuccessful = response.filter((p) => !p.published); if (successful.length > 0) { success("packages published successfully:"); diff --git a/packages/cli/src/commands/publish/npm-utils.ts b/packages/cli/src/commands/publish/npm-utils.ts index d72805ea2..4b78d93d2 100644 --- a/packages/cli/src/commands/publish/npm-utils.ts +++ b/packages/cli/src/commands/publish/npm-utils.ts @@ -46,12 +46,12 @@ async function getPublishTool( return { name: "pnpm", shouldAddNoGitChecks: - parsed?.major === undefined ? false : parsed.major >= 5 + parsed?.major === undefined ? false : parsed.major >= 5, }; } catch (e) { return { name: "pnpm", - shouldAddNoGitChecks: false + shouldAddNoGitChecks: false, }; } } @@ -60,10 +60,10 @@ export async function getTokenIsRequired() { // Due to a super annoying issue in yarn, we have to manually override this env variable // See: https://github.com/yarnpkg/yarn/issues/2935#issuecomment-355292633 const envOverride = { - npm_config_registry: getCorrectRegistry() + npm_config_registry: getCorrectRegistry(), }; let result = await spawn("npm", ["profile", "get", "--json"], { - env: Object.assign({}, process.env, envOverride) + env: Object.assign({}, process.env, envOverride), }); if (result.code !== 0) { error( @@ -94,7 +94,7 @@ export function getPackageInfo(packageJson: PackageJSON) { packageJson.name, "--registry", getCorrectRegistry(packageJson), - "--json" + "--json", ]); // Github package registry returns empty string when calling npm info @@ -102,8 +102,8 @@ export function getPackageInfo(packageJson: PackageJSON) { if (result.stdout.toString() === "") { return { error: { - code: "E404" - } + code: "E404", + }, }; } return jsonParse(result.stdout.toString()); @@ -172,13 +172,13 @@ async function internalPublish( // Due to a super annoying issue in yarn, we have to manually override this env variable // See: https://github.com/yarnpkg/yarn/issues/2935#issuecomment-355292633 const envOverride = { - npm_config_registry: getCorrectRegistry() + npm_config_registry: getCorrectRegistry(), }; let { code, stdout, stderr } = await spawn( publishTool.name, ["publish", opts.cwd, "--json", ...publishFlags], { - env: Object.assign({}, process.env, envOverride) + env: Object.assign({}, process.env, envOverride), } ); if (code !== 0) { diff --git a/packages/cli/src/commands/publish/publishPackages.ts b/packages/cli/src/commands/publish/publishPackages.ts index f714d46b7..02fce7625 100644 --- a/packages/cli/src/commands/publish/publishPackages.ts +++ b/packages/cli/src/commands/publish/publishPackages.ts @@ -41,7 +41,7 @@ const isCustomRegistry = (registry?: string): boolean => const getTwoFactorState = ({ otp, - publicPackages + publicPackages, }: { otp?: string; publicPackages: Package[]; @@ -49,27 +49,27 @@ const getTwoFactorState = ({ if (otp) { return { token: otp, - isRequired: Promise.resolve(true) + isRequired: Promise.resolve(true), }; } if ( isCI || - publicPackages.some(pkg => + publicPackages.some((pkg) => isCustomRegistry(pkg.packageJson.publishConfig?.registry) ) || isCustomRegistry(process.env.npm_config_registry) ) { return { token: null, - isRequired: Promise.resolve(false) + isRequired: Promise.resolve(false), }; } return { token: null, // note: we're not awaiting this here, we want this request to happen in parallel with getUnpublishedPackages - isRequired: npmUtils.getTokenIsRequired() + isRequired: npmUtils.getTokenIsRequired(), }; }; @@ -78,7 +78,7 @@ export default async function publishPackages({ access, otp, preState, - tag + tag, }: { packages: Package[]; access: AccessType; @@ -86,11 +86,11 @@ export default async function publishPackages({ preState: PreState | undefined; tag?: string; }) { - const packagesByName = new Map(packages.map(x => [x.packageJson.name, x])); - const publicPackages = packages.filter(pkg => !pkg.packageJson.private); + const packagesByName = new Map(packages.map((x) => [x.packageJson.name, x])); + const publicPackages = packages.filter((pkg) => !pkg.packageJson.private); const twoFactorState: TwoFactorState = getTwoFactorState({ otp, - publicPackages + publicPackages, }); const unpublishedPackagesInfo = await getUnpublishedPackages( publicPackages, @@ -102,7 +102,7 @@ export default async function publishPackages({ } return Promise.all( - unpublishedPackagesInfo.map(pkgInfo => { + unpublishedPackagesInfo.map((pkgInfo) => { let pkg = packagesByName.get(pkgInfo.name)!; return publishAPackage( pkg, @@ -135,7 +135,7 @@ async function publishAPackage( { cwd: publishDir, access: localAccess || access, - tag + tag, }, twoFactorState ); @@ -143,7 +143,7 @@ async function publishAPackage( return { name, newVersion: version, - published: publishConfirmation.published + published: publishConfirmation.published, }; } @@ -174,7 +174,7 @@ async function getUnpublishedPackages( name: packageJson.name, localVersion: packageJson.version, publishedState: publishedState, - publishedVersions: response.pkgInfo.versions || [] + publishedVersions: response.pkgInfo.versions || [], }; }) ); diff --git a/packages/cli/src/commands/status/__tests__/status.ts b/packages/cli/src/commands/status/__tests__/status.ts index a661cad6a..f8b2bfb5d 100644 --- a/packages/cli/src/commands/status/__tests__/status.ts +++ b/packages/cli/src/commands/status/__tests__/status.ts @@ -22,8 +22,8 @@ const simpleChangeset: NewChangeset = { summary: "This is a summary", releases: [ { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" } - ] + { name: "pkg-b", type: "patch" }, + ], }; const simpleReleasePlan: ReleasePlan = { @@ -33,42 +33,42 @@ const simpleReleasePlan: ReleasePlan = { type: "minor", changesets: ["ascii"], oldVersion: "1.0.0", - newVersion: "1.1.0" + newVersion: "1.1.0", }, { name: "pkg-b", type: "patch", changesets: ["ascii"], oldVersion: "1.0.0", - newVersion: "1.0.1" - } + newVersion: "1.0.1", + }, ], changesets: [ { summary: "This is a summary", releases: [ { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" } + { name: "pkg-b", type: "patch" }, ], - id: "ascii" - } + id: "ascii", + }, ], - preState: undefined + preState: undefined, }; const simpleChangedPackagesList: Package[] = [ { packageJson: { name: "pkg-a", version: "1.0.0", dependencies: {} }, - dir: "/fake/folder/doesnt/matter" + dir: "/fake/folder/doesnt/matter", }, { packageJson: { name: "pkg-b", version: "1.0.0" }, - dir: "/fake/folder/doesnt/matter" - } + dir: "/fake/folder/doesnt/matter", + }, ]; const writeChangesets = (changesets: NewChangeset[], cwd: string) => { - return Promise.all(changesets.map(commit => writeChangeset(commit, cwd))); + return Promise.all(changesets.map((commit) => writeChangeset(commit, cwd))); }; describe("status", () => { @@ -118,7 +118,7 @@ describe("status", () => { expect(releaseObj).toEqual({ changesets: [], releases: [], - preState: undefined + preState: undefined, }); }); diff --git a/packages/cli/src/commands/status/index.ts b/packages/cli/src/commands/status/index.ts index 81530d53d..ad4937278 100644 --- a/packages/cli/src/commands/status/index.ts +++ b/packages/cli/src/commands/status/index.ts @@ -10,7 +10,7 @@ import { VersionType, Release, ComprehensiveRelease, - Config + Config, } from "@changesets/types"; export default async function getStatus( @@ -19,7 +19,7 @@ export default async function getStatus( sinceMaster, since, verbose, - output + output, }: { sinceMaster?: boolean; since?: string; @@ -40,7 +40,7 @@ export default async function getStatus( const { changesets, releases } = releasePlan; const changedPackages = await git.getChangedPackagesSinceRef({ cwd, - ref: sinceBranch || config.baseBranch + ref: sinceBranch || config.baseBranch, }); if (changedPackages.length > 0 && changesets.length === 0) { @@ -72,7 +72,7 @@ export default async function getStatus( } function SimplePrint(type: VersionType, releases: Array) { - const packages = releases.filter(r => r.type === type); + const packages = releases.filter((r) => r.type === type); if (packages.length) { info(chalk`Packages to be bumped at {green ${type}}:\n`); @@ -87,7 +87,7 @@ function verbosePrint( type: VersionType, releases: Array ) { - const packages = releases.filter(r => r.type === type); + const packages = releases.filter((r) => r.type === type); if (packages.length) { info(chalk`Packages to be bumped at {green ${type}}`); @@ -95,7 +95,7 @@ function verbosePrint( ({ name, newVersion: version, changesets }) => [ chalk.green(name), version, - changesets.map(c => chalk.blue(` .changeset/${c}.md`)).join(" +") + changesets.map((c) => chalk.blue(` .changeset/${c}.md`)).join(" +"), ] ); @@ -103,7 +103,7 @@ function verbosePrint( [ { value: "Package Name", width: 20 }, { value: "New Version", width: 20 }, - { value: "Related Changeset Summaries", width: 70 } + { value: "Related Changeset Summaries", width: 70 }, ], columns, { paddingLeft: 1, paddingRight: 0, headerAlign: "center", align: "left" } diff --git a/packages/cli/src/commands/tag/__tests__/index.test.ts b/packages/cli/src/commands/tag/__tests__/index.test.ts index 117c6e9c5..67034d512 100644 --- a/packages/cli/src/commands/tag/__tests__/index.test.ts +++ b/packages/cli/src/commands/tag/__tests__/index.test.ts @@ -30,7 +30,7 @@ describe("tag command", () => { (git.getAllTags as jest.Mock).mockReturnValue( new Set([ // pkg-a should not be re-tagged - "pkg-a@1.0.0" + "pkg-a@1.0.0", ]) ); diff --git a/packages/cli/src/commands/version/index.ts b/packages/cli/src/commands/version/index.ts index 3dff717d4..6f3b5f651 100644 --- a/packages/cli/src/commands/version/index.ts +++ b/packages/cli/src/commands/version/index.ts @@ -32,12 +32,12 @@ export default async function version( const releaseConfig = { ...config, // Disable committing when in snapshot mode - commit: options.snapshot ? false : config.commit + commit: options.snapshot ? false : config.commit, }; const [changesets, preState] = await Promise.all([ readChangesets(cwd), readPreState(cwd), - removeEmptyFolders(path.resolve(cwd, ".changeset")) + removeEmptyFolders(path.resolve(cwd, ".changeset")), ]); if (preState?.mode === "pre") { @@ -76,7 +76,7 @@ export default async function version( tag: options.snapshot === true ? undefined : options.snapshot, commit: config.snapshot.prereleaseTemplate?.includes("{commit}") ? await getCurrentCommitId({ cwd }) - : undefined + : undefined, } : undefined ); diff --git a/packages/cli/src/commands/version/version.test.ts b/packages/cli/src/commands/version/version.test.ts index e4fe9e0ec..21ab085cd 100644 --- a/packages/cli/src/commands/version/version.test.ts +++ b/packages/cli/src/commands/version/version.test.ts @@ -50,11 +50,11 @@ let changelogPath = path.resolve(__dirname, "../../changelog"); let commitPath = path.resolve(__dirname, "../../commit"); let modifiedDefaultConfig: Config = { ...defaultConfig, - changelog: [changelogPath, null] + changelog: [changelogPath, null], }; let defaultOptions = { - snapshot: undefined + snapshot: undefined, }; // avoid polluting test logs with error message in console @@ -71,7 +71,7 @@ git.add.mockImplementation(() => Promise.resolve(true)); // @ts-ignore git.commit.mockImplementation(() => Promise.resolve(true)); // @ts-ignore -git.getCommitsThatAddFiles.mockImplementation(changesetIds => +git.getCommitsThatAddFiles.mockImplementation((changesetIds) => Promise.resolve(changesetIds.map(() => "g1th4sh")) ); // @ts-ignore @@ -83,33 +83,33 @@ git.tag.mockImplementation(() => Promise.resolve(true)); const simpleChangeset: NewChangeset = { summary: "This is a summary", releases: [{ name: "pkg-a", type: "minor" }], - id: "having-lotsof-fun" + id: "having-lotsof-fun", }; const simpleChangeset2: NewChangeset = { summary: "This is a summary too", releases: [ { name: "pkg-a", type: "minor" }, - { name: "pkg-b", type: "patch" } + { name: "pkg-b", type: "patch" }, ], - id: "wouldnit-be-nice" + id: "wouldnit-be-nice", }; const simpleChangeset3: NewChangeset = { summary: "This is not a summary", releases: [{ name: "pkg-b", type: "patch" }], - id: "hot-day-today" + id: "hot-day-today", }; const writeChangesets = (changesets: NewChangeset[], cwd: string) => { return Promise.all( - changesets.map(changeset => writeChangeset(changeset, cwd)) + changesets.map((changeset) => writeChangeset(changeset, cwd)) ); }; const getFile = (pkgName: string, fileName: string, calls: any) => { let castCalls: [string, string][] = calls; - const foundCall = castCalls.find(call => + const foundCall = castCalls.find((call) => call[0].endsWith(`${pkgName}${path.sep}${fileName}`) ); if (!foundCall) @@ -190,7 +190,7 @@ describe("running version in a simple project", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - ignore: ["pkg-a"] + ignore: ["pkg-a"], }); const bumpedPackageA = !!spy.mock.calls.find((call: string[]) => @@ -205,10 +205,10 @@ describe("running version in a simple project", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - ignore: ["pkg-a"] + ignore: ["pkg-a"], }); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -245,7 +245,7 @@ describe("running version in a simple project", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - commit: [commitPath, null] + commit: [commitPath, null], }); expect(spy).toHaveBeenCalled(); @@ -267,7 +267,7 @@ describe("running version in a simple project", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - commit: [commitPath, null] + commit: [commitPath, null], }); expect(spy).toHaveBeenCalled(); @@ -287,18 +287,18 @@ describe("running version in a simple project", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "1.0.0" - } + "pkg-b": "1.0.0", + }, }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); const changesetDir = await fs.readdir(path.join(cwd, ".changeset")); @@ -312,14 +312,14 @@ describe("running version in a simple project", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -361,14 +361,14 @@ describe("running version in a simple project", () => { expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }) ); // second should be a patch expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-b", - version: "1.0.1" + version: "1.0.1", }) ); }); @@ -390,7 +390,7 @@ describe("fixed", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - fixed: [["pkg-a", "pkg-b"]] + fixed: [["pkg-a", "pkg-b"]], }); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( @@ -408,10 +408,10 @@ describe("fixed", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, fixed: [["pkg-a", "pkg-b"]], - ignore: ["pkg-a"] + ignore: ["pkg-a"], }); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -437,7 +437,7 @@ describe("fixed", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - fixed: [["pkg-a", "pkg-b"]] + fixed: [["pkg-a", "pkg-b"]], }); expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(` @@ -467,7 +467,7 @@ describe("fixed", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - fixed: [["pkg-a", "pkg-b"]] + fixed: [["pkg-a", "pkg-b"]], }); expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(` @@ -513,7 +513,7 @@ describe("linked", () => { await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( @@ -545,18 +545,18 @@ describe("workspace range", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "workspace:1.0.1" - } + "pkg-b": "workspace:1.0.1", + }, }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); }); @@ -566,25 +566,25 @@ describe("workspace range", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.0.1", dependencies: { - "pkg-b": "workspace:*" - } + "pkg-b": "workspace:*", + }, }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); }); @@ -594,30 +594,30 @@ describe("workspace range", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.0.1", dependencies: { "pkg-b": "workspace:^", - "pkg-c": "workspace:~" - } + "pkg-c": "workspace:~", + }, }, { name: "pkg-b", - version: "1.0.1" + version: "1.0.1", }, { name: "pkg-c", - version: "1.0.0" - } + version: "1.0.0", + }, ]); }); }); @@ -630,10 +630,10 @@ describe("same package in different dependency types", () => { releases: [ { name: "pkg-b", - type: "patch" - } + type: "patch", + }, ], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -641,21 +641,21 @@ describe("same package in different dependency types", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { devDependencies: { - "pkg-b": "1.0.1" + "pkg-b": "1.0.1", }, peerDependencies: { - "pkg-b": "^1.0.1" + "pkg-b": "^1.0.1", }, name: "pkg-a", - version: "1.0.0" + version: "1.0.0", }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); }); }); @@ -668,24 +668,24 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: "experimental" + snapshot: "experimental", }, { ...modifiedDefaultConfig, - commit: false + commit: false, } ); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-a", - version: expect.stringContaining("0.0.0-experimental-") + version: expect.stringContaining("0.0.0-experimental-"), }) ); expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-b", - version: expect.stringContaining("0.0.0-experimental-") + version: expect.stringContaining("0.0.0-experimental-"), }) ); }); @@ -700,11 +700,11 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: "experimental" + snapshot: "experimental", }, { ...modifiedDefaultConfig, - commit: [commitPath, null] + commit: [commitPath, null], } ); @@ -716,7 +716,7 @@ describe("snapshot release", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "none" }], - summary: "some internal stuff" + summary: "some internal stuff", }, cwd ); @@ -724,12 +724,12 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: true + snapshot: true, }, modifiedDefaultConfig ); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -754,7 +754,7 @@ describe("snapshot release", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); @@ -762,15 +762,15 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: true + snapshot: true, }, { ...modifiedDefaultConfig, - ignore: ["pkg-a"] + ignore: ["pkg-a"], } ); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -804,8 +804,8 @@ describe("snapshot release", () => { commit: false, snapshot: { ...modifiedDefaultConfig.snapshot, - prereleaseTemplate: `{tag}.{commit}` - } + prereleaseTemplate: `{tag}.{commit}`, + }, } ) ).rejects.toThrow( @@ -827,8 +827,8 @@ describe("snapshot release", () => { commit: false, snapshot: { ...modifiedDefaultConfig.snapshot, - prereleaseTemplate: `{commit}` - } + prereleaseTemplate: `{commit}`, + }, } ) ).rejects.toThrow( @@ -847,13 +847,13 @@ describe("snapshot release", () => { [ "{tag}.{timestamp}.{commit}", "alpha", - "0.0.0-alpha.1639354050879.abcdef" + "0.0.0-alpha.1639354050879.abcdef", ], ["{datetime}-{tag}", "alpha", "0.0.0-20211213000730-alpha"], // Legacy support ["", "test", "0.0.0-test-20211213000730"], [undefined, "canary", "0.0.0-canary-20211213000730"], - [null, "alpha", "0.0.0-alpha-20211213000730"] + [null, "alpha", "0.0.0-alpha-20211213000730"], ])( "should customize release correctly based on snapshotPrereleaseTemplate template: %p (tag: '%p')", mockGlobalDate( @@ -869,22 +869,22 @@ describe("snapshot release", () => { commit: false, snapshot: { ...modifiedDefaultConfig.snapshot, - prereleaseTemplate: snapshotTemplate as string - } + prereleaseTemplate: snapshotTemplate as string, + }, } ); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-a", - version: expectedResult + version: expectedResult, }) ); expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-b", - version: expectedResult + version: expectedResult, }) ); } @@ -900,28 +900,28 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: "experimental" + snapshot: "experimental", }, { ...modifiedDefaultConfig, commit: false, snapshot: { useCalculatedVersion: true, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-a", - version: expect.stringContaining("1.1.0-experimental-") + version: expect.stringContaining("1.1.0-experimental-"), }) ); expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-b", - version: expect.stringContaining("1.0.1-experimental-") + version: expect.stringContaining("1.0.1-experimental-"), }) ); }); @@ -931,7 +931,7 @@ describe("snapshot release", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "none" }], - summary: "some internal stuff" + summary: "some internal stuff", }, cwd ); @@ -939,18 +939,18 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: true + snapshot: true, }, { ...modifiedDefaultConfig, snapshot: { useCalculatedVersion: true, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -975,7 +975,7 @@ describe("snapshot release", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); @@ -983,19 +983,19 @@ describe("snapshot release", () => { await version( cwd, { - snapshot: true + snapshot: true, }, { ...modifiedDefaultConfig, ignore: ["pkg-a"], snapshot: { useCalculatedVersion: true, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, } ); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1025,8 +1025,8 @@ describe("updateInternalDependents: always", () => { ...modifiedDefaultConfig, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - updateInternalDependents: "always" - } + updateInternalDependents: "always", + }, }); expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual( @@ -1034,14 +1034,14 @@ describe("updateInternalDependents: always", () => { name: "pkg-a", version: "1.0.1", dependencies: { - "pkg-b": "^1.0.1" - } + "pkg-b": "^1.0.1", + }, }) ); expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( expect.objectContaining({ name: "pkg-b", - version: "1.0.1" + version: "1.0.1", }) ); expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(` @@ -1075,92 +1075,92 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "1.0.1-next.0" + "pkg-b": "1.0.1-next.0", }, name: "pkg-a", - version: "1.0.1-next.0" + version: "1.0.1-next.0", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "1.0.1-next.0" + "pkg-b": "1.0.1-next.0", }, name: "pkg-a", - version: "1.0.1-next.1" + version: "1.0.1-next.1", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary for the second change" + summary: "a very useful summary for the second change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "1.0.1-next.0" + "pkg-b": "1.0.1-next.0", }, name: "pkg-a", - version: "1.0.1-next.2" + version: "1.0.1-next.2", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], - summary: "a very useful summary for the third change" + summary: "a very useful summary for the third change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toMatchInlineSnapshot( + expect(packages.packages.map((x) => x.packageJson)).toMatchInlineSnapshot( [ { dependencies: { - "pkg-b": "1.0.1-next.0" + "pkg-b": "1.0.1-next.0", }, name: "pkg-a", - version: "1.1.0-next.3" + version: "1.1.0-next.3", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ], ` Object { @@ -1181,18 +1181,18 @@ describe("pre", () => { await pre(cwd, { command: "exit" }); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "1.0.1" + "pkg-b": "1.0.1", }, name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); expect( await fs.readFile( @@ -1269,60 +1269,60 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "1.0.1-next.0" + "pkg-b": "1.0.1-next.0", }, name: "pkg-a", - version: "1.0.1-next.0" + version: "1.0.1-next.0", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ]); await fs.mkdir(path.join(cwd, "packages", "pkg-c")); await fs.writeJson(path.join(cwd, "packages", "pkg-c", "package.json"), { name: "pkg-c", - version: "0.0.0" + version: "0.0.0", }); await writeChangeset( { releases: [ { name: "pkg-b", type: "major" }, - { name: "pkg-c", type: "patch" } + { name: "pkg-c", type: "patch" }, ], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "2.0.0-next.1" + "pkg-b": "2.0.0-next.1", }, name: "pkg-a", - version: "1.0.1-next.1" + version: "1.0.1-next.1", }, { name: "pkg-b", - version: "2.0.0-next.1" + version: "2.0.0-next.1", }, { name: "pkg-c", - version: "0.0.1-next.0" - } + version: "0.0.1-next.0", + }, ]); }); it("should work for my weird case", async () => { @@ -1330,46 +1330,46 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "1.1.1-next.0" + version: "1.1.1-next.0", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); }); // https://github.com/changesets/changesets/pull/382#discussion_r434434182 @@ -1379,43 +1379,43 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "^1.0.1-next.0" + "pkg-b": "^1.0.1-next.0", }, name: "pkg-a", - version: "1.0.1-next.0" + version: "1.0.1-next.0", }, { name: "pkg-b", - version: "1.0.1-next.0" - } + version: "1.0.1-next.0", + }, ]); await pre(cwd, { command: "exit" }); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { - "pkg-b": "^1.0.1" + "pkg-b": "^1.0.1", }, name: "pkg-a", - version: "1.0.1" + version: "1.0.1", }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); }); @@ -1424,7 +1424,7 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -1433,38 +1433,38 @@ describe("pre", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "2.0.0-next.0" + version: "2.0.0-next.0", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], - summary: "a very useful summary for the second change" + summary: "a very useful summary for the second change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "2.0.0-next.1" + version: "2.0.0-next.1", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); }); it("should use the highest bump type between all prereleases when versioning a dependent package", async () => { @@ -1474,7 +1474,7 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -1482,38 +1482,38 @@ describe("pre", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "2.0.0-next.0" + version: "2.0.0-next.0", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-b", type: "minor" }], - summary: "a very useful summary for the second change" + summary: "a very useful summary for the second change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "2.0.0-next.1", - dependencies: { "pkg-b": "1.1.0-next.0" } + dependencies: { "pkg-b": "1.1.0-next.0" }, }, { name: "pkg-b", - version: "1.1.0-next.0" - } + version: "1.1.0-next.0", + }, ]); }); @@ -1522,7 +1522,7 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -1531,16 +1531,16 @@ describe("pre", () => { await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { devDependencies: { "pkg-b": "2.0.0-next.0" }, name: "pkg-a", - version: "1.0.0" + version: "1.0.0", }, { name: "pkg-b", - version: "2.0.0-next.0" - } + version: "2.0.0-next.0", + }, ]); }); it("should not bump ignored packages through dependencies", async () => { @@ -1548,7 +1548,7 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "major" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -1556,7 +1556,7 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "major" }], - summary: "a very useful summary for the first change" + summary: "a very useful summary for the first change", }, cwd ); @@ -1564,20 +1564,20 @@ describe("pre", () => { await pre(cwd, { command: "enter", tag: "next" }); await version(cwd, defaultOptions, { ...modifiedDefaultConfig, - ignore: ["pkg-a"] + ignore: ["pkg-a"], }); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "2.0.0-next.0" }, name: "pkg-a", - version: "1.0.0" + version: "1.0.0", }, { name: "pkg-b", - version: "2.0.0-next.0" - } + version: "2.0.0-next.0", + }, ]); }); it("should bump dependent of prerelease package when bumping a `workspace:~` dependency", async () => { @@ -1587,30 +1587,30 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-c", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); let packages = await getPackages(cwd); - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.0.1-alpha.0", dependencies: { "pkg-b": "workspace:^", - "pkg-c": "workspace:~" - } + "pkg-c": "workspace:~", + }, }, { name: "pkg-b", - version: "1.0.0" + version: "1.0.0", }, { name: "pkg-c", - version: "1.0.1-alpha.0" - } + version: "1.0.1-alpha.0", + }, ]); }); @@ -1622,14 +1622,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1649,14 +1649,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1682,14 +1682,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1715,14 +1715,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1748,14 +1748,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1786,14 +1786,14 @@ describe("pre", () => { await writeChangeset( { releases: [{ name: "pkg-c", type: "patch" }], - summary: "a very useful summary for the change" + summary: "a very useful summary for the change", }, cwd ); await version(cwd, defaultOptions, modifiedDefaultConfig); - expect((await getPackages(cwd)).packages.map(x => x.packageJson)) + expect((await getPackages(cwd)).packages.map((x) => x.packageJson)) .toMatchInlineSnapshot(` Array [ Object { @@ -1820,180 +1820,180 @@ describe("pre", () => { it("should work with linked", async () => { let linkedConfig = { ...modifiedDefaultConfig, - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }; let cwd = f.copy("simple-project"); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.0.0" }, name: "pkg-a", - version: "1.1.0" + version: "1.1.0", }, { name: "pkg-b", - version: "1.0.0" - } + version: "1.0.0", + }, ]); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.1.1-next.0" }, name: "pkg-a", - version: "1.1.1-next.0" + version: "1.1.1-next.0", }, { name: "pkg-b", - version: "1.1.1-next.0" - } + version: "1.1.1-next.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.1.1-next.0" }, name: "pkg-a", - version: "1.1.1-next.1" + version: "1.1.1-next.1", }, { name: "pkg-b", - version: "1.1.1-next.0" - } + version: "1.1.1-next.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-a", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { dependencies: { "pkg-b": "1.1.1-next.0" }, name: "pkg-a", - version: "1.1.1-next.2" + version: "1.1.1-next.2", }, { name: "pkg-b", - version: "1.1.1-next.0" - } + version: "1.1.1-next.0", + }, ]); }); it("should use the highest bump type between all prereleases for a linked package when versioning a dependent package", async () => { let linkedConfig = { ...modifiedDefaultConfig, - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }; let cwd = f.copy("linked-and-not-linked-packages"); await pre(cwd, { command: "enter", tag: "next" }); await writeChangeset( { releases: [{ name: "pkg-a", type: "minor" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", - version: "1.1.0-next.0" + version: "1.1.0-next.0", }, { name: "pkg-b", version: "1.0.0", - dependencies: { "pkg-c": "0.1.0" } + dependencies: { "pkg-c": "0.1.0" }, }, { name: "pkg-c", - version: "0.1.0" - } + version: "0.1.0", + }, ]); await writeChangeset( { releases: [{ name: "pkg-c", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", - version: "1.1.0-next.0" + version: "1.1.0-next.0", }, { name: "pkg-b", version: "1.1.0-next.1", - dependencies: { "pkg-c": "0.1.1-next.0" } + dependencies: { "pkg-c": "0.1.1-next.0" }, }, { name: "pkg-c", - version: "0.1.1-next.0" - } + version: "0.1.1-next.0", + }, ]); }); it("should not bump a linked package if its linked devDep gets released", async () => { let linkedConfig = { ...modifiedDefaultConfig, - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }; let cwd = f.copy("linked-packages-with-linked-dev-dep"); await writeChangeset( { releases: [{ name: "pkg-b", type: "patch" }], - summary: "a very useful summary" + summary: "a very useful summary", }, cwd ); await version(cwd, defaultOptions, linkedConfig); let packages = (await getPackages(cwd))!; - expect(packages.packages.map(x => x.packageJson)).toEqual([ + expect(packages.packages.map((x) => x.packageJson)).toEqual([ { name: "pkg-a", version: "1.0.0", - devDependencies: { "pkg-b": "1.0.1" } + devDependencies: { "pkg-b": "1.0.1" }, }, { name: "pkg-b", - version: "1.0.1" - } + version: "1.0.1", + }, ]); }); }); diff --git a/packages/cli/src/commit/commit.test.ts b/packages/cli/src/commit/commit.test.ts index 2564dcd90..cd2af9711 100644 --- a/packages/cli/src/commit/commit.test.ts +++ b/packages/cli/src/commit/commit.test.ts @@ -5,16 +5,16 @@ import { NewChangeset, ReleasePlan } from "@changesets/types"; const simpleChangeset: NewChangeset = { summary: "This is a summary", releases: [{ name: "package-a", type: "minor" }], - id: "abc123xy" + id: "abc123xy", }; const simpleChangeset2: NewChangeset = { summary: "This is another summary", releases: [ { name: "package-a", type: "patch" }, - { name: "package-b", type: "minor" } + { name: "package-b", type: "minor" }, ], - id: "abc123fh" + id: "abc123fh", }; let simpleReleasePlan: ReleasePlan = { @@ -25,10 +25,10 @@ let simpleReleasePlan: ReleasePlan = { type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: [simpleChangeset.id] - } + changesets: [simpleChangeset.id], + }, ], - preState: undefined + preState: undefined, }; let secondReleasePlan: ReleasePlan = { @@ -39,17 +39,17 @@ let secondReleasePlan: ReleasePlan = { type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: [simpleChangeset.id] + changesets: [simpleChangeset.id], }, { name: "package-b", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: [simpleChangeset2.id] - } + changesets: [simpleChangeset2.id], + }, ], - preState: undefined + preState: undefined, }; describe("defaultCommitFunctions", () => { @@ -62,9 +62,9 @@ describe("defaultCommitFunctions", () => { releases: [ { name: "package-a", - type: "minor" - } - ] + type: "minor", + }, + ], }, { skipCI: "version" } ); @@ -78,9 +78,9 @@ describe("defaultCommitFunctions", () => { releases: [ { name: "package-a", - type: "minor" - } - ] + type: "minor", + }, + ], }, { skipCI: "add" } ); @@ -94,7 +94,7 @@ describe("defaultCommitFunctions", () => { it("should handle a single simple releaseObject with one released package - skipCI", async () => { const commitStr = await getVersionMessage(simpleReleasePlan, { - skipCI: "version" + skipCI: "version", }); expect(commitStr).toEqual(outdent` RELEASING: Releasing 1 package(s) @@ -109,7 +109,7 @@ describe("defaultCommitFunctions", () => { it("should handle a single simple releaseObject with one released package", async () => { const commitStr = await getVersionMessage(simpleReleasePlan, { - skipCI: false + skipCI: false, }); expect(commitStr).toEqual(outdent` RELEASING: Releasing 1 package(s) @@ -129,20 +129,20 @@ describe("defaultCommitFunctions", () => { type: "patch", oldVersion: "1.0.0", newVersion: "1.0.1", - changesets: [simpleChangeset.id] + changesets: [simpleChangeset.id], }, { name: "package-b", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: [simpleChangeset2.id] - } + changesets: [simpleChangeset2.id], + }, ], - preState: undefined + preState: undefined, }; const commitStr = await getVersionMessage(releasePlan, { - skipCI: "version" + skipCI: "version", }); expect(commitStr).toEqual(outdent` RELEASING: Releasing 2 package(s) @@ -158,7 +158,7 @@ describe("defaultCommitFunctions", () => { it("should handle a merging releases from multiple changesets", async () => { const commitStr = await getVersionMessage(secondReleasePlan, { - skipCI: "version" + skipCI: "version", }); expect(commitStr).toEqual(outdent` @@ -182,9 +182,9 @@ describe("defaultCommitFunctions", () => { summary: "Hey, let's have fun with testing!", releases: [ { name: "pkg-a", type: "none" }, - { name: "pkg-b", type: "minor" } - ] - } + { name: "pkg-b", type: "minor" }, + ], + }, ], releases: [ { @@ -192,17 +192,17 @@ describe("defaultCommitFunctions", () => { type: "none", oldVersion: "1.0.0", newVersion: "1.0.0", - changesets: ["quick-lions-devour"] + changesets: ["quick-lions-devour"], }, { name: "pkg-b", type: "minor", oldVersion: "1.0.0", newVersion: "1.1.0", - changesets: ["quick-lions-devour"] - } + changesets: ["quick-lions-devour"], + }, ], - preState: undefined + preState: undefined, }, { skipCI: "version" } ); diff --git a/packages/cli/src/commit/index.ts b/packages/cli/src/commit/index.ts index ce35c744f..fe76c65c6 100644 --- a/packages/cli/src/commit/index.ts +++ b/packages/cli/src/commit/index.ts @@ -19,12 +19,12 @@ const getVersionMessage: CommitFunctions["getVersionMessage"] = async ( ) => { const skipCI = options?.skipCI === "version" || options?.skipCI === true; const publishableReleases = releasePlan.releases.filter( - release => release.type !== "none" + (release) => release.type !== "none" ); const numPackagesReleased = publishableReleases.length; const releasesLines = publishableReleases - .map(release => ` ${release.name}@${release.newVersion}`) + .map((release) => ` ${release.name}@${release.newVersion}`) .join("\n"); return outdent` @@ -38,7 +38,7 @@ const getVersionMessage: CommitFunctions["getVersionMessage"] = async ( const defaultCommitFunctions: Required = { getAddMessage, - getVersionMessage + getVersionMessage, }; export default defaultCommitFunctions; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 3aebf966b..10ef30602 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -20,52 +20,52 @@ const { input, flags } = meow( { flags: { sinceMaster: { - type: "boolean" + type: "boolean", }, verbose: { type: "boolean", - alias: "v" + alias: "v", }, output: { type: "string", - alias: "o" + alias: "o", }, otp: { - type: "string" + type: "string", }, empty: { - type: "boolean" + type: "boolean", }, since: { - type: "string" + type: "string", }, ignore: { type: "string", - isMultiple: true + isMultiple: true, }, tag: { - type: "string" + type: "string", }, open: { - type: "boolean" + type: "boolean", }, gitTag: { type: "boolean", - default: true + default: true, }, snapshotPrereleaseTemplate: { - type: "string" - } + type: "string", + }, // mixed type like this is not supported by `meow` // if it gets passed explicitly then it's still available on the flags with an inferred type though // snapshot: { type: "boolean" | "string" }, - } + }, } ); const cwd = process.cwd(); -run(input, flags, cwd).catch(err => { +run(input, flags, cwd).catch((err) => { if (err instanceof InternalError) { error( "The following error is an internal unexpected error, these should never happen." diff --git a/packages/cli/src/run.ts b/packages/cli/src/run.ts index 9c9c7b5eb..82b4e41b4 100644 --- a/packages/cli/src/run.ts +++ b/packages/cli/src/run.ts @@ -84,11 +84,11 @@ export async function run( snapshotPrereleaseTemplate, tag, open, - gitTag + gitTag, }: CliOptions = flags; const deadFlags = ["updateChangelog", "isPublic", "skipCI", "commit"]; - deadFlags.forEach(flag => { + deadFlags.forEach((flag) => { if (flags[flag]) { error( `the flag ${flag} has been removed from changesets for version 2` @@ -144,7 +144,7 @@ export async function run( // Validate that all dependents of ignored packages are listed in the ignore list const dependentsGraph = getDependentsGraph(packages, { bumpVersionsWithWorkspaceProtocolOnly: - config.bumpVersionsWithWorkspaceProtocolOnly + config.bumpVersionsWithWorkspaceProtocolOnly, }); for (const ignoredPackage of config.ignore) { const dependents = dependentsGraph.get(ignoredPackage) || []; diff --git a/packages/cli/src/utils/cli-utilities.ts b/packages/cli/src/utils/cli-utilities.ts index 603bc61d9..2a1f4f63c 100644 --- a/packages/cli/src/utils/cli-utilities.ts +++ b/packages/cli/src/utils/cli-utilities.ts @@ -33,7 +33,7 @@ type StringPromptOptions = Extract< * At each call, the entire responses object is returned, so we need a unique * identifier for the name every time. This is why we are using serial IDs */ -const serialId: () => number = (function() { +const serialId: () => number = (function () { let id = 0; return () => id++; })(); @@ -64,11 +64,11 @@ async function askCheckboxPlus( onCancel: cancelFlow, symbols: { indicator: symbols.radioOff, - checked: symbols.radioOn + checked: symbols.radioOn, }, indicator(state: any, choice: any) { return choice.enabled ? state.symbols.checked : state.symbols.indicator; - } + }, } as ArrayPromptOptions) .then((responses: any) => responses[name]) .catch((err: unknown) => { @@ -85,8 +85,8 @@ async function askQuestion(message: string): Promise { message, name, prefix, - onCancel: cancelFlow - } as StringPromptOptions + onCancel: cancelFlow, + } as StringPromptOptions, ]) .then((responses: any) => responses[name]) .catch((err: unknown) => { @@ -112,8 +112,8 @@ async function askConfirm(message: string): Promise { prefix, type: "confirm", initial: true, - onCancel: cancelFlow - } as BooleanPromptOptions + onCancel: cancelFlow, + } as BooleanPromptOptions, ]) .then((responses: any) => responses[name]) .catch((err: unknown) => { @@ -134,8 +134,8 @@ async function askList( name, prefix, type: "select", - onCancel: cancelFlow - } as ArrayPromptOptions + onCancel: cancelFlow, + } as ArrayPromptOptions, ]) .then((responses: any) => responses[name]) .catch((err: unknown) => { @@ -148,5 +148,5 @@ export { askQuestion, askQuestionWithEditor, askConfirm, - askList + askList, }; diff --git a/packages/cli/src/utils/getLastJsonObjectFromString.test.ts b/packages/cli/src/utils/getLastJsonObjectFromString.test.ts index a0923baaa..e9aec8491 100644 --- a/packages/cli/src/utils/getLastJsonObjectFromString.test.ts +++ b/packages/cli/src/utils/getLastJsonObjectFromString.test.ts @@ -12,12 +12,12 @@ describe("getLastJsonObjectFromString", () => { getLastJsonObjectFromString( JSON.stringify({ test: "foo", - bar: { baz: { qwe: "rty" }, arr: [1, 2, 3, 4] } + bar: { baz: { qwe: "rty" }, arr: [1, 2, 3, 4] }, }) ) ).toEqual({ test: "foo", - bar: { baz: { qwe: "rty" }, arr: [1, 2, 3, 4] } + bar: { baz: { qwe: "rty" }, arr: [1, 2, 3, 4] }, }); }); @@ -50,7 +50,7 @@ describe("getLastJsonObjectFromString", () => { getLastJsonObjectFromString( `${JSON.stringify({ test: "foo", - baz: { qwe: "rty" } + baz: { qwe: "rty" }, })} \n\n ${JSON.stringify({ much: "awesome" })}` ) ).toEqual({ much: "awesome" }); diff --git a/packages/cli/src/utils/v1-legacy/removeFolders.ts b/packages/cli/src/utils/v1-legacy/removeFolders.ts index 98e849580..b71e5360c 100644 --- a/packages/cli/src/utils/v1-legacy/removeFolders.ts +++ b/packages/cli/src/utils/v1-legacy/removeFolders.ts @@ -8,7 +8,7 @@ import fs from "fs-extra"; const removeEmptyFolders = async (folderPath: string) => { const dirContents = fs.readdirSync(folderPath); return Promise.all( - dirContents.map(async contentPath => { + dirContents.map(async (contentPath) => { const singleChangesetPath = path.resolve(folderPath, contentPath); try { if ((await fs.readdir(singleChangesetPath)).length < 1) { diff --git a/packages/config/src/index.test.ts b/packages/config/src/index.test.ts index bc313e871..85b1f8e79 100644 --- a/packages/config/src/index.test.ts +++ b/packages/config/src/index.test.ts @@ -18,18 +18,18 @@ let f = fixturez(__dirname); let defaultPackages: Packages = { root: { packageJson: { name: "", version: "" }, - dir: "/" + dir: "/", }, packages: [], - tool: "yarn" + tool: "yarn", }; const withPackages = (pkgNames: string[]) => ({ ...defaultPackages, - packages: pkgNames.map(pkgName => ({ + packages: pkgNames.map((pkgName) => ({ packageJson: { name: pkgName, version: "" }, - dir: "dir" - })) + dir: "dir", + })), }); test("read reads the config", async () => { @@ -47,12 +47,12 @@ test("read reads the config", async () => { bumpVersionsWithWorkspaceProtocolOnly: false, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null - } + prereleaseTemplate: null, + }, }); }); @@ -67,100 +67,100 @@ let defaults = { ignore: [], ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { onlyUpdatePeerDependentsWhenOutOfRange: false, - updateInternalDependents: "out-of-range" + updateInternalDependents: "out-of-range", }, snapshot: { useCalculatedVersion: false, - prereleaseTemplate: null + prereleaseTemplate: null, }, - bumpVersionsWithWorkspaceProtocolOnly: false + bumpVersionsWithWorkspaceProtocolOnly: false, } as const; let correctCases: Record = { defaults: { input: {}, - output: defaults + output: defaults, }, "changelog string": { input: { - changelog: "some-module" + changelog: "some-module", }, output: { ...defaults, - changelog: ["some-module", null] - } + changelog: ["some-module", null], + }, }, "changelog false": { input: { - changelog: false + changelog: false, }, output: { ...defaults, - changelog: false - } + changelog: false, + }, }, "changelog tuple": { input: { - changelog: ["some-module", { something: true }] + changelog: ["some-module", { something: true }], }, output: { ...defaults, - changelog: ["some-module", { something: true }] - } + changelog: ["some-module", { something: true }], + }, }, "commit false": { input: { - commit: false + commit: false, }, output: { ...defaults, - commit: false - } + commit: false, + }, }, "commit true": { input: { - commit: true + commit: true, }, output: { ...defaults, - commit: ["@changesets/cli/commit", { skipCI: "version" }] - } + commit: ["@changesets/cli/commit", { skipCI: "version" }], + }, }, "commit custom": { input: { - commit: ["./some-module", { customOption: true }] + commit: ["./some-module", { customOption: true }], }, output: { ...defaults, - commit: ["./some-module", { customOption: true }] - } + commit: ["./some-module", { customOption: true }], + }, }, "access private": { input: { - access: "restricted" + access: "restricted", }, output: { ...defaults, - access: "restricted" - } + access: "restricted", + }, }, "access public": { input: { - access: "public" + access: "public", }, output: { ...defaults, - access: "public" - } + access: "public", + }, }, fixed: { input: { - fixed: [["pkg-a", "pkg-b"]] + fixed: [["pkg-a", "pkg-b"]], }, output: { ...defaults, - fixed: [["pkg-a", "pkg-b"]] - } + fixed: [["pkg-a", "pkg-b"]], + }, }, fixedWithGlobs: { packages: [ @@ -169,15 +169,15 @@ let correctCases: Record = { "@pkg/a", "@pkg/b", "@pkg-other/a", - "@pkg-other/b" + "@pkg-other/b", ], input: { - fixed: [["pkg-*", "@pkg/*"], ["@pkg-other/a"]] + fixed: [["pkg-*", "@pkg/*"], ["@pkg-other/a"]], }, output: { ...defaults, - fixed: [["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]] - } + fixed: [["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]], + }, }, fixedWithGlobsAndExclusion: { packages: [ @@ -186,24 +186,24 @@ let correctCases: Record = { "@pkg/a", "@pkg/b", "@pkg-other/a", - "@pkg-other/b" + "@pkg-other/b", ], input: { - fixed: [["pkg-*", "!pkg-b", "@pkg/*"], ["@pkg-other/a"]] + fixed: [["pkg-*", "!pkg-b", "@pkg/*"], ["@pkg-other/a"]], }, output: { ...defaults, - fixed: [["pkg-a", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]] - } + fixed: [["pkg-a", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]], + }, }, linked: { input: { - linked: [["pkg-a", "pkg-b"]] + linked: [["pkg-a", "pkg-b"]], }, output: { ...defaults, - linked: [["pkg-a", "pkg-b"]] - } + linked: [["pkg-a", "pkg-b"]], + }, }, linkedWithGlobs: { packages: [ @@ -212,15 +212,15 @@ let correctCases: Record = { "@pkg/a", "@pkg/b", "@pkg-other/a", - "@pkg-other/b" + "@pkg-other/b", ], input: { - linked: [["pkg-*", "@pkg/*"], ["@pkg-other/a"]] + linked: [["pkg-*", "@pkg/*"], ["@pkg-other/a"]], }, output: { ...defaults, - linked: [["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]] - } + linked: [["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]], + }, }, linkedWithGlobsAndExclusion: { packages: [ @@ -229,96 +229,96 @@ let correctCases: Record = { "@pkg/a", "@pkg/b", "@pkg-other/a", - "@pkg-other/b" + "@pkg-other/b", ], input: { - linked: [["pkg-*", "!pkg-b", "@pkg/*"], ["@pkg-other/a"]] + linked: [["pkg-*", "!pkg-b", "@pkg/*"], ["@pkg-other/a"]], }, output: { ...defaults, - linked: [["pkg-a", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]] - } + linked: [["pkg-a", "@pkg/a", "@pkg/b"], ["@pkg-other/a"]], + }, }, "update internal dependencies minor": { input: { - updateInternalDependencies: "minor" + updateInternalDependencies: "minor", }, output: { ...defaults, - updateInternalDependencies: "minor" - } + updateInternalDependencies: "minor", + }, }, "update internal dependencies patch": { input: { - updateInternalDependencies: "patch" + updateInternalDependencies: "patch", }, output: { ...defaults, - updateInternalDependencies: "patch" - } + updateInternalDependencies: "patch", + }, }, ignore: { input: { - ignore: ["pkg-a", "pkg-b"] + ignore: ["pkg-a", "pkg-b"], }, output: { ...defaults, - ignore: ["pkg-a", "pkg-b"] - } + ignore: ["pkg-a", "pkg-b"], + }, }, ignoreWithGlobs: { packages: ["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], input: { - ignore: ["pkg-*", "@pkg/*"] + ignore: ["pkg-*", "@pkg/*"], }, output: { ...defaults, - ignore: ["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"] - } + ignore: ["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], + }, }, ignoreWithGlobsAndExclusions: { packages: ["pkg-a", "pkg-b", "@pkg/a", "@pkg/b"], input: { - ignore: ["pkg-*", "!pkg-b", "@pkg/*"] + ignore: ["pkg-*", "!pkg-b", "@pkg/*"], }, output: { ...defaults, - ignore: ["pkg-a", "@pkg/a", "@pkg/b"] - } + ignore: ["pkg-a", "@pkg/a", "@pkg/b"], + }, }, updateInternalDependents: { input: { ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { - updateInternalDependents: "always" - } + updateInternalDependents: "always", + }, }, output: { ...defaults, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { ...defaults.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, - updateInternalDependents: "always" - } - } + updateInternalDependents: "always", + }, + }, }, experimental_deprecated_useCalculatedVersionInSnapshot: { input: { ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { - useCalculatedVersionForSnapshots: true - } + useCalculatedVersionForSnapshots: true, + }, }, output: { ...defaults, snapshot: { useCalculatedVersion: true, - prereleaseTemplate: null - } - } - } + prereleaseTemplate: null, + }, + }, + }, }; jestInCase( "parse", - testCase => { + (testCase) => { expect( parse( testCase.input, @@ -576,15 +576,15 @@ The package or glob expression \\"pkg-*\\" is specified in the \`ignore\` option packageJson: { name: "pkg-a", version: "1.0.0", - dependencies: { "pkg-b": "1.0.0" } + dependencies: { "pkg-b": "1.0.0" }, }, - dir: "dir" + dir: "dir", }, { packageJson: { name: "pkg-b", version: "1.0.0" }, - dir: "dir" - } - ] + dir: "dir", + }, + ], } ) ).toThrowErrorMatchingInlineSnapshot(` @@ -598,8 +598,8 @@ The package \\"pkg-a\\" depends on the ignored package \\"pkg-b\\", but \\"pkg-a unsafeParse( { ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { - onlyUpdatePeerDependentsWhenOutOfRange: "not true" - } + onlyUpdatePeerDependentsWhenOutOfRange: "not true", + }, }, defaultPackages ); @@ -614,8 +614,8 @@ The \`onlyUpdatePeerDependentsWhenOutOfRange\` option is set as \\"not true\\" w unsafeParse( { snapshot: { - useCalculatedVersion: "not true" - } + useCalculatedVersion: "not true", + }, }, defaultPackages ); @@ -630,8 +630,8 @@ The \`snapshot.useCalculatedVersion\` option is set as \\"not true\\" when the o unsafeParse( { ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { - useCalculatedVersionForSnapshots: "not true" - } + useCalculatedVersionForSnapshots: "not true", + }, }, defaultPackages ); diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 5a96293e1..08cca2cb7 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -9,7 +9,7 @@ import { WrittenConfig, Fixed, Linked, - PackageGroup + PackageGroup, } from "@changesets/types"; import packageJson from "../package.json"; import { getDependentsGraph } from "@changesets/get-dependents-graph"; @@ -23,7 +23,7 @@ export let defaultWrittenConfig = { access: "restricted", baseBranch: "master", updateInternalDependencies: "patch", - ignore: [] as ReadonlyArray + ignore: [] as ReadonlyArray, } as const; function flatten(arr: Array): T[] { @@ -62,8 +62,8 @@ function getUnmatchedPatterns( pkgNames: readonly string[] ): string[] { return listOfPackageNamesOrGlob.filter( - pkgNameOrGlob => - !pkgNames.some(pkgName => micromatch.isMatch(pkgName, pkgNameOrGlob)) + (pkgNameOrGlob) => + !pkgNames.some((pkgName) => micromatch.isMatch(pkgName, pkgNameOrGlob)) ); } @@ -73,7 +73,8 @@ const havePackageGroupsCorrectShape = ( return ( isArray(pkgGroups) && pkgGroups.every( - arr => isArray(arr) && arr.every(pkgName => typeof pkgName === "string") + (arr) => + isArray(arr) && arr.every((pkgName) => typeof pkgName === "string") ) ); }; @@ -186,7 +187,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { for (let fixedGroup of json.fixed) { messages.push( ...getUnmatchedPatterns(fixedGroup, pkgNames).map( - pkgOrGlob => + (pkgOrGlob) => `The package or glob expression "${pkgOrGlob}" specified in the \`fixed\` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.` ) ); @@ -203,7 +204,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { } if (duplicatedPkgNames.size) { - duplicatedPkgNames.forEach(pkgName => { + duplicatedPkgNames.forEach((pkgName) => { messages.push( `The package "${pkgName}" is defined in multiple sets of fixed packages. Packages can only be defined in a single set of fixed packages. If you are using glob expressions, make sure that they are valid according to https://www.npmjs.com/package/micromatch.` ); @@ -229,7 +230,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { for (let linkedGroup of json.linked) { messages.push( ...getUnmatchedPatterns(linkedGroup, pkgNames).map( - pkgOrGlob => + (pkgOrGlob) => `The package or glob expression "${pkgOrGlob}" specified in the \`linked\` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.` ) ); @@ -246,7 +247,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { } if (duplicatedPkgNames.size) { - duplicatedPkgNames.forEach(pkgName => { + duplicatedPkgNames.forEach((pkgName) => { messages.push( `The package "${pkgName}" is defined in multiple sets of linked packages. Packages can only be defined in a single set of linked packages. If you are using glob expressions, make sure that they are valid according to https://www.npmjs.com/package/micromatch.` ); @@ -258,7 +259,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { const allFixedPackages = new Set(flatten(fixed)); const allLinkedPackages = new Set(flatten(linked)); - allFixedPackages.forEach(pkgName => { + allFixedPackages.forEach((pkgName) => { if (allLinkedPackages.has(pkgName)) { messages.push( `The package "${pkgName}" can be found in both fixed and linked groups. A package can only be either fixed or linked.` @@ -282,7 +283,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { if ( !( isArray(json.ignore) && - json.ignore.every(pkgName => typeof pkgName === "string") + json.ignore.every((pkgName) => typeof pkgName === "string") ) ) { messages.push( @@ -295,7 +296,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { } else { messages.push( ...getUnmatchedPatterns(json.ignore, pkgNames).map( - pkgOrGlob => + (pkgOrGlob) => `The package or glob expression "${pkgOrGlob}" is specified in the \`ignore\` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.` ) ); @@ -348,7 +349,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { const { onlyUpdatePeerDependentsWhenOutOfRange, updateInternalDependents, - useCalculatedVersionForSnapshots + useCalculatedVersionForSnapshots, } = json.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH; if ( @@ -445,7 +446,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { ?.useCalculatedVersionForSnapshots !== undefined ? json.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH ?.useCalculatedVersionForSnapshots - : false + : false, }, ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { @@ -459,8 +460,8 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => { updateInternalDependents: json.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH - ?.updateInternalDependents ?? "out-of-range" - } + ?.updateInternalDependents ?? "out-of-range", + }, }; return config; }; @@ -469,12 +470,12 @@ let fakePackage = { dir: "", packageJson: { name: "", - version: "" - } + version: "", + }, }; export let defaultConfig = parse(defaultWrittenConfig, { root: fakePackage, tool: "root", - packages: [fakePackage] + packages: [fakePackage], }); diff --git a/packages/get-dependents-graph/src/get-dependency-graph.test.ts b/packages/get-dependents-graph/src/get-dependency-graph.test.ts index 375c3f607..bae95c99b 100644 --- a/packages/get-dependents-graph/src/get-dependency-graph.test.ts +++ b/packages/get-dependents-graph/src/get-dependency-graph.test.ts @@ -11,12 +11,12 @@ afterEach(() => { console.error = consoleError; }); -describe("getting the dependency graph", function() { - it("should skip dependencies specified through the link protocol", function() { +describe("getting the dependency graph", function () { + it("should skip dependencies specified through the link protocol", function () { const { graph, valid } = getDependencyGraph({ root: { dir: ".", - packageJson: { name: "root", version: "1.0.0" } + packageJson: { name: "root", version: "1.0.0" }, }, packages: [ { @@ -25,30 +25,30 @@ describe("getting the dependency graph", function() { name: "foo", version: "1.0.0", devDependencies: { - bar: "link:../bar" - } - } + bar: "link:../bar", + }, + }, }, { dir: "bar", packageJson: { name: "bar", - version: "1.0.0" - } - } + version: "1.0.0", + }, + }, ], - tool: "pnpm" + tool: "pnpm", }); expect(graph.get("foo")!.dependencies).toStrictEqual([]); expect(valid).toBeTruthy(); expect((console.error as any).mock.calls).toMatchInlineSnapshot(`Array []`); }); - it("should skip dependencies specified using a tag", function() { + it("should skip dependencies specified using a tag", function () { const { graph, valid } = getDependencyGraph({ root: { dir: ".", - packageJson: { name: "root", version: "1.0.0" } + packageJson: { name: "root", version: "1.0.0" }, }, packages: [ { @@ -57,19 +57,19 @@ describe("getting the dependency graph", function() { name: "foo-example", version: "1.0.0", dependencies: { - bar: "latest" - } - } + bar: "latest", + }, + }, }, { dir: "packages/bar", packageJson: { name: "bar", - version: "1.0.0" - } - } + version: "1.0.0", + }, + }, ], - tool: "pnpm" + tool: "pnpm", }); expect(graph.get("foo-example")!.dependencies).toStrictEqual([]); expect(valid).toBeTruthy(); @@ -82,7 +82,7 @@ describe("getting the dependency graph", function() { const { valid } = getDependencyGraph({ root: { dir: ".", - packageJson: { name: "root", version: "1.0.0" } + packageJson: { name: "root", version: "1.0.0" }, }, packages: [ { @@ -91,19 +91,19 @@ describe("getting the dependency graph", function() { name: "foo", version: "1.0.0", dependencies: { - bar: "link:../bar" - } - } + bar: "link:../bar", + }, + }, }, { dir: "bar", packageJson: { name: "bar", - version: "1.0.0" - } - } + version: "1.0.0", + }, + }, ], - tool: "pnpm" + tool: "pnpm", }); expect(valid).toBeFalsy(); expect((console.error as any).mock.calls).toMatchInlineSnapshot(` diff --git a/packages/get-dependents-graph/src/get-dependency-graph.ts b/packages/get-dependents-graph/src/get-dependency-graph.ts index 6625cb29e..a1bf47948 100644 --- a/packages/get-dependents-graph/src/get-dependency-graph.ts +++ b/packages/get-dependents-graph/src/get-dependency-graph.ts @@ -8,7 +8,7 @@ const DEPENDENCY_TYPES = [ "dependencies", "devDependencies", "peerDependencies", - "optionalDependencies" + "optionalDependencies", ] as const; const getAllDependencies = (config: PackageJSON) => { @@ -64,7 +64,7 @@ export default function getDependencyGraph( let valid = true; const packagesByName: { [key: string]: Package } = { - [packages.root.packageJson.name]: packages.root + [packages.root.packageJson.name]: packages.root, }; const queue = [packages.root]; diff --git a/packages/get-dependents-graph/src/index.ts b/packages/get-dependents-graph/src/index.ts index 1d08442ba..4a51dbb1a 100644 --- a/packages/get-dependents-graph/src/index.ts +++ b/packages/get-dependents-graph/src/index.ts @@ -9,33 +9,33 @@ export function getDependentsGraph( const { graph: dependencyGraph } = getDependencyGraph(packages, { bumpVersionsWithWorkspaceProtocolOnly: - opts?.bumpVersionsWithWorkspaceProtocolOnly === true + opts?.bumpVersionsWithWorkspaceProtocolOnly === true, }); const dependentsLookup: { [key: string]: { pkg: Package; dependents: Array }; } = {}; - packages.packages.forEach(pkg => { + packages.packages.forEach((pkg) => { dependentsLookup[pkg.packageJson.name] = { pkg, - dependents: [] + dependents: [], }; }); - packages.packages.forEach(pkg => { + packages.packages.forEach((pkg) => { const dependent = pkg.packageJson.name; const valFromDependencyGraph = dependencyGraph.get(dependent); if (valFromDependencyGraph) { const dependencies = valFromDependencyGraph.dependencies; - dependencies.forEach(dependency => { + dependencies.forEach((dependency) => { dependentsLookup[dependency].dependents.push(dependent); }); } }); - Object.keys(dependentsLookup).forEach(key => { + Object.keys(dependentsLookup).forEach((key) => { graph.set(key, dependentsLookup[key]); }); diff --git a/packages/get-github-info/README.md b/packages/get-github-info/README.md index b878b4893..e54ba3ee7 100644 --- a/packages/get-github-info/README.md +++ b/packages/get-github-info/README.md @@ -31,19 +31,19 @@ const { getInfo } = require("@changesets/get-github-info"); const getReleaseLine = async (changeset, type) => { const [firstLine, ...futureLines] = changeset.summary .split("\n") - .map(l => l.trimRight()); + .map((l) => l.trimRight()); // getInfo exposes the GH username and PR number if you want them directly // but it also exposes a set of links for the commit, PR and GH username let { user, pull, links } = await getInfo({ // replace this will your own repo repo: "Noviny/changesets", - commit: changeset.commit + commit: changeset.commit, }); let returnVal = `- ${links.commit}${ links.pull === null ? "" : ` ${links.pull}` }${links.user === null ? "" : ` Thanks ${links.user}!`}: ${firstLine}`; if (futureLines.length > 0) { - returnVal += `\n${futureLines.map(l => ` ${l}`).join("\n")}`; + returnVal += `\n${futureLines.map((l) => ` ${l}`).join("\n")}`; } return returnVal; }; diff --git a/packages/get-github-info/package.json b/packages/get-github-info/package.json index 67f3f6c83..217ae53ea 100644 --- a/packages/get-github-info/package.json +++ b/packages/get-github-info/package.json @@ -12,6 +12,6 @@ }, "devDependencies": { "nock": "^11.7.0", - "prettier": "^1.19.1" + "prettier": "^2.7.1" } } diff --git a/packages/get-github-info/src/index.test.ts b/packages/get-github-info/src/index.test.ts index f6a52e1ba..f13eb8b34 100644 --- a/packages/get-github-info/src/index.test.ts +++ b/packages/get-github-info/src/index.test.ts @@ -9,8 +9,8 @@ let apiPath = `/graphql`; test("associated with multiple PRs with only one merged", async () => { nock("https://api.github.com", { reqheaders: { - Authorization: `Token ${process.env.GITHUB_TOKEN}` - } + Authorization: `Token ${process.env.GITHUB_TOKEN}`, + }, }) .post(apiPath, ({ query }) => { expect(prettier.format(query, { parser: "graphql" })) @@ -61,8 +61,8 @@ test("associated with multiple PRs with only one merged", async () => { mergedAt: null, author: { login: "mitchellhamilton", - url: "https://github.com/mitchellhamilton" - } + url: "https://github.com/mitchellhamilton", + }, }, { number: 1600, @@ -70,8 +70,8 @@ test("associated with multiple PRs with only one merged", async () => { mergedAt: null, author: { login: "mitchellhamilton", - url: "https://github.com/mitchellhamilton" - } + url: "https://github.com/mitchellhamilton", + }, }, { number: 1613, @@ -79,8 +79,8 @@ test("associated with multiple PRs with only one merged", async () => { mergedAt: "2019-11-07T06:43:58Z", author: { login: "Andarist", - url: "https://github.com/Andarist" - } + url: "https://github.com/Andarist", + }, }, { number: 1628, @@ -88,8 +88,8 @@ test("associated with multiple PRs with only one merged", async () => { mergedAt: null, author: { login: "Andarist", - url: "https://github.com/Andarist" - } + url: "https://github.com/Andarist", + }, }, { number: 1630, @@ -97,20 +97,20 @@ test("associated with multiple PRs with only one merged", async () => { mergedAt: null, author: { login: "Andarist", - url: "https://github.com/Andarist" - } - } - ] + url: "https://github.com/Andarist", + }, + }, + ], }, author: { user: { login: "Andarist", - url: "https://github.com/Andarist" - } - } - } - } - } + url: "https://github.com/Andarist", + }, + }, + }, + }, + }, }) ); let result = await getInfo({ commit: "a085003", repo: "emotion-js/emotion" }); @@ -120,8 +120,8 @@ test("associated with multiple PRs with only one merged", async () => { test("associated with multiple PRs with multiple merged gets the one that was merged first", async () => { nock("https://api.github.com", { reqheaders: { - Authorization: `Token ${process.env.GITHUB_TOKEN}` - } + Authorization: `Token ${process.env.GITHUB_TOKEN}`, + }, }) .post(apiPath, ({ query }) => { expect(prettier.format(query, { parser: "graphql" })) @@ -172,8 +172,8 @@ test("associated with multiple PRs with multiple merged gets the one that was me mergedAt: null, author: { login: "mitchellhamilton", - url: "https://github.com/mitchellhamilton" - } + url: "https://github.com/mitchellhamilton", + }, }, { number: 1600, @@ -181,8 +181,8 @@ test("associated with multiple PRs with multiple merged gets the one that was me mergedAt: "2019-11-20T06:43:58Z", author: { login: "mitchellhamilton", - url: "https://github.com/mitchellhamilton" - } + url: "https://github.com/mitchellhamilton", + }, }, { number: 1613, @@ -190,8 +190,8 @@ test("associated with multiple PRs with multiple merged gets the one that was me mergedAt: "2019-11-07T06:43:58Z", author: { login: "Andarist", - url: "https://github.com/Andarist" - } + url: "https://github.com/Andarist", + }, }, { number: 1628, @@ -199,8 +199,8 @@ test("associated with multiple PRs with multiple merged gets the one that was me mergedAt: null, author: { login: "Andarist", - url: "https://github.com/Andarist" - } + url: "https://github.com/Andarist", + }, }, { number: 1630, @@ -208,20 +208,20 @@ test("associated with multiple PRs with multiple merged gets the one that was me mergedAt: null, author: { login: "Andarist", - url: "https://github.com/Andarist" - } - } - ] + url: "https://github.com/Andarist", + }, + }, + ], }, author: { user: { login: "Andarist", - url: "https://github.com/Andarist" - } - } - } - } - } + url: "https://github.com/Andarist", + }, + }, + }, + }, + }, }) ); let result = await getInfo({ commit: "a085003", repo: "emotion-js/emotion" }); @@ -231,8 +231,8 @@ test("associated with multiple PRs with multiple merged gets the one that was me test("gets the author of the associated pull request if it exists rather than the author of the changeset", async () => { nock("https://api.github.com", { reqheaders: { - Authorization: `Token ${process.env.GITHUB_TOKEN}` - } + Authorization: `Token ${process.env.GITHUB_TOKEN}`, + }, }) .post(apiPath, ({ query }) => { expect(prettier.format(query, { parser: "graphql" })) @@ -283,32 +283,32 @@ test("gets the author of the associated pull request if it exists rather than th mergedAt: "2019-10-02T07:37:15Z", author: { login: "lmvco", - url: "https://github.com/lmvco" - } - } - ] + url: "https://github.com/lmvco", + }, + }, + ], }, author: { user: { login: "JedWatson", - url: "https://github.com/JedWatson" - } - } - } - } - } + url: "https://github.com/JedWatson", + }, + }, + }, + }, + }, }) ); let result = await getInfo({ commit: "c7e9c69", - repo: "JedWatson/react-select" + repo: "JedWatson/react-select", }); expect(result).toMatchObject({ pull: 3682, user: "lmvco" }); }); test("throws error on missing repo name", () => { const request = { - commit: "c7e9c69" + commit: "c7e9c69", }; expect(async () => @@ -322,7 +322,7 @@ test("throws error on missing repo name", () => { test("throws error on invalid repo name", () => { const request = { commit: "c7e9c69", - repo: "https://github.com/JedWatson/react-select" + repo: "https://github.com/JedWatson/react-select", }; expect(async () => @@ -335,8 +335,8 @@ test("throws error on invalid repo name", () => { test("associated with multiple PRs with only one merged", async () => { nock("https://api.github.com", { reqheaders: { - Authorization: `Token ${process.env.GITHUB_TOKEN}` - } + Authorization: `Token ${process.env.GITHUB_TOKEN}`, + }, }) .post(apiPath, ({ query }) => { expect(prettier.format(query, { parser: "graphql" })) @@ -369,21 +369,21 @@ test("associated with multiple PRs with only one merged", async () => { url: "https://github.com/emotion-js/emotion/pull/1613", author: { login: "Andarist", - url: "https://github.com/Andarist" + url: "https://github.com/Andarist", }, mergeCommit: { commitUrl: "https://github.com/emotion-js/emotion/commit/a085003d4c8ca284c116668d7217fb747802ed85", - abbreviatedOid: "a085003" - } - } - } - } + abbreviatedOid: "a085003", + }, + }, + }, + }, }) ); let result = await getInfoFromPullRequest({ pull: 1613, - repo: "emotion-js/emotion" + repo: "emotion-js/emotion", }); expect(result).toMatchInlineSnapshot(` Object { diff --git a/packages/get-github-info/src/index.ts b/packages/get-github-info/src/index.ts index 822e77a43..ba40745c3 100644 --- a/packages/get-github-info/src/index.ts +++ b/packages/get-github-info/src/index.ts @@ -24,7 +24,7 @@ function makeQuery(repos: ReposWithCommitsAndPRsToFetch) { name: ${JSON.stringify(repo.split("/")[1])} ) { ${repos[repo] - .map(data => + .map((data) => data.kind === "commit" ? `a${data.commit}: object(expression: ${JSON.stringify( data.commit @@ -95,9 +95,9 @@ const GHDataLoader = new DataLoader(async (requests: RequestData[]) => { const data = await fetch("https://api.github.com/graphql", { method: "POST", headers: { - Authorization: `Token ${process.env.GITHUB_TOKEN}` + Authorization: `Token ${process.env.GITHUB_TOKEN}`, }, - body: JSON.stringify({ query: makeQuery(repos) }) + body: JSON.stringify({ query: makeQuery(repos) }), }).then((x: any) => x.json()); if (data.errors) { @@ -126,7 +126,7 @@ const GHDataLoader = new DataLoader(async (requests: RequestData[]) => { Object.keys(repos).forEach((repo, index) => { let output: { commit: Record; pull: Record } = { commit: {}, - pull: {} + pull: {}, }; cleanedData[repo] = output; Object.entries(data.data[`a${index}`]).forEach(([field, value]) => { @@ -212,8 +212,8 @@ export async function getInfo(request: { pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null, - user: user ? `[@${user.login}](${user.url})` : null - } + user: user ? `[@${user.login}](${user.url})` : null, + }, }; } @@ -258,7 +258,7 @@ export async function getInfoFromPullRequest(request: { ? `[\`${commit.abbreviatedOid}\`](${commit.commitUrl})` : null, pull: `[#${request.pull}](https://github.com/${request.repo}/pull/${request.pull})`, - user: user ? `[@${user.login}](${user.url})` : null - } + user: user ? `[@${user.login}](${user.url})` : null, + }, }; } diff --git a/packages/get-version-range-type/src/index.test.ts b/packages/get-version-range-type/src/index.test.ts index 60e73106a..2038bfcb5 100644 --- a/packages/get-version-range-type/src/index.test.ts +++ b/packages/get-version-range-type/src/index.test.ts @@ -6,7 +6,7 @@ test.each([ [">=1.0.0", ">="], ["<=1.0.0", "<="], [">1.0.0", ">"], - ["1.0.0", ""] + ["1.0.0", ""], ])('getVersionRangeType should return "%s" if passed "%s"', (input, output) => { expect(getVersionRangeType(input)).toEqual(output); }); diff --git a/packages/git/src/index.test.ts b/packages/git/src/index.test.ts index 6eda5a9e5..09ac3ea39 100644 --- a/packages/git/src/index.test.ts +++ b/packages/git/src/index.test.ts @@ -12,7 +12,7 @@ import { getDivergedCommit, getChangedPackagesSinceRef, getChangedChangesetFilesSinceRef, - getAllTags + getAllTags, } from "./"; const f = fixtures(__dirname); @@ -53,7 +53,7 @@ describe("git", () => { await spawn("git", ["config", "commit.gpgSign", "false"], { cwd }); await spawn("git", ["config", "tag.gpgSign", "false"], { cwd }); await spawn("git", ["config", "tag.forceSignAnnotataled", "false"], { - cwd + cwd, }); }); @@ -100,12 +100,12 @@ describe("git", () => { await add("packages/pkg-a/package.json", cwd); const gitCmd = await spawn("git", ["diff", "--name-only", "--cached"], { - cwd + cwd, }); const stagedFiles = gitCmd.stdout .toString() .split("\n") - .filter(a => a); + .filter((a) => a); expect(stagedFiles).toHaveLength(1); expect(stagedFiles[0]).toEqual("packages/pkg-a/package.json"); @@ -117,12 +117,12 @@ describe("git", () => { await add("packages/pkg-b/package.json", cwd); const gitCmd = await spawn("git", ["diff", "--name-only", "--cached"], { - cwd + cwd, }); const stagedFiles = gitCmd.stdout .toString() .split("\n") - .filter(a => a); + .filter((a) => a); expect(stagedFiles).toHaveLength(3); expect(stagedFiles[0]).toEqual("package.json"); @@ -134,19 +134,19 @@ describe("git", () => { await add("packages", cwd); const gitCmd = await spawn("git", ["diff", "--name-only", "--cached"], { - cwd + cwd, }); const stagedFiles = gitCmd.stdout .toString() .split("\n") - .filter(a => a); + .filter((a) => a); expect(stagedFiles).toEqual([ "packages/package.json", "packages/pkg-a/index.js", "packages/pkg-a/package.json", "packages/pkg-b/index.js", - "packages/pkg-b/package.json" + "packages/pkg-b/package.json", ]); }); }); @@ -157,7 +157,7 @@ describe("git", () => { await commit("added packageA package.json", cwd); const gitCmd = await spawn("git", ["log", "-1", "--pretty=%B"], { - cwd + cwd, }); const commitMessage = gitCmd.stdout.toString().trim(); @@ -201,7 +201,7 @@ describe("git", () => { it("should create a tag, make a new commit, then create a second tag", async () => { const initialHead = await spawn("git", ["rev-parse", "HEAD"], { - cwd + cwd, }); await tag("tag_message", cwd); await add("packages/pkg-b/package.json", cwd); @@ -280,7 +280,7 @@ describe("git", () => { // a local repo ["clone", "--depth", depth.toString(), fileUrl(cwd), "."], { - cwd: cloneDir + cwd: cloneDir, } ); return cloneDir; @@ -373,7 +373,7 @@ describe("git", () => { const changedFiles = await getChangedFilesSince({ ref: head.stdout.toString().trim(), cwd, - fullPath: false + fullPath: false, }); expect(changedFiles).toHaveLength(0); }); @@ -383,7 +383,7 @@ describe("git", () => { const changedFiles = await getChangedFilesSince({ ref: head.stdout.toString().trim(), cwd, - fullPath: true + fullPath: true, }); expect(changedFiles).toHaveLength(0); }); @@ -400,7 +400,7 @@ describe("git", () => { const filesChangedSinceFirstRef = await getChangedFilesSince({ ref: firstRef.stdout.toString().trim(), - cwd + cwd, }); expect(filesChangedSinceFirstRef[0]).toEqual("packages/pkg-a/index.js"); expect(filesChangedSinceFirstRef[1]).toEqual("packages/pkg-b/index.js"); @@ -410,7 +410,7 @@ describe("git", () => { const filesChangedSinceSecondRef = await getChangedFilesSince({ ref: secondRef.stdout.toString().trim(), - cwd + cwd, }); expect(filesChangedSinceSecondRef[0]).toEqual("packages/pkg-b/index.js"); expect(filesChangedSinceSecondRef[1]).toEqual( @@ -429,7 +429,7 @@ describe("git", () => { const filesChangedSinceRef = await getChangedFilesSince({ ref: ref.stdout.toString().trim(), cwd, - fullPath: true + fullPath: true, }); expect(filesChangedSinceRef[0]).toBe( path.resolve(cwd, "packages/pkg-a/index.js") @@ -441,7 +441,7 @@ describe("git", () => { const filesChangedSinceRef2 = await getChangedFilesSince({ ref: ref.stdout.toString().trim(), cwd: path.resolve(cwd, "packages"), - fullPath: true + fullPath: true, }); expect(filesChangedSinceRef2[0]).toBe( path.resolve(cwd, "packages/pkg-a/index.js") @@ -462,7 +462,7 @@ describe("git", () => { await spawn("git", ["checkout", "-b", "new-branch"], { cwd }); const changedPackages = await getChangedPackagesSinceRef({ cwd, - ref: "main" + ref: "main", }); expect(changedPackages).toHaveLength(0); }); @@ -478,7 +478,7 @@ describe("git", () => { const changedPackages = await getChangedPackagesSinceRef({ cwd, - ref: "main" + ref: "main", }); expect(changedPackages).toHaveLength(2); @@ -494,7 +494,7 @@ describe("git", () => { const files = await getChangedChangesetFilesSinceRef({ cwd, - ref: "main" + ref: "main", }); expect(files).toHaveLength(0); }); @@ -506,7 +506,7 @@ describe("git", () => { const files = await getChangedChangesetFilesSinceRef({ cwd, - ref: "main" + ref: "main", }); expect(files).toHaveLength(2); expect(files[1]).toEqual(".changeset/quick-lions-devour.md"); @@ -519,7 +519,7 @@ describe("git", () => { const files = await getChangedChangesetFilesSinceRef({ cwd, - ref: "some-branch" + ref: "some-branch", }); expect(files).toHaveLength(2); expect(files[1]).toEqual(".changeset/quick-lions-devour.md"); diff --git a/packages/git/src/index.ts b/packages/git/src/index.ts index 2c65deaae..875f61b04 100644 --- a/packages/git/src/index.ts +++ b/packages/git/src/index.ts @@ -33,10 +33,7 @@ export async function getAllTags(cwd: string): Promise> { throw new Error(gitCmd.stderr.toString()); } - const tags = gitCmd.stdout - .toString() - .trim() - .split("\n"); + const tags = gitCmd.stdout.toString().trim().split("\n"); return new Set(tags); } @@ -95,7 +92,7 @@ export async function getCommitsThatAddFiles( "--diff-filter=A", "--max-count=1", "--pretty=format:%h:%p", - gitPath + gitPath, ], { cwd } ) @@ -135,7 +132,7 @@ export async function getCommitsThatAddFiles( if (await isRepoShallow({ cwd })) { // Yes. await deepenCloneBy({ by: 50, cwd }); - remaining = commitsWithMissingParents.map(p => p.path); + remaining = commitsWithMissingParents.map((p) => p.path); } else { // It's not a shallow clone, so all the commit SHAs we have are legitimate. for (const unresolved of commitsWithMissingParents) { @@ -145,13 +142,13 @@ export async function getCommitsThatAddFiles( } } while (true); - return gitPaths.map(p => map.get(p)); + return gitPaths.map((p) => map.get(p)); } export async function isRepoShallow({ cwd }: { cwd: string }) { const isShallowRepoOutput = ( await spawn("git", ["rev-parse", "--is-shallow-repository"], { - cwd + cwd, }) ).stdout .toString() @@ -193,16 +190,13 @@ async function getRepoRoot({ cwd }: { cwd: string }) { throw new Error(stderr.toString()); } - return stdout - .toString() - .trim() - .replace(/\n|\r/g, ""); + return stdout.toString().trim().replace(/\n|\r/g, ""); } export async function getChangedFilesSince({ cwd, ref, - fullPath = false + fullPath = false, }: { cwd: string; ref: string; @@ -221,17 +215,17 @@ export async function getChangedFilesSince({ .toString() .trim() .split("\n") - .filter(a => a); + .filter((a) => a); if (!fullPath) return files; const repoRoot = await getRepoRoot({ cwd }); - return files.map(file => path.resolve(repoRoot, file)); + return files.map((file) => path.resolve(repoRoot, file)); } // below are less generic functions that we use in combination with other things we are doing export async function getChangedChangesetFilesSinceRef({ cwd, - ref + ref, }: { cwd: string; ref: string; @@ -243,7 +237,7 @@ export async function getChangedChangesetFilesSinceRef({ "git", ["diff", "--name-only", "--diff-filter=d", divergedAt], { - cwd + cwd, } ); @@ -253,7 +247,7 @@ export async function getChangedChangesetFilesSinceRef({ .toString() .trim() .split("\n") - .filter(file => tester.test(file)); + .filter((file) => tester.test(file)); return files; } catch (err) { if (err instanceof GitError) return []; @@ -263,7 +257,7 @@ export async function getChangedChangesetFilesSinceRef({ export async function getChangedPackagesSinceRef({ cwd, - ref + ref, }: { cwd: string; ref: string; @@ -273,8 +267,8 @@ export async function getChangedPackagesSinceRef({ const fileToPackage: Record = {}; - packages.packages.forEach(pkg => - changedFiles.filter(isInDir(pkg.dir)).forEach(fileName => { + packages.packages.forEach((pkg) => + changedFiles.filter(isInDir(pkg.dir)).forEach((fileName) => { const prevPkg = fileToPackage[fileName] || { dir: "" }; if (pkg.dir.length > prevPkg.dir.length) fileToPackage[fileName] = pkg; }) @@ -288,7 +282,7 @@ export async function getChangedPackagesSinceRef({ } export async function getCurrentCommitId({ - cwd + cwd, }: { cwd: string; }): Promise { diff --git a/packages/parse/src/index.test.ts b/packages/parse/src/index.test.ts index a15e9bd39..9ad4c67a7 100644 --- a/packages/parse/src/index.test.ts +++ b/packages/parse/src/index.test.ts @@ -14,7 +14,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should parse major, minor, and patch changes", () => { @@ -32,9 +32,9 @@ describe("parsing a changeset", () => { releases: [ { name: "cool-package", type: "minor" }, { name: "cool-package2", type: "major" }, - { name: "cool-package3", type: "patch" } + { name: "cool-package3", type: "patch" }, ], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should parse a changeset with a scoped package", () => { @@ -48,7 +48,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "@cool/package", type: "minor" }], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should parse a changeset with multiline summary", () => { @@ -72,7 +72,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: expectedSummary + summary: expectedSummary, }); }); it("should parse a changeset with multiple packages and multiline summary", () => { @@ -98,9 +98,9 @@ describe("parsing a changeset", () => { expect(changeset).toEqual({ releases: [ { name: "cool-package", type: "minor" }, - { name: "best-package", type: "patch" } + { name: "best-package", type: "patch" }, ], - summary: expectedSummary + summary: expectedSummary, }); }); it("should be fine if a packageName includes ---", () => { @@ -114,7 +114,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool---package", type: "minor" }], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should be fine if the summary body includes ---", () => { @@ -133,7 +133,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: expectedSummary + summary: expectedSummary, }); }); it("should be fine if the summary body is completely empty and there is no trailing whitespace", () => { @@ -144,7 +144,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: "" + summary: "", }); }); it("should be fine if there is no summary body and the frontmatter has some trailing whitespace", () => { @@ -155,7 +155,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: "" + summary: "", }); }); it("should be fine if the changeset is empty", () => { @@ -167,14 +167,14 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [], - summary: "" + summary: "", }); }); it("should be fine if the changeset is empty and without any trailing whitespace", () => { const changeset = parse(`---\n---`); expect(changeset).toEqual({ releases: [], - summary: "" + summary: "", }); }); it("should be fine if the frontmatter is followed by a whitespace on the same line", () => { @@ -190,7 +190,7 @@ describe("parsing a changeset", () => { const changeset = parse(changesetMd); expect(changeset).toEqual({ releases: [{ name: "cool-package", type: "minor" }], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should be fine when md contains Windows new lines", () => { @@ -208,9 +208,9 @@ describe("parsing a changeset", () => { expect(changeset).toEqual({ releases: [ { name: "cool-package", type: "minor" }, - { name: "best-package", type: "patch" } + { name: "best-package", type: "patch" }, ], - summary: "Nice simple summary" + summary: "Nice simple summary", }); }); it("should throw if the frontmatter is followed by non-whitespace characters on the same line", () => { diff --git a/packages/parse/src/index.ts b/packages/parse/src/index.ts index e9b397ffd..04431e648 100644 --- a/packages/parse/src/index.ts +++ b/packages/parse/src/index.ts @@ -3,9 +3,7 @@ import { Release, VersionType } from "@changesets/types"; const mdRegex = /\s*---([^]*?)\n\s*---(\s*(?:\n|$)[^]*)/; -export default function parseChangesetFile( - contents: string -): { +export default function parseChangesetFile(contents: string): { summary: string; releases: Release[]; } { @@ -20,13 +18,12 @@ export default function parseChangesetFile( let releases: Release[]; try { - const yamlStuff: { [key: string]: VersionType } = yaml.safeLoad( - roughReleases - ); + const yamlStuff: { [key: string]: VersionType } = + yaml.safeLoad(roughReleases); if (yamlStuff) { releases = Object.entries(yamlStuff).map(([name, type]) => ({ name, - type + type, })); } else { releases = []; diff --git a/packages/pre/src/index.test.ts b/packages/pre/src/index.test.ts index 49f5b417b..8f0faef1a 100644 --- a/packages/pre/src/index.test.ts +++ b/packages/pre/src/index.test.ts @@ -5,7 +5,7 @@ import path from "path"; import { PreState } from "@changesets/types"; import { PreEnterButInPreModeError, - PreExitButNotInPreModeError + PreExitButNotInPreModeError, } from "@changesets/errors/src"; let f = fixturez(__dirname); @@ -14,20 +14,20 @@ let preStateForSimpleProject: PreState = { changesets: [], initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, mode: "pre", - tag: "next" + tag: "next", }; let preStateForExited: PreState = { changesets: ["slimy-dingos-whisper"], initialVersions: { "pkg-a": "1.0.0", - "pkg-b": "1.0.0" + "pkg-b": "1.0.0", }, mode: "exit", - tag: "beta" + tag: "beta", }; describe("enterPre", () => { @@ -60,7 +60,7 @@ describe("enterPre", () => { { ...preStateForExited, mode: "pre", - tag: "next" + tag: "next", } ); }); @@ -75,9 +75,9 @@ describe("exitPre", () => { ); await exitPre(cwd); - expect( - await fs.readJson(path.join(cwd, ".changeset", "pre.json")) - ).toEqual({ ...preStateForSimpleProject, mode: "exit" }); + expect(await fs.readJson(path.join(cwd, ".changeset", "pre.json"))).toEqual( + { ...preStateForSimpleProject, mode: "exit" } + ); }); it("should throw if not in pre", async () => { let cwd = f.copy("simple-project"); diff --git a/packages/pre/src/index.ts b/packages/pre/src/index.ts index 4ed43873b..419bf24be 100644 --- a/packages/pre/src/index.ts +++ b/packages/pre/src/index.ts @@ -4,7 +4,7 @@ import { PreState } from "@changesets/types"; import { getPackages } from "@manypkg/get-packages"; import { PreExitButNotInPreModeError, - PreEnterButInPreModeError + PreEnterButInPreModeError, } from "@changesets/errors"; export async function readPreState(cwd: string): Promise { @@ -56,7 +56,7 @@ export async function enterPre(cwd: string, tag: string) { mode: "pre", tag, initialVersions: {}, - changesets: preState?.changesets ?? [] + changesets: preState?.changesets ?? [], }; for (let pkg of packages.packages) { newPreState.initialVersions[pkg.packageJson.name] = pkg.packageJson.version; diff --git a/packages/read/src/index.test.ts b/packages/read/src/index.test.ts index e68c3cf02..5352c6547 100644 --- a/packages/read/src/index.test.ts +++ b/packages/read/src/index.test.ts @@ -17,8 +17,8 @@ describe("read changesets from disc", () => { { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "basic-changeset" - } + id: "basic-changeset", + }, ]); }); it("should ignore a readme file", async () => { @@ -29,8 +29,8 @@ describe("read changesets from disc", () => { { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "basic-changeset" - } + id: "basic-changeset", + }, ]); }); it("read a changeset that isn't a three word id", async () => { @@ -43,8 +43,8 @@ describe("read changesets from disc", () => { { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "basic-changeset" - } + id: "basic-changeset", + }, ]); }); it("should read many changesets from disc", async () => { @@ -55,14 +55,14 @@ describe("read changesets from disc", () => { { releases: [{ name: "cool-package", type: "minor" }], summary: "Nice simple summary", - id: "first-changeset" + id: "first-changeset", }, { releases: [{ name: "best-package", type: "patch" }], summary: "I'm amazed we needed to update the best package, because it was already the best", - id: "second-changeset" - } + id: "second-changeset", + }, ]); }); it("should return an empty array when no changesets are found", async () => { @@ -105,8 +105,8 @@ describe("read changesets from disc", () => { { releases: [], summary: "", - id: "empty-changeset" - } + id: "empty-changeset", + }, ]); }); it("should filter out ignored changesets", async () => { @@ -117,8 +117,8 @@ describe("read changesets from disc", () => { { releases: [{ name: "pkg-a", type: "minor" }], summary: "Nice simple summary, much wow", - id: "changesets-are-beautiful" - } + id: "changesets-are-beautiful", + }, ]); }); }); diff --git a/packages/read/src/index.ts b/packages/read/src/index.ts index 7df5fe87d..3c1243b92 100644 --- a/packages/read/src/index.ts +++ b/packages/read/src/index.ts @@ -12,11 +12,11 @@ async function filterChangesetsSinceRef( ) { const newChangesets = await git.getChangedChangesetFilesSinceRef({ cwd: changesetBase, - ref: sinceRef + ref: sinceRef, }); - const newHashes = newChangesets.map(c => c.split("/")[1]); + const newHashes = newChangesets.map((c) => c.split("/")[1]); - return changesets.filter(dir => newHashes.includes(dir)); + return changesets.filter((dir) => newHashes.includes(dir)); } export default async function getChangesets( @@ -45,11 +45,11 @@ export default async function getChangesets( let oldChangesetsPromise = getOldChangesetsAndWarn(changesetBase, contents); let changesets = contents.filter( - file => + (file) => !file.startsWith(".") && file.endsWith(".md") && file !== "README.md" ); - const changesetContents = changesets.map(async file => { + const changesetContents = changesets.map(async (file) => { const changeset = await fs.readFile( path.join(changesetBase, file), "utf-8" @@ -59,6 +59,6 @@ export default async function getChangesets( }); return [ ...(await oldChangesetsPromise), - ...(await Promise.all(changesetContents)) + ...(await Promise.all(changesetContents)), ]; } diff --git a/packages/read/src/legacy.ts b/packages/read/src/legacy.ts index 06d48f438..a2001673d 100644 --- a/packages/read/src/legacy.ts +++ b/packages/read/src/legacy.ts @@ -20,11 +20,11 @@ async function getOldChangesets( dirs: string[] ): Promise> { // this needs to support just not dealing with dirs that aren't set up properly - let changesets = await pFilter(dirs, async dir => + let changesets = await pFilter(dirs, async (dir) => (await fs.lstat(path.join(changesetBase, dir))).isDirectory() ); - const changesetContents = changesets.map(async changesetDir => { + const changesetContents = changesets.map(async (changesetDir) => { const jsonPath = path.join(changesetBase, changesetDir, "changes.json"); const [summary, json] = await Promise.all([ @@ -32,7 +32,7 @@ async function getOldChangesets( path.join(changesetBase, changesetDir, "changes.md"), "utf-8" ), - fs.readJson(jsonPath) + fs.readJson(jsonPath), ]); return { releases: json.releases, summary, id: changesetDir }; diff --git a/packages/release-utils/src/gitUtils.ts b/packages/release-utils/src/gitUtils.ts index 2a1a66c78..98ee80acb 100644 --- a/packages/release-utils/src/gitUtils.ts +++ b/packages/release-utils/src/gitUtils.ts @@ -18,7 +18,7 @@ export const push = async ( { force, includeTags, - cwd + cwd, }: { force?: boolean; includeTags?: boolean; cwd: string } ) => { await execWithOutput( @@ -28,7 +28,7 @@ export const push = async ( "origin", `HEAD:${branch}`, includeTags && "--tags", - force && "--force" + force && "--force", ].filter((x): x is string => !!x), { cwd } ); @@ -40,7 +40,7 @@ export const switchToMaybeExistingBranch = async ( ) => { let { stderr } = await execWithOutput("git", ["checkout", branch], { ignoreReturnCode: true, - cwd + cwd, }); let isCreatingBranch = !stderr .toString() @@ -60,14 +60,14 @@ export const reset = async ( export const commitAll = async (message: string, cwd: string) => { await execWithOutput("git", ["add", "."], { - cwd + cwd, }); await execWithOutput("git", ["commit", "-m", message], { cwd }); }; export const checkIfClean = async (cwd: string): Promise => { const { stdout } = await execWithOutput("git", ["status", "--porcelain"], { - cwd + cwd, }); return !stdout.length; }; diff --git a/packages/release-utils/src/readChangesetState.ts b/packages/release-utils/src/readChangesetState.ts index 8c2244153..ad4e07aee 100644 --- a/packages/release-utils/src/readChangesetState.ts +++ b/packages/release-utils/src/readChangesetState.ts @@ -17,11 +17,11 @@ export async function readChangesetState( if (isInPreMode && preState !== undefined) { let changesetsToFilter = new Set(preState.changesets); - changesets = changesets.filter(x => !changesetsToFilter.has(x.id)); + changesets = changesets.filter((x) => !changesetsToFilter.has(x.id)); } return { preState: isInPreMode ? preState : undefined, - changesets + changesets, }; } diff --git a/packages/release-utils/src/run.test.ts b/packages/release-utils/src/run.test.ts index 7edaac054..4539f1a34 100644 --- a/packages/release-utils/src/run.test.ts +++ b/packages/release-utils/src/run.test.ts @@ -19,7 +19,7 @@ const linkNodeModules = async (cwd: string) => { ); }; const writeChangesets = (changesets: Changeset[], cwd: string) => { - return Promise.all(changesets.map(commit => writeChangeset(commit, cwd))); + return Promise.all(changesets.map((commit) => writeChangeset(commit, cwd))); }; jest.setTimeout(10000); @@ -44,7 +44,7 @@ async function setupRepoAndClone(cwd: string) { // a local repo ["clone", "--depth", "1", fileUrl(cwd), "."], { - cwd: clone + cwd: clone, } ); await spawn("git", ["checkout", "-b", "some-other-branch"], { cwd }); @@ -61,15 +61,15 @@ describe("version", () => { releases: [ { name: "pkg-a", - type: "minor" + type: "minor", }, { name: "pkg-b", - type: "minor" - } + type: "minor", + }, ], - summary: "Awesome feature" - } + summary: "Awesome feature", + }, ], cwd ); @@ -79,11 +79,11 @@ describe("version", () => { await linkNodeModules(clone); const { changedPackages } = await runVersion({ - cwd: clone + cwd: clone, }); await spawn("git", ["checkout", `changeset-release/${mainBranch}`], { - cwd + cwd, }); expect( @@ -149,14 +149,14 @@ describe("version", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "1.1.0" - } - } + "pkg-b": "1.1.0", + }, + }, }, { dir: path.join(clone, "packages", "pkg-b"), - packageJson: { name: "pkg-b", version: "1.1.0" } - } + packageJson: { name: "pkg-b", version: "1.1.0" }, + }, ]); }); @@ -169,11 +169,11 @@ describe("version", () => { releases: [ { name: "pkg-a", - type: "minor" - } + type: "minor", + }, ], - summary: "Awesome feature" - } + summary: "Awesome feature", + }, ], cwd ); @@ -183,11 +183,11 @@ describe("version", () => { await linkNodeModules(clone); const { changedPackages } = await runVersion({ - cwd: clone + cwd: clone, }); await spawn("git", ["checkout", `changeset-release/${mainBranch}`], { - cwd + cwd, }); expect( @@ -243,10 +243,10 @@ describe("version", () => { name: "pkg-a", version: "1.1.0", dependencies: { - "pkg-b": "1.0.0" - } - } - } + "pkg-b": "1.0.0", + }, + }, + }, ]); }); @@ -259,11 +259,11 @@ describe("version", () => { releases: [ { name: "ignored-package-pkg-b", - type: "minor" - } + type: "minor", + }, ], - summary: "Awesome feature" - } + summary: "Awesome feature", + }, ], cwd ); @@ -273,13 +273,13 @@ describe("version", () => { await linkNodeModules(clone); let { changedPackages } = await runVersion({ - cwd: clone + cwd: clone, }); expect(changedPackages).toEqual([ { dir: path.join(clone, "packages", "pkg-b"), - packageJson: { name: "ignored-package-pkg-b", version: "1.1.0" } - } + packageJson: { name: "ignored-package-pkg-b", version: "1.1.0" }, + }, ]); }); }); @@ -294,12 +294,12 @@ describe("publish", () => { let result = await runPublish({ script: `node ${require.resolve("./fake-publish-script-single-package")}`, - cwd: clone + cwd: clone, }); expect(result).toEqual({ published: true, - publishedPackages: [{ name: "single-package", version: "1.0.0" }] + publishedPackages: [{ name: "single-package", version: "1.0.0" }], }); let tagsResult = await spawn("git", ["tag"], { cwd }); expect(tagsResult.stdout.toString("utf8").trim()).toEqual("v1.0.0"); @@ -313,15 +313,15 @@ describe("publish", () => { let result = await runPublish({ script: `node ${require.resolve("./fake-publish-script-multi-package")}`, - cwd: clone + cwd: clone, }); expect(result).toEqual({ published: true, publishedPackages: [ { name: "pkg-a", version: "1.0.0" }, - { name: "pkg-b", version: "1.0.0" } - ] + { name: "pkg-b", version: "1.0.0" }, + ], }); let tagsResult = await spawn("git", ["tag"], { cwd }); expect(tagsResult.stdout.toString("utf8").trim()).toEqual( diff --git a/packages/release-utils/src/run.ts b/packages/release-utils/src/run.ts index 8617683ad..7fb0b9d73 100644 --- a/packages/release-utils/src/run.ts +++ b/packages/release-utils/src/run.ts @@ -4,7 +4,7 @@ import * as semver from "semver"; import { execWithOutput, getVersionsByDirectory, - getChangedPackages + getChangedPackages, } from "./utils"; import * as gitUtils from "./gitUtils"; import { readChangesetState } from "./readChangesetState"; @@ -27,7 +27,7 @@ type PublishResult = export async function runPublish({ script, - cwd = process.cwd() + cwd = process.cwd(), }: PublishOptions): Promise { let branch = await gitUtils.getCurrentBranch(cwd); let [publishCommand, ...publishArgs] = script.split(/\s+/); @@ -46,7 +46,7 @@ export async function runPublish({ if (tool !== "root") { let newTagRegex = /New tag:\s+(@[^/]+\/[^@]+|[^/]+)@([^\s]+)/; - let packagesByName = new Map(packages.map(x => [x.packageJson.name, x])); + let packagesByName = new Map(packages.map((x) => [x.packageJson.name, x])); for (let line of changesetPublishOutput.stdout.split("\n")) { let match = line.match(newTagRegex); @@ -86,10 +86,10 @@ export async function runPublish({ if (releasedPackages.length) { return { published: true, - publishedPackages: releasedPackages.map(pkg => ({ + publishedPackages: releasedPackages.map((pkg) => ({ name: pkg.packageJson.name, - version: pkg.packageJson.version - })) + version: pkg.packageJson.version, + })), }; } @@ -105,7 +105,7 @@ type VersionOptions = { export async function runVersion({ script, cwd = process.cwd(), - commitMessage = "Version Packages" + commitMessage = "Version Packages", }: VersionOptions) { let branch = await gitUtils.getCurrentBranch(cwd); let versionBranch = `changeset-release/${branch}`; diff --git a/packages/release-utils/src/utils.test.ts b/packages/release-utils/src/utils.test.ts index d5d07de67..1cd0900ba 100644 --- a/packages/release-utils/src/utils.test.ts +++ b/packages/release-utils/src/utils.test.ts @@ -84,18 +84,18 @@ test("it sorts the things right", () => { { name: "a", highestLevel: BumpLevels.major, - private: true + private: true, }, { name: "b", highestLevel: BumpLevels.patch, - private: false + private: false, }, { name: "c", highestLevel: BumpLevels.major, - private: false - } + private: false, + }, ]; expect(things.sort(sortChangelogEntries)).toMatchSnapshot(); }); diff --git a/packages/release-utils/src/utils.ts b/packages/release-utils/src/utils.ts index 5162934c3..d499d25f4 100644 --- a/packages/release-utils/src/utils.ts +++ b/packages/release-utils/src/utils.ts @@ -11,12 +11,12 @@ export const BumpLevels = { dep: 0, patch: 1, minor: 2, - major: 3 + major: 3, } as const; export async function getVersionsByDirectory(cwd: string) { let { packages } = await getPackages(cwd); - return new Map(packages.map(x => [x.dir, x.packageJson.version])); + return new Map(packages.map((x) => [x.dir, x.packageJson.version])); } export async function getChangedPackages( @@ -37,9 +37,7 @@ export async function getChangedPackages( } export function getChangelogEntry(changelog: string, version: string) { - let ast = unified() - .use(remarkParse) - .parse(changelog); + let ast = unified().use(remarkParse).parse(changelog); let highestLevel: number = BumpLevels.dep; @@ -64,7 +62,7 @@ export function getChangelogEntry(changelog: string, version: string) { if (headingStartInfo === undefined && stringified === version) { headingStartInfo = { index: i, - depth: node.depth + depth: node.depth, }; continue; } @@ -85,10 +83,8 @@ export function getChangelogEntry(changelog: string, version: string) { ); } return { - content: unified() - .use(remarkStringify) - .stringify(ast), - highestLevel: highestLevel + content: unified().use(remarkStringify).stringify(ast), + highestLevel: highestLevel, }; } @@ -99,10 +95,10 @@ export async function execWithOutput( ) { process.stdout.write(`Running: ${command} ${args.join(" ")}` + os.EOL); let childProcess = spawn(command, args, { - cwd: options.cwd + cwd: options.cwd, }); - childProcess.on("stdout", data => process.stdout.write(data)); - childProcess.on("stderr", data => process.stderr.write(data)); + childProcess.on("stdout", (data) => process.stdout.write(data)); + childProcess.on("stderr", (data) => process.stderr.write(data)); let result = await childProcess; if (!options?.ignoreReturnCode && result.code !== 0) { throw new Error( @@ -114,7 +110,7 @@ export async function execWithOutput( return { code: result.code, stdout: result.stdout.toString("utf8"), - stderr: result.stderr.toString("utf8") + stderr: result.stderr.toString("utf8"), }; } diff --git a/packages/test-utils/src/index.ts b/packages/test-utils/src/index.ts index 234c800f5..3e7ab08ea 100644 --- a/packages/test-utils/src/index.ts +++ b/packages/test-utils/src/index.ts @@ -54,7 +54,7 @@ const createLogSilencer = () => { process.stdout.write = originalStdoutWrite; process.stderr.write = originalStderrWrite; }; - } + }, }; }; @@ -71,14 +71,13 @@ export const silenceLogsInBlock = () => { }); }; -export const temporarilySilenceLogs = ( - testFn: () => Promise | void -) => async () => { - const silencer = createLogSilencer(); - const dispose = silencer.setup(); - try { - await testFn(); - } finally { - dispose(); - } -}; +export const temporarilySilenceLogs = + (testFn: () => Promise | void) => async () => { + const silencer = createLogSilencer(); + const dispose = silencer.setup(); + try { + await testFn(); + } finally { + dispose(); + } + }; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 63259af53..3a48b8224 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -4,7 +4,7 @@ const DEPENDENCY_TYPES = [ "dependencies", "devDependencies", "peerDependencies", - "optionalDependencies" + "optionalDependencies", ] as const; export type VersionType = "major" | "minor" | "patch" | "none"; diff --git a/packages/write/README.md b/packages/write/README.md index dc0cdac8f..850357cc7 100644 --- a/packages/write/README.md +++ b/packages/write/README.md @@ -9,8 +9,8 @@ const changeset = { summary: "A description of a minor change", releases: [ { name: "@changesets/something", type: "minor" }, - { name: "@changesets/something-else", type: "patch" } - ] + { name: "@changesets/something-else", type: "patch" }, + ], }; const uniqueId = await write(changeset, cwd); diff --git a/packages/write/package.json b/packages/write/package.json index f17d493d7..4d907ffb4 100644 --- a/packages/write/package.json +++ b/packages/write/package.json @@ -11,7 +11,7 @@ "@changesets/types": "^5.1.0", "fs-extra": "^7.0.1", "human-id": "^1.0.2", - "prettier": "^1.19.1" + "prettier": "^2.7.1" }, "devDependencies": { "@changesets/parse": "*", diff --git a/packages/write/src/index.test.ts b/packages/write/src/index.test.ts index a6773c78c..86c017104 100644 --- a/packages/write/src/index.test.ts +++ b/packages/write/src/index.test.ts @@ -14,12 +14,12 @@ jest.mock("human-id"); const simpleChangeset: { summary: string; releases: Release[] } = { summary: "This is a summary", - releases: [{ name: "pkg-a", type: "minor" }] + releases: [{ name: "pkg-a", type: "minor" }], }; const emptyChangeset: { summary: string; releases: Release[] } = { summary: "", - releases: [] + releases: [], }; describe("simple project", () => { diff --git a/packages/write/src/index.ts b/packages/write/src/index.ts index 8945b76e6..b9e2838c3 100644 --- a/packages/write/src/index.ts +++ b/packages/write/src/index.ts @@ -4,6 +4,17 @@ import prettier from "prettier"; import humanId from "human-id"; import { Changeset } from "@changesets/types"; +function getPrettierInstance(cwd: string): typeof prettier { + try { + return require(require.resolve("prettier", { paths: [cwd] })); + } catch (err) { + if (!err || (err as any).code !== "MODULE_NOT_FOUND") { + throw err; + } + return prettier; + } +} + async function writeChangeset( changeset: Changeset, cwd: string @@ -16,10 +27,11 @@ async function writeChangeset( // experimenting with human readable ids to make finding changesets easier const changesetID = humanId({ separator: "-", - capitalize: false + capitalize: false, }); - const prettierConfig = await prettier.resolveConfig(cwd); + const prettierInstance = getPrettierInstance(cwd); + const prettierConfig = await prettierInstance.resolveConfig(cwd); const newChangesetPath = path.resolve(changesetBase, `${changesetID}.md`); @@ -27,7 +39,7 @@ async function writeChangeset( // not spec for yaml. This is because package names can contain special // characters that will otherwise break the parsing step const changesetContents = `--- -${releases.map(release => `"${release.name}": ${release.type}`).join("\n")} +${releases.map((release) => `"${release.name}": ${release.type}`).join("\n")} --- ${summary} @@ -35,9 +47,9 @@ ${summary} await fs.writeFile( newChangesetPath, - prettier.format(changesetContents, { + prettierInstance.format(changesetContents, { ...prettierConfig, - parser: "markdown" + parser: "markdown", }) ); diff --git a/types/boxen.d.ts b/types/boxen.d.ts index 2014310f0..435c3575b 100644 --- a/types/boxen.d.ts +++ b/types/boxen.d.ts @@ -1,6 +1,6 @@ // NOTE: There is a boxen types that doesn't work so made this here declare module "boxen" { - export default function( + export default function ( meesage: string, options: { borderStyle: string; diff --git a/types/fixturez.d.ts b/types/fixturez.d.ts index 68a71b8fb..f71803e57 100644 --- a/types/fixturez.d.ts +++ b/types/fixturez.d.ts @@ -5,7 +5,7 @@ type Opts = { }; declare module "fixturez" { - export default function( + export default function ( cwd: string, opts?: Opts ): { diff --git a/types/human-id.d.ts b/types/human-id.d.ts index 52e4deb57..721cbf223 100644 --- a/types/human-id.d.ts +++ b/types/human-id.d.ts @@ -1,5 +1,5 @@ declare module "human-id" { - export default function(options: { + export default function (options: { separator: string; capitalize: boolean; }): string; diff --git a/types/tty-table.d.ts b/types/tty-table.d.ts index 0fb86d515..2645f3b36 100644 --- a/types/tty-table.d.ts +++ b/types/tty-table.d.ts @@ -1,6 +1,6 @@ // NOTE: There is a boxen types that doesn't work so made this here declare module "tty-table" { - export default function( + export default function ( value: Array<{ value: string; width: number }>, columsn: string[][], options: { diff --git a/yarn.lock b/yarn.lock index 43ec2b916..f36d87bc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1714,11 +1714,16 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== -"@types/prettier@^1.19.0", "@types/prettier@^1.19.1": +"@types/prettier@^1.19.0": version "1.19.1" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.1.tgz#33509849f8e679e4add158959fdb086440e9553f" integrity sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ== +"@types/prettier@^2.7.0": + version "2.7.0" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.0.tgz#ea03e9f0376a4446f44797ca19d9c46c36e352dc" + integrity sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A== + "@types/resolve@1.17.1": version "1.17.1" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" @@ -6339,10 +6344,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" + integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== pretty-format@^24.9.0: version "24.9.0"