@lemonadecms/create 0.0.0-stage → 0.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +26 -2
  4. package/bin/create-lemonade.mjs +122 -0
  5. package/dist/catalog.json +604 -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 +4234 -0
  9. package/dist/templates/angular/package.json +61 -0
  10. package/dist/templates/angular/src/app/app.config.server.ts +23 -0
  11. package/dist/templates/angular/src/app/app.config.ts +34 -0
  12. package/dist/templates/angular/src/app/app.ts +9 -0
  13. package/dist/templates/angular/src/app/blog.service.ts +74 -0
  14. package/dist/templates/angular/src/app/journal.html +71 -0
  15. package/dist/templates/angular/src/app/journal.ts +47 -0
  16. package/dist/templates/angular/src/index.html +14 -0
  17. package/dist/templates/angular/src/main.server.ts +5 -0
  18. package/dist/templates/angular/src/main.ts +6 -0
  19. package/dist/templates/angular/src/server.ts +79 -0
  20. package/dist/templates/angular/tsconfig.app.json +8 -0
  21. package/dist/templates/angular/tsconfig.json +21 -0
  22. package/dist/templates/astro/astro.config.mjs +7 -0
  23. package/dist/templates/astro/locks/npm-lock.json.template +5478 -0
  24. package/dist/templates/astro/locks/pnpm-lock.yaml.template +3530 -0
  25. package/dist/templates/astro/package.json +42 -0
  26. package/dist/templates/astro/src/components/BlogView.astro +92 -0
  27. package/dist/templates/astro/src/layouts/Site.astro +23 -0
  28. package/dist/templates/astro/src/pages/articles/[id].astro +13 -0
  29. package/dist/templates/astro/src/pages/index.astro +13 -0
  30. package/dist/templates/astro/src/pages/lemonade/preview/[...path].ts +4 -0
  31. package/dist/templates/astro/src/pages/lemonade/preview.ts +4 -0
  32. package/dist/templates/astro/tsconfig.json +9 -0
  33. package/dist/templates/next/app/articles/[id]/page.tsx +29 -0
  34. package/dist/templates/next/app/data.ts +12 -0
  35. package/dist/templates/next/app/error.tsx +15 -0
  36. package/dist/templates/next/app/layout.tsx +13 -0
  37. package/dist/templates/next/app/lemonade/preview/[[...path]]/route.ts +7 -0
  38. package/dist/templates/next/app/loading.tsx +7 -0
  39. package/dist/templates/next/app/not-found.tsx +8 -0
  40. package/dist/templates/next/app/page.tsx +17 -0
  41. package/dist/templates/next/app/view.tsx +111 -0
  42. package/dist/templates/next/locks/npm-lock.json.template +1158 -0
  43. package/dist/templates/next/locks/pnpm-lock.yaml.template +715 -0
  44. package/dist/templates/next/next-env.d.ts +2 -0
  45. package/dist/templates/next/next.config.mjs +8 -0
  46. package/dist/templates/next/package.json +44 -0
  47. package/dist/templates/next/proxy.ts +19 -0
  48. package/dist/templates/next/tsconfig.json +25 -0
  49. package/dist/templates/nuxt/app/app.vue +1 -0
  50. package/dist/templates/nuxt/app/components/JournalView.vue +75 -0
  51. package/dist/templates/nuxt/app/pages/articles/[id].vue +8 -0
  52. package/dist/templates/nuxt/app/pages/index.vue +8 -0
  53. package/dist/templates/nuxt/locks/npm-lock.json.template +9113 -0
  54. package/dist/templates/nuxt/locks/pnpm-lock.yaml.template +6466 -0
  55. package/dist/templates/nuxt/nuxt.config.ts +27 -0
  56. package/dist/templates/nuxt/package.json +54 -0
  57. package/dist/templates/nuxt/server/api/blog/[id].get.ts +10 -0
  58. package/dist/templates/nuxt/server/api/blog.get.ts +9 -0
  59. package/dist/templates/nuxt/server/middleware/preview.ts +9 -0
  60. package/dist/templates/nuxt/server/utils/cms-environment.ts +15 -0
  61. package/dist/templates/nuxt/tsconfig.json +7 -0
  62. package/dist/templates/shared/GETTING_STARTED.md +29 -0
  63. package/dist/templates/shared/README.md +8 -0
  64. package/dist/templates/shared/env.example.template +11 -0
  65. package/dist/templates/shared/gitignore.template +13 -0
  66. package/dist/templates/shared/model-template.json +75 -0
  67. package/dist/templates/shared/public/blog.css +255 -0
  68. package/dist/templates/shared/public/lemonade.svg +5 -0
  69. package/dist/templates/shared/schema-contract.json +37 -0
  70. package/dist/templates/shared/scripts/cms-tools.mjs +171 -0
  71. package/dist/templates/shared/scripts/environment.mjs +68 -0
  72. package/dist/templates/shared/scripts/run.mjs +122 -0
  73. package/dist/templates/shared/server/blog.d.mts +35 -0
  74. package/dist/templates/shared/server/blog.mjs +159 -0
  75. package/dist/templates/shared/server/config.d.mts +11 -0
  76. package/dist/templates/shared/server/config.mjs +42 -0
  77. package/dist/templates/shared/server/preview.d.mts +4 -0
  78. package/dist/templates/shared/server/preview.mjs +276 -0
  79. package/dist/templates/shared/src/types/cms-models.ts +37 -0
  80. package/package.json +24 -4
  81. package/src/arguments.mjs +55 -0
  82. package/src/catalog.mjs +134 -0
  83. package/src/errors.mjs +10 -0
  84. package/src/generation.mjs +103 -0
  85. package/src/paths.mjs +90 -0
  86. package/src/prompts.mjs +65 -0
