@geekity/cms 0.3.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/LICENSE +21 -0
- package/README.md +870 -0
- package/admin/layouts/_flash.njk +5 -0
- package/admin/layouts/base.njk +27 -0
- package/admin/layouts/dashboard.njk +78 -0
- package/admin/layouts/document-conflict.njk +49 -0
- package/admin/layouts/document-editor.njk +167 -0
- package/admin/layouts/document-list.njk +92 -0
- package/admin/layouts/federation.njk +145 -0
- package/admin/layouts/login.njk +23 -0
- package/admin/layouts/placeholder.njk +10 -0
- package/admin/layouts/settings.njk +116 -0
- package/admin/layouts/setup.njk +27 -0
- package/admin/layouts/shell.njk +37 -0
- package/admin/layouts/users.njk +91 -0
- package/admin/static/admin.css +726 -0
- package/admin/static/editor.js +30 -0
- package/dist/admin/assets.d.ts +26 -0
- package/dist/admin/assets.d.ts.map +1 -0
- package/dist/admin/assets.js +38 -0
- package/dist/admin/assets.js.map +1 -0
- package/dist/admin/credentials.d.ts +28 -0
- package/dist/admin/credentials.d.ts.map +1 -0
- package/dist/admin/credentials.js +39 -0
- package/dist/admin/credentials.js.map +1 -0
- package/dist/admin/documents.d.ts +134 -0
- package/dist/admin/documents.d.ts.map +1 -0
- package/dist/admin/documents.js +613 -0
- package/dist/admin/documents.js.map +1 -0
- package/dist/admin/federation.d.ts +194 -0
- package/dist/admin/federation.d.ts.map +1 -0
- package/dist/admin/federation.js +299 -0
- package/dist/admin/federation.js.map +1 -0
- package/dist/admin/flash.d.ts +24 -0
- package/dist/admin/flash.d.ts.map +1 -0
- package/dist/admin/flash.js +31 -0
- package/dist/admin/flash.js.map +1 -0
- package/dist/admin/index.d.ts +23 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +15 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/passwords.d.ts +49 -0
- package/dist/admin/passwords.d.ts.map +1 -0
- package/dist/admin/passwords.js +122 -0
- package/dist/admin/passwords.js.map +1 -0
- package/dist/admin/preview.d.ts +18 -0
- package/dist/admin/preview.d.ts.map +1 -0
- package/dist/admin/preview.js +83 -0
- package/dist/admin/preview.js.map +1 -0
- package/dist/admin/routes.d.ts +54 -0
- package/dist/admin/routes.d.ts.map +1 -0
- package/dist/admin/routes.js +383 -0
- package/dist/admin/routes.js.map +1 -0
- package/dist/admin/session.d.ts +44 -0
- package/dist/admin/session.d.ts.map +1 -0
- package/dist/admin/session.js +69 -0
- package/dist/admin/session.js.map +1 -0
- package/dist/admin/settings.d.ts +194 -0
- package/dist/admin/settings.d.ts.map +1 -0
- package/dist/admin/settings.js +470 -0
- package/dist/admin/settings.js.map +1 -0
- package/dist/admin/store.d.ts +407 -0
- package/dist/admin/store.d.ts.map +1 -0
- package/dist/admin/store.js +704 -0
- package/dist/admin/store.js.map +1 -0
- package/dist/admin/templates.d.ts +36 -0
- package/dist/admin/templates.d.ts.map +1 -0
- package/dist/admin/templates.js +43 -0
- package/dist/admin/templates.js.map +1 -0
- package/dist/admin/uploads.d.ts +96 -0
- package/dist/admin/uploads.d.ts.map +1 -0
- package/dist/admin/uploads.js +179 -0
- package/dist/admin/uploads.js.map +1 -0
- package/dist/admin/users.d.ts +95 -0
- package/dist/admin/users.d.ts.map +1 -0
- package/dist/admin/users.js +233 -0
- package/dist/admin/users.js.map +1 -0
- package/dist/cli.d.ts +85 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +424 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +172 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +184 -0
- package/dist/config.js.map +1 -0
- package/dist/content/document.d.ts +66 -0
- package/dist/content/document.d.ts.map +1 -0
- package/dist/content/document.js +13 -0
- package/dist/content/document.js.map +1 -0
- package/dist/content/index.d.ts +17 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +10 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/markdown.d.ts +3 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +39 -0
- package/dist/content/markdown.js.map +1 -0
- package/dist/content/media.d.ts +65 -0
- package/dist/content/media.d.ts.map +1 -0
- package/dist/content/media.js +143 -0
- package/dist/content/media.js.map +1 -0
- package/dist/content/parser.d.ts +24 -0
- package/dist/content/parser.d.ts.map +1 -0
- package/dist/content/parser.js +165 -0
- package/dist/content/parser.js.map +1 -0
- package/dist/content/save.d.ts +60 -0
- package/dist/content/save.d.ts.map +1 -0
- package/dist/content/save.js +103 -0
- package/dist/content/save.js.map +1 -0
- package/dist/content/slug.d.ts +25 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +75 -0
- package/dist/content/slug.js.map +1 -0
- package/dist/content/store.d.ts +133 -0
- package/dist/content/store.d.ts.map +1 -0
- package/dist/content/store.js +411 -0
- package/dist/content/store.js.map +1 -0
- package/dist/content/sync.d.ts +146 -0
- package/dist/content/sync.d.ts.map +1 -0
- package/dist/content/sync.js +421 -0
- package/dist/content/sync.js.map +1 -0
- package/dist/content/writer.d.ts +37 -0
- package/dist/content/writer.d.ts.map +1 -0
- package/dist/content/writer.js +97 -0
- package/dist/content/writer.js.map +1 -0
- package/dist/env.d.ts +48 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +2 -0
- package/dist/env.js.map +1 -0
- package/dist/federation/actor.d.ts +55 -0
- package/dist/federation/actor.d.ts.map +1 -0
- package/dist/federation/actor.js +101 -0
- package/dist/federation/actor.js.map +1 -0
- package/dist/federation/article.d.ts +83 -0
- package/dist/federation/article.d.ts.map +1 -0
- package/dist/federation/article.js +169 -0
- package/dist/federation/article.js.map +1 -0
- package/dist/federation/delivery.d.ts +90 -0
- package/dist/federation/delivery.d.ts.map +1 -0
- package/dist/federation/delivery.js +289 -0
- package/dist/federation/delivery.js.map +1 -0
- package/dist/federation/federation.d.ts +75 -0
- package/dist/federation/federation.d.ts.map +1 -0
- package/dist/federation/federation.js +190 -0
- package/dist/federation/federation.js.map +1 -0
- package/dist/federation/followers.d.ts +43 -0
- package/dist/federation/followers.d.ts.map +1 -0
- package/dist/federation/followers.js +69 -0
- package/dist/federation/followers.js.map +1 -0
- package/dist/federation/inbox.d.ts +68 -0
- package/dist/federation/inbox.d.ts.map +1 -0
- package/dist/federation/inbox.js +171 -0
- package/dist/federation/inbox.js.map +1 -0
- package/dist/federation/index.d.ts +14 -0
- package/dist/federation/index.d.ts.map +1 -0
- package/dist/federation/index.js +10 -0
- package/dist/federation/index.js.map +1 -0
- package/dist/federation/keys.d.ts +27 -0
- package/dist/federation/keys.d.ts.map +1 -0
- package/dist/federation/keys.js +60 -0
- package/dist/federation/keys.js.map +1 -0
- package/dist/federation/mount.d.ts +23 -0
- package/dist/federation/mount.d.ts.map +1 -0
- package/dist/federation/mount.js +71 -0
- package/dist/federation/mount.js.map +1 -0
- package/dist/federation/paths.d.ts +85 -0
- package/dist/federation/paths.d.ts.map +1 -0
- package/dist/federation/paths.js +97 -0
- package/dist/federation/paths.js.map +1 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +71 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +125 -0
- package/dist/init.js.map +1 -0
- package/dist/web/assets.d.ts +65 -0
- package/dist/web/assets.d.ts.map +1 -0
- package/dist/web/assets.js +152 -0
- package/dist/web/assets.js.map +1 -0
- package/dist/web/context.d.ts +121 -0
- package/dist/web/context.d.ts.map +1 -0
- package/dist/web/context.js +112 -0
- package/dist/web/context.js.map +1 -0
- package/dist/web/documents.d.ts +28 -0
- package/dist/web/documents.d.ts.map +1 -0
- package/dist/web/documents.js +39 -0
- package/dist/web/documents.js.map +1 -0
- package/dist/web/feeds.d.ts +122 -0
- package/dist/web/feeds.d.ts.map +1 -0
- package/dist/web/feeds.js +229 -0
- package/dist/web/feeds.js.map +1 -0
- package/dist/web/index.d.ts +17 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +10 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/negotiate.d.ts +219 -0
- package/dist/web/negotiate.d.ts.map +1 -0
- package/dist/web/negotiate.js +409 -0
- package/dist/web/negotiate.js.map +1 -0
- package/dist/web/pagination.d.ts +48 -0
- package/dist/web/pagination.d.ts.map +1 -0
- package/dist/web/pagination.js +30 -0
- package/dist/web/pagination.js.map +1 -0
- package/dist/web/render.d.ts +72 -0
- package/dist/web/render.d.ts.map +1 -0
- package/dist/web/render.js +73 -0
- package/dist/web/render.js.map +1 -0
- package/dist/web/routes.d.ts +31 -0
- package/dist/web/routes.d.ts.map +1 -0
- package/dist/web/routes.js +366 -0
- package/dist/web/routes.js.map +1 -0
- package/dist/web/templates.d.ts +34 -0
- package/dist/web/templates.d.ts.map +1 -0
- package/dist/web/templates.js +106 -0
- package/dist/web/templates.js.map +1 -0
- package/package.json +68 -0
- package/templates/site/content/_data/site.json +8 -0
- package/templates/site/content/pages/about.md +11 -0
- package/templates/site/content/pages/pages.json +3 -0
- package/templates/site/content/posts/2026-01-01-hello-world.md +34 -0
- package/templates/site/content/posts/posts.json +4 -0
- package/templates/site/geekity.config.ts +11 -0
- package/templates/site/gitignore +3 -0
- package/templates/site/server.ts +20 -0
- package/templates/site/tsconfig.json +18 -0
- package/themes/default/README.md +148 -0
- package/themes/default/layouts/404.njk +9 -0
- package/themes/default/layouts/base.njk +59 -0
- package/themes/default/layouts/home.njk +9 -0
- package/themes/default/layouts/page.njk +13 -0
- package/themes/default/layouts/post.njk +30 -0
- package/themes/default/layouts/tag.njk +19 -0
- package/themes/default/partials/pagination.njk +14 -0
- package/themes/default/partials/post-list.njk +24 -0
- package/themes/default/partials/tags.njk +12 -0
- package/themes/default/static/style.css +327 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
3
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
4
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
5
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
};
|
|
10
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { createInterface } from 'node:readline';
|
|
14
|
+
import { Writable } from 'node:stream';
|
|
15
|
+
import { pathToFileURL } from 'node:url';
|
|
16
|
+
import { credentialProblem } from './admin/credentials.js';
|
|
17
|
+
import { DuplicateUsernameError, openAdminStore } from './admin/store.js';
|
|
18
|
+
import { resolveConfig } from './config.js';
|
|
19
|
+
import { createCms } from './index.js';
|
|
20
|
+
import { initSite, ownManifest } from './init.js';
|
|
21
|
+
/** The commands a site can name on the command line, as opposed to the flags. */
|
|
22
|
+
const COMMANDS = ['serve', 'init', 'sync', 'user'];
|
|
23
|
+
const CONFIG_FILENAMES = ['geekity.config.ts', 'geekity.config.js', 'geekity.config.mjs'];
|
|
24
|
+
const USAGE = `geekity — the Geekity CMS command line
|
|
25
|
+
|
|
26
|
+
Usage:
|
|
27
|
+
geekity [serve] [--config <file>]
|
|
28
|
+
geekity init <directory>
|
|
29
|
+
geekity sync [--config <file>]
|
|
30
|
+
geekity user add <username> [--password <pw>] [--config <file>]
|
|
31
|
+
|
|
32
|
+
Commands:
|
|
33
|
+
serve Start the CMS (the default when no command is given).
|
|
34
|
+
init Create a new site in <directory>.
|
|
35
|
+
sync Rebuild the content index once and exit.
|
|
36
|
+
user add Create an admin user, so a site can get its first login
|
|
37
|
+
without the setup screen.
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
--config <file> Config file to load. Defaults to the first of
|
|
41
|
+
${CONFIG_FILENAMES.join(', ')} found in the working directory.
|
|
42
|
+
--password <pw> The new user's password. Left off, it is asked for without
|
|
43
|
+
echo, or read as one line when standard input is a pipe.
|
|
44
|
+
A password on the command line is visible in the process
|
|
45
|
+
list and in shell history, so prefer being asked.
|
|
46
|
+
-h, --help Show this help.
|
|
47
|
+
-v, --version Show the installed version.
|
|
48
|
+
|
|
49
|
+
Environment overrides:
|
|
50
|
+
GEEKITY_PORT (or PORT), GEEKITY_CONTENT_DIR, GEEKITY_DATA_DIR,
|
|
51
|
+
GEEKITY_THEME_DIR, GEEKITY_BASE_URL, GEEKITY_WATCH
|
|
52
|
+
`;
|
|
53
|
+
/** Turn `process.argv.slice(2)` into a command, its options and its arguments. */
|
|
54
|
+
export function parseArgs(argv) {
|
|
55
|
+
let command;
|
|
56
|
+
let configPath;
|
|
57
|
+
let password;
|
|
58
|
+
const args = [];
|
|
59
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
60
|
+
const arg = argv[i];
|
|
61
|
+
if (arg === '--help' || arg === '-h')
|
|
62
|
+
return { command: 'help', configPath, password, args };
|
|
63
|
+
if (arg === '--version' || arg === '-v') {
|
|
64
|
+
return { command: 'version', configPath, password, args };
|
|
65
|
+
}
|
|
66
|
+
if (arg === '--config') {
|
|
67
|
+
const value = argv[i + 1];
|
|
68
|
+
if (value === undefined || value.startsWith('-')) {
|
|
69
|
+
throw new Error('--config needs a file path, for example --config geekity.config.ts');
|
|
70
|
+
}
|
|
71
|
+
configPath = value;
|
|
72
|
+
i += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (arg.startsWith('--config=')) {
|
|
76
|
+
const value = arg.slice('--config='.length);
|
|
77
|
+
if (value === '') {
|
|
78
|
+
throw new Error('--config needs a file path, for example --config geekity.config.ts');
|
|
79
|
+
}
|
|
80
|
+
configPath = value;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Unlike --config, the value after --password is taken as given: a
|
|
84
|
+
// password may legitimately start with a dash, and `--password=` with
|
|
85
|
+
// nothing after it is refused by the password rules, which say why.
|
|
86
|
+
if (arg === '--password') {
|
|
87
|
+
const value = argv[i + 1];
|
|
88
|
+
if (value === undefined) {
|
|
89
|
+
throw new Error('--password needs a value, or leave it off to be asked for one.');
|
|
90
|
+
}
|
|
91
|
+
password = value;
|
|
92
|
+
i += 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (arg.startsWith('--password=')) {
|
|
96
|
+
password = arg.slice('--password='.length);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// The first bare word is the command; everything bare after it belongs to
|
|
100
|
+
// that command, so `geekity user add ada` reaches `user` with `add ada`.
|
|
101
|
+
if (command === undefined) {
|
|
102
|
+
if (!isCommand(arg)) {
|
|
103
|
+
throw new Error(`Unknown command "${arg}". Run geekity --help to see what is available.`);
|
|
104
|
+
}
|
|
105
|
+
command = arg;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
args.push(arg);
|
|
109
|
+
}
|
|
110
|
+
return { command: command ?? 'serve', configPath, password, args };
|
|
111
|
+
}
|
|
112
|
+
function isCommand(value) {
|
|
113
|
+
return COMMANDS.includes(value);
|
|
114
|
+
}
|
|
115
|
+
/** Extensions that need TypeScript support in the loader. */
|
|
116
|
+
const TYPESCRIPT_EXTENSIONS = new Set(['.ts', '.mts', '.cts']);
|
|
117
|
+
/**
|
|
118
|
+
* Load a config module, returning `{}` when the site has no config file.
|
|
119
|
+
*
|
|
120
|
+
* A TypeScript config is imported directly first. That is all it takes on Node
|
|
121
|
+
* 24, which strips types without a flag, and inside this repository, where
|
|
122
|
+
* the CLI already runs under tsx. A Node started with stripping disabled — and
|
|
123
|
+
* any file carrying TypeScript syntax that stripping cannot erase — falls back to
|
|
124
|
+
* registering tsx from the *site's* own dependencies, which is where a site
|
|
125
|
+
* scaffolded by `geekity init` has it. A site with neither writes
|
|
126
|
+
* `geekity.config.js` instead; it is in the candidate list for exactly that.
|
|
127
|
+
*/
|
|
128
|
+
export async function loadConfig(cwd, configPath) {
|
|
129
|
+
const candidates = configPath === undefined
|
|
130
|
+
? CONFIG_FILENAMES.map((name) => path.resolve(cwd, name))
|
|
131
|
+
: [path.resolve(cwd, configPath)];
|
|
132
|
+
for (const candidate of candidates) {
|
|
133
|
+
const href = pathToFileURL(candidate).href;
|
|
134
|
+
let module;
|
|
135
|
+
try {
|
|
136
|
+
module = (await import(__rewriteRelativeImportExtension(href)));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (isModuleNotFound(error, candidate))
|
|
140
|
+
continue;
|
|
141
|
+
if (!needsTypeScriptLoader(error, candidate))
|
|
142
|
+
throw error;
|
|
143
|
+
await registerTypeScriptLoader(cwd, candidate);
|
|
144
|
+
module = (await import(__rewriteRelativeImportExtension(href)));
|
|
145
|
+
}
|
|
146
|
+
return module.default ?? {};
|
|
147
|
+
}
|
|
148
|
+
if (configPath !== undefined) {
|
|
149
|
+
throw new Error(`Config file not found: ${path.resolve(cwd, configPath)}`);
|
|
150
|
+
}
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The site's own tsx, as the directory the package was installed into, or
|
|
155
|
+
* `undefined` when the site does not have one.
|
|
156
|
+
*
|
|
157
|
+
* Node's resolver is deliberately not asked: this has to be the tsx the *site*
|
|
158
|
+
* installed, and a resolver anchored anywhere else — or patched by a tsx that
|
|
159
|
+
* is already loaded, which is what happens inside this repository — would
|
|
160
|
+
* happily answer with somebody else's copy.
|
|
161
|
+
*/
|
|
162
|
+
export function findSiteTsx(cwd) {
|
|
163
|
+
let directory = path.resolve(cwd);
|
|
164
|
+
for (;;) {
|
|
165
|
+
const candidate = path.join(directory, 'node_modules', 'tsx');
|
|
166
|
+
if (existsSync(path.join(candidate, 'package.json')))
|
|
167
|
+
return candidate;
|
|
168
|
+
const parent = path.dirname(directory);
|
|
169
|
+
if (parent === directory)
|
|
170
|
+
return undefined;
|
|
171
|
+
directory = parent;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Teach this process to import TypeScript, using the tsx installed alongside
|
|
176
|
+
* the site.
|
|
177
|
+
*
|
|
178
|
+
* tsx is the site's rather than this package's because the CMS does not depend
|
|
179
|
+
* on it at runtime: a site that runs `server.ts` already has it, and a site
|
|
180
|
+
* that does not want it writes its config in JavaScript instead.
|
|
181
|
+
*/
|
|
182
|
+
export async function registerTypeScriptLoader(cwd, configFile) {
|
|
183
|
+
const tsx = findSiteTsx(cwd);
|
|
184
|
+
if (tsx === undefined) {
|
|
185
|
+
throw new Error(`Could not load ${configFile}: this Node cannot import TypeScript on its own and tsx is ` +
|
|
186
|
+
'not installed in this site. Either add it (pnpm add -D tsx), or write the config as ' +
|
|
187
|
+
'geekity.config.js instead.');
|
|
188
|
+
}
|
|
189
|
+
const fromTsx = createRequire(path.join(tsx, 'package.json'));
|
|
190
|
+
const api = (await import(__rewriteRelativeImportExtension(pathToFileURL(fromTsx.resolve('tsx/esm/api')).href)));
|
|
191
|
+
api.register();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Whether an import failed because the loader could not handle TypeScript.
|
|
195
|
+
*
|
|
196
|
+
* `ERR_UNKNOWN_FILE_EXTENSION` is Node before type stripping was on by
|
|
197
|
+
* default; `ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX` is a file using `enum` or
|
|
198
|
+
* `namespace`, which stripping refuses because erasing it is not enough.
|
|
199
|
+
*/
|
|
200
|
+
function needsTypeScriptLoader(error, candidate) {
|
|
201
|
+
if (!TYPESCRIPT_EXTENSIONS.has(path.extname(candidate).toLowerCase()))
|
|
202
|
+
return false;
|
|
203
|
+
const code = error?.code;
|
|
204
|
+
return code === 'ERR_UNKNOWN_FILE_EXTENSION' || code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX';
|
|
205
|
+
}
|
|
206
|
+
function isModuleNotFound(error, candidate) {
|
|
207
|
+
return (typeof error === 'object' &&
|
|
208
|
+
error !== null &&
|
|
209
|
+
'code' in error &&
|
|
210
|
+
error.code === 'ERR_MODULE_NOT_FOUND' &&
|
|
211
|
+
String(error.message ?? '').includes(candidate));
|
|
212
|
+
}
|
|
213
|
+
/** Run one command. Resolves with the exit code the process should use. */
|
|
214
|
+
async function main(argv) {
|
|
215
|
+
const { command, configPath, password, args } = parseArgs(argv);
|
|
216
|
+
if (command === 'help') {
|
|
217
|
+
process.stdout.write(USAGE);
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
if (command === 'version') {
|
|
221
|
+
process.stdout.write(`${ownManifest().version}\n`);
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
if (command === 'init')
|
|
225
|
+
return init(args);
|
|
226
|
+
if (command === 'user')
|
|
227
|
+
return userCommand(args, configPath, password);
|
|
228
|
+
if (command === 'sync')
|
|
229
|
+
return syncCommand(configPath);
|
|
230
|
+
return serveCommand(configPath);
|
|
231
|
+
}
|
|
232
|
+
/** `geekity init <directory>`: scaffold a new site. */
|
|
233
|
+
async function init(args) {
|
|
234
|
+
const directory = args[0];
|
|
235
|
+
if (directory === undefined) {
|
|
236
|
+
throw new Error('geekity init <directory> needs the directory to create.');
|
|
237
|
+
}
|
|
238
|
+
const site = await initSite({ directory, cwd: process.cwd() });
|
|
239
|
+
const relative = path.relative(process.cwd(), site.directory) || '.';
|
|
240
|
+
process.stdout.write([
|
|
241
|
+
`Created ${site.directory}`,
|
|
242
|
+
'',
|
|
243
|
+
'Next:',
|
|
244
|
+
` cd ${relative}`,
|
|
245
|
+
' pnpm install',
|
|
246
|
+
' pnpm dev',
|
|
247
|
+
'',
|
|
248
|
+
].join('\n'));
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* `geekity sync`: bring the index into line with the files once and stop.
|
|
253
|
+
*
|
|
254
|
+
* Watching is forced off whatever the config says, because a one-shot scan
|
|
255
|
+
* that then sat in a watcher would never exit.
|
|
256
|
+
*/
|
|
257
|
+
async function syncCommand(configPath) {
|
|
258
|
+
const config = await loadConfig(process.cwd(), configPath);
|
|
259
|
+
const cms = createCms({ ...config, watch: false });
|
|
260
|
+
try {
|
|
261
|
+
const result = await cms.sync();
|
|
262
|
+
process.stdout.write(`Scanned ${String(result.scanned)}: ${String(result.created)} created, ` +
|
|
263
|
+
`${String(result.updated)} updated, ${String(result.removed)} removed, ` +
|
|
264
|
+
`${String(result.unchanged)} unchanged, ${String(result.failed)} failed\n`);
|
|
265
|
+
if (result.failed > 0) {
|
|
266
|
+
process.stderr.write(`${String(result.failed)} file${result.failed === 1 ? '' : 's'} could not be parsed and ` +
|
|
267
|
+
`${result.failed === 1 ? 'was' : 'were'} left out of the index; the warnings above name ` +
|
|
268
|
+
`${result.failed === 1 ? 'it' : 'them'}.\n`);
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
await cms.close();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/** `geekity serve`: the default. Runs until it is signalled. */
|
|
278
|
+
async function serveCommand(configPath) {
|
|
279
|
+
const cms = createCms(await loadConfig(process.cwd(), configPath));
|
|
280
|
+
const { port } = await cms.serve();
|
|
281
|
+
process.stdout.write(`Geekity is serving ${cms.config.baseUrl} on port ${String(port)}\n`);
|
|
282
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
283
|
+
process.once(signal, () => {
|
|
284
|
+
void cms.close().then(() => process.exit(0));
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* `geekity user add <username>`: create an admin without the setup screen.
|
|
291
|
+
*
|
|
292
|
+
* The other door into the users table is the first-run setup form, and this
|
|
293
|
+
* one has to leave the same thing behind it, so both go through
|
|
294
|
+
* {@link credentialProblem} rather than each carrying its own idea of a legal
|
|
295
|
+
* username. The store is opened against the config's `dataDir`, which is the
|
|
296
|
+
* same file the server will read, and it is closed whatever happens.
|
|
297
|
+
*/
|
|
298
|
+
async function userCommand(args, configPath, flagPassword) {
|
|
299
|
+
const subcommand = args[0];
|
|
300
|
+
if (subcommand === undefined) {
|
|
301
|
+
throw new Error('geekity user add <username> needs a subcommand. The only one is: add.');
|
|
302
|
+
}
|
|
303
|
+
if (subcommand !== 'add') {
|
|
304
|
+
throw new Error(`Unknown user subcommand "${subcommand}". The only one is: add.`);
|
|
305
|
+
}
|
|
306
|
+
const username = args[1];
|
|
307
|
+
if (username === undefined) {
|
|
308
|
+
throw new Error('geekity user add <username> needs the name of the user to create.');
|
|
309
|
+
}
|
|
310
|
+
const password = flagPassword ?? (await readPassword({ prompt: `Password for ${username}: ` }));
|
|
311
|
+
const problem = credentialProblem(username, password);
|
|
312
|
+
if (problem !== undefined) {
|
|
313
|
+
process.stderr.write(`${problem}\n`);
|
|
314
|
+
return 1;
|
|
315
|
+
}
|
|
316
|
+
const config = resolveConfig(await loadConfig(process.cwd(), configPath));
|
|
317
|
+
const admin = openAdminStore({ dataDir: config.dataDir });
|
|
318
|
+
try {
|
|
319
|
+
const user = admin.createUser({ username, password });
|
|
320
|
+
process.stdout.write(`Created admin user ${user.username}. Sign in at ${LOGIN_URL}.\n`);
|
|
321
|
+
return 0;
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
if (error instanceof DuplicateUsernameError) {
|
|
325
|
+
process.stderr.write(`${error.message} Pick another name, or change that user's password from the admin.\n`);
|
|
326
|
+
return 1;
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
finally {
|
|
331
|
+
admin.close();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** Where the success line points a new admin. Relative, because the host is the site's. */
|
|
335
|
+
const LOGIN_URL = '/admin/login';
|
|
336
|
+
/**
|
|
337
|
+
* Ask for a password once, without putting it on the screen.
|
|
338
|
+
*
|
|
339
|
+
* Two things would otherwise echo it, and both are turned off: the terminal
|
|
340
|
+
* driver, silenced by putting the input into raw mode, and readline, whose
|
|
341
|
+
* output goes to a writable that keeps nothing. Readline happens to set raw
|
|
342
|
+
* mode itself, but it is set here as well rather than relied on: the day that
|
|
343
|
+
* changes, a password would be printed. Raw mode also means readline sees
|
|
344
|
+
* Ctrl-C as a byte rather than a signal, so it is turned back into a
|
|
345
|
+
* cancellation here.
|
|
346
|
+
*
|
|
347
|
+
* Off a terminal — a pipe, a heredoc, a CI job — nothing is printed and the
|
|
348
|
+
* first line is the password, which is what makes
|
|
349
|
+
* `printf '%s\n' "$PW" | geekity user add ada` work.
|
|
350
|
+
*/
|
|
351
|
+
export async function readPassword(options = {}) {
|
|
352
|
+
const input = options.input ?? process.stdin;
|
|
353
|
+
const output = options.output ?? process.stderr;
|
|
354
|
+
const terminal = input.isTTY === true;
|
|
355
|
+
if (terminal && options.prompt !== undefined)
|
|
356
|
+
output.write(options.prompt);
|
|
357
|
+
const wasRaw = input.isRaw === true;
|
|
358
|
+
if (terminal)
|
|
359
|
+
input.setRawMode?.(true);
|
|
360
|
+
const muted = new Writable({
|
|
361
|
+
write(_chunk, _encoding, callback) {
|
|
362
|
+
callback();
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
const reader = createInterface({ input, output: muted, terminal });
|
|
366
|
+
let cancelled = false;
|
|
367
|
+
reader.on('SIGINT', () => {
|
|
368
|
+
cancelled = true;
|
|
369
|
+
reader.close();
|
|
370
|
+
});
|
|
371
|
+
try {
|
|
372
|
+
for await (const line of reader) {
|
|
373
|
+
if (!cancelled)
|
|
374
|
+
return line;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
finally {
|
|
379
|
+
reader.close();
|
|
380
|
+
if (terminal) {
|
|
381
|
+
input.setRawMode?.(wasRaw);
|
|
382
|
+
// The terminal is left on the line the swallowed newline never printed.
|
|
383
|
+
output.write('\n');
|
|
384
|
+
}
|
|
385
|
+
input.pause();
|
|
386
|
+
}
|
|
387
|
+
if (cancelled)
|
|
388
|
+
throw new Error('Cancelled; no user was created.');
|
|
389
|
+
throw new Error('No password was given: standard input ended before a line arrived. Pass --password, or ' +
|
|
390
|
+
'pipe the password in as a single line.');
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* True when this module is the process entry point.
|
|
394
|
+
*
|
|
395
|
+
* The entry path is realpath'd first: package managers link a bin through
|
|
396
|
+
* `node_modules/.bin`, so `process.argv[1]` reaches this file through a symlink
|
|
397
|
+
* while `import.meta.url` is already resolved.
|
|
398
|
+
*/
|
|
399
|
+
function isEntryPoint() {
|
|
400
|
+
const entry = process.argv[1];
|
|
401
|
+
if (entry === undefined)
|
|
402
|
+
return false;
|
|
403
|
+
try {
|
|
404
|
+
return import.meta.url === pathToFileURL(realpathSync(entry)).href;
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (isEntryPoint()) {
|
|
411
|
+
main(process.argv.slice(2))
|
|
412
|
+
.then((code) => {
|
|
413
|
+
// `serve` resolves with 0 while the server is still listening; exiting
|
|
414
|
+
// here would kill it, so only a command that finished sets the code and
|
|
415
|
+
// lets the event loop empty on its own.
|
|
416
|
+
if (code !== 0)
|
|
417
|
+
process.exitCode = code;
|
|
418
|
+
})
|
|
419
|
+
.catch((error) => {
|
|
420
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
421
|
+
process.exit(1);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO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
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { KvStore, MessageQueue } from '@fedify/fedify';
|
|
2
|
+
import type { DocumentChange } from './content/sync.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Something a site wants to happen when the index changes.
|
|
5
|
+
*
|
|
6
|
+
* Whatever a hook returns is ignored, which is what the `unknown` return says:
|
|
7
|
+
* `void` would have a linter reject an `async` hook, and `void | Promise<void>`
|
|
8
|
+
* would have the compiler reject a one-expression hook like
|
|
9
|
+
* `(change) => queue.push(change)`. A hook may therefore be `async`, and a
|
|
10
|
+
* promise that rejects is caught and reported rather than left unhandled. The
|
|
11
|
+
* CMS never waits for a hook, so a slow or broken subscriber can neither delay
|
|
12
|
+
* nor wedge the watcher.
|
|
13
|
+
*/
|
|
14
|
+
export type DocumentChangeHook = (change: DocumentChange) => unknown;
|
|
15
|
+
/**
|
|
16
|
+
* The federation stores and guards a site may swap, which decision-5 promised
|
|
17
|
+
* would be configuration rather than a redesign.
|
|
18
|
+
*
|
|
19
|
+
* Everything here has a default that is right for a single-process personal
|
|
20
|
+
* blog; a site only names one when it has outgrown that, and a test names one
|
|
21
|
+
* when it needs the federation to behave predictably.
|
|
22
|
+
*/
|
|
23
|
+
export interface FederationOverrides {
|
|
24
|
+
/**
|
|
25
|
+
* Fedify's cache and idempotence store. Defaults to an in-memory one, per
|
|
26
|
+
* decision-5: nothing that has to survive a restart lives in it.
|
|
27
|
+
*/
|
|
28
|
+
kv?: KvStore | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The delivery and inbox queue. Defaults to Fedify's in-process one.
|
|
31
|
+
*
|
|
32
|
+
* `null` means no queue at all: an inbound activity is handled, and an
|
|
33
|
+
* outbound one delivered, before the request that carried it is answered.
|
|
34
|
+
* That is slower under load and has no retry, which is why it is not the
|
|
35
|
+
* default, but it is the only way to know from outside when the work is
|
|
36
|
+
* done — so it is what a test asks for.
|
|
37
|
+
*/
|
|
38
|
+
queue?: MessageQueue | null | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Whether Fedify's document loader may fetch private and loopback
|
|
41
|
+
* addresses. Off, as it must be in production: turning it on removes the
|
|
42
|
+
* guard that stops a hostile actor id from making the server fetch its own
|
|
43
|
+
* network. Tests that federate two make-believe hosts turn it on.
|
|
44
|
+
*/
|
|
45
|
+
allowPrivateAddress?: boolean | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What a site writes in `geekity.config.ts`. Every field is optional; see
|
|
49
|
+
* {@link DEFAULT_PORT} and friends for what each one falls back to.
|
|
50
|
+
*/
|
|
51
|
+
export interface GeekityConfig {
|
|
52
|
+
/** Port the HTTP server listens on. Default 3000. Overridden by `GEEKITY_PORT`, then `PORT`. */
|
|
53
|
+
port?: number;
|
|
54
|
+
/** Markdown content directory. Default `<cwd>/content`. Overridden by `GEEKITY_CONTENT_DIR`. */
|
|
55
|
+
contentDir?: string;
|
|
56
|
+
/** Directory for derived state such as the SQLite index. Default `<cwd>/data`. Overridden by `GEEKITY_DATA_DIR`. */
|
|
57
|
+
dataDir?: string;
|
|
58
|
+
/** Site template overrides, resolved before the packaged default theme. Default `<cwd>/theme`. Overridden by `GEEKITY_THEME_DIR`. */
|
|
59
|
+
themeDir?: string;
|
|
60
|
+
/** Public origin, used for canonical URLs, feeds and ActivityPub ids. Default `http://localhost:<port>`. Overridden by `GEEKITY_BASE_URL`. */
|
|
61
|
+
baseUrl?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Watch the content directory and keep the index in step with it while the
|
|
64
|
+
* server runs. Default `true`. Turn it off for a one-shot sync or a host
|
|
65
|
+
* whose content cannot change under the process. Overridden by `GEEKITY_WATCH`.
|
|
66
|
+
*/
|
|
67
|
+
watch?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* How long an admin login lasts, in seconds. Default 14 days. Overridden by
|
|
70
|
+
* `GEEKITY_SESSION_LIFETIME`. The clock starts when the session is created,
|
|
71
|
+
* and an expired session is deleted rather than merely ignored.
|
|
72
|
+
*/
|
|
73
|
+
sessionLifetime?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Largest file the editor's upload endpoint accepts, in bytes. Default 10
|
|
76
|
+
* MiB. Overridden by `GEEKITY_UPLOAD_MAX_BYTES`.
|
|
77
|
+
*/
|
|
78
|
+
uploadMaxBytes?: number;
|
|
79
|
+
/**
|
|
80
|
+
* File extensions the upload endpoint accepts, with or without the leading
|
|
81
|
+
* dot and in any case. Default: PNG, JPEG, GIF, WebP, AVIF, PDF, plain text
|
|
82
|
+
* and Markdown. Overridden by `GEEKITY_UPLOAD_TYPES`, a comma-separated
|
|
83
|
+
* list. Every entry has to be one the CMS knows a media type for; see
|
|
84
|
+
* `KNOWN_UPLOAD_TYPES`.
|
|
85
|
+
*/
|
|
86
|
+
uploadTypes?: string[];
|
|
87
|
+
/**
|
|
88
|
+
* Called for every `created`, `updated` and `deleted` the index records.
|
|
89
|
+
*
|
|
90
|
+
* The boot scan reports a cold index as a directory full of creations, so a
|
|
91
|
+
* hook that must not re-fire on a rebuilt index should check
|
|
92
|
+
* `change.origin !== 'scan'`.
|
|
93
|
+
*/
|
|
94
|
+
onDocumentChange?: DocumentChangeHook;
|
|
95
|
+
/**
|
|
96
|
+
* Called when a document becomes visible on the public site: created live, a
|
|
97
|
+
* draft published, or a document restored from the trash. Subject to the
|
|
98
|
+
* same `origin` caveat as {@link GeekityConfig.onDocumentChange}.
|
|
99
|
+
*/
|
|
100
|
+
onPublish?: DocumentChangeHook;
|
|
101
|
+
/**
|
|
102
|
+
* Federation stores and guards. Every field has a default; see
|
|
103
|
+
* {@link FederationOverrides}.
|
|
104
|
+
*/
|
|
105
|
+
federation?: FederationOverrides;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A {@link GeekityConfig} with every field filled in and every path absolute.
|
|
109
|
+
*
|
|
110
|
+
* The two hooks are the exception to "filled in": they have no default, so
|
|
111
|
+
* they are present and `undefined` when the site named neither.
|
|
112
|
+
*/
|
|
113
|
+
export interface ResolvedConfig {
|
|
114
|
+
port: number;
|
|
115
|
+
contentDir: string;
|
|
116
|
+
dataDir: string;
|
|
117
|
+
themeDir: string;
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
/**
|
|
120
|
+
* Where {@link ResolvedConfig.baseUrl} came from.
|
|
121
|
+
*
|
|
122
|
+
* `default` means nobody named one and it is the `http://localhost:<port>`
|
|
123
|
+
* fallback, which is what lets the admin's settings screen offer a base URL
|
|
124
|
+
* of its own: an `environment` or `config` value is a deployment fact and
|
|
125
|
+
* wins over anything stored in SQLite.
|
|
126
|
+
*/
|
|
127
|
+
baseUrlSource: 'environment' | 'config' | 'default';
|
|
128
|
+
watch: boolean;
|
|
129
|
+
sessionLifetime: number;
|
|
130
|
+
uploadMaxBytes: number;
|
|
131
|
+
/** Normalised: lower case, each with its leading dot. */
|
|
132
|
+
uploadTypes: string[];
|
|
133
|
+
onDocumentChange: DocumentChangeHook | undefined;
|
|
134
|
+
onPublish: DocumentChangeHook | undefined;
|
|
135
|
+
/** Federation stores and guards, empty when the site named none. */
|
|
136
|
+
federation: FederationOverrides;
|
|
137
|
+
}
|
|
138
|
+
/** Ambient inputs {@link resolveConfig} reads, injectable so the resolution is testable. */
|
|
139
|
+
export interface ResolveConfigContext {
|
|
140
|
+
/** Directory relative paths resolve against. Defaults to `process.cwd()`. */
|
|
141
|
+
cwd?: string;
|
|
142
|
+
/** Environment to read overrides from. Defaults to `process.env`. */
|
|
143
|
+
env?: Record<string, string | undefined>;
|
|
144
|
+
}
|
|
145
|
+
export declare const DEFAULT_PORT = 3000;
|
|
146
|
+
export declare const DEFAULT_CONTENT_DIR = "content";
|
|
147
|
+
export declare const DEFAULT_DATA_DIR = "data";
|
|
148
|
+
export declare const DEFAULT_THEME_DIR = "theme";
|
|
149
|
+
/** How long an admin login lasts by default: fourteen days, in seconds. */
|
|
150
|
+
export declare const DEFAULT_SESSION_LIFETIME: number;
|
|
151
|
+
/** Largest upload a site accepts by default: ten mebibytes. */
|
|
152
|
+
export declare const DEFAULT_UPLOAD_MAX_BYTES: number;
|
|
153
|
+
/**
|
|
154
|
+
* What the editor may upload by default: the raster image formats a browser
|
|
155
|
+
* displays, PDFs, and the two text formats. Everything the CMS knows about
|
|
156
|
+
* except SVG, which is script-bearing markup served from the site's own origin
|
|
157
|
+
* and so is opt-in.
|
|
158
|
+
*/
|
|
159
|
+
export declare const DEFAULT_UPLOAD_TYPES: readonly string[];
|
|
160
|
+
/**
|
|
161
|
+
* Identity helper that gives a `geekity.config.ts` file type checking and
|
|
162
|
+
* completion without the site importing the type by hand.
|
|
163
|
+
*/
|
|
164
|
+
export declare function defineConfig(config: GeekityConfig): GeekityConfig;
|
|
165
|
+
/**
|
|
166
|
+
* Merge a site's config with environment overrides and defaults.
|
|
167
|
+
*
|
|
168
|
+
* Precedence is environment variable, then config file, then default. Relative
|
|
169
|
+
* directories resolve against `cwd`; absolute ones are left alone.
|
|
170
|
+
*/
|
|
171
|
+
export declare function resolveConfig(config?: GeekityConfig, context?: ResolveConfigContext): ResolvedConfig;
|
|
172
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,EAAE,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,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