@foliwake/cli 0.0.0-stage → 0.6.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 +35 -0
- package/LICENSE +202 -0
- package/README.md +643 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/command-words.d.ts +13 -0
- package/dist/command-words.js +53 -0
- package/dist/commands/account/keys/create.d.ts +12 -0
- package/dist/commands/account/keys/create.js +36 -0
- package/dist/commands/account/keys/list.d.ts +9 -0
- package/dist/commands/account/keys/list.js +23 -0
- package/dist/commands/account/keys/revoke.d.ts +12 -0
- package/dist/commands/account/keys/revoke.js +15 -0
- package/dist/commands/branch/bootstrap.d.ts +11 -0
- package/dist/commands/branch/bootstrap.js +23 -0
- package/dist/commands/branch/delete.d.ts +17 -0
- package/dist/commands/branch/delete.js +38 -0
- package/dist/commands/branch/history.d.ts +14 -0
- package/dist/commands/branch/history.js +24 -0
- package/dist/commands/branch/list.d.ts +11 -0
- package/dist/commands/branch/list.js +15 -0
- package/dist/commands/branch/update.d.ts +19 -0
- package/dist/commands/branch/update.js +49 -0
- package/dist/commands/code/deploy.d.ts +15 -0
- package/dist/commands/code/deploy.js +78 -0
- package/dist/commands/code/prepare.d.ts +13 -0
- package/dist/commands/code/prepare.js +54 -0
- package/dist/commands/code/release.d.ts +19 -0
- package/dist/commands/code/release.js +51 -0
- package/dist/commands/code/rollback.d.ts +17 -0
- package/dist/commands/code/rollback.js +38 -0
- package/dist/commands/connect.d.ts +19 -0
- package/dist/commands/connect.js +100 -0
- package/dist/commands/create.d.ts +30 -0
- package/dist/commands/create.js +163 -0
- package/dist/commands/credential/list.d.ts +10 -0
- package/dist/commands/credential/list.js +21 -0
- package/dist/commands/credential/rm.d.ts +12 -0
- package/dist/commands/credential/rm.js +18 -0
- package/dist/commands/credential/set.d.ts +15 -0
- package/dist/commands/credential/set.js +58 -0
- package/dist/commands/dev.d.ts +25 -0
- package/dist/commands/dev.js +89 -0
- package/dist/commands/login.d.ts +20 -0
- package/dist/commands/login.js +94 -0
- package/dist/commands/logout.d.ts +14 -0
- package/dist/commands/logout.js +61 -0
- package/dist/commands/migration/commit.d.ts +13 -0
- package/dist/commands/migration/commit.js +42 -0
- package/dist/commands/migration/prepare.d.ts +18 -0
- package/dist/commands/migration/prepare.js +53 -0
- package/dist/commands/operation/cancel.d.ts +14 -0
- package/dist/commands/operation/cancel.js +21 -0
- package/dist/commands/operation/get.d.ts +14 -0
- package/dist/commands/operation/get.js +26 -0
- package/dist/commands/operation/list.d.ts +12 -0
- package/dist/commands/operation/list.js +25 -0
- package/dist/commands/operation/recover.d.ts +20 -0
- package/dist/commands/operation/recover.js +49 -0
- package/dist/commands/page/changes.d.ts +13 -0
- package/dist/commands/page/changes.js +26 -0
- package/dist/commands/page/check.d.ts +12 -0
- package/dist/commands/page/check.js +25 -0
- package/dist/commands/page/replace.d.ts +13 -0
- package/dist/commands/page/replace.js +59 -0
- package/dist/commands/page/unpreview.d.ts +17 -0
- package/dist/commands/page/unpreview.js +54 -0
- package/dist/commands/page/unpublish.d.ts +18 -0
- package/dist/commands/page/unpublish.js +36 -0
- package/dist/commands/project/preview.d.ts +8 -0
- package/dist/commands/project/preview.js +20 -0
- package/dist/commands/project/publish.d.ts +16 -0
- package/dist/commands/project/publish.js +40 -0
- package/dist/commands/project/unpublish.d.ts +16 -0
- package/dist/commands/project/unpublish.js +33 -0
- package/dist/commands/release/rollback.d.ts +17 -0
- package/dist/commands/release/rollback.js +38 -0
- package/dist/commands/servers/index.d.ts +20 -0
- package/dist/commands/servers/index.js +36 -0
- package/dist/commands/servers/use.d.ts +11 -0
- package/dist/commands/servers/use.js +30 -0
- package/dist/commands/site/adopt.d.ts +11 -0
- package/dist/commands/site/adopt.js +21 -0
- package/dist/commands/site/create.d.ts +18 -0
- package/dist/commands/site/create.js +61 -0
- package/dist/commands/site/edit.d.ts +11 -0
- package/dist/commands/site/edit.js +56 -0
- package/dist/commands/site/history.d.ts +11 -0
- package/dist/commands/site/history.js +25 -0
- package/dist/commands/site/link.d.ts +15 -0
- package/dist/commands/site/link.js +35 -0
- package/dist/commands/site/list.d.ts +9 -0
- package/dist/commands/site/list.js +29 -0
- package/dist/commands/site/reset-storage.d.ts +15 -0
- package/dist/commands/site/reset-storage.js +61 -0
- package/dist/commands/site/set.d.ts +16 -0
- package/dist/commands/site/set.js +45 -0
- package/dist/commands/site/show.d.ts +10 -0
- package/dist/commands/site/show.js +19 -0
- package/dist/commands/site/status.d.ts +11 -0
- package/dist/commands/site/status.js +15 -0
- package/dist/commands/site/unlink.d.ts +11 -0
- package/dist/commands/site/unlink.js +28 -0
- package/dist/commands/source/add.d.ts +32 -0
- package/dist/commands/source/add.js +103 -0
- package/dist/commands/source/adopt-pages.d.ts +14 -0
- package/dist/commands/source/adopt-pages.js +30 -0
- package/dist/commands/source/check.d.ts +17 -0
- package/dist/commands/source/check.js +52 -0
- package/dist/commands/source/list.d.ts +11 -0
- package/dist/commands/source/list.js +15 -0
- package/dist/commands/source/mappings/check.d.ts +13 -0
- package/dist/commands/source/mappings/check.js +69 -0
- package/dist/commands/source/pending.d.ts +12 -0
- package/dist/commands/source/pending.js +25 -0
- package/dist/commands/source/plugins.d.ts +6 -0
- package/dist/commands/source/plugins.js +17 -0
- package/dist/commands/source/sync.d.ts +16 -0
- package/dist/commands/source/sync.js +58 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.js +21 -0
- package/dist/connect-prompts.d.ts +16 -0
- package/dist/connect-prompts.js +24 -0
- package/dist/connect.d.ts +133 -0
- package/dist/connect.js +416 -0
- package/dist/core-command.d.ts +91 -0
- package/dist/core-command.js +262 -0
- package/dist/core-types.d.ts +21 -0
- package/dist/core-types.js +1 -0
- package/dist/create-connect.d.ts +26 -0
- package/dist/create-connect.js +93 -0
- package/dist/dev/code-watcher.d.ts +66 -0
- package/dist/dev/code-watcher.js +254 -0
- package/dist/dev/dev-checks.d.ts +14 -0
- package/dist/dev/dev-checks.js +138 -0
- package/dist/dev/dev-reload.d.ts +51 -0
- package/dist/dev/dev-reload.js +345 -0
- package/dist/dev/flags.d.ts +15 -0
- package/dist/dev/flags.js +43 -0
- package/dist/dev/html.d.ts +30 -0
- package/dist/dev/html.js +106 -0
- package/dist/dev/kit-files.d.ts +7 -0
- package/dist/dev/kit-files.js +33 -0
- package/dist/dev/local-code.d.ts +22 -0
- package/dist/dev/local-code.js +101 -0
- package/dist/dev/remote-config.d.ts +57 -0
- package/dist/dev/remote-config.js +100 -0
- package/dist/dev/remote-dev.d.ts +41 -0
- package/dist/dev/remote-dev.js +527 -0
- package/dist/dev/remote-fetch.d.ts +5 -0
- package/dist/dev/remote-fetch.js +36 -0
- package/dist/dev/remote-html.d.ts +10 -0
- package/dist/dev/remote-html.js +60 -0
- package/dist/dev/remote-page.d.ts +34 -0
- package/dist/dev/remote-page.js +183 -0
- package/dist/dev/remote-routes.d.ts +63 -0
- package/dist/dev/remote-routes.js +114 -0
- package/dist/dev/signal-stop.d.ts +17 -0
- package/dist/dev/signal-stop.js +46 -0
- package/dist/dev/start.d.ts +18 -0
- package/dist/dev/start.js +80 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/lib/diagnostics.d.ts +15 -0
- package/dist/lib/diagnostics.js +12 -0
- package/dist/lib/front-matter.d.ts +6 -0
- package/dist/lib/front-matter.js +59 -0
- package/dist/lib/operation-result.d.ts +3 -0
- package/dist/lib/operation-result.js +16 -0
- package/dist/lib/problem-groups.d.ts +27 -0
- package/dist/lib/problem-groups.js +49 -0
- package/dist/lib/problems.d.ts +50 -0
- package/dist/lib/problems.js +94 -0
- package/dist/lib/prompts.d.ts +38 -0
- package/dist/lib/prompts.js +77 -0
- package/dist/lib/result-types.d.ts +198 -0
- package/dist/lib/result-types.js +3 -0
- package/dist/lib/rules.d.ts +15 -0
- package/dist/lib/rules.js +26 -0
- package/dist/lib/summaries.d.ts +19 -0
- package/dist/lib/summaries.js +22 -0
- package/dist/lib/sync-problems.d.ts +21 -0
- package/dist/lib/sync-problems.js +19 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +40 -0
- package/dist/project-preview.d.ts +35 -0
- package/dist/project-preview.js +156 -0
- package/dist/project-publish.d.ts +28 -0
- package/dist/project-publish.js +173 -0
- package/dist/remote/connection.d.ts +8 -0
- package/dist/remote/connection.js +19 -0
- package/dist/remote/core-failure.d.ts +8 -0
- package/dist/remote/core-failure.js +15 -0
- package/dist/remote/credentials.d.ts +15 -0
- package/dist/remote/credentials.js +112 -0
- package/dist/remote/device-login.d.ts +33 -0
- package/dist/remote/device-login.js +161 -0
- package/dist/remote/remote-caller.d.ts +14 -0
- package/dist/remote/remote-caller.js +52 -0
- package/dist/remote/rpc-wire.d.ts +18 -0
- package/dist/remote/rpc-wire.js +57 -0
- package/dist/remote/servers.d.ts +80 -0
- package/dist/remote/servers.js +162 -0
- package/dist/remote/session.d.ts +53 -0
- package/dist/remote/session.js +132 -0
- package/dist/remote/sign-in-here.d.ts +5 -0
- package/dist/remote/sign-in-here.js +33 -0
- package/dist/remote/sign-in.d.ts +25 -0
- package/dist/remote/sign-in.js +55 -0
- package/dist/remote/wait-slices.d.ts +16 -0
- package/dist/remote/wait-slices.js +21 -0
- package/dist/render/add.d.ts +3 -0
- package/dist/render/add.js +9 -0
- package/dist/render/branch-write.d.ts +9 -0
- package/dist/render/branch-write.js +28 -0
- package/dist/render/branches.d.ts +5 -0
- package/dist/render/branches.js +28 -0
- package/dist/render/credentials.d.ts +5 -0
- package/dist/render/credentials.js +39 -0
- package/dist/render/operation-result.d.ts +16 -0
- package/dist/render/operation-result.js +65 -0
- package/dist/render/operation.d.ts +7 -0
- package/dist/render/operation.js +15 -0
- package/dist/render/page-changes.d.ts +3 -0
- package/dist/render/page-changes.js +36 -0
- package/dist/render/pending.d.ts +3 -0
- package/dist/render/pending.js +46 -0
- package/dist/render/plugin-list.d.ts +3 -0
- package/dist/render/plugin-list.js +30 -0
- package/dist/render/probe.d.ts +3 -0
- package/dist/render/probe.js +61 -0
- package/dist/render/problems.d.ts +35 -0
- package/dist/render/problems.js +64 -0
- package/dist/render/recovery.d.ts +2 -0
- package/dist/render/recovery.js +36 -0
- package/dist/render/reset-storage.d.ts +4 -0
- package/dist/render/reset-storage.js +70 -0
- package/dist/render/site-status.d.ts +2 -0
- package/dist/render/site-status.js +81 -0
- package/dist/render/source-list.d.ts +2 -0
- package/dist/render/source-list.js +37 -0
- package/dist/render/sync.d.ts +5 -0
- package/dist/render/sync.js +66 -0
- package/dist/settings.d.ts +10 -0
- package/dist/settings.js +45 -0
- package/dist/site-entry-edit.d.ts +5 -0
- package/dist/site-entry-edit.js +44 -0
- package/dist/source-entry.d.ts +32 -0
- package/dist/source-entry.js +89 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +10 -0
- package/package.json +108 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Command, Errors, Flags } from '@oclif/core';
|
|
2
|
+
import { NEEDS_ENGINE } from '../core-command.js';
|
|
3
|
+
import { devProblem, isRemote, withRemoteValue } from '../dev/flags.js';
|
|
4
|
+
import { UsageError } from '../dev/start.js';
|
|
5
|
+
const WITHOUT_REMOTE = `\`dev\` without --remote serves local content and ${NEEDS_ENGINE}`;
|
|
6
|
+
export default class Dev extends Command {
|
|
7
|
+
static summary = 'Develop blocks against a deployed site: its content, this checkout’s code (dev --remote)';
|
|
8
|
+
static description = 'A server process, not a core operation: content from the deployed preview (default) or live site, ' +
|
|
9
|
+
'components/, scripts/ and styles/ from this checkout, until Ctrl+C. Serving local content needs the engine.';
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> dev --remote --watch # in the frontend checkout: preview content, local code',
|
|
12
|
+
'<%= config.bin %> dev --remote live --port 3001',
|
|
13
|
+
'<%= config.bin %> dev --remote-url https://preview.foliwake.example --remote-auth-user owner ' +
|
|
14
|
+
'--remote-auth-env PREVIEW_PASSWORD',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
port: Flags.integer({ min: 0, max: 65535, description: 'port to listen on (default 3000)' }),
|
|
18
|
+
watch: Flags.boolean({
|
|
19
|
+
description: 'watch local components/, scripts/, styles/ and reload open browser pages after changes ' +
|
|
20
|
+
'(one reload per burst of saves; problems are shown in the page until fixed). Without it, refresh by hand',
|
|
21
|
+
}),
|
|
22
|
+
'watch-polling': Flags.boolean({
|
|
23
|
+
allowNo: true,
|
|
24
|
+
description: 'with --watch: detect code changes by polling file stats (default on macOS); --no-watch-polling: ' +
|
|
25
|
+
'native file-system events (default elsewhere). Precedence: this flag, then ' +
|
|
26
|
+
'FOLIWAKE_WATCH_POLLING=1|0, then CHOKIDAR_USEPOLLING, then the platform default',
|
|
27
|
+
}),
|
|
28
|
+
remote: Flags.string({
|
|
29
|
+
helpValue: '[preview|live]',
|
|
30
|
+
description: 'content from the deployed preview (default) or live site, local components/, scripts/ and styles/; ' +
|
|
31
|
+
'endpoints from ./foliwake.remote.json. Live only when named; never a fallback',
|
|
32
|
+
}),
|
|
33
|
+
'remote-url': Flags.string({
|
|
34
|
+
description: 'remote mode with this site origin instead of foliwake.remote.json (https; http only for loopback)',
|
|
35
|
+
}),
|
|
36
|
+
'remote-auth-env': Flags.string({
|
|
37
|
+
helpValue: 'NAME',
|
|
38
|
+
description: 'with --remote-url: NAME of the environment variable holding the HTTP Basic password ' +
|
|
39
|
+
'(never the password itself)',
|
|
40
|
+
}),
|
|
41
|
+
'remote-auth-user': Flags.string({ description: 'with --remote-auth-env: the HTTP Basic user name' }),
|
|
42
|
+
'remote-config': Flags.string({
|
|
43
|
+
description: 'with --remote: another endpoints file than ./foliwake.remote.json (same format, secret-free)',
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
async run() {
|
|
47
|
+
const { flags } = await this.parse(Dev, withRemoteValue(this.argv));
|
|
48
|
+
if (!isRemote(flags))
|
|
49
|
+
this.error(WITHOUT_REMOTE, { exit: 2 });
|
|
50
|
+
const problem = devProblem(flags);
|
|
51
|
+
if (problem)
|
|
52
|
+
throw new UsageError(problem);
|
|
53
|
+
const { startRemoteDev } = await import('../dev/start.js');
|
|
54
|
+
const options = {
|
|
55
|
+
remote: flags.remote === 'live' ? 'live' : 'preview',
|
|
56
|
+
port: flags.port,
|
|
57
|
+
watch: flags.watch,
|
|
58
|
+
polling: flags['watch-polling'],
|
|
59
|
+
remoteUrl: flags['remote-url'],
|
|
60
|
+
remoteConfig: flags['remote-config'],
|
|
61
|
+
remoteAuthEnv: flags['remote-auth-env'],
|
|
62
|
+
remoteAuthUser: flags['remote-auth-user'],
|
|
63
|
+
};
|
|
64
|
+
await startRemoteDev(options, (line) => this.log(line), (stop) => this.stopOnSignal(stop));
|
|
65
|
+
}
|
|
66
|
+
/** Set by stopOnSignal(): settles when a signal has stopped the server. */
|
|
67
|
+
stopped = null;
|
|
68
|
+
/** On Ctrl+C or SIGTERM: closes the listeners, waits for the work that runs, exits. */
|
|
69
|
+
stopOnSignal(stop) {
|
|
70
|
+
const warn = (line) => this.logToStderr(line);
|
|
71
|
+
this.stopped = import('../dev/signal-stop.js').then(({ stopOnSignals }) => stopOnSignals({ stop, exit: (code) => process.exit(code), warn }));
|
|
72
|
+
}
|
|
73
|
+
// The command is done when a signal stopped the server, not when its listener started.
|
|
74
|
+
async _run() {
|
|
75
|
+
const result = await super._run();
|
|
76
|
+
if (this.stopped)
|
|
77
|
+
await this.stopped;
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
// Printed as they are: these messages name flags, paths and variables that a wrap would break.
|
|
81
|
+
async catch(error) {
|
|
82
|
+
if (error instanceof Errors.CLIError || error instanceof Errors.ExitError)
|
|
83
|
+
return super.catch(error);
|
|
84
|
+
if (!(error instanceof UsageError))
|
|
85
|
+
return super.catch(error);
|
|
86
|
+
this.logToStderr(error.message);
|
|
87
|
+
return this.exit(2);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Login extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
6
|
+
static args: {
|
|
7
|
+
server: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
browser: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
default: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'insecure-storage': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
/** The server as typed, or asked for in a terminal; without either, a usage error. */
|
|
16
|
+
private typedServer;
|
|
17
|
+
/** Says whether the server is now the default; true when it is. */
|
|
18
|
+
private reportDefault;
|
|
19
|
+
private originOf;
|
|
20
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { CLOUD, CLOUD_NOTE, ServerAddressError, cloudConfigured, nameOrigin, readProfiles, serverDisplay, serverOrigin, } from '../remote/servers.js';
|
|
3
|
+
import { COMMAND } from '../settings.js';
|
|
4
|
+
const NO_SERVER = `Name the server to sign in to: \`${COMMAND} login <origin or host>\`, e.g. https://foliwake.example.`;
|
|
5
|
+
/** Asks for the server's address in a terminal; null when cancelled or empty. */
|
|
6
|
+
async function askServer() {
|
|
7
|
+
const { isCancel, text } = await import('@clack/prompts');
|
|
8
|
+
const answer = await text({ message: 'Address of your Foliwake server', placeholder: 'https://foliwake.example' });
|
|
9
|
+
return isCancel(answer) || !answer.trim() ? null : answer.trim();
|
|
10
|
+
}
|
|
11
|
+
export default class Login extends Command {
|
|
12
|
+
static description = 'Sign this computer in to a Foliwake server through the browser (device code)';
|
|
13
|
+
static examples = [
|
|
14
|
+
'<%= config.bin %> login https://foliwake.example',
|
|
15
|
+
'<%= config.bin %> login http://localhost:8080 --default',
|
|
16
|
+
'<%= config.bin %> login 127.0.0.1:8098 --no-browser',
|
|
17
|
+
];
|
|
18
|
+
static enableJsonFlag = true;
|
|
19
|
+
static args = {
|
|
20
|
+
server: Args.string({
|
|
21
|
+
description: 'server origin or host (asked in a terminal when left out); Foliwake Cloud is not available yet',
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
static flags = {
|
|
25
|
+
browser: Flags.boolean({
|
|
26
|
+
description: 'open the approval page in the browser (--no-browser only prints its address)',
|
|
27
|
+
default: true,
|
|
28
|
+
allowNo: true,
|
|
29
|
+
}),
|
|
30
|
+
default: Flags.boolean({
|
|
31
|
+
description: 'make this server the default of other commands (the first sign-in always is)',
|
|
32
|
+
}),
|
|
33
|
+
'insecure-storage': Flags.boolean({
|
|
34
|
+
description: 'keep the token in a 0600 file when there is no system keychain',
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
async run() {
|
|
38
|
+
const { args, flags } = await this.parse(Login);
|
|
39
|
+
const origin = this.originOf(await this.typedServer(args.server));
|
|
40
|
+
const { CredentialStoreError } = await import('../remote/credentials.js');
|
|
41
|
+
const { SignInError } = await import('../remote/device-login.js');
|
|
42
|
+
const { deviceSignIn } = await import('../remote/sign-in.js');
|
|
43
|
+
try {
|
|
44
|
+
const signed = await deviceSignIn(origin, {
|
|
45
|
+
browser: flags.browser,
|
|
46
|
+
tty: process.stdout.isTTY === true,
|
|
47
|
+
insecureStorage: flags['insecure-storage'],
|
|
48
|
+
makeDefault: flags.default,
|
|
49
|
+
// Straight to stderr: the code must show also with --json (oclif silences logToStderr there).
|
|
50
|
+
log: (text) => void process.stderr.write(text),
|
|
51
|
+
});
|
|
52
|
+
const who = signed.email ?? signed.grant.principal;
|
|
53
|
+
this.log(`Signed in to ${serverDisplay(origin)} as ${who}; the token is in the ${signed.store}.`);
|
|
54
|
+
const isDefault = this.reportDefault(origin);
|
|
55
|
+
return { server: origin, ...signed.grant, store: signed.store, default: isDefault };
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof SignInError || error instanceof CredentialStoreError)
|
|
59
|
+
this.error(error.message, { exit: 1 });
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The server as typed, or asked for in a terminal; without either, a usage error. */
|
|
64
|
+
async typedServer(typed) {
|
|
65
|
+
if (typed !== undefined)
|
|
66
|
+
return typed;
|
|
67
|
+
const tty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
68
|
+
const asked = tty ? await askServer() : null;
|
|
69
|
+
if (asked === null)
|
|
70
|
+
this.error(NO_SERVER, { exit: 2 });
|
|
71
|
+
return asked;
|
|
72
|
+
}
|
|
73
|
+
/** Says whether the server is now the default; true when it is. */
|
|
74
|
+
reportDefault(origin) {
|
|
75
|
+
const { default: name } = readProfiles();
|
|
76
|
+
const isDefault = name !== null && nameOrigin(name) === origin;
|
|
77
|
+
if (!isDefault && name !== null) {
|
|
78
|
+
this.log(`The default server stays ${name}; \`${COMMAND} servers use ${origin}\` or --default changes it.`);
|
|
79
|
+
}
|
|
80
|
+
return isDefault;
|
|
81
|
+
}
|
|
82
|
+
originOf(typed) {
|
|
83
|
+
if (typed.trim().toLowerCase() === CLOUD && !cloudConfigured())
|
|
84
|
+
this.error(CLOUD_NOTE, { exit: 1 });
|
|
85
|
+
try {
|
|
86
|
+
return serverOrigin(typed);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof ServerAddressError)
|
|
90
|
+
this.error(error.message, { exit: 2 });
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Logout extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
6
|
+
static args: {
|
|
7
|
+
server: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
'forget-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<unknown>;
|
|
13
|
+
private originOf;
|
|
14
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { ServerAddressError, defaultOrigin, serverDisplay, serverOrigin } from '../remote/servers.js';
|
|
3
|
+
import { COMMAND } from '../settings.js';
|
|
4
|
+
const NOT_REVOKED_HINT = 'it then stays valid until 90 days after its last use';
|
|
5
|
+
export default class Logout extends Command {
|
|
6
|
+
static description = 'Revoke this computer’s sign-in to a Foliwake server and forget its token';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> logout',
|
|
9
|
+
'<%= config.bin %> logout https://foliwake.example',
|
|
10
|
+
'<%= config.bin %> logout cloud',
|
|
11
|
+
];
|
|
12
|
+
static enableJsonFlag = true;
|
|
13
|
+
static args = { server: Args.string({ description: 'server origin or host (default: the default server)' }) };
|
|
14
|
+
static flags = {
|
|
15
|
+
'forget-only': Flags.boolean({
|
|
16
|
+
description: 'forget the token here even when the server cannot revoke it (it then stays valid there until it expires)',
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(Logout);
|
|
21
|
+
const origin = this.originOf(args.server);
|
|
22
|
+
if (origin === null)
|
|
23
|
+
this.error('This computer is not signed in to any server.', { exit: 1 });
|
|
24
|
+
const { forgetSignIn, storedSignIn } = await import('../remote/session.js');
|
|
25
|
+
const { revokeToken } = await import('../remote/device-login.js');
|
|
26
|
+
// The sign-in kept for this server, also one issued elsewhere (the name `cloud` moved since).
|
|
27
|
+
const signIn = storedSignIn(origin);
|
|
28
|
+
if (!signIn)
|
|
29
|
+
this.error(`This computer is not signed in to ${serverDisplay(origin)}.`, { exit: 1 });
|
|
30
|
+
// A token is revoked only where it was issued: for a moved sign-in, that is its old origin.
|
|
31
|
+
const issuer = signIn.issuer;
|
|
32
|
+
const moved = issuer !== null && issuer !== origin;
|
|
33
|
+
const where = moved ? ` at ${issuer}, where it was issued (${signIn.key} now means ${origin})` : '';
|
|
34
|
+
if (issuer === null && !flags['forget-only']) {
|
|
35
|
+
this.error(`This computer's sign-in to ${signIn.key} does not say where it was issued, so its token is not sent ` +
|
|
36
|
+
`anywhere to be revoked. Pass --forget-only to forget it here (${NOT_REVOKED_HINT}).`, { exit: 1 });
|
|
37
|
+
}
|
|
38
|
+
// Revoked first: a token forgotten here but still valid there could not be revoked any more.
|
|
39
|
+
const revoked = issuer !== null && signIn.token !== null && (await revokeToken(issuer, signIn.token));
|
|
40
|
+
if (!revoked && signIn.token !== null && !flags['forget-only']) {
|
|
41
|
+
this.error(`${issuer ?? origin} could not revoke the token, so it is kept here to try again. Run ` +
|
|
42
|
+
`\`${COMMAND} logout\` again later, or pass --forget-only to forget it anyway ` +
|
|
43
|
+
'(it then stays valid there until 90 days after its last use).', { exit: 1 });
|
|
44
|
+
}
|
|
45
|
+
forgetSignIn(origin);
|
|
46
|
+
if (!revoked)
|
|
47
|
+
process.stderr.write(`Warning: the token was not revoked${where}; it was forgotten here only.\n`);
|
|
48
|
+
this.log(`Signed out of ${serverDisplay(origin)}${revoked && where ? `; the token was revoked${where}` : ''}.`);
|
|
49
|
+
return { server: origin, revoked };
|
|
50
|
+
}
|
|
51
|
+
originOf(typed) {
|
|
52
|
+
try {
|
|
53
|
+
return typed === undefined ? defaultOrigin() : serverOrigin(typed);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof ServerAddressError)
|
|
57
|
+
this.error(error.message, { exit: 2 });
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class MigrationCommit extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
expect: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
sequence: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<unknown>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { COMMAND } from '../../settings.js';
|
|
3
|
+
import { parseExpectedVersion } from '../../lib/rules.js';
|
|
4
|
+
import { CoreCommand } from '../../core-command.js';
|
|
5
|
+
import { exitCodeOf, operationResultLines, succeeded } from '../../render/operation-result.js';
|
|
6
|
+
export default class MigrationCommit extends CoreCommand {
|
|
7
|
+
static description = 'Release the reviewed preview of new code: code and pages go live as one site release (core migration.commit)';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> migration commit --expect sr_…@cd_…',
|
|
10
|
+
'<%= config.bin %> migration commit --expect sr_…@cd_… --sequence <ci run id> --json',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
...CoreCommand.siteFlags,
|
|
14
|
+
expect: Flags.string({ description: 'the reviewed preview and its code, sr_…@cd_… (`site status` prints them)' }),
|
|
15
|
+
sequence: Flags.integer({
|
|
16
|
+
description: 'deployment ordering, e.g. a CI run id; an older one than live code is refused',
|
|
17
|
+
min: 1,
|
|
18
|
+
}),
|
|
19
|
+
...CoreCommand.inputFlag,
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(MigrationCommit);
|
|
23
|
+
const input = await this.resolveInput(flags.input, async () => {
|
|
24
|
+
const expected = flags.expect === undefined ? null : parseExpectedVersion(flags.expect);
|
|
25
|
+
if (expected?.code === undefined)
|
|
26
|
+
this.error('--expect must be the reviewed preview and its code, sr_…@cd_….', { exit: 2 });
|
|
27
|
+
return {
|
|
28
|
+
...(await this.siteInput(flags.site)),
|
|
29
|
+
expect: { preview: expected.preview, code: expected.code },
|
|
30
|
+
...(flags.sequence === undefined ? {} : { sequence: flags.sequence }),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const result = await this.core.migration.commit(input);
|
|
34
|
+
for (const line of operationResultLines(result, `Released ${result.codeRelease ?? 'the reviewed code'} with every page`))
|
|
35
|
+
this.log(line);
|
|
36
|
+
if (succeeded(result) && result.previousSiteRelease && result.siteRelease) {
|
|
37
|
+
this.log(`To go back: \`${COMMAND} release rollback ${result.previousSiteRelease} --expect ${result.siteRelease}\`.`);
|
|
38
|
+
}
|
|
39
|
+
process.exitCode = exitCodeOf(result);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class MigrationPrepare extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
code: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
rev: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
add: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
remove: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
content: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<unknown>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { COMMAND } from '../../settings.js';
|
|
3
|
+
import { CoreCommand } from '../../core-command.js';
|
|
4
|
+
import { operationResultLines, succeeded } from '../../render/operation-result.js';
|
|
5
|
+
const pageList = (value) => value === undefined
|
|
6
|
+
? undefined
|
|
7
|
+
: value
|
|
8
|
+
.split(',')
|
|
9
|
+
.map((id) => id.trim())
|
|
10
|
+
.filter(Boolean);
|
|
11
|
+
export default class MigrationPrepare extends CoreCommand {
|
|
12
|
+
static description = 'Rebuild every live page against prepared code as the preview; live is unchanged (core migration.prepare)';
|
|
13
|
+
static examples = [
|
|
14
|
+
'<%= config.bin %> migration prepare cd_…',
|
|
15
|
+
'<%= config.bin %> migration prepare cd_… --rev <sha> --json',
|
|
16
|
+
'<%= config.bin %> migration prepare cd_… --remove old-page --add new-page',
|
|
17
|
+
];
|
|
18
|
+
static args = { code: Args.string({ description: 'the prepared code release (cd_…)' }) };
|
|
19
|
+
static flags = {
|
|
20
|
+
...CoreCommand.siteFlags,
|
|
21
|
+
...CoreCommand.contentFlag,
|
|
22
|
+
rev: Flags.string({ description: 'the commit the code was prepared from, recorded with the preview' }),
|
|
23
|
+
add: Flags.string({ description: 'pages that are not live and join the site with it (comma-separated IDs)' }),
|
|
24
|
+
remove: Flags.string({ description: 'live pages that leave the site with it (comma-separated IDs)' }),
|
|
25
|
+
...CoreCommand.inputFlag,
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
const { args, flags } = await this.parse(MigrationPrepare);
|
|
29
|
+
const input = await this.resolveInput(flags.input, async () => {
|
|
30
|
+
if (args.code == null)
|
|
31
|
+
this.error('Name the prepared code release (or pass the full input as --input JSON).', { exit: 2 });
|
|
32
|
+
const add = pageList(flags.add);
|
|
33
|
+
const remove = pageList(flags.remove);
|
|
34
|
+
return {
|
|
35
|
+
...(await this.siteInput(flags.site)),
|
|
36
|
+
code: args.code,
|
|
37
|
+
...(flags.rev ? { sourceRevision: flags.rev } : {}),
|
|
38
|
+
...(add ? { add } : {}),
|
|
39
|
+
...(remove ? { remove } : {}),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
const result = await this.core.migration.prepare(input);
|
|
43
|
+
for (const line of operationResultLines(result, 'Every page rebuilt in preview'))
|
|
44
|
+
this.log(line);
|
|
45
|
+
if (succeeded(result) && result.siteRelease && result.codeRelease) {
|
|
46
|
+
this.log(`Live is unchanged. Review the preview, then release it with \`${COMMAND} migration commit --expect ` +
|
|
47
|
+
`${result.siteRelease}@${result.codeRelease}\`.`);
|
|
48
|
+
}
|
|
49
|
+
if (!succeeded(result))
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class OperationCancel extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
import { operationRow } from '../../render/operation.js';
|
|
4
|
+
export default class OperationCancel extends CoreCommand {
|
|
5
|
+
static description = 'Ask a long operation to stop: a queued one stops at once, a running one when it can (core operations.cancel)';
|
|
6
|
+
static examples = ['<%= config.bin %> operation cancel co_…'];
|
|
7
|
+
static args = { id: Args.string({ description: 'operation id (co_…)', required: true }) };
|
|
8
|
+
static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags, args } = await this.parse(OperationCancel);
|
|
11
|
+
const input = await this.resolveInput(flags.input, async () => ({
|
|
12
|
+
...(await this.siteInput(flags.site)),
|
|
13
|
+
id: args.id,
|
|
14
|
+
}));
|
|
15
|
+
const operation = await this.core.operations.cancel(input);
|
|
16
|
+
this.log(operationRow(operation));
|
|
17
|
+
if (!operation.cancelRequested)
|
|
18
|
+
this.log(' It cannot stop at this step; it ends on its own.');
|
|
19
|
+
return operation;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class OperationGet extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
import { operationRow, traceLines } from '../../render/operation.js';
|
|
4
|
+
export default class OperationGet extends CoreCommand {
|
|
5
|
+
static description = 'One long operation: its state, stage, delivery and result (core operations.get)';
|
|
6
|
+
static examples = ['<%= config.bin %> operation get co_… --json'];
|
|
7
|
+
static args = { id: Args.string({ description: 'operation id (co_…)', required: true }) };
|
|
8
|
+
static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags, args } = await this.parse(OperationGet);
|
|
11
|
+
const input = await this.resolveInput(flags.input, async () => ({
|
|
12
|
+
...(await this.siteInput(flags.site)),
|
|
13
|
+
id: args.id,
|
|
14
|
+
}));
|
|
15
|
+
const operation = await this.core.operations.get(input);
|
|
16
|
+
this.log(operationRow(operation));
|
|
17
|
+
if (operation.delivery)
|
|
18
|
+
this.log(` cache refresh: ` +
|
|
19
|
+
`${operation.delivery.state}${operation.delivery.reason ? ` (${operation.delivery.reason})` : ''}`);
|
|
20
|
+
if (operation.error)
|
|
21
|
+
this.log(` ${operation.error.code}: ${operation.error.message}`);
|
|
22
|
+
for (const line of traceLines(operation.trace))
|
|
23
|
+
this.log(line);
|
|
24
|
+
return operation;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class OperationList extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
import { operationRow } from '../../render/operation.js';
|
|
4
|
+
export default class OperationList extends CoreCommand {
|
|
5
|
+
static description = 'The latest long operations of a site, newest first (core operations.list)';
|
|
6
|
+
static examples = ['<%= config.bin %> operation list', '<%= config.bin %> operation list --limit 5 --json'];
|
|
7
|
+
static flags = {
|
|
8
|
+
...CoreCommand.siteFlags,
|
|
9
|
+
limit: Flags.integer({ min: 1, max: 200, description: 'how many (default 50)' }),
|
|
10
|
+
...CoreCommand.inputFlag,
|
|
11
|
+
};
|
|
12
|
+
async run() {
|
|
13
|
+
const { flags } = await this.parse(OperationList);
|
|
14
|
+
const input = await this.resolveInput(flags.input, async () => ({
|
|
15
|
+
...(await this.siteInput(flags.site)),
|
|
16
|
+
...(flags.limit === undefined ? {} : { limit: flags.limit }),
|
|
17
|
+
}));
|
|
18
|
+
const list = await this.core.operations.list(input);
|
|
19
|
+
if (list.operations.length === 0)
|
|
20
|
+
this.log('No operations yet.');
|
|
21
|
+
for (const operation of list.operations)
|
|
22
|
+
this.log(operationRow(operation));
|
|
23
|
+
return list;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exit status of `operation recover --wait` when cache refreshes are still pending at its deadline (they stay
|
|
4
|
+
* recorded).
|
|
5
|
+
*/
|
|
6
|
+
export declare const EXIT_REFRESH_PENDING = 3;
|
|
7
|
+
export default class OperationRecover extends CoreCommand {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
timings: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
'wait-timeout': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'break-lock': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<unknown>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CoreCommand, NEEDS_ENGINE } from '../../core-command.js';
|
|
3
|
+
import { recoveryLines } from '../../render/recovery.js';
|
|
4
|
+
/**
|
|
5
|
+
* Exit status of `operation recover --wait` when cache refreshes are still pending at its deadline (they stay
|
|
6
|
+
* recorded).
|
|
7
|
+
*/
|
|
8
|
+
export const EXIT_REFRESH_PENDING = 3;
|
|
9
|
+
export default class OperationRecover extends CoreCommand {
|
|
10
|
+
static description = 'Find out what happened to interrupted operations, finish the engine’s interrupted work and pending cache ' +
|
|
11
|
+
'refreshes; never runs an operation again (core operations.recover)';
|
|
12
|
+
static examples = ['<%= config.bin %> operation recover --wait'];
|
|
13
|
+
static flags = {
|
|
14
|
+
...CoreCommand.siteFlags,
|
|
15
|
+
wait: Flags.boolean({
|
|
16
|
+
description: 'also wait (bounded) for pending cache refreshes; those still pending then stay recorded and the exit ' +
|
|
17
|
+
'status is 3',
|
|
18
|
+
}),
|
|
19
|
+
'wait-timeout': Flags.integer({ min: 0, description: 'limit of --wait in seconds (default: settle delay + 90 s)' }),
|
|
20
|
+
'break-lock': Flags.boolean({
|
|
21
|
+
description: 'remove a state lock left by a process that is gone (on the server: needs the engine there)',
|
|
22
|
+
}),
|
|
23
|
+
...CoreCommand.timingsFlag,
|
|
24
|
+
...CoreCommand.inputFlag,
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(OperationRecover);
|
|
28
|
+
if (flags['break-lock'])
|
|
29
|
+
this.error(`--break-lock ${NEEDS_ENGINE}`, { exit: 2 });
|
|
30
|
+
const input = await this.resolveInput(flags.input, async () => {
|
|
31
|
+
const { site } = await this.siteInput(flags.site);
|
|
32
|
+
if (!flags.wait)
|
|
33
|
+
return { site, waitMs: null };
|
|
34
|
+
return {
|
|
35
|
+
site,
|
|
36
|
+
waitMs: flags['wait-timeout'] === undefined
|
|
37
|
+
? (await this.settleDelayMs(site)) + 90_000
|
|
38
|
+
: flags['wait-timeout'] * 1000,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const answer = await this.timed('recover', flags.timings, () => this.core.operations.recover(input));
|
|
42
|
+
if (!this.jsonEnabled())
|
|
43
|
+
for (const line of recoveryLines(answer))
|
|
44
|
+
this.log(line);
|
|
45
|
+
if (input.waitMs !== null && answer.engine.cacheRefresh.state === 'pending')
|
|
46
|
+
process.exitCode = EXIT_REFRESH_PENDING;
|
|
47
|
+
return answer;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class PageChanges extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
changed: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
content: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<unknown>;
|
|
13
|
+
}
|