@cloud-cli/dx 2.3.0 → 2.3.1
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 +5 -1
- package/dist/containers.js +5 -3
- package/dist/store.d.ts +2 -0
- package/dist/store.js +14 -9
- package/dist/types.d.ts +2 -0
- package/package.json +4 -6
package/dist/containers.d.ts
CHANGED
|
@@ -7,5 +7,9 @@ export declare function renameContainer(options: RenameOptions): Container;
|
|
|
7
7
|
export declare function startAll(_: any, cli: any): Promise<boolean>;
|
|
8
8
|
export declare function refreshContainer(options: ContainerName, { run }: ServerParams): Promise<void>;
|
|
9
9
|
export declare function restartContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
|
10
|
-
export
|
|
10
|
+
export interface StartOptions {
|
|
11
|
+
worker?: boolean;
|
|
12
|
+
startArgs?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function startContainer(options: ContainerName & StartOptions, { run }: ServerParams): Promise<boolean>;
|
|
11
15
|
export declare function stopContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
package/dist/containers.js
CHANGED
|
@@ -105,7 +105,7 @@ export async function startContainer(options, { run }) {
|
|
|
105
105
|
const portBindings = addExecFlag([ports.join(':')], 'p');
|
|
106
106
|
const extraArgs = [];
|
|
107
107
|
const config = await getConfig('dx');
|
|
108
|
-
if (container.domain) {
|
|
108
|
+
if (container.domain && !options.worker) {
|
|
109
109
|
const [domain, path = ''] = container.domain.split("/");
|
|
110
110
|
await run("dns.add", { domain });
|
|
111
111
|
extraArgs.push("--label", "px:host=" + domain, "--label", "px:path=" + path);
|
|
@@ -119,8 +119,7 @@ export async function startContainer(options, { run }) {
|
|
|
119
119
|
const execArgs = [
|
|
120
120
|
'run',
|
|
121
121
|
'--detach',
|
|
122
|
-
'--restart',
|
|
123
|
-
'always',
|
|
122
|
+
...(!options.worker ? ['--restart', 'always'] : []),
|
|
124
123
|
'--name',
|
|
125
124
|
name,
|
|
126
125
|
...extraArgs,
|
|
@@ -129,6 +128,9 @@ export async function startContainer(options, { run }) {
|
|
|
129
128
|
...addExecFlag(envKeys, 'e'),
|
|
130
129
|
container.image,
|
|
131
130
|
];
|
|
131
|
+
if (options.startArgs) {
|
|
132
|
+
execArgs.push(...JSON.parse(options.startArgs));
|
|
133
|
+
}
|
|
132
134
|
const output = await exec('docker', execArgs.filter(Boolean), { env });
|
|
133
135
|
if (!output.ok) {
|
|
134
136
|
const e = 'Failed to start container ' + name;
|
package/dist/store.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ interface ContainerUpdateOptions extends ContainerName {
|
|
|
7
7
|
domain?: string;
|
|
8
8
|
volumes?: string;
|
|
9
9
|
port?: string;
|
|
10
|
+
worker?: boolean;
|
|
11
|
+
startArgs?: string;
|
|
10
12
|
}
|
|
11
13
|
type ContainerListOptions = Partial<Container>;
|
|
12
14
|
export declare function addContainer(options: ContainerUpdateOptions): Container;
|
package/dist/store.js
CHANGED
|
@@ -10,9 +10,8 @@ export function addContainer(options) {
|
|
|
10
10
|
if (!image)
|
|
11
11
|
throw new Error('Image required');
|
|
12
12
|
const volumes = options.volumes ? sanitiseVolumes(options.volumes) : '';
|
|
13
|
-
const port =
|
|
14
|
-
const
|
|
15
|
-
const container = { name, image, volumes, port, domain };
|
|
13
|
+
const { port = '', domain = '', worker = false, startArgs = '' } = options;
|
|
14
|
+
const container = { name, image, volumes, port, domain, worker, startArgs };
|
|
16
15
|
set(name, container);
|
|
17
16
|
return container;
|
|
18
17
|
}
|
|
@@ -31,23 +30,29 @@ export function getContainer(options) {
|
|
|
31
30
|
const optionSplitter = /,\s*/;
|
|
32
31
|
export function updateContainer(options) {
|
|
33
32
|
readTargetName(options);
|
|
34
|
-
let { port, volumes, name, image, domain } = options;
|
|
33
|
+
let { port, volumes, name, image, domain, startArgs, worker } = options;
|
|
35
34
|
const container = get(name);
|
|
36
35
|
if (!container) {
|
|
37
36
|
throw new Error('Container not found');
|
|
38
37
|
}
|
|
39
|
-
if (port) {
|
|
38
|
+
if (port !== undefined) {
|
|
40
39
|
container.port = port;
|
|
41
40
|
}
|
|
42
|
-
if (volumes) {
|
|
41
|
+
if (volumes !== undefined) {
|
|
43
42
|
container.volumes = sanitiseVolumes(volumes);
|
|
44
43
|
}
|
|
45
|
-
if (image) {
|
|
44
|
+
if (image !== undefined) {
|
|
46
45
|
container.image = image;
|
|
47
46
|
}
|
|
48
|
-
if (domain) {
|
|
47
|
+
if (domain !== undefined) {
|
|
49
48
|
container.domain = domain;
|
|
50
49
|
}
|
|
50
|
+
if (startArgs !== undefined) {
|
|
51
|
+
container.startArgs = startArgs;
|
|
52
|
+
}
|
|
53
|
+
if (worker !== undefined) {
|
|
54
|
+
container.worker = worker;
|
|
55
|
+
}
|
|
51
56
|
set(container.name, container);
|
|
52
57
|
return container;
|
|
53
58
|
}
|
|
@@ -63,7 +68,7 @@ export function listContainers(options = {}) {
|
|
|
63
68
|
const list = getAll();
|
|
64
69
|
const filtered = keys.reduce((list, key) => {
|
|
65
70
|
if (options[key]) {
|
|
66
|
-
return list.filter((c) => String(c[key]).toLowerCase().includes(options[key].toLowerCase()));
|
|
71
|
+
return list.filter((c) => String(c[key]).toLowerCase().includes(String(options[key]).toLowerCase()));
|
|
67
72
|
}
|
|
68
73
|
return list;
|
|
69
74
|
}, list);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-cli/dx",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Docker container management",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,18 +10,16 @@
|
|
|
10
10
|
"test": "vitest",
|
|
11
11
|
"build": "rm -rf ./dist/* && tsc"
|
|
12
12
|
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"cloudy"
|
|
15
|
-
],
|
|
13
|
+
"keywords": ["cloudy"],
|
|
16
14
|
"license": "MIT",
|
|
17
15
|
"author": "Darlan Alves <me@darlanalv.es>",
|
|
18
16
|
"devDependencies": {
|
|
19
17
|
"@cloud-cli/prettier-config": "^1.0.0",
|
|
20
18
|
"@cloud-cli/typescript-config": "^1.0.1",
|
|
21
19
|
"@types/node": "^20.12.8",
|
|
22
|
-
"@vitest/coverage-v8": "^1.
|
|
20
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
23
21
|
"typescript": "^5.4.5",
|
|
24
|
-
"vitest": "^1.
|
|
22
|
+
"vitest": "^3.1.1"
|
|
25
23
|
},
|
|
26
24
|
"repository": {
|
|
27
25
|
"type": "git",
|