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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "main"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
Expand All @@ -21,8 +18,7 @@
"^build"
],
"inputs": [
"production",
"^production"
"{projectRoot}/src/**/*"
],
"outputs": [
"{projectRoot}/dist"
Expand All @@ -31,7 +27,7 @@
},
"lint": {
"inputs": [
"default",
"{projectRoot}/**/*",
"{workspaceRoot}/.oxlintrc.js"
],
"cache": true
Expand Down
11 changes: 7 additions & 4 deletions packages/github-to-graphite-button/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
const PATH_REGEX = /^\/([^\/]+)\/([^\/]+)\/pull\/([^\/]+).*$/;
const SELECTOR = '[class^="gh-header-actions"]';

const addButton = (toolbar) => {
const [_, org, repo, pr] = window.location.pathname.match(PATH_REGEX);
const addButton = (toolbar: HTMLElement) => {
const match = window.location.pathname.match(PATH_REGEX);
if (!match) return;

const [_, org, repo, pr] = match;
const graphiteLink = `https://app.graphite.dev/github/pr/${org}/${repo}/${pr}/`;

if (document.getElementById("graphiteLink") != null) {
Expand All @@ -35,14 +38,14 @@ const addButton = (toolbar) => {
};

const toolbarObserver = new MutationObserver((_, observer) => {
const toolbar = document.querySelector(SELECTOR);
const toolbar = document.querySelector(SELECTOR) as HTMLElement;
if (toolbar) {
observer.disconnect();
addButton(toolbar);
}
});

let lastPathname;
let lastPathname: string | undefined;
const routeChangeObserver = new MutationObserver(() => {
const { pathname } = window.location;

Expand Down
9 changes: 9 additions & 0 deletions packages/github-to-graphite-button/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
11 changes: 7 additions & 4 deletions packages/graphite-to-github-button/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ const PATH_REGEX = /^\/github\/pr\/([^\/]+)\/([^\/]+)\/([^\/]+).*$/;
const SELECTOR =
'[class^="PullRequestTitleBar_container_"] > div:nth-child(1) > div:nth-child(2)';

const addButton = (toolbar) => {
const [_, org, repo, pr] = window.location.pathname.match(PATH_REGEX);
const addButton = (toolbar: HTMLElement) => {
const match = window.location.pathname.match(PATH_REGEX);
if (!match) return;

const [_, org, repo, pr] = match;
const gitHubLink = `https://github.com/${org}/${repo}/pull/${pr}`;

if (document.getElementById("gitHubLink") != null) {
Expand All @@ -38,14 +41,14 @@ const addButton = (toolbar) => {
};

const toolbarObserver = new MutationObserver((_, observer) => {
const toolbar = document.querySelector(SELECTOR);
const toolbar = document.querySelector(SELECTOR) as HTMLElement;
if (toolbar) {
observer.disconnect();
addButton(toolbar);
}
});

let lastPathname;
let lastPathname: string | undefined;
const routeChangeObserver = new MutationObserver(() => {
const { pathname } = window.location;

Expand Down
9 changes: 9 additions & 0 deletions packages/graphite-to-github-button/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}