@divithselvam/jokebook 1.0.0 → 1.1.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 +35 -0
- package/README.md +27 -21
- package/bin/run.js +4 -1
- package/{docs → dist/catalog}/STACK.md +26 -0
- package/dist/catalog/index.json +4 -0
- package/dist/commands/add.d.ts +12 -4
- package/dist/commands/add.js +29 -24
- package/dist/commands/init.js +14 -24
- package/dist/commands/stack/list.d.ts +26 -15
- package/dist/commands/stack/list.js +184 -24
- package/dist/commands/stack/show.js +1 -0
- package/dist/commands/upgrade.d.ts +10 -0
- package/dist/commands/upgrade.js +55 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +71 -20
- package/dist/starter.d.ts +14 -0
- package/dist/starter.js +38 -0
- package/dist/starters/1.0.0/desktop.tgz +0 -0
- package/dist/starters/1.0.0/mobile.tgz +0 -0
- package/dist/{starter-1.0.0-web.tgz → starters/1.0.0/web.tgz} +0 -0
- package/dist/starters/1.1.0/desktop.tgz +0 -0
- package/dist/starters/1.1.0/mobile.tgz +0 -0
- package/dist/starters/1.1.0/web.tgz +0 -0
- package/dist/starters/index.json +21 -0
- package/dist/upgrade.d.ts +30 -0
- package/dist/upgrade.js +504 -0
- package/package.json +20 -5
- package/dist/starter-1.0.0-desktop.tgz +0 -0
- package/dist/starter-1.0.0-mobile.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Jokebook are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## [1.1.0] - 2026-12-01
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `jokebook upgrade` with `--check` and `--apply`: three-way merge against the bundled old and new starters, structural merges for `package.json` and `tauri.conf.json`, automatic text merges with `git merge-file`, and conflict refusal.
|
|
10
|
+
- Atomic upgrade writes with per-file backups, rollback after a failed write, path validation, and a report under `.jokebook/`.
|
|
11
|
+
- Catalog-only updates when the catalog changes without a starter revision bump.
|
|
12
|
+
- Machine-readable `jokebook-catalog` metadata in catalog 1.1.0, declaring section ownership, table headers and automated recipes.
|
|
13
|
+
- A bundled starter index at `dist/starters/index.json` and per-revision archive paths at `dist/starters/<revision>/<surface>.tgz`.
|
|
14
|
+
- Catalog-driven recipe resolution: ids, aliases, package, version, capability, summary and workspace come from the catalog instead of constants in commands.
|
|
15
|
+
- Packed-package verification of the tarball layout, catalog hash, starter index, version output, `stack list`, `stack show`, `init --dry-run` and outside-product `upgrade` refusal.
|
|
16
|
+
- Tests for catalog metadata, legacy catalog fallback, archive layout, clean upgrades, conflict refusal and catalog-only updates.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Package version and catalog/starter revisions are 1.1.0. Starter 1.1.0 reuses the verified 1.0.0 application sources; it updates agent guidance and generated READMEs and removes the placeholder catalog marker.
|
|
21
|
+
- The npm package ships only the current catalog at `dist/catalog/STACK.md`; every bundled starter revision remains available for upgrades.
|
|
22
|
+
- Generated `AGENTS.md` now explains the catalog contract, the upgrade check/apply workflow, conflict refusal and post-upgrade checks.
|
|
23
|
+
- Recipe and archive selection no longer hardcode versioned packument strings, archive filenames, catalog hashes, workspace paths or status text.
|
|
24
|
+
- `add` requires the current starter revision and tells older products to upgrade first.
|
|
25
|
+
- Documentation, `CONTRIBUTING.md` and release checks describe the new build layout and upgrade lifecycle.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Skill installation no longer fails when Jokebook itself runs through `npm exec --package=@divithselvam/jokebook`: the nested `npx` call no longer inherits npm's outer package selection.
|
|
30
|
+
- Upgrade plans no longer report success while unresolved conflicts remain, and a failed apply no longer leaves a half-updated marker.
|
|
31
|
+
- Starter extraction creates its destination before reading archives.
|
|
32
|
+
- Previously stale release metadata in `package.json`, `bin/run.js` and the verify script is derived from the package manifest and generated indexes.
|
|
33
|
+
|
|
34
|
+
### Security
|
|
35
|
+
|
|
36
|
+
- Upgrade refuses absolute paths, paths that escape the product, and non-file replacement targets.
|
|
37
|
+
- Upgrade restores every touched file when an application step fails.
|
|
38
|
+
|
|
5
39
|
## [1.0.0] - 2026-11-30
|
|
6
40
|
|
|
7
41
|
### Added
|
|
@@ -26,4 +60,5 @@ All notable changes to Jokebook are documented here. The format follows [Keep a
|
|
|
26
60
|
- Existing non-empty destinations are refused.
|
|
27
61
|
- A staged product is moved into place only after dependency installation, recipe checks and both skill verifications succeed.
|
|
28
62
|
|
|
63
|
+
[1.1.0]: https://github.com/Divith123/jokebook/releases/tag/v1.1.0
|
|
29
64
|
[1.0.0]: https://github.com/Divith123/jokebook/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Jokebook is a versioned project generator for production-minded web products. One command creates a pnpm workspace with a SvelteKit web app, a Rust/Axum API, PostgreSQL development configuration, and optional Tauri desktop and shared-Swift native mobile clients.
|
|
7
7
|
|
|
8
|
-
Every generated product carries a byte-for-byte copy of the architecture and package catalog it was built from, plus two project-local agent skills whose source commits are recorded in `skills-lock.json`. Generation is staged, checked, and moved into place only after dependency installation and skill verification succeed.
|
|
8
|
+
Every generated product carries a byte-for-byte copy of the architecture and package catalog it was built from, plus two project-local agent skills whose source commits are recorded in `skills-lock.json`. Generation is staged, checked, and moved into place only after dependency installation and skill verification succeed. Existing products can merge a newer bundled starter with `jokebook upgrade` without discarding local edits.
|
|
9
9
|
|
|
10
10
|
## Requirements
|
|
11
11
|
|
|
@@ -51,6 +51,7 @@ jokebook init [product] [--preset web|desktop|mobile|full] [--dir <path>] [--wit
|
|
|
51
51
|
jokebook stack list [--json]
|
|
52
52
|
jokebook stack show <capability> [--json]
|
|
53
53
|
jokebook add <recipe> [--no-interactive] [--json] [--dry-run]
|
|
54
|
+
jokebook upgrade [--check | --apply] [--json]
|
|
54
55
|
jokebook --help
|
|
55
56
|
jokebook --version
|
|
56
57
|
```
|
|
@@ -69,13 +70,21 @@ The command exits `0` on success, `1` on failure and `130` on cancellation. `--j
|
|
|
69
70
|
|
|
70
71
|
`stack list` and `stack show` are read-only. Inside a generated product they read that product's pinned `STACK.md` and verify its SHA-256. Elsewhere they read the catalog bundled with the CLI.
|
|
71
72
|
|
|
72
|
-
`stack show` accepts a capability slug from `stack list` or a unique backticked package name. It reports the recommendation,
|
|
73
|
+
Capability rows, sections, table headers, workspace ownership and automated recipes come from the catalog's machine-readable metadata. `stack show` accepts a capability slug from `stack list` or a unique backticked package name. It reports the recommendation, versions, owning workspace, source row and links, setup notes and recipe status.
|
|
73
74
|
|
|
74
75
|
### `add`
|
|
75
76
|
|
|
76
|
-
`add runtime-validation` (alias `valibot`) resolves the
|
|
77
|
+
`add runtime-validation` (alias `valibot`) resolves the package and exact version declared by the catalog recipe, installs it in the recipe's workspace with the product's pnpm workspace, and verifies a real import. It can also be selected with `init --with runtime-validation`. Repeating the recipe verifies the existing installation and makes no change.
|
|
77
78
|
|
|
78
|
-
Catalog capabilities without an automated recipe return their documented setup guidance and leave the product untouched. Run `add` from the product directory or any of its subdirectories.
|
|
79
|
+
Automated recipes require the current starter revision. If the product is older, run `jokebook upgrade --apply` first. Catalog capabilities without an automated recipe return their documented setup guidance and leave the product untouched. Run `add` from the product directory or any of its subdirectories.
|
|
80
|
+
|
|
81
|
+
### `upgrade`
|
|
82
|
+
|
|
83
|
+
`upgrade --check` plans a three-way merge between the bundled old and new starters and reports added, updated, merged and removed files. It writes nothing. `upgrade --apply` writes the same plan only when there are no conflicts.
|
|
84
|
+
|
|
85
|
+
Jokebook keeps local edits. Text files use `git merge-file`; `package.json` and `tauri.conf.json` use a semantic three-way merge; new and removed files are compared against the bundled old starter. A conflict blocks the whole plan: `--apply` refuses to change any file and exits non-zero. Applied writes are atomic, and a failed write restores every touched file from its backup.
|
|
86
|
+
|
|
87
|
+
A completed upgrade writes a report under `.jokebook/`, updates the product marker and moves the pinned catalog when needed. A catalog-only release is handled without changing the starter revision. Review the report and `git diff`, run `pnpm install` if dependencies changed, then run the product checks.
|
|
79
88
|
|
|
80
89
|
## What a product contains
|
|
81
90
|
|
|
@@ -88,14 +97,14 @@ my-product/
|
|
|
88
97
|
services/api/ Rust/Axum HTTP API
|
|
89
98
|
packages/ Shared workspace packages
|
|
90
99
|
STACK.md Pinned architecture and package catalog
|
|
91
|
-
AGENTS.md
|
|
100
|
+
AGENTS.md Agent guidance for the catalog and update workflow
|
|
92
101
|
skills-lock.json Skills CLI provenance for both project skills
|
|
93
102
|
pnpm-workspace.yaml One pnpm workspace and root lockfile
|
|
94
103
|
Cargo.toml Rust workspace
|
|
95
|
-
package.json Product marker, preset and catalog hash
|
|
104
|
+
package.json Product marker, preset, catalog revision and catalog hash
|
|
96
105
|
```
|
|
97
106
|
|
|
98
|
-
The generated `README.md` covers development commands, the API and readiness endpoints, production static hosting, native prerequisites
|
|
107
|
+
The generated `README.md` covers development commands, the API and readiness endpoints, production static hosting, native prerequisites, catalog lookup and the upgrade workflow.
|
|
99
108
|
|
|
100
109
|
## How generation works
|
|
101
110
|
|
|
@@ -111,11 +120,13 @@ If any step fails, the staging directory is removed and an existing empty destin
|
|
|
111
120
|
|
|
112
121
|
## Catalog and recipes
|
|
113
122
|
|
|
114
|
-
`
|
|
123
|
+
The canonical catalog lives at `catalogs/<revision>/STACK.md`. Catalog `1.1.0` is the current revision, with SHA-256 `14f8bf06942076bf593e89e20f6413677fbf8f0cf4aee9151fbe87e604150e17`. Catalog `1.0.0` remains bundled as the frozen upgrade base at SHA-256 `850953320cc8e9093b9c3286e4279596dbdd274319e2b60ab648977ae4e90307`.
|
|
115
124
|
|
|
116
|
-
|
|
125
|
+
The `1.1.0` catalog adds a machine-readable `jokebook-catalog` block that declares section ownership, table headers and recipes. Its Markdown content is otherwise identical to `1.0.0`. The frozen `1.0.0` catalog predates that block, so the CLI keeps a clearly marked legacy section map for it only.
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
Every generated product gets a byte-for-byte copy of the catalog bundled with its starter. The CLI refuses to continue if a product's `STACK.md` no longer matches the hash recorded in its `package.json`. The published package contains only the current catalog at `dist/catalog/STACK.md`; bundled starter revisions live under `dist/starters/<revision>/<surface>.tgz`.
|
|
128
|
+
|
|
129
|
+
`runtime-validation` is the only automated recipe because it has a real, repeatable integration check. Other capabilities remain documented recommendations; they are not installed blindly. Recipe aliases, implementation, package, summary, workspace and capability target all come from the catalog metadata.
|
|
119
130
|
|
|
120
131
|
## Agent skills
|
|
121
132
|
|
|
@@ -124,12 +135,7 @@ Every real `init` installs these two skills with the pinned Skills CLI 1.9.1, fr
|
|
|
124
135
|
- `Divith123/skills` → `blame-the-intern`
|
|
125
136
|
- `googlechrome/modern-web-guidance` → `modern-web-guidance`
|
|
126
137
|
|
|
127
|
-
Both use the project-local `universal` target and copy mode. Jokebook verifies each `SKILL.md` identity and the source repository and commit recorded by the Skills CLI.
|
|
128
|
-
|
|
129
|
-
```text
|
|
130
|
-
Use `blame-the-intern` from `.agents/skills/blame-the-intern/SKILL.md` and read `STACK.md` before scaffolding or changing dependencies.
|
|
131
|
-
Use `modern-web-guidance` from `.agents/skills/modern-web-guidance/SKILL.md` for browser UI, accessibility, and web performance.
|
|
132
|
-
```
|
|
138
|
+
Both use the project-local `universal` target and copy mode. Jokebook verifies each `SKILL.md` identity and the source repository and commit recorded by the Skills CLI. The starter's `AGENTS.md` then tells agents to load both skills, read `STACK.md` before scaffolding or changing dependencies, and use `jokebook upgrade --check` before `--apply`.
|
|
133
139
|
|
|
134
140
|
No agent command or global skill installation is required after generation.
|
|
135
141
|
|
|
@@ -148,7 +154,7 @@ npm ci
|
|
|
148
154
|
npm run verify
|
|
149
155
|
```
|
|
150
156
|
|
|
151
|
-
`npm run verify` runs ESLint, the test suite and a packed-package smoke test. The smoke test
|
|
157
|
+
`npm run verify` runs ESLint, the test suite and a packed-package smoke test. The smoke test packs the npm tarball, inspects its contents, checks the bundled catalog and starter indexes, then runs `jokebook --version`, `stack list`, `stack show`, an `init --dry-run` and an `upgrade` refusal outside a product. It also covers catalog-only and starter upgrades, conflict refusal, catalog parsing and archive contents. `npm run verify:package` runs only the package check.
|
|
152
158
|
|
|
153
159
|
Before a release, inspect the package and run a publish dry run:
|
|
154
160
|
|
|
@@ -157,11 +163,11 @@ npm pack
|
|
|
157
163
|
npm publish --access public --dry-run
|
|
158
164
|
```
|
|
159
165
|
|
|
160
|
-
`prepublishOnly` runs `npm run verify`, so a publish cannot bypass the local gate. `npm run build`
|
|
166
|
+
`prepublishOnly` runs `npm run verify`, so a publish cannot bypass the local gate. `npm run build` compiles the CLI, copies the current catalog to `dist/catalog/` and creates a `web`, `desktop` and `mobile` archive for every bundled starter revision under `dist/starters/`. The old `1.0.0` revision stays available as the upgrade base.
|
|
161
167
|
|
|
162
168
|
## Starter provenance
|
|
163
169
|
|
|
164
|
-
Starter **1.0.0**
|
|
170
|
+
Starter **1.1.0** reuses the verified `1.0.0` application sources. It updates `AGENTS.md` and the generated READMEs for the catalog and upgrade contract, and removes the placeholder catalog marker from `package.json` so generation writes the real marker. Starter **1.0.0** remains frozen with the 30 November 2026 catalog at SHA-256 `850953320cc8e9093b9c3286e4279596dbdd274319e2b60ab648977ae4e90307`.
|
|
165
171
|
|
|
166
172
|
| Source | Generation |
|
|
167
173
|
| --- | --- |
|
|
@@ -174,9 +180,9 @@ Starter **1.0.0** preserves the 30 November 2026 catalog at SHA-256 `850953320cc
|
|
|
174
180
|
| Mobile | Hand-written SwiftPM `MobileCore` and `MobileCoreAndroid` targets, SwiftUI app, Jetpack Compose app, swift-java 0.7.0 JNI bindings, Swift 6.4.3, Kotlin 2.4.21, Compose BOM 2026.09.00, Gradle 9.5.0 and NDK r30 |
|
|
175
181
|
| Skills | Vercel Skills CLI 1.9.1, run locally with `--agent universal --copy --yes` |
|
|
176
182
|
|
|
177
|
-
Refresh starter sources with the upstream generators, verify the resulting workspace locks and target builds, then
|
|
183
|
+
Refresh starter sources with the upstream generators, verify the resulting workspace locks and target builds, then publish a new starter revision and catalog metadata before packing. The Jokebook source repository uses npm to build and distribute the CLI; each generated product uses pnpm.
|
|
178
184
|
|
|
179
|
-
Release verification for 1.
|
|
185
|
+
Release verification for 1.1.0 runs on macOS on Apple silicon. The CLI and starter use cross-platform Node APIs, but Linux and Windows native builds are not part of the 1.1.0 verification matrix. The generated README lists the host-specific prerequisites.
|
|
180
186
|
|
|
181
187
|
## Contributing
|
|
182
188
|
|
package/bin/run.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import {readFile} from 'node:fs/promises'
|
|
4
|
+
|
|
3
5
|
if (Object.hasOwn(process.env, 'NO_COLOR')) delete process.env.FORCE_COLOR
|
|
6
|
+
const manifest = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
|
|
4
7
|
const {run, flush, Errors} = await import('@oclif/core')
|
|
5
8
|
try {
|
|
6
9
|
await run(process.argv.slice(2), import.meta.url)
|
|
@@ -14,7 +17,7 @@ try {
|
|
|
14
17
|
stage: 'arguments',
|
|
15
18
|
settings: null,
|
|
16
19
|
destination: null,
|
|
17
|
-
starterRevision:
|
|
20
|
+
starterRevision: manifest.jokebook?.starter ?? null,
|
|
18
21
|
installedSkills: [],
|
|
19
22
|
error: {message: error.message},
|
|
20
23
|
usage: 'Try: jokebook --help',
|
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
30 November 2026 · Web, desktop, mobile, collaboration, AI, data, and production infrastructure
|
|
4
4
|
|
|
5
|
+
<!-- jokebook-catalog
|
|
6
|
+
{
|
|
7
|
+
"recipes": [
|
|
8
|
+
{
|
|
9
|
+
"aliases": ["valibot"],
|
|
10
|
+
"capability": "runtime-validation",
|
|
11
|
+
"id": "runtime-validation",
|
|
12
|
+
"implementation": "valibot",
|
|
13
|
+
"package": "valibot",
|
|
14
|
+
"summary": "Browser-side input validation",
|
|
15
|
+
"workspace": "apps/web"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"sections": [
|
|
19
|
+
{"heading": "The decision", "header": "Surface", "workspace": "Root architecture and platform foundations"},
|
|
20
|
+
{"heading": "Web package catalog", "header": "Capability", "workspace": "apps/web"},
|
|
21
|
+
{"heading": "Rust API and worker packages", "header": "Capability", "workspace": "services/api and Cargo workspace"},
|
|
22
|
+
{"heading": "Desktop packages and operating-system integration", "header": "Capability", "workspace": "apps/desktop"},
|
|
23
|
+
{"heading": "Mobile packages and operating-system integration", "header": "Capability", "workspace": "apps/mobile"},
|
|
24
|
+
{"heading": "Data, synchronization, search, analytics and AI", "header": "Capability", "workspace": "services and infrastructure, with client integration as specified"},
|
|
25
|
+
{"heading": "Smaller packages that matter in specialized products", "header": "Capability", "workspace": "Depends on capability. See setup."},
|
|
26
|
+
{"heading": "Monorepo, delivery and operations", "header": "Capability", "workspace": "Workspace root, tooling and infrastructure"}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
-->
|
|
30
|
+
|
|
5
31
|
## The decision
|
|
6
32
|
|
|
7
33
|
**Build the web application in Svelte 5 and SvelteKit 3, with Vite+ for web tooling. Keep Rust in the backend and desktop core. Use Tauri for the general desktop client, GPUI for a desktop-first product that warrants its own renderer, and a shared Swift core with native SwiftUI and Jetpack Compose shells for mobile.** PostgreSQL owns durable server state. Add SQLite and PowerSync when the product promises offline writes. Use a CRDT for the collaborative document itself when independent clients must merge edits. [1](<https://www.npmjs.com/package/svelte?activeTab=versions>) [2](<https://www.npmjs.com/package/%40sveltejs/kit?activeTab=versions>) [3](<https://voidzero.dev/posts/announcing-vite-plus-1-0>) [4](<https://v2.tauri.app/release>) [5](<https://zed.dev/blog/zed-1-0>) [6](<https://github.com/swiftlang/swift/releases/tag/swift-6.4.3-RELEASE>) [7](<https://powersync.com/blog/moving-the-powersync-service-to-apache>) [8](<https://github.com/loro-dev/loro>)
|
package/dist/commands/add.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import { findProduct, Workflow } from '../index.js';
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { type CatalogRecipe, type CatalogRow } from './stack/list.js';
|
|
4
|
+
export type RecipeSpec = CatalogRecipe & {
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
type Catalog = {
|
|
8
|
+
recipes: CatalogRecipe[];
|
|
9
|
+
rows: CatalogRow[];
|
|
10
|
+
};
|
|
11
|
+
export declare function catalogRecipes(markdown: string): Catalog;
|
|
12
|
+
export declare function resolveRecipe(name: string, product?: Awaited<ReturnType<typeof findProduct>>): Promise<RecipeSpec>;
|
|
13
|
+
export declare function applyRecipe(workflow: Workflow, cwd: string, recipe: RecipeSpec, isDryRun: boolean): Promise<{
|
|
7
14
|
alreadyApplied: boolean;
|
|
8
15
|
changed: boolean;
|
|
9
16
|
dryRun: boolean;
|
|
@@ -23,3 +30,4 @@ export default class Add extends Command {
|
|
|
23
30
|
};
|
|
24
31
|
run(): Promise<void>;
|
|
25
32
|
}
|
|
33
|
+
export {};
|
package/dist/commands/add.js
CHANGED
|
@@ -2,23 +2,28 @@ import { Args, Command, Flags } from '@oclif/core';
|
|
|
2
2
|
import { lstat, mkdir, readFile, rmdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { catalogDocument, findProduct, Issue, readJson, release, slug, Workflow } from '../index.js';
|
|
5
|
-
import {
|
|
6
|
-
export const recipeName = 'runtime-validation';
|
|
7
|
-
export const recipePackage = 'valibot';
|
|
8
|
-
const recipeVersion = '1.5.0';
|
|
5
|
+
import { compileCatalog, lookup, recipeVersion } from './stack/list.js';
|
|
9
6
|
const usage = 'Try: jokebook add runtime-validation --no-interactive (from a Jokebook product)';
|
|
7
|
+
export function catalogRecipes(markdown) {
|
|
8
|
+
const catalog = compileCatalog(markdown);
|
|
9
|
+
return { recipes: catalog.metadata?.recipes ?? [], rows: catalog.rows };
|
|
10
|
+
}
|
|
10
11
|
export async function resolveRecipe(name, product) {
|
|
11
|
-
if ([recipeName, recipePackage].includes(slug(name)))
|
|
12
|
-
return recipeName;
|
|
13
12
|
const { text } = await catalogDocument(product);
|
|
14
|
-
const
|
|
13
|
+
const catalog = catalogRecipes(text);
|
|
14
|
+
const id = slug(name);
|
|
15
|
+
const recipe = catalog.recipes.find(({ aliases, id: recipeId }) => recipeId === id || aliases.includes(id));
|
|
16
|
+
if (recipe) {
|
|
17
|
+
return { ...recipe, version: recipeVersion(catalog.rows, recipe) };
|
|
18
|
+
}
|
|
19
|
+
const capability = lookup(catalog.rows, name);
|
|
15
20
|
if (capability) {
|
|
16
21
|
throw new Issue('This capability requires manual integration. Follow the catalog setup instructions.', { capability });
|
|
17
22
|
}
|
|
18
23
|
throw new Issue(`Unknown recipe "${name}". Run jokebook stack list to find a capability.`);
|
|
19
24
|
}
|
|
20
|
-
async function inspect(cwd) {
|
|
21
|
-
const workspace = path.join(cwd,
|
|
25
|
+
async function inspect(cwd, recipe) {
|
|
26
|
+
const workspace = path.join(cwd, recipe.workspace);
|
|
22
27
|
const manifest = path.join(workspace, 'package.json');
|
|
23
28
|
const lockfile = path.join(cwd, 'pnpm-lock.yaml');
|
|
24
29
|
const root = path.join(cwd, 'package.json');
|
|
@@ -33,27 +38,27 @@ async function inspect(cwd) {
|
|
|
33
38
|
const contents = await readFile(manifest, 'utf8');
|
|
34
39
|
const data = JSON.parse(contents);
|
|
35
40
|
const declarations = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
|
|
36
|
-
.filter((group) => data[group]?.[
|
|
41
|
+
.filter((group) => data[group]?.[recipe.package] !== undefined);
|
|
37
42
|
const isApplied = declarations.length === 1 && declarations[0] === 'dependencies' &&
|
|
38
|
-
data.dependencies?.[
|
|
43
|
+
data.dependencies?.[recipe.package] === recipe.version;
|
|
39
44
|
if (!isApplied && declarations.length > 0) {
|
|
40
|
-
throw new Issue(
|
|
45
|
+
throw new Issue(`${recipe.workspace} already declares ${recipe.package} in a conflicting form. Review that declaration before applying this recipe.`);
|
|
41
46
|
}
|
|
42
47
|
return { contents, isApplied, lockfile, manifest };
|
|
43
48
|
}
|
|
44
49
|
export async function applyRecipe(workflow, cwd, recipe, isDryRun) {
|
|
45
50
|
workflow.stage = 'recipe-inspection';
|
|
46
|
-
if (recipe !==
|
|
47
|
-
throw new Issue(`Unknown
|
|
48
|
-
const current = await inspect(cwd);
|
|
49
|
-
const spec = `${
|
|
51
|
+
if (recipe.implementation !== 'valibot')
|
|
52
|
+
throw new Issue(`Unknown recipe implementation "${recipe.implementation}".`);
|
|
53
|
+
const current = await inspect(cwd, recipe);
|
|
54
|
+
const spec = `${recipe.package}@${recipe.version}`;
|
|
50
55
|
const result = {
|
|
51
56
|
alreadyApplied: current.isApplied,
|
|
52
57
|
changed: !current.isApplied && !isDryRun,
|
|
53
58
|
dryRun: isDryRun,
|
|
54
59
|
package: spec,
|
|
55
|
-
recipe,
|
|
56
|
-
workspace:
|
|
60
|
+
recipe: recipe.id,
|
|
61
|
+
workspace: recipe.workspace,
|
|
57
62
|
};
|
|
58
63
|
if (isDryRun)
|
|
59
64
|
return result;
|
|
@@ -68,22 +73,22 @@ export async function applyRecipe(workflow, cwd, recipe, isDryRun) {
|
|
|
68
73
|
throw error;
|
|
69
74
|
}
|
|
70
75
|
try {
|
|
71
|
-
const { contents, isApplied, lockfile, manifest } = await inspect(cwd);
|
|
76
|
+
const { contents, isApplied, lockfile, manifest } = await inspect(cwd, recipe);
|
|
72
77
|
const previousLock = await readFile(lockfile);
|
|
73
78
|
workflow.stage = 'recipe-installation';
|
|
74
79
|
try {
|
|
75
80
|
if (!isApplied) {
|
|
76
|
-
await workflow.command('pnpm', ['--filter',
|
|
81
|
+
await workflow.command('pnpm', ['--filter', `./${recipe.workspace}`, 'add', '--save-exact', '--lockfile-only', spec], {
|
|
77
82
|
cwd,
|
|
78
|
-
deliverable: `resolve ${spec} for
|
|
83
|
+
deliverable: `resolve ${spec} for ${recipe.workspace}`,
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
86
|
await workflow.command('pnpm', ['install', '--frozen-lockfile'], { cwd, deliverable: 'install recipe dependencies' });
|
|
82
87
|
workflow.stage = 'recipe-verification';
|
|
83
|
-
await workflow.command('pnpm', ['--filter',
|
|
84
|
-
'-e',
|
|
88
|
+
await workflow.command('pnpm', ['--filter', `./${recipe.workspace}`, 'exec', 'node', '--input-type=module',
|
|
89
|
+
'-e', `import {parse, string} from '${recipe.package}'; if (parse(string(), 'ready') !== 'ready') process.exit(1)`], {
|
|
85
90
|
cwd,
|
|
86
|
-
deliverable: `verify ${spec} from
|
|
91
|
+
deliverable: `verify ${spec} from ${recipe.workspace}`,
|
|
87
92
|
});
|
|
88
93
|
return { ...result, alreadyApplied: isApplied, changed: !isApplied };
|
|
89
94
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as prompts from '@clack/prompts';
|
|
2
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
3
|
-
import {
|
|
3
|
+
import { lstat, mkdtemp, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { applyRecipe,
|
|
5
|
+
import { assertDestination, catalogDocument, Issue, isUnattended, presets, readJson, release, resolveDestination, skills, Workflow, } from '../index.js';
|
|
6
|
+
import { extractStarter } from '../starter.js';
|
|
7
|
+
import { applyRecipe, catalogRecipes, resolveRecipe } from './add.js';
|
|
8
8
|
const usage = 'Try: jokebook init my-product --preset web --dir ./my-product --no-interactive';
|
|
9
9
|
const presetNames = Object.keys(presets);
|
|
10
10
|
function productError(value = '') {
|
|
@@ -43,10 +43,10 @@ async function promptPreset() {
|
|
|
43
43
|
})),
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
46
|
-
async function promptRecipes() {
|
|
46
|
+
async function promptRecipes(recipes) {
|
|
47
47
|
return answered(await prompts.multiselect({
|
|
48
48
|
message: 'Optional recipes',
|
|
49
|
-
options:
|
|
49
|
+
options: recipes.map(({ id, package: packageName, summary }) => ({ hint: summary, label: packageName, value: id })),
|
|
50
50
|
required: false,
|
|
51
51
|
}));
|
|
52
52
|
}
|
|
@@ -97,32 +97,21 @@ async function applyRecipes(workflow, stage, recipes, index = 0) {
|
|
|
97
97
|
const recipe = recipes[index];
|
|
98
98
|
if (!recipe)
|
|
99
99
|
return;
|
|
100
|
-
await applyRecipe(workflow, stage, recipe, false);
|
|
100
|
+
await applyRecipe(workflow, stage, await resolveRecipe(recipe), false);
|
|
101
101
|
await applyRecipes(workflow, stage, recipes, index + 1);
|
|
102
102
|
}
|
|
103
103
|
async function materialize(workflow, settings) {
|
|
104
104
|
const { destination, preset, product, recipes } = settings;
|
|
105
105
|
const isDesktop = ['desktop', 'full'].includes(preset);
|
|
106
|
-
const isMobile = ['full', 'mobile'].includes(preset);
|
|
107
106
|
workflow.stage = 'generation';
|
|
108
107
|
const stage = await mkdtemp(path.join(path.dirname(destination), '.jokebook-'));
|
|
109
108
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const apps = path.join(stage, 'apps');
|
|
114
|
-
await mkdir(apps, { recursive: true });
|
|
115
|
-
await extract({
|
|
116
|
-
cwd: apps,
|
|
117
|
-
file: packageFile(`./starter-${release.revision}-mobile.tgz`),
|
|
118
|
-
strict: true,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
await catalogDocument();
|
|
122
|
-
await copyFile(packageFile('../docs/STACK.md'), path.join(stage, 'STACK.md'));
|
|
109
|
+
await extractStarter(release.revision, preset, stage);
|
|
110
|
+
const { digest, text } = await catalogDocument();
|
|
111
|
+
await writeFile(path.join(stage, 'STACK.md'), text);
|
|
123
112
|
const manifest = path.join(stage, 'package.json');
|
|
124
113
|
const starterManifest = await readJson(manifest);
|
|
125
|
-
const marker = { preset, stackSha256:
|
|
114
|
+
const marker = { catalog: release.catalog, preset, stackSha256: digest, starter: release.revision };
|
|
126
115
|
await writeFile(manifest, JSON.stringify({ ...starterManifest, jokebook: marker, name: product }, null, 2) + '\n');
|
|
127
116
|
if (isDesktop) {
|
|
128
117
|
const configFile = path.join(stage, 'apps/desktop/src-tauri/tauri.conf.json');
|
|
@@ -166,7 +155,7 @@ export default class Init extends Command {
|
|
|
166
155
|
json: Flags.boolean({ description: 'Emit a single JSON result without prompts' }),
|
|
167
156
|
'no-interactive': Flags.boolean({ description: 'Resolve input without prompts' }),
|
|
168
157
|
preset: Flags.string({ description: 'Surface preset (default: web)', options: presetNames }),
|
|
169
|
-
with: Flags.string({ description:
|
|
158
|
+
with: Flags.string({ description: 'Apply an automated catalog recipe (repeat for each recipe)', multiple: true }),
|
|
170
159
|
};
|
|
171
160
|
async run() {
|
|
172
161
|
const workflow = new Workflow('init');
|
|
@@ -177,6 +166,7 @@ export default class Init extends Command {
|
|
|
177
166
|
throw new Issue('--interactive requires a usable terminal outside CI and conflicts with --no-interactive and --json.');
|
|
178
167
|
}
|
|
179
168
|
await Promise.all((flags.with ?? []).map(async (recipe) => resolveRecipe(recipe)));
|
|
169
|
+
const catalog = catalogRecipes((await catalogDocument()).text);
|
|
180
170
|
const product = args.product ?? (canPrompt ? await promptProduct() : undefined);
|
|
181
171
|
if (!product)
|
|
182
172
|
throw new Issue('Supply a product name in non-interactive mode.');
|
|
@@ -185,7 +175,7 @@ export default class Init extends Command {
|
|
|
185
175
|
throw new Issue(invalid);
|
|
186
176
|
const dir = flags.dir ?? (canPrompt ? await promptDestination(product) : product);
|
|
187
177
|
const preset = flags.preset ?? (canPrompt ? await promptPreset() : 'web');
|
|
188
|
-
const recipes = flags.with ?? (canPrompt ? await promptRecipes() : []);
|
|
178
|
+
const recipes = flags.with ?? (canPrompt ? await promptRecipes(catalog.recipes) : []);
|
|
189
179
|
workflow.stage = 'destination';
|
|
190
180
|
const settings = {
|
|
191
181
|
destination: await resolveDestination(dir),
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
export
|
|
2
|
+
export type CatalogRecipe = {
|
|
3
|
+
aliases: string[];
|
|
3
4
|
capability: string;
|
|
4
5
|
id: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
status: string;
|
|
15
|
-
versions: string[];
|
|
6
|
+
implementation: string;
|
|
7
|
+
package: string;
|
|
8
|
+
summary: string;
|
|
9
|
+
workspace: string;
|
|
10
|
+
};
|
|
11
|
+
type CatalogSection = {
|
|
12
|
+
header: string;
|
|
13
|
+
heading: string;
|
|
16
14
|
workspace: string;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
15
|
+
};
|
|
16
|
+
export type CatalogMetadata = {
|
|
17
|
+
recipes: CatalogRecipe[];
|
|
18
|
+
sections: CatalogSection[];
|
|
19
|
+
};
|
|
20
|
+
export type CatalogRow = {
|
|
19
21
|
capability: string;
|
|
20
22
|
id: string;
|
|
21
|
-
recipe: string |
|
|
23
|
+
recipe: string | undefined;
|
|
22
24
|
section: string;
|
|
23
25
|
selection: string;
|
|
24
26
|
setup: string;
|
|
@@ -31,6 +33,14 @@ export declare function lookup(catalog: ReturnType<typeof entries>, capability:
|
|
|
31
33
|
versions: string[];
|
|
32
34
|
workspace: string;
|
|
33
35
|
};
|
|
36
|
+
export declare function catalogMetadata(markdown: string): CatalogMetadata | undefined;
|
|
37
|
+
export declare function compileCatalog(markdown: string): {
|
|
38
|
+
metadata: CatalogMetadata | undefined;
|
|
39
|
+
rows: CatalogRow[];
|
|
40
|
+
};
|
|
41
|
+
export declare function entries(markdown: string): CatalogRow[];
|
|
42
|
+
export declare function recipeVersion(rows: CatalogRow[], recipe: CatalogRecipe): string;
|
|
43
|
+
export declare function lookup(catalog: ReturnType<typeof entries>, capability: string): CatalogRow;
|
|
34
44
|
export default class List extends Command {
|
|
35
45
|
static description: string;
|
|
36
46
|
static flags: {
|
|
@@ -38,3 +48,4 @@ export default class List extends Command {
|
|
|
38
48
|
};
|
|
39
49
|
run(): Promise<void>;
|
|
40
50
|
}
|
|
51
|
+
export {};
|