@django-stack/cli 0.0.1 → 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 (79) hide show
  1. package/README.md +27 -3
  2. package/dist/bin.js +1302 -2
  3. package/dist/index.d.ts +250 -1
  4. package/dist/index.js +1 -4
  5. package/dist/stack-OTrWHXrO.js +712 -0
  6. package/package.json +14 -7
  7. package/templates/backend/.dockerignore +11 -0
  8. package/templates/backend/Dockerfile +45 -0
  9. package/templates/backend/config/__init__.py +0 -0
  10. package/templates/backend/config/asgi.py +7 -0
  11. package/templates/backend/config/settings.py +87 -0
  12. package/templates/backend/config/studio.py +20 -0
  13. package/templates/backend/config/urls.py +9 -0
  14. package/templates/backend/config/wsgi.py +7 -0
  15. package/templates/backend/conftest.py +7 -0
  16. package/templates/backend/content/__init__.py +0 -0
  17. package/templates/backend/content/admin.py +107 -0
  18. package/templates/backend/content/apps.py +6 -0
  19. package/templates/backend/content/blocks.py +51 -0
  20. package/templates/backend/content/migrations/0001_initial.py +418 -0
  21. package/templates/backend/content/migrations/__init__.py +0 -0
  22. package/templates/backend/content/models.py +234 -0
  23. package/templates/backend/content/seed.py +153 -0
  24. package/templates/backend/content/tests/__init__.py +0 -0
  25. package/templates/backend/content/tests/test_api.py +73 -0
  26. package/templates/backend/entrypoint.sh +27 -0
  27. package/templates/backend/manage.py +16 -0
  28. package/templates/backend/pyproject.toml +33 -0
  29. package/templates/backend/vendor/.gitkeep +0 -0
  30. package/templates/base/.github/workflows/deploy.yml +70 -0
  31. package/templates/base/AGENTS.md +78 -0
  32. package/templates/base/CLAUDE.md +1 -0
  33. package/templates/base/Caddyfile +51 -0
  34. package/templates/base/README.md +87 -0
  35. package/templates/base/SECURITY.md +12 -0
  36. package/templates/base/compose.yaml +303 -0
  37. package/templates/base/env.example +80 -0
  38. package/templates/base/gitignore +15 -0
  39. package/templates/base/package.json +21 -0
  40. package/templates/frontend-astro/.dockerignore +4 -0
  41. package/templates/frontend-astro/Dockerfile +32 -0
  42. package/templates/frontend-astro/astro.config.mjs +38 -0
  43. package/templates/frontend-astro/package.json +31 -0
  44. package/templates/frontend-astro/public/favicon.svg +1 -0
  45. package/templates/frontend-astro/src/components/Blocks.astro +32 -0
  46. package/templates/frontend-astro/src/components/ContactForm.astro +68 -0
  47. package/templates/frontend-astro/src/components/Image.astro +34 -0
  48. package/templates/frontend-astro/src/components/PostCard.astro +41 -0
  49. package/templates/frontend-astro/src/components/PostList.astro +39 -0
  50. package/templates/frontend-astro/src/components/RichText.astro +14 -0
  51. package/templates/frontend-astro/src/components/Seo.astro +20 -0
  52. package/templates/frontend-astro/src/components/blocks/CallToAction.astro +23 -0
  53. package/templates/frontend-astro/src/components/blocks/Image.astro +24 -0
  54. package/templates/frontend-astro/src/components/blocks/Quote.astro +10 -0
  55. package/templates/frontend-astro/src/components/blocks/Text.astro +8 -0
  56. package/templates/frontend-astro/src/layouts/Base.astro +122 -0
  57. package/templates/frontend-astro/src/lib/api.ts +24 -0
  58. package/templates/frontend-astro/src/lib/cache.ts +58 -0
  59. package/templates/frontend-astro/src/lib/headless.ts +344 -0
  60. package/templates/frontend-astro/src/middleware.ts +69 -0
  61. package/templates/frontend-astro/src/pages/404.astro +13 -0
  62. package/templates/frontend-astro/src/pages/[...slug].astro +21 -0
  63. package/templates/frontend-astro/src/pages/blog/[slug].astro +50 -0
  64. package/templates/frontend-astro/src/pages/blog/index.astro +15 -0
  65. package/templates/frontend-astro/src/pages/category/[slug].astro +25 -0
  66. package/templates/frontend-astro/src/pages/index.astro +28 -0
  67. package/templates/frontend-astro/src/pages/preview/exit.ts +7 -0
  68. package/templates/frontend-astro/src/pages/preview/index.ts +26 -0
  69. package/templates/frontend-astro/src/pages/revalidate.ts +19 -0
  70. package/templates/frontend-astro/src/pages/robots.txt.ts +7 -0
  71. package/templates/frontend-astro/src/pages/rss.xml.ts +19 -0
  72. package/templates/frontend-astro/src/pages/sitemap.xml.ts +29 -0
  73. package/templates/frontend-astro/src/pages/tag/[slug].astro +24 -0
  74. package/templates/frontend-astro/src/styles/global.css +101 -0
  75. package/templates/frontend-astro/test/blocks.test.ts +42 -0
  76. package/templates/frontend-astro/test/cache.test.ts +22 -0
  77. package/templates/frontend-astro/tsconfig.json +5 -0
  78. package/templates/frontend-astro/vendor/.gitkeep +0 -0
  79. package/templates/frontend-astro/vitest.config.ts +8 -0
package/dist/index.d.ts CHANGED
@@ -1,2 +1,251 @@
1
+ interface Check {
2
+ name: string;
3
+ ok: boolean;
4
+ /** Not a failure: the check could not run or only warns. */
5
+ warning?: boolean;
6
+ detail?: string;
7
+ }
8
+ /** Checks a project directory: tools, .env, and the running services. */
9
+ export declare function runDoctor(directory: string): Promise<Check[]>;
10
+ /** Reads a .env file: KEY=value lines, comments and blank lines ignored. */
11
+ export declare function parseEnv(text: string): Record<string, string>;
12
+ /** Sets KEY=value lines in .env text, replacing existing ones and appending new ones. */
13
+ export declare function setEnvValues(text: string, values: Record<string, string>): string;
14
+ interface ProductionOptions {
15
+ /** The domain the site runs on, such as example.com. */
16
+ domain: string;
17
+ /** The SMTP server for outgoing mail. */
18
+ emailUrl?: string;
19
+ }
20
+ interface ProductionEnv {
21
+ text: string;
22
+ adminPassword: string;
23
+ /** Things to finish by hand before the first deploy. */
24
+ todo: string[];
25
+ }
26
+ export declare function validateDomain(domain: string): string | undefined;
27
+ /**
28
+ * The .env for a server, from a project's development .env: the prod
29
+ * profile, HTTPS on the domain, and fresh secrets, so nothing from the
30
+ * laptop works on the server.
31
+ */
32
+ export declare function productionEnv(devEnv: string, options: ProductionOptions): ProductionEnv;
33
+ export declare const FRONTENDS: readonly ["astro"];
34
+ type Frontend = (typeof FRONTENDS)[number];
35
+ interface ScaffoldOptions {
36
+ /** The directory to create the project in. */
37
+ directory: string;
38
+ /** The project name: lowercase letters, digits and dashes. */
39
+ name: string;
40
+ frontend: Frontend;
41
+ /** Demo pages and posts on the first start. */
42
+ demoContent: boolean;
43
+ /** An external Postgres URL; the bundled Postgres when not set. */
44
+ databaseUrl?: string;
45
+ /** Store uploads in the local S3 service in development, like S3 in production. */
46
+ localS3?: boolean;
47
+ /** A DjangoStack monorepo to take the packages from instead of the registries (for development). */
48
+ link?: string;
49
+ /** The time zone of the backend, such as Europe/Amsterdam. UTC by default. */
50
+ timeZone?: string;
51
+ /** The preset code of the stack, saved in package.json for `config`. */
52
+ preset?: string;
53
+ /** Where the templates are; the ones in the package by default. */
54
+ templatesDir?: string;
55
+ }
56
+ interface ScaffoldResult {
57
+ directory: string;
58
+ adminUsername: string;
59
+ adminPassword: string;
60
+ files: number;
61
+ }
62
+ /** A valid project name from a directory name: `My Site` becomes `my-site`. */
63
+ export declare function toProjectName(value: string): string;
64
+ export declare function validateProjectName(value: string): string | undefined;
65
+ /** Postgres URLs for hosts other than this machine must use TLS. */
66
+ export declare function normalizeDatabaseUrl(url: string): string;
67
+ export declare function scaffold(options: ScaffoldOptions): ScaffoldResult;
68
+ /** A URL-safe random secret with `bytes` bytes of randomness. */
69
+ export declare function generateSecret(bytes?: number): string;
70
+ /** The secrets a project's .env needs, by the name used in `{{secret:<name>}}`. */
71
+ export declare function generateProjectSecrets(): Record<string, string>;
72
+ export declare const STACK_OPTIONS: readonly [{
73
+ readonly key: "frontend";
74
+ readonly flag: "--frontend";
75
+ readonly message: "Frontend";
76
+ readonly description: "The frontend framework";
77
+ readonly values: readonly [{
78
+ readonly value: "astro";
79
+ readonly label: "Astro";
80
+ readonly hint: "server-rendered, fast by default";
81
+ readonly generated: true;
82
+ }, {
83
+ readonly value: "next";
84
+ readonly label: "Next.js";
85
+ readonly hint: "React, server components";
86
+ readonly generated: false;
87
+ }, {
88
+ readonly value: "headless";
89
+ readonly label: "Headless";
90
+ readonly hint: "just the API and the admin";
91
+ readonly generated: false;
92
+ }, {
93
+ readonly value: "templates";
94
+ readonly label: "Django templates";
95
+ readonly hint: "no Node, Django renders the site";
96
+ readonly generated: false;
97
+ }];
98
+ }, {
99
+ readonly key: "postgres";
100
+ readonly flag: "--postgres";
101
+ readonly message: "Postgres version";
102
+ readonly description: "The bundled Postgres version";
103
+ readonly values: readonly [{
104
+ readonly value: "stable";
105
+ readonly label: "Stable";
106
+ readonly hint: "Postgres 17";
107
+ readonly generated: true;
108
+ }, {
109
+ readonly value: "latest";
110
+ readonly label: "Latest";
111
+ readonly hint: "Postgres 18";
112
+ readonly generated: false;
113
+ }];
114
+ }, {
115
+ readonly key: "analytics";
116
+ readonly flag: "--analytics";
117
+ readonly message: "Analytics";
118
+ readonly description: "Page analytics";
119
+ readonly values: readonly [{
120
+ readonly value: "umami";
121
+ readonly label: "Umami";
122
+ readonly hint: "built in, private, no cookies";
123
+ readonly generated: false;
124
+ }, {
125
+ readonly value: "off";
126
+ readonly label: "Off";
127
+ readonly generated: true;
128
+ }];
129
+ }, {
130
+ readonly key: "tasks";
131
+ readonly flag: "--tasks";
132
+ readonly message: "Background tasks";
133
+ readonly description: "The task queue";
134
+ readonly values: readonly [{
135
+ readonly value: "huey";
136
+ readonly label: "Huey";
137
+ readonly hint: "a worker container with Valkey";
138
+ readonly generated: true;
139
+ }, {
140
+ readonly value: "off";
141
+ readonly label: "Off";
142
+ readonly generated: false;
143
+ }];
144
+ }, {
145
+ readonly key: "cache";
146
+ readonly flag: "--cache";
147
+ readonly message: "Cache";
148
+ readonly description: "The cache backend";
149
+ readonly values: readonly [{
150
+ readonly value: "database";
151
+ readonly label: "Database";
152
+ readonly hint: "a Postgres table, nothing extra to run";
153
+ readonly generated: false;
154
+ }, {
155
+ readonly value: "valkey";
156
+ readonly label: "Valkey";
157
+ readonly hint: "in memory, Redis-compatible";
158
+ readonly generated: false;
159
+ }, {
160
+ readonly value: "off";
161
+ readonly label: "Off";
162
+ readonly generated: false;
163
+ }];
164
+ }, {
165
+ readonly key: "notifications";
166
+ readonly flag: "--notifications";
167
+ readonly message: "Notifications";
168
+ readonly description: "Notifications in the admin and by email";
169
+ readonly values: readonly [{
170
+ readonly value: "on";
171
+ readonly label: "On";
172
+ readonly hint: "in the admin and by email";
173
+ readonly generated: false;
174
+ }, {
175
+ readonly value: "off";
176
+ readonly label: "Off";
177
+ readonly generated: true;
178
+ }];
179
+ }, {
180
+ readonly key: "captcha";
181
+ readonly flag: "--captcha";
182
+ readonly message: "Captcha";
183
+ readonly description: "The built-in captcha for forms";
184
+ readonly values: readonly [{
185
+ readonly value: "on";
186
+ readonly label: "On";
187
+ readonly hint: "proof of work, no tracking";
188
+ readonly generated: false;
189
+ }, {
190
+ readonly value: "off";
191
+ readonly label: "Off";
192
+ readonly generated: true;
193
+ }];
194
+ }, {
195
+ readonly key: "storage";
196
+ readonly flag: "--storage";
197
+ readonly message: "Uploads in development";
198
+ readonly description: "Where uploads go in development";
199
+ readonly values: readonly [{
200
+ readonly value: "local";
201
+ readonly label: "Local files";
202
+ readonly hint: "a Docker volume";
203
+ readonly generated: true;
204
+ }, {
205
+ readonly value: "s3";
206
+ readonly label: "Local S3";
207
+ readonly hint: "the same code path as S3 in production";
208
+ readonly generated: true;
209
+ }];
210
+ }, {
211
+ readonly key: "packageManager";
212
+ readonly flag: "--package-manager";
213
+ readonly message: "Package manager";
214
+ readonly description: "The frontend's package manager";
215
+ readonly values: readonly [{
216
+ readonly value: "pnpm";
217
+ readonly label: "pnpm";
218
+ readonly generated: false;
219
+ }, {
220
+ readonly value: "npm";
221
+ readonly label: "npm";
222
+ readonly generated: true;
223
+ }, {
224
+ readonly value: "bun";
225
+ readonly label: "Bun";
226
+ readonly generated: false;
227
+ }];
228
+ }];
229
+ type Options = (typeof STACK_OPTIONS)[number];
230
+ type StackKey = Options["key"];
231
+ type Stack = { [O in Options as O["key"]]: O["values"][number]["value"]; };
232
+ export declare const DEFAULT_STACK: Stack;
233
+ /** A preset code for a stack: the version, then one character per option, trailing defaults left out. */
234
+ export declare function encodePreset(stack: Stack): string;
235
+ /** The stack of a preset code. Throws with a one-line reason for a bad code. */
236
+ export declare function decodePreset(code: string): Stack;
237
+ export declare const NAMED_PRESETS: Record<string, {
238
+ description: string;
239
+ stack: Partial<Stack>;
240
+ }>;
241
+ /** The stack of a preset name or code. */
242
+ export declare function resolvePreset(input: string): Stack;
243
+ /** The choices this CLI version does not generate yet, as `--flag value`. */
244
+ export declare function pendingChoices(stack: Stack): {
245
+ key: StackKey;
246
+ choice: string;
247
+ isDefault: boolean;
248
+ }[];
1
249
  /** The version of this package, the same for every @django-stack package. */
2
- export declare const VERSION = "0.0.1";
250
+ declare const CLI_VERSION: string;
251
+ export { type Check, type Frontend, type ProductionEnv, type ProductionOptions, type ScaffoldOptions, type ScaffoldResult, type Stack, CLI_VERSION as VERSION };
package/dist/index.js CHANGED
@@ -1,4 +1 @@
1
- // src/index.ts
2
- /** The version of this package, the same for every @django-stack package. */
3
- const VERSION = "0.0.1";
4
- export { VERSION };
1
+ export { t as DEFAULT_STACK, u as FRONTENDS, n as NAMED_PRESETS, r as STACK_OPTIONS, b as VERSION, a as decodePreset, o as encodePreset, C as generateProjectSecrets, w as generateSecret, p as normalizeDatabaseUrl, E as parseEnv, s as pendingChoices, x as productionEnv, c as resolvePreset, T as runDoctor, h as scaffold, D as setEnvValues, _ as toProjectName, S as validateDomain, v as validateProjectName } from "./stack-OTrWHXrO.js";