appstash 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config-store.d.ts +6 -0
- package/config-store.js +19 -0
- package/esm/config-store.d.ts +6 -0
- package/esm/config-store.js +19 -0
- package/esm/index.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
package/config-store.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export interface ContextTargetEndpoint {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
}
|
|
1
4
|
export interface ContextConfig {
|
|
2
5
|
name: string;
|
|
3
6
|
endpoint: string;
|
|
7
|
+
targets?: Record<string, ContextTargetEndpoint>;
|
|
4
8
|
createdAt: string;
|
|
5
9
|
updatedAt: string;
|
|
6
10
|
}
|
|
@@ -23,12 +27,14 @@ export interface ConfigStore {
|
|
|
23
27
|
saveSettings(settings: GlobalSettings): void;
|
|
24
28
|
createContext(name: string, options: {
|
|
25
29
|
endpoint: string;
|
|
30
|
+
targets?: Record<string, ContextTargetEndpoint>;
|
|
26
31
|
}): ContextConfig;
|
|
27
32
|
loadContext(name: string): ContextConfig | null;
|
|
28
33
|
listContexts(): ContextConfig[];
|
|
29
34
|
deleteContext(name: string): boolean;
|
|
30
35
|
getCurrentContext(): ContextConfig | null;
|
|
31
36
|
setCurrentContext(name: string): boolean;
|
|
37
|
+
getTargetEndpoint(targetName: string, contextName?: string): string | null;
|
|
32
38
|
setCredentials(contextName: string, creds: ContextCredentials): void;
|
|
33
39
|
getCredentials(contextName: string): ContextCredentials | null;
|
|
34
40
|
removeCredentials(contextName: string): boolean;
|
package/config-store.js
CHANGED
|
@@ -89,6 +89,9 @@ function createConfigStore(toolName, options) {
|
|
|
89
89
|
createdAt: now,
|
|
90
90
|
updatedAt: now,
|
|
91
91
|
};
|
|
92
|
+
if (options.targets) {
|
|
93
|
+
context.targets = options.targets;
|
|
94
|
+
}
|
|
92
95
|
writeJson(contextPath(name), context);
|
|
93
96
|
return context;
|
|
94
97
|
}
|
|
@@ -177,6 +180,21 @@ function createConfigStore(toolName, options) {
|
|
|
177
180
|
}
|
|
178
181
|
return true;
|
|
179
182
|
}
|
|
183
|
+
function getTargetEndpoint(targetName, contextName) {
|
|
184
|
+
let ctx;
|
|
185
|
+
if (contextName) {
|
|
186
|
+
ctx = loadContext(contextName);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
ctx = getCurrentContext();
|
|
190
|
+
}
|
|
191
|
+
if (!ctx)
|
|
192
|
+
return null;
|
|
193
|
+
if (ctx.targets && ctx.targets[targetName]) {
|
|
194
|
+
return ctx.targets[targetName].endpoint;
|
|
195
|
+
}
|
|
196
|
+
return ctx.endpoint;
|
|
197
|
+
}
|
|
180
198
|
return {
|
|
181
199
|
loadSettings,
|
|
182
200
|
saveSettings,
|
|
@@ -186,6 +204,7 @@ function createConfigStore(toolName, options) {
|
|
|
186
204
|
deleteContext,
|
|
187
205
|
getCurrentContext,
|
|
188
206
|
setCurrentContext,
|
|
207
|
+
getTargetEndpoint,
|
|
189
208
|
setCredentials,
|
|
190
209
|
getCredentials,
|
|
191
210
|
removeCredentials,
|
package/esm/config-store.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export interface ContextTargetEndpoint {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
}
|
|
1
4
|
export interface ContextConfig {
|
|
2
5
|
name: string;
|
|
3
6
|
endpoint: string;
|
|
7
|
+
targets?: Record<string, ContextTargetEndpoint>;
|
|
4
8
|
createdAt: string;
|
|
5
9
|
updatedAt: string;
|
|
6
10
|
}
|
|
@@ -23,12 +27,14 @@ export interface ConfigStore {
|
|
|
23
27
|
saveSettings(settings: GlobalSettings): void;
|
|
24
28
|
createContext(name: string, options: {
|
|
25
29
|
endpoint: string;
|
|
30
|
+
targets?: Record<string, ContextTargetEndpoint>;
|
|
26
31
|
}): ContextConfig;
|
|
27
32
|
loadContext(name: string): ContextConfig | null;
|
|
28
33
|
listContexts(): ContextConfig[];
|
|
29
34
|
deleteContext(name: string): boolean;
|
|
30
35
|
getCurrentContext(): ContextConfig | null;
|
|
31
36
|
setCurrentContext(name: string): boolean;
|
|
37
|
+
getTargetEndpoint(targetName: string, contextName?: string): string | null;
|
|
32
38
|
setCredentials(contextName: string, creds: ContextCredentials): void;
|
|
33
39
|
getCredentials(contextName: string): ContextCredentials | null;
|
|
34
40
|
removeCredentials(contextName: string): boolean;
|
package/esm/config-store.js
CHANGED
|
@@ -53,6 +53,9 @@ export function createConfigStore(toolName, options) {
|
|
|
53
53
|
createdAt: now,
|
|
54
54
|
updatedAt: now,
|
|
55
55
|
};
|
|
56
|
+
if (options.targets) {
|
|
57
|
+
context.targets = options.targets;
|
|
58
|
+
}
|
|
56
59
|
writeJson(contextPath(name), context);
|
|
57
60
|
return context;
|
|
58
61
|
}
|
|
@@ -141,6 +144,21 @@ export function createConfigStore(toolName, options) {
|
|
|
141
144
|
}
|
|
142
145
|
return true;
|
|
143
146
|
}
|
|
147
|
+
function getTargetEndpoint(targetName, contextName) {
|
|
148
|
+
let ctx;
|
|
149
|
+
if (contextName) {
|
|
150
|
+
ctx = loadContext(contextName);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
ctx = getCurrentContext();
|
|
154
|
+
}
|
|
155
|
+
if (!ctx)
|
|
156
|
+
return null;
|
|
157
|
+
if (ctx.targets && ctx.targets[targetName]) {
|
|
158
|
+
return ctx.targets[targetName].endpoint;
|
|
159
|
+
}
|
|
160
|
+
return ctx.endpoint;
|
|
161
|
+
}
|
|
144
162
|
return {
|
|
145
163
|
loadSettings,
|
|
146
164
|
saveSettings,
|
|
@@ -150,6 +168,7 @@ export function createConfigStore(toolName, options) {
|
|
|
150
168
|
deleteContext,
|
|
151
169
|
getCurrentContext,
|
|
152
170
|
setCurrentContext,
|
|
171
|
+
getTargetEndpoint,
|
|
153
172
|
setCredentials,
|
|
154
173
|
getCredentials,
|
|
155
174
|
removeCredentials,
|
package/esm/index.d.ts
CHANGED
|
@@ -98,4 +98,4 @@ export declare function ensure(dirs: AppStashResult): EnsureResult;
|
|
|
98
98
|
*/
|
|
99
99
|
export declare function resolve(dirs: AppStashResult, kind: 'config' | 'cache' | 'data' | 'logs' | 'tmp', ...parts: string[]): string;
|
|
100
100
|
export { createConfigStore } from './config-store';
|
|
101
|
-
export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, Credentials, GlobalSettings, } from './config-store';
|
|
101
|
+
export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, ContextTargetEndpoint, Credentials, GlobalSettings, } from './config-store';
|
package/index.d.ts
CHANGED
|
@@ -98,4 +98,4 @@ export declare function ensure(dirs: AppStashResult): EnsureResult;
|
|
|
98
98
|
*/
|
|
99
99
|
export declare function resolve(dirs: AppStashResult, kind: 'config' | 'cache' | 'data' | 'logs' | 'tmp', ...parts: string[]): string;
|
|
100
100
|
export { createConfigStore } from './config-store';
|
|
101
|
-
export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, Credentials, GlobalSettings, } from './config-store';
|
|
101
|
+
export type { ConfigStore, ConfigStoreOptions, ContextConfig, ContextCredentials, ContextTargetEndpoint, Credentials, GlobalSettings, } from './config-store';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appstash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Simple, clean application directory resolution",
|
|
6
6
|
"main": "index.js",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"xdg",
|
|
41
41
|
"appdirs"
|
|
42
42
|
],
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "fd9721cb17389c4e2f9847169d5a42de2f9746dd"
|
|
44
44
|
}
|