Starter: refuse single-language and non-pl-default sites explicitly (later); docs and tests
ipal-kit create stops before writing anything and points to the manual ipal-setup path; project-starter.md, AGENT.md, ipal-setup, ipal-site and the CHANGELOG say the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0170419473
commit
0dffb85ec1
+24
-3
@@ -1,4 +1,4 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import { existsSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
renderI18nConfig,
|
||||
renderSite,
|
||||
rewriteFonts,
|
||||
runCreateCli,
|
||||
secretFindings,
|
||||
type SiteContext,
|
||||
type StarterAnswers,
|
||||
@@ -121,11 +122,31 @@ describe('starter: answers', () => {
|
||||
expect(validateAnswers(a)).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('keeps to what the base seed backs: default pl, en present', () => {
|
||||
expect(validateAnswers(answers((x) => { x.languages.default = 'en' }))).toHaveLength(1)
|
||||
it('refuses single-language and English-default sites with a pointer to ipal-setup', () => {
|
||||
const single = validateAnswers(answers((x) => { x.languages.locales = [{ code: 'pl', label: 'Polski' }] }))
|
||||
expect(single).toHaveLength(1)
|
||||
expect(single[0]).toMatch(/single-language site is not supported by `ipal-kit create` yet .*ipal-setup/)
|
||||
const english = validateAnswers(answers((x) => { x.languages.default = 'en' }))
|
||||
expect(english).toHaveLength(1)
|
||||
expect(english[0]).toMatch(/default language other than "pl" \(here "en"\).*ipal-setup/)
|
||||
expect(validateAnswers(answers((x) => { x.languages.locales = [{ code: 'pl', label: 'Polski' }, { code: 'de', label: 'Deutsch' }] }))[0]).toMatch(/without "en"/)
|
||||
expect(validateAnswers(answers((x) => { x.languages.locales.push({ code: 'de', label: 'Deutsch' }) }))).toEqual([])
|
||||
})
|
||||
|
||||
it('stops the command before writing anything', async () => {
|
||||
const lines: string[] = []
|
||||
const dir = path.join(root, '.starter-test-single')
|
||||
const file = path.join(root, '.starter-test-answers.json')
|
||||
writeFileSync(file, JSON.stringify(answers((x) => { x.languages.locales = [{ code: 'pl', label: 'Polski' }] })))
|
||||
try {
|
||||
expect(await runCreateCli(['acme-test.pl', '--answers', file, '--dir', dir, '--no-install', '--no-git'], (line) => lines.push(line))).toBe(1)
|
||||
expect(lines.join('\n')).toMatch(/nothing was written[\s\S]*single-language site[\s\S]*ipal-setup/)
|
||||
expect(existsSync(dir)).toBe(false)
|
||||
} finally {
|
||||
rmSync(file, { force: true })
|
||||
}
|
||||
})
|
||||
|
||||
it('turns answers into the flags the reference markers test', () => {
|
||||
const flags = flagsFromAnswers(answers((x) => { x.consent.tools = ['metaPixel'] }))
|
||||
expect(flags).toMatchObject({ analytics: false, demo: false, enforceCsp: false, metaPixel: true, posts: true, scannerWithoutCrawl: true, twoFactor: true })
|
||||
|
||||
Reference in New Issue
Block a user