@cloud-cli/px 4.4.3 → 4.4.5
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/dist/index.d.ts +3 -2
- package/dist/index.js +22 -12
- package/dist/proxy-manager.d.ts +2 -3
- package/dist/proxy-manager.js +10 -12
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { help, init } from
|
|
2
|
-
import { DomainAndTarget, DomainName, Proxy, WithOptionalProps } from
|
|
1
|
+
import { help, init } from '@cloud-cli/cli';
|
|
2
|
+
import { DomainAndTarget, DomainName, Proxy, WithOptionalProps } from './types.js';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
add(options: WithOptionalProps<Proxy>): Promise<Proxy>;
|
|
5
5
|
remove(options: WithOptionalProps<DomainAndTarget>): Promise<boolean>;
|
|
@@ -8,6 +8,7 @@ declare const _default: {
|
|
|
8
8
|
get(options: DomainName): Promise<Proxy[]>;
|
|
9
9
|
domains(): Promise<string[]>;
|
|
10
10
|
reload(): Promise<void>;
|
|
11
|
+
restart(): Promise<void>;
|
|
11
12
|
[init](): Promise<import("@cloud-cli/proxy").ProxyServer>;
|
|
12
13
|
[help](): string;
|
|
13
14
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { help, init, logInfo } from
|
|
2
|
-
import { ProxyManager } from
|
|
1
|
+
import { help, init, logInfo } from '@cloud-cli/cli';
|
|
2
|
+
import { ProxyManager } from './proxy-manager.js';
|
|
3
3
|
const manager = new ProxyManager();
|
|
4
4
|
export default {
|
|
5
5
|
async add(options) {
|
|
@@ -21,25 +21,35 @@ export default {
|
|
|
21
21
|
return manager.getDomainList();
|
|
22
22
|
},
|
|
23
23
|
async reload() {
|
|
24
|
-
logInfo(
|
|
24
|
+
logInfo('Reloading proxy configuration');
|
|
25
25
|
return await manager.reload();
|
|
26
26
|
},
|
|
27
|
+
async restart() {
|
|
28
|
+
logInfo('Restarting server');
|
|
29
|
+
return await manager.restart();
|
|
30
|
+
},
|
|
27
31
|
async [init]() {
|
|
28
|
-
await manager.
|
|
32
|
+
await manager.restart();
|
|
29
33
|
return manager.server;
|
|
30
34
|
},
|
|
31
35
|
[help]() {
|
|
32
36
|
return `Manages reverse proxy entries
|
|
33
37
|
|
|
34
38
|
Available commands:
|
|
35
|
-
px.add
|
|
36
|
-
px.
|
|
37
|
-
|
|
38
|
-
px.
|
|
39
|
-
|
|
40
|
-
px.
|
|
41
|
-
|
|
39
|
+
px.add
|
|
40
|
+
px.update
|
|
41
|
+
--domain <domain> <proxy options>
|
|
42
|
+
px.remove
|
|
43
|
+
--domain <domain>
|
|
44
|
+
px.list
|
|
45
|
+
[--domain <domain>] <proxy options>
|
|
46
|
+
px.get
|
|
47
|
+
--domain <domain>
|
|
48
|
+
px.domains
|
|
49
|
+
px.reload
|
|
50
|
+
px.restart
|
|
42
51
|
|
|
43
|
-
Proxy options:
|
|
52
|
+
Proxy options:
|
|
53
|
+
--target <url> [--cors] [--redirect] [--preserveHost] [--redirectUrl <url>] [--headers <headers>] [--authorization <value>]`;
|
|
44
54
|
},
|
|
45
55
|
};
|
package/dist/proxy-manager.d.ts
CHANGED
|
@@ -9,9 +9,8 @@ export declare class ProxyManager {
|
|
|
9
9
|
getProxyListWithContainers(): Promise<Proxy[]>;
|
|
10
10
|
getProxyList(filters?: Partial<Proxy>): Promise<Proxy[]>;
|
|
11
11
|
getProxyListForDomain(options: WithOptionalProps<DomainName>): Promise<Proxy[]>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}): Promise<void>;
|
|
12
|
+
restart(): Promise<void>;
|
|
13
|
+
reload(): Promise<void>;
|
|
15
14
|
private loadProxy;
|
|
16
15
|
getRunningContainers(): Promise<DockerContainer[]>;
|
|
17
16
|
}
|
package/dist/proxy-manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getStorage, getConfig } from '@cloud-cli/cli';
|
|
1
|
+
import { getStorage, getConfig, logInfo, logError } from '@cloud-cli/cli';
|
|
2
2
|
import { ProxyEntry, ProxyServer, ProxySettings } from '@cloud-cli/proxy';
|
|
3
3
|
import { exec } from '@cloud-cli/exec';
|
|
4
4
|
const defaultOptions = {
|
|
@@ -125,20 +125,17 @@ export class ProxyManager {
|
|
|
125
125
|
const all = await this.getProxyListWithContainers();
|
|
126
126
|
return all.filter((p) => p.domain.includes(options.domain));
|
|
127
127
|
}
|
|
128
|
-
async
|
|
128
|
+
async restart() {
|
|
129
|
+
await px.reset();
|
|
130
|
+
await px.start();
|
|
131
|
+
await this.reload();
|
|
132
|
+
}
|
|
133
|
+
async reload() {
|
|
129
134
|
const all = await this.getProxyListWithContainers();
|
|
130
|
-
|
|
131
|
-
px.reset();
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
px.resetProxies();
|
|
135
|
-
}
|
|
135
|
+
px.resetProxies();
|
|
136
136
|
for (const t of all) {
|
|
137
137
|
this.loadProxy(t);
|
|
138
138
|
}
|
|
139
|
-
if (options.servers) {
|
|
140
|
-
px.start();
|
|
141
|
-
}
|
|
142
139
|
}
|
|
143
140
|
loadProxy(t) {
|
|
144
141
|
try {
|
|
@@ -154,9 +151,10 @@ export class ProxyManager {
|
|
|
154
151
|
authorization: t.authorization,
|
|
155
152
|
preserveHost: t.preserveHost,
|
|
156
153
|
}));
|
|
154
|
+
logInfo(` ${t.domain} => ${t.target || t.redirectUrl}`);
|
|
157
155
|
}
|
|
158
156
|
catch (error) {
|
|
159
|
-
|
|
157
|
+
logError(`Error adding proxy for ${t.domain}: ${error}`);
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
160
|
async getRunningContainers() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-cli/px",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.5",
|
|
4
4
|
"description": "Reverse Proxy",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@cloud-cli/proxy": "^1.
|
|
31
|
+
"@cloud-cli/proxy": "^1.12.12",
|
|
32
32
|
"@cloud-cli/exec": "^1.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|