@mccaskie-labs/workbench-site 0.0.0-stage → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/README.md +39 -2
- package/dist/builder.d.ts +79 -0
- package/dist/builder.js +828 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +128 -0
- package/dist/frames.d.ts +91 -0
- package/dist/frames.js +63 -0
- package/dist/html.d.ts +6 -0
- package/dist/html.js +24 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/recipe.d.ts +216 -0
- package/dist/recipe.js +166 -0
- package/dist/recipes/admin.d.ts +3 -0
- package/dist/recipes/admin.js +199 -0
- package/dist/recipes/enquiries-kit.d.ts +55 -0
- package/dist/recipes/enquiries-kit.js +235 -0
- package/dist/recipes/every-site.d.ts +3 -0
- package/dist/recipes/every-site.js +293 -0
- package/dist/recipes/index.d.ts +2 -0
- package/dist/recipes/index.js +7 -0
- package/dist/recipes/members.d.ts +3 -0
- package/dist/recipes/members.js +38 -0
- package/dist/samples.d.ts +18 -0
- package/dist/samples.js +69 -0
- package/dist/sections.d.ts +142 -0
- package/dist/sections.js +116 -0
- package/dist/styles.d.ts +33 -0
- package/dist/styles.js +153 -0
- package/package.json +52 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @mccaskie-labs/workbench-site
|
|
2
|
+
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Default pages step 1 (`docs/default-pages.md`): three new recipes, Questions and answers (`faq`, `/faq`), Accessibility (`accessibility`, `/accessibility`) and Something went wrong (`error`, no address, status 500).
|
|
8
|
+
- Every recipe has a `tier`: `always` (built without asking), `ticked` (suggested) or `offered` (shown unticked). Only About, Questions and answers and Accessibility are not always. `npx workbench-site add` with no pages named builds the always set (`alwaysSet()`), members pages left out; `list` shows each page's tier.
|
|
9
|
+
- `src/pages/index.ts` exports `errorPage(request, env)`, which draws Something went wrong in the site's look with status 500, never cached. The template's `src/index.ts` calls it when answering throws, and its starter `src/pages/index.ts` has it too: a project on an older template keeps its plain error until it takes the template update. The generated pages test checks a page that throws shows it.
|
|
10
|
+
|
|
11
|
+
## 0.9.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- The Design mode page (`/admin/design`, recipe `design`): turns design mode on or off in this browser, on the test site only. While it is on, the site helper puts workbench-ui 0.14.0's design script on every public page, so an admin can try looks and layouts in place. `designSwitch`, `designModePost` and `designModeOn` are exported, and `frame` takes `design: { script, keep? }`. An unchanged 0.8.0 `src/pages/site.ts` takes the new helper on the next `add`. `add` raises workbench-ui to 0.14.0.
|
|
16
|
+
|
|
17
|
+
## 0.8.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- The Looks page (`/admin/look`, recipe `look`): the site's home page and the first two pages of its header, in every look it may choose, light or dark, side by side, from workbench-ui 0.13.3's `lookPreview`. Looking changes nothing.
|
|
22
|
+
- The site helper shows a public page in another look when asked with `?wb-look=` and `?wb-scheme=` (workbench-ui's `previewAttributes`), outside production only and never on a members or admin page: the look's colours and fonts from `looks.css`, and its own header and footer. Public pages may now be framed by the site itself (`frame-ancestors 'self'`), so the Looks page can show them; members and admin pages still can't be framed.
|
|
23
|
+
- `frame` takes `preview: { look, scheme }`.
|
|
24
|
+
- A project whose `src/pages/site.ts` is still exactly as an earlier workbench-site wrote it gets the new helper on the next `add`; a changed one is kept. `add` raises workbench-ui to 0.13.3.
|
|
25
|
+
|
|
26
|
+
## 0.7.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- The site helper takes the site layout from `src/site-layout.generated.ts` (`SITE_LAYOUT`, written by `npx workbench-ui styles` from 0.13.2), so a layout from `workbench/looks/` works too. `add` raises the project's workbench-ui to 0.13.2 if it is older, and the generated pages test reads the same module. A project built with 0.6.0 keeps its own `site.ts`: swap its `resolveSiteLayout(themeInput(brandFile).input)` for `SITE_LAYOUT`.
|
|
31
|
+
|
|
32
|
+
## 0.6.0
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- Every page is drawn in the project's site layout: the `src/pages/site.ts` the builder writes reads brand.json's `layout` (or its look's) with workbench-ui's `resolveSiteLayout` and passes its header and footer to `frame()`, and the generated test checks each page's `data-header` and `data-footer`. A layout only `workbench/looks/` holds falls back to the look's. A project built with 0.5.0 or earlier keeps its own `site.ts`: add `layout` to its `frame()` call the same way.
|
|
37
|
+
|
|
38
|
+
## 0.5.0
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- The Style guide recipe (`/admin/style-guide`, the site's admins only, `docs/look-studio.md` §9.5): every sample of every tool the project uses, in its look, with a switch between light, dark and the admin look. Its page calls workbench-ui's `styleGuide`, so adding it raises the project's workbench-ui to 0.13.0 if older (new recipe field `packages`), with the project's `src/samples.generated.ts` and links `public/styles/style-guide.css`, both written by `npx workbench-ui styles`. New section kind `style-guide`. `frame()` takes `scheme` (light or dark), drawn as `data-wb-scheme` on `<html>`, and the project's `sitePage` takes `view` and extra `stylesheets` (a project built with 0.3.0 or earlier keeps its own `src/pages/site.ts`, so add those two options to it before adding the style guide).
|
|
43
|
+
|
|
44
|
+
## 0.4.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- Samples at `./samples` for the style guide (docs/look-studio.md §5.1): a page in each frame, header and footer, and every section, drawn by the tool's own frame() and sections with made-up words.
|
|
49
|
+
|
|
50
|
+
## 0.3.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- Site layouts in the page frame (theming step 5): `frame()` takes `layout` (header menu-right, centred or menu-centre; footer line, columns or centred), drawn as `data-header` and `data-footer` with `wb-site-*` rules, and `headerAction` for the header's one button. The page width and section spacing read the new theme tokens `--wb-page-width` and `--wb-section-space` (new variable `--wb-site-section-space`), with today's sizes as fallbacks.
|
|
55
|
+
|
|
56
|
+
## 0.2.0
|
|
57
|
+
|
|
58
|
+
- Members and admin pages (`docs/site-planner.md`, step 2): the Account recipe (`/account`, signed in only, with a sign-out button) and the Admin home recipe (`/admin`, the site's admins only, listing every admin page with a line on what it's for). Members and admin pages are never indexed, never cached and carry no analytics beacon, and an admin page carries `wb-ui-admin`, so it takes the theme's admin look (the project's accent and fonts on light neutrals, `docs/theming.md`); the generated routes send people who aren't signed in to the sign-in page, and refuse admin pages to anyone who isn't one of the site's admins. New `account` section, and a list item can link its title.
|
|
59
|
+
- Contact's enquiry form and the Enquiries admin list. Contact (recipe version 2) now needs the new Enquiries recipe (`/admin/enquiries`), so no enquiry is taken before there is somewhere to read it. Adding it writes, once each: `workbench/forms/enquiry.json` (name, email, phone, message; `npm run forms` builds it, and `add` runs it), `src/pages/enquiry-store.ts` (the form's POST, with the template's Turnstile check and same-site check, and the admin list and delete), and the migration `<stamp>_workbench_site_enquiries.sql` with its down file: the `site_enquiries` table, which anyone may add to (dated by the database) and only the site's admins read or delete, with no secret key. `add` says to apply it on staging and refresh the staging snapshot. A page with a form has `post`; the generated routes take POST only for those pages. New sections `formSection` and `enquiryList`. A database test (`npm run test:store`) proves the table's columns and policies.
|
|
60
|
+
- `npx workbench-site check` (also `npm run check:site`, added to the project's `package.json`): `workbench/site.json` must match the page files and every page's words must be in the strings catalogue. `--live` also fails on any `[fill-in]` still in a page's words, for before a site goes live. `siteProblems` is the same check as a function.
|
|
61
|
+
|
|
62
|
+
## 0.1.0
|
|
63
|
+
|
|
64
|
+
- First version (`docs/site-planner.md`, step 1): the page recipe shape (`Recipe`, checked by `recipeProblems`), the "Every site" recipes (Home, About, Contact, Not found; Privacy and Terms come with their written clauses, and Contact's enquiry form with the Enquiries list), and the builder `buildSite`, which writes one thin page file per recipe into a project made from Workbench's template (`src/pages/`), its words into the strings catalogue (a word the project already has is kept), the routes, the header and footer links, a test per page and `workbench/site.json`. A page once built is never written again. Page frames (`frame`: landing, column, two-columns) and sections (`hero` in three arrangements, `text`, `list`, `picture`, `callToAction`, `details`), drawn with `wb-site-*` classes listed in `SITE_STYLES`, whose variables default to the shared theme tokens. `npx workbench-site list` and `npx workbench-site add <page>...`.
|
package/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mccaskie-labs/workbench-site
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Workbench project's standard pages (`docs/site-planner.md`). Workbench builds the pages; the project's Claude goes over them with the owner and changes what they want.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx workbench-site list # the pages it can build, and which are asked about
|
|
7
|
+
npx workbench-site add # build the pages every project has, without asking
|
|
8
|
+
npx workbench-site add about faq # and the ones the owner kept
|
|
9
|
+
npx workbench-site check # site.json matches the pages, every word is there
|
|
10
|
+
npx workbench-site check --live # and no [fill-in] is left, before going live
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Every page has a tier (`docs/default-pages.md` §3). Always pages are built without asking: Home, Contact, Not found, Something went wrong (the site's own error page, shown when a page breaks), Admin home, Enquiries, Style guide, Looks and Design mode. The owner is asked about three: About and Questions and answers (ticked) and Accessibility (not ticked).
|
|
14
|
+
|
|
15
|
+
`add` writes, in a project made from Workbench's template:
|
|
16
|
+
|
|
17
|
+
| File | What it is |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `src/pages/<page>.ts` | One thin file per page: its frame, its sections in order and its words' keys. The project's own from then on |
|
|
20
|
+
| `src/pages/site.ts` | The shared page wrapper (words, frame, header and footer). Written once |
|
|
21
|
+
| `src/pages/index.ts`, `src/pages/nav.ts` | The routes and the header and footer links, rewritten on each add |
|
|
22
|
+
| `strings/strings.en-AU.json` | Each page's words. Words in `[square brackets]` are the owner's to fill in |
|
|
23
|
+
| `test/pages.test.ts` | Every page answers, in the project's look, and is owner-only on staging |
|
|
24
|
+
| `workbench/site.json` | Each page, its recipe and version, its frame, and its state (`built`, `checked`, `changed`) |
|
|
25
|
+
|
|
26
|
+
Then it runs `npm install` and `npm run styles` (skip with `--no-install`). A page already in `workbench/site.json` is left alone. It also adds `npm run check:site`.
|
|
27
|
+
|
|
28
|
+
Pages come in three areas. Public pages are for anyone. Members pages (Account) need a sign-in, and admin pages (Admin home) need one of the site's admins; both are never indexed or cached and carry no analytics beacon. On staging every page is owner-only, as the rest of the project is.
|
|
29
|
+
|
|
30
|
+
The Style guide (`/admin/style-guide`) shows every sample of every tool the project uses, in its look, light and dark, with the admin look beside them. It needs `@mccaskie-labs/workbench-ui` 0.13.2 or newer, which `add` sets: `npx workbench-ui styles` writes `src/samples.generated.ts` and `public/styles/style-guide.css`, which the page reads.
|
|
31
|
+
|
|
32
|
+
Contact comes with an enquiry form and the Enquiries admin list (`/admin/enquiries`). They need a table, so `add` also writes `workbench/forms/enquiry.json`, `src/pages/enquiry-store.ts` and the migration `supabase/migrations/<stamp>_workbench_site_enquiries.sql` with its down file. Apply the migration on staging with Workbench Control (`sb_migration_apply`, free there: a new table and its policies only), then refresh `supabase/staging-columns.json`; until then `check:limits` and the forms kit fail. Anyone may add an enquiry and only the site's admins read or delete them, with no secret key. The page checks the form and Turnstile first. Rows sent straight to the database with the publishable key skip those checks, but each is capped in length.
|
|
33
|
+
|
|
34
|
+
## Sections and frames
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { account, callToAction, details, enquiryList, formSection, frame, hero, list, picture, text } from "@mccaskie-labs/workbench-site";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Each section takes plain words (escaped) and returns HTML with `wb-site-*` classes; `frame` wraps them in a whole page (`landing`, `column` or `two-columns`). Restyle them in the project's `public/styles/project.css`: every class and `--wb-site-*` variable is listed in the generated `public/styles/workbench.css`, and the colour, font, corner and space variables follow the project's theme tokens (`--wb-accent` and the rest).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { FrameName } from "./frames.ts";
|
|
2
|
+
import { type Recipe } from "./recipe.ts";
|
|
3
|
+
export declare const SITE_FILE = "workbench/site.json";
|
|
4
|
+
/** One page of the site, as workbench/site.json records it. */
|
|
5
|
+
export interface SitePageRecord {
|
|
6
|
+
recipe: string;
|
|
7
|
+
/** The recipe's version it was built from. */
|
|
8
|
+
version: number;
|
|
9
|
+
/** Its address, or null for the Not found page. */
|
|
10
|
+
path: string | null;
|
|
11
|
+
/** Who may open it: anyone, a signed-in user, or one of the app's admins. */
|
|
12
|
+
access: "public" | "members" | "admin";
|
|
13
|
+
frame: FrameName;
|
|
14
|
+
/** The page's file, from the project's root. */
|
|
15
|
+
file: string;
|
|
16
|
+
/** built: by Workbench, not yet gone over with the owner. checked: gone over and the owner's words in. changed: the project's Claude changed it. */
|
|
17
|
+
state: "built" | "checked" | "changed";
|
|
18
|
+
}
|
|
19
|
+
export interface SiteRecord {
|
|
20
|
+
format: 1;
|
|
21
|
+
pages: SitePageRecord[];
|
|
22
|
+
}
|
|
23
|
+
export interface BuildOptions {
|
|
24
|
+
/** Reads a project file by its path from the project's root; undefined when it doesn't exist. */
|
|
25
|
+
read: (path: string) => string | undefined;
|
|
26
|
+
/** Lists a project folder's file names; undefined or empty when it doesn't exist. */
|
|
27
|
+
list?: (dir: string) => readonly string[] | undefined;
|
|
28
|
+
/** The recipe ids to add. Empty builds the always set (alwaysSet). */
|
|
29
|
+
add: readonly string[];
|
|
30
|
+
/** This package's version, written into the page files and the project's dependency. */
|
|
31
|
+
version: string;
|
|
32
|
+
/** The project's base locale: its words go into strings/strings.<base>.json. Defaults to en-AU. */
|
|
33
|
+
base?: string;
|
|
34
|
+
catalogue?: readonly Recipe[];
|
|
35
|
+
/** Stamps a new migration's file name. Defaults to now. */
|
|
36
|
+
now?: Date;
|
|
37
|
+
}
|
|
38
|
+
export interface BuildResult {
|
|
39
|
+
/** Path from the project's root to its new content. */
|
|
40
|
+
writes: Record<string, string>;
|
|
41
|
+
/** The recipes added, needed ones included, in build order. */
|
|
42
|
+
added: string[];
|
|
43
|
+
/** Asked for but already on the site. */
|
|
44
|
+
already: string[];
|
|
45
|
+
/** Why nothing can be written; when not empty, `writes` is empty. */
|
|
46
|
+
problems: string[];
|
|
47
|
+
/** The migrations written, for the owner's Claude to apply on staging (sb_migration_apply), then refresh supabase/staging-columns.json. */
|
|
48
|
+
migrations: string[];
|
|
49
|
+
/** True when a form's answers file was written, so `npm run forms` must run. */
|
|
50
|
+
forms: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The pages every project gets without being asked (docs/default-pages.md §3):
|
|
54
|
+
* the always tier, members pages left out (they come when the project has
|
|
55
|
+
* members, default pages step 4).
|
|
56
|
+
*/
|
|
57
|
+
export declare function alwaysSet(catalogue?: readonly Recipe[]): string[];
|
|
58
|
+
/** Builds the chosen recipes into the project; with none chosen, the always set. */
|
|
59
|
+
export declare function buildSite(o: BuildOptions): BuildResult;
|
|
60
|
+
/** One problem with the site's record, its page files or their words. */
|
|
61
|
+
export interface SiteCheckInput {
|
|
62
|
+
/** workbench/site.json. */
|
|
63
|
+
site: unknown;
|
|
64
|
+
/** The base strings catalogue. */
|
|
65
|
+
strings: Readonly<Record<string, string>>;
|
|
66
|
+
/** The page files, by path from the project's root (src/pages/<page>.ts). */
|
|
67
|
+
files: Readonly<Record<string, string>>;
|
|
68
|
+
/** Before go-live: a built page's word still in [square brackets] is a problem. */
|
|
69
|
+
live?: boolean;
|
|
70
|
+
catalogue?: readonly Recipe[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* check:site (docs/site-planner.md §10): every page in workbench/site.json has
|
|
74
|
+
* its file and a known recipe, no two share an address, and a page Workbench
|
|
75
|
+
* built (state built or checked) names only words the catalogue has. With
|
|
76
|
+
* `live`, also no word of a built page still waits for the owner. A page the
|
|
77
|
+
* project changed is its own: only its file is checked.
|
|
78
|
+
*/
|
|
79
|
+
export declare function siteProblems(i: SiteCheckInput): string[];
|