@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,103 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { confirm, isCancel } from '@clack/prompts';
|
|
3
|
+
import { Errors, Flags } from '@oclif/core';
|
|
4
|
+
import { CoreCommand } from '../../core-command.js';
|
|
5
|
+
import { addLines } from '../../render/add.js';
|
|
6
|
+
import { probeLines } from '../../render/probe.js';
|
|
7
|
+
import { DEFAULT_DRIVE_KEY, DRIVE_PLUGIN, entryOf } from '../../source-entry.js';
|
|
8
|
+
const usable = (probe) => Object.keys(probe.fields).length === 0;
|
|
9
|
+
async function readRules(file) {
|
|
10
|
+
if (file === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(await readFile(file, 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw new Errors.CLIError(`--mappings: ${file} is not a readable JSON file of rules.`, { exit: 2 });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default class SourceAdd extends CoreCommand {
|
|
20
|
+
static description = 'Adds a content source to a site: checks it first (settings, credentials, connection, files and their ' +
|
|
21
|
+
'addresses), then saves it after a confirmation; nothing is fetched (core sources.probe, sources.add)';
|
|
22
|
+
static examples = [
|
|
23
|
+
'<%= config.bin %> source add --site my-site --id lessons --owns /lessons ' +
|
|
24
|
+
'--folder https://drive.google.com/drive/folders/1AbC…',
|
|
25
|
+
'<%= config.bin %> source add --site docs --plugin git-markdown --id docs --owns /docs ' +
|
|
26
|
+
'--repository https://github.com/acme/docs',
|
|
27
|
+
'<%= config.bin %> source add --site news --plugin drupal --id news --owns /articles ' +
|
|
28
|
+
'--base-url https://cms.example.org --language en',
|
|
29
|
+
];
|
|
30
|
+
static flags = {
|
|
31
|
+
...CoreCommand.siteFlags,
|
|
32
|
+
plugin: Flags.string({ description: 'the connector', default: DRIVE_PLUGIN }),
|
|
33
|
+
id: Flags.string({ description: 'the new source id (lower case, digits, "-")', required: true }),
|
|
34
|
+
'display-name': Flags.string({ description: 'the name the dashboard shows' }),
|
|
35
|
+
owns: Flags.string({
|
|
36
|
+
description: 'a path the source owns, such as /lessons or "=/" (repeatable)',
|
|
37
|
+
multiple: true,
|
|
38
|
+
required: true,
|
|
39
|
+
}),
|
|
40
|
+
mappings: Flags.string({
|
|
41
|
+
description: 'a JSON file with path mapping rules (default: each file names its address)',
|
|
42
|
+
}),
|
|
43
|
+
folder: Flags.string({ description: 'Google Drive: the folder link or ID' }),
|
|
44
|
+
subfolder: Flags.string({ description: 'Google Drive or Git: the folder inside that holds the pages' }),
|
|
45
|
+
identity: Flags.string({
|
|
46
|
+
description: 'Google Drive: file-id (default; renames keep the page) or front-matter',
|
|
47
|
+
options: ['file-id', 'front-matter'],
|
|
48
|
+
}),
|
|
49
|
+
key: Flags.string({
|
|
50
|
+
description: `Google Drive: the credential name of the service-account key (default ${DEFAULT_DRIVE_KEY})`,
|
|
51
|
+
}),
|
|
52
|
+
repository: Flags.string({ description: 'Git: the https address of the repository' }),
|
|
53
|
+
branch: Flags.string({ description: 'Git: the branch (default main)' }),
|
|
54
|
+
token: Flags.string({ description: 'Git: the credential name of a read-only token (private repository)' }),
|
|
55
|
+
'base-url': Flags.string({ description: 'Drupal: the site address' }),
|
|
56
|
+
language: Flags.string({ description: 'Drupal: a language code, the default first (repeatable)', multiple: true }),
|
|
57
|
+
'basic-user': Flags.string({ description: 'Drupal: the credential name of a read-only user name (HTTP Basic)' }),
|
|
58
|
+
'basic-password': Flags.string({ description: 'Drupal: the credential name of its password' }),
|
|
59
|
+
'check-only': Flags.boolean({ description: 'check and print, save nothing' }),
|
|
60
|
+
yes: Flags.boolean({ description: 'save without asking (scripts)' }),
|
|
61
|
+
};
|
|
62
|
+
async run() {
|
|
63
|
+
const { flags } = await this.parse(SourceAdd);
|
|
64
|
+
const site = (await this.siteInput(flags.site)).site;
|
|
65
|
+
const built = entryOf(flags, await readRules(flags.mappings));
|
|
66
|
+
if (!built.ok)
|
|
67
|
+
throw new Errors.CLIError(built.problem, { exit: 2 });
|
|
68
|
+
const probe = await this.core.sources.probe({ site, candidate: built.value, listing: {} });
|
|
69
|
+
this.print(probeLines(probe));
|
|
70
|
+
if (!usable(probe) || flags['check-only'])
|
|
71
|
+
return this.finishCheck(probe);
|
|
72
|
+
if (!(await this.confirmed(flags.yes, probe)))
|
|
73
|
+
return { probe, saved: null };
|
|
74
|
+
const saved = await this.core.sources.add({
|
|
75
|
+
site,
|
|
76
|
+
entry: built.value,
|
|
77
|
+
expect: { revision: probe.revision ?? '' },
|
|
78
|
+
});
|
|
79
|
+
this.print(addLines(saved));
|
|
80
|
+
return { probe, saved };
|
|
81
|
+
}
|
|
82
|
+
print(lines) {
|
|
83
|
+
if (!this.jsonEnabled())
|
|
84
|
+
for (const line of lines)
|
|
85
|
+
this.log(line);
|
|
86
|
+
}
|
|
87
|
+
finishCheck(probe) {
|
|
88
|
+
if (!usable(probe) || probe.connection?.ok === false)
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
return { probe, saved: null };
|
|
91
|
+
}
|
|
92
|
+
/** --yes, or a person who says yes in a terminal; a failed connection is said before the question. */
|
|
93
|
+
async confirmed(yes, probe) {
|
|
94
|
+
if (yes)
|
|
95
|
+
return true;
|
|
96
|
+
if (!process.stdin.isTTY || this.jsonEnabled()) {
|
|
97
|
+
throw new Errors.CLIError('Add --yes to save without a terminal (or --check-only to save nothing).', { exit: 2 });
|
|
98
|
+
}
|
|
99
|
+
const warning = probe.connection?.ok === false ? ' The connection check failed;' : '';
|
|
100
|
+
const answer = await confirm({ message: `${warning} Save source ${probe.source} to site ${probe.site}?`.trim() });
|
|
101
|
+
return !isCancel(answer) && answer === true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class SourceAdoptPages extends CoreCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
source: 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
|
+
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,30 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
export default class SourceAdoptPages extends CoreCommand {
|
|
4
|
+
static description = 'Let a source take over published pages that no source owns yet (published by an earlier configuration: one ' +
|
|
5
|
+
'folder), at paths it owns; preview and live are unchanged (core sources.adoptPages)';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> source adopt-pages git',
|
|
8
|
+
'<%= config.bin %> source adopt-pages git --site a --json',
|
|
9
|
+
];
|
|
10
|
+
static args = {
|
|
11
|
+
source: Args.string({ description: 'the content source that takes the pages over (see `source list`)' }),
|
|
12
|
+
};
|
|
13
|
+
static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(SourceAdoptPages);
|
|
16
|
+
const input = await this.resolveInput(flags.input, async () => {
|
|
17
|
+
if (args.source == null)
|
|
18
|
+
this.error('Name the source that takes the pages over.', { exit: 2 });
|
|
19
|
+
return { ...(await this.siteInput(flags.site)), source: args.source };
|
|
20
|
+
});
|
|
21
|
+
const result = await this.core.sources.adoptPages(input);
|
|
22
|
+
this.log(result.accepted.length
|
|
23
|
+
? `Source ${result.source} now owns ${result.accepted.length} published page id(s): ` +
|
|
24
|
+
`${result.accepted.join(', ')}. Recorded; preview and live are unchanged.`
|
|
25
|
+
: `No published page without an owner lies at a path source ${result.source} owns; nothing was accepted.`);
|
|
26
|
+
for (const skipped of result.skipped)
|
|
27
|
+
this.log(` not accepted: ${skipped.page_id} (${skipped.reason})`);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class SourceCheck 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
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
listing: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
max: import("@oclif/core/interfaces").OptionFlag<number | 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
|
+
private probeInput;
|
|
15
|
+
private probeOne;
|
|
16
|
+
private enabledSources;
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
import { probeLines } from '../../render/probe.js';
|
|
4
|
+
export default class SourceCheck extends CoreCommand {
|
|
5
|
+
static description = 'Checks content sources without changing anything: settings, credentials, the connection and, ' +
|
|
6
|
+
'with --listing, the files and the page addresses they would get (core sources.probe)';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> source check --site my-site',
|
|
9
|
+
'<%= config.bin %> source check --site my-site --source lessons --listing',
|
|
10
|
+
`<%= config.bin %> source check --site my-site --input '{"site":"my-site","candidate":{…}}'`,
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
...CoreCommand.siteFlags,
|
|
14
|
+
source: Flags.string({ description: 'one source of the site (default: every enabled source)' }),
|
|
15
|
+
listing: Flags.boolean({
|
|
16
|
+
description: 'also list the files and their page addresses (slower: reads the whole source)',
|
|
17
|
+
}),
|
|
18
|
+
max: Flags.integer({ min: 1, max: 5000, description: 'at most this many files in the listing (default 500)' }),
|
|
19
|
+
...CoreCommand.inputFlag,
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(SourceCheck);
|
|
23
|
+
const site = (await this.siteInput(flags.site)).site;
|
|
24
|
+
const listing = flags.listing ? { listing: flags.max === undefined ? {} : { max: flags.max } } : {};
|
|
25
|
+
if (flags.input !== undefined)
|
|
26
|
+
return this.probeInput(flags.input, site);
|
|
27
|
+
const ids = flags.source === undefined ? await this.enabledSources(site) : [flags.source];
|
|
28
|
+
const answers = [];
|
|
29
|
+
for (const source of ids)
|
|
30
|
+
answers.push(await this.probeOne({ site, source, ...listing }));
|
|
31
|
+
if (answers.some((answer) => answer.connection?.ok === false || Object.keys(answer.fields).length))
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
return answers;
|
|
34
|
+
}
|
|
35
|
+
async probeInput(raw, site) {
|
|
36
|
+
const answer = await this.probeOne(await this.resolveInput(raw, () => ({ site })));
|
|
37
|
+
if (answer.connection?.ok === false || Object.keys(answer.fields).length)
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return answer;
|
|
40
|
+
}
|
|
41
|
+
async probeOne(input) {
|
|
42
|
+
const answer = await this.core.sources.probe(input);
|
|
43
|
+
if (!this.jsonEnabled())
|
|
44
|
+
for (const line of [...probeLines(answer), ''])
|
|
45
|
+
this.log(line);
|
|
46
|
+
return answer;
|
|
47
|
+
}
|
|
48
|
+
async enabledSources(site) {
|
|
49
|
+
const { sources } = await this.core.sources.list({ site });
|
|
50
|
+
return sources.filter((source) => source.enabled && source.mode === 'snapshot').map((source) => source.id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class SourceList 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
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
import { sourceListLines } from '../../render/source-list.js';
|
|
3
|
+
export default class SourceList extends CoreCommand {
|
|
4
|
+
static description = "The site's content sources: plugin, owned paths and selected snapshot (core sources.list)";
|
|
5
|
+
static examples = ['<%= config.bin %> source list', '<%= config.bin %> source list --site a --json'];
|
|
6
|
+
static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
|
|
7
|
+
async run() {
|
|
8
|
+
const { flags } = await this.parse(SourceList);
|
|
9
|
+
const input = await this.resolveInput(flags.input, () => this.siteInput(flags.site));
|
|
10
|
+
const sources = await this.core.sources.list(input);
|
|
11
|
+
for (const line of sourceListLines(sources))
|
|
12
|
+
this.log(line);
|
|
13
|
+
return sources;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CoreCommand } from '../../../core-command.js';
|
|
2
|
+
export default class SourceMappingsCheck 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
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
file: 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
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Flags } from '@oclif/core';
|
|
4
|
+
import { formatDiagnostic } from '../../../lib/diagnostics.js';
|
|
5
|
+
import { coverageSummary } from '../../../lib/summaries.js';
|
|
6
|
+
import { CoreCommand } from '../../../core-command.js';
|
|
7
|
+
export default class SourceMappingsCheck extends CoreCommand {
|
|
8
|
+
static description = [
|
|
9
|
+
"Dry run of a source's path mappings over the documents it already has (the selected snapshot, or a working " +
|
|
10
|
+
"folder's files):",
|
|
11
|
+
"each document's page path now and with the rules, unmatched files and problems; reads no upstream and changes " +
|
|
12
|
+
'nothing (core sources.mappingsCheck)',
|
|
13
|
+
].join(' ');
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> source mappings check',
|
|
16
|
+
'<%= config.bin %> source mappings check --site my-site --source docs-en',
|
|
17
|
+
'<%= config.bin %> source mappings check --source docs-en --file mappings.json',
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
...CoreCommand.siteFlags,
|
|
21
|
+
source: Flags.string({ description: 'only this source (default: every source with path mappings)' }),
|
|
22
|
+
file: Flags.string({
|
|
23
|
+
description: 'check the rules in this JSON file (a list of rules) instead of the configured ones; needs --source',
|
|
24
|
+
}),
|
|
25
|
+
...CoreCommand.inputFlag,
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
const { flags } = await this.parse(SourceMappingsCheck);
|
|
29
|
+
const input = await this.resolveInput(flags.input, async () => {
|
|
30
|
+
let mappings;
|
|
31
|
+
if (flags.file !== undefined) {
|
|
32
|
+
try {
|
|
33
|
+
mappings = JSON.parse(await readFile(path.resolve(process.cwd(), flags.file), 'utf8'));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.error(`--file ${flags.file}: ${error instanceof Error ? error.message : String(error)}`, { exit: 2 });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const site = await this.siteInput(flags.site);
|
|
40
|
+
return {
|
|
41
|
+
...site,
|
|
42
|
+
...(flags.source === undefined ? {} : { source: flags.source }),
|
|
43
|
+
...(mappings === undefined ? {} : { mappings }),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
const result = await this.core.sources.mappingsCheck(input);
|
|
47
|
+
if (result.sources.length === 0)
|
|
48
|
+
this.log('No source of this site has path mappings.');
|
|
49
|
+
for (const source of result.sources) {
|
|
50
|
+
this.log(`Source ${source.source} (${source.mode}${source.snapshot ? `, snapshot ${source.snapshot}` : ''}):`);
|
|
51
|
+
for (const problem of source.ruleProblems)
|
|
52
|
+
this.log(` rule problem: ${problem}`);
|
|
53
|
+
if (source.mode === 'snapshot' && source.snapshot === null)
|
|
54
|
+
this.log(' no snapshot is selected yet: nothing to check (sync the source first).');
|
|
55
|
+
for (const row of source.documents) {
|
|
56
|
+
const change = row.before === row.after ? (row.after ?? '-') : `${row.before ?? '-'} → ${row.after ?? '-'}`;
|
|
57
|
+
this.log(` ${row.document}: ${row.outcome === 'page' ? change : row.outcome}${row.rule ? ` (${row.rule})` : ''}`);
|
|
58
|
+
}
|
|
59
|
+
if (source.rules.length > 0)
|
|
60
|
+
this.log(` documents per rule: ${coverageSummary(source.rules)}`);
|
|
61
|
+
for (const diagnostic of source.diagnostics)
|
|
62
|
+
this.log(` ${formatDiagnostic(diagnostic).replaceAll('\n', '\n ')}`);
|
|
63
|
+
this.log(` ${source.documents.length} document(s): ${source.errors} error(s), ${source.warnings} warning(s).`);
|
|
64
|
+
}
|
|
65
|
+
if (result.sources.some((source) => source.errors > 0))
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class SourcePending 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
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | 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 { pendingLines } from '../../render/pending.js';
|
|
4
|
+
export default class SourcePending extends CoreCommand {
|
|
5
|
+
static description = 'Edits waiting in the content sources that the selected snapshots do not have: a read-only check, nothing is ' +
|
|
6
|
+
'fetched into a snapshot or stored (core sources.pending)';
|
|
7
|
+
static examples = ['<%= config.bin %> source pending', '<%= config.bin %> source pending --source lessons --json'];
|
|
8
|
+
static flags = {
|
|
9
|
+
...CoreCommand.siteFlags,
|
|
10
|
+
source: Flags.string({ description: 'content source id of the site (see `source list`; default: every source)' }),
|
|
11
|
+
...CoreCommand.inputFlag,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags } = await this.parse(SourcePending);
|
|
15
|
+
const input = await this.resolveInput(flags.input, async () => ({
|
|
16
|
+
...(await this.siteInput(flags.site)),
|
|
17
|
+
...(flags.source === undefined ? {} : { source: flags.source }),
|
|
18
|
+
}));
|
|
19
|
+
const answer = await this.core.sources.pending(input);
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
for (const line of pendingLines(answer))
|
|
22
|
+
this.log(line);
|
|
23
|
+
return answer;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
import { pluginListLines } from '../../render/plugin-list.js';
|
|
3
|
+
export default class SourcePlugins extends CoreCommand {
|
|
4
|
+
static description = 'Registered content-source plugins, their versions and the planned catalog (core sources.plugins)';
|
|
5
|
+
static examples = [
|
|
6
|
+
'<%= config.bin %> source plugins',
|
|
7
|
+
'<%= config.bin %> source plugins --debug # why a plugin failed, on stderr',
|
|
8
|
+
];
|
|
9
|
+
async run() {
|
|
10
|
+
const plugins = await this.core.sources.plugins();
|
|
11
|
+
for (const line of pluginListLines(plugins))
|
|
12
|
+
this.log(line);
|
|
13
|
+
if (plugins.problems.length)
|
|
14
|
+
process.exitCode = 1;
|
|
15
|
+
return plugins;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CoreCommand } from '../../core-command.js';
|
|
2
|
+
export default class SourceSync 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
|
+
timings: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
full: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
code: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CoreCommand } from '../../core-command.js';
|
|
3
|
+
import { syncLines } from '../../render/sync.js';
|
|
4
|
+
export default class SourceSync extends CoreCommand {
|
|
5
|
+
static description = 'Read content sources into private snapshots and select them; preview and live are unchanged (core sources.sync)';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> source sync',
|
|
8
|
+
'<%= config.bin %> source sync --source content --json',
|
|
9
|
+
'<%= config.bin %> source sync --source lessons --full',
|
|
10
|
+
'<%= config.bin %> source sync --code cd_… # before `migration prepare cd_…`',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
...CoreCommand.siteFlags,
|
|
14
|
+
source: Flags.string({
|
|
15
|
+
description: 'content source id of the site (see `source list`; default: every enabled source)',
|
|
16
|
+
}),
|
|
17
|
+
full: Flags.boolean({
|
|
18
|
+
description: 'read every item of the source again (no incremental sync: unchanged items are not kept from the selected ' +
|
|
19
|
+
'snapshot)',
|
|
20
|
+
}),
|
|
21
|
+
code: Flags.string({
|
|
22
|
+
description: 'the prepared code of a migration: read and check the sources against it instead of live code',
|
|
23
|
+
}),
|
|
24
|
+
verbose: Flags.boolean({
|
|
25
|
+
description: "also print codes, snapshots, attempts and the engine's technical text (for support)",
|
|
26
|
+
}),
|
|
27
|
+
...CoreCommand.timingsFlag,
|
|
28
|
+
...CoreCommand.inputFlag,
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
const { flags } = await this.parse(SourceSync);
|
|
32
|
+
const input = await this.resolveInput(flags.input, async () => ({
|
|
33
|
+
...(await this.siteInput(flags.site)),
|
|
34
|
+
target: flags.source === undefined ? { all: true } : { source: flags.source },
|
|
35
|
+
allowWorkingFolder: true,
|
|
36
|
+
...(flags.full ? { full: true } : {}),
|
|
37
|
+
...(flags.code === undefined ? {} : { validationCode: flags.code }),
|
|
38
|
+
}));
|
|
39
|
+
return this.timed('sync', flags.timings, async () => {
|
|
40
|
+
const accepted = await this.core.sources.sync(input);
|
|
41
|
+
// Ctrl-C asks the sync to stop; it ends with what it has, nothing selected.
|
|
42
|
+
const cancel = () => void this.core.operations.cancel({ site: accepted.site, id: accepted.id }).catch(() => { });
|
|
43
|
+
process.once('SIGINT', cancel);
|
|
44
|
+
try {
|
|
45
|
+
const operation = await this.follow(accepted, { wait: false, waitTimeout: undefined });
|
|
46
|
+
if (!this.jsonEnabled())
|
|
47
|
+
for (const line of syncLines(operation, flags.code, { verbose: flags.verbose }))
|
|
48
|
+
this.log(line);
|
|
49
|
+
if (operation.state !== 'succeeded')
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return operation;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
process.removeListener('SIGINT', cancel);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CoreCommand } from '../core-command.js';
|
|
2
|
+
import { serverDisplay } from '../remote/servers.js';
|
|
3
|
+
const membershipText = (m) => `${m.org} (${m.role}${m.live ? ', live' : ''}${m.sites ? `: ${m.sites.join(', ')}` : ''})`;
|
|
4
|
+
export default class Whoami extends CoreCommand {
|
|
5
|
+
static description = 'Show the server, who this command acts as and what it may do (core whoami)';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> whoami',
|
|
8
|
+
'<%= config.bin %> whoami --server cloud',
|
|
9
|
+
'<%= config.bin %> whoami --json',
|
|
10
|
+
];
|
|
11
|
+
async run() {
|
|
12
|
+
const grant = await this.core.whoami();
|
|
13
|
+
const server = this.target.origin;
|
|
14
|
+
const organisations = grant.memberships.map(membershipText).join('; ');
|
|
15
|
+
this.log(`Server ${serverDisplay(server)}`);
|
|
16
|
+
this.log(`Principal ${grant.principal}`);
|
|
17
|
+
this.log(`Installation ${grant.installation ? 'yes' : 'no'}`);
|
|
18
|
+
this.log(`Organisations ${organisations || (grant.installation ? 'all' : 'none')}`);
|
|
19
|
+
return { server, ...grant };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
import type { ConnectRequest } from './connect.js';
|
|
3
|
+
export interface TerminalStreams {
|
|
4
|
+
input: Readable & {
|
|
5
|
+
isTTY?: boolean;
|
|
6
|
+
};
|
|
7
|
+
output: Writable & {
|
|
8
|
+
isTTY?: boolean;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** True when both streams are a terminal. */
|
|
12
|
+
export declare const isTerminal: (streams: TerminalStreams) => boolean;
|
|
13
|
+
/** `pick` and `confirmRelink` for a connect request in a terminal; nothing otherwise. */
|
|
14
|
+
export declare function terminalQuestions(streams: TerminalStreams, { ask }: {
|
|
15
|
+
ask: boolean;
|
|
16
|
+
}): Pick<ConnectRequest, 'pick' | 'confirmRelink'>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** True when both streams are a terminal. */
|
|
2
|
+
export const isTerminal = (streams) => streams.input.isTTY === true && streams.output.isTTY === true;
|
|
3
|
+
/** `pick` and `confirmRelink` for a connect request in a terminal; nothing otherwise. */
|
|
4
|
+
export function terminalQuestions(streams, { ask }) {
|
|
5
|
+
if (!ask || !isTerminal(streams))
|
|
6
|
+
return {};
|
|
7
|
+
const io = { input: streams.input, output: streams.output };
|
|
8
|
+
return {
|
|
9
|
+
pick: async (servers) => {
|
|
10
|
+
const { askServer } = await import('./lib/prompts.js');
|
|
11
|
+
return askServer(io, servers, (typed) => typed, { message: 'Which Foliwake server?', allowOther: false });
|
|
12
|
+
},
|
|
13
|
+
confirmRelink: async (from, to) => {
|
|
14
|
+
const { confirm, isCancel } = await import('@clack/prompts');
|
|
15
|
+
const { describeLink } = await import('./connect.js');
|
|
16
|
+
const answer = await confirm({
|
|
17
|
+
...io,
|
|
18
|
+
message: `This folder is linked to ${describeLink(from)}. Replace that with site ${to.site} on ${to.server}?`,
|
|
19
|
+
initialValue: false,
|
|
20
|
+
});
|
|
21
|
+
return !isCancel(answer) && answer === true;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|