@cloud-cli/dx 2.5.0 → 2.6.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/README.md CHANGED
@@ -1,10 +1,10 @@
1
- ## DX
1
+ # DX
2
2
 
3
3
  Run Docker containers
4
4
 
5
5
  ## Install
6
6
 
7
- ```
7
+ ```sh
8
8
  npm i @cloud-cli/dx
9
9
  ```
10
10
 
@@ -24,10 +24,10 @@ cy dx.updateAll --image node:latest
24
24
 
25
25
  ## Options
26
26
 
27
- | Option | Description |
28
- |-|-|
29
- | name | Required. Container name |
30
- | image | Required: Container image |
31
- | volumes | Comma-separated list of volume bindings |
32
- | port | Empty = random port. `:port` = random host port. `number` = fixed port on host and container |
33
- | domain | Domain to bind this container to. Requires `@cloud-cli/px` and `@cloud-cli/dns` |
27
+ | Option | Description |
28
+ | ------- | -------------------------------------------------------------------------------------------- |
29
+ | name | Required. Container name |
30
+ | image | Required: Container image |
31
+ | volumes | Comma-separated list of volume bindings |
32
+ | port | Empty = random port. `:port` = random host port. `number` = fixed port on host and container |
33
+ | domain | Domain to bind this container to. Requires `@cloud-cli/px` and `@cloud-cli/dns` |
@@ -4,10 +4,12 @@ export declare function getRunningContainers(): Promise<string[]>;
4
4
  export declare function getAllContainers(): Promise<NameAndStatus[]>;
5
5
  export declare function getLogs(options: GetLogsOptions): Promise<string>;
6
6
  export declare function renameContainer(options: RenameOptions): Container;
7
- export declare function startAll(_: any, cli: any): Promise<boolean>;
8
- export declare function updateAll(options: {
9
- image: string;
10
- }, cli: any): Promise<any[]>;
7
+ export interface AllOptions {
8
+ image?: string;
9
+ }
10
+ export declare function updateAll({ image }: AllOptions, cli: any): Promise<any[]>;
11
+ export declare function startAll({ image }: AllOptions, cli: any): Promise<boolean>;
12
+ export declare function stopAll({ image }: AllOptions, cli: any): Promise<any[]>;
11
13
  export declare function refreshContainer(options: ContainerName, { run }: ServerParams): Promise<void>;
12
14
  export declare function restartContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
13
15
  export interface StartOptions {
@@ -44,8 +44,20 @@ export function renameContainer(options) {
44
44
  }
45
45
  return rename(name, newName);
46
46
  }
47
- export async function startAll(_, cli) {
48
- const list = listContainers();
47
+ export async function updateAll({ image } = {}, cli) {
48
+ const list = listContainers({ image });
49
+ const affected = [];
50
+ for (const app of list) {
51
+ try {
52
+ await refreshContainer({ name: app.name }, cli);
53
+ affected.push(app.name);
54
+ }
55
+ catch { }
56
+ }
57
+ return affected;
58
+ }
59
+ export async function startAll({ image } = {}, cli) {
60
+ const list = listContainers({ image });
49
61
  const running = (await getRunningContainers());
50
62
  const notRunning = list.filter(({ name }) => !running.includes(name));
51
63
  for (const app of notRunning) {
@@ -56,14 +68,14 @@ export async function startAll(_, cli) {
56
68
  }
57
69
  return true;
58
70
  }
59
- export async function updateAll(options, cli) {
60
- const list = listContainers();
71
+ export async function stopAll({ image } = {}, cli) {
72
+ const list = listContainers({ image });
73
+ const running = await getRunningContainers();
74
+ const runningContainers = list.filter(({ name }) => running.includes(name));
61
75
  const affected = [];
62
- for (const app of list) {
63
- if (app.image !== options.image)
64
- continue;
76
+ for (const app of runningContainers) {
65
77
  try {
66
- await refreshContainer({ name: app.name }, cli);
78
+ await stopContainer({ name: app.name }, cli);
67
79
  affected.push(app.name);
68
80
  }
69
81
  catch { }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getLogs, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer, runContainer } from "./containers.js";
1
+ import { getLogs, refreshContainer, restartContainer, startAll, updateAll, startContainer, stopAll, stopContainer, renameContainer, runContainer } 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";
@@ -15,9 +15,11 @@ declare const _default: {
15
15
  list: typeof listContainers;
16
16
  refresh: typeof refreshContainer;
17
17
  update: typeof updateContainer;
18
+ updateAll: typeof updateAll;
18
19
  startAll: typeof startAll;
19
20
  start: typeof startContainer;
20
21
  run: typeof runContainer;
22
+ stopAll: typeof stopAll;
21
23
  stop: typeof stopContainer;
22
24
  restart: typeof restartContainer;
23
25
  ps: typeof ps;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer, runContainer, } from "./containers.js";
1
+ import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, updateAll, startContainer, stopAll, stopContainer, renameContainer, runContainer, } from "./containers.js";
2
2
  import { prune, pull } from "./images.js";
3
3
  import { addContainer, getContainer, listContainers, removeContainer, updateContainer, } from "./store.js";
4
4
  function ps(options = {}) {
@@ -17,9 +17,11 @@ export default {
17
17
  list: listContainers,
18
18
  refresh: refreshContainer,
19
19
  update: updateContainer,
20
+ updateAll,
20
21
  startAll,
21
22
  start: startContainer,
22
23
  run: runContainer,
24
+ stopAll,
23
25
  stop: stopContainer,
24
26
  restart: restartContainer,
25
27
  ps: ps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/dx",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Docker container management",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",