@prenta/cli 0.14.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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +353 -0
- package/CHANGELOG.md +404 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/__tests__/db-init.test.d.ts +2 -0
- package/dist/__tests__/db-init.test.d.ts.map +1 -0
- package/dist/__tests__/db-init.test.js +127 -0
- package/dist/__tests__/db-init.test.js.map +1 -0
- package/dist/__tests__/db-sync-resolver.test.d.ts +2 -0
- package/dist/__tests__/db-sync-resolver.test.d.ts.map +1 -0
- package/dist/__tests__/db-sync-resolver.test.js +25 -0
- package/dist/__tests__/db-sync-resolver.test.js.map +1 -0
- package/dist/__tests__/db-sync.test.d.ts +2 -0
- package/dist/__tests__/db-sync.test.d.ts.map +1 -0
- package/dist/__tests__/db-sync.test.js +167 -0
- package/dist/__tests__/db-sync.test.js.map +1 -0
- package/dist/__tests__/deployment-diagnostics.test.d.ts +2 -0
- package/dist/__tests__/deployment-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/deployment-diagnostics.test.js +401 -0
- package/dist/__tests__/deployment-diagnostics.test.js.map +1 -0
- package/dist/__tests__/form-seed.test.d.ts +2 -0
- package/dist/__tests__/form-seed.test.d.ts.map +1 -0
- package/dist/__tests__/form-seed.test.js +79 -0
- package/dist/__tests__/form-seed.test.js.map +1 -0
- package/dist/__tests__/init.test.d.ts +2 -0
- package/dist/__tests__/init.test.d.ts.map +1 -0
- package/dist/__tests__/init.test.js +25 -0
- package/dist/__tests__/init.test.js.map +1 -0
- package/dist/__tests__/load-dotenv.test.d.ts +2 -0
- package/dist/__tests__/load-dotenv.test.d.ts.map +1 -0
- package/dist/__tests__/load-dotenv.test.js +40 -0
- package/dist/__tests__/load-dotenv.test.js.map +1 -0
- package/dist/__tests__/mcp-init.test.d.ts +2 -0
- package/dist/__tests__/mcp-init.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-init.test.js +100 -0
- package/dist/__tests__/mcp-init.test.js.map +1 -0
- package/dist/__tests__/prisma-client-path.test.d.ts +2 -0
- package/dist/__tests__/prisma-client-path.test.d.ts.map +1 -0
- package/dist/__tests__/prisma-client-path.test.js +66 -0
- package/dist/__tests__/prisma-client-path.test.js.map +1 -0
- package/dist/__tests__/schema-fragment.test.d.ts +2 -0
- package/dist/__tests__/schema-fragment.test.d.ts.map +1 -0
- package/dist/__tests__/schema-fragment.test.js +40 -0
- package/dist/__tests__/schema-fragment.test.js.map +1 -0
- package/dist/__tests__/seed.test.d.ts +2 -0
- package/dist/__tests__/seed.test.d.ts.map +1 -0
- package/dist/__tests__/seed.test.js +207 -0
- package/dist/__tests__/seed.test.js.map +1 -0
- package/dist/__tests__/upgrade.test.d.ts +2 -0
- package/dist/__tests__/upgrade.test.d.ts.map +1 -0
- package/dist/__tests__/upgrade.test.js +41 -0
- package/dist/__tests__/upgrade.test.js.map +1 -0
- package/dist/__tests__/vercel-env-matrix.test.d.ts +2 -0
- package/dist/__tests__/vercel-env-matrix.test.d.ts.map +1 -0
- package/dist/__tests__/vercel-env-matrix.test.js +56 -0
- package/dist/__tests__/vercel-env-matrix.test.js.map +1 -0
- package/dist/commands/db-init.d.ts +24 -0
- package/dist/commands/db-init.d.ts.map +1 -0
- package/dist/commands/db-init.js +195 -0
- package/dist/commands/db-init.js.map +1 -0
- package/dist/commands/db-status.d.ts +3 -0
- package/dist/commands/db-status.d.ts.map +1 -0
- package/dist/commands/db-status.js +108 -0
- package/dist/commands/db-status.js.map +1 -0
- package/dist/commands/db-sync.d.ts +66 -0
- package/dist/commands/db-sync.d.ts.map +1 -0
- package/dist/commands/db-sync.js +310 -0
- package/dist/commands/db-sync.js.map +1 -0
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +282 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +99 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +24 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/import.d.ts +3 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +201 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +31 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +126 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate-media-usage.d.ts +3 -0
- package/dist/commands/migrate-media-usage.d.ts.map +1 -0
- package/dist/commands/migrate-media-usage.js +52 -0
- package/dist/commands/migrate-media-usage.js.map +1 -0
- package/dist/commands/migrate-meta.d.ts +3 -0
- package/dist/commands/migrate-meta.d.ts.map +1 -0
- package/dist/commands/migrate-meta.js +81 -0
- package/dist/commands/migrate-meta.js.map +1 -0
- package/dist/commands/migrate-schema.d.ts +3 -0
- package/dist/commands/migrate-schema.d.ts.map +1 -0
- package/dist/commands/migrate-schema.js +84 -0
- package/dist/commands/migrate-schema.js.map +1 -0
- package/dist/commands/migrate-sections.d.ts +3 -0
- package/dist/commands/migrate-sections.d.ts.map +1 -0
- package/dist/commands/migrate-sections.js +56 -0
- package/dist/commands/migrate-sections.js.map +1 -0
- package/dist/commands/migrate.d.ts +3 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +51 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/seed.d.ts +60 -0
- package/dist/commands/seed.d.ts.map +1 -0
- package/dist/commands/seed.js +585 -0
- package/dist/commands/seed.js.map +1 -0
- package/dist/commands/update-check.d.ts +3 -0
- package/dist/commands/update-check.d.ts.map +1 -0
- package/dist/commands/update-check.js +132 -0
- package/dist/commands/update-check.js.map +1 -0
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +175 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/vercel-blob-link.d.ts +3 -0
- package/dist/commands/vercel-blob-link.d.ts.map +1 -0
- package/dist/commands/vercel-blob-link.js +83 -0
- package/dist/commands/vercel-blob-link.js.map +1 -0
- package/dist/deployment/diagnostics.d.ts +136 -0
- package/dist/deployment/diagnostics.d.ts.map +1 -0
- package/dist/deployment/diagnostics.js +575 -0
- package/dist/deployment/diagnostics.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/database.d.ts +21 -0
- package/dist/utils/database.d.ts.map +1 -0
- package/dist/utils/database.js +98 -0
- package/dist/utils/database.js.map +1 -0
- package/dist/utils/form-seed.d.ts +15 -0
- package/dist/utils/form-seed.d.ts.map +1 -0
- package/dist/utils/form-seed.js +97 -0
- package/dist/utils/form-seed.js.map +1 -0
- package/dist/utils/load-dotenv.d.ts +11 -0
- package/dist/utils/load-dotenv.d.ts.map +1 -0
- package/dist/utils/load-dotenv.js +47 -0
- package/dist/utils/load-dotenv.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +16 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/prisma-client-path.d.ts +20 -0
- package/dist/utils/prisma-client-path.d.ts.map +1 -0
- package/dist/utils/prisma-client-path.js +77 -0
- package/dist/utils/prisma-client-path.js.map +1 -0
- package/dist/vercel/client.d.ts +32 -0
- package/dist/vercel/client.d.ts.map +1 -0
- package/dist/vercel/client.js +74 -0
- package/dist/vercel/client.js.map +1 -0
- package/dist/vercel/env-matrix.d.ts +35 -0
- package/dist/vercel/env-matrix.d.ts.map +1 -0
- package/dist/vercel/env-matrix.js +66 -0
- package/dist/vercel/env-matrix.js.map +1 -0
- package/package.json +41 -0
- package/src/__tests__/db-init.test.ts +155 -0
- package/src/__tests__/db-sync-resolver.test.ts +29 -0
- package/src/__tests__/db-sync.test.ts +221 -0
- package/src/__tests__/deployment-diagnostics.test.ts +474 -0
- package/src/__tests__/form-seed.test.ts +91 -0
- package/src/__tests__/init.test.ts +30 -0
- package/src/__tests__/load-dotenv.test.ts +53 -0
- package/src/__tests__/mcp-init.test.ts +125 -0
- package/src/__tests__/prisma-client-path.test.ts +87 -0
- package/src/__tests__/schema-fragment.test.ts +51 -0
- package/src/__tests__/seed.test.ts +249 -0
- package/src/__tests__/upgrade.test.ts +44 -0
- package/src/__tests__/vercel-env-matrix.test.ts +65 -0
- package/src/commands/db-init.ts +211 -0
- package/src/commands/db-status.ts +122 -0
- package/src/commands/db-sync.ts +367 -0
- package/src/commands/doctor.ts +354 -0
- package/src/commands/export.ts +118 -0
- package/src/commands/generate.ts +26 -0
- package/src/commands/import.ts +228 -0
- package/src/commands/init.ts +36 -0
- package/src/commands/mcp.ts +181 -0
- package/src/commands/migrate-media-usage.ts +68 -0
- package/src/commands/migrate-meta.ts +107 -0
- package/src/commands/migrate-schema.ts +110 -0
- package/src/commands/migrate-sections.ts +73 -0
- package/src/commands/migrate.ts +56 -0
- package/src/commands/seed.ts +693 -0
- package/src/commands/update-check.ts +152 -0
- package/src/commands/upgrade.ts +202 -0
- package/src/commands/vercel-blob-link.ts +116 -0
- package/src/deployment/diagnostics.ts +735 -0
- package/src/index.ts +54 -0
- package/src/utils/database.ts +126 -0
- package/src/utils/form-seed.ts +137 -0
- package/src/utils/load-dotenv.ts +52 -0
- package/src/utils/logger.ts +26 -0
- package/src/utils/prisma-client-path.ts +81 -0
- package/src/vercel/client.ts +112 -0
- package/src/vercel/env-matrix.ts +112 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildDeploymentManifest,
|
|
5
|
+
createDiagnosticReport,
|
|
6
|
+
detectBlobLinkState,
|
|
7
|
+
detectFormsLaunchReadiness,
|
|
8
|
+
detectFormsWebMcpReadiness,
|
|
9
|
+
REQUIRED_CMS_MODELS,
|
|
10
|
+
REQUIRED_ENV_VARS,
|
|
11
|
+
} from '../deployment/diagnostics.js'
|
|
12
|
+
|
|
13
|
+
describe('deployment diagnostics', () => {
|
|
14
|
+
it('tracks deploy-critical models used by first-run admin features', () => {
|
|
15
|
+
expect(REQUIRED_CMS_MODELS).toEqual(
|
|
16
|
+
expect.arrayContaining([
|
|
17
|
+
'User',
|
|
18
|
+
'Session',
|
|
19
|
+
'Document',
|
|
20
|
+
'Media',
|
|
21
|
+
'Version',
|
|
22
|
+
'Folder',
|
|
23
|
+
'Redirect',
|
|
24
|
+
'FormSubmission',
|
|
25
|
+
'AuditLog',
|
|
26
|
+
'PasswordResetToken',
|
|
27
|
+
'MediaUsage',
|
|
28
|
+
'ScriptTag',
|
|
29
|
+
'PageTemplate',
|
|
30
|
+
'SavedSection',
|
|
31
|
+
]),
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('reports missing models and env vars with exact fix commands', () => {
|
|
36
|
+
const report = createDiagnosticReport({
|
|
37
|
+
schemaModels: new Set(['User', 'Session', 'Document']),
|
|
38
|
+
schemaContent: '',
|
|
39
|
+
env: {
|
|
40
|
+
DATABASE_URL: 'postgresql://example',
|
|
41
|
+
},
|
|
42
|
+
packageManager: 'pnpm',
|
|
43
|
+
schemaPath: 'prisma/schema.prisma',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
expect(report.status).toBe('fail')
|
|
47
|
+
expect(report.checks).toEqual(
|
|
48
|
+
expect.arrayContaining([
|
|
49
|
+
expect.objectContaining({
|
|
50
|
+
id: 'schema-models',
|
|
51
|
+
status: 'fail',
|
|
52
|
+
fix: 'Run `prenta db:init --schema prisma/schema.prisma` for new schemas, or update the existing Prenta block from the database setup docs, then create and apply a Prisma migration.',
|
|
53
|
+
}),
|
|
54
|
+
expect.objectContaining({
|
|
55
|
+
id: 'environment',
|
|
56
|
+
status: 'fail',
|
|
57
|
+
fix: 'Set missing environment variables before deploying: CMS_SECRET, CMS_ENCRYPTION_KEY, NEXT_PUBLIC_SITE_URL.',
|
|
58
|
+
}),
|
|
59
|
+
]),
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('requires migration connection details for deploy checks', () => {
|
|
64
|
+
const report = createDiagnosticReport({
|
|
65
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
66
|
+
schemaContent: '',
|
|
67
|
+
env: {
|
|
68
|
+
DATABASE_URL: 'postgresql://example',
|
|
69
|
+
CMS_SECRET: 'secret',
|
|
70
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
71
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
72
|
+
},
|
|
73
|
+
packageManager: 'pnpm',
|
|
74
|
+
schemaPath: 'prisma/schema.prisma',
|
|
75
|
+
mode: 'deploy',
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
expect(report.status).toBe('fail')
|
|
79
|
+
expect(report.checks).toEqual(
|
|
80
|
+
expect.arrayContaining([
|
|
81
|
+
expect.objectContaining({
|
|
82
|
+
id: 'environment',
|
|
83
|
+
message: expect.stringContaining('DIRECT_DATABASE_URL'),
|
|
84
|
+
}),
|
|
85
|
+
]),
|
|
86
|
+
)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('warns when designed marketing pages appear to use flat fields instead of page-builder content', () => {
|
|
90
|
+
const report = createDiagnosticReport({
|
|
91
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
92
|
+
schemaContent: '',
|
|
93
|
+
configContent: `
|
|
94
|
+
export default defineConfig({
|
|
95
|
+
collections: {
|
|
96
|
+
pages: {
|
|
97
|
+
slug: 'pages',
|
|
98
|
+
fields: {
|
|
99
|
+
title: { type: 'text' },
|
|
100
|
+
slug: { type: 'slug' },
|
|
101
|
+
heroHeadline: { type: 'text' },
|
|
102
|
+
heroSubheadline: { type: 'text' },
|
|
103
|
+
heroImage: { type: 'media' },
|
|
104
|
+
bodyContent: { type: 'richText' },
|
|
105
|
+
ctaButtonText: { type: 'text' }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
`,
|
|
111
|
+
env: {
|
|
112
|
+
DATABASE_URL: 'postgresql://example',
|
|
113
|
+
CMS_SECRET: 'secret',
|
|
114
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
115
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
116
|
+
},
|
|
117
|
+
packageManager: 'pnpm',
|
|
118
|
+
schemaPath: 'prisma/schema.prisma',
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
expect(report.status).toBe('warn')
|
|
122
|
+
expect(report.checks).toEqual(
|
|
123
|
+
expect.arrayContaining([
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
id: 'design-first-page-builder',
|
|
126
|
+
status: 'warn',
|
|
127
|
+
docs: 'https://prentacms.dev/docs/design-first-page-builder',
|
|
128
|
+
}),
|
|
129
|
+
]),
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('passes when Marketplace Blob is linked via BLOB_STORE_ID without read-write token', () => {
|
|
134
|
+
const report = createDiagnosticReport({
|
|
135
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
136
|
+
schemaContent: '',
|
|
137
|
+
env: {
|
|
138
|
+
DATABASE_URL: 'postgresql://example',
|
|
139
|
+
CMS_SECRET: 'secret',
|
|
140
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
141
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
142
|
+
BLOB_STORE_ID: 'store_abc123',
|
|
143
|
+
BLOB_WEBHOOK_PUBLIC_KEY: 'pk_abc',
|
|
144
|
+
},
|
|
145
|
+
packageManager: 'pnpm',
|
|
146
|
+
schemaPath: 'prisma/schema.prisma',
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
expect(report.checks).toEqual(
|
|
150
|
+
expect.arrayContaining([
|
|
151
|
+
expect.objectContaining({
|
|
152
|
+
id: 'blob-storage',
|
|
153
|
+
status: 'pass',
|
|
154
|
+
message: expect.stringMatching(/Marketplace|OIDC|BLOB_STORE_ID/i),
|
|
155
|
+
}),
|
|
156
|
+
]),
|
|
157
|
+
)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('fails when blob is referenced but BLOB_STORE_ID is missing', () => {
|
|
161
|
+
const report = createDiagnosticReport({
|
|
162
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
163
|
+
schemaContent: '',
|
|
164
|
+
env: {
|
|
165
|
+
DATABASE_URL: 'postgresql://example',
|
|
166
|
+
CMS_SECRET: 'secret',
|
|
167
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
168
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
169
|
+
BLOB_WEBHOOK_PUBLIC_KEY: 'pk_abc',
|
|
170
|
+
},
|
|
171
|
+
configContent: "provider: 'vercel-blob'",
|
|
172
|
+
packageManager: 'pnpm',
|
|
173
|
+
schemaPath: 'prisma/schema.prisma',
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
expect(report.status).toBe('fail')
|
|
177
|
+
expect(report.checks).toEqual(
|
|
178
|
+
expect.arrayContaining([expect.objectContaining({ id: 'blob-storage', status: 'fail' })]),
|
|
179
|
+
)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('passes the blob check when no Blob storage is configured', () => {
|
|
183
|
+
const report = createDiagnosticReport({
|
|
184
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
185
|
+
schemaContent: '',
|
|
186
|
+
env: {
|
|
187
|
+
DATABASE_URL: 'postgresql://example',
|
|
188
|
+
CMS_SECRET: 'secret',
|
|
189
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
190
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
191
|
+
},
|
|
192
|
+
packageManager: 'pnpm',
|
|
193
|
+
schemaPath: 'prisma/schema.prisma',
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
expect(report.checks).toEqual(
|
|
197
|
+
expect.arrayContaining([expect.objectContaining({ id: 'blob-storage', status: 'pass' })]),
|
|
198
|
+
)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('classifies blob link state from env and config signals', () => {
|
|
202
|
+
expect(detectBlobLinkState({ BLOB_READ_WRITE_TOKEN: 'vercel_blob_rw_x' })).toBe('ok')
|
|
203
|
+
expect(detectBlobLinkState({ BLOB_READ_WRITE_TOKEN: 'not-a-real-token' })).toBe('token-format')
|
|
204
|
+
expect(detectBlobLinkState({ BLOB_STORE_ID: 'store_x' })).toBe('ok')
|
|
205
|
+
expect(detectBlobLinkState({ BLOB_WEBHOOK_PUBLIC_KEY: 'pk_x' })).toBe('partial')
|
|
206
|
+
expect(detectBlobLinkState({}, "storage: { provider: 'vercel-blob' }")).toBe('partial')
|
|
207
|
+
expect(detectBlobLinkState({})).toBe('none')
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('exposes machine-readable deployment metadata', () => {
|
|
211
|
+
const manifest = buildDeploymentManifest()
|
|
212
|
+
|
|
213
|
+
expect(manifest.requiredModels).toEqual(REQUIRED_CMS_MODELS)
|
|
214
|
+
expect(manifest.requiredEnv).toEqual(REQUIRED_ENV_VARS)
|
|
215
|
+
expect(manifest.routes.apiHealth).toBe('/api/cms/health')
|
|
216
|
+
expect(manifest.crons.scheduledPublish).toBe('/api/cms/cron/publish')
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('warns when recommended production plugins are missing', () => {
|
|
220
|
+
const report = createDiagnosticReport({
|
|
221
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
222
|
+
schemaContent: '',
|
|
223
|
+
configContent: 'export default defineConfig({ plugins: [] })',
|
|
224
|
+
env: {
|
|
225
|
+
DATABASE_URL: 'postgresql://example',
|
|
226
|
+
CMS_SECRET: 'secret',
|
|
227
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
228
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
229
|
+
},
|
|
230
|
+
packageManager: 'pnpm',
|
|
231
|
+
schemaPath: 'prisma/schema.prisma',
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
expect(report.checks).toEqual(
|
|
235
|
+
expect.arrayContaining([
|
|
236
|
+
expect.objectContaining({ id: 'production-plugins', status: 'warn' }),
|
|
237
|
+
]),
|
|
238
|
+
)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it('detects Astro split deploy and skips Next ISR catch-all warnings', () => {
|
|
242
|
+
const report = createDiagnosticReport({
|
|
243
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
244
|
+
schemaContent: '',
|
|
245
|
+
configContent: 'seoPlugin() formsPlugin() redirectsPlugin() mediaPlugin() emailPlugin()',
|
|
246
|
+
env: {
|
|
247
|
+
DATABASE_URL: 'postgresql://example',
|
|
248
|
+
CMS_SECRET: 'secret',
|
|
249
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
250
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
251
|
+
},
|
|
252
|
+
packageManager: 'pnpm',
|
|
253
|
+
schemaPath: 'prisma/schema.prisma',
|
|
254
|
+
projectFiles: {
|
|
255
|
+
apiRoute: 'handlePrentaAPI({ cache: { publicReads: {}, onInvalidate() {} } })',
|
|
256
|
+
astroConfigPresent: true,
|
|
257
|
+
astroCmsLib: `
|
|
258
|
+
import { createAstroSiteHelpers } from '@prenta/core/astro/site';
|
|
259
|
+
export const { getPublishedDocument } = createAstroSiteHelpers({
|
|
260
|
+
baseUrl: import.meta.env.PRENTA_CMS_URL,
|
|
261
|
+
});
|
|
262
|
+
`,
|
|
263
|
+
astroCatchAll: 'getPublishedDocument(urlPath)',
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
expect(report.checks).toEqual(
|
|
268
|
+
expect.arrayContaining([
|
|
269
|
+
expect.objectContaining({ id: 'astro-split-site', status: 'pass' }),
|
|
270
|
+
expect.objectContaining({ id: 'astro-cms-helpers', status: 'pass' }),
|
|
271
|
+
expect.objectContaining({ id: 'seo-public-routes', status: 'pass' }),
|
|
272
|
+
expect.objectContaining({ id: 'cached-resolve', status: 'pass' }),
|
|
273
|
+
]),
|
|
274
|
+
)
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
it('warns when catch-all resolves without ISR caching helpers', () => {
|
|
278
|
+
const report = createDiagnosticReport({
|
|
279
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
280
|
+
schemaContent: '',
|
|
281
|
+
configContent: 'seoPlugin() formsPlugin() redirectsPlugin() mediaPlugin() emailPlugin()',
|
|
282
|
+
env: {
|
|
283
|
+
DATABASE_URL: 'postgresql://example',
|
|
284
|
+
CMS_SECRET: 'secret',
|
|
285
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
286
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
287
|
+
},
|
|
288
|
+
packageManager: 'pnpm',
|
|
289
|
+
schemaPath: 'prisma/schema.prisma',
|
|
290
|
+
projectFiles: {
|
|
291
|
+
catchAllPage: `
|
|
292
|
+
export async function generateMetadata() {
|
|
293
|
+
return resolveDocument(urlPath);
|
|
294
|
+
}
|
|
295
|
+
export default async function Page() {
|
|
296
|
+
await resolveDocument(urlPath);
|
|
297
|
+
}
|
|
298
|
+
`,
|
|
299
|
+
cmsLib: 'export function resolveDocument() {}',
|
|
300
|
+
},
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
expect(report.checks).toEqual(
|
|
304
|
+
expect.arrayContaining([expect.objectContaining({ id: 'cached-resolve', status: 'warn' })]),
|
|
305
|
+
)
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it('passes cached-resolve when createNextSiteHelpers is wired', () => {
|
|
309
|
+
const report = createDiagnosticReport({
|
|
310
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
311
|
+
schemaContent: '',
|
|
312
|
+
configContent: 'seoPlugin() formsPlugin() redirectsPlugin() mediaPlugin() emailPlugin()',
|
|
313
|
+
env: {
|
|
314
|
+
DATABASE_URL: 'postgresql://example',
|
|
315
|
+
CMS_SECRET: 'secret',
|
|
316
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
317
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
318
|
+
},
|
|
319
|
+
packageManager: 'pnpm',
|
|
320
|
+
schemaPath: 'prisma/schema.prisma',
|
|
321
|
+
projectFiles: {
|
|
322
|
+
catchAllPage: `
|
|
323
|
+
export async function generateMetadata() {
|
|
324
|
+
return getCachedPageMetadata(urlPath);
|
|
325
|
+
}
|
|
326
|
+
export default async function Page({ searchParams }) {
|
|
327
|
+
const { preview } = await searchParams;
|
|
328
|
+
return preview ? resolveDocument(urlPath, preview) : getCachedPublishedDocument(urlPath);
|
|
329
|
+
}
|
|
330
|
+
result.jsonLd
|
|
331
|
+
`,
|
|
332
|
+
cmsLib: 'createNextSiteHelpers() getCachedPageMetadata getCachedPublishedDocument',
|
|
333
|
+
apiRoute: 'publicReads: { enabled: true } onInvalidate revalidateTag',
|
|
334
|
+
llmsRoute: 'export async function GET() {}',
|
|
335
|
+
robotsRoute: 'export async function GET() {}',
|
|
336
|
+
sitemapRoute: 'export async function GET() {}',
|
|
337
|
+
},
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
expect(report.checks).toEqual(
|
|
341
|
+
expect.arrayContaining([
|
|
342
|
+
expect.objectContaining({ id: 'cached-resolve', status: 'pass' }),
|
|
343
|
+
expect.objectContaining({ id: 'seo-public-routes', status: 'pass' }),
|
|
344
|
+
expect.objectContaining({ id: 'structured-data-html', status: 'pass' }),
|
|
345
|
+
expect.objectContaining({ id: 'api-cache-invalidation', status: 'pass' }),
|
|
346
|
+
]),
|
|
347
|
+
)
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
it('warns when catch-all omits JSON-LD and API route lacks cache wiring', () => {
|
|
351
|
+
const report = createDiagnosticReport({
|
|
352
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
353
|
+
schemaContent: '',
|
|
354
|
+
configContent: 'seoPlugin() formsPlugin() redirectsPlugin() mediaPlugin() emailPlugin()',
|
|
355
|
+
env: {
|
|
356
|
+
DATABASE_URL: 'postgresql://example',
|
|
357
|
+
CMS_SECRET: 'secret',
|
|
358
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
359
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
360
|
+
},
|
|
361
|
+
packageManager: 'pnpm',
|
|
362
|
+
schemaPath: 'prisma/schema.prisma',
|
|
363
|
+
projectFiles: {
|
|
364
|
+
catchAllPage: 'getCachedPublishedDocument(urlPath)',
|
|
365
|
+
apiRoute: 'handlePrentaAPI({ prismaClient, config })',
|
|
366
|
+
},
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
expect(report.checks).toEqual(
|
|
370
|
+
expect.arrayContaining([
|
|
371
|
+
expect.objectContaining({ id: 'structured-data-html', status: 'warn' }),
|
|
372
|
+
expect.objectContaining({ id: 'api-cache-invalidation', status: 'warn' }),
|
|
373
|
+
]),
|
|
374
|
+
)
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
it('detectFormsWebMcpReadiness passes when catch-all prefetches forms', () => {
|
|
378
|
+
expect(
|
|
379
|
+
detectFormsWebMcpReadiness(
|
|
380
|
+
'formsPlugin()',
|
|
381
|
+
'await prefetchPublicForms(getPublicForm); prefetchedForms',
|
|
382
|
+
),
|
|
383
|
+
).toMatchObject({ status: 'pass' })
|
|
384
|
+
expect(detectFormsWebMcpReadiness('webmcp: { enabled: false }', '')).toMatchObject({
|
|
385
|
+
status: 'warn',
|
|
386
|
+
})
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
it('detectFormsLaunchReadiness finds contact form + page in marketing seed shape', () => {
|
|
390
|
+
const seed = JSON.stringify({
|
|
391
|
+
collections: {
|
|
392
|
+
forms: [{ status: 'PUBLISHED', data: { slug: 'contact', status: 'active' } }],
|
|
393
|
+
pages: [
|
|
394
|
+
{
|
|
395
|
+
status: 'PUBLISHED',
|
|
396
|
+
data: {
|
|
397
|
+
slug: 'contact',
|
|
398
|
+
path: '/contact',
|
|
399
|
+
sections: [{ sectionType: 'form', content: { formSlug: 'contact' } }],
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
})
|
|
405
|
+
expect(detectFormsLaunchReadiness('formsPlugin()', seed)).toEqual({
|
|
406
|
+
hasFormsPlugin: true,
|
|
407
|
+
hasSeedFile: true,
|
|
408
|
+
hasContactForm: true,
|
|
409
|
+
hasContactPageWithForm: true,
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
it('adds forms launch checks when forms plugin is registered', () => {
|
|
414
|
+
const seed = JSON.stringify({
|
|
415
|
+
collections: {
|
|
416
|
+
forms: [{ status: 'PUBLISHED', data: { slug: 'contact', status: 'active' } }],
|
|
417
|
+
pages: [
|
|
418
|
+
{
|
|
419
|
+
status: 'PUBLISHED',
|
|
420
|
+
data: {
|
|
421
|
+
slug: 'contact',
|
|
422
|
+
path: '/contact',
|
|
423
|
+
sections: [{ sectionType: 'form', content: { formSlug: 'contact' } }],
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
},
|
|
428
|
+
})
|
|
429
|
+
const report = createDiagnosticReport({
|
|
430
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
431
|
+
schemaContent: '',
|
|
432
|
+
configContent: 'formsPlugin()',
|
|
433
|
+
env: {
|
|
434
|
+
DATABASE_URL: 'postgresql://example',
|
|
435
|
+
CMS_SECRET: 'secret',
|
|
436
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
437
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
438
|
+
},
|
|
439
|
+
packageManager: 'pnpm',
|
|
440
|
+
schemaPath: 'prisma/schema.prisma',
|
|
441
|
+
projectFiles: { seedFile: seed },
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
expect(report.checks).toEqual(
|
|
445
|
+
expect.arrayContaining([
|
|
446
|
+
expect.objectContaining({ id: 'forms-contact-seed', status: 'pass' }),
|
|
447
|
+
expect.objectContaining({ id: 'forms-crm-webhook', status: 'warn' }),
|
|
448
|
+
]),
|
|
449
|
+
)
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
it('warns when forms plugin is on but contact seed is incomplete', () => {
|
|
453
|
+
const report = createDiagnosticReport({
|
|
454
|
+
schemaModels: new Set(REQUIRED_CMS_MODELS),
|
|
455
|
+
schemaContent: '',
|
|
456
|
+
configContent: 'formsPlugin()',
|
|
457
|
+
env: {
|
|
458
|
+
DATABASE_URL: 'postgresql://example',
|
|
459
|
+
CMS_SECRET: 'secret',
|
|
460
|
+
CMS_ENCRYPTION_KEY: 'a'.repeat(64),
|
|
461
|
+
NEXT_PUBLIC_SITE_URL: 'https://example.com',
|
|
462
|
+
},
|
|
463
|
+
packageManager: 'pnpm',
|
|
464
|
+
schemaPath: 'prisma/schema.prisma',
|
|
465
|
+
projectFiles: { seedFile: '{"collections":{"pages":[]}}' },
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
expect(report.checks).toEqual(
|
|
469
|
+
expect.arrayContaining([
|
|
470
|
+
expect.objectContaining({ id: 'forms-contact-seed', status: 'warn' }),
|
|
471
|
+
]),
|
|
472
|
+
)
|
|
473
|
+
})
|
|
474
|
+
})
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
// seed.js transitively imports cms-core helpers at module scope via mocks
|
|
4
|
+
// elsewhere; keep the same stub so importing DEMO_FORMS stays side-effect-free.
|
|
5
|
+
vi.mock('@prenta/core', () => ({
|
|
6
|
+
extractPlainText: vi.fn(),
|
|
7
|
+
hashContent: vi.fn(),
|
|
8
|
+
sanitizeHtml: vi.fn(),
|
|
9
|
+
createInitialAdmin: vi.fn(),
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
import { validateFormSeedData, validateFormSeeds } from '../utils/form-seed.js'
|
|
13
|
+
import { DEMO_FORMS } from '../commands/seed.js'
|
|
14
|
+
|
|
15
|
+
const validForm = () => ({
|
|
16
|
+
name: 'Contact',
|
|
17
|
+
slug: 'contact',
|
|
18
|
+
status: 'active',
|
|
19
|
+
fields: [{ id: 'f1', key: 'email', label: 'Email', type: 'email', required: true, sortOrder: 0 }],
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe('validateFormSeedData', () => {
|
|
23
|
+
it('accepts the canonical form shape', () => {
|
|
24
|
+
expect(validateFormSeedData(validForm())).toEqual([])
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('every DEMO_FORMS entry passes its own validation', () => {
|
|
28
|
+
for (const form of DEMO_FORMS) {
|
|
29
|
+
expect(validateFormSeedData(form, form.slug)).toEqual([])
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('explains the data.status vs document status split when status is missing', () => {
|
|
34
|
+
const { status: _status, ...form } = validForm()
|
|
35
|
+
const errors = validateFormSeedData(form)
|
|
36
|
+
expect(errors).toHaveLength(1)
|
|
37
|
+
expect(errors[0]).toContain('data.status to "active"')
|
|
38
|
+
expect(errors[0]).toContain('document envelope status')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('catches a document-envelope status (PUBLISHED) used as the form status', () => {
|
|
42
|
+
const errors = validateFormSeedData({ ...validForm(), status: 'PUBLISHED' })
|
|
43
|
+
expect(errors).toHaveLength(1)
|
|
44
|
+
expect(errors[0]).toContain('looks like a document envelope status')
|
|
45
|
+
expect(errors[0]).toContain('"active" | "draft" | "archived"')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('rejects unknown statuses with the allowed list', () => {
|
|
49
|
+
const errors = validateFormSeedData({ ...validForm(), status: 'live' })
|
|
50
|
+
expect(errors[0]).toContain('invalid data.status "live"')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('requires slug, name, and a non-empty fields array', () => {
|
|
54
|
+
const errors = validateFormSeedData({ status: 'active' })
|
|
55
|
+
expect(errors.some((e) => e.includes('"slug"'))).toBe(true)
|
|
56
|
+
expect(errors.some((e) => e.includes('"name"'))).toBe(true)
|
|
57
|
+
expect(errors.some((e) => e.includes('"fields"'))).toBe(true)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('points "name"-keyed fields (the old demo shape) at key/label', () => {
|
|
61
|
+
const errors = validateFormSeedData({
|
|
62
|
+
...validForm(),
|
|
63
|
+
fields: [{ name: 'email', type: 'email' }],
|
|
64
|
+
})
|
|
65
|
+
expect(errors.some((e) => e.includes('Rename name → key'))).toBe(true)
|
|
66
|
+
expect(errors.some((e) => e.includes('"label"'))).toBe(true)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('rejects unknown field types', () => {
|
|
70
|
+
const errors = validateFormSeedData({
|
|
71
|
+
...validForm(),
|
|
72
|
+
fields: [{ key: 'x', label: 'X', type: 'dropdown' }],
|
|
73
|
+
})
|
|
74
|
+
expect(errors[0]).toContain('invalid type "dropdown"')
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('validateFormSeeds', () => {
|
|
79
|
+
it('only validates forms-collection documents and labels errors by slug', () => {
|
|
80
|
+
const errors = validateFormSeeds([
|
|
81
|
+
{ collection: 'pages', data: { title: 'Home' } },
|
|
82
|
+
{ collection: 'forms', data: { ...validForm(), slug: 'contact', status: 'PUBLISHED' } },
|
|
83
|
+
])
|
|
84
|
+
expect(errors).toHaveLength(1)
|
|
85
|
+
expect(errors[0]).toContain('forms "contact"')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('returns no errors for a payload without forms', () => {
|
|
89
|
+
expect(validateFormSeeds([{ collection: 'pages', data: {} }])).toEqual([])
|
|
90
|
+
})
|
|
91
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
|
|
5
|
+
import { buildCreatePrentaArgs, registerInitCommand } from '../commands/init.js'
|
|
6
|
+
|
|
7
|
+
describe('init command', () => {
|
|
8
|
+
it('registers an init command that delegates to create-prenta', () => {
|
|
9
|
+
const program = new Command()
|
|
10
|
+
registerInitCommand(program)
|
|
11
|
+
|
|
12
|
+
const command = program.commands.find((candidate) => candidate.name() === 'init')
|
|
13
|
+
|
|
14
|
+
expect(command).toBeDefined()
|
|
15
|
+
expect(buildCreatePrentaArgs()).toEqual(['create', 'prenta@latest'])
|
|
16
|
+
expect(buildCreatePrentaArgs('maidpro-site')).toEqual([
|
|
17
|
+
'create',
|
|
18
|
+
'prenta@latest',
|
|
19
|
+
'maidpro-site',
|
|
20
|
+
])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('exposes an prenta-cms bin alias for installed CLI usage', async () => {
|
|
24
|
+
const raw = await readFile(new URL('../../package.json', import.meta.url), 'utf-8')
|
|
25
|
+
const pkg = JSON.parse(raw) as { bin?: Record<string, string> }
|
|
26
|
+
|
|
27
|
+
expect(pkg.bin?.prenta).toBe('dist/index.js')
|
|
28
|
+
expect(pkg.bin?.['prenta-cms']).toBe('dist/index.js')
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { mkdtemp, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
import { loadProjectEnv, parseDotenv } from '../utils/load-dotenv.js'
|
|
7
|
+
|
|
8
|
+
describe('parseDotenv', () => {
|
|
9
|
+
it('parses KEY=VALUE lines and strips quotes', () => {
|
|
10
|
+
expect(
|
|
11
|
+
parseDotenv(`
|
|
12
|
+
# comment
|
|
13
|
+
CMS_SECRET=abc123456789012345678901234567890
|
|
14
|
+
DATABASE_URL="postgresql://x"
|
|
15
|
+
EMPTY=
|
|
16
|
+
`),
|
|
17
|
+
).toEqual({
|
|
18
|
+
CMS_SECRET: 'abc123456789012345678901234567890',
|
|
19
|
+
DATABASE_URL: 'postgresql://x',
|
|
20
|
+
EMPTY: '',
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('loadProjectEnv', () => {
|
|
26
|
+
it('loads .env and lets .env.local override empty base values', async () => {
|
|
27
|
+
const dir = await mkdtemp(join(tmpdir(), 'prenta-doctor-env-'))
|
|
28
|
+
await writeFile(join(dir, '.env'), 'CMS_SECRET=from-dotenv\nCMS_ENCRYPTION_KEY=enc\n', 'utf-8')
|
|
29
|
+
await writeFile(
|
|
30
|
+
join(dir, '.env.local'),
|
|
31
|
+
'NEXT_PUBLIC_SITE_URL=http://localhost:3000\n',
|
|
32
|
+
'utf-8',
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const env = await loadProjectEnv(dir, {
|
|
36
|
+
DATABASE_URL: 'postgresql://preset',
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(env.DATABASE_URL).toBe('postgresql://preset')
|
|
40
|
+
expect(env.CMS_SECRET).toBe('from-dotenv')
|
|
41
|
+
expect(env.CMS_ENCRYPTION_KEY).toBe('enc')
|
|
42
|
+
expect(env.NEXT_PUBLIC_SITE_URL).toBe('http://localhost:3000')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('does not override non-empty values already in the parent env', async () => {
|
|
46
|
+
const dir = await mkdtemp(join(tmpdir(), 'prenta-doctor-env-'))
|
|
47
|
+
await writeFile(join(dir, '.env'), 'CMS_SECRET=from-file\n', 'utf-8')
|
|
48
|
+
|
|
49
|
+
const env = await loadProjectEnv(dir, { CMS_SECRET: 'from-shell' })
|
|
50
|
+
|
|
51
|
+
expect(env.CMS_SECRET).toBe('from-shell')
|
|
52
|
+
})
|
|
53
|
+
})
|