@cloud-cli/dx 1.6.0 → 1.7.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/cloud.db +0 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +7 -0
- package/dist/containers.js +8 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/cloud.db
CHANGED
|
Binary file
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
package/dist/containers.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { exec } from '@cloud-cli/exec';
|
|
2
2
|
import { findContainer, listContainers } from './store.js';
|
|
3
|
+
import { getConfig } from './config.js';
|
|
3
4
|
import { addExecFlag, getEnvVars, getListFromString, getPorts } from './utils.js';
|
|
4
5
|
export async function getRunningContainers() {
|
|
5
6
|
const ps = await exec('docker', ['ps', '--format', '{{.Names}}']);
|
|
@@ -57,12 +58,14 @@ export async function startContainer(options, { run }) {
|
|
|
57
58
|
const ports = getPorts([...container.ports.split(','), env.PORT + ':' + env.PORT]);
|
|
58
59
|
if (container.host) {
|
|
59
60
|
const domain = container.host;
|
|
60
|
-
|
|
61
|
-
await run('px.remove', { domain });
|
|
62
|
-
await run('px.add', { ...proxy, domain, target: 'http://localhost:' + env.PORT });
|
|
61
|
+
await run('px.update', { domain, target: 'http://localhost:' + env.PORT });
|
|
63
62
|
await run('dns.add', { domain });
|
|
64
63
|
await run('dns.reload', {});
|
|
65
64
|
}
|
|
65
|
+
const dnsOption = [];
|
|
66
|
+
if (getConfig('dns')) {
|
|
67
|
+
dnsOption.push('--dns=' + getConfig('dns'));
|
|
68
|
+
}
|
|
66
69
|
const execArgs = [
|
|
67
70
|
'run',
|
|
68
71
|
'--detach',
|
|
@@ -70,12 +73,13 @@ export async function startContainer(options, { run }) {
|
|
|
70
73
|
'always',
|
|
71
74
|
'--name',
|
|
72
75
|
name,
|
|
76
|
+
...dnsOption,
|
|
73
77
|
...volumes,
|
|
74
78
|
...ports,
|
|
75
79
|
...envKeys.map((e) => '-e' + e),
|
|
76
80
|
container.image,
|
|
77
81
|
];
|
|
78
|
-
const output = await exec('docker', execArgs, { env });
|
|
82
|
+
const output = await exec('docker', execArgs.filter(Boolean), { env });
|
|
79
83
|
if (!output.ok) {
|
|
80
84
|
throw new Error('Failed to start ' + name);
|
|
81
85
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { init } from '@cloud-cli/cli';
|
|
|
2
2
|
import { getRunningContainers, getLogs, startContainer, stopContainer, refreshContainer, startAll } from './containers.js';
|
|
3
3
|
import { addContainer, removeContainer, listContainers, updateContainer, getContainer } from './store.js';
|
|
4
4
|
import { pull, prune } from './images.js';
|
|
5
|
+
import { Config } from './config';
|
|
6
|
+
export { Config } from './config';
|
|
5
7
|
declare const _default: {
|
|
6
8
|
pull: typeof pull;
|
|
7
9
|
prune: typeof prune;
|
|
@@ -16,6 +18,6 @@ declare const _default: {
|
|
|
16
18
|
stop: typeof stopContainer;
|
|
17
19
|
ps: typeof getRunningContainers;
|
|
18
20
|
logs: typeof getLogs;
|
|
19
|
-
[init](): Promise<void>;
|
|
21
|
+
[init](config?: Config): Promise<void>;
|
|
20
22
|
};
|
|
21
23
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Container } from './store.js';
|
|
|
4
4
|
import { getRunningContainers, getLogs, startContainer, stopContainer, refreshContainer, startAll } from './containers.js';
|
|
5
5
|
import { addContainer, removeContainer, listContainers, updateContainer, getContainer } from './store.js';
|
|
6
6
|
import { pull, prune } from './images.js';
|
|
7
|
+
import { setConfig } from './config';
|
|
7
8
|
async function initResource() {
|
|
8
9
|
Resource.use(new SQLiteDriver());
|
|
9
10
|
await Resource.create(Container);
|
|
@@ -22,7 +23,8 @@ export default {
|
|
|
22
23
|
stop: stopContainer,
|
|
23
24
|
ps: getRunningContainers,
|
|
24
25
|
logs: getLogs,
|
|
25
|
-
async [init]() {
|
|
26
|
+
async [init](config) {
|
|
27
|
+
setConfig(config);
|
|
26
28
|
await initResource();
|
|
27
29
|
}
|
|
28
30
|
};
|