11/**
2- * GitHub Sharing Settings Section
2+ * GitHub Publishing Settings Section
33 *
4- * Feature-owned settings UI for GitHub-based sharing (fallback when Radicle unavailable) .
5- * Rendered within the main settings panel .
4+ * Feature-owned settings UI for publishing DreamSongs to GitHub Pages .
5+ * Mirrors DreamNode repos to GitHub and creates static DreamSong sites .
66 */
77
88import type InterBrainPlugin from '../../main' ;
@@ -14,22 +14,43 @@ interface GitHubIdentity {
1414 ghVersion : string ;
1515}
1616
17+ /**
18+ * Get environment with extended PATH for gh CLI detection
19+ * Obsidian/Electron may not have the full shell PATH
20+ */
21+ function getExtendedEnv ( ) : Record < string , string > {
22+ const nodeProcess = ( globalThis as any ) . process ;
23+ const env = { ...nodeProcess ?. env } ;
24+
25+ // Add common gh install locations to PATH
26+ const extraPaths = [
27+ '/opt/homebrew/bin' , // macOS ARM Homebrew
28+ '/usr/local/bin' , // macOS Intel Homebrew / Linux
29+ '/usr/bin' , // System
30+ `${ env . HOME } /.local/bin` , // Linux user installs
31+ ] . filter ( Boolean ) ;
32+
33+ env . PATH = [ ...extraPaths , env . PATH ] . join ( ':' ) ;
34+ return env ;
35+ }
36+
1737/**
1838 * Get GitHub identity (username and gh version)
1939 */
2040async function getGitHubIdentity ( ) : Promise < GitHubIdentity | null > {
2141 const { exec } = require ( 'child_process' ) ;
2242 const { promisify } = require ( 'util' ) ;
2343 const execAsync = promisify ( exec ) ;
44+ const env = getExtendedEnv ( ) ;
2445
2546 try {
2647 // Get gh version
27- const versionResult = await execAsync ( 'gh --version' ) ;
48+ const versionResult = await execAsync ( 'gh --version' , { env } ) ;
2849 const versionMatch = versionResult . stdout . match ( / g h v e r s i o n ( [ \d . ] + ) / ) ;
2950 const ghVersion = versionMatch ? versionMatch [ 1 ] : 'unknown' ;
3051
3152 // Get authenticated username via gh api
32- const userResult = await execAsync ( 'gh api user --jq .login' ) ;
53+ const userResult = await execAsync ( 'gh api user --jq .login' , { env } ) ;
3354 const username = userResult . stdout . trim ( ) ;
3455
3556 if ( username ) {
@@ -48,12 +69,13 @@ export async function checkGitHubStatus(): Promise<FeatureStatus> {
4869 const { exec } = require ( 'child_process' ) ;
4970 const { promisify } = require ( 'util' ) ;
5071 const execAsync = promisify ( exec ) ;
72+ const env = getExtendedEnv ( ) ;
5173
5274 try {
5375 // Step 1: Check if gh CLI is installed
5476 let ghVersion : string | null = null ;
5577 try {
56- const versionResult = await execAsync ( 'gh --version' ) ;
78+ const versionResult = await execAsync ( 'gh --version' , { env } ) ;
5779 const versionMatch = versionResult . stdout . match ( / g h v e r s i o n ( [ \d . ] + ) / ) ;
5880 ghVersion = versionMatch ? versionMatch [ 1 ] : 'installed' ;
5981 } catch {
@@ -68,7 +90,7 @@ export async function checkGitHubStatus(): Promise<FeatureStatus> {
6890
6991 // Step 2: Check if authenticated
7092 try {
71- const userResult = await execAsync ( 'gh api user --jq .login' ) ;
93+ const userResult = await execAsync ( 'gh api user --jq .login' , { env } ) ;
7294 const username = userResult . stdout . trim ( ) ;
7395
7496 if ( username ) {
@@ -108,22 +130,22 @@ export async function checkGitHubStatus(): Promise<FeatureStatus> {
108130}
109131
110132/**
111- * Create the GitHub sharing settings section
133+ * Create the GitHub publishing settings section
112134 */
113135export function createGitHubSettingsSection (
114136 containerEl : HTMLElement ,
115137 _plugin : InterBrainPlugin ,
116138 status : FeatureStatus | undefined
117139) : void {
118- const header = containerEl . createEl ( 'h2' , { text : '📤 GitHub Sharing (Fallback) ' } ) ;
140+ const header = containerEl . createEl ( 'h2' , { text : '🧬 GitHub Publishing ' } ) ;
119141 header . id = 'github-section' ;
120142
121143 if ( status ) {
122144 createStatusDisplay ( containerEl , status ) ;
123145 }
124146
125147 containerEl . createEl ( 'p' , {
126- text : 'GitHub is used automatically when Radicle is unavailable or on Windows. Creates GitHub repositories and GitHub Pages sites for DreamNodes .' ,
148+ text : 'Publish DreamSongs as static GitHub Pages sites. Also mirrors DreamNode repositories to GitHub as open source .' ,
127149 cls : 'setting-item-description'
128150 } ) ;
129151
0 commit comments