@lemonadecms/create 0.0.0-stage → 0.1.1

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +42 -2
  4. package/bin/create-lemonade.mjs +124 -0
  5. package/dist/catalog.json +772 -0
  6. package/dist/templates/angular/angular.json +54 -0
  7. package/dist/templates/angular/locks/npm-lock.json.template +7079 -0
  8. package/dist/templates/angular/locks/pnpm-lock.yaml.template +4237 -0
  9. package/dist/templates/angular/locks/yarn.lock.template +4899 -0
  10. package/dist/templates/angular/package.json +68 -0
  11. package/dist/templates/angular/src/app/app.config.server.ts +23 -0
  12. package/dist/templates/angular/src/app/app.config.ts +34 -0
  13. package/dist/templates/angular/src/app/app.ts +9 -0
  14. package/dist/templates/angular/src/app/blog.service.ts +74 -0
  15. package/dist/templates/angular/src/app/journal.html +71 -0
  16. package/dist/templates/angular/src/app/journal.ts +47 -0
  17. package/dist/templates/angular/src/index.html +14 -0
  18. package/dist/templates/angular/src/main.server.ts +5 -0
  19. package/dist/templates/angular/src/main.ts +6 -0
  20. package/dist/templates/angular/src/server.ts +79 -0
  21. package/dist/templates/angular/tsconfig.app.json +8 -0
  22. package/dist/templates/angular/tsconfig.json +21 -0
  23. package/dist/templates/angular/vendor/README.md +32 -0
  24. package/dist/templates/angular/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
  25. package/dist/templates/angular/vendor/picomatch-4.0.7.patch +59 -0
  26. package/dist/templates/angular/vendor/provenance.json +29 -0
  27. package/dist/templates/astro/astro.config.mjs +7 -0
  28. package/dist/templates/astro/locks/npm-lock.json.template +5478 -0
  29. package/dist/templates/astro/locks/pnpm-lock.yaml.template +3537 -0
  30. package/dist/templates/astro/locks/yarn.lock.template +4085 -0
  31. package/dist/templates/astro/package.json +51 -0
  32. package/dist/templates/astro/src/components/BlogView.astro +92 -0
  33. package/dist/templates/astro/src/layouts/Site.astro +23 -0
  34. package/dist/templates/astro/src/pages/articles/[id].astro +13 -0
  35. package/dist/templates/astro/src/pages/index.astro +13 -0
  36. package/dist/templates/astro/src/pages/lemonade/preview/[...path].ts +4 -0
  37. package/dist/templates/astro/src/pages/lemonade/preview.ts +4 -0
  38. package/dist/templates/astro/tsconfig.json +9 -0
  39. package/dist/templates/astro/vendor/README.md +32 -0
  40. package/dist/templates/astro/vendor/picomatch-2.3.2-lemonade-sec51.1.tgz +0 -0
  41. package/dist/templates/astro/vendor/picomatch-2.3.2.patch +59 -0
  42. package/dist/templates/astro/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
  43. package/dist/templates/astro/vendor/picomatch-4.0.7.patch +59 -0
  44. package/dist/templates/astro/vendor/provenance.json +43 -0
  45. package/dist/templates/next/app/articles/[id]/page.tsx +29 -0
  46. package/dist/templates/next/app/data.ts +12 -0
  47. package/dist/templates/next/app/error.tsx +15 -0
  48. package/dist/templates/next/app/layout.tsx +13 -0
  49. package/dist/templates/next/app/lemonade/preview/[[...path]]/route.ts +7 -0
  50. package/dist/templates/next/app/loading.tsx +7 -0
  51. package/dist/templates/next/app/not-found.tsx +8 -0
  52. package/dist/templates/next/app/page.tsx +17 -0
  53. package/dist/templates/next/app/view.tsx +111 -0
  54. package/dist/templates/next/locks/npm-lock.json.template +1158 -0
  55. package/dist/templates/next/locks/pnpm-lock.yaml.template +715 -0
  56. package/dist/templates/next/locks/yarn.lock.template +775 -0
  57. package/dist/templates/next/next-env.d.ts +2 -0
  58. package/dist/templates/next/next.config.mjs +8 -0
  59. package/dist/templates/next/package.json +44 -0
  60. package/dist/templates/next/proxy.ts +19 -0
  61. package/dist/templates/next/tsconfig.json +25 -0
  62. package/dist/templates/nuxt/app/app.vue +1 -0
  63. package/dist/templates/nuxt/app/components/JournalView.vue +75 -0
  64. package/dist/templates/nuxt/app/pages/articles/[id].vue +8 -0
  65. package/dist/templates/nuxt/app/pages/index.vue +8 -0
  66. package/dist/templates/nuxt/locks/npm-lock.json.template +9113 -0
  67. package/dist/templates/nuxt/locks/pnpm-lock.yaml.template +6471 -0
  68. package/dist/templates/nuxt/locks/yarn.lock.template +6915 -0
  69. package/dist/templates/nuxt/nuxt.config.ts +27 -0
  70. package/dist/templates/nuxt/package.json +66 -0
  71. package/dist/templates/nuxt/server/api/blog/[id].get.ts +10 -0
  72. package/dist/templates/nuxt/server/api/blog.get.ts +9 -0
  73. package/dist/templates/nuxt/server/middleware/preview.ts +9 -0
  74. package/dist/templates/nuxt/server/utils/cms-environment.ts +15 -0
  75. package/dist/templates/nuxt/tsconfig.json +7 -0
  76. package/dist/templates/nuxt/vendor/README.md +32 -0
  77. package/dist/templates/nuxt/vendor/picomatch-2.3.2-lemonade-sec51.1.tgz +0 -0
  78. package/dist/templates/nuxt/vendor/picomatch-2.3.2.patch +59 -0
  79. package/dist/templates/nuxt/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
  80. package/dist/templates/nuxt/vendor/picomatch-4.0.7.patch +59 -0
  81. package/dist/templates/nuxt/vendor/provenance.json +43 -0
  82. package/dist/templates/shared/GETTING_STARTED.md +29 -0
  83. package/dist/templates/shared/README.md +8 -0
  84. package/dist/templates/shared/env.example.template +11 -0
  85. package/dist/templates/shared/gitignore.template +16 -0
  86. package/dist/templates/shared/model-template.json +75 -0
  87. package/dist/templates/shared/public/blog.css +255 -0
  88. package/dist/templates/shared/public/lemonade.svg +5 -0
  89. package/dist/templates/shared/schema-contract.json +37 -0
  90. package/dist/templates/shared/scripts/cms-tools.mjs +171 -0
  91. package/dist/templates/shared/scripts/environment.mjs +68 -0
  92. package/dist/templates/shared/scripts/run.mjs +122 -0
  93. package/dist/templates/shared/server/blog.d.mts +35 -0
  94. package/dist/templates/shared/server/blog.mjs +159 -0
  95. package/dist/templates/shared/server/config.d.mts +11 -0
  96. package/dist/templates/shared/server/config.mjs +42 -0
  97. package/dist/templates/shared/server/preview.d.mts +4 -0
  98. package/dist/templates/shared/server/preview.mjs +276 -0
  99. package/dist/templates/shared/src/types/cms-models.ts +37 -0
  100. package/dist/templates/shared/yarnrc.yml.template +2 -0
  101. package/package.json +24 -4
  102. package/src/arguments.mjs +75 -0
  103. package/src/catalog.mjs +166 -0
  104. package/src/errors.mjs +10 -0
  105. package/src/generation.mjs +103 -0
  106. package/src/paths.mjs +90 -0
  107. package/src/prompts.mjs +68 -0
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "lemonade-blog",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "engines": {
7
+ "node": "^22.23.5 || ^24.22.3"
8
+ },
9
+ "packageManager": "npm@11.6.2",
10
+ "lemonade": {
11
+ "framework": "angular",
12
+ "contract": 1
13
+ },
14
+ "scripts": {
15
+ "dev": "node scripts/run.mjs dev",
16
+ "check": "node scripts/run.mjs check",
17
+ "build": "node scripts/run.mjs build",
18
+ "start": "node scripts/run.mjs start",
19
+ "cms:setup": "node scripts/cms-tools.mjs setup",
20
+ "cms:check": "node scripts/cms-tools.mjs check",
21
+ "cms:types": "node scripts/cms-tools.mjs types"
22
+ },
23
+ "dependencies": {
24
+ "@lemonadecms/client": "0.2.3",
25
+ "markdown-it": "15.0.3",
26
+ "@angular/common": "22.2.6",
27
+ "@angular/compiler": "22.2.6",
28
+ "@angular/core": "22.2.6",
29
+ "@angular/platform-browser": "22.2.6",
30
+ "@angular/platform-server": "22.2.6",
31
+ "@angular/router": "22.2.6",
32
+ "@angular/ssr": "22.2.7",
33
+ "rxjs": "7.8.2",
34
+ "tslib": "2.9.1",
35
+ "express": "5.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "24.10.1",
39
+ "@types/markdown-it": "14.1.2",
40
+ "@angular/cli": "22.2.7",
41
+ "@angular/build": "22.2.7",
42
+ "@angular/compiler-cli": "22.2.6",
43
+ "typescript": "6.0.2",
44
+ "@types/express": "5.0.3"
45
+ },
46
+ "pnpm": {
47
+ "onlyBuiltDependencies": [
48
+ "@parcel/watcher",
49
+ "esbuild",
50
+ "sharp"
51
+ ],
52
+ "overrides": {
53
+ "@oxc-parser/binding-wasm32-wasi>@napi-rs/wasm-runtime": "1.2.5",
54
+ "picomatch@4.0.7": "file:vendor/picomatch-4.0.7-lemonade-sec51.1.tgz"
55
+ }
56
+ },
57
+ "overrides": {
58
+ "@oxc-parser/binding-wasm32-wasi": {
59
+ "@napi-rs/wasm-runtime": "1.2.5"
60
+ }
61
+ },
62
+ "resolutions": {
63
+ "@oxc-parser/binding-wasm32-wasi/@napi-rs/wasm-runtime": "1.2.5",
64
+ "picomatch@npm:4.0.7": "file:./vendor/picomatch-4.0.7-lemonade-sec51.1.tgz",
65
+ "picomatch@npm:^4.0.4": "file:./vendor/picomatch-4.0.7-lemonade-sec51.1.tgz",
66
+ "picomatch@npm:^4.0.7": "file:./vendor/picomatch-4.0.7-lemonade-sec51.1.tgz"
67
+ }
68
+ }
@@ -0,0 +1,23 @@
1
+ import { mergeApplicationConfig, inject, RESPONSE_INIT } from '@angular/core';
2
+ import { provideServerRendering, withRoutes, RenderMode } from '@angular/ssr';
3
+ import { config as browser } from './app.config';
4
+ import { BLOG_LOADER } from './blog.service';
5
+ import { readBlog } from '../../server/blog.mjs';
6
+ export const config = mergeApplicationConfig(browser, {
7
+ providers: [
8
+ provideServerRendering(withRoutes([{ path: '**', renderMode: RenderMode.Server }])),
9
+ {
10
+ provide: BLOG_LOADER,
11
+ useFactory: () => {
12
+ const response = inject(RESPONSE_INIT, { optional: true });
13
+ return async (path: string) => {
14
+ const u = new URL(path, 'http://request.invalid');
15
+ const match = u.pathname.match(/^\/articles\/([^/]+)$/);
16
+ const view = await readBlog(u.href, { id: match?.[1] });
17
+ if (response) response.status = view.status;
18
+ return view;
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ });
@@ -0,0 +1,34 @@
1
+ import {
2
+ ApplicationConfig,
3
+ inject,
4
+ provideZonelessChangeDetection,
5
+ } from '@angular/core';
6
+ import { provideRouter, type ResolveFn } from '@angular/router';
7
+ import { provideHttpClient, withFetch } from '@angular/common/http';
8
+ import { provideClientHydration } from '@angular/platform-browser';
9
+ import { BlogService } from './blog.service';
10
+ import { Journal } from './journal';
11
+ import type { BlogView } from '../../server/blog.mjs';
12
+ const resolveBlog: ResolveFn<BlogView> = (_route, state) =>
13
+ inject(BlogService).read(state.url);
14
+ export const config: ApplicationConfig = {
15
+ providers: [
16
+ provideZonelessChangeDetection(),
17
+ provideHttpClient(withFetch()),
18
+ provideClientHydration(),
19
+ provideRouter([
20
+ {
21
+ path: '',
22
+ component: Journal,
23
+ resolve: { view: resolveBlog },
24
+ runGuardsAndResolvers: 'paramsOrQueryParamsChange',
25
+ },
26
+ {
27
+ path: 'articles/:id',
28
+ component: Journal,
29
+ resolve: { view: resolveBlog },
30
+ runGuardsAndResolvers: 'paramsOrQueryParamsChange',
31
+ },
32
+ ]),
33
+ ],
34
+ };
@@ -0,0 +1,9 @@
1
+ import { Component } from '@angular/core';
2
+ import { RouterOutlet } from '@angular/router';
3
+ @Component({
4
+ selector: 'app-root',
5
+ standalone: true,
6
+ imports: [RouterOutlet],
7
+ template: '<router-outlet />',
8
+ })
9
+ export class App {}
@@ -0,0 +1,74 @@
1
+ import {
2
+ inject,
3
+ Injectable,
4
+ InjectionToken,
5
+ TransferState,
6
+ makeStateKey,
7
+ } from '@angular/core';
8
+ import { HttpClient } from '@angular/common/http';
9
+ import { firstValueFrom, catchError, of } from 'rxjs';
10
+ import type { BlogView } from '../../server/blog.mjs';
11
+ export const BLOG_LOADER = new InjectionToken<(url: string) => Promise<BlogView>>(
12
+ 'server blog loader',
13
+ );
14
+ @Injectable({ providedIn: 'root' })
15
+ export class BlogService {
16
+ private transfer = inject(TransferState);
17
+ private http = inject(HttpClient);
18
+ private server = inject(BLOG_LOADER, { optional: true });
19
+ async read(url: string): Promise<BlogView> {
20
+ const context = makeStateKey<string>('lemonade-read-context');
21
+ const key = makeStateKey<BlogView>(
22
+ 'lemonade-blog:' + this.transfer.get(context, '') + ':' + url,
23
+ );
24
+ if (this.transfer.hasKey(key)) {
25
+ const value = this.transfer.get(key, null as unknown as BlogView);
26
+ this.transfer.remove(key);
27
+ return value;
28
+ }
29
+ if (this.server) {
30
+ const value = await this.server(url);
31
+ this.transfer.set(context, value.contextKey);
32
+ this.transfer.set(
33
+ makeStateKey<BlogView>('lemonade-blog:' + value.contextKey + ':' + url),
34
+ value,
35
+ );
36
+ return value;
37
+ }
38
+ const u = new URL(url, 'http://request.invalid');
39
+ const match = u.pathname.match(/^\/articles\/([^/]+)$/);
40
+ return firstValueFrom(
41
+ this.http
42
+ .get<BlogView>(
43
+ '/api/blog' + (match ? '/' + encodeURIComponent(match[1]) : '') + u.search,
44
+ )
45
+ .pipe(
46
+ catchError((error) =>
47
+ of({
48
+ // Preserve distinct recovery states during client navigation.
49
+ // Never copy an upstream error body into the public view.
50
+ state:
51
+ error.status === 404
52
+ ? 'not-found'
53
+ : error.status === 400
54
+ ? 'invalid'
55
+ : [401, 403].includes(error.status)
56
+ ? 'denied'
57
+ : 'unavailable',
58
+ status: error.status || 503,
59
+ title: 'Content unavailable',
60
+ description: 'Check your connection and try again.',
61
+ canonical: '',
62
+ contextKey: 'unavailable',
63
+ locale: 'en',
64
+ posts: [],
65
+ article: null,
66
+ page: 1,
67
+ hasNext: false,
68
+ hasPrevious: false,
69
+ } as BlogView),
70
+ ),
71
+ ),
72
+ );
73
+ }
74
+ }
@@ -0,0 +1,71 @@
1
+ <a class="skip" href="#content">Skip to content</a>
2
+ <header>
3
+ <a class="brand" routerLink="/"
4
+ ><span class="mark" aria-hidden="true"></span>Lemonade journal</a
5
+ ><a href="https://app.lemonadecms.com">Studio</a>
6
+ </header>
7
+ <main id="content">
8
+ @if(view.state!=='ready'){
9
+ <section class="notice" role="status">
10
+ <h1>{{messages[view.state]}}</h1>
11
+ <p>
12
+ Check GETTING_STARTED.md and your connection. Published content is never replaced
13
+ by demonstration data.
14
+ </p>
15
+ <a class="button" routerLink="/">Return to journal</a>
16
+ </section>
17
+ } @else if(view.article;as article){
18
+ <article class="article">
19
+ <a routerLink="/" [queryParams]="{page:view.page}">Back to journal</a>
20
+ <h1>{{article.title}}</h1>
21
+ <p class="byline"><span>{{article.author}}</span><time>{{article.date}}</time></p>
22
+ @if(article.image){<img
23
+ class="post-image"
24
+ [src]="article.image"
25
+ [alt]="article.imageAlt"
26
+ />}
27
+ <div class="body" [innerHTML]="article.bodyHtml"></div>
28
+ </article>
29
+ } @else{
30
+ <section class="hero">
31
+ <h1>A little room<br />for good ideas.</h1>
32
+ <p>Notes, stories and new perspectives. Published with Lemonade CMS.</p>
33
+ </section>
34
+ @if(view.posts.length){
35
+ <section class="posts" aria-label="Published articles">
36
+ @for(post of view.posts;track post.id){
37
+ <article class="post">
38
+ @if(post.image){<img
39
+ class="post-image"
40
+ [src]="post.image"
41
+ alt=""
42
+ loading="lazy"
43
+ />}
44
+ <h2>
45
+ <a [routerLink]="['/articles',post.id]" [queryParams]="{page:view.page}"
46
+ >{{post.title}}</a
47
+ >
48
+ </h2>
49
+ <p>{{post.description}}</p>
50
+ <div class="byline"><span>{{post.author}}</span><time>{{post.date}}</time></div>
51
+ </article>
52
+ }
53
+ </section>
54
+ }@else{
55
+ <section class="notice">
56
+ <h2>No published articles yet</h2>
57
+ <p>Publish an author and article in the selected Studio environment to begin.</p>
58
+ </section>
59
+ }
60
+ <nav class="pagination" aria-label="Article pages">
61
+ @if(view.hasPrevious){<a routerLink="/" [queryParams]="{page:view.page-1}"
62
+ >Previous page</a
63
+ >}@else{<span></span>}<span>Page {{view.page}}</span>@if(view.hasNext){<a
64
+ routerLink="/"
65
+ [queryParams]="{page:view.page+1}"
66
+ >Next page</a
67
+ >}@else{<span></span>}
68
+ </nav>
69
+ }
70
+ </main>
71
+ <footer>Your ideas, thoughtfully published.</footer>
@@ -0,0 +1,47 @@
1
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2
+ import { DOCUMENT } from '@angular/common';
3
+ import { Component, inject } from '@angular/core';
4
+ import { ActivatedRoute, RouterLink } from '@angular/router';
5
+ import { Title, Meta } from '@angular/platform-browser';
6
+ import type { BlogView } from '../../server/blog.mjs';
7
+ @Component({
8
+ selector: 'app-journal',
9
+ standalone: true,
10
+ imports: [RouterLink],
11
+ templateUrl: './journal.html',
12
+ })
13
+ export class Journal {
14
+ private document = inject(DOCUMENT);
15
+ private route = inject(ActivatedRoute);
16
+ private title = inject(Title);
17
+ private meta = inject(Meta);
18
+ readonly messages: Record<string, string> = {
19
+ unconfigured: 'Connect your workspace to start your journal.',
20
+ invalid: 'This page link is invalid.',
21
+ 'not-found': 'This article is not available.',
22
+ unavailable: 'Content is temporarily unavailable.',
23
+ denied: 'Content access was denied. Review your published read token.',
24
+ 'context-mismatch':
25
+ 'The content connection does not match the configured workspace, environment or language.',
26
+ };
27
+ constructor() {
28
+ this.route.data.pipe(takeUntilDestroyed()).subscribe((data) => {
29
+ const v = data['view'] as BlogView;
30
+ this.document.documentElement.lang = v.locale;
31
+ let canonical =
32
+ this.document.querySelector<HTMLLinkElement>('link[rel=canonical]');
33
+ if (!canonical) {
34
+ canonical = this.document.createElement('link');
35
+ canonical.rel = 'canonical';
36
+ this.document.head.append(canonical);
37
+ }
38
+ if (v.canonical) canonical.href = v.canonical;
39
+ else canonical.remove();
40
+ this.title.setTitle(v.title);
41
+ this.meta.updateTag({ name: 'description', content: v.description });
42
+ });
43
+ }
44
+ get view(): BlogView {
45
+ return this.route.snapshot.data['view'] as BlogView;
46
+ }
47
+ }
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <base href="/" />
7
+ <title>Lemonade journal</title>
8
+ <link rel="stylesheet" href="/blog.css" data-beasties-skip />
9
+ <link rel="icon" href="/lemonade.svg" type="image/svg+xml" />
10
+ </head>
11
+ <body>
12
+ <app-root></app-root>
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ import { bootstrapApplication, type BootstrapContext } from '@angular/platform-browser';
2
+ import { App } from './app/app';
3
+ import { config } from './app/app.config.server';
4
+ export default (context: BootstrapContext) =>
5
+ bootstrapApplication(App, config, context);
@@ -0,0 +1,6 @@
1
+ import { bootstrapApplication } from '@angular/platform-browser';
2
+ import { App } from './app/app';
3
+ import { config } from './app/app.config';
4
+ bootstrapApplication(App, config).catch(() =>
5
+ console.error('Application unavailable.'),
6
+ );
@@ -0,0 +1,79 @@
1
+ import express from 'express';
2
+ import { resolve } from 'node:path';
3
+ import { Readable } from 'node:stream';
4
+ import {
5
+ AngularNodeAppEngine,
6
+ createNodeRequestHandler,
7
+ isMainModule,
8
+ writeResponseToNodeResponse,
9
+ } from '@angular/ssr/node';
10
+ import { handlePreview } from '../server/preview.mjs';
11
+ import { readBlog, headers } from '../server/blog.mjs';
12
+ import { siteOrigin } from '../server/config.mjs';
13
+ const site = siteOrigin(process.env['SITE_URL']);
14
+ const allowedHosts = site
15
+ ? [new URL(site).hostname]
16
+ : ['localhost', '127.0.0.1', '[::1]'];
17
+ const app = express(),
18
+ angular = new AngularNodeAppEngine({ allowedHosts, trustProxyHeaders: false });
19
+ app.disable('x-powered-by');
20
+ app.use((req, res, next) => {
21
+ res.set(headers);
22
+ let host;
23
+ try {
24
+ const u = new URL('http://' + req.headers.host);
25
+ if (u.username || u.password || u.pathname !== '/' || u.search || u.hash)
26
+ throw Error();
27
+ host = u.hostname;
28
+ } catch {
29
+ return res.status(400).send('Invalid host.');
30
+ }
31
+ if (!allowedHosts.includes(host)) return res.status(400).send('Invalid host.');
32
+ if (req.path === '/lemonade/preview' || req.path.startsWith('/lemonade/preview/')) {
33
+ let origin = 'http://127.0.0.1';
34
+ try {
35
+ if (process.env['CMS_PREVIEW_URL'])
36
+ origin = new URL(process.env['CMS_PREVIEW_URL']!).origin;
37
+ } catch {}
38
+ const h = new Headers();
39
+ for (let i = 0; i < req.rawHeaders.length; i += 2)
40
+ h.append(req.rawHeaders[i], req.rawHeaders[i + 1]);
41
+ const init: RequestInit & { duplex?: 'half' } = { method: req.method, headers: h };
42
+ if (!['GET', 'HEAD'].includes(req.method)) {
43
+ init.body = Readable.toWeb(req) as ReadableStream<Uint8Array>;
44
+ init.duplex = 'half';
45
+ }
46
+ void handlePreview(new Request(origin + req.originalUrl, init))
47
+ .then((r) => (r ? writeResponseToNodeResponse(r, res) : next()))
48
+ .catch(() => res.status(503).send('Preview unavailable.'));
49
+ return;
50
+ }
51
+ next();
52
+ });
53
+ app.get(['/api/blog', '/api/blog/:id'], (req, res) => {
54
+ void readBlog('http://request.invalid' + req.originalUrl, {
55
+ id: typeof req.params['id'] === 'string' ? req.params['id'] : null,
56
+ })
57
+ .then((v) => res.status(v.status).json(v))
58
+ .catch(() => res.status(503).json({ error: 'Content unavailable' }));
59
+ });
60
+ app.use(
61
+ express.static(resolve(import.meta.dirname, '../browser'), {
62
+ maxAge: 0,
63
+ index: false,
64
+ redirect: false,
65
+ }),
66
+ );
67
+ app.use((req, res, next) => {
68
+ angular
69
+ .handle(req)
70
+ .then((r) => (r ? writeResponseToNodeResponse(r, res) : next()))
71
+ .catch(() => res.status(503).send('Content unavailable.'));
72
+ });
73
+ if (isMainModule(import.meta.url)) {
74
+ const port = Number(process.env['PORT'] || 4000);
75
+ app.listen(port, process.env['HOST'] || '127.0.0.1', () =>
76
+ console.log('Journal server ready.'),
77
+ );
78
+ }
79
+ export const reqHandler = createNodeRequestHandler(app);
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node"]
5
+ },
6
+ "include": ["src/**/*.ts", "server/**/*.mjs", "server/**/*.mts"],
7
+ "exclude": ["node_modules", "dist"]
8
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "preserve",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "dom"],
7
+ "experimentalDecorators": true,
8
+ "useDefineForClassFields": false,
9
+ "esModuleInterop": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "skipLibCheck": true,
12
+ "strict": true,
13
+ "allowJs": true,
14
+ "checkJs": false,
15
+ "outDir": "./dist/out-tsc"
16
+ },
17
+ "angularCompilerOptions": {
18
+ "strictTemplates": true,
19
+ "strictInjectionParameters": true
20
+ }
21
+ }
@@ -0,0 +1,32 @@
1
+ # Local picomatch security backports
2
+
3
+ These archives contain Lemonade's SEC-51 parser backports for
4
+ [GHSA-fc5q-39xc-vjpf](https://github.com/advisories/GHSA-fc5q-39xc-vjpf), not an
5
+ upstream patched release. Each retains the original package name/version and MIT
6
+ license. No install hook modifies node_modules. Keep this directory with the app.
7
+
8
+ Use the supplied frozen lock (`npm ci` or `pnpm install --frozen-lockfile`). npm
9
+ locks bind each transitive occurrence directly to its local archive/integrity;
10
+ pnpm additionally uses exact-version local overrides. Updating dependencies or
11
+ regenerating locks requires reviewing all picomatch resolutions. Ordinary npm
12
+ audit tools still identify the original upstream versions as affected.
13
+
14
+ Simple single-branch repeated wildcard patterns retain matching behavior without
15
+ nested unbounded quantifiers. Unsafe complex wildcard/capture patterns use
16
+ picomatch's existing literal fallback; their former complex/capture semantics
17
+ are intentionally unavailable. Quoted/escaped stars and ordinary globs retain
18
+ their behavior. The existing explicit `maxExtglobRecursion: false` disables safety;
19
+ never use it with untrusted patterns.
20
+
21
+ `provenance.json` records original npm SRI/SHA-256, parser/patch/output hashes and
22
+ inspected upstream PR heads. The original archives are obtainable from npm's
23
+ `picomatch` registry record for that exact version. Verify their SRI before
24
+ applying the included single-file patches to `package/lib/parse.js`. Every other
25
+ file, including package metadata and license, remains byte-identical. The
26
+ repository's `scripts/security/picomatch_backports.py` rebuilds canonical tar/gzip
27
+ outputs with sorted names, fixed modes, zero timestamps and no links.
28
+
29
+ Upstream PRs 237 and 246 were open and unmerged when inspected. Replace these
30
+ local backports only with a reviewed upstream fix qualified against this app's
31
+ actual framework and both package managers. Regenerate and review locks together;
32
+ do not silently remove the patch or rename its version to bypass an advisory.
@@ -0,0 +1,59 @@
1
+ --- a/lib/parse.js
2
+ +++ b/lib/parse.js
3
+ @@ -284,6 +284,33 @@
4
+ return depth;
5
+ };
6
+
7
+ +// Lemonade SEC-51 backport: preserve simple repeated-star languages without
8
+ +// nesting unbounded quantifiers. Other bare-star shapes use the existing risky
9
+ +// extglob literal fallback. Quoted/escaped/class stars are not wildcard stars.
10
+ +const analyzeSingleStarBranch = (branch, options) => {
11
+ + let quoted = false;
12
+ + let escaped = false;
13
+ + let bracket = false;
14
+ + let wildcard = false;
15
+ +
16
+ + for (let i = 0; i < branch.length; i++) {
17
+ + const ch = branch[i];
18
+ + if (escaped) { escaped = false; continue; }
19
+ + if (ch === '\\') { escaped = true; continue; }
20
+ + if (ch === '"' && !bracket) { quoted = !quoted; continue; }
21
+ + if (quoted) continue;
22
+ + if (ch === '[') { bracket = true; continue; }
23
+ + if (ch === ']' && bracket) { bracket = false; continue; }
24
+ + if (!bracket && ch === '*' && branch[i + 1] !== '(') wildcard = true;
25
+ + }
26
+ +
27
+ + if (!wildcard) return null;
28
+ + if (options.capture === true || branch.includes('**') || /[\\/"?()[\]{}|!+@]/.test(branch)) {
29
+ + return { risky: true };
30
+ + }
31
+ + return { risky: false, collapse: true };
32
+ +};
33
+ +
34
+ const analyzeRepeatedExtglob = (body, options) => {
35
+ if (options.maxExtglobRecursion === false) {
36
+ return { risky: false };
37
+ @@ -341,6 +368,11 @@
38
+ return combinable
39
+ ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) }
40
+ : { risky: true };
41
+ + }
42
+ +
43
+ + if (branches.length === 1) {
44
+ + const single = analyzeSingleStarBranch(branches[0], options);
45
+ + if (single) return single;
46
+ }
47
+
48
+ return { risky: false };
49
+ @@ -565,6 +597,10 @@
50
+ return;
51
+ }
52
+
53
+ + if (analysis.collapse === true && (token.type === 'plus' || token.type === 'star')) {
54
+ + token.close = token.type === 'plus' ? ')' : ')?';
55
+ + }
56
+ +
57
+ let output = token.close + (opts.capture ? ')' : '');
58
+ let rest;
59
+
@@ -0,0 +1,29 @@
1
+ {
2
+ "advisory": "GHSA-fc5q-39xc-vjpf",
3
+ "upstream_fixes": [
4
+ {
5
+ "url": "https://github.com/micromatch/picomatch/pull/237",
6
+ "head": "1bf0d04563cb9ce568cf36efc5f6b7187d9911d5"
7
+ },
8
+ {
9
+ "url": "https://github.com/micromatch/picomatch/pull/246",
10
+ "head": "f03bec2c02e46f063fbfdc161aae1d0f854b2565"
11
+ }
12
+ ],
13
+ "packages": [
14
+ {
15
+ "name": "picomatch",
16
+ "version": "4.0.7",
17
+ "upstream": "upstream/picomatch-4.0.7.tgz",
18
+ "upstream_sha256": "697b463be3cdbd9ffc8f4194fd5019a69ddf95875fb703d78b2b115cc9e740a8",
19
+ "upstream_integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
20
+ "patch": "patches/picomatch-4.0.7.patch",
21
+ "patch_sha256": "ed1fe75757af96f132a2adb63d12376994e1d9582e8c6e7dd9741ecae9ddf9bc",
22
+ "original_parser_sha256": "4e1e05447668aa1e94366c5516a2bcd8f5fff800cc92b1d0cd7d77703b8618c4",
23
+ "patched_parser_sha256": "01c40acfda6f7c40a32dd4e6671cbec1c70e22f980cda8b22ea64d948a323c0c",
24
+ "archive": "archives/picomatch-4.0.7-lemonade-sec51.1.tgz",
25
+ "archive_sha256": "a0af57ad2de1444dbb70588db2444e906a47a5bd77c5150905cbfd6de02d636c",
26
+ "archive_integrity": "sha512-jkjudKn+93rODxiTonD3ehUEbHrHtSWpYcdZglbGGSbbc/Aqjz6j3R/1m0uuQJQXqFY/WZTtv9F+ZSM3ZCSrdA=="
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'astro/config';
2
+ import node from '@astrojs/node';
3
+ export default defineConfig({
4
+ output: 'server',
5
+ adapter: node({ mode: 'standalone' }),
6
+ server: { host: '127.0.0.1' },
7
+ });