@cloud-cli/dx 2.0.0 → 2.1.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/dist/containers.d.ts +2 -9
- package/dist/containers.js +11 -3
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -2
- package/dist/types.d.ts +11 -0
- package/package.json +1 -1
package/dist/containers.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { ServerParams } from '@cloud-cli/cli';
|
|
2
|
-
import {
|
|
2
|
+
import { ContainerName, GetLogsOptions, NameAndStatus } from './types.js';
|
|
3
3
|
export declare function getRunningContainers(): Promise<string[]>;
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
lines?: string;
|
|
7
|
-
}
|
|
8
|
-
interface ContainerName extends ExtraOptions {
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
4
|
+
export declare function getAllContainers(): Promise<NameAndStatus[]>;
|
|
11
5
|
export declare function getLogs(options: GetLogsOptions): Promise<string>;
|
|
12
6
|
export declare function startAll(_: any, cli: any): Promise<boolean>;
|
|
13
7
|
export declare function refreshContainer(options: ContainerName, { run }: ServerParams): Promise<void>;
|
|
14
8
|
export declare function restartContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
|
15
9
|
export declare function startContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
|
16
10
|
export declare function stopContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
|
17
|
-
export {};
|
package/dist/containers.js
CHANGED
|
@@ -7,7 +7,15 @@ export async function getRunningContainers() {
|
|
|
7
7
|
if (!ps.ok) {
|
|
8
8
|
throw new Error('Failed to list containers: ' + ps.stderr);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const list = getListFromString(ps.stdout).sort();
|
|
11
|
+
return list;
|
|
12
|
+
}
|
|
13
|
+
export async function getAllContainers() {
|
|
14
|
+
const running = await getRunningContainers();
|
|
15
|
+
return listContainers().map((c) => ({
|
|
16
|
+
name: c.name,
|
|
17
|
+
status: running.includes(c.name) ? 'running' : 'stopped',
|
|
18
|
+
}));
|
|
11
19
|
}
|
|
12
20
|
export async function getLogs(options) {
|
|
13
21
|
readTargetName(options);
|
|
@@ -23,8 +31,8 @@ export async function getLogs(options) {
|
|
|
23
31
|
return [sh.stdout, sh.stderr].join('\n\n').trim();
|
|
24
32
|
}
|
|
25
33
|
export async function startAll(_, cli) {
|
|
26
|
-
const list =
|
|
27
|
-
const running = await getRunningContainers();
|
|
34
|
+
const list = listContainers();
|
|
35
|
+
const running = (await getRunningContainers());
|
|
28
36
|
const notRunning = list.filter(({ name }) => !running.includes(name));
|
|
29
37
|
for (const app of notRunning) {
|
|
30
38
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { getLogs,
|
|
1
|
+
import { getLogs, refreshContainer, restartContainer, startAll, startContainer, stopContainer } from './containers.js';
|
|
2
2
|
import { prune, pull } from './images.js';
|
|
3
3
|
import { addContainer, getContainer, listContainers, removeContainer, updateContainer } from './store.js';
|
|
4
4
|
export type { Config } from './types.js';
|
|
5
|
+
declare function ps(options?: {
|
|
6
|
+
status?: boolean;
|
|
7
|
+
}): Promise<string[]> | Promise<import("./types.js").NameAndStatus[]>;
|
|
5
8
|
declare const _default: {
|
|
6
9
|
pull: typeof pull;
|
|
7
10
|
prune: typeof prune;
|
|
@@ -15,7 +18,7 @@ declare const _default: {
|
|
|
15
18
|
start: typeof startContainer;
|
|
16
19
|
stop: typeof stopContainer;
|
|
17
20
|
restart: typeof restartContainer;
|
|
18
|
-
ps: typeof
|
|
21
|
+
ps: typeof ps;
|
|
19
22
|
logs: typeof getLogs;
|
|
20
23
|
};
|
|
21
24
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer } from './containers.js';
|
|
1
|
+
import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer } from './containers.js';
|
|
2
2
|
import { prune, pull } from './images.js';
|
|
3
3
|
import { addContainer, getContainer, listContainers, removeContainer, updateContainer } from './store.js';
|
|
4
|
+
function ps(options = {}) {
|
|
5
|
+
if (options.status) {
|
|
6
|
+
return getAllContainers();
|
|
7
|
+
}
|
|
8
|
+
return getRunningContainers();
|
|
9
|
+
}
|
|
4
10
|
export default {
|
|
5
11
|
pull,
|
|
6
12
|
prune,
|
|
@@ -14,6 +20,6 @@ export default {
|
|
|
14
20
|
start: startContainer,
|
|
15
21
|
stop: stopContainer,
|
|
16
22
|
restart: restartContainer,
|
|
17
|
-
ps:
|
|
23
|
+
ps: ps,
|
|
18
24
|
logs: getLogs,
|
|
19
25
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,17 @@ export interface Container {
|
|
|
9
9
|
port: string;
|
|
10
10
|
volumes: string;
|
|
11
11
|
}
|
|
12
|
+
export interface NameAndStatus {
|
|
13
|
+
name: string;
|
|
14
|
+
status: string;
|
|
15
|
+
}
|
|
12
16
|
export interface ExtraOptions {
|
|
13
17
|
_?: string[];
|
|
14
18
|
}
|
|
19
|
+
export interface GetLogsOptions extends ExtraOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
lines?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ContainerName extends ExtraOptions {
|
|
24
|
+
name: string;
|
|
25
|
+
}
|