@velocity-astro/cms-astro 0.0.0-stage → 0.1.0-beta.11
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 +12 -2
- package/bin/velocity-cms.mjs +6 -0
- package/dist/admin-files.d.ts +21 -0
- package/dist/admin-files.d.ts.map +1 -0
- package/dist/admin-files.js +83 -0
- package/dist/admin-files.js.map +1 -0
- package/dist/challenge.d.ts +35 -0
- package/dist/challenge.d.ts.map +1 -0
- package/dist/challenge.js +84 -0
- package/dist/challenge.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +76 -0
- package/dist/cli.js.map +1 -0
- package/dist/connection.d.ts +26 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +87 -0
- package/dist/connection.js.map +1 -0
- package/dist/editor.d.ts +67 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +194 -0
- package/dist/editor.js.map +1 -0
- package/dist/entry-page.d.ts +37 -0
- package/dist/entry-page.d.ts.map +1 -0
- package/dist/entry-page.js +56 -0
- package/dist/entry-page.js.map +1 -0
- package/dist/form-post.d.ts +114 -0
- package/dist/form-post.d.ts.map +1 -0
- package/dist/form-post.js +298 -0
- package/dist/form-post.js.map +1 -0
- package/dist/hosted.d.ts +76 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +104 -0
- package/dist/hosted.js.map +1 -0
- package/dist/image-optimizer.d.ts +35 -0
- package/dist/image-optimizer.d.ts.map +1 -0
- package/dist/image-optimizer.js +76 -0
- package/dist/image-optimizer.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +35 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +140 -0
- package/dist/init.js.map +1 -0
- package/dist/integration.d.ts +72 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +143 -0
- package/dist/integration.js.map +1 -0
- package/dist/link.d.ts +32 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +80 -0
- package/dist/link.js.map +1 -0
- package/dist/live-loader.d.ts +44 -0
- package/dist/live-loader.d.ts.map +1 -0
- package/dist/live-loader.js +98 -0
- package/dist/live-loader.js.map +1 -0
- package/dist/live-pages.d.ts +69 -0
- package/dist/live-pages.d.ts.map +1 -0
- package/dist/live-pages.js +94 -0
- package/dist/live-pages.js.map +1 -0
- package/dist/loader.d.ts +22 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +62 -0
- package/dist/loader.js.map +1 -0
- package/dist/media-store.d.ts +61 -0
- package/dist/media-store.d.ts.map +1 -0
- package/dist/media-store.js +178 -0
- package/dist/media-store.js.map +1 -0
- package/dist/menu.d.ts +51 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +81 -0
- package/dist/menu.js.map +1 -0
- package/dist/page-head.d.ts +23 -0
- package/dist/page-head.d.ts.map +1 -0
- package/dist/page-head.js +66 -0
- package/dist/page-head.js.map +1 -0
- package/dist/page-marks.d.ts +50 -0
- package/dist/page-marks.d.ts.map +1 -0
- package/dist/page-marks.js +90 -0
- package/dist/page-marks.js.map +1 -0
- package/dist/preview.d.ts +92 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +192 -0
- package/dist/preview.js.map +1 -0
- package/dist/resend-mailer.d.ts +63 -0
- package/dist/resend-mailer.d.ts.map +1 -0
- package/dist/resend-mailer.js +116 -0
- package/dist/resend-mailer.js.map +1 -0
- package/dist/secret.d.ts +8 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +17 -0
- package/dist/secret.js.map +1 -0
- package/dist/single.d.ts +18 -0
- package/dist/single.d.ts.map +1 -0
- package/dist/single.js +37 -0
- package/dist/single.js.map +1 -0
- package/dist/site-editor.d.ts +41 -0
- package/dist/site-editor.d.ts.map +1 -0
- package/dist/site-editor.js +140 -0
- package/dist/site-editor.js.map +1 -0
- package/dist/site-forms.d.ts +54 -0
- package/dist/site-forms.d.ts.map +1 -0
- package/dist/site-forms.js +100 -0
- package/dist/site-forms.js.map +1 -0
- package/dist/site-images.d.ts +17 -0
- package/dist/site-images.d.ts.map +1 -0
- package/dist/site-images.js +22 -0
- package/dist/site-images.js.map +1 -0
- package/dist/site-mail.d.ts +45 -0
- package/dist/site-mail.d.ts.map +1 -0
- package/dist/site-mail.js +84 -0
- package/dist/site-mail.js.map +1 -0
- package/dist/site-media.d.ts +22 -0
- package/dist/site-media.d.ts.map +1 -0
- package/dist/site-media.js +52 -0
- package/dist/site-media.js.map +1 -0
- package/dist/site-name.d.ts +9 -0
- package/dist/site-name.d.ts.map +1 -0
- package/dist/site-name.js +21 -0
- package/dist/site-name.js.map +1 -0
- package/dist/site-plugins.d.ts +10 -0
- package/dist/site-plugins.d.ts.map +1 -0
- package/dist/site-plugins.js +23 -0
- package/dist/site-plugins.js.map +1 -0
- package/dist/site-search.d.ts +12 -0
- package/dist/site-search.d.ts.map +1 -0
- package/dist/site-search.js +79 -0
- package/dist/site-search.js.map +1 -0
- package/dist/site-storage.d.ts +34 -0
- package/dist/site-storage.d.ts.map +1 -0
- package/dist/site-storage.js +118 -0
- package/dist/site-storage.js.map +1 -0
- package/package.json +56 -3
- package/routes/admin.ts +10 -0
- package/routes/api.ts +15 -0
- package/routes/auth.ts +10 -0
- package/routes/due.ts +12 -0
- package/routes/editor.ts +49 -0
- package/routes/form-client.js.ts +173 -0
- package/routes/media.ts +10 -0
- package/routes/pages.ts +13 -0
- package/routes/plugins.ts +10 -0
- package/routes/preview-client.js.ts +18 -0
- package/routes/published.ts +29 -0
- package/routes/schedule.ts +20 -0
- package/routes/search-client.js.ts +33 -0
- package/routes/search.json.ts +10 -0
- package/routes/share-image.png.ts +33 -0
- package/routes/sitemap-live.xml.ts +16 -0
- package/routes/sites.ts +11 -0
- package/routes/submit.ts +22 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { sharedConnection, type Connection, type ConnectionOptions } from './connection.js';
|
|
2
|
+
export { AdminFiles, type EditorPageConfig } from './admin-files.js';
|
|
3
|
+
export { EditorHost, LogMailer, type EditorHostOptions } from './editor.js';
|
|
4
|
+
export { default, type VelocityCmsOptions } from './integration.js';
|
|
5
|
+
export { ResendMailer, MailRefusedError, englishMailWords, mailerFromEnv, type MailWords, type ResendMailerOptions, type TestMail } from './resend-mailer.js';
|
|
6
|
+
export { SiteMail, type SiteMailOptions } from './site-mail.js';
|
|
7
|
+
export { SiteMediaStore, type SiteMediaStoreOptions } from './site-storage.js';
|
|
8
|
+
export { definePlugin, type PluginContext, type PluginDefinition } from '@velocity-astro/cms-core';
|
|
9
|
+
export { registerSitePlugins } from './site-plugins.js';
|
|
10
|
+
export { EditorNotSetUpError, editorOrigin, pagesOrigin, siteEditorHost, withEditor, type SiteEditorSettings } from './site-editor.js';
|
|
11
|
+
export { cmsLiveLoader, entryTag, invalidateLiveContent, liveContentVersion, typeTag, type CmsCollectionFilter, type CmsEntryFilter, type CmsLiveLoaderOptions, } from './live-loader.js';
|
|
12
|
+
export { isEditorPreview, isPreview } from './preview.js';
|
|
13
|
+
export { PREVIEW_BRIDGE_SCRIPT } from '@velocity-astro/cms-admin/page-bridge';
|
|
14
|
+
export { EDITOR_PREVIEW_VERSION } from './preview.js';
|
|
15
|
+
export { fieldMark, sectionMark, slotMark, type PageMark } from './page-marks.js';
|
|
16
|
+
export { pageHead, type DrawnPage } from './page-head.js';
|
|
17
|
+
export { entryPage, entryPageAddresses, type EntryPage, type EntryPageOptions } from './entry-page.js';
|
|
18
|
+
export { linkTo, type LinkTarget } from './link.js';
|
|
19
|
+
export { FORM_ABOUT_FIELD, FORM_CHALLENGE_KEY_FIELD, FORM_LOCALE_FIELD, FORM_PAGE_FIELD, FORM_TOKEN_FIELD, FORM_TRAP_FIELD, FormPosts, MemoryRateLimiter, aboutMark, englishFormPostWords, type FormPostWords, type FormPostsOptions, type NoticeMailer, type RateLimiter, type PostLimit, type SubmissionNotice, } from './form-post.js';
|
|
20
|
+
export { FORM_CHALLENGE_FIELD, SiteChallenge, TURNSTILE_HOST, TURNSTILE_SCRIPT, TURNSTILE_VERIFY, type ChallengeCheck, type SiteChallengeOptions } from './challenge.js';
|
|
21
|
+
export { FORM_SCRIPT, siteForm, siteFormPosts, type FormChoice, type SiteForm, type SiteFormOptions } from './site-forms.js';
|
|
22
|
+
export { menuLinks, type MenuColumn, type MenuLink, type MenuOptions } from './menu.js';
|
|
23
|
+
export { single } from './single.js';
|
|
24
|
+
export type { PageHead } from '@velocity-astro/cms-core';
|
|
25
|
+
export { cmsLoader, type CmsLoaderOptions } from './loader.js';
|
|
26
|
+
export { liveAddresses, liveCollections, matchLocalizedPage, matchParams, type LiveAddress, type PageModule, type PageSources, type StaticPath, } from './live-pages.js';
|
|
27
|
+
export { SharpImageOptimizer, type SharpImageOptimizerOptions } from './image-optimizer.js';
|
|
28
|
+
export { FolderMediaStore, S3MediaStore, StorageRefusedError, bucketFromEnv, folderFromEnv, mediaStoreFromEnv, type S3MediaStoreOptions } from './media-store.js';
|
|
29
|
+
export { hasSiteSecret } from './secret.js';
|
|
30
|
+
export { refreshUploadedImages, uploadedFile, uploadedImage } from './site-media.js';
|
|
31
|
+
export { folderImages, type ImageFile } from './site-images.js';
|
|
32
|
+
export { indexPages, indexSite, searchSite, toSearchDocument } from './site-search.js';
|
|
33
|
+
export { NoSiteError, currentSite, hostedRequest, inSite, isHosted, siteCacheTag, useSiteRegistry, type HostedSite, type SiteRegistry } from './hosted.js';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,C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,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAClK,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { sharedConnection } from './connection.js';
|
|
2
|
+
export { AdminFiles } from './admin-files.js';
|
|
3
|
+
export { EditorHost, LogMailer } from './editor.js';
|
|
4
|
+
export { default } from './integration.js';
|
|
5
|
+
export { ResendMailer, MailRefusedError, englishMailWords, mailerFromEnv } from './resend-mailer.js';
|
|
6
|
+
export { SiteMail } from './site-mail.js';
|
|
7
|
+
export { SiteMediaStore } from './site-storage.js';
|
|
8
|
+
// What a site's own plugin file needs, so it imports from the one package the site installed.
|
|
9
|
+
export { definePlugin } from '@velocity-astro/cms-core';
|
|
10
|
+
export { registerSitePlugins } from './site-plugins.js';
|
|
11
|
+
export { EditorNotSetUpError, editorOrigin, pagesOrigin, siteEditorHost, withEditor } from './site-editor.js';
|
|
12
|
+
export { cmsLiveLoader, entryTag, invalidateLiveContent, liveContentVersion, typeTag, } from './live-loader.js';
|
|
13
|
+
export { isEditorPreview, isPreview } from './preview.js';
|
|
14
|
+
export { PREVIEW_BRIDGE_SCRIPT } from '@velocity-astro/cms-admin/page-bridge';
|
|
15
|
+
export { EDITOR_PREVIEW_VERSION } from './preview.js';
|
|
16
|
+
export { fieldMark, sectionMark, slotMark } from './page-marks.js';
|
|
17
|
+
export { pageHead } from './page-head.js';
|
|
18
|
+
export { entryPage, entryPageAddresses } from './entry-page.js';
|
|
19
|
+
export { linkTo } from './link.js';
|
|
20
|
+
export { FORM_ABOUT_FIELD, FORM_CHALLENGE_KEY_FIELD, FORM_LOCALE_FIELD, FORM_PAGE_FIELD, FORM_TOKEN_FIELD, FORM_TRAP_FIELD, FormPosts, MemoryRateLimiter, aboutMark, englishFormPostWords, } from './form-post.js';
|
|
21
|
+
export { FORM_CHALLENGE_FIELD, SiteChallenge, TURNSTILE_HOST, TURNSTILE_SCRIPT, TURNSTILE_VERIFY } from './challenge.js';
|
|
22
|
+
export { FORM_SCRIPT, siteForm, siteFormPosts } from './site-forms.js';
|
|
23
|
+
export { menuLinks } from './menu.js';
|
|
24
|
+
export { single } from './single.js';
|
|
25
|
+
export { cmsLoader } from './loader.js';
|
|
26
|
+
export { liveAddresses, liveCollections, matchLocalizedPage, matchParams, } from './live-pages.js';
|
|
27
|
+
export { SharpImageOptimizer } from './image-optimizer.js';
|
|
28
|
+
export { FolderMediaStore, S3MediaStore, StorageRefusedError, bucketFromEnv, folderFromEnv, mediaStoreFromEnv } from './media-store.js';
|
|
29
|
+
export { hasSiteSecret } from './secret.js';
|
|
30
|
+
export { refreshUploadedImages, uploadedFile, uploadedImage } from './site-media.js';
|
|
31
|
+
export { folderImages } from './site-images.js';
|
|
32
|
+
export { indexPages, indexSite, searchSite, toSearchDocument } from './site-search.js';
|
|
33
|
+
export { NoSiteError, currentSite, hostedRequest, inSite, isHosted, siteCacheTag, useSiteRegistry } from './hosted.js';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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
export declare function runScript(dir: string, script: string): string;
|
|
3
|
+
export interface InitOptions {
|
|
4
|
+
/** The site's folder. */
|
|
5
|
+
readonly dir: string;
|
|
6
|
+
readonly print: (line: string) => void;
|
|
7
|
+
/** Makes the site's secret. Tests give their own. */
|
|
8
|
+
readonly secret?: () => string;
|
|
9
|
+
}
|
|
10
|
+
export interface InitResult {
|
|
11
|
+
readonly code: number;
|
|
12
|
+
/** The settings as they now are in `.env`, for whatever runs next in the same command. */
|
|
13
|
+
readonly env: Readonly<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/** The settings a `.env` file holds, by name. Quotes around a value are taken off. */
|
|
16
|
+
export declare function readEnvFile(text: string): Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* The config with the integration added, or `null` when it cannot be added with certainty. Only
|
|
19
|
+
* a config with one `integrations: [` list is changed; anything else is the person's to edit,
|
|
20
|
+
* with the two lines printed for them.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withIntegration(config: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Sets a site up for the CMS, in its folder: a secret and the database's place in `.env`, both
|
|
25
|
+
* kept out of git, and the integration in the Astro config. It can be run again: it adds only
|
|
26
|
+
* what is missing and never changes a value that is there.
|
|
27
|
+
*/
|
|
28
|
+
export declare function initSite({ dir, print, secret }: InitOptions): InitResult;
|
|
29
|
+
/**
|
|
30
|
+
* Reads the CMS's own settings from the site's `.env` files into the environment, where the CMS
|
|
31
|
+
* looks for them. Astro reads those files for the site's code but not for the server it runs
|
|
32
|
+
* while developing and building. A setting the environment already has is left as it is.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadCmsEnv(dir: string, mode: string, env?: Record<string, string | undefined>): void;
|
|
35
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAWA,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM7D;AAED,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB7D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAoD,EAAE,EAAE,WAAW,GAAG,UAAU,CA6DtH;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,IAAI,CASjH"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
const PACKAGE = '@velocity-astro/cms-astro';
|
|
5
|
+
const CONFIG_FILES = ['astro.config.mjs', 'astro.config.ts', 'astro.config.js', 'astro.config.mts'];
|
|
6
|
+
/** Where the database is kept unless the site says otherwise (see `connect`). */
|
|
7
|
+
const DATA_FOLDER = 'cms';
|
|
8
|
+
/** What the CMS writes in that folder: the database (with the files SQLite keeps beside it) and uploads. */
|
|
9
|
+
const KEPT_OUT = [`/${DATA_FOLDER}/data.db*`, `/${DATA_FOLDER}/media/`];
|
|
10
|
+
/** How this site's own scripts are run, from the lockfile its package manager left. */
|
|
11
|
+
export function runScript(dir, script) {
|
|
12
|
+
const has = (file) => fs.existsSync(path.join(dir, file));
|
|
13
|
+
if (has('pnpm-lock.yaml'))
|
|
14
|
+
return `pnpm ${script}`;
|
|
15
|
+
if (has('yarn.lock'))
|
|
16
|
+
return `yarn ${script}`;
|
|
17
|
+
if (has('bun.lock') || has('bun.lockb'))
|
|
18
|
+
return `bun run ${script}`;
|
|
19
|
+
return `npm run ${script}`;
|
|
20
|
+
}
|
|
21
|
+
/** The settings a `.env` file holds, by name. Quotes around a value are taken off. */
|
|
22
|
+
export function readEnvFile(text) {
|
|
23
|
+
const found = {};
|
|
24
|
+
for (const line of text.split(/\r?\n/)) {
|
|
25
|
+
const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/.exec(line);
|
|
26
|
+
if (!match || match[1] === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
found[match[1]] = (match[2] ?? '').replace(/^(['"])(.*)\1$/, '$2');
|
|
29
|
+
}
|
|
30
|
+
return found;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The config with the integration added, or `null` when it cannot be added with certainty. Only
|
|
34
|
+
* a config with one `integrations: [` list is changed; anything else is the person's to edit,
|
|
35
|
+
* with the two lines printed for them.
|
|
36
|
+
*/
|
|
37
|
+
export function withIntegration(config) {
|
|
38
|
+
const lists = config.match(/\bintegrations\s*:\s*\[/g) ?? [];
|
|
39
|
+
if (lists.length !== 1 || lists[0] === undefined)
|
|
40
|
+
return null;
|
|
41
|
+
const at = config.indexOf(lists[0]) + lists[0].length;
|
|
42
|
+
const rest = config.slice(at);
|
|
43
|
+
// An empty list takes the call alone; a list with something in it takes it first, with a comma.
|
|
44
|
+
const isEmpty = /^\s*\]/.test(rest);
|
|
45
|
+
// A list written over several lines takes a line of its own, set in as its neighbours are.
|
|
46
|
+
const lines = /^[ \t]*\r?\n([ \t]*)/.exec(rest);
|
|
47
|
+
const added = config.slice(0, at) + (isEmpty ? 'velocityCms()' : lines ? `\n${lines[1] ?? ''}velocityCms(),` : 'velocityCms(), ') + rest;
|
|
48
|
+
const imports = [...added.matchAll(/^import\s.*$/gm)];
|
|
49
|
+
const last = imports.at(-1);
|
|
50
|
+
const line = `import velocityCms from '${PACKAGE}';`;
|
|
51
|
+
if (!last || last.index === undefined)
|
|
52
|
+
return `${line}\n\n${added}`;
|
|
53
|
+
const end = last.index + last[0].length;
|
|
54
|
+
return `${added.slice(0, end)}\n${line}${added.slice(end)}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sets a site up for the CMS, in its folder: a secret and the database's place in `.env`, both
|
|
58
|
+
* kept out of git, and the integration in the Astro config. It can be run again: it adds only
|
|
59
|
+
* what is missing and never changes a value that is there.
|
|
60
|
+
*/
|
|
61
|
+
export function initSite({ dir, print, secret = () => randomBytes(32).toString('base64url') }) {
|
|
62
|
+
const at = (file) => path.join(dir, file);
|
|
63
|
+
const configFile = CONFIG_FILES.find((file) => fs.existsSync(at(file)));
|
|
64
|
+
if (!configFile) {
|
|
65
|
+
print(`There is no Astro site in this folder (no ${CONFIG_FILES[0]}). Run this in the site's own folder.`);
|
|
66
|
+
return { code: 1, env: {} };
|
|
67
|
+
}
|
|
68
|
+
// 1. The secret, in .env. A value that is there is never replaced: sessions and saved keys depend on it.
|
|
69
|
+
const envText = fs.existsSync(at('.env')) ? fs.readFileSync(at('.env'), 'utf8') : '';
|
|
70
|
+
const env = readEnvFile(envText);
|
|
71
|
+
const lines = [];
|
|
72
|
+
if (!env['VELOCITY_CMS_SECRET']) {
|
|
73
|
+
env['VELOCITY_CMS_SECRET'] = secret();
|
|
74
|
+
lines.push('# Signs sessions, preview links and the keys plugins save. Keep it out of git, and set the same name on your host.', `VELOCITY_CMS_SECRET=${env['VELOCITY_CMS_SECRET']}`);
|
|
75
|
+
}
|
|
76
|
+
if (!env['VELOCITY_CMS_ORIGIN']) {
|
|
77
|
+
env['VELOCITY_CMS_ORIGIN'] = 'http://localhost:4321';
|
|
78
|
+
lines.push("# The site's address on this computer. On your host, set it to the real one, such as https://example.com.", `VELOCITY_CMS_ORIGIN=${env['VELOCITY_CMS_ORIGIN']}`);
|
|
79
|
+
}
|
|
80
|
+
if (lines.length > 0) {
|
|
81
|
+
fs.writeFileSync(at('.env'), `${envText}${envText === '' || envText.endsWith('\n') ? '' : '\n'}${envText === '' ? '' : '\n'}${lines.join('\n')}\n`);
|
|
82
|
+
print('.env: added the settings the CMS needs.');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
print('.env: already has the settings the CMS needs.');
|
|
86
|
+
}
|
|
87
|
+
// 2. Neither the secret nor the database belongs in git.
|
|
88
|
+
const ignoreText = fs.existsSync(at('.gitignore')) ? fs.readFileSync(at('.gitignore'), 'utf8') : '';
|
|
89
|
+
const ignored = ignoreText.split(/\r?\n/).map((line) => line.trim());
|
|
90
|
+
// The database's folder is named from the top, so a `src/cms` of the site's own is still kept.
|
|
91
|
+
const bare = (entry) => entry.replace(/^\/|\/$/g, '');
|
|
92
|
+
// Only what the CMS writes there is left out: the site's own files in that folder (its model, its seed) are kept.
|
|
93
|
+
const whole = ignored.some((line) => bare(line) === DATA_FOLDER);
|
|
94
|
+
const missing = ['.env', ...(whole ? [] : KEPT_OUT)].filter((entry) => !ignored.some((line) => bare(line) === bare(entry)));
|
|
95
|
+
if (missing.length > 0) {
|
|
96
|
+
fs.writeFileSync(at('.gitignore'), `${ignoreText}${ignoreText === '' || ignoreText.endsWith('\n') ? '' : '\n'}${missing.join('\n')}\n`);
|
|
97
|
+
print(`.gitignore: now leaves out ${missing.join(' and ')}.`);
|
|
98
|
+
}
|
|
99
|
+
// 3. The integration.
|
|
100
|
+
const config = fs.readFileSync(at(configFile), 'utf8');
|
|
101
|
+
if (config.includes(PACKAGE)) {
|
|
102
|
+
print(`${configFile}: already has the CMS.`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const next = withIntegration(config);
|
|
106
|
+
if (next) {
|
|
107
|
+
fs.writeFileSync(at(configFile), next);
|
|
108
|
+
print(`${configFile}: added the CMS to integrations.`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
print(`${configFile}: add these two lines yourself, since the file is not laid out as expected:\n\n import velocityCms from '${PACKAGE}';\n integrations: [velocityCms()],\n`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const latest = fs.readFileSync(at(configFile), 'utf8');
|
|
115
|
+
if (!/\badapter\s*:/.test(latest)) {
|
|
116
|
+
print(`${configFile}: has no adapter yet. The editor and live pages run on a server, so add one for where the site will live, for example \`npx astro add node\`.`);
|
|
117
|
+
}
|
|
118
|
+
if (!/\bsite\s*:/.test(latest)) {
|
|
119
|
+
print(`${configFile}: has no \`site\` yet. Set it to the site's address before you deploy, so sign-in links lead there.`);
|
|
120
|
+
}
|
|
121
|
+
return { code: 0, env };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reads the CMS's own settings from the site's `.env` files into the environment, where the CMS
|
|
125
|
+
* looks for them. Astro reads those files for the site's code but not for the server it runs
|
|
126
|
+
* while developing and building. A setting the environment already has is left as it is.
|
|
127
|
+
*/
|
|
128
|
+
export function loadCmsEnv(dir, mode, env = process.env) {
|
|
129
|
+
// Later files are the more specific, so they are read first and win.
|
|
130
|
+
for (const file of [`.env.${mode}.local`, '.env.local', `.env.${mode}`, '.env']) {
|
|
131
|
+
const full = path.join(dir, file);
|
|
132
|
+
if (!fs.existsSync(full))
|
|
133
|
+
continue;
|
|
134
|
+
for (const [name, value] of Object.entries(readEnvFile(fs.readFileSync(full, 'utf8')))) {
|
|
135
|
+
if (name.startsWith('VELOCITY_CMS_') && !env[name])
|
|
136
|
+
env[name] = value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAC5C,MAAM,YAAY,GAAG,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AACpG,iFAAiF;AACjF,MAAM,WAAW,GAAG,KAAK,CAAC;AAC1B,4GAA4G;AAC5G,MAAM,QAAQ,GAAG,CAAC,IAAI,WAAW,WAAW,EAAE,IAAI,WAAW,SAAS,CAAC,CAAC;AAExE,uFAAuF;AACvF,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAc;IACnD,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,IAAI,GAAG,CAAC,gBAAgB,CAAC;QAAE,OAAO,QAAQ,MAAM,EAAE,CAAC;IACnD,IAAI,GAAG,CAAC,WAAW,CAAC;QAAE,OAAO,QAAQ,MAAM,EAAE,CAAC;IAC9C,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,MAAM,EAAE,CAAC;IACpE,OAAO,WAAW,MAAM,EAAE,CAAC;AAC7B,CAAC;AAgBD,sFAAsF;AACtF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,KAAK,GAA2B,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,EAAE,YAAY,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACvF,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { AstroIntegration } from 'astro';
|
|
2
|
+
export interface VelocityCmsOptions {
|
|
3
|
+
/** Addresses to leave out of the sitemap, such as search results: `['/search/', '/es/buscar/']`. */
|
|
4
|
+
readonly unlisted?: readonly string[];
|
|
5
|
+
/** The site's name, shown in the editor, in sign-in emails and in the passkey prompt. */
|
|
6
|
+
readonly siteName?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The file whose default export delivers sign-in links by email (a `Mailer`), from the
|
|
9
|
+
* project's root: `'./src/cms-mailer.ts'`. Without one, links are printed to the server's log.
|
|
10
|
+
*/
|
|
11
|
+
readonly mailer?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The folder of images that image fields choose from, from the project's root:
|
|
14
|
+
* `'./src/assets/photos'`. An image is called by its file name without the ending.
|
|
15
|
+
*/
|
|
16
|
+
readonly images?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The site's plugins, each a package name or a file from the project's root whose default
|
|
19
|
+
* export is a `definePlugin(...)`: `['@velocity-astro/cms-plugin-seo', './src/cms/ratings.ts']`.
|
|
20
|
+
* A plugin that cannot start is switched off and listed, with the reason, under Plugins in the editor.
|
|
21
|
+
*/
|
|
22
|
+
readonly plugins?: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* The content types whose entries are pages one route of the site draws, such as the pages
|
|
25
|
+
* people build in the editor: `['pages']`. Their addresses join the sitemap, search and share
|
|
26
|
+
* images, which otherwise know only the pages the site has files for.
|
|
27
|
+
*/
|
|
28
|
+
readonly entryPages?: readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* For a host that runs many sites from this one copy. The file whose default export is a
|
|
31
|
+
* `SiteRegistry`, from the project's root: `'./src/cms-sites.ts'`. It says which site a host
|
|
32
|
+
* name belongs to, with that site's own database, secret, address and uploads. A host name it
|
|
33
|
+
* does not know gets no site, and nothing is read from the `VELOCITY_CMS_*` settings of one
|
|
34
|
+
* site. Such a copy builds no page ahead of time: every page is drawn for the site that asked.
|
|
35
|
+
* A site of its own leaves this out.
|
|
36
|
+
*/
|
|
37
|
+
readonly sites?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The Velocity CMS integration. Add it to `integrations` in `astro.config.mjs`.
|
|
41
|
+
*
|
|
42
|
+
* It gives a site with live pages what the build used to make from finished pages, and the
|
|
43
|
+
* addresses that go with them:
|
|
44
|
+
*
|
|
45
|
+
* - `/sitemap-live.xml`: the live pages' share of the sitemap
|
|
46
|
+
* - `/og/<page>.png`: a share image for any live page, drawn on first use (on a Velocity site, which has the card drawing)
|
|
47
|
+
* - `/api/cms/search.json` and `/cms-search.js`: search from the CMS database
|
|
48
|
+
* - `/api/cms/submit/<form>` and `/cms-form.js`: where a form posts, and the script that sends it in place
|
|
49
|
+
* - `/api/cms/published`: where a publish is announced
|
|
50
|
+
* - `/media/<file>`: the images people upload in the editor
|
|
51
|
+
* - preview links, through a middleware
|
|
52
|
+
*
|
|
53
|
+
* And it switches the editor on:
|
|
54
|
+
*
|
|
55
|
+
* - `/admin`: the editor, whose image fields choose from the folder named by `images`
|
|
56
|
+
* - `/api/cms/*`: the API the editor calls
|
|
57
|
+
* - `/api/cms/auth/*`: sign-in with an email link or a passkey
|
|
58
|
+
*
|
|
59
|
+
* Uploads are kept in a folder beside a database that is a file, or in an S3-compatible bucket
|
|
60
|
+
* named by the `VELOCITY_CMS_S3_*` environment variables (see `mediaStoreFromEnv`). A host with
|
|
61
|
+
* neither takes no uploads, and image fields choose from the `images` folder alone.
|
|
62
|
+
*
|
|
63
|
+
* The editor needs `VELOCITY_CMS_SECRET` and the site's address (`site` in the Astro config).
|
|
64
|
+
* `npx velocity-cms init <email> <name>` sets both up in a new site and makes the first owner;
|
|
65
|
+
* `npx velocity-cms owner <email> <name>` makes the first owner alone.
|
|
66
|
+
*
|
|
67
|
+
* It also keeps this package out of the site's bundle. The package opens a SQLite database
|
|
68
|
+
* through a native module, which a bundler cannot carry. The routes above are the exception:
|
|
69
|
+
* they are compiled with the site, because they need to see the site's own pages.
|
|
70
|
+
*/
|
|
71
|
+
export default function velocityCms(options?: VelocityCmsOptions): AstroIntegration;
|
|
72
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAa9C,MAAM,WAAW,kBAAkB;IACjC,oGAAoG;IACpG,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,gBAAgB,CA4FtF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { loadCmsEnv } from './init.js';
|
|
5
|
+
const PACKAGE = '@velocity-astro/cms-astro';
|
|
6
|
+
const OPTIONS = 'virtual:velocity-cms/options';
|
|
7
|
+
const MAILER = 'virtual:velocity-cms/mailer';
|
|
8
|
+
const PLUGINS = 'virtual:velocity-cms/plugins';
|
|
9
|
+
const IMAGES = 'virtual:velocity-cms/images';
|
|
10
|
+
const SITES = 'virtual:velocity-cms/sites';
|
|
11
|
+
const IMAGE_FILES = '*.{jpg,jpeg,png,webp,avif,gif}';
|
|
12
|
+
const ADMIN_PATH = '/admin';
|
|
13
|
+
const route = (file) => fileURLToPath(new URL(`../routes/${file}`, import.meta.url));
|
|
14
|
+
/**
|
|
15
|
+
* The Velocity CMS integration. Add it to `integrations` in `astro.config.mjs`.
|
|
16
|
+
*
|
|
17
|
+
* It gives a site with live pages what the build used to make from finished pages, and the
|
|
18
|
+
* addresses that go with them:
|
|
19
|
+
*
|
|
20
|
+
* - `/sitemap-live.xml`: the live pages' share of the sitemap
|
|
21
|
+
* - `/og/<page>.png`: a share image for any live page, drawn on first use (on a Velocity site, which has the card drawing)
|
|
22
|
+
* - `/api/cms/search.json` and `/cms-search.js`: search from the CMS database
|
|
23
|
+
* - `/api/cms/submit/<form>` and `/cms-form.js`: where a form posts, and the script that sends it in place
|
|
24
|
+
* - `/api/cms/published`: where a publish is announced
|
|
25
|
+
* - `/media/<file>`: the images people upload in the editor
|
|
26
|
+
* - preview links, through a middleware
|
|
27
|
+
*
|
|
28
|
+
* And it switches the editor on:
|
|
29
|
+
*
|
|
30
|
+
* - `/admin`: the editor, whose image fields choose from the folder named by `images`
|
|
31
|
+
* - `/api/cms/*`: the API the editor calls
|
|
32
|
+
* - `/api/cms/auth/*`: sign-in with an email link or a passkey
|
|
33
|
+
*
|
|
34
|
+
* Uploads are kept in a folder beside a database that is a file, or in an S3-compatible bucket
|
|
35
|
+
* named by the `VELOCITY_CMS_S3_*` environment variables (see `mediaStoreFromEnv`). A host with
|
|
36
|
+
* neither takes no uploads, and image fields choose from the `images` folder alone.
|
|
37
|
+
*
|
|
38
|
+
* The editor needs `VELOCITY_CMS_SECRET` and the site's address (`site` in the Astro config).
|
|
39
|
+
* `npx velocity-cms init <email> <name>` sets both up in a new site and makes the first owner;
|
|
40
|
+
* `npx velocity-cms owner <email> <name>` makes the first owner alone.
|
|
41
|
+
*
|
|
42
|
+
* It also keeps this package out of the site's bundle. The package opens a SQLite database
|
|
43
|
+
* through a native module, which a bundler cannot carry. The routes above are the exception:
|
|
44
|
+
* they are compiled with the site, because they need to see the site's own pages.
|
|
45
|
+
*/
|
|
46
|
+
export default function velocityCms(options = {}) {
|
|
47
|
+
let clientDir = '';
|
|
48
|
+
let site;
|
|
49
|
+
let root = '';
|
|
50
|
+
return {
|
|
51
|
+
name: PACKAGE,
|
|
52
|
+
hooks: {
|
|
53
|
+
'astro:config:setup': ({ config, command, updateConfig, addMiddleware, injectRoute }) => {
|
|
54
|
+
root = fileURLToPath(config.root);
|
|
55
|
+
// The secret a person put in .env must reach the server that runs here, not only the site's code.
|
|
56
|
+
loadCmsEnv(root, command === 'dev' ? 'development' : 'production');
|
|
57
|
+
// The site a request is for is chosen before anything else looks at it.
|
|
58
|
+
if (options.sites)
|
|
59
|
+
addMiddleware({ entrypoint: route('sites.ts'), order: 'pre' });
|
|
60
|
+
addMiddleware({ entrypoint: `${PACKAGE}/middleware`, order: 'pre' });
|
|
61
|
+
// Entries set to go out at a time are looked for as pages are asked for.
|
|
62
|
+
addMiddleware({ entrypoint: route('due.ts'), order: 'pre' });
|
|
63
|
+
// Loaded with the server, so the plugins are known before the first request.
|
|
64
|
+
if ((options.plugins ?? []).length > 0)
|
|
65
|
+
addMiddleware({ entrypoint: route('plugins.ts'), order: 'pre' });
|
|
66
|
+
injectRoute({ pattern: '/sitemap-live.xml', entrypoint: route('sitemap-live.xml.ts') });
|
|
67
|
+
// Share images are drawn by Velocity's own card drawing. A site without it keeps its own.
|
|
68
|
+
if (fs.existsSync(path.join(root, 'integrations', 'og-images.mjs')))
|
|
69
|
+
injectRoute({ pattern: '/og/[...live].png', entrypoint: route('share-image.png.ts') });
|
|
70
|
+
injectRoute({ pattern: '/api/cms/search.json', entrypoint: route('search.json.ts') });
|
|
71
|
+
injectRoute({ pattern: '/api/cms/published', entrypoint: route('published.ts') });
|
|
72
|
+
injectRoute({ pattern: '/cms-search.js', entrypoint: route('search-client.js.ts') });
|
|
73
|
+
injectRoute({ pattern: '/cms-form.js', entrypoint: route('form-client.js.ts') });
|
|
74
|
+
injectRoute({ pattern: '/cms-preview.js', entrypoint: route('preview-client.js.ts') });
|
|
75
|
+
injectRoute({ pattern: '/media/[file]', entrypoint: route('media.ts') });
|
|
76
|
+
injectRoute({ pattern: '/api/cms/submit/[form]', entrypoint: route('submit.ts') });
|
|
77
|
+
injectRoute({ pattern: '/api/cms/schedule', entrypoint: route('schedule.ts') });
|
|
78
|
+
injectRoute({ pattern: '/api/cms/auth/[...path]', entrypoint: route('auth.ts') });
|
|
79
|
+
injectRoute({ pattern: '/api/cms/[...path]', entrypoint: route('api.ts') });
|
|
80
|
+
injectRoute({ pattern: `${ADMIN_PATH}/[...path]`, entrypoint: route('admin.ts') });
|
|
81
|
+
const external = { resolve: { external: [PACKAGE] } };
|
|
82
|
+
updateConfig({
|
|
83
|
+
vite: {
|
|
84
|
+
ssr: { external: [PACKAGE] },
|
|
85
|
+
// Astro builds prerendered pages in their own Vite environment, which does not read `ssr`.
|
|
86
|
+
environments: { ssr: external, prerender: external, astro: external },
|
|
87
|
+
plugins: [
|
|
88
|
+
{
|
|
89
|
+
name: 'velocity-cms:options',
|
|
90
|
+
resolveId: (id) => (id === OPTIONS || id === MAILER || id === IMAGES || id === PLUGINS || id === SITES ? `\0${id}` : undefined),
|
|
91
|
+
load: (id) => {
|
|
92
|
+
if (id === `\0${OPTIONS}`) {
|
|
93
|
+
const editor = { site, siteName: options.siteName ?? 'Velocity CMS', adminPath: ADMIN_PATH };
|
|
94
|
+
return `export default ${JSON.stringify({ unlisted: options.unlisted ?? [], entryPages: options.entryPages ?? [], clientDir, editor })};`;
|
|
95
|
+
}
|
|
96
|
+
if (id === `\0${MAILER}`) {
|
|
97
|
+
return options.mailer
|
|
98
|
+
? `export { default } from ${JSON.stringify(path.resolve(root, options.mailer))};`
|
|
99
|
+
: 'export default undefined;';
|
|
100
|
+
}
|
|
101
|
+
if (id === `\0${SITES}`) {
|
|
102
|
+
return `export { default } from ${JSON.stringify(path.resolve(root, options.sites ?? ''))};`;
|
|
103
|
+
}
|
|
104
|
+
if (id === `\0${PLUGINS}`) {
|
|
105
|
+
// A path is the project's own file; anything else is a package the site installed.
|
|
106
|
+
const from = (plugin) => (/^\.{0,2}\//.test(plugin) ? path.resolve(root, plugin) : plugin);
|
|
107
|
+
const names = (options.plugins ?? []).map((plugin, index) => `import plugin${index} from ${JSON.stringify(from(plugin))};`);
|
|
108
|
+
return [...names, `export default [${names.map((_, index) => `plugin${index}`).join(', ')}];`].join('\n');
|
|
109
|
+
}
|
|
110
|
+
if (id === `\0${IMAGES}`) {
|
|
111
|
+
if (!options.images)
|
|
112
|
+
return 'export default undefined;';
|
|
113
|
+
const folder = path.relative(root, path.resolve(root, options.images)).split(path.sep).join('/');
|
|
114
|
+
return [
|
|
115
|
+
"import { getImage } from 'astro:assets';",
|
|
116
|
+
`import { folderImages } from ${JSON.stringify(PACKAGE)};`,
|
|
117
|
+
`const files = import.meta.glob(${JSON.stringify(`/${folder}/${IMAGE_FILES}`)}, { eager: true, import: 'default' });`,
|
|
118
|
+
// A small copy for the editor, made by the site's own image service.
|
|
119
|
+
'export default folderImages(files, async (file) => (await getImage({ src: file, width: 480 })).src);',
|
|
120
|
+
].join('\n');
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
// A copy that runs many sites builds no page ahead of time. Such a page is built for no
|
|
130
|
+
// site and served to all of them, so one site's name, menu or post would be every site's.
|
|
131
|
+
// Every page is drawn when it is asked for, for the site whose host name asked.
|
|
132
|
+
'astro:route:setup': ({ route: page }) => {
|
|
133
|
+
if (options.sites)
|
|
134
|
+
page.prerender = false;
|
|
135
|
+
},
|
|
136
|
+
'astro:config:done': ({ config }) => {
|
|
137
|
+
clientDir = fileURLToPath(config.adapter ? config.build.client : config.outDir);
|
|
138
|
+
site = config.site;
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAC5C,MAAM,OAAO,GAAG,8BAA8B,CAAC;AAC/C,MAAM,MAAM,GAAG,6BAA6B,CAAC;AAC7C,MAAM,OAAO,GAAG,8BAA8B,CAAC;AAC/C,MAAM,MAAM,GAAG,6BAA6B,CAAC;AAC7C,MAAM,KAAK,GAAG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AM,CAAC,CAAC;gBAChF,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACrB,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Cms, type ContentTypeDef, type Entry } from '@velocity-astro/cms-core';
|
|
2
|
+
import type { DrawnPage } from './page-head.js';
|
|
3
|
+
/** The language of the pages at a type's `urlPattern`. */
|
|
4
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
5
|
+
/** Where a link leads, ready to be written into a page. */
|
|
6
|
+
export interface LinkTarget {
|
|
7
|
+
readonly href: string;
|
|
8
|
+
/** True when the link leaves the site. */
|
|
9
|
+
readonly external: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Every entry of a type. */
|
|
12
|
+
export declare function entriesOf(cms: Cms, type: ContentTypeDef): Promise<Entry[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Turns the values of `link` fields into addresses for pages in one language. A type's entries
|
|
15
|
+
* are read once however many links point there, so make one for a page and use it for every link.
|
|
16
|
+
* `preview` follows the versions being worked on.
|
|
17
|
+
*/
|
|
18
|
+
export declare function linkResolver(cms: Cms, locale: string, preview?: boolean): (link: unknown) => Promise<LinkTarget | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Where a `link` field's value leads, for the page being drawn:
|
|
21
|
+
*
|
|
22
|
+
* ```astro
|
|
23
|
+
* const button = await linkTo(Astro, buttonLink);
|
|
24
|
+
* {button && <a href={button.href}>{buttonLabel}</a>}
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* A link to an entry is that entry's address today, in the page's language. It answers with
|
|
28
|
+
* nothing when the entry is not published, the address is not one a site may link to, or
|
|
29
|
+
* anything goes wrong: a page is never lost over a button.
|
|
30
|
+
*/
|
|
31
|
+
export declare function linkTo(page: DrawnPage, link: unknown): Promise<LinkTarget | undefined>;
|
|
32
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,GAAG,EAAE,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE9G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,0DAA0D;AAC1D,eAAO,MAAM,cAAc,OAAO,CAAC;AAGnC,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAKD,6BAA6B;AAC7B,wBAAsB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAQhF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAuB1H;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAW5F"}
|