@@ -0,4 +1,8 @@ | ||
| export interface ContextTargetEndpoint { | ||
| endpoint: string; | ||
| } | ||
| export interface ContextConfig { | ||
| name: string; | ||
| endpoint: string; | ||
| targets?: Record<string, ContextTargetEndpoint>; | ||
| createdAt: string; | ||
@@ -26,2 +30,3 @@ updatedAt: string; | ||
| endpoint: string; | ||
| targets?: Record<string, ContextTargetEndpoint>; | ||
| }): ContextConfig; | ||
@@ -33,2 +38,3 @@ loadContext(name: string): ContextConfig | null; | ||
| setCurrentContext(name: string): boolean; | ||
| getTargetEndpoint(targetName: string, contextName?: string): string | null; | ||
| setCredentials(contextName: string, creds: ContextCredentials): void; | ||
@@ -35,0 +41,0 @@ getCredentials(contextName: string): ContextCredentials | null; |
+19
-0
@@ -92,2 +92,5 @@ "use strict"; | ||
| }; | ||
| if (options.targets) { | ||
| context.targets = options.targets; | ||
| } | ||
| writeJson(contextPath(name), context); | ||
@@ -181,2 +184,17 @@ return context; | ||
| } | ||
| function getTargetEndpoint(targetName, contextName) { | ||
| let ctx; | ||
| if (contextName) { | ||
| ctx = loadContext(contextName); | ||
| } | ||
| else { | ||
| ctx = getCurrentContext(); | ||
| } | ||
| if (!ctx) | ||
| return null; | ||
| if (ctx.targets && ctx.targets[targetName]) { | ||
| return ctx.targets[targetName].endpoint; | ||
| } | ||
| return ctx.endpoint; | ||
| } | ||
| return { | ||
@@ -191,2 +209,3 @@ loadSettings, | ||
| setCurrentContext, | ||
| getTargetEndpoint, | ||
| setCredentials, | ||
@@ -193,0 +212,0 @@ getCredentials, |
@@ -0,4 +1,8 @@ | ||
| export interface ContextTargetEndpoint { | ||
| endpoint: string; | ||
| } | ||
| export interface ContextConfig { | ||
| name: string; | ||
| endpoint: string; | ||
| targets?: Record<string, ContextTargetEndpoint>; | ||
| createdAt: string; | ||
@@ -26,2 +30,3 @@ updatedAt: string; | ||
| endpoint: string; | ||
| targets?: Record<string, ContextTargetEndpoint>; | ||
| }): ContextConfig; | ||
@@ -33,2 +38,3 @@ loadContext(name: string): ContextConfig | null; | ||
| setCurrentContext(name: string): boolean; | ||
| getTargetEndpoint(targetName: string, contextName?: string): string | null; | ||
| setCredentials(contextName: string, creds: ContextCredentials): void; | ||
@@ -35,0 +41,0 @@ getCredentials(contextName: string): ContextCredentials | null; |
+19
-0
@@ -56,2 +56,5 @@ import * as fs from 'fs'; | ||
| }; | ||
| if (options.targets) { | ||
| context.targets = options.targets; | ||
| } | ||
| writeJson(contextPath(name), context); | ||
@@ -145,2 +148,17 @@ return context; | ||
| } | ||
| function getTargetEndpoint(targetName, contextName) { | ||
| let ctx; | ||
| if (contextName) { | ||
| ctx = loadContext(contextName); | ||
| } | ||
| else { | ||
| ctx = getCurrentContext(); | ||
| } | ||
| if (!ctx) | ||
| return null; | ||
| if (ctx.targets && ctx.targets[targetName]) { | ||
| return ctx.targets[targetName].endpoint; | ||
| } | ||
| return ctx.endpoint; | ||
| } | ||
| return { | ||
@@ -155,2 +173,3 @@ loadSettings, | ||
| setCurrentContext, | ||
| getTargetEndpoint, | ||
| setCredentials, | ||
@@ -157,0 +176,0 @@ getCredentials, |
+1
-1
@@ -101,2 +101,2 @@ /** | ||
| export { createConfigStore } from './config-store'; | ||
| export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, Credentials, GlobalSettings, } from './config-store'; | ||
| export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, ContextTargetEndpoint, Credentials, GlobalSettings, } from './config-store'; |
+1
-1
@@ -101,2 +101,2 @@ /** | ||
| export { createConfigStore } from './config-store'; | ||
| export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, Credentials, GlobalSettings, } from './config-store'; | ||
| export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, ContextTargetEndpoint, Credentials, GlobalSettings, } from './config-store'; |
+2
-2
| { | ||
| "name": "appstash", | ||
| "version": "0.4.0", | ||
| "version": "0.5.0", | ||
| "author": "Constructive <developers@constructive.io>", | ||
@@ -43,3 +43,3 @@ "description": "Simple, clean application directory resolution", | ||
| ], | ||
| "gitHead": "de740970766f110cad481ea900880a9b3120f9d5" | ||
| "gitHead": "fd9721cb17389c4e2f9847169d5a42de2f9746dd" | ||
| } |
46066
3.64%1126
4.65%