@catladder/cli 0.0.0-next-cf4e99eb → 0.0.0-next-cb2cfd57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-next-cf4e99eb",
56
+ "version": "0.0.0-next-cb2cfd57",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -15,6 +15,7 @@ describe("runChangesetCheck", () => {
15
15
  pending: [changeset("minor", "Add the fancy dashboard")],
16
16
  lastTag: "v4.7.0",
17
17
  requestLabel: "merge request",
18
+ packageManager: "yarn",
18
19
  });
19
20
  expect(result.addsChangeset).toBe(true);
20
21
  expect(result.markdown).toContain(CHANGESET_CHECK_MARKER);
@@ -31,6 +32,7 @@ describe("runChangesetCheck", () => {
31
32
  pending: [],
32
33
  lastTag: "v4.7.0",
33
34
  requestLabel: "merge request",
35
+ packageManager: "yarn",
34
36
  });
35
37
  expect(result.addsChangeset).toBe(false);
36
38
  expect(result.markdown).toContain(
@@ -48,6 +50,7 @@ describe("runChangesetCheck", () => {
48
50
  ],
49
51
  lastTag: "v4.7.0",
50
52
  requestLabel: "merge request",
53
+ packageManager: "yarn",
51
54
  });
52
55
  expect(result.addsChangeset).toBe(false);
53
56
  expect(result.markdown).toContain("2 changesets are pending");
@@ -55,12 +58,27 @@ describe("runChangesetCheck", () => {
55
58
  expect(result.markdown).toContain("Remove the legacy mode");
56
59
  });
57
60
 
61
+ it("names the project's own package manager in the how-to hint", () => {
62
+ const forPm = (packageManager: "yarn" | "pnpm") =>
63
+ runChangesetCheck({
64
+ addedFiles: [],
65
+ pending: [],
66
+ lastTag: "v4.7.0",
67
+ requestLabel: "merge request",
68
+ packageManager,
69
+ }).markdown;
70
+ expect(forPm("pnpm")).toContain("`pnpm changeset`");
71
+ expect(forPm("pnpm")).not.toContain("yarn");
72
+ expect(forPm("yarn")).toContain("`yarn changeset`");
73
+ });
74
+
58
75
  it("handles the first release (no previous tag)", () => {
59
76
  const result = runChangesetCheck({
60
77
  addedFiles: ["init.md"],
61
78
  pending: [changeset("minor", "Initial feature")],
62
79
  lastTag: null,
63
80
  requestLabel: "pull request",
81
+ packageManager: "yarn",
64
82
  });
65
83
  expect(result.markdown).toContain("✅ This pull request adds 1 changeset");
66
84
  expect(result.markdown).toContain("**v1.0.0**");
@@ -28,6 +28,11 @@ export type ChangesetCheckInput = {
28
28
  lastTag: string | null;
29
29
  /** platform wording: "merge request" (gitlab) or "pull request" (github) */
30
30
  requestLabel: string;
31
+ /**
32
+ * the project's package manager, so the "how to add one" hint names a
33
+ * command that actually exists there
34
+ */
35
+ packageManager: "yarn" | "pnpm";
31
36
  };
32
37
 
33
38
  export type ChangesetCheckResult = {
@@ -42,6 +47,7 @@ export const runChangesetCheck = ({
42
47
  pending,
43
48
  lastTag,
44
49
  requestLabel,
50
+ packageManager,
45
51
  }: ChangesetCheckInput): ChangesetCheckResult => {
46
52
  const addsChangeset = addedFiles.length > 0;
47
53
 
@@ -53,7 +59,7 @@ export const runChangesetCheck = ({
53
59
  );
54
60
  } else {
55
61
  lines.push(
56
- `⚠️ **This ${requestLabel} adds no changeset.** If the change is user-facing it will be missing from the next release's changelog — add \`.changeset/<name>.md\` (or run \`yarn changeset\`). For docs/chore changes this warning can be ignored.`,
62
+ `⚠️ **This ${requestLabel} adds no changeset.** If the change is user-facing it will be missing from the next release's changelog — add \`.changeset/<name>.md\` (or run \`${packageManager} changeset\`). For docs/chore changes this warning can be ignored.`,
57
63
  );
58
64
  }
59
65
  lines.push("");
@@ -7,6 +7,7 @@
7
7
  * sticky MR/PR comment where a token allows it. Exits 1 (the job runs
8
8
  * with allow_failure) when the merge request adds no changeset.
9
9
  */
10
+ import { existsSync } from "fs";
10
11
  import { writeFile } from "fs/promises";
11
12
  import { CHANGESET_CHECK_MARKER, runChangesetCheck } from "./changesetCheck";
12
13
  import { readPendingChangesets } from "./changesetsReleaseJob";
@@ -17,6 +18,13 @@ export const CHANGESET_REPORT_FILE = "changeset-report.md";
17
18
 
18
19
  const onGithub = () => process.env.GITHUB_ACTIONS === "true";
19
20
 
21
+ /**
22
+ * the repo's package manager, from the lockfile in the checkout — the
23
+ * hint for adding a changeset should name a command the project has
24
+ */
25
+ const detectPackageManager = (): "yarn" | "pnpm" =>
26
+ existsSync("pnpm-lock.yaml") ? "pnpm" : "yarn";
27
+
20
28
  /**
21
29
  * the changeset files added by this merge request: diffed against the
22
30
  * merge base with the target branch (fetched explicitly — CI checkouts
@@ -172,6 +180,7 @@ export const changesetCheckJob = async () => {
172
180
  pending,
173
181
  lastTag,
174
182
  requestLabel: onGithub() ? "pull request" : "merge request",
183
+ packageManager: detectPackageManager(),
175
184
  });
176
185
 
177
186
  console.log(result.markdown.replace(`${CHANGESET_CHECK_MARKER}\n`, ""));
@@ -5,6 +5,7 @@
5
5
  * from the last `v*` tag, writes the changelog, commits, tags and
6
6
  * pushes — the pushed tag triggers the taggedRelease pipeline.
7
7
  */
8
+ import { existsSync } from "fs";
8
9
  import { readFile, readdir, rm, writeFile } from "fs/promises";
9
10
  import { join } from "path";
10
11
  import type { Changeset } from "./changesets";
@@ -145,7 +146,7 @@ export const changesetsReleaseJob = async () => {
145
146
  `no changesets found in ${CHANGESET_DIR}/ — nothing to release`,
146
147
  );
147
148
  console.log(
148
- "add one with `yarn changeset` (or write .changeset/<name>.md by hand) and merge it to release",
149
+ `add one with \`${existsSync("pnpm-lock.yaml") ? "pnpm" : "yarn"} changeset\` (or write .changeset/<name>.md by hand) and merge it to release`,
149
150
  );
150
151
  console.log(
151
152
  "to release anyway (patch bump), run the force release job instead",