@@ -0,0 +1,42 @@
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": "astro",
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
+ "astro": "7.4.7",
27
+ "@astrojs/node": "11.1.12"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "24.10.1",
31
+ "@types/markdown-it": "14.1.2",
32
+ "@astrojs/check": "0.9.12",
33
+ "typescript": "5.9.3"
34
+ },
35
+ "pnpm": {
36
+ "onlyBuiltDependencies": [
37
+ "@parcel/watcher",
38
+ "esbuild",
39
+ "sharp"
40
+ ]
41
+ }
42
+ }
@@ -0,0 +1,92 @@
1
+ ---
2
+ import { message, type BlogView } from '../../server/blog.mjs';
3
+ interface Props {
4
+ view: BlogView;
5
+ }
6
+ const { view } = Astro.props;
7
+ ---
8
+
9
+ <a class="skip" href="#content">
10
+ Skip to content
11
+ </a>
12
+ <header>
13
+ <a class="brand" href="/">
14
+ <span class="mark" aria-hidden="true"></span>Lemonade journal
15
+ </a>
16
+ <a href="https://app.lemonadecms.com">Studio</a>
17
+ </header>
18
+ <main id="content">
19
+ {view.state !== 'ready' ? (
20
+ <section class="notice" role="status">
21
+ <h1>{message(view.state)}</h1>
22
+ <p>
23
+ {view.state === 'unconfigured'
24
+ ? 'Follow GETTING_STARTED.md and configure your workspace, environment and published read token.'
25
+ : 'Your published content has not been replaced. Try again or check the connection.'}
26
+ </p>
27
+ <a class="button" href="/">
28
+ Return to journal
29
+ </a>
30
+ </section>
31
+ ) : view.article ? (
32
+ <article class="article">
33
+ <a href={`/?page=${view.page}`}>Back to journal</a>
34
+ <h1>{view.article.title}</h1>
35
+ <p class="byline">
36
+ <span>{view.article.author}</span>
37
+ <time>{view.article.date}</time>
38
+ </p>
39
+ {view.article.image && (
40
+ <img class="post-image" src={view.article.image} alt={view.article.imageAlt} />
41
+ )}
42
+ <div class="body" set:html={view.article.bodyHtml} />
43
+ </article>
44
+ ) : (
45
+ <>
46
+ <section class="hero">
47
+ <h1>
48
+ A little room
49
+ <br />
50
+ for good ideas.
51
+ </h1>
52
+ <p>Notes, stories and new perspectives. Published with Lemonade CMS.</p>
53
+ </section>
54
+ {view.posts.length ? (
55
+ <section class="posts" aria-label="Published articles">
56
+ {view.posts.map((post) => (
57
+ <article class="post">
58
+ {post.image && (
59
+ <img class="post-image" src={post.image} alt="" loading="lazy" />
60
+ )}
61
+ <h2>
62
+ <a href={`/articles/${post.id}?page=${view.page}`}>{post.title}</a>
63
+ </h2>
64
+ <p>{post.description}</p>
65
+ <div class="byline">
66
+ <span>{post.author}</span>
67
+ <time>{post.date}</time>
68
+ </div>
69
+ </article>
70
+ ))}
71
+ </section>
72
+ ) : (
73
+ <section class="notice">
74
+ <h2>No published articles yet</h2>
75
+ <p>
76
+ Publish an author and article in the selected Studio environment to begin.
77
+ </p>
78
+ </section>
79
+ )}
80
+ <nav class="pagination" aria-label="Article pages">
81
+ {view.hasPrevious ? (
82
+ <a href={`/?page=${view.page - 1}`}>Previous page</a>
83
+ ) : (
84
+ <span />
85
+ )}
86
+ <span>Page {view.page}</span>
87
+ {view.hasNext ? <a href={`/?page=${view.page + 1}`}>Next page</a> : <span />}
88
+ </nav>
89
+ </>
90
+ )}
91
+ </main>
92
+ <footer>Your ideas, thoughtfully published.</footer>
@@ -0,0 +1,23 @@
1
+ ---
2
+ import type { BlogView } from '../../server/blog.mjs';
3
+ interface Props {
4
+ view: BlogView;
5
+ }
6
+ const { view } = Astro.props;
7
+ ---
8
+
9
+ <!doctype html>
10
+ <html lang={view.locale}>
11
+ <head>
12
+ <meta charset="utf-8" />
13
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
14
+ <title>{view.title}</title>
15
+ <meta name="description" content={view.description} />
16
+ {view.canonical && <link rel="canonical" href={view.canonical} />}
17
+ <link rel="stylesheet" href="/blog.css" />
18
+ <link rel="icon" href="/lemonade.svg" type="image/svg+xml" />
19
+ </head>
20
+ <body>
21
+ <slot />
22
+ </body>
23
+ </html>
@@ -0,0 +1,13 @@
1
+ ---
2
+ import { readBlog, headers } from '../../../server/blog.mjs';
3
+ import Site from '../../layouts/Site.astro';
4
+ import BlogView from '../../components/BlogView.astro';
5
+ const view = await readBlog(Astro.url.href, { id: Astro.params.id });
6
+ Astro.response.status = view.status;
7
+ for (const [key, value] of Object.entries(headers))
8
+ Astro.response.headers.set(key, value);
9
+ ---
10
+
11
+ <Site view={view}>
12
+ <BlogView view={view} />
13
+ </Site>
@@ -0,0 +1,13 @@
1
+ ---
2
+ import { readBlog, headers } from '../../server/blog.mjs';
3
+ import Site from '../layouts/Site.astro';
4
+ import BlogView from '../components/BlogView.astro';
5
+ const view = await readBlog(Astro.url.href);
6
+ Astro.response.status = view.status;
7
+ for (const [key, value] of Object.entries(headers))
8
+ Astro.response.headers.set(key, value);
9
+ ---
10
+
11
+ <Site view={view}>
12
+ <BlogView view={view} />
13
+ </Site>
@@ -0,0 +1,4 @@
1
+ import type { APIRoute } from 'astro';
2
+ import { handlePreview } from '../../../../server/preview.mjs';
3
+ export const ALL: APIRoute = async ({ request }) =>
4
+ (await handlePreview(request)) || new Response('Not found', { status: 404 });
@@ -0,0 +1,4 @@
1
+ import type { APIRoute } from 'astro';
2
+ import { handlePreview } from '../../../server/preview.mjs';
3
+ export const ALL: APIRoute = async ({ request }) =>
4
+ (await handlePreview(request)) || new Response('Not found', { status: 404 });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "astro/tsconfigs/strict",
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "checkJs": false
6
+ },
7
+ "include": [".astro/types.d.ts", "**/*"],
8
+ "exclude": ["dist"]
9
+ }
@@ -0,0 +1,29 @@
1
+ import { getBlog, query } from '../../data';
2
+ import { Journal } from '../../view';
3
+ import { notFound } from 'next/navigation';
4
+ export const dynamic = 'force-dynamic';
5
+ export const runtime = 'nodejs';
6
+ type Props = {
7
+ params: Promise<{ id: string }>;
8
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
9
+ };
10
+ async function read(p: Props) {
11
+ const { id } = await p.params;
12
+ return getBlog(
13
+ '/articles/' + encodeURIComponent(id) + query(await p.searchParams),
14
+ id,
15
+ );
16
+ }
17
+ export async function generateMetadata(p: Props) {
18
+ const v = await read(p);
19
+ return {
20
+ title: v.title,
21
+ description: v.description,
22
+ alternates: { canonical: v.canonical },
23
+ };
24
+ }
25
+ export default async function Page(p: Props) {
26
+ const v = await read(p);
27
+ if (v.status === 404) notFound();
28
+ return <Journal view={v} />;
29
+ }
@@ -0,0 +1,12 @@
1
+ import { cache } from 'react';
2
+ import { readBlog } from '../server/blog.mjs';
3
+ export const getBlog = cache(async (path: string, id?: string) =>
4
+ readBlog('http://request.invalid' + path, { id }),
5
+ );
6
+ export function query(values: Record<string, string | string[] | undefined>) {
7
+ const q = new URLSearchParams();
8
+ for (const [key, value] of Object.entries(values))
9
+ if (Array.isArray(value)) for (const item of value) q.append(key, item);
10
+ else if (value !== undefined) q.set(key, value);
11
+ return q.size ? '?' + q.toString() : '';
12
+ }
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ export default function ErrorView({ reset }: { reset: () => void }) {
3
+ return (
4
+ <main id="content" className="notice">
5
+ <h1>Content is temporarily unavailable</h1>
6
+ <p>Your content has not changed.</p>
7
+ <button className="button" onClick={() => reset()}>
8
+ Try again
9
+ </button>
10
+ <p>
11
+ <a href="/">Return to journal</a>
12
+ </p>
13
+ </main>
14
+ );
15
+ }
@@ -0,0 +1,13 @@
1
+ import { configuration } from '../server/config.mjs';
2
+ import type { ReactNode } from 'react';
3
+ export default function Layout({ children }: { children: ReactNode }) {
4
+ return (
5
+ <html lang={configuration()?.locale || 'en'}>
6
+ <head>
7
+ <link rel="stylesheet" href="/blog.css" />
8
+ <link rel="icon" href="/lemonade.svg" type="image/svg+xml" />
9
+ </head>
10
+ <body>{children}</body>
11
+ </html>
12
+ );
13
+ }
@@ -0,0 +1,7 @@
1
+ import { handlePreview } from '../../../../server/preview.mjs';
2
+ export const runtime = 'nodejs';
3
+ export const dynamic = 'force-dynamic';
4
+ export async function GET(request: Request) {
5
+ return (await handlePreview(request)) || new Response('Not found', { status: 404 });
6
+ }
7
+ export const POST = GET;
@@ -0,0 +1,7 @@
1
+ export default function Loading() {
2
+ return (
3
+ <main id="content">
4
+ <p role="status">Loading published articles…</p>
5
+ </main>
6
+ );
7
+ }
@@ -0,0 +1,8 @@
1
+ export default function NotFound() {
2
+ return (
3
+ <main className="notice">
4
+ <h1>This article is not available.</h1>
5
+ <a href="/">Return to journal</a>
6
+ </main>
7
+ );
8
+ }
@@ -0,0 +1,17 @@
1
+ import { getBlog, query } from './data';
2
+ import { Journal } from './view';
3
+ export const dynamic = 'force-dynamic';
4
+ export const runtime = 'nodejs';
5
+ type Props = { searchParams: Promise<Record<string, string | string[] | undefined>> };
6
+ export async function generateMetadata({ searchParams }: Props) {
7
+ const v = await getBlog('/' + query(await searchParams));
8
+ return {
9
+ title: v.title,
10
+ description: v.description,
11
+ alternates: { canonical: v.canonical },
12
+ };
13
+ }
14
+ export default async function Page({ searchParams }: Props) {
15
+ const v = await getBlog('/' + query(await searchParams));
16
+ return <Journal view={v} />;
17
+ }
@@ -0,0 +1,111 @@
1
+ import type { BlogView } from '../server/blog.mjs';
2
+ import { message } from '../server/blog.mjs';
3
+ export function Journal({ view }: { view: BlogView }) {
4
+ return (
5
+ <>
6
+ <a className="skip" href="#content">
7
+ Skip to content
8
+ </a>
9
+ <header>
10
+ <a className="brand" href="/">
11
+ <span className="mark" aria-hidden="true" />
12
+ Lemonade journal
13
+ </a>
14
+ <a href="https://app.lemonadecms.com">Studio</a>
15
+ </header>
16
+ <main id="content">
17
+ {view.state !== 'ready' ? (
18
+ <section className="notice" role="status">
19
+ <h1>{message(view.state)}</h1>
20
+ <p>
21
+ Check GETTING_STARTED.md and the connection. No demonstration content is
22
+ substituted.
23
+ </p>
24
+ <a className="button" href="/">
25
+ Return to journal
26
+ </a>
27
+ </section>
28
+ ) : view.article ? (
29
+ <article className="article">
30
+ <a href={`/?page=${view.page}`}>Back to journal</a>
31
+ <h1>{view.article.title}</h1>
32
+ <p className="byline">
33
+ <span>{view.article.author}</span>
34
+ <time>{view.article.date}</time>
35
+ </p>
36
+ {view.article.image && (
37
+ <img
38
+ className="post-image"
39
+ src={view.article.image}
40
+ alt={view.article.imageAlt}
41
+ />
42
+ )}
43
+ <div
44
+ className="body"
45
+ dangerouslySetInnerHTML={{ __html: view.article.bodyHtml }}
46
+ />
47
+ </article>
48
+ ) : (
49
+ <>
50
+ <section className="hero">
51
+ <h1>
52
+ A little room
53
+ <br />
54
+ for good ideas.
55
+ </h1>
56
+ <p>Notes, stories and new perspectives. Published with Lemonade CMS.</p>
57
+ </section>
58
+ {view.posts.length ? (
59
+ <section className="posts" aria-label="Published articles">
60
+ {view.posts.map((post) => (
61
+ <article key={post.id} className="post">
62
+ {post.image && (
63
+ <img
64
+ className="post-image"
65
+ src={post.image}
66
+ alt=""
67
+ loading="lazy"
68
+ />
69
+ )}
70
+ <h2>
71
+ <a href={`/articles/${post.id}?page=${view.page}`}>
72
+ {post.title}
73
+ </a>
74
+ </h2>
75
+ <p>{post.description}</p>
76
+ <div className="byline">
77
+ <span>{post.author}</span>
78
+ <time>{post.date}</time>
79
+ </div>
80
+ </article>
81
+ ))}
82
+ </section>
83
+ ) : (
84
+ <section className="notice">
85
+ <h2>No published articles yet</h2>
86
+ <p>
87
+ Publish an author and article in the selected Studio environment to
88
+ begin.
89
+ </p>
90
+ </section>
91
+ )}
92
+ <nav className="pagination" aria-label="Article pages">
93
+ {view.hasPrevious ? (
94
+ <a href={`/?page=${view.page - 1}`}>Previous page</a>
95
+ ) : (
96
+ <span />
97
+ )}
98
+ <span>Page {view.page}</span>
99
+ {view.hasNext ? (
100
+ <a href={`/?page=${view.page + 1}`}>Next page</a>
101
+ ) : (
102
+ <span />
103
+ )}
104
+ </nav>
105
+ </>
106
+ )}
107
+ </main>
108
+ <footer>Your ideas, thoughtfully published.</footer>
109
+ </>
110
+ );
111
+ }