Skip to content

Commit

Permalink
chore: update environment vars for branch main and stable
Browse files Browse the repository at this point in the history
branch urls now handled by Env
  • Loading branch information
Aetherinox committed Apr 3, 2024
1 parent b88fc60 commit 271a25c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
13 changes: 8 additions & 5 deletions src/api/Env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { App, PluginManifest, apiVersion } from 'obsidian'
import { lng } from 'src/lang'

/*
Plugin ID
Expand Down Expand Up @@ -30,7 +31,8 @@ type Repo =
urlWiki?: HttpsUrl
urlIssues?: HttpsUrl
urlReleases?: HttpsUrl
urlPackage?: HttpsUrl
urlBranchMain?: HttpsUrl
urlBranchBeta?: HttpsUrl
urlDemoVault?: HttpsUrl
}

Expand All @@ -51,7 +53,8 @@ export abstract class Env
urlWiki: 'https://github.com/Aetherinox/obsidian-gistr/wiki',
urlIssues: 'https://github.com/Aetherinox/obsidian-gistr/issues',
urlReleases: 'https://github.com/Aetherinox/obsidian-gistr/releases',
urlPackage: 'https://raw.githubusercontent.com/Aetherinox/obsidian-gistr/{0}/package.json',
urlBranchMain: 'https://raw.githubusercontent.com/Aetherinox/obsidian-gistr/main/package.json',
urlBranchBeta: 'https://raw.githubusercontent.com/Aetherinox/obsidian-gistr/beta/package.json',
urlDemoVault: 'https://github.com/Aetherinox/obsidian-gistr/tree/main/tests/gistr-vault',
}

Expand All @@ -62,7 +65,7 @@ export abstract class Env
static _Initialize( app: App, manifest: PluginManifest )
{
if ( this._manifest || this._obsidianApiVer )
throw console.log( 'Plugin attempted to define data more than once' )
throw console.log( lng( 'base_saturyn_define' ) )

this._obsidianApiVer = apiVersion
this._manifest = manifest
Expand All @@ -75,7 +78,7 @@ export abstract class Env
static get obsidianVersion( )
{
if ( !this._obsidianApiVer )
throw console.log( 'Obsidian version not set. Ensure Env._Initialize() has fired. ' )
throw console.log( lng( 'base_saturyn_obsidianver_notinitialized' ) )

return this._obsidianApiVer
}
Expand Down Expand Up @@ -105,7 +108,7 @@ export abstract class Env
static get manifest( ): PluginManifest
{
if ( !this._manifest )
throw console.log( 'Plugin manifest not set. Ensure Env._Initialize() has fired.' )
throw console.log( lng( 'base_saturyn_pluginmanifest_notinitialized' ) )

return this._manifest
}
Expand Down
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ export default class GistrPlugin extends Plugin
try
{
const ver_running = this.manifest.version
let ver_stable = await requestUrl( lng( "ver_url", "main" ) ).then( async ( res ) =>
let ver_stable = await requestUrl( Env.Links[ 'urlBranchMain' ] ).then( async ( res ) =>
{
if ( res.status === 200 )
{
Expand All @@ -657,10 +657,10 @@ export default class GistrPlugin extends Plugin
} )
.catch( ( err ) =>
{
console.error( `Failed to fetch version (stable): ${ err }` )
console.error( lng( 'base_ver_nofetch', 'stable', err ) )
} )

let ver_beta = await requestUrl( lng( "ver_url", "beta" ) ).then( async ( res ) =>
let ver_beta = await requestUrl( Env.Links[ 'urlBranchBeta' ] ).then( async ( res ) =>
{
if ( res.status === 200 )
{
Expand All @@ -670,7 +670,7 @@ export default class GistrPlugin extends Plugin
} )
.catch( ( err ) =>
{
console.error( `Failed to fetch version (beta): ${ err }` )
console.error( lng( 'base_ver_nofetch', 'beta', err ) )
} )

/*
Expand Down Expand Up @@ -712,7 +712,7 @@ export default class GistrPlugin extends Plugin
}
catch ( exception )
{
console.error( `Could not fetch version information: ${ exception }\n` )
console.error( lng( 'base_ver_nofind', exception ) )
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/settings/sections/SettingsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ColorPickrDefaults: Record< string, Color > =
"og_clr_bg_light": "#CBCBCB",
"og_clr_bg_dark": "#121315",
"og_clr_sb_light": "#BA4956",
"og_clr_sb_dark": "#4960ba",
"og_clr_sb_dark": "#4960BA",
"og_clr_tx_light": "#2A2626",
"og_clr_tx_dark": "#CAD3F5",

Expand Down Expand Up @@ -2016,7 +2016,7 @@ export class SettingsSection extends PluginSettingTab

try
{
get_ver_stable: requestUrl( lng( "ver_url", "main" ) ).then( ( res ) =>
get_ver_stable: requestUrl( Env.Links[ 'urlBranchMain' ] ).then( ( res ) =>
{
if ( res.status === 200 )
return res.json.version ?? lng( "cfg_tab_su_ver_connection_issues" )
Expand All @@ -2025,10 +2025,10 @@ export class SettingsSection extends PluginSettingTab
})
.catch( ( err ) =>
{
console.error( `Promise rejected: ${ err }` );
console.error( lng( 'base_promise_rejected', err ) )
} )

get_ver_beta: requestUrl( lng( "ver_url", "beta" ) ).then( ( res ) =>
get_ver_beta: requestUrl( Env.Links[ 'urlBranchBeta' ] ).then( ( res ) =>
{
if ( res.status === 200 )
return res.json.version ?? lng( "cfg_tab_su_ver_connection_issues" )
Expand All @@ -2037,12 +2037,12 @@ export class SettingsSection extends PluginSettingTab
} )
.catch( ( err ) =>
{
console.error( `Promise rejected: ${ err }` );
console.error( lng( 'base_promise_rejected', err ) )
} )
}
catch ( exception )
{
console.error( `Could not fetch version information: ${ exception }\n` )
console.error( lng( 'base_ver_nofind', exception ) )
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface GistrSettings
gh_clr_bg_light: string | "E5E5E5"
gh_clr_bg_dark: string | "121315"
gh_clr_sb_light: string | "3D85C4"
gh_clr_sb_dark: string | "4960ba"
gh_clr_sb_dark: string | "4960BA"
gh_clr_tx_light: string | "2A2626"
gh_clr_tx_dark: string | "CAD3F5"
gh_opacity: number | 1
Expand Down

0 comments on commit 271a25c

Please sign in to comment.