-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Jira active tasks right panel #2008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8bad0e9
feat: Jira Active Tasks Right Panel v1
brherron 3157505
chore: good start
brherron 3b04e41
chore: good spot on the jira props
brherron 8c5b782
docs: add jira ticket detail pane redesign spec
brherron 2a7e545
docs: add jira related issues detail row spec
brherron 625e06e
chore: added related tasks
brherron d8ee5ad
chore: fixing missing pieces
brherron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ apps/*/dist | |
| packages/*/dist | ||
| .env | ||
| .env.local | ||
| .t3-jira-config.json | ||
| build/ | ||
| .logs/ | ||
| release/ | ||
|
|
||
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
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import { spawnSync } from "node:child_process"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const bunExecutable = process.env.npm_execpath ?? "bun"; | ||
| const cliEntrypoint = fileURLToPath(new URL("./cli.ts", import.meta.url)); | ||
|
|
||
| const result = spawnSync(bunExecutable, [cliEntrypoint, ...process.argv.slice(2)], { | ||
| stdio: "inherit", | ||
| }); | ||
|
|
||
| if (result.error) { | ||
| throw result.error; | ||
| } | ||
|
|
||
| process.exit(result.status ?? 1); | ||
|
brherron marked this conversation as resolved.
|
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
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
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 |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| import { readFile } from "node:fs/promises"; | ||
| import path from "node:path"; | ||
|
|
||
| import { Effect, Layer, Schema } from "effect"; | ||
|
|
||
| import { JiraError, TrimmedNonEmptyString } from "@t3tools/contracts"; | ||
| import { JiraConfig, type ResolvedJiraConfig } from "../Services/JiraConfig.ts"; | ||
| import { runProcess } from "../../processRunner.ts"; | ||
|
|
||
| const JiraAutomationConfigSchema = Schema.Struct({ | ||
| enabled: Schema.Boolean, | ||
| transitionId: Schema.optional(TrimmedNonEmptyString), | ||
| }); | ||
|
|
||
| const JiraFileConfigSchema = Schema.Struct({ | ||
| baseUrl: TrimmedNonEmptyString, | ||
| email: TrimmedNonEmptyString, | ||
| token: TrimmedNonEmptyString, | ||
| automations: Schema.optional( | ||
| Schema.Struct({ | ||
| on_branch_created: Schema.optional(JiraAutomationConfigSchema), | ||
| on_pr_opened: Schema.optional(JiraAutomationConfigSchema), | ||
| }), | ||
| ), | ||
| }); | ||
|
|
||
| function normalizeConfig( | ||
| input: typeof JiraFileConfigSchema.Type, | ||
| configPath: string, | ||
| ): ResolvedJiraConfig { | ||
| let baseUrl: string; | ||
| try { | ||
| const url = new URL(input.baseUrl); | ||
| url.pathname = ""; | ||
| url.search = ""; | ||
| url.hash = ""; | ||
| baseUrl = url.toString().replace(/\/+$/g, ""); | ||
| } catch (cause) { | ||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.parse", | ||
| message: "Invalid Jira baseUrl in .t3-jira-config.json.", | ||
| cause, | ||
| }); | ||
| } | ||
|
|
||
| return { | ||
| configPath, | ||
| baseUrl, | ||
| email: input.email, | ||
| token: input.token, | ||
| automations: input.automations ?? {}, | ||
| }; | ||
| } | ||
|
|
||
| async function resolveConfigPath(cwd: string): Promise<string> { | ||
| const result = await runProcess("git", ["-C", cwd, "rev-parse", "--git-common-dir"], { | ||
| allowNonZeroExit: true, | ||
| }); | ||
|
|
||
| if (result.code !== 0) { | ||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.resolvePath", | ||
| message: "Jira config requires a git repository.", | ||
| }); | ||
| } | ||
|
|
||
| const rawCommonDir = result.stdout.trim(); | ||
| if (rawCommonDir.length === 0) { | ||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.resolvePath", | ||
| message: "Could not resolve the shared git directory.", | ||
| }); | ||
| } | ||
|
|
||
| const commonDir = path.resolve(cwd, rawCommonDir); | ||
| const repoRoot = path.basename(commonDir) === ".git" ? path.dirname(commonDir) : commonDir; | ||
| return path.join(repoRoot, ".t3-jira-config.json"); | ||
| } | ||
|
|
||
| const parseJiraFileConfig = Schema.decodeUnknownSync(JiraFileConfigSchema); | ||
|
|
||
| async function loadResolvedConfig(cwd: string): Promise<ResolvedJiraConfig> { | ||
| const configPath = await resolveConfigPath(cwd); | ||
|
|
||
| let rawConfig: string; | ||
| try { | ||
| rawConfig = await readFile(configPath, "utf8"); | ||
| } catch (cause) { | ||
| const code = (cause as NodeJS.ErrnoException | undefined)?.code; | ||
| if (code === "ENOENT") { | ||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.read", | ||
| message: "Missing .t3-jira-config.json in the shared repository root.", | ||
| cause, | ||
| }); | ||
| } | ||
|
|
||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.read", | ||
| message: "Failed to read .t3-jira-config.json.", | ||
| cause, | ||
| }); | ||
| } | ||
|
|
||
| let decoded: unknown; | ||
| try { | ||
| decoded = JSON.parse(rawConfig); | ||
| } catch (cause) { | ||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.parse", | ||
| message: "Invalid Jira config JSON.", | ||
| cause, | ||
| }); | ||
| } | ||
|
|
||
| try { | ||
| return normalizeConfig(parseJiraFileConfig(decoded), configPath); | ||
| } catch (cause) { | ||
| if (Schema.is(JiraError)(cause)) { | ||
| throw cause; | ||
| } | ||
|
|
||
| throw new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.parse", | ||
| message: "Invalid Jira config shape.", | ||
| cause, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| export const makeJiraConfig = () => | ||
| Layer.effect( | ||
| JiraConfig, | ||
| Effect.succeed({ | ||
| getConfigStatus: (cwd: string) => | ||
| Effect.tryPromise({ | ||
| try: async () => { | ||
| let configPath: string; | ||
| try { | ||
| configPath = await resolveConfigPath(cwd); | ||
| } catch (cause) { | ||
| return { | ||
| status: "invalid" as const, | ||
| configPath: path.join(cwd, ".t3-jira-config.json"), | ||
| error: | ||
| cause instanceof Error ? cause.message : "Failed to resolve Jira config path.", | ||
| }; | ||
| } | ||
|
|
||
| try { | ||
| await loadResolvedConfig(cwd); | ||
| return { | ||
| status: "ready" as const, | ||
| configPath, | ||
| }; | ||
| } catch (cause) { | ||
| if (Schema.is(JiraError)(cause) && cause.kind === "config") { | ||
| return { | ||
| status: cause.message.includes("Missing .t3-jira-config.json") | ||
| ? ("missing" as const) | ||
| : ("invalid" as const), | ||
| configPath, | ||
| ...(cause.message.includes("Missing .t3-jira-config.json") | ||
| ? {} | ||
| : { error: cause.message }), | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| status: "invalid" as const, | ||
| configPath, | ||
| error: cause instanceof Error ? cause.message : "Failed to load Jira config.", | ||
| }; | ||
| } | ||
| }, | ||
| catch: (cause) => | ||
| new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.status", | ||
| message: "Failed to inspect Jira config status.", | ||
| cause, | ||
| }), | ||
| }), | ||
| getResolvedConfig: (cwd: string) => | ||
| Effect.tryPromise({ | ||
| try: () => loadResolvedConfig(cwd), | ||
| catch: (cause) => | ||
| Schema.is(JiraError)(cause) | ||
| ? cause | ||
| : new JiraError({ | ||
| kind: "config", | ||
| operation: "jira.config.load", | ||
| message: "Failed to load Jira config.", | ||
| cause, | ||
| }), | ||
| }), | ||
| }), | ||
| ); | ||
|
|
||
| export const JiraConfigLive = makeJiraConfig(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
scripts/cli.mjs:6When this script is invoked via
npm run,process.env.npm_execpathcontains npm's CLI script path (e.g.,/usr/lib/node_modules/npm/bin/npm-cli.js), not a runtime executable.spawnSyncthen attempts to use that npm script to executecli.ts, which fails because npm's CLI cannot directly run TypeScript files. The intent is to runcli.tswith bun, so thenpm_execpathcheck is counterproductive when npm is the package manager. Consider removing thenpm_execpathfallback or checking that the value is actually bun.Also found in 1 other location(s)
apps/server/scripts/cli.ts:147🤖 Copy this AI Prompt to have your agent fix this: