Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3043b0
commit 4f49798
Showing
8 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 1 addition & 1 deletion
2
packages/lib/src/SettingsLoader/CommandLineArgumentSettingsLoader.ts
This file contains 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 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 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
2 changes: 1 addition & 1 deletion
2
packages/lib/src/SettingsLoader/EnvironmentVariableSettingsLoader.ts
This file contains 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 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,49 @@ | ||
import { ConfluenceSettings } from "../Settings"; | ||
|
||
export abstract class SettingsLoader { | ||
abstract loadPartial(): Partial<ConfluenceSettings>; | ||
|
||
load(): ConfluenceSettings { | ||
const initialSettings = this.loadPartial(); | ||
const settings = this.validateSettings(initialSettings); | ||
return settings; | ||
} | ||
|
||
protected validateSettings( | ||
settings: Partial<ConfluenceSettings> | ||
): ConfluenceSettings { | ||
if (!settings.confluenceBaseUrl) { | ||
throw new Error("Confluence base URL is required"); | ||
} | ||
|
||
if (!settings.confluenceParentId) { | ||
throw new Error("Confluence parent ID is required"); | ||
} | ||
|
||
if (!settings.atlassianUserName) { | ||
throw new Error("Atlassian user name is required"); | ||
} | ||
|
||
if (!settings.atlassianApiToken) { | ||
throw new Error("Atlassian API token is required"); | ||
} | ||
|
||
if (!settings.folderToPublish) { | ||
throw new Error("Folder to publish is required"); | ||
} | ||
|
||
if (!settings.contentRoot) { | ||
throw new Error("Content root is required"); | ||
} else { | ||
if (!settings.contentRoot.endsWith("/")) { | ||
settings.contentRoot += "/"; | ||
} | ||
} | ||
|
||
if (!("firstHeadingPageTitle" in settings)) { | ||
settings.firstHeadingPageTitle = false; | ||
} | ||
|
||
return settings as ConfluenceSettings; | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,56 +1,7 @@ | ||
import { ConfluenceSettings } from "../Settings"; | ||
|
||
export * from "./AutoSettingsLoader"; | ||
export * from "./CommandLineArgumentSettingsLoader"; | ||
export * from "./ConfigFileSettingsLoader"; | ||
export * from "./DefaultSettingsLoader"; | ||
export * from "./EnvironmentVariableSettingsLoader"; | ||
export * from "./StaticSettingsLoader"; | ||
|
||
export abstract class SettingsLoader { | ||
abstract loadPartial(): Partial<ConfluenceSettings>; | ||
|
||
load(): ConfluenceSettings { | ||
const initialSettings = this.loadPartial(); | ||
const settings = this.validateSettings(initialSettings); | ||
return settings; | ||
} | ||
|
||
protected validateSettings( | ||
settings: Partial<ConfluenceSettings> | ||
): ConfluenceSettings { | ||
if (!settings.confluenceBaseUrl) { | ||
throw new Error("Confluence base URL is required"); | ||
} | ||
|
||
if (!settings.confluenceParentId) { | ||
throw new Error("Confluence parent ID is required"); | ||
} | ||
|
||
if (!settings.atlassianUserName) { | ||
throw new Error("Atlassian user name is required"); | ||
} | ||
|
||
if (!settings.atlassianApiToken) { | ||
throw new Error("Atlassian API token is required"); | ||
} | ||
|
||
if (!settings.folderToPublish) { | ||
throw new Error("Folder to publish is required"); | ||
} | ||
|
||
if (!settings.contentRoot) { | ||
throw new Error("Content root is required"); | ||
} else { | ||
if (!settings.contentRoot.endsWith("/")) { | ||
settings.contentRoot += "/"; | ||
} | ||
} | ||
|
||
if (!("firstHeadingPageTitle" in settings)) { | ||
settings.firstHeadingPageTitle = false; | ||
} | ||
|
||
return settings as ConfluenceSettings; | ||
} | ||
} | ||
export * from "./SettingsLoader"; |