@lets-ship/site 0.0.0-stage → 1.0.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 +59 -2
- package/bin/ship-site.js +5 -0
- package/dist/badge/badge.d.ts +14 -0
- package/dist/badge/badge.d.ts.map +1 -0
- package/dist/badge/badge.js +16 -0
- package/dist/badge/badge.js.map +1 -0
- package/dist/blog/arrow.d.ts +6 -0
- package/dist/blog/arrow.d.ts.map +1 -0
- package/dist/blog/arrow.js +6 -0
- package/dist/blog/arrow.js.map +1 -0
- package/dist/blog/article-view.d.ts +20 -0
- package/dist/blog/article-view.d.ts.map +1 -0
- package/dist/blog/article-view.js +71 -0
- package/dist/blog/article-view.js.map +1 -0
- package/dist/blog/article.d.ts +72 -0
- package/dist/blog/article.d.ts.map +1 -0
- package/dist/blog/article.js +90 -0
- package/dist/blog/article.js.map +1 -0
- package/dist/blog/featured.d.ts +18 -0
- package/dist/blog/featured.d.ts.map +1 -0
- package/dist/blog/featured.js +19 -0
- package/dist/blog/featured.js.map +1 -0
- package/dist/blog/frontmatter.d.ts +155 -0
- package/dist/blog/frontmatter.d.ts.map +1 -0
- package/dist/blog/frontmatter.js +96 -0
- package/dist/blog/frontmatter.js.map +1 -0
- package/dist/blog/index-view.d.ts +21 -0
- package/dist/blog/index-view.d.ts.map +1 -0
- package/dist/blog/index-view.js +70 -0
- package/dist/blog/index-view.js.map +1 -0
- package/dist/blog/inline-markdown.d.ts +15 -0
- package/dist/blog/inline-markdown.d.ts.map +1 -0
- package/dist/blog/inline-markdown.js +44 -0
- package/dist/blog/inline-markdown.js.map +1 -0
- package/dist/blog/post-card.d.ts +37 -0
- package/dist/blog/post-card.d.ts.map +1 -0
- package/dist/blog/post-card.js +68 -0
- package/dist/blog/post-card.js.map +1 -0
- package/dist/blog/site.d.ts +57 -0
- package/dist/blog/site.d.ts.map +1 -0
- package/dist/blog/site.js +76 -0
- package/dist/blog/site.js.map +1 -0
- package/dist/blog/toc.d.ts +32 -0
- package/dist/blog/toc.d.ts.map +1 -0
- package/dist/blog/toc.js +46 -0
- package/dist/blog/toc.js.map +1 -0
- package/dist/config/context.d.ts +16 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +11 -0
- package/dist/config/context.js.map +1 -0
- package/dist/config/identity.d.ts +41 -0
- package/dist/config/identity.d.ts.map +1 -0
- package/dist/config/identity.js +28 -0
- package/dist/config/identity.js.map +1 -0
- package/dist/config/json-schema.d.ts +11 -0
- package/dist/config/json-schema.d.ts.map +1 -0
- package/dist/config/json-schema.js +14 -0
- package/dist/config/json-schema.js.map +1 -0
- package/dist/config/site-config.d.ts +145 -0
- package/dist/config/site-config.d.ts.map +1 -0
- package/dist/config/site-config.js +130 -0
- package/dist/config/site-config.js.map +1 -0
- package/dist/docs/page-view.d.ts +21 -0
- package/dist/docs/page-view.d.ts.map +1 -0
- package/dist/docs/page-view.js +27 -0
- package/dist/docs/page-view.js.map +1 -0
- package/dist/feeds/feeds.d.ts +33 -0
- package/dist/feeds/feeds.d.ts.map +1 -0
- package/dist/feeds/feeds.js +122 -0
- package/dist/feeds/feeds.js.map +1 -0
- package/dist/format/dates.d.ts +5 -0
- package/dist/format/dates.d.ts.map +1 -0
- package/dist/format/dates.js +17 -0
- package/dist/format/dates.js.map +1 -0
- package/dist/format/node-text.d.ts +7 -0
- package/dist/format/node-text.d.ts.map +1 -0
- package/dist/format/node-text.js +15 -0
- package/dist/format/node-text.js.map +1 -0
- package/dist/format/toc-depth.d.ts +11 -0
- package/dist/format/toc-depth.d.ts.map +1 -0
- package/dist/format/toc-depth.js +14 -0
- package/dist/format/toc-depth.js.map +1 -0
- package/dist/i18n/fumadocs-keys.d.ts +13 -0
- package/dist/i18n/fumadocs-keys.d.ts.map +1 -0
- package/dist/i18n/fumadocs-keys.js +136 -0
- package/dist/i18n/fumadocs-keys.js.map +1 -0
- package/dist/i18n/strings.d.ts +19 -0
- package/dist/i18n/strings.d.ts.map +1 -0
- package/dist/i18n/strings.js +59 -0
- package/dist/i18n/strings.js.map +1 -0
- package/dist/i18n/tables/de.d.ts +3 -0
- package/dist/i18n/tables/de.d.ts.map +1 -0
- package/dist/i18n/tables/de.js +82 -0
- package/dist/i18n/tables/de.js.map +1 -0
- package/dist/i18n/tables/en.d.ts +3 -0
- package/dist/i18n/tables/en.d.ts.map +1 -0
- package/dist/i18n/tables/en.js +25 -0
- package/dist/i18n/tables/en.js.map +1 -0
- package/dist/i18n/tables/es.d.ts +3 -0
- package/dist/i18n/tables/es.d.ts.map +1 -0
- package/dist/i18n/tables/es.js +82 -0
- package/dist/i18n/tables/es.js.map +1 -0
- package/dist/i18n/tables/fr.d.ts +3 -0
- package/dist/i18n/tables/fr.d.ts.map +1 -0
- package/dist/i18n/tables/fr.js +82 -0
- package/dist/i18n/tables/fr.js.map +1 -0
- package/dist/i18n/tables/nl.d.ts +3 -0
- package/dist/i18n/tables/nl.d.ts.map +1 -0
- package/dist/i18n/tables/nl.js +82 -0
- package/dist/i18n/tables/nl.js.map +1 -0
- package/dist/i18n/tables/pt.d.ts +3 -0
- package/dist/i18n/tables/pt.d.ts.map +1 -0
- package/dist/i18n/tables/pt.js +82 -0
- package/dist/i18n/tables/pt.js.map +1 -0
- package/dist/i18n/tables/tr.d.ts +3 -0
- package/dist/i18n/tables/tr.d.ts.map +1 -0
- package/dist/i18n/tables/tr.js +82 -0
- package/dist/i18n/tables/tr.js.map +1 -0
- package/dist/i18n/types.d.ts +39 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/layout/analytics.d.ts +9 -0
- package/dist/layout/analytics.d.ts.map +1 -0
- package/dist/layout/analytics.js +18 -0
- package/dist/layout/analytics.js.map +1 -0
- package/dist/layout/brand-files.d.ts +15 -0
- package/dist/layout/brand-files.d.ts.map +1 -0
- package/dist/layout/brand-files.js +15 -0
- package/dist/layout/brand-files.js.map +1 -0
- package/dist/layout/footer.d.ts +10 -0
- package/dist/layout/footer.d.ts.map +1 -0
- package/dist/layout/footer.js +21 -0
- package/dist/layout/footer.js.map +1 -0
- package/dist/layout/not-found.d.ts +7 -0
- package/dist/layout/not-found.d.ts.map +1 -0
- package/dist/layout/not-found.js +8 -0
- package/dist/layout/not-found.js.map +1 -0
- package/dist/layout/provider.d.ts +17 -0
- package/dist/layout/provider.d.ts.map +1 -0
- package/dist/layout/provider.js +14 -0
- package/dist/layout/provider.js.map +1 -0
- package/dist/layout/root.d.ts +17 -0
- package/dist/layout/root.d.ts.map +1 -0
- package/dist/layout/root.js +47 -0
- package/dist/layout/root.js.map +1 -0
- package/dist/lint/source.d.ts +19 -0
- package/dist/lint/source.d.ts.map +1 -0
- package/dist/lint/source.js +43 -0
- package/dist/lint/source.js.map +1 -0
- package/dist/llms/llms.d.ts +22 -0
- package/dist/llms/llms.d.ts.map +1 -0
- package/dist/llms/llms.js +24 -0
- package/dist/llms/llms.js.map +1 -0
- package/dist/markdown/article.d.ts +44 -0
- package/dist/markdown/article.d.ts.map +1 -0
- package/dist/markdown/article.js +108 -0
- package/dist/markdown/article.js.map +1 -0
- package/dist/markdown/inline.d.ts +40 -0
- package/dist/markdown/inline.d.ts.map +1 -0
- package/dist/markdown/inline.js +74 -0
- package/dist/markdown/inline.js.map +1 -0
- package/dist/markdown/page.d.ts +13 -0
- package/dist/markdown/page.d.ts.map +1 -0
- package/dist/markdown/page.js +21 -0
- package/dist/markdown/page.js.map +1 -0
- package/dist/marker.d.ts +37 -0
- package/dist/marker.d.ts.map +1 -0
- package/dist/marker.js +36 -0
- package/dist/marker.js.map +1 -0
- package/dist/mdx/allow-list.d.ts +23 -0
- package/dist/mdx/allow-list.d.ts.map +1 -0
- package/dist/mdx/allow-list.js +79 -0
- package/dist/mdx/allow-list.js.map +1 -0
- package/dist/mdx/components.d.ts +8 -0
- package/dist/mdx/components.d.ts.map +1 -0
- package/dist/mdx/components.js +68 -0
- package/dist/mdx/components.js.map +1 -0
- package/dist/mdx/remark-alerts.d.ts +4 -0
- package/dist/mdx/remark-alerts.d.ts.map +1 -0
- package/dist/mdx/remark-alerts.js +39 -0
- package/dist/mdx/remark-alerts.js.map +1 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +55 -0
- package/dist/next.js.map +1 -0
- package/dist/node/bin.d.ts +3 -0
- package/dist/node/bin.d.ts.map +1 -0
- package/dist/node/bin.js +13 -0
- package/dist/node/bin.js.map +1 -0
- package/dist/node/brand.d.ts +13 -0
- package/dist/node/brand.d.ts.map +1 -0
- package/dist/node/brand.js +48 -0
- package/dist/node/brand.js.map +1 -0
- package/dist/node/build.d.ts +31 -0
- package/dist/node/build.d.ts.map +1 -0
- package/dist/node/build.js +151 -0
- package/dist/node/build.js.map +1 -0
- package/dist/node/cli.d.ts +11 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +80 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/config-file.d.ts +5 -0
- package/dist/node/config-file.d.ts.map +1 -0
- package/dist/node/config-file.js +31 -0
- package/dist/node/config-file.js.map +1 -0
- package/dist/node/content.d.ts +6 -0
- package/dist/node/content.d.ts.map +1 -0
- package/dist/node/content.js +36 -0
- package/dist/node/content.js.map +1 -0
- package/dist/node/errors.d.ts +26 -0
- package/dist/node/errors.d.ts.map +1 -0
- package/dist/node/errors.js +34 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/files.d.ts +12 -0
- package/dist/node/files.d.ts.map +1 -0
- package/dist/node/files.js +43 -0
- package/dist/node/files.js.map +1 -0
- package/dist/node/og.d.ts +17 -0
- package/dist/node/og.d.ts.map +1 -0
- package/dist/node/og.js +43 -0
- package/dist/node/og.js.map +1 -0
- package/dist/node/project-root.d.ts +12 -0
- package/dist/node/project-root.d.ts.map +1 -0
- package/dist/node/project-root.js +27 -0
- package/dist/node/project-root.js.map +1 -0
- package/dist/node/serve.d.ts +32 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/serve.js +133 -0
- package/dist/node/serve.js.map +1 -0
- package/dist/node/theme.d.ts +15 -0
- package/dist/node/theme.d.ts.map +1 -0
- package/dist/node/theme.js +46 -0
- package/dist/node/theme.js.map +1 -0
- package/dist/search/dialog.d.ts +14 -0
- package/dist/search/dialog.d.ts.map +1 -0
- package/dist/search/dialog.js +17 -0
- package/dist/search/dialog.js.map +1 -0
- package/dist/search/language.d.ts +8 -0
- package/dist/search/language.d.ts.map +1 -0
- package/dist/search/language.js +30 -0
- package/dist/search/language.js.map +1 -0
- package/dist/search/route.d.ts +9 -0
- package/dist/search/route.d.ts.map +1 -0
- package/dist/search/route.js +11 -0
- package/dist/search/route.js.map +1 -0
- package/dist/seo/article.d.ts +84 -0
- package/dist/seo/article.d.ts.map +1 -0
- package/dist/seo/article.js +117 -0
- package/dist/seo/article.js.map +1 -0
- package/dist/seo/collection.d.ts +19 -0
- package/dist/seo/collection.d.ts.map +1 -0
- package/dist/seo/collection.js +30 -0
- package/dist/seo/collection.js.map +1 -0
- package/dist/seo/dataset.d.ts +31 -0
- package/dist/seo/dataset.d.ts.map +1 -0
- package/dist/seo/dataset.js +33 -0
- package/dist/seo/dataset.js.map +1 -0
- package/dist/seo/json-ld.d.ts +6 -0
- package/dist/seo/json-ld.d.ts.map +1 -0
- package/dist/seo/json-ld.js +8 -0
- package/dist/seo/json-ld.js.map +1 -0
- package/dist/seo/script-json.d.ts +8 -0
- package/dist/seo/script-json.d.ts.map +1 -0
- package/dist/seo/script-json.js +12 -0
- package/dist/seo/script-json.js.map +1 -0
- package/dist/seo/title.d.ts +11 -0
- package/dist/seo/title.d.ts.map +1 -0
- package/dist/seo/title.js +11 -0
- package/dist/seo/title.js.map +1 -0
- package/dist/seo/x-handle.d.ts +9 -0
- package/dist/seo/x-handle.d.ts.map +1 -0
- package/dist/seo/x-handle.js +21 -0
- package/dist/seo/x-handle.js.map +1 -0
- package/dist/site/app.d.ts +56 -0
- package/dist/site/app.d.ts.map +1 -0
- package/dist/site/app.js +79 -0
- package/dist/site/app.js.map +1 -0
- package/dist/site/features.d.ts +26 -0
- package/dist/site/features.d.ts.map +1 -0
- package/dist/site/features.js +46 -0
- package/dist/site/features.js.map +1 -0
- package/dist/site/metadata.d.ts +6 -0
- package/dist/site/metadata.d.ts.map +1 -0
- package/dist/site/metadata.js +78 -0
- package/dist/site/metadata.js.map +1 -0
- package/dist/site/outputs.d.ts +24 -0
- package/dist/site/outputs.d.ts.map +1 -0
- package/dist/site/outputs.js +113 -0
- package/dist/site/outputs.js.map +1 -0
- package/dist/site/posts.d.ts +6 -0
- package/dist/site/posts.d.ts.map +1 -0
- package/dist/site/posts.js +9 -0
- package/dist/site/posts.js.map +1 -0
- package/dist/site/routes.d.ts +43 -0
- package/dist/site/routes.d.ts.map +1 -0
- package/dist/site/routes.js +94 -0
- package/dist/site/routes.js.map +1 -0
- package/dist/site/site-page.d.ts +11 -0
- package/dist/site/site-page.d.ts.map +1 -0
- package/dist/site/site-page.js +70 -0
- package/dist/site/site-page.js.map +1 -0
- package/dist/site/sources.d.ts +58 -0
- package/dist/site/sources.d.ts.map +1 -0
- package/dist/site/sources.js +2 -0
- package/dist/site/sources.js.map +1 -0
- package/dist/site/url-style.d.ts +21 -0
- package/dist/site/url-style.d.ts.map +1 -0
- package/dist/site/url-style.js +18 -0
- package/dist/site/url-style.js.map +1 -0
- package/dist/website/blocks/commerce.d.ts +41 -0
- package/dist/website/blocks/commerce.d.ts.map +1 -0
- package/dist/website/blocks/commerce.js +26 -0
- package/dist/website/blocks/commerce.js.map +1 -0
- package/dist/website/blocks/content.d.ts +41 -0
- package/dist/website/blocks/content.d.ts.map +1 -0
- package/dist/website/blocks/content.js +25 -0
- package/dist/website/blocks/content.js.map +1 -0
- package/dist/website/blocks/marketing.d.ts +32 -0
- package/dist/website/blocks/marketing.d.ts.map +1 -0
- package/dist/website/blocks/marketing.js +23 -0
- package/dist/website/blocks/marketing.js.map +1 -0
- package/dist/website/blocks/parts.d.ts +26 -0
- package/dist/website/blocks/parts.d.ts.map +1 -0
- package/dist/website/blocks/parts.js +13 -0
- package/dist/website/blocks/parts.js.map +1 -0
- package/dist/website/page-view.d.ts +12 -0
- package/dist/website/page-view.d.ts.map +1 -0
- package/dist/website/page-view.js +10 -0
- package/dist/website/page-view.js.map +1 -0
- package/dist/zod.d.ts +8 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +8 -0
- package/dist/zod.js.map +1 -0
- package/package.json +187 -3
- package/styles.css +326 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/node/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EAAE,GAAG;IACV,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IACxD,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;CACxD,CAAC;AACF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;AACpE,gEAAgE;AAChE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO;IAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC/C,IAAI,IAAI,KAAK,CAAC;IAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dna } from "@lets-ship/brand-dna/schema/dna";
|
|
2
|
+
/** A site's brand lives at a fixed place, so no config key can point the build at another one. */
|
|
3
|
+
export declare const BRAND_DNA = "brand/brand.dna.json";
|
|
4
|
+
export declare const BRAND_ASSETS = "brand/assets";
|
|
5
|
+
export type LoadedBrand = {
|
|
6
|
+
readonly dna: Dna;
|
|
7
|
+
readonly dnaHash: string;
|
|
8
|
+
/** The site's own logos and fonts, by `sha256:<hex>`. */
|
|
9
|
+
readonly assets: ReadonlyMap<string, Uint8Array>;
|
|
10
|
+
};
|
|
11
|
+
/** The brand DNA and its assets, after the brand lint. A lint error stops the build. */
|
|
12
|
+
export declare function loadBrand(dir: string): Promise<LoadedBrand>;
|
|
13
|
+
//# sourceMappingURL=brand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/node/brand.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAGtD,kGAAkG;AAClG,eAAO,MAAM,SAAS,yBAAyB,CAAC;AAChD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACjD,CAAC;AA6BF,wFAAwF;AACxF,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CASjE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { hashCanonical } from "@lets-ship/brand-dna/canonical";
|
|
4
|
+
import { lintDna } from "@lets-ship/brand-dna/lint";
|
|
5
|
+
import { loadLockedFonts } from "@lets-ship/brand-dna/node/catalog";
|
|
6
|
+
import { loadAssets } from "@lets-ship/brand-dna/node/io";
|
|
7
|
+
import { Dna } from "@lets-ship/brand-dna/schema/dna";
|
|
8
|
+
import { brandFileError, brandLintError } from "./errors.js";
|
|
9
|
+
/** A site's brand lives at a fixed place, so no config key can point the build at another one. */
|
|
10
|
+
export const BRAND_DNA = "brand/brand.dna.json";
|
|
11
|
+
export const BRAND_ASSETS = "brand/assets";
|
|
12
|
+
const isMissing = (error) => error.code === "ENOENT";
|
|
13
|
+
async function readDna(dir) {
|
|
14
|
+
const text = await readFile(join(dir, BRAND_DNA), "utf8").catch((error) => {
|
|
15
|
+
if (isMissing(error))
|
|
16
|
+
throw brandFileError(BRAND_DNA, "the file is missing. A site's brand lives there.");
|
|
17
|
+
throw error;
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(text);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw brandFileError(BRAND_DNA, `not valid JSON (${error.message})`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** A brand with no files of its own (catalog fonts, a preset mark) has no assets folder; that is not an error. */
|
|
27
|
+
async function ownAssets(dir) {
|
|
28
|
+
const path = join(dir, BRAND_ASSETS);
|
|
29
|
+
const present = await access(path).then(() => true, (error) => {
|
|
30
|
+
if (isMissing(error))
|
|
31
|
+
return false;
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
return present ? loadAssets(path) : new Map();
|
|
35
|
+
}
|
|
36
|
+
/** The brand DNA and its assets, after the brand lint. A lint error stops the build. */
|
|
37
|
+
export async function loadBrand(dir) {
|
|
38
|
+
const raw = await readDna(dir);
|
|
39
|
+
const assets = await ownAssets(dir);
|
|
40
|
+
const catalog = (await loadLockedFonts()).map((f) => [f.sha256, f.data]);
|
|
41
|
+
const report = await lintDna(raw, { assets: new Map([...catalog, ...assets]) });
|
|
42
|
+
const errors = report.findings.filter((f) => f.severity === "error");
|
|
43
|
+
if (errors.length > 0)
|
|
44
|
+
throw brandLintError(errors.map((f) => `${f.rule} ${f.path}: ${f.message}`));
|
|
45
|
+
const dna = Dna.parse(raw);
|
|
46
|
+
return { dna, dnaHash: await hashCanonical(dna), assets };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.js","sourceRoot":"","sources":["../../src/node/brand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,kGAAkG;AAClG,MAAM,CAAC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAS3C,MAAM,SAAS,GAAG,CAAC,KAAc,EAAW,EAAE,CAAE,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE/F,KAAK,UAAU,OAAO,CAAC,GAAW;IACjC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAClF,IAAI,SAAS,CAAC,KAAK,CAAC;YAAE,MAAM,cAAc,CAAC,SAAS,EAAE,kDAAkD,CAAC,CAAC;QAC1G,MAAM,KAAK,CAAC;IACb,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IACpC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AO,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACpG,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SiteConfig } from "../config/site-config.js";
|
|
2
|
+
import { type SiteMarker } from "../marker.js";
|
|
3
|
+
import { type LoadedBrand } from "./brand.js";
|
|
4
|
+
export declare const OUT_DIR = "out";
|
|
5
|
+
export type Io = {
|
|
6
|
+
readonly out: (line: string) => void;
|
|
7
|
+
readonly err: (line: string) => void;
|
|
8
|
+
};
|
|
9
|
+
/** The steps every command shares: config, brand and content, each a hard stop on error. */
|
|
10
|
+
export declare function checkInputs(dir: string): Promise<{
|
|
11
|
+
config: SiteConfig;
|
|
12
|
+
brand: LoadedBrand;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* The `NEXT_PUBLIC_*` values of the build's environment, by name. Next writes each one into the
|
|
16
|
+
* pages, so they are inputs too: a preview built with a test key and a production build with the
|
|
17
|
+
* site's own key must not share a build id (D36). A value in a `.env` file is in the source hash.
|
|
18
|
+
*/
|
|
19
|
+
export declare function publicEnvOf(env: Readonly<Record<string, string | undefined>>): Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* The build id: the hash of the inputs, the versions and the public environment. A build with no
|
|
22
|
+
* public value hashes what it hashed before that value counted, so its id stays the same.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildIdOf(inputs: SiteMarker["inputs"], versions: SiteMarker["versions"], env: Readonly<Record<string, string | undefined>>): string;
|
|
25
|
+
/** `ship-site build` (architecture section 1): the static export of a site and its marker. */
|
|
26
|
+
export declare function buildSite(dir: string, io: Io): Promise<SiteMarker>;
|
|
27
|
+
/** `ship-site theme`: the brand compiled, so `next dev`, typecheck and the MDX config can read it. */
|
|
28
|
+
export declare function themeSite(dir: string): Promise<void>;
|
|
29
|
+
/** `ship-site dev`: the checks and the theme, then `next dev`, which serves it with hot reload. */
|
|
30
|
+
export declare function devSite(dir: string, port: number): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGzF,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,YAAY,CAAC;AAQzD,eAAO,MAAM,OAAO,QAAQ,CAAC;AAqB7B,MAAM,MAAM,EAAE,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAAC;AAEhG,4FAA4F;AAC5F,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CAKlG;AAyDD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKrG;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC5B,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,EAChC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAC/C,MAAM,CAIR;AAED,8FAA8F;AAC9F,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CA0BxE;AAED,sGAAsG;AACtG,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1D;AAED,mGAAmG;AACnG,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAItE"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { checkSite } from "@lets-ship/brand-dna/node/site-check";
|
|
8
|
+
import { identityFromDna } from "../config/identity.js";
|
|
9
|
+
import { BADGE_ATTRIBUTE, MARKER_FILE, markerJson } from "../marker.js";
|
|
10
|
+
import { BUILD_ID_ENV, ROOT_ENV, ROUTES_ENV } from "../next.js";
|
|
11
|
+
import { formatFeatures, routeFeatures } from "../site/features.js";
|
|
12
|
+
import { loadBrand } from "./brand.js";
|
|
13
|
+
import { loadSiteConfigFile, SITE_CONFIG_FILE } from "./config-file.js";
|
|
14
|
+
import { checkContent, contentDirs } from "./content.js";
|
|
15
|
+
import { badgeMissingError, buildStepError, siteCheckError } from "./errors.js";
|
|
16
|
+
import { FILE_CONCURRENCY, hashTree, listTree, mapLimit } from "./files.js";
|
|
17
|
+
import { projectRoot } from "./project-root.js";
|
|
18
|
+
import { compileTheme } from "./theme.js";
|
|
19
|
+
export const OUT_DIR = "out";
|
|
20
|
+
/**
|
|
21
|
+
* What a build never hashes: dependencies, outputs, files that tools generate (fumadocs-mdx writes
|
|
22
|
+
* `.source` during the build, after the hash) and files an OS drops. A generated file in the hash
|
|
23
|
+
* would give the same inputs two build ids, depending on what ran before.
|
|
24
|
+
*/
|
|
25
|
+
const NOT_SOURCE = new Set([
|
|
26
|
+
"node_modules",
|
|
27
|
+
".next",
|
|
28
|
+
OUT_DIR,
|
|
29
|
+
".ship-site",
|
|
30
|
+
".source",
|
|
31
|
+
".git",
|
|
32
|
+
".turbo",
|
|
33
|
+
"_brand",
|
|
34
|
+
"next-env.d.ts",
|
|
35
|
+
"tsconfig.tsbuildinfo",
|
|
36
|
+
".DS_Store",
|
|
37
|
+
]);
|
|
38
|
+
/** The steps every command shares: config, brand and content, each a hard stop on error. */
|
|
39
|
+
export async function checkInputs(dir) {
|
|
40
|
+
const config = await loadSiteConfigFile(dir);
|
|
41
|
+
const brand = await loadBrand(dir);
|
|
42
|
+
await checkContent(dir, config);
|
|
43
|
+
return { config, brand };
|
|
44
|
+
}
|
|
45
|
+
/** The version of a package as the site resolves it, which is the version its build ran. */
|
|
46
|
+
function version(dir, name) {
|
|
47
|
+
const path = createRequire(join(dir, "package.json")).resolve(`${name}/package.json`);
|
|
48
|
+
return JSON.parse(readFileSync(path, "utf8")).version;
|
|
49
|
+
}
|
|
50
|
+
const sha256 = (text) => `sha256:${createHash("sha256").update(text).digest("hex")}`;
|
|
51
|
+
async function inputHashes(dir, config, brand) {
|
|
52
|
+
const content = await Promise.all(contentDirs(config).map((folder) => hashTree(join(dir, folder))));
|
|
53
|
+
return {
|
|
54
|
+
dna: brand.dnaHash,
|
|
55
|
+
config: sha256(await readFile(join(dir, SITE_CONFIG_FILE), "utf8")),
|
|
56
|
+
content: sha256(content.join("\n")),
|
|
57
|
+
source: await hashTree(dir, NOT_SOURCE),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** What withShipSite reads: the optional routes the config turns on, and the project root. */
|
|
61
|
+
const nextEnv = (dir, config) => ({
|
|
62
|
+
[ROUTES_ENV]: formatFeatures(routeFeatures(config)),
|
|
63
|
+
[ROOT_ENV]: projectRoot(dir),
|
|
64
|
+
});
|
|
65
|
+
function runNext(dir, args, env) {
|
|
66
|
+
const bin = join(dirname(createRequire(join(dir, "package.json")).resolve("next/package.json")), "dist/bin/next");
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const child = spawn(process.execPath, [bin, ...args], {
|
|
69
|
+
cwd: dir,
|
|
70
|
+
env: { ...process.env, ...env },
|
|
71
|
+
stdio: "inherit",
|
|
72
|
+
});
|
|
73
|
+
child.on("error", (error) => reject(buildStepError(`next ${args[0]}`, error.message)));
|
|
74
|
+
child.on("exit", (code) => code === 0 ? resolve() : reject(buildStepError(`next ${args[0]}`, `exit code ${code}`)));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async function checkBadge(out) {
|
|
78
|
+
const pages = (await listTree(out)).filter((path) => path.endsWith(".html"));
|
|
79
|
+
const html = await mapLimit(pages, FILE_CONCURRENCY, async (path) => ({
|
|
80
|
+
path,
|
|
81
|
+
text: await readFile(join(out, path), "utf8"),
|
|
82
|
+
}));
|
|
83
|
+
const missing = html.filter((page) => !page.text.includes(BADGE_ATTRIBUTE)).map((page) => page.path);
|
|
84
|
+
if (missing.length > 0)
|
|
85
|
+
throw badgeMissingError(missing);
|
|
86
|
+
}
|
|
87
|
+
async function checkOutput(out, config, brand) {
|
|
88
|
+
const hits = await checkSite(out, brand.dna, { brandFonts: new Set(brand.assets.keys()), url: config.origin });
|
|
89
|
+
if (hits.length > 0)
|
|
90
|
+
throw siteCheckError(hits.map((hit) => `${hit.rule} ${hit.path}: ${hit.message}`));
|
|
91
|
+
if (config.footer.badge)
|
|
92
|
+
await checkBadge(out);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The `NEXT_PUBLIC_*` values of the build's environment, by name. Next writes each one into the
|
|
96
|
+
* pages, so they are inputs too: a preview built with a test key and a production build with the
|
|
97
|
+
* site's own key must not share a build id (D36). A value in a `.env` file is in the source hash.
|
|
98
|
+
*/
|
|
99
|
+
export function publicEnvOf(env) {
|
|
100
|
+
const entries = Object.entries(env).filter((entry) => entry[0].startsWith("NEXT_PUBLIC_") && entry[1] !== undefined);
|
|
101
|
+
return Object.fromEntries(entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The build id: the hash of the inputs, the versions and the public environment. A build with no
|
|
105
|
+
* public value hashes what it hashed before that value counted, so its id stays the same.
|
|
106
|
+
*/
|
|
107
|
+
export function buildIdOf(inputs, versions, env) {
|
|
108
|
+
const publicEnv = publicEnvOf(env);
|
|
109
|
+
const hashed = Object.keys(publicEnv).length === 0 ? { inputs, versions } : { inputs, versions, publicEnv };
|
|
110
|
+
return sha256(JSON.stringify(hashed)).slice(7, 23);
|
|
111
|
+
}
|
|
112
|
+
/** `ship-site build` (architecture section 1): the static export of a site and its marker. */
|
|
113
|
+
export async function buildSite(dir, io) {
|
|
114
|
+
const { config, brand } = await checkInputs(dir);
|
|
115
|
+
await compileTheme(dir, brand, identityFromDna(brand.dna));
|
|
116
|
+
const inputs = await inputHashes(dir, config, brand);
|
|
117
|
+
const versions = {
|
|
118
|
+
site: version(dir, "@lets-ship/site"),
|
|
119
|
+
brandDna: version(dir, "@lets-ship/brand-dna"),
|
|
120
|
+
next: version(dir, "next"),
|
|
121
|
+
};
|
|
122
|
+
const buildId = buildIdOf(inputs, versions, process.env);
|
|
123
|
+
const out = join(dir, OUT_DIR);
|
|
124
|
+
await rm(out, { recursive: true, force: true });
|
|
125
|
+
await runNext(dir, ["build"], { ...nextEnv(dir, config), [BUILD_ID_ENV]: buildId, NEXT_TELEMETRY_DISABLED: "1" });
|
|
126
|
+
await checkOutput(out, config, brand);
|
|
127
|
+
const marker = {
|
|
128
|
+
marker: "ship-site@1",
|
|
129
|
+
origin: config.origin,
|
|
130
|
+
inputs,
|
|
131
|
+
versions,
|
|
132
|
+
buildId,
|
|
133
|
+
badge: config.footer.badge,
|
|
134
|
+
output: await hashTree(out),
|
|
135
|
+
};
|
|
136
|
+
await writeFile(join(out, MARKER_FILE), markerJson(marker));
|
|
137
|
+
io.out(`built ${out}: ${marker.output}`);
|
|
138
|
+
return marker;
|
|
139
|
+
}
|
|
140
|
+
/** `ship-site theme`: the brand compiled, so `next dev`, typecheck and the MDX config can read it. */
|
|
141
|
+
export async function themeSite(dir) {
|
|
142
|
+
const brand = await loadBrand(dir);
|
|
143
|
+
await compileTheme(dir, brand, identityFromDna(brand.dna));
|
|
144
|
+
}
|
|
145
|
+
/** `ship-site dev`: the checks and the theme, then `next dev`, which serves it with hot reload. */
|
|
146
|
+
export async function devSite(dir, port) {
|
|
147
|
+
const { config } = await checkInputs(dir);
|
|
148
|
+
await themeSite(dir);
|
|
149
|
+
await runNext(dir, ["dev", "--port", String(port)], nextEnv(dir, config));
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CA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AAM,CAAC;AACf,CAAC;AAED,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW,EAAE,IAAY;IACtD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;IACrB,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Io } from "./build.js";
|
|
2
|
+
type Parsed = {
|
|
3
|
+
readonly positional: readonly string[];
|
|
4
|
+
readonly port: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
/** `--port <n>` or `--port=<n>`, and the positional arguments. Any other flag is a usage error, not ignored. */
|
|
7
|
+
export declare function parseArgs(args: readonly string[]): Parsed;
|
|
8
|
+
/** The `ship-site` bin. It prints the error's own message, which names the cause and the fix. */
|
|
9
|
+
export declare function runCli(args: readonly string[], cwd: string, io: Io): Promise<number>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,EAAE,EAAa,MAAM,YAAY,CAAC;AAmBjF,KAAK,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAS5F,gHAAgH;AAChH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CASzD;AA+BD,iGAAiG;AACjG,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAO1F"}
|
package/dist/node/cli.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { buildSite, checkInputs, devSite, themeSite } from "./build.js";
|
|
3
|
+
import { SiteInputError, UsageError } from "./errors.js";
|
|
4
|
+
import { serveStatic } from "./serve.js";
|
|
5
|
+
const USAGE = [
|
|
6
|
+
"usage: ship-site <command>",
|
|
7
|
+
" build build the site into out/ and write out/.ship-site.json",
|
|
8
|
+
" theme compile the brand into .ship-site/theme and public/_brand",
|
|
9
|
+
" check check site.config.ts, the brand and the content, without building",
|
|
10
|
+
" dev [--port <n>] compile the brand and run next dev",
|
|
11
|
+
" serve <dir> [--port <n>] serve a built site with the hosting rules",
|
|
12
|
+
].join("\n");
|
|
13
|
+
/** Exit codes: 0 ok, 1 a problem in the site's own files, 2 usage, 70 a failed build step. */
|
|
14
|
+
function exitCode(error) {
|
|
15
|
+
if (error instanceof UsageError)
|
|
16
|
+
return 2;
|
|
17
|
+
return error instanceof SiteInputError ? 1 : 70;
|
|
18
|
+
}
|
|
19
|
+
function parsePort(value) {
|
|
20
|
+
if (value === undefined || value === "")
|
|
21
|
+
throw new UsageError("--port needs a number, for example --port 4173");
|
|
22
|
+
const parsed = Number(value);
|
|
23
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535)
|
|
24
|
+
throw new UsageError(`--port ${value} is not a port`);
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
/** `--port <n>` or `--port=<n>`, and the positional arguments. Any other flag is a usage error, not ignored. */
|
|
28
|
+
export function parseArgs(args) {
|
|
29
|
+
const at = args.findIndex((arg) => arg === "--port" || arg.startsWith("--port="));
|
|
30
|
+
const flag = at >= 0 ? args[at] : undefined;
|
|
31
|
+
const port = flag === undefined ? undefined : parsePort(flag === "--port" ? args[at + 1] : flag.slice(7));
|
|
32
|
+
const used = flag === "--port" ? [at, at + 1] : [at];
|
|
33
|
+
const positional = args.filter((_, i) => !used.includes(i));
|
|
34
|
+
const unknown = positional.find((arg) => arg.startsWith("-"));
|
|
35
|
+
if (unknown)
|
|
36
|
+
throw new UsageError(`unknown flag ${unknown}\n${USAGE}`);
|
|
37
|
+
return { positional, port };
|
|
38
|
+
}
|
|
39
|
+
async function serve(cwd, parsed, io) {
|
|
40
|
+
const [dir] = parsed.positional;
|
|
41
|
+
if (!dir)
|
|
42
|
+
throw new UsageError(`serve needs the folder to serve\n${USAGE}`);
|
|
43
|
+
const server = await serveStatic(resolve(cwd, dir), parsed.port ?? 4173);
|
|
44
|
+
const address = server.address();
|
|
45
|
+
io.out(`serving ${dir} on http://127.0.0.1:${typeof address === "object" && address ? address.port : ""}`);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
async function run(args, cwd, io) {
|
|
49
|
+
const [command, ...rest] = args;
|
|
50
|
+
const parsed = parseArgs(rest);
|
|
51
|
+
if (command === "build")
|
|
52
|
+
return buildSite(cwd, io).then(() => 0);
|
|
53
|
+
if (command === "theme") {
|
|
54
|
+
await themeSite(cwd);
|
|
55
|
+
io.out("compiled the brand into .ship-site/theme and public/_brand");
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
if (command === "check") {
|
|
59
|
+
await checkInputs(cwd);
|
|
60
|
+
io.out("site.config.ts, brand and content: ok");
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
// Next's own port is the usual one for dev; a flag picks another.
|
|
64
|
+
if (command === "dev")
|
|
65
|
+
return devSite(cwd, parsed.port ?? 3000).then(() => 0);
|
|
66
|
+
if (command === "serve")
|
|
67
|
+
return serve(cwd, parsed, io);
|
|
68
|
+
throw new UsageError(command ? `unknown command ${command}\n${USAGE}` : USAGE);
|
|
69
|
+
}
|
|
70
|
+
/** The `ship-site` bin. It prints the error's own message, which names the cause and the fix. */
|
|
71
|
+
export async function runCli(args, cwd, io) {
|
|
72
|
+
try {
|
|
73
|
+
return await run(args, cwd, io);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
io.err(error instanceof Error ? `${error.name}: ${error.message}` : String(error));
|
|
77
|
+
return exitCode(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAW,SAAS,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,KAAK,GAAG;IACb,4BAA4B;IAC5B,gFAAgF;IAChF,mFAAmF;IACnF,2FAA2F;IAC3F,4DAA4D;IAC5D,uEAAuE;CACvE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,8FAA8F;AAC9F,SAAS,QAAQ,CAAC,KAAc;IAC/B,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,KAAK,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC;AAID,SAAS,SAAS,CAAC,KAAyB;IAC3C,IAAI,KAAK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
+
/** Loads `site.config.ts` (TypeScript, so jiti) and checks it against the schema. */
|
|
4
|
+
export declare function loadSiteConfigFile(dir: string): Promise<SiteConfig>;
|
|
5
|
+
//# sourceMappingURL=config-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/node/config-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG7E,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD,qFAAqF;AACrF,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBzE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { access } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { createJiti } from "jiti";
|
|
4
|
+
import { defineSiteConfig } from "../config/site-config.js";
|
|
5
|
+
import { SiteInputError, siteConfigFileError } from "./errors.js";
|
|
6
|
+
export const SITE_CONFIG_FILE = "site.config.ts";
|
|
7
|
+
/** Loads `site.config.ts` (TypeScript, so jiti) and checks it against the schema. */
|
|
8
|
+
export async function loadSiteConfigFile(dir) {
|
|
9
|
+
const path = join(dir, SITE_CONFIG_FILE);
|
|
10
|
+
await access(path).catch(() => {
|
|
11
|
+
throw siteConfigFileError(dir, "the file is missing. Every site has one at its root.");
|
|
12
|
+
});
|
|
13
|
+
const jiti = createJiti(import.meta.url, { moduleCache: false });
|
|
14
|
+
try {
|
|
15
|
+
const module = await jiti.import(path);
|
|
16
|
+
if (module.site === undefined)
|
|
17
|
+
throw siteConfigFileError(dir, "it exports no `site`. Export defineSiteConfig({...}) as `site`.");
|
|
18
|
+
return defineSiteConfig(module.site);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
// The file runs defineSiteConfig itself, so a schema error surfaces from the import. jiti may
|
|
22
|
+
// load its own copy of the config module, so the class is matched by name, not instanceof.
|
|
23
|
+
if (error instanceof SiteInputError)
|
|
24
|
+
throw error;
|
|
25
|
+
if (error instanceof Error && error.name === "SiteConfigError")
|
|
26
|
+
throw new SiteInputError("SiteConfigError", error.message, []);
|
|
27
|
+
// Anything else that stops the file loading (a syntax error, a bad import) is the file's own problem.
|
|
28
|
+
throw siteConfigFileError(dir, `it does not load: ${error instanceof Error ? error.message : String(error)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../src/node/config-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACzC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QAC7B,MAAM,mBAAmB,CAAC,GAAG,EAAE,sDAAsD,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAqB,IAAI,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAC5B,MAAM,mBAAmB,CAAC,GAAG,EAAE,iEAAiE,CAAC,CAAC;QACnG,OAAO,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,8FAA8F;QAC9F,2FAA2F;QAC3F,IAAI,KAAK,YAAY,cAAc;YAAE,MAAM,KAAK,CAAC;QACjD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;YAC7D,MAAM,IAAI,cAAc,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChE,sGAAsG;QACtG,MAAM,mBAAmB,CAAC,GAAG,EAAE,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC/G,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SiteConfig } from "../config/site-config.js";
|
|
2
|
+
/** The content folder of each section the config turns on. */
|
|
3
|
+
export declare function contentDirs(config: SiteConfig): string[];
|
|
4
|
+
/** The content check (D23, D31): every MDX file parses, and every component it uses is on the allow-list. */
|
|
5
|
+
export declare function checkContent(dir: string, config: SiteConfig): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/node/content.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAK3D,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CAExD;AAqBD,6GAA6G;AAC7G,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { ENGINE_COMPONENTS, MdxParseError, unlistedComponents } from "../mdx/allow-list.js";
|
|
4
|
+
import { contentError, contentParseError } from "./errors.js";
|
|
5
|
+
import { FILE_CONCURRENCY, listTree, mapLimit } from "./files.js";
|
|
6
|
+
/** The content folder of each section the config turns on. */
|
|
7
|
+
export function contentDirs(config) {
|
|
8
|
+
return Object.values(config.sections).flatMap((section) => (section === false ? [] : [section.content]));
|
|
9
|
+
}
|
|
10
|
+
async function mdxFiles(dir, folder) {
|
|
11
|
+
const root = join(dir, folder);
|
|
12
|
+
const present = await access(root).then(() => true, () => false);
|
|
13
|
+
if (!present)
|
|
14
|
+
throw contentError([`${folder}: the folder the site config names for this section is missing`]);
|
|
15
|
+
return (await listTree(root)).filter((path) => /\.mdx?$/.test(path)).map((path) => join(folder, path));
|
|
16
|
+
}
|
|
17
|
+
async function checkFile(dir, file, allowed) {
|
|
18
|
+
try {
|
|
19
|
+
return unlistedComponents(file, await readFile(join(dir, file), "utf8"), allowed);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof MdxParseError)
|
|
23
|
+
throw contentParseError(`${error.file}:${error.line}`, error.message);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The content check (D23, D31): every MDX file parses, and every component it uses is on the allow-list. */
|
|
28
|
+
export async function checkContent(dir, config) {
|
|
29
|
+
const allowed = [...ENGINE_COMPONENTS, ...config.mdxComponents];
|
|
30
|
+
const files = (await Promise.all(contentDirs(config).map((folder) => mdxFiles(dir, folder)))).flat();
|
|
31
|
+
const findings = await mapLimit(files, FILE_CONCURRENCY, (file) => checkFile(dir, file, allowed));
|
|
32
|
+
const lines = findings.flat().map((f) => `${f.file}:${f.line} <${f.component}>`);
|
|
33
|
+
if (lines.length > 0)
|
|
34
|
+
throw contentError(lines);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/node/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAuB,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAElE,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,MAAkB;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,GAAW,EAAE,MAAc;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC,GAAG,EAAE,CAAC,IAAI,EACV,GAAG,EAAE,CAAC,KAAK,CACX,CAAC;IACF,IAAI,CAAC,OAAO;QAAE,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,gEAAgE,CAAC,CAAC,CAAC;IAC9G,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,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I,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;IACjF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The errors of `ship-site`. Each names what is wrong and how to fix it, and stops the build: a
|
|
3
|
+
* site that half-builds is a site that deploys wrong (no fallback, root AGENTS.md).
|
|
4
|
+
*/
|
|
5
|
+
export declare class ShipSiteError extends Error {
|
|
6
|
+
constructor(name: string, message: string);
|
|
7
|
+
}
|
|
8
|
+
/** Problems in what the user wrote: the config, the brand or the content. Exit code 1. */
|
|
9
|
+
export declare class SiteInputError extends ShipSiteError {
|
|
10
|
+
readonly findings: readonly string[];
|
|
11
|
+
constructor(name: string, summary: string, findings: readonly string[]);
|
|
12
|
+
}
|
|
13
|
+
/** The command line itself is wrong: an unknown command, a flag with no value. Exit code 2. */
|
|
14
|
+
export declare class UsageError extends ShipSiteError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
export declare const siteConfigFileError: (dir: string, detail: string) => SiteInputError;
|
|
18
|
+
export declare const brandFileError: (path: string, detail: string) => SiteInputError;
|
|
19
|
+
export declare const contentParseError: (file: string, detail: string) => SiteInputError;
|
|
20
|
+
export declare const brandLintError: (findings: readonly string[]) => SiteInputError;
|
|
21
|
+
export declare const contentError: (findings: readonly string[]) => SiteInputError;
|
|
22
|
+
export declare const siteCheckError: (findings: readonly string[]) => SiteInputError;
|
|
23
|
+
export declare const badgeMissingError: (pages: readonly string[]) => SiteInputError;
|
|
24
|
+
/** A step of the build itself failed: next build, or a file the build needs. Exit code 70. */
|
|
25
|
+
export declare const buildStepError: (step: string, detail: string) => ShipSiteError;
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/node/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC3B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAIzC;AAED,0FAA0F;AAC1F,qBAAa,cAAe,SAAQ,aAAa;IAChD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;gBACzB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE;CAItE;AAED,+FAA+F;AAC/F,qBAAa,UAAW,SAAQ,aAAa;gBAChC,OAAO,EAAE,MAAM;CAG3B;AAED,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,cACmB,CAAC;AAEtF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,cACC,CAAC;AAEhE,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,cACkB,CAAC;AAEpF,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,MAAM,EAAE,KAAG,cACgD,CAAC;AAE9G,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,MAAM,EAAE,KAAG,cAKzD,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,MAAM,EAAE,KAAG,cACuC,CAAC;AAErG,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,MAAM,EAAE,KAAG,cAK3D,CAAC;AAEH,8FAA8F;AAC9F,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,aACG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The errors of `ship-site`. Each names what is wrong and how to fix it, and stops the build: a
|
|
3
|
+
* site that half-builds is a site that deploys wrong (no fallback, root AGENTS.md).
|
|
4
|
+
*/
|
|
5
|
+
export class ShipSiteError extends Error {
|
|
6
|
+
constructor(name, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = name;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Problems in what the user wrote: the config, the brand or the content. Exit code 1. */
|
|
12
|
+
export class SiteInputError extends ShipSiteError {
|
|
13
|
+
findings;
|
|
14
|
+
constructor(name, summary, findings) {
|
|
15
|
+
super(name, findings.length > 0 ? `${summary}\n${findings.map((f) => ` ${f}`).join("\n")}` : summary);
|
|
16
|
+
this.findings = findings;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** The command line itself is wrong: an unknown command, a flag with no value. Exit code 2. */
|
|
20
|
+
export class UsageError extends ShipSiteError {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super("UsageError", message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const siteConfigFileError = (dir, detail) => new SiteInputError("SiteConfigFileError", `site.config.ts in ${dir}: ${detail}`, []);
|
|
26
|
+
export const brandFileError = (path, detail) => new SiteInputError("BrandFileError", `${path}: ${detail}`, []);
|
|
27
|
+
export const contentParseError = (file, detail) => new SiteInputError("ContentParseError", `${file} is not valid MDX: ${detail}`, []);
|
|
28
|
+
export const brandLintError = (findings) => new SiteInputError("BrandLintError", "brand/brand.dna.json fails the brand lint. Fix each error:", findings);
|
|
29
|
+
export const contentError = (findings) => new SiteInputError("ContentError", "content uses components that are not on the allow-list. Use a listed one, or add the site's own to mdxComponents in site.config.ts:", findings);
|
|
30
|
+
export const siteCheckError = (findings) => new SiteInputError("SiteCheckError", "the built site fails the white-label check (D23):", findings);
|
|
31
|
+
export const badgeMissingError = (pages) => new SiteInputError("BadgeMissingError", "footer.badge is on, but these pages have no badge. Render SiteFooter in the layout of each:", pages);
|
|
32
|
+
/** A step of the build itself failed: next build, or a file the build needs. Exit code 70. */
|
|
33
|
+
export const buildStepError = (step, detail) => new ShipSiteError("BuildStepError", `${step} failed: ${detail}`);
|
|
34
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/node/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,YAAY,IAAY,EAAE,OAAe;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,0FAA0F;AAC1F,MAAM,OAAO,cAAe,SAAQ,aAAa;IACvC,QAAQ,CAAoB;IACrC,YAAY,IAAY,EAAE,OAAe,EAAE,QAA2B;QACrE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACvG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAED,+FAA+F;AAC/F,MAAM,OAAO,UAAW,SAAQ,aAAa;IAC5C,YAAY,OAAe;QAC1B,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,MAAc,EAAkB,EAAE,CAClF,IAAI,cAAc,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,KAAK,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,MAAc,EAAkB,EAAE,CAC9E,IAAI,cAAc,CAAC,gBAAgB,EAAE,GAAG,IAAI,KAAK,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,MAAc,EAAkB,EAAE,CACjF,IAAI,cAAc,CAAC,mBAAmB,EAAE,GAAG,IAAI,sBAAsB,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAA2B,EAAkB,EAAE,CAC7E,IAAI,cAAc,CAAC,gBAAgB,EAAE,4DAA4D,EAAE,QAAQ,CAAC,CAAC;AAE9G,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAA2B,EAAkB,EAAE,CAC3E,IAAI,cAAc,CACjB,cAAc,EACd,qIAAqI,EACrI,QAAQ,CACR,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAA2B,EAAkB,EAAE,CAC7E,IAAI,cAAc,CAAC,gBAAgB,EAAE,mDAAmD,EAAE,QAAQ,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAwB,EAAkB,EAAE,CAC7E,IAAI,cAAc,CACjB,mBAAmB,EACnB,6FAA6F,EAC7F,KAAK,CACL,CAAC;AAEH,8FAA8F;AAC9F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,MAAc,EAAiB,EAAE,CAC7E,IAAI,aAAa,CAAC,gBAAgB,EAAE,GAAG,IAAI,YAAY,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Every file under a folder, as sorted POSIX paths relative to it, skipping the named folders and files. */
|
|
2
|
+
export declare function listTree(root: string, skip?: ReadonlySet<string>): Promise<string[]>;
|
|
3
|
+
/** How many files a step reads at once: well under the default open-file limit (256 on macOS). */
|
|
4
|
+
export declare const FILE_CONCURRENCY = 32;
|
|
5
|
+
/** `items.map(fn)` with at most `limit` calls in flight, results in input order. */
|
|
6
|
+
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
|
|
7
|
+
/**
|
|
8
|
+
* One hash for a folder: each file's path and the hash of its bytes, in path order. The same
|
|
9
|
+
* files give the same hash on any machine, whatever order the file system lists them in.
|
|
10
|
+
*/
|
|
11
|
+
export declare function hashTree(root: string, skip?: ReadonlySet<string>): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/node/files.ts"],"names":[],"mappings":"AAKA,6GAA6G;AAC7G,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOrG;AAID,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,oFAAoF;AACpF,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAYlH;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnG"}
|