@cloud-cli/dx 2.3.1 → 2.5.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 +1 -0
- package/dist/containers.d.ts +4 -0
- package/dist/containers.js +23 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +4 -2
package/README.md
CHANGED
package/dist/containers.d.ts
CHANGED
|
@@ -5,11 +5,15 @@ 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
7
|
export declare function startAll(_: any, cli: any): Promise<boolean>;
|
|
8
|
+
export declare function updateAll(options: {
|
|
9
|
+
image: string;
|
|
10
|
+
}, cli: any): Promise<any[]>;
|
|
8
11
|
export declare function refreshContainer(options: ContainerName, { run }: ServerParams): Promise<void>;
|
|
9
12
|
export declare function restartContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
|
10
13
|
export interface StartOptions {
|
|
11
14
|
worker?: boolean;
|
|
12
15
|
startArgs?: string;
|
|
13
16
|
}
|
|
17
|
+
export declare function runContainer(options: ContainerName & StartOptions, p: ServerParams): Promise<boolean>;
|
|
14
18
|
export declare function startContainer(options: ContainerName & StartOptions, { run }: ServerParams): Promise<boolean>;
|
|
15
19
|
export declare function stopContainer(options: ContainerName, { run }: ServerParams): Promise<boolean>;
|
package/dist/containers.js
CHANGED
|
@@ -56,6 +56,20 @@ export async function startAll(_, cli) {
|
|
|
56
56
|
}
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
|
+
export async function updateAll(options, cli) {
|
|
60
|
+
const list = listContainers();
|
|
61
|
+
const affected = [];
|
|
62
|
+
for (const app of list) {
|
|
63
|
+
if (app.image !== options.image)
|
|
64
|
+
continue;
|
|
65
|
+
try {
|
|
66
|
+
await refreshContainer({ name: app.name }, cli);
|
|
67
|
+
affected.push(app.name);
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
}
|
|
71
|
+
return affected;
|
|
72
|
+
}
|
|
59
73
|
export async function refreshContainer(options, { run }) {
|
|
60
74
|
readTargetName(options);
|
|
61
75
|
if (!options.name) {
|
|
@@ -87,6 +101,9 @@ async function getPorts(container) {
|
|
|
87
101
|
const port = Number(container.port);
|
|
88
102
|
return [port, port];
|
|
89
103
|
}
|
|
104
|
+
export function runContainer(options, p) {
|
|
105
|
+
return startContainer({ ...options, worker: true }, p);
|
|
106
|
+
}
|
|
90
107
|
export async function startContainer(options, { run }) {
|
|
91
108
|
readTargetName(options);
|
|
92
109
|
const { name } = options;
|
|
@@ -106,9 +123,9 @@ export async function startContainer(options, { run }) {
|
|
|
106
123
|
const extraArgs = [];
|
|
107
124
|
const config = await getConfig('dx');
|
|
108
125
|
if (container.domain && !options.worker) {
|
|
109
|
-
const [domain, path = ''] = container.domain.split(
|
|
110
|
-
await run(
|
|
111
|
-
extraArgs.push(
|
|
126
|
+
const [domain, path = ''] = container.domain.split('/');
|
|
127
|
+
await run('dns.add', { domain });
|
|
128
|
+
extraArgs.push('--label', 'px:host=' + domain, '--label', 'px:path=' + path);
|
|
112
129
|
}
|
|
113
130
|
if (config.dns) {
|
|
114
131
|
extraArgs.push('--dns=' + config.dns);
|
|
@@ -129,7 +146,8 @@ export async function startContainer(options, { run }) {
|
|
|
129
146
|
container.image,
|
|
130
147
|
];
|
|
131
148
|
if (options.startArgs) {
|
|
132
|
-
|
|
149
|
+
const p = options.startArgs;
|
|
150
|
+
execArgs.push(...(Array.isArray(p) ? p : JSON.parse(p)));
|
|
133
151
|
}
|
|
134
152
|
const output = await exec('docker', execArgs.filter(Boolean), { env });
|
|
135
153
|
if (!output.ok) {
|
|
@@ -152,7 +170,7 @@ export async function stopContainer(options, { run }) {
|
|
|
152
170
|
}
|
|
153
171
|
await exec('docker', ['stop', '-t', '5', name]);
|
|
154
172
|
await exec('docker', ['rm', name]);
|
|
155
|
-
const containers = [findContainer(name)].filter(c => c && c.domain);
|
|
173
|
+
const containers = [findContainer(name)].filter((c) => c && c.domain);
|
|
156
174
|
for (const container of containers) {
|
|
157
175
|
await run('dns.remove', { domain: container.domain });
|
|
158
176
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getLogs, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer } from "./containers.js";
|
|
1
|
+
import { getLogs, refreshContainer, restartContainer, startAll, startContainer, 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";
|
|
@@ -17,6 +17,7 @@ declare const _default: {
|
|
|
17
17
|
update: typeof updateContainer;
|
|
18
18
|
startAll: typeof startAll;
|
|
19
19
|
start: typeof startContainer;
|
|
20
|
+
run: typeof runContainer;
|
|
20
21
|
stop: typeof stopContainer;
|
|
21
22
|
restart: typeof restartContainer;
|
|
22
23
|
ps: typeof ps;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, stopContainer, renameContainer, } from "./containers.js";
|
|
1
|
+
import { getAllContainers, getLogs, getRunningContainers, refreshContainer, restartContainer, startAll, startContainer, 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 = {}) {
|
|
@@ -19,6 +19,7 @@ export default {
|
|
|
19
19
|
update: updateContainer,
|
|
20
20
|
startAll,
|
|
21
21
|
start: startContainer,
|
|
22
|
+
run: runContainer,
|
|
22
23
|
stop: stopContainer,
|
|
23
24
|
restart: restartContainer,
|
|
24
25
|
ps: ps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-cli/dx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Docker container management",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"test": "vitest",
|
|
11
11
|
"build": "rm -rf ./dist/* && tsc"
|
|
12
12
|
},
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cloudy"
|
|
15
|
+
],
|
|
14
16
|
"license": "MIT",
|
|
15
17
|
"author": "Darlan Alves <me@darlanalv.es>",
|
|
16
18
|
"devDependencies": {
|