Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: changesets/bot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: CopilotKit/changesets-bot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Dec 13, 2024

  1. changes

    arielweinberger committed Dec 13, 2024
    Copy the full SHA
    c12d341 View commit details
  2. add gitignore

    arielweinberger committed Dec 13, 2024
    Copy the full SHA
    41c3332 View commit details
  3. fix comment

    arielweinberger committed Dec 13, 2024
    Copy the full SHA
    3a3ad79 View commit details
Showing with 13,463 additions and 1,646 deletions.
  1. +4 −0 .env.example
  2. +2 −1 .gitignore
  3. +16 −9 get-changed-packages.ts
  4. +7 −7 index.ts
  5. +12,241 −0 package-lock.json
  6. +3 −0 package.json
  7. +1,190 −1,629 yarn.lock
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WEBHOOK_SECRET=""
PRIVATE_KEY=""
APP_ID=""
WEBHOOK_PROXY_URL=""
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.next
.next
.env
25 changes: 16 additions & 9 deletions get-changed-packages.ts
Original file line number Diff line number Diff line change
@@ -16,13 +16,15 @@ export let getChangedPackages = async ({
changedFiles: changedFilesPromise,
octokit,
installationToken,
rootDir = "CopilotKit",
}: {
owner: string;
repo: string;
ref: string;
changedFiles: string[] | Promise<string[]>;
octokit: InstanceType<typeof ProbotOctokit>;
installationToken: string;
rootDir?: string;
}) => {
let hasErrored = false;
let encodedCredentials = Buffer.from(
@@ -68,8 +70,8 @@ export let getChangedPackages = async ({
};
}

let rootPackageJsonContentsPromise = fetchJsonFile("package.json");
let configPromise: Promise<any> = fetchJsonFile(".changeset/config.json");
let rootPackageJsonContentsPromise = fetchJsonFile(`${rootDir}/package.json`);
let configPromise: Promise<any> = fetchJsonFile(`${rootDir}/.changeset/config.json`);

let tree = await octokit.git.getTree({
owner,
@@ -86,20 +88,22 @@ export let getChangedPackages = async ({

for (let item of tree.data.tree) {
if (!item.path) continue;
if (!item.path.startsWith(rootDir)) continue;

if (item.path.endsWith("/package.json")) {
let dirPath = nodePath.dirname(item.path);
potentialWorkspaceDirectories.push(dirPath);
} else if (item.path === "pnpm-workspace.yaml") {
} else if (item.path === `${rootDir}/pnpm-workspace.yaml`) {
isPnpm = true;
} else if (item.path === ".changeset/pre.json") {
preStatePromise = fetchJsonFile(".changeset/pre.json");
} else if (item.path === `${rootDir}/.changeset/pre.json`) {
preStatePromise = fetchJsonFile(`${rootDir}/.changeset/pre.json`);
} else if (
item.path !== ".changeset/README.md" &&
item.path.startsWith(".changeset") &&
item.path !== `${rootDir}/.changeset/README.md` &&
item.path.startsWith(`${rootDir}/.changeset`) &&
item.path.endsWith(".md") &&
changedFiles.includes(item.path)
) {
let res = /\.changeset\/([^\.]+)\.md/.exec(item.path);
let res = new RegExp(`${rootDir}/\\.changeset/([^\.]+)\\.md`).exec(item.path);
if (!res) {
throw new Error("could not get name from changeset filename");
}
@@ -121,7 +125,7 @@ export let getChangedPackages = async ({
if (isPnpm) {
tool = {
tool: "pnpm",
globs: safeLoad(await fetchTextFile("pnpm-workspace.yaml")).packages,
globs: safeLoad(await fetchTextFile("CopilotKit/pnpm-workspace.yaml")).packages,
};
} else {
let rootPackageJsonContent = await rootPackageJsonContentsPromise;
@@ -167,6 +171,9 @@ export let getChangedPackages = async ({
) {
throw new Error("globs are not valid: " + JSON.stringify(tool.globs));
}

tool.globs = tool.globs.map((glob) => `${rootDir}/${glob}`);

let matches = micromatch(potentialWorkspaceDirectories, tool.globs);

packages.packages = await Promise.all(
14 changes: 7 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -65,8 +65,6 @@ Merging this PR will not cause a version bump for any packages. If these changes
${getReleasePlanMessage(releasePlan)}
[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).
[Click here if you're a maintainer who wants to add a changeset to this PR](${addChangesetUrl})
`;
@@ -83,8 +81,6 @@ Latest commit: ${commitSha}
${getReleasePlanMessage(releasePlan)}
Not sure what this means? [Click here to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).
[Click here if you're a maintainer who wants to add another changeset to this PR](${addChangesetUrl})
`;
@@ -123,8 +119,8 @@ const hasChangesetBeenAdded = (
files.data.some(
(file) =>
file.status === "added" &&
/^\.changeset\/.+\.md$/.test(file.filename) &&
file.filename !== ".changeset/README.md"
/^CopilotKit\/\.changeset\/.+\.md$/.test(file.filename) &&
file.filename !== "CopilotKit/.changeset/README.md"
)
);

@@ -183,6 +179,8 @@ export default (app: Probot) => {
})
).data.token,
}).catch((err) => {
console.log("CAUGHT");
console.log("err", err)
if (err instanceof ValidationError) {
errFromFetchingChangedFiles = `<details><summary>💥 An error occurred when fetching the changed packages and changesets in this PR</summary>\n\n\`\`\`\n${err.message}\n\`\`\`\n\n</details>\n`;
} else {
@@ -196,11 +194,13 @@ export default (app: Probot) => {
}),
] as const);

console.log("changedPackages", changedPackages)

let addChangesetUrl = `${
context.payload.pull_request.head.repo.html_url
}/new/${
context.payload.pull_request.head.ref
}?filename=.changeset/${humanId({
}?filename=CopilotKit/.changeset/${humanId({
separator: "-",
capitalize: false,
})}.md&value=${getNewChangesetTemplate(
Loading