diff --git a/nx.json b/nx.json index 23bc166..837f967 100644 --- a/nx.json +++ b/nx.json @@ -1,8 +1,5 @@ { "$schema": "./node_modules/nx/schemas/nx-schema.json", - "affected": { - "defaultBase": "main" - }, "tasksRunnerOptions": { "default": { "runner": "nx/tasks-runners/default", @@ -21,8 +18,7 @@ "^build" ], "inputs": [ - "production", - "^production" + "{projectRoot}/src/**/*" ], "outputs": [ "{projectRoot}/dist" @@ -31,7 +27,7 @@ }, "lint": { "inputs": [ - "default", + "{projectRoot}/**/*", "{workspaceRoot}/.oxlintrc.js" ], "cache": true diff --git a/packages/github-to-graphite-button/src/index.ts b/packages/github-to-graphite-button/src/index.ts index 41d5ea4..7f60b2f 100644 --- a/packages/github-to-graphite-button/src/index.ts +++ b/packages/github-to-graphite-button/src/index.ts @@ -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) { @@ -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; diff --git a/packages/github-to-graphite-button/tsconfig.json b/packages/github-to-graphite-button/tsconfig.json new file mode 100644 index 0000000..33034f9 --- /dev/null +++ b/packages/github-to-graphite-button/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} \ No newline at end of file diff --git a/packages/graphite-to-github-button/src/index.ts b/packages/graphite-to-github-button/src/index.ts index 5ca7400..cdcdbff 100644 --- a/packages/graphite-to-github-button/src/index.ts +++ b/packages/graphite-to-github-button/src/index.ts @@ -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) { @@ -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; diff --git a/packages/graphite-to-github-button/tsconfig.json b/packages/graphite-to-github-button/tsconfig.json new file mode 100644 index 0000000..33034f9 --- /dev/null +++ b/packages/graphite-to-github-button/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} \ No newline at end of file