@foliwake/cli 0.10.0 → 0.11.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/CHANGELOG.md +76 -0
- package/README.md +196 -14
- package/config/docker/compose.varnish.yaml +44 -0
- package/config/docker/compose.yaml +165 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.js +58 -21
- package/dist/commands/docker/backup.d.ts +12 -0
- package/dist/commands/docker/backup.js +29 -0
- package/dist/commands/docker/configure.d.ts +23 -0
- package/dist/commands/docker/configure.js +73 -0
- package/dist/commands/docker/exec.d.ts +8 -0
- package/dist/commands/docker/exec.js +26 -0
- package/dist/commands/docker/install.d.ts +33 -0
- package/dist/commands/docker/install.js +126 -0
- package/dist/commands/docker/link.d.ts +12 -0
- package/dist/commands/docker/link.js +24 -0
- package/dist/commands/docker/list.d.ts +7 -0
- package/dist/commands/docker/list.js +16 -0
- package/dist/commands/docker/logs.d.ts +15 -0
- package/dist/commands/docker/logs.js +33 -0
- package/dist/commands/docker/remove.d.ts +13 -0
- package/dist/commands/docker/remove.js +35 -0
- package/dist/commands/docker/restart.d.ts +9 -0
- package/dist/commands/docker/restart.js +18 -0
- package/dist/commands/docker/restore.d.ts +14 -0
- package/dist/commands/docker/restore.js +34 -0
- package/dist/commands/docker/start.d.ts +9 -0
- package/dist/commands/docker/start.js +18 -0
- package/dist/commands/docker/status.d.ts +10 -0
- package/dist/commands/docker/status.js +22 -0
- package/dist/commands/docker/stop.d.ts +9 -0
- package/dist/commands/docker/stop.js +18 -0
- package/dist/commands/docker/update.d.ts +14 -0
- package/dist/commands/docker/update.js +42 -0
- package/dist/commands/project/publish.d.ts +1 -0
- package/dist/commands/project/publish.js +9 -2
- package/dist/core-command.d.ts +4 -1
- package/dist/core-command.js +6 -2
- package/dist/core-types.d.ts +1 -0
- package/dist/dev/container.d.ts +45 -0
- package/dist/dev/container.js +128 -0
- package/dist/dev/remote-html.js +2 -2
- package/dist/docker/asker.d.ts +4 -0
- package/dist/docker/asker.js +34 -0
- package/dist/docker/backup.d.ts +21 -0
- package/dist/docker/backup.js +114 -0
- package/dist/docker/cache-plan.d.ts +17 -0
- package/dist/docker/cache-plan.js +58 -0
- package/dist/docker/compose-file.d.ts +18 -0
- package/dist/docker/compose-file.js +58 -0
- package/dist/docker/context.d.ts +55 -0
- package/dist/docker/context.js +12 -0
- package/dist/docker/engine.d.ts +8 -0
- package/dist/docker/engine.js +51 -0
- package/dist/docker/env-block.d.ts +19 -0
- package/dist/docker/env-block.js +117 -0
- package/dist/docker/env-keys.d.ts +4 -0
- package/dist/docker/env-keys.js +33 -0
- package/dist/docker/env-verify.d.ts +17 -0
- package/dist/docker/env-verify.js +62 -0
- package/dist/docker/install-plan.d.ts +81 -0
- package/dist/docker/install-plan.js +332 -0
- package/dist/docker/install.d.ts +22 -0
- package/dist/docker/install.js +118 -0
- package/dist/docker/instance.d.ts +105 -0
- package/dist/docker/instance.js +184 -0
- package/dist/docker/lifecycle.d.ts +19 -0
- package/dist/docker/lifecycle.js +70 -0
- package/dist/docker/ports.d.ts +14 -0
- package/dist/docker/ports.js +50 -0
- package/dist/docker/process-context.d.ts +8 -0
- package/dist/docker/process-context.js +26 -0
- package/dist/docker/remove.d.ts +7 -0
- package/dist/docker/remove.js +82 -0
- package/dist/docker/report.d.ts +32 -0
- package/dist/docker/report.js +109 -0
- package/dist/docker/runner.d.ts +28 -0
- package/dist/docker/runner.js +55 -0
- package/dist/docker/settings-files.d.ts +40 -0
- package/dist/docker/settings-files.js +125 -0
- package/dist/docker/trace-url.d.ts +5 -0
- package/dist/docker/trace-url.js +36 -0
- package/dist/docker/update.d.ts +29 -0
- package/dist/docker/update.js +317 -0
- package/dist/docker-command.d.ts +17 -0
- package/dist/docker-command.js +37 -0
- package/dist/project-preview.d.ts +8 -0
- package/dist/project-preview.js +27 -5
- package/dist/project-publish.d.ts +8 -7
- package/dist/project-publish.js +124 -57
- package/dist/publish-code.d.ts +75 -0
- package/dist/publish-code.js +223 -0
- package/dist/remote/servers.d.ts +1 -1
- package/dist/remote/servers.js +1 -1
- package/dist/render/site-status.js +2 -2
- package/package.json +14 -9
package/dist/commands/dev.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { Command, Errors, Flags } from '@oclif/core';
|
|
2
|
-
import { NEEDS_ENGINE } from '../core-command.js';
|
|
3
2
|
import { devProblem, isRemote, withRemoteValue } from '../dev/flags.js';
|
|
4
3
|
import { UsageError } from '../dev/start.js';
|
|
5
4
|
import { localRuntime } from '../local-runtime.js';
|
|
6
|
-
const WITHOUT_REMOTE = `\`dev\` without --remote serves local content and ${NEEDS_ENGINE}`;
|
|
7
5
|
/**
|
|
8
6
|
* With the engine registered, the engine serves `dev`: its working files, and with --remote its own remote mode
|
|
9
|
-
* (with the block catalog, which needs its renderer).
|
|
7
|
+
* (with the block catalog, which needs its renderer). Without it, local mode runs the engine's `dev` in Docker
|
|
8
|
+
* (dev/container.ts) and --remote is served by this package.
|
|
10
9
|
*/
|
|
11
10
|
const ENGINE = localRuntime() !== null;
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const IMAGE_FLAG = 'without the engine on this computer: the Foliwake image dev runs in (default: the image of the Docker ' +
|
|
12
|
+
'instance this folder is linked to, or of the only one; else ghcr.io/foliwake/foliwake:main)';
|
|
13
|
+
/** --image chooses the container of local mode; null when it may be given here. */
|
|
14
|
+
function imageProblem(image, engine, remote) {
|
|
15
|
+
if (image === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
if (remote)
|
|
18
|
+
return '--image applies to local mode (without --remote).';
|
|
19
|
+
if (engine)
|
|
20
|
+
return '--image applies when dev runs in Docker; the engine on this computer serves dev here.';
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
14
23
|
const ENGINE_EXAMPLES = [
|
|
15
24
|
'<%= config.bin %> dev',
|
|
16
25
|
'<%= config.bin %> dev --watch',
|
|
@@ -18,29 +27,36 @@ const ENGINE_EXAMPLES = [
|
|
|
18
27
|
'<%= config.bin %> dev --config foliwake.config.json --site a',
|
|
19
28
|
];
|
|
20
29
|
export default class Dev extends Command {
|
|
21
|
-
static summary =
|
|
22
|
-
? 'Serve working files with live diagnostics (http://127.0.0.1:3000)'
|
|
23
|
-
: 'Develop blocks against a deployed site: its content, this checkout’s code (dev --remote)';
|
|
30
|
+
static summary = 'Serve working files with live diagnostics (http://127.0.0.1:3000)';
|
|
24
31
|
static description = ENGINE
|
|
25
32
|
? "A server process, not a core operation: serves the working files (or the selected snapshot of the site's " +
|
|
26
33
|
'source) with diagnostics, until Ctrl+C. With --remote: content from the deployed preview (default) or ' +
|
|
27
34
|
'live site, code from this checkout.'
|
|
28
|
-
:
|
|
29
|
-
'
|
|
35
|
+
: "A server process, not a core operation: the Foliwake engine's dev in a throwaway container of the " +
|
|
36
|
+
'Foliwake image (Docker needed; this folder mounted, the port on 127.0.0.1) serves the working files with ' +
|
|
37
|
+
'diagnostics, until Ctrl+C. With --remote, without Docker: content from the deployed preview (default) or ' +
|
|
38
|
+
'live site, components/, scripts/ and styles/ from this checkout.';
|
|
30
39
|
static examples = [
|
|
31
|
-
...
|
|
40
|
+
...ENGINE_EXAMPLES,
|
|
32
41
|
'<%= config.bin %> dev --remote --watch # in the frontend checkout: preview content, local code',
|
|
33
42
|
'<%= config.bin %> dev --remote live --port 3001',
|
|
34
43
|
'<%= config.bin %> dev --remote-url https://preview.foliwake.example --remote-auth-user owner ' +
|
|
35
44
|
'--remote-auth-env PREVIEW_PASSWORD',
|
|
36
45
|
];
|
|
37
46
|
static flags = {
|
|
38
|
-
config:
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
config: Flags.string({
|
|
48
|
+
description: 'project configuration (default: $FOLIWAKE_CONFIG, else ./foliwake.config.json in this folder)',
|
|
49
|
+
}),
|
|
50
|
+
site: Flags.string({
|
|
51
|
+
description: 'site id from the project configuration (required when it lists several sites)',
|
|
52
|
+
}),
|
|
53
|
+
content: Flags.string({
|
|
54
|
+
description: "this folder instead of the site's content sources; refused when they need the page ledger",
|
|
55
|
+
}),
|
|
56
|
+
image: Flags.string({ description: IMAGE_FLAG, hidden: ENGINE }),
|
|
41
57
|
port: Flags.integer({ min: 0, max: 65535, description: 'port to listen on (default 3000)' }),
|
|
42
58
|
watch: Flags.boolean({
|
|
43
|
-
description:
|
|
59
|
+
description: 'watch local components/, scripts/, styles/ and Markdown content and reload open ' +
|
|
44
60
|
'browser pages after changes ' +
|
|
45
61
|
'(one reload per burst of saves; problems are shown in the page until fixed). Without it, refresh by hand',
|
|
46
62
|
}),
|
|
@@ -71,11 +87,15 @@ export default class Dev extends Command {
|
|
|
71
87
|
async run() {
|
|
72
88
|
const { flags } = await this.parse(Dev, withRemoteValue(this.argv));
|
|
73
89
|
const engine = localRuntime();
|
|
74
|
-
|
|
75
|
-
this.error(WITHOUT_REMOTE, { exit: 2 });
|
|
76
|
-
const problem = devProblem(flags);
|
|
90
|
+
const problem = devProblem(flags) ?? imageProblem(flags.image, engine !== null, isRemote(flags));
|
|
77
91
|
if (problem)
|
|
78
92
|
throw new UsageError(problem);
|
|
93
|
+
if (!engine && !isRemote(flags)) {
|
|
94
|
+
const code = await this.serveInDocker(flags);
|
|
95
|
+
if (code !== 0)
|
|
96
|
+
this.exit(code);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
79
99
|
if (engine) {
|
|
80
100
|
const code = await this.serveWithEngine(engine, flags);
|
|
81
101
|
if (code !== 0)
|
|
@@ -118,6 +138,21 @@ export default class Dev extends Command {
|
|
|
118
138
|
const io = { log: (line) => this.log(line), warn: (line) => this.logToStderr(line) };
|
|
119
139
|
return engine.dev(options, io);
|
|
120
140
|
}
|
|
141
|
+
/** Without the engine on this computer: the engine's `dev` in a throwaway container of the Foliwake image. */
|
|
142
|
+
async serveInDocker(flags) {
|
|
143
|
+
const { processDockerContext } = await import('../docker/process-context.js');
|
|
144
|
+
const { runDevInContainer } = await import('../dev/container.js');
|
|
145
|
+
const request = {
|
|
146
|
+
port: flags.port,
|
|
147
|
+
watch: flags.watch,
|
|
148
|
+
polling: flags['watch-polling'],
|
|
149
|
+
content: flags.content,
|
|
150
|
+
config: flags.config,
|
|
151
|
+
site: flags.site,
|
|
152
|
+
image: flags.image,
|
|
153
|
+
};
|
|
154
|
+
return runDevInContainer(processDockerContext(false), request);
|
|
155
|
+
}
|
|
121
156
|
/** Set by stopOnSignal(): settles when a signal has stopped the server. */
|
|
122
157
|
stopped = null;
|
|
123
158
|
/** On Ctrl+C or SIGTERM: closes the listeners, waits for the work that runs, exits. */
|
|
@@ -136,9 +171,11 @@ export default class Dev extends Command {
|
|
|
136
171
|
async catch(error) {
|
|
137
172
|
if (error instanceof Errors.CLIError || error instanceof Errors.ExitError)
|
|
138
173
|
return super.catch(error);
|
|
139
|
-
|
|
174
|
+
const { dockerExit } = await import('../docker/process-context.js');
|
|
175
|
+
const exit = error instanceof UsageError ? { message: error.message, code: 2 } : dockerExit(error);
|
|
176
|
+
if (!exit)
|
|
140
177
|
return super.catch(error);
|
|
141
|
-
this.logToStderr(
|
|
142
|
-
return this.exit(
|
|
178
|
+
this.logToStderr(exit.message);
|
|
179
|
+
return this.exit(exit.code);
|
|
143
180
|
}
|
|
144
181
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerBackup extends DockerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
out: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
3
|
+
export default class DockerBackup extends DockerCommand {
|
|
4
|
+
static description = [
|
|
5
|
+
"Back up an instance's data volume to one .tar.gz on this computer: consistent copies of its databases,",
|
|
6
|
+
"its other files, no caches. The server may keep running. The archive holds the server's secrets (0600).",
|
|
7
|
+
].join('\n');
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> docker backup',
|
|
10
|
+
'<%= config.bin %> docker backup staging --out ./staging.tar.gz',
|
|
11
|
+
];
|
|
12
|
+
static args = {
|
|
13
|
+
name: Args.string({
|
|
14
|
+
description: 'instance name (default: the only one; asked in a terminal when there are several)',
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
static flags = {
|
|
18
|
+
out: Flags.string({
|
|
19
|
+
description: 'the archive to write (default: ~/.config/foliwake/docker/<name>/backups/<name>-<time>.tar.gz)',
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { args, flags } = await this.parse(DockerBackup);
|
|
24
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
25
|
+
const instance = await this.instance(ctx, args.name, { allowDataOnly: true });
|
|
26
|
+
const { runBackup } = await import('../../docker/backup.js');
|
|
27
|
+
process.exitCode = await runBackup(ctx, instance, flags.out);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerConfigure extends DockerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
traces: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
port: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
bind: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'public-origin': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
domain: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
image: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
cache: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'cache-port': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'jaeger-store': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'jaeger-port': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'trace-url-template': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'otlp-endpoint': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
};
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
3
|
+
export default class DockerConfigure extends DockerCommand {
|
|
4
|
+
static description = [
|
|
5
|
+
'Change settings of an instance, then recreate it (the data volume stays). Only the given flags change; ' +
|
|
6
|
+
'other lines of its .env are kept.',
|
|
7
|
+
'It has no storage flags yet: the storage of new sites follows FOLIWAKE_STORAGE_* of the instance ' +
|
|
8
|
+
'at each start (the Docker guide says how).',
|
|
9
|
+
].join('\n');
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> docker configure --traces jaeger',
|
|
12
|
+
'<%= config.bin %> docker configure --cache varnish --cache-port 8090',
|
|
13
|
+
'<%= config.bin %> docker configure staging --port 8082',
|
|
14
|
+
'<%= config.bin %> docker configure --traces external --otlp-endpoint https://otlp.example.com',
|
|
15
|
+
];
|
|
16
|
+
static args = {
|
|
17
|
+
name: Args.string({
|
|
18
|
+
description: 'instance name (default: the only one; asked in a terminal when there are several)',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static flags = {
|
|
22
|
+
traces: Flags.string({
|
|
23
|
+
options: ['none', 'jaeger', 'external'],
|
|
24
|
+
description: 'traces: none, Jaeger beside the server, or your own OTLP collector',
|
|
25
|
+
}),
|
|
26
|
+
port: Flags.string({
|
|
27
|
+
description: 'port on this computer (the public address follows when it was the default http://localhost:<port>)',
|
|
28
|
+
}),
|
|
29
|
+
bind: Flags.string({ description: 'address the port is published on (127.0.0.1 or 0.0.0.0)' }),
|
|
30
|
+
'public-origin': Flags.string({ description: 'where browsers and `foliwake login` reach the server' }),
|
|
31
|
+
domain: Flags.string({ description: 'sites at <site>.live.<domain> and <site>.preview.<domain>' }),
|
|
32
|
+
image: Flags.string({ description: 'the image (tag or digest)' }),
|
|
33
|
+
cache: Flags.string({
|
|
34
|
+
options: ['none', 'varnish'],
|
|
35
|
+
description: 'a Varnish in front of the live sites, on a port of its own (none: remove it)',
|
|
36
|
+
}),
|
|
37
|
+
'cache-port': Flags.string({
|
|
38
|
+
description: 'with --cache varnish: its port (default: the first free one from 8090)',
|
|
39
|
+
}),
|
|
40
|
+
'jaeger-store': Flags.string({
|
|
41
|
+
options: ['memory', 'badger'],
|
|
42
|
+
description: 'with --traces jaeger: in memory (default) or on disk for a week',
|
|
43
|
+
}),
|
|
44
|
+
'jaeger-port': Flags.string({ description: 'with --traces jaeger: the UI port on 127.0.0.1' }),
|
|
45
|
+
'trace-url-template': Flags.string({
|
|
46
|
+
description: 'with traces to your own collector: its trace page with {traceId} ' +
|
|
47
|
+
'(FOLIWAKE_TRACE_URL_TEMPLATE; "" removes it). With Jaeger the CLI sets it',
|
|
48
|
+
}),
|
|
49
|
+
'otlp-endpoint': Flags.string({
|
|
50
|
+
description: 'with --traces external: the OTLP/HTTP endpoint (headers from $OTEL_EXPORTER_OTLP_HEADERS or asked hidden)',
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
async run() {
|
|
54
|
+
const { args, flags } = await this.parse(DockerConfigure);
|
|
55
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
56
|
+
const instance = await this.instance(ctx, args.name);
|
|
57
|
+
const { runConfigure } = await import('../../docker/update.js');
|
|
58
|
+
process.exitCode = await runConfigure(ctx, instance, {
|
|
59
|
+
traces: flags.traces,
|
|
60
|
+
port: flags.port,
|
|
61
|
+
bind: flags.bind,
|
|
62
|
+
publicOrigin: flags['public-origin'],
|
|
63
|
+
domain: flags.domain,
|
|
64
|
+
image: flags.image,
|
|
65
|
+
jaegerStore: flags['jaeger-store'],
|
|
66
|
+
jaegerPort: flags['jaeger-port'],
|
|
67
|
+
otlpEndpoint: flags['otlp-endpoint'],
|
|
68
|
+
traceUrlTemplate: flags['trace-url-template'],
|
|
69
|
+
cache: flags.cache,
|
|
70
|
+
cachePort: flags['cache-port'],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerExec extends DockerCommand {
|
|
3
|
+
static description = "Run the foliwake CLI inside an instance's server container (it reads the container's settings): " +
|
|
4
|
+
'`docker exec [name] -- <args>`';
|
|
5
|
+
static examples = [
|
|
6
|
+
'<%= config.bin %> docker exec -- account invite --email author@example.com',
|
|
7
|
+
'<%= config.bin %> docker exec staging -- source plugins list',
|
|
8
|
+
];
|
|
9
|
+
static strict = false;
|
|
10
|
+
static usage = 'docker exec [NAME] -- <foliwake arguments>';
|
|
11
|
+
async run() {
|
|
12
|
+
const { argv, flags } = await this.parse(DockerExec);
|
|
13
|
+
const words = argv;
|
|
14
|
+
const raw = this.argv;
|
|
15
|
+
const separator = raw.indexOf('--');
|
|
16
|
+
const before = separator === -1 ? words : raw.slice(0, separator).filter((word) => !word.startsWith('-'));
|
|
17
|
+
const rest = separator === -1 ? [] : raw.slice(separator + 1);
|
|
18
|
+
const { DockerUsageError } = await import('../../docker/context.js');
|
|
19
|
+
if (separator === -1 || before.length > 1)
|
|
20
|
+
throw new DockerUsageError('Usage: foliwake docker exec [NAME] -- <foliwake arguments>');
|
|
21
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
22
|
+
const instance = await this.instance(ctx, before[0]);
|
|
23
|
+
const { runExec } = await import('../../docker/lifecycle.js');
|
|
24
|
+
process.exitCode = await runExec(ctx, instance, rest, process.stdin.isTTY === true && process.stdout.isTTY === true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerInstall extends DockerCommand {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
port: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
bind: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'public-origin': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
domain: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'owner-email': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
storage: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'storage-endpoint': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'storage-region': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'storage-bucket': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'storage-create-buckets': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
traces: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
cache: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'cache-port': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
'jaeger-store': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
'jaeger-port': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
'otlp-endpoint': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
'trace-url-template': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
image: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
pull: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
30
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
31
|
+
};
|
|
32
|
+
run(): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
3
|
+
export default class DockerInstall extends DockerCommand {
|
|
4
|
+
static summary = "Install a Foliwake instance in Docker: questions, then pull, start, and the owner's sign-in link";
|
|
5
|
+
static description = [
|
|
6
|
+
'An instance is a Compose project on the current Docker engine (docker context / DOCKER_HOST), found ' +
|
|
7
|
+
'again by its dev.foliwake.* labels; no command looks at the current folder.',
|
|
8
|
+
'In a terminal it asks for what the flags leave open; without one it uses the defaults and refuses ' +
|
|
9
|
+
'where there is none (the owner e-mail at a first start). Its settings go to ~/.config/foliwake/docker/<name>/ ' +
|
|
10
|
+
'(compose.yaml, and .env with mode 0600).',
|
|
11
|
+
'Secrets are never flags: the S3 key is asked hidden, or read from FOLIWAKE_STORAGE_ACCESS_KEY_ID ' +
|
|
12
|
+
"and FOLIWAKE_STORAGE_SECRET_ACCESS_KEY in this command's environment; OTLP headers likewise from " +
|
|
13
|
+
'OTEL_EXPORTER_OTLP_HEADERS.',
|
|
14
|
+
'Needs Docker Compose 2.24 or later. A private image needs `docker login ghcr.io` first.',
|
|
15
|
+
].join('\n');
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> docker install',
|
|
18
|
+
'<%= config.bin %> docker install staging --port 8081 --owner-email you@example.com --no-interactive',
|
|
19
|
+
'<%= config.bin %> docker install --traces jaeger --jaeger-store badger',
|
|
20
|
+
'<%= config.bin %> docker install --cache varnish',
|
|
21
|
+
'FOLIWAKE_STORAGE_ACCESS_KEY_ID=… FOLIWAKE_STORAGE_SECRET_ACCESS_KEY=… <%= config.bin %> docker install ' +
|
|
22
|
+
'prod --public-origin https://foliwake.example.com --domain example.com --owner-email you@example.com ' +
|
|
23
|
+
'--storage s3 --storage-endpoint https://s3.example.com --no-interactive',
|
|
24
|
+
];
|
|
25
|
+
static args = {
|
|
26
|
+
name: Args.string({
|
|
27
|
+
description: 'instance name (default: foliwake): lowercase letters, digits and dashes; also the Compose project name',
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
static flags = {
|
|
31
|
+
port: Flags.string({
|
|
32
|
+
description: 'port on this computer (default: the first free one from 8080; ' +
|
|
33
|
+
'a taken port is refused, never swapped silently)',
|
|
34
|
+
}),
|
|
35
|
+
bind: Flags.string({
|
|
36
|
+
description: 'address the port is published on: 127.0.0.1 (this computer only, default) or 0.0.0.0 ' +
|
|
37
|
+
'(everywhere; put HTTPS in front; FOLIWAKE_TRUST_PROXY is then not set)',
|
|
38
|
+
}),
|
|
39
|
+
'public-origin': Flags.string({
|
|
40
|
+
description: 'where browsers and `foliwake login` reach the server (default: http://localhost:<port>)',
|
|
41
|
+
}),
|
|
42
|
+
domain: Flags.string({
|
|
43
|
+
description: "sites at <site>.live.<domain> and <site>.preview.<domain> (default: the public origin's host)",
|
|
44
|
+
}),
|
|
45
|
+
'owner-email': Flags.string({
|
|
46
|
+
description: 'the owner account made at the first start (no mail is sent); not needed when the data volume is reused',
|
|
47
|
+
}),
|
|
48
|
+
storage: Flags.string({
|
|
49
|
+
options: ['volume', 's3'],
|
|
50
|
+
description: 'where sites are kept: the data volume (default) or S3-compatible storage; fixed at the first start',
|
|
51
|
+
}),
|
|
52
|
+
'storage-endpoint': Flags.string({ description: 'with --storage s3: the S3 endpoint (https://…)' }),
|
|
53
|
+
'storage-region': Flags.string({ description: 'with --storage s3: the region (default us-east-1; `auto` on R2)' }),
|
|
54
|
+
'storage-bucket': Flags.string({
|
|
55
|
+
description: 'with --storage s3: the bucket name of each site (default foliwake-{org}-{site})',
|
|
56
|
+
}),
|
|
57
|
+
'storage-create-buckets': Flags.boolean({
|
|
58
|
+
allowNo: true,
|
|
59
|
+
description: 'with --storage s3: the key may create buckets (default yes)',
|
|
60
|
+
}),
|
|
61
|
+
traces: Flags.string({
|
|
62
|
+
options: ['none', 'jaeger', 'external'],
|
|
63
|
+
description: 'traces: none (default), Jaeger beside the server (UI on 127.0.0.1), or your own OTLP collector',
|
|
64
|
+
}),
|
|
65
|
+
cache: Flags.string({
|
|
66
|
+
options: ['none', 'varnish'],
|
|
67
|
+
description: 'a Varnish in front of the live sites, on a port of its own (default: none)',
|
|
68
|
+
}),
|
|
69
|
+
'cache-port': Flags.string({
|
|
70
|
+
description: 'with --cache varnish: its port (default: the first free one from 8090)',
|
|
71
|
+
}),
|
|
72
|
+
'jaeger-store': Flags.string({
|
|
73
|
+
options: ['memory', 'badger'],
|
|
74
|
+
description: 'with --traces jaeger: keep traces in memory (default) or on disk for a week',
|
|
75
|
+
}),
|
|
76
|
+
'jaeger-port': Flags.string({
|
|
77
|
+
description: 'with --traces jaeger: the UI port on 127.0.0.1 (default: the first free one from 16686)',
|
|
78
|
+
}),
|
|
79
|
+
'otlp-endpoint': Flags.string({
|
|
80
|
+
description: 'with --traces external: the OTLP/HTTP endpoint (headers from $OTEL_EXPORTER_OTLP_HEADERS or asked hidden)',
|
|
81
|
+
}),
|
|
82
|
+
'trace-url-template': Flags.string({
|
|
83
|
+
description: "with --traces external: your collector's trace page with {traceId} (FOLIWAKE_TRACE_URL_TEMPLATE), " +
|
|
84
|
+
'for links from the dashboard and `operation get`',
|
|
85
|
+
}),
|
|
86
|
+
image: Flags.string({
|
|
87
|
+
description: 'the image: a tag, digest or local build (default ghcr.io/foliwake/foliwake:main; never asked)',
|
|
88
|
+
}),
|
|
89
|
+
pull: Flags.string({
|
|
90
|
+
options: ['always', 'missing'],
|
|
91
|
+
description: 'always (default): pull the image, a failed pull stops the install; missing: use the image if it ' +
|
|
92
|
+
'is on this engine already (a local build), pull only otherwise',
|
|
93
|
+
}),
|
|
94
|
+
open: Flags.boolean({
|
|
95
|
+
allowNo: true,
|
|
96
|
+
description: "open the owner's sign-in link in the browser (default: asked in a terminal, else no)",
|
|
97
|
+
}),
|
|
98
|
+
yes: Flags.boolean({ description: 'do not ask «Install?» at the end of the questions' }),
|
|
99
|
+
};
|
|
100
|
+
async run() {
|
|
101
|
+
const { args, flags } = await this.parse(DockerInstall);
|
|
102
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
103
|
+
const { runInstall } = await import('../../docker/install.js');
|
|
104
|
+
process.exitCode = await runInstall(ctx, {
|
|
105
|
+
name: args.name,
|
|
106
|
+
port: flags.port,
|
|
107
|
+
bind: flags.bind,
|
|
108
|
+
publicOrigin: flags['public-origin'],
|
|
109
|
+
domain: flags.domain,
|
|
110
|
+
ownerEmail: flags['owner-email'],
|
|
111
|
+
storage: flags.storage,
|
|
112
|
+
storageEndpoint: flags['storage-endpoint'],
|
|
113
|
+
storageRegion: flags['storage-region'],
|
|
114
|
+
storageBucket: flags['storage-bucket'],
|
|
115
|
+
storageCreateBuckets: flags['storage-create-buckets'],
|
|
116
|
+
traces: flags.traces,
|
|
117
|
+
jaegerStore: flags['jaeger-store'],
|
|
118
|
+
jaegerPort: flags['jaeger-port'],
|
|
119
|
+
otlpEndpoint: flags['otlp-endpoint'],
|
|
120
|
+
traceUrlTemplate: flags['trace-url-template'],
|
|
121
|
+
image: flags.image,
|
|
122
|
+
cache: flags.cache,
|
|
123
|
+
cachePort: flags['cache-port'],
|
|
124
|
+
}, { yes: flags.yes, open: flags.open, pull: flags.pull });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerLink extends DockerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
3
|
+
export default class DockerLink extends DockerCommand {
|
|
4
|
+
static description = 'A new one-time sign-in link (15 minutes) for the owner or another account of an instance';
|
|
5
|
+
static examples = [
|
|
6
|
+
'<%= config.bin %> docker link',
|
|
7
|
+
'<%= config.bin %> docker link staging --email author@example.com',
|
|
8
|
+
];
|
|
9
|
+
static args = {
|
|
10
|
+
name: Args.string({
|
|
11
|
+
description: 'instance name (default: the only one; asked in a terminal when there are several)',
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
static flags = {
|
|
15
|
+
email: Flags.string({ description: "the account's e-mail address (default: the owner of the instance)" }),
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const { args, flags } = await this.parse(DockerLink);
|
|
19
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
20
|
+
const instance = await this.instance(ctx, args.name);
|
|
21
|
+
const { runLink } = await import('../../docker/lifecycle.js');
|
|
22
|
+
process.exitCode = await runLink(ctx, instance, flags.email);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerList extends DockerCommand {
|
|
3
|
+
static description = 'Foliwake instances on this Docker engine, found by their labels (removed ones whose data was kept: "data only")';
|
|
4
|
+
static examples = ['<%= config.bin %> docker list', '<%= config.bin %> docker list --json'];
|
|
5
|
+
static enableJsonFlag = true;
|
|
6
|
+
async run() {
|
|
7
|
+
const { flags } = await this.parse(DockerList);
|
|
8
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
9
|
+
const { discoverInstances } = await import('../../docker/instance.js');
|
|
10
|
+
const { listLines, summarize } = await import('../../docker/report.js');
|
|
11
|
+
const summaries = (await discoverInstances(ctx)).map(summarize);
|
|
12
|
+
for (const line of listLines(summaries))
|
|
13
|
+
this.log(line);
|
|
14
|
+
return { instances: summaries };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerLogs extends DockerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
follow: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
since: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
tail: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
service: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
3
|
+
export default class DockerLogs extends DockerCommand {
|
|
4
|
+
static description = "The log of an instance's server (or its Jaeger); it holds one-time sign-in links, so keep it private";
|
|
5
|
+
static examples = [
|
|
6
|
+
'<%= config.bin %> docker logs',
|
|
7
|
+
'<%= config.bin %> docker logs staging -f --since 10m',
|
|
8
|
+
'<%= config.bin %> docker logs --service jaeger',
|
|
9
|
+
];
|
|
10
|
+
static args = {
|
|
11
|
+
name: Args.string({
|
|
12
|
+
description: 'instance name (default: the only one; asked in a terminal when there are several)',
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
static flags = {
|
|
16
|
+
follow: Flags.boolean({ char: 'f', description: 'keep printing new lines' }),
|
|
17
|
+
since: Flags.string({ description: 'only lines since a time or duration (e.g. 10m, 2026-11-13T10:00:00)' }),
|
|
18
|
+
tail: Flags.string({ description: 'only the last N lines' }),
|
|
19
|
+
service: Flags.string({ options: ['foliwake', 'jaeger'], description: 'which service (default foliwake)' }),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { args, flags } = await this.parse(DockerLogs);
|
|
23
|
+
const ctx = await this.dockerContext(flags.interactive);
|
|
24
|
+
const instance = await this.instance(ctx, args.name);
|
|
25
|
+
const { runLogs } = await import('../../docker/lifecycle.js');
|
|
26
|
+
process.exitCode = await runLogs(ctx, instance, {
|
|
27
|
+
follow: flags.follow,
|
|
28
|
+
since: flags.since,
|
|
29
|
+
tail: flags.tail,
|
|
30
|
+
service: flags.service,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DockerCommand } from '../../docker-command.js';
|
|
2
|
+
export default class DockerRemove extends DockerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
'delete-data': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|