Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
- name: Check and build
env:
EFFECTIFIED_PACKAGES: ${{ github.workspace }}/.packages
GITHUB_TOKEN: ${{ github.token }}
run: |
pnpm check
pnpm build
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ The Pi family and its packages are in [`src/data/catalog.ts`](src/data/catalog.t
[effectified/packages](https://github.com/effectified/packages) are a content collection
([`src/content.config.ts`](src/content.config.ts)): each one's `docs.json` and `SKILL.md`, which the engine generates
into it, read from a checkout of that repository (`EFFECTIFIED_PACKAGES`, a sibling `../packages`, or a shallow clone).
Each facade gets a page (`/<name>`) with its examples, its frontend demo, its API and its skill (`/<name>/SKILL.md`).
The build also writes `_redirects`: `/<name>.tgz` is the tarball of each package's newest release, so the page never
names a version. The counts on the page are computed at build time; never write a number or a version into the page
by hand.
Each facade gets a page (`/<name>`) with its examples, its frontend demo (unpacked from its GitHub release at build
time), its API and its skill (`/<name>/SKILL.md`). Every package installs from npm by name, so the page never names a
version. The counts on the page are computed at build time; never write a number or a version into the page by hand.

## Brand

Expand Down
6 changes: 3 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// effectified.dev: a static Astro build, served by Cloudflare Workers as static assets (wrangler.jsonc). Its facade
// pages come from effectified/packages (src/content.config.ts); `releases` adds `_redirects` and the live demos.
// pages come from effectified/packages (src/content.config.ts); `demos` adds the live demos.
import { defineConfig } from "astro/config";
import { releases } from "./src/integrations/releases.ts";
import { demos } from "./src/integrations/demos.ts";

export default defineConfig({
site: "https://effectified.dev",
output: "static",
trailingSlash: "never",
build: { format: "file" },
integrations: [releases()],
integrations: [demos()],
});
18 changes: 8 additions & 10 deletions src/components/Install.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
// page; without JavaScript the npm one shows and can be selected by hand.

interface Props {
/** The tarball: `https://effectified.dev/<name>.tgz`, which always installs the newest release. */
url: string;
/** Further packages to install with it (Effect UI's snapshot build, say). */
extra?: string | undefined;
/** Whether the package's own dependencies are tarball URLs, which pnpm installs only when told to. */
urlDependencies?: boolean;
/** The package, installed from npm by name: its newest version. */
name: string;
/** Effect UI's snapshot build, a URL installed beside a frontend facade; npm installs a URL only when told to. */
effectUi?: string | undefined;
}

const { url, extra, urlDependencies = false } = Astro.props;
const rest = `${url} effect${extra === undefined ? "" : ` ${extra}`}`;
const { name, effectUi } = Astro.props;
const rest = `${name} effect${effectUi === undefined ? "" : ` ${effectUi}`}`;
const managers = [
{ id: "npm", command: `npm install --allow-remote=all ${rest}` },
{ id: "pnpm", command: `pnpm add ${urlDependencies ? "--config.block-exotic-subdeps=false " : ""}${rest}` },
{ id: "npm", command: `npm install ${effectUi === undefined ? "" : "--allow-remote=root "}${rest}` },
{ id: "pnpm", command: `pnpm add ${rest}` },
{ id: "bun", command: `bun add ${rest}` },
] as const;
---
Expand Down
16 changes: 2 additions & 14 deletions src/data/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Package {
/** The upstream packages it wraps or builds on, with the pinned version. */
readonly wraps: ReadonlyArray<string>;
readonly summary: string;
/** Not in the release: private like the upstream package it wraps, used from a checkout. */
/** Not on npm: private like the upstream package it wraps, used from a checkout. */
readonly private?: true;
}

Expand All @@ -20,11 +20,9 @@ export interface Family {
readonly title: string;
readonly upstream: { readonly name: string; readonly url: string; readonly version: string };
readonly repo: string;
/** The npm scope of the family's packages. */
/** The npm scope of the family's packages: each installs from npm as `<scope>/<name>`. */
readonly scope: string;
readonly status: "alpha";
/** The GitHub release the packages install from: `<base>/<scope>-<name>-<version>.tgz`. */
readonly release: { readonly tag: string; readonly version: string; readonly base: string };
readonly effect: string;
readonly packages: ReadonlyArray<Package>;
}
Expand All @@ -47,11 +45,6 @@ export const FAMILIES: ReadonlyArray<Family> = [
repo: "https://github.com/effectified/pi",
scope: "@effectified",
status: "alpha",
release: {
tag: "v0.2.0",
version: "0.2.0",
base: "https://github.com/effectified/pi/releases/download/v0.2.0",
},
effect: "~4.1.5",
packages: [
{
Expand Down Expand Up @@ -209,8 +202,3 @@ export const totals = {
packages: FAMILIES.reduce((sum, family) => sum + family.packages.length, 0),
upstream: new Set(FAMILIES.flatMap((family) => family.packages.flatMap((pkg) => pkg.wraps.map((w) => `${family.id}/${w}`)))).size,
};

/** The release URL of a package's tarball, as `npm pack` names it. */
export function tarballUrl(family: Family, pkg: Package): string {
return `${family.release.base}/${family.scope.slice(1)}-${pkg.name}-${family.release.version}.tgz`;
}
57 changes: 14 additions & 43 deletions src/data/packages.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// The facades of effectified/packages, as the site lists them: each one's docs.json and SKILL.md, which the engine
// generates into every facade, read from a checkout of effectified/packages, with its library's npm downloads. Also
// the newest release of the Pi family. Read at build time, so a site build shows what is released now: nothing here
// names a version by hand.
// generates into every facade, read from a checkout of effectified/packages, with its library's npm downloads. Read
// at build time, so a site build shows what is released now: nothing here names a version by hand.

import { execFileSync } from "node:child_process";
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { FAMILIES } from "./catalog";

/** docs.json, schema 1, as `src/docs.ts` of effectified/engine writes it. */
/** docs.json, schema 2, as `src/docs.ts` of effectified/engine writes it; the site reads the fields it shows. */
export interface FacadeDocs {
readonly schema: 1;
readonly schema: 2;
readonly name: string;
readonly slug: string;
readonly kind: "runtime" | "ui";
Expand All @@ -21,7 +19,11 @@ export interface FacadeDocs {
readonly engine: string;
readonly page: string;
readonly source: string;
readonly install: { readonly latest: string; readonly release: string; readonly tag: string; readonly effectUi?: string };
/**
* The package installs by `name` from npm (`npm`, its page there), with Effect UI's snapshot build beside it for a
* frontend facade (`effectUi`, a URL); `tag` is its GitHub release, which holds its notes and demo.
*/
readonly install: { readonly npm: string; readonly tag: string; readonly effectUi?: string };
readonly demo?: { readonly url: string; readonly pages: ReadonlyArray<string> };
readonly tests: number;
readonly examples: ReadonlyArray<{ readonly title: string; readonly source: string; readonly code: string; readonly demo?: string }>;
Expand Down Expand Up @@ -72,7 +74,7 @@ export function packagesCheckout(): string {
return cache;
}

/** Every facade's docs and skill, read from the checkout; facades whose docs.json is another schema are left out. */
/** Every facade's docs and skill, read from the checkout; a facade whose docs.json is another schema is left out, with a warning. */
export function readFacadeDocs(): ReadonlyArray<FacadeDocs & { readonly skill: string }> {
const targets = join(packagesCheckout(), "targets");
return readdirSync(targets)
Expand All @@ -82,7 +84,10 @@ export function readFacadeDocs(): ReadonlyArray<FacadeDocs & { readonly skill: s
if (!existsSync(join(directory, "docs.json"))) return [];
// docs.json is generated by the engine and committed: a stored format, checked by its schema number.
const docs = JSON.parse(readFileSync(join(directory, "docs.json"), "utf8")) as { readonly schema?: unknown };
if (docs.schema !== 1) return [];
if (docs.schema !== 2) {
console.warn(`effectified: ${target} left out, its docs.json is schema ${String(docs.schema)}, the site reads 2`);
return [];
}
return [{ ...(docs as FacadeDocs), skill: readFileSync(join(directory, "SKILL.md"), "utf8") }];
});
}
Expand All @@ -109,37 +114,3 @@ async function weeklyDownloads(name: string): Promise<number | undefined> {
return undefined;
}
}

/** A family's newest release: its tag and the base URL of its tarballs. */
export interface Release {
readonly tag: string;
readonly version: string;
readonly base: string;
}

/**
* The newest release of the Pi family from GitHub's API (prereleases included; `GITHUB_TOKEN` lifts its rate limit),
* or the catalog's when the API does not answer.
*/
export async function piRelease(): Promise<Release> {
const pi = FAMILIES[0];
if (pi === undefined) throw new Error("the catalog has no family");
try {
const token = process.env["GITHUB_TOKEN"];
const response = await fetch("https://api.github.com/repos/effectified/pi/releases?per_page=1", {
headers: { accept: "application/vnd.github+json", ...(token === undefined || token === "" ? {} : { authorization: `Bearer ${token}` }) },
});
if (!response.ok) return pi.release;
const [newest] = (await response.json()) as ReadonlyArray<{ readonly tag_name?: unknown }>;
const tag = newest?.tag_name;
if (typeof tag !== "string" || !/^v\d/.test(tag)) return pi.release;
return { tag, version: tag.slice(1), base: `${pi.repo}/releases/download/${tag}` };
} catch {
return pi.release;
}
}

/** The URL that installs a Pi package's newest release: effectified.dev redirects it to the release's tarball. */
export function piLatestUrl(name: string): string {
return `https://effectified.dev/${name}.tgz`;
}
27 changes: 6 additions & 21 deletions src/integrations/releases.ts → src/integrations/demos.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
// What a site build adds beside its pages, from the releases it lists: `_redirects`, which sends `/<name>.tgz` to the
// tarball of each package's newest release (so the site and every README install "the latest" by one stable URL),
// and the live demos of the frontend facades, unpacked from their releases under `/demos/<slug>/`.
// What a site build adds beside its pages: the live demos of the frontend facades, unpacked from their GitHub releases
// (`<slug>-v<version>`, as each facade's docs.json names it) under `/demos/<slug>/`.

import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import type { AstroIntegration } from "astro";
import { FAMILIES, tarballUrl } from "../data/catalog";
import { piRelease, readFacadeDocs } from "../data/packages";
import { readFacadeDocs } from "../data/packages";

/** The integration: runs once the pages are built. */
export function releases(): AstroIntegration {
export function demos(): AstroIntegration {
return {
name: "effectified-releases",
name: "effectified-demos",
hooks: {
"astro:build:done": async ({ dir, logger }) => {
const out = fileURLToPath(dir);
const facades = readFacadeDocs();
const pi = FAMILIES[0];
const release = await piRelease();
const lines = [
...facades.map((facade) => `/${facade.slug}.tgz ${facade.install.release} 302`),
...(pi === undefined
? []
: pi.packages
.filter((pkg) => pkg.kind !== "docs" && pkg.private !== true)
.map((pkg) => `/${pkg.name}.tgz ${tarballUrl({ ...pi, release }, pkg)} 302`)),
];
writeFileSync(join(out, "_redirects"), `${lines.join("\n")}\n`);
logger.info(`_redirects: ${lines.length} packages to their newest release`);
for (const facade of facades) {
for (const facade of readFacadeDocs()) {
if (facade.demo === undefined) continue;
const unpacked = await unpackDemo(facade.demo.url, join(out, "demos", facade.slug));
if (unpacked) logger.info(`demo of ${facade.name}: ${facade.demo.pages.join(", ")}`);
Expand Down
9 changes: 5 additions & 4 deletions src/pages/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
// One facade's page, generated from the docs.json and SKILL.md the engine writes into it in effectified/packages:
// what it is, how to install its newest release, its examples (a frontend facade's beside the live demo that runs
// what it is, how to install it from npm, its examples (a frontend facade's beside the live demo that runs
// them), its API, and the skill an agent follows to use it. Nothing here is written per facade.
import { Code } from "astro:components";
import { getCollection } from "astro:content";
Expand All @@ -21,7 +21,7 @@ export async function getStaticPaths() {
const { facade } = Astro.props;
const { api } = facade;
const ui = facade.kind === "ui";
const releases = facade.source.replace(/\/tree\/main\/.*$/, `/releases?q=${encodeURIComponent(facade.slug)}`);
const notes = facade.source.replace(/\/tree\/main\/.*$/, `/releases/tag/${facade.install.tag}`);
const list = (names: ReadonlyArray<string>) => (names.length === 0 ? "–" : names.join(", "));
const effects = api.handles.reduce((sum, handle) => sum + handle.effects.length, 0);
const streams = api.handles.reduce((sum, handle) => sum + handle.streams.length + handle.events.length, 0);
Expand Down Expand Up @@ -60,10 +60,11 @@ const facts = ui
))}
</dl>
<div class="facade-install">
<Install url={facade.install.latest} extra={facade.install.effectUi} />
<Install name={facade.name} effectUi={facade.install.effectUi} />
<p class="note">
<span class="quiet">
Always the newest release. To pin one, install its tarball from the <a href={releases}>releases</a>.
<a href={facade.install.npm}>On npm</a>, published by the release workflow of effectified/packages with a
provenance attestation. <a href={notes}>Release notes</a>.
{ui ? " Effect UI is in public preview: its snapshot build installs with it." : ""}
</span>
</p>
Expand Down
16 changes: 8 additions & 8 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Scene from "../components/Scene.astro";
import Base from "../layouts/Base.astro";
import { effectifiedDark } from "../code-theme";
import { FAMILIES, KINDS, totals, type Kind } from "../data/catalog";
import { type Facade, piLatestUrl } from "../data/packages";
import type { Facade } from "../data/packages";

// The Pi family and its composition, the one package a product installs first.
const [pi] = FAMILIES;
Expand Down Expand Up @@ -270,7 +270,7 @@ const engineTests = facades.reduce((sum, facade) => sum + facade.tests, 0);
{pkg.name}
</span>
) : (
<a href={piLatestUrl(pkg.name)} title="Tarball of the newest release">
<a href={`https://www.npmjs.com/package/${family.scope}/${pkg.name}`} title="Its page on npm">
<span class="scope">{family.scope}/</span>
{pkg.name}
</a>
Expand Down Expand Up @@ -298,14 +298,14 @@ const engineTests = facades.reduce((sum, facade) => sum + facade.tests, 0);
</div>
<div class="release reveal">
<div>
<span class="label">// Install from GitHub</span>
<span class="label">// Install from npm</span>
<p>
Released on GitHub, not npm. One URL installs a package with every effectified package it needs;
Pi and <code>effect</code> come from npm. The URL always installs the newest release.{" "}
On npm, under <code>{pi.scope}</code>: each repository's own workflow publishes its packages, with a
provenance attestation. A package brings every Effectified package it needs, and Pi with it.{" "}
<a href={`${pi.repo}/releases`}>Release notes</a>
</p>
</div>
<Install url={piLatestUrl(thread.name)} urlDependencies />
<Install name={`${pi.scope}/${thread.name}`} />
</div>
</div>
</section>
Expand All @@ -329,7 +329,7 @@ const engineTests = facades.reduce((sum, facade) => sum + facade.tests, 0);
<h3>effectified/packages</h3>
<div class="meta">
<span>made by <a href="https://github.com/effectified/engine">effectified/engine</a> · TypeScript 7 · ast-grep · Effect 4</span>
<span>generated, tested in CI, released on GitHub</span>
<span>generated, tested in CI, published to npm</span>
<a href="https://github.com/effectified/packages">source</a>
<a href="https://github.com/effectified/packages/blob/main/CONTRIBUTING.md">contribute</a>
</div>
Expand Down Expand Up @@ -384,7 +384,7 @@ const engineTests = facades.reduce((sum, facade) => sum + facade.tests, 0);
<a class="btn btn-ghost" href="https://github.com/effectified">github.com/effectified</a>
</div>
<div class="closing-install">
<Install url={piLatestUrl(thread.name)} urlDependencies />
<Install name={`${pi.scope}/${thread.name}`} />
</div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.25; letter-spacing: -0
.closing h2 .dim { display: block; }
.closing-install { margin-top: clamp(48px, 16vw, 300px); max-width: 980px; }

/* Install: one package from its GitHub release, per package manager */
/* Install: one package from npm, per package manager */

.install {
border: 1px solid var(--line-strong);
Expand Down