FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Upgrade manypkg/get-packages by elliot-nelson · Pull Request #1069 · changesets/changesets · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (9) .lock  (1) .ts  (15) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion packages/apply-release-plan/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@changesets/get-version-range-type": "^0.3.2",
"@changesets/git": "^2.0.0",
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"@manypkg/get-packages": "^2.0.0",
"detect-indent": "^6.0.0",
"fs-extra": "^7.0.1",
"lodash.startcase": "^4.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/apply-release-plan/src/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default async function applyReleasePlan(
config: Config = defaultConfig,
snapshot?: string | boolean
) {
let cwd = packages.root.dir;
let cwd = packages.rootDir;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If I'm not mistaken - this is a breaking change for @changesets/apply-release-plan. This is fine - we just have to create a major changeset for it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is it major? I might misunderstand the ramifications but I think apply-release-plan's external behavior for all existing monorepo implementations doesn't change (it's just a dependency bump + corresponding implementation tweak).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The problem is in the API surface - not the behavior. It now accepts an argument of a different shape

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👋


let touchedFiles = [];

Expand Down
3 changes: 2 additions & 1 deletion packages/assemble-release-plan/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"@changesets/errors": "^0.1.4",
"@changesets/get-dependents-graph": "^1.3.6",
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"@manypkg/get-packages": "^2.0.0",
"@manypkg/tools": "^1.0.0",
"semver": "^7.5.3"
},
"devDependencies": {
Expand Down
12 changes: 8 additions & 4 deletions packages/assemble-release-plan/src/test-utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NewChangeset, Release, VersionType } from "@changesets/types";
import { Package, Packages } from "@manypkg/get-packages";
import { YarnTool } from "@manypkg/tools";

function getPackage({
name,
Expand All @@ -13,7 +14,8 @@ function getPackage({
name,
version,
},
dir: "this-shouldn't-matter",
dir: "/monorepo/this-shouldn't-matter",
relativeDir: "this-shouldn't-matter",
};
}

Expand Down Expand Up @@ -46,15 +48,17 @@ function getRelease({

let getSimpleSetup = () => ({
packages: {
root: {
rootDir: "/monorepo",
rootPackage: {
packageJson: {
name: "root",
version: "0.0.0",
},
dir: "/",
dir: "/monorepo",
relativeDir: ".",
},
packages: [getPackage({ name: "pkg-a", version: "1.0.0" })],
tool: "yarn" as const,
tool: YarnTool,
},
changesets: [
getChangeset({ releases: [getRelease({ name: "pkg-a", type: "patch" })] }),
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
"@changesets/read": "^0.5.9",
"@changesets/types": "^5.2.1",
"@changesets/write": "^0.2.3",
"@manypkg/get-packages": "^1.1.3",
"@manypkg/get-packages": "^2.0.0",
"@manypkg/tools": "^1.0.0",
"@types/is-ci": "^3.0.0",
"@types/semver": "^6.0.0",
"@types/semver": "^7.5.0",
"ansi-colors": "^4.1.3",
"chalk": "^2.1.0",
Expand Down
53 changes: 53 additions & 0 deletions packages/cli/src/commands/add/__tests__/add.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,57 @@ describe("Changesets", () => {
const { choices } = askCheckboxPlus.mock.calls[0][1][0];
expect(choices).toEqual(["pkg-a", "pkg-c"]);
});

describe("in a rush monorepo", () => {
it("generates a changeset", async () => {
const cwd = await testdir({
"rush.json": JSON.stringify({
projects: [
{
projectFolder: "libraries/a",
packageName: "@example/a",
},
],
}),
"libraries/a/package.json": JSON.stringify({
name: "@example/a",
version: "1.0.0",
}),
});

const summary = "summary message mock";

// @ts-ignore
askList.mockReturnValueOnce(Promise.resolve("minor"));

let confirmAnswers = {
"Is this your desired changeset?": true,
};
// @ts-ignore
askQuestion.mockReturnValueOnce("");
// @ts-ignore
askQuestionWithEditor.mockReturnValueOnce(summary);
// @ts-ignore
askConfirm.mockImplementation((question) => {
question = stripAnsi(question);
// @ts-ignore
if (confirmAnswers[question]) {
// @ts-ignore
return confirmAnswers[question];
}
throw new Error(`An answer could not be found for ${question}`);
});

await addChangeset(cwd, { empty: false }, defaultConfig);

expect(writeChangeset).toHaveBeenCalledWith(
expect.objectContaining({
summary: "summary message mock",
releases: [{ name: "@example/a", type: "minor" }],
}),
expect.any(String)
);
expect(writeChangeset).toHaveBeenCalledTimes(1);
});
});
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function getUntaggedPrivatePackages(
const packageWithTags = await Promise.all(
privatePackages.map(async (privatePkg) => {
const tagName =
tool === "root"
tool.type === "root"
? `v${privatePkg.packageJson.version}`
: `${privatePkg.packageJson.name}@${privatePkg.packageJson.version}`;
const isMissingTag = !(
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/commands/publish/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as git from "@changesets/git";
import { readPreState } from "@changesets/pre";
import { Config, PreState } from "@changesets/types";
import { getPackages } from "@manypkg/get-packages";
import { Tool } from "@manypkg/tools";
import chalk from "chalk";
import { getUntaggedPrivatePackages } from "./getUntaggedPrivatePackages";

Expand Down Expand Up @@ -117,11 +118,11 @@ export default async function run(
}

async function tagPublish(
tool: string,
tool: Tool,
packageReleases: PublishedResult[],
cwd: string
) {
if (tool !== "root") {
if (tool.type !== "root") {
for (const pkg of packageReleases) {
const tag = `${pkg.name}@${pkg.newVersion}`;
log("New tag: ", tag);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/tag/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function run(cwd: string) {

for (const pkg of packages) {
const tag =
tool !== "root"
tool.type !== "root"
? `${pkg.packageJson.name}@${pkg.packageJson.version}`
: `v${pkg.packageJson.version}`;

Expand Down
52 changes: 52 additions & 0 deletions packages/cli/src/commands/version/version.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,58 @@ describe("running version in a simple project", () => {
});
});

describe("when there is a changeset commit in a Rush monorepo", () => {
it("should bump releasedPackages", async () => {
const cwd = await testdir({
"rush.json": JSON.stringify({
projects: [
{
projectFolder: "packages/pkg-a",
packageName: "pkg-a",
},
{
projectFolder: "packages/pkg-b",
packageName: "pkg-b",
},
],
}),
"packages/pkg-a/package.json": JSON.stringify({
name: "pkg-a",
version: "1.0.0",
dependencies: {
"pkg-b": "1.0.0",
},
}),
"packages/pkg-b/package.json": JSON.stringify({
name: "pkg-b",
version: "1.0.0",
}),
});
await writeChangesets(
[
{
summary: "This is a summary too",
releases: [
{ name: "pkg-a", type: "minor" },
{ name: "pkg-b", type: "patch" },
],
},
],
cwd
);
const spy = jest.spyOn(fs, "writeFile");

await version(cwd, defaultOptions, modifiedDefaultConfig);

expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual(
expect.objectContaining({ name: "pkg-a", version: "1.1.0" })
);
expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual(
expect.objectContaining({ name: "pkg-b", version: "1.0.1" })
);
});
});

it("should not touch package.json of an ignored package when it is not a dependent of any releasedPackages ", async () => {
const cwd = await testdir({
"package.json": JSON.stringify({
Expand Down
3 changes: 2 additions & 1 deletion packages/config/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@changesets/get-dependents-graph": "^1.3.6",
"@changesets/logger": "^0.0.5",
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"@manypkg/get-packages": "^2.0.0",
"@manypkg/tools": "^1.0.0",
"fs-extra": "^7.0.1",
"micromatch": "^4.0.2"
},
Expand Down
14 changes: 9 additions & 5 deletions packages/config/src/index.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import jestInCase from "jest-in-case";
import * as logger from "@changesets/logger";
import { Config, WrittenConfig } from "@changesets/types";
import { Packages } from "@manypkg/get-packages";
import { YarnTool } from "@manypkg/tools";
import { testdir } from "@changesets/test-utils";

jest.mock("@changesets/logger");
Expand All @@ -14,19 +15,22 @@ type CorrectCase = {
};

let defaultPackages: Packages = {
root: {
rootPackage: {
packageJson: { name: "", version: "" },
dir: "/",
dir: "/monorepo",
relativeDir: ".",
},
packages: [],
tool: "yarn",
rootDir: "/monorepo",
tool: YarnTool,
};

const withPackages = (pkgNames: string[]) => ({
const withPackages = (pkgNames: string[]): Packages => ({
...defaultPackages,
packages: pkgNames.map((pkgName) => ({
packageJson: { name: pkgName, version: "" },
dir: "dir",
relativeDir: "dir",
dir: "/monorepo/dir",
})),
});

Expand Down
7 changes: 5 additions & 2 deletions packages/config/src/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import micromatch from "micromatch";
import { ValidationError } from "@changesets/errors";
import { warn } from "@changesets/logger";
import { Packages } from "@manypkg/get-packages";
import { RootTool } from "@manypkg/tools";
import {
Config,
WrittenConfig,
Expand Down Expand Up @@ -505,14 +506,16 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => {

let fakePackage = {
dir: "",
relativeDir: "",
packageJson: {
name: "",
version: "",
},
};

export let defaultConfig = parse(defaultWrittenConfig, {
root: fakePackage,
tool: "root",
rootPackage: fakePackage,
rootDir: "",
tool: RootTool,
packages: [fakePackage],
});
3 changes: 2 additions & 1 deletion packages/get-dependents-graph/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"repository": "https://github.com/changesets/changesets/tree/main/packages/get-dependents-graph",
"dependencies": {
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"@manypkg/get-packages": "^2.0.0",
"@manypkg/tools": "^1.0.0",
"chalk": "^2.1.0",
"fs-extra": "^7.0.1",
"semver": "^7.5.3"
Expand Down
Loading

Back | FazBrowse Home | New Git URL