@cloud-cli/dx 2.2.2 → 2.3.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 -1
- package/dist/containers.js +15 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/store.d.ts +1 -0
- package/dist/store.js +7 -0
- package/dist/types.d.ts +4 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +3 -0
- package/package.json +1 -1
package/dist/containers.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ServerParams } from '@cloud-cli/cli';
|
|
2
|
-
import { ContainerName, GetLogsOptions, NameAndStatus } from './types.js';
|
|
2
|
+
import { Container, ContainerName, GetLogsOptions, NameAndStatus, RenameOptions } from './types.js';
|
|
3
3
|
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
|
+
export declare function renameContainer(options: RenameOptions): Container;
|
|
6
7
|
export declare function startAll(_: any, cli: any): Promise<boolean>;
|
|
7
8
|
export declare function refreshContainer(options: ContainerName, { run }: ServerParams): Promise<void>;
|
|
8
9
|
export declare function restartContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
package/dist/containers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { exec } from '@cloud-cli/exec';
|
|
2
2
|
import { getConfig, logInfo, logError } from '@cloud-cli/cli';
|
|
3
|
-
import { findContainer, listContainers } from './store.js';
|
|
4
|
-
import { addExecFlag, getEnvVars, getListFromString, readTargetName } from './utils.js';
|
|
3
|
+
import { findContainer, listContainers, rename } from './store.js';
|
|
4
|
+
import { addExecFlag, getEnvVars, getListFromString, readTargetName, readTargetNewName } from './utils.js';
|
|
5
5
|
import getPort from 'get-port';
|
|
6
6
|
export async function getRunningContainers() {
|
|
7
7
|
const ps = await exec('docker', ['ps', '--format', '{{.Names}}']);
|
|
@@ -31,6 +31,19 @@ export async function getLogs(options) {
|
|
|
31
31
|
const sh = await exec('docker', args);
|
|
32
32
|
return [sh.stdout, sh.stderr].join('\n\n').trim();
|
|
33
33
|
}
|
|
34
|
+
export function renameContainer(options) {
|
|
35
|
+
readTargetName(options);
|
|
36
|
+
readTargetNewName(options);
|
|
37
|
+
const { name, newName } = options;
|
|
38
|
+
if (!name || !newName) {
|
|
39
|
+
throw new Error('Name and new name required');
|
|
40
|
+
}
|
|
41
|
+
const container = findContainer(name);
|
|
42
|
+
if (!container) {
|
|
43
|
+
throw new Error('Container not found: ' + name);
|
|
44
|
+
}
|
|
45
|
+
return rename(name, newName);
|
|
46
|
+
}
|
|
34
47
|
export async function startAll(_, cli) {
|
|
35
48
|
const list = listContainers();
|
|
36
49
|
const running = (await getRunningContainers());
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getLogs, refreshContainer, restartContainer, startAll, startContainer, stopContainer } from
|
|
2
|
-
import { prune, pull } from
|
|
3
|
-
import { addContainer, getContainer, listContainers, removeContainer, updateContainer } from
|
|
4
|
-
export type { Config } from
|
|
1
|
+
import { getLogs, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer } from "./containers.js";
|
|
2
|
+
import { prune, pull } from "./images.js";
|
|
3
|
+
import { addContainer, getContainer, listContainers, removeContainer, updateContainer } from "./store.js";
|
|
4
|
+
export type { Config } from "./types.js";
|
|
5
5
|
declare function ps(options?: {
|
|
6
6
|
status?: boolean;
|
|
7
7
|
}): Promise<string[]> | Promise<import("./types.js").NameAndStatus[]>;
|
|
@@ -10,6 +10,7 @@ declare const _default: {
|
|
|
10
10
|
prune: typeof prune;
|
|
11
11
|
add: typeof addContainer;
|
|
12
12
|
remove: typeof removeContainer;
|
|
13
|
+
rename: typeof renameContainer;
|
|
13
14
|
get: typeof getContainer;
|
|
14
15
|
list: typeof listContainers;
|
|
15
16
|
refresh: typeof refreshContainer;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer } from
|
|
2
|
-
import { prune, pull } from
|
|
3
|
-
import { addContainer, getContainer, listContainers, removeContainer, updateContainer } from
|
|
1
|
+
import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer, } from "./containers.js";
|
|
2
|
+
import { prune, pull } from "./images.js";
|
|
3
|
+
import { addContainer, getContainer, listContainers, removeContainer, updateContainer, } from "./store.js";
|
|
4
4
|
function ps(options = {}) {
|
|
5
5
|
if (options.status) {
|
|
6
6
|
return getAllContainers();
|
|
@@ -12,6 +12,7 @@ export default {
|
|
|
12
12
|
prune,
|
|
13
13
|
add: addContainer,
|
|
14
14
|
remove: removeContainer,
|
|
15
|
+
rename: renameContainer,
|
|
15
16
|
get: getContainer,
|
|
16
17
|
list: listContainers,
|
|
17
18
|
refresh: refreshContainer,
|
package/dist/store.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function addContainer(options: ContainerUpdateOptions): Container
|
|
|
13
13
|
export declare function removeContainer(options: ContainerName): boolean;
|
|
14
14
|
export declare function getContainer(options: ContainerName): Container;
|
|
15
15
|
export declare function updateContainer(options: Partial<ContainerUpdateOptions>): Container;
|
|
16
|
+
export declare function rename(name: string, newName: string): Container;
|
|
16
17
|
export declare function listContainers(options?: ContainerListOptions): Container[];
|
|
17
18
|
export declare function findContainer(name: string): Container;
|
|
18
19
|
export {};
|
package/dist/store.js
CHANGED
|
@@ -51,6 +51,13 @@ export function updateContainer(options) {
|
|
|
51
51
|
set(container.name, container);
|
|
52
52
|
return container;
|
|
53
53
|
}
|
|
54
|
+
export function rename(name, newName) {
|
|
55
|
+
const container = get(name);
|
|
56
|
+
container.name = newName;
|
|
57
|
+
set(newName, container);
|
|
58
|
+
remove(name);
|
|
59
|
+
return container;
|
|
60
|
+
}
|
|
54
61
|
export function listContainers(options = {}) {
|
|
55
62
|
const keys = ['name', 'image', 'domain', 'port', 'volumes'];
|
|
56
63
|
const list = getAll();
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export declare function getEnvVars(vars: EnvList): Promise<{
|
|
|
12
12
|
export declare function getListFromString(string: string): string[];
|
|
13
13
|
export declare function addExecFlag(list: string[], flag: string): string[];
|
|
14
14
|
export declare function readTargetName(args: any): void;
|
|
15
|
+
export declare function readTargetNewName(args: any): void;
|
|
15
16
|
export declare function readTargetImage(args: any): void;
|
package/dist/utils.js
CHANGED
|
@@ -18,6 +18,9 @@ export function addExecFlag(list, flag) {
|
|
|
18
18
|
export function readTargetName(args) {
|
|
19
19
|
readPositionalArgs(args, 'name');
|
|
20
20
|
}
|
|
21
|
+
export function readTargetNewName(args) {
|
|
22
|
+
readPositionalArgs(args, 'newName');
|
|
23
|
+
}
|
|
21
24
|
export function readTargetImage(args) {
|
|
22
25
|
readPositionalArgs(args, 'image');
|
|
23
26
|
}
|