create-claudecraft 1.0.0 → 2.0.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/README.md +43 -178
- package/bin/cli.js +186 -1
- package/dist/answers.d.ts +269 -0
- package/dist/answers.js +215 -0
- package/dist/ink-prompts.d.ts +90 -12
- package/dist/ink-prompts.js +371 -330
- package/dist/lettering.d.ts +2 -0
- package/dist/lettering.js +28 -0
- package/lib/apps.mjs +141 -0
- package/lib/github.mjs +24 -0
- package/lib/init.mjs +153 -0
- package/lib/ports.mjs +56 -0
- package/lib/scaffold.mjs +218 -0
- package/lib/upgrade.mjs +164 -0
- package/package.json +39 -33
- package/templates/astro/.editorconfig +15 -0
- package/templates/astro/.env.example +2 -0
- package/templates/astro/.github/workflows/ci.yml +37 -0
- package/templates/astro/.github/workflows/deploy.yml +46 -0
- package/templates/astro/.nvmrc +1 -0
- package/templates/astro/.prettierignore +10 -0
- package/templates/astro/.prettierrc.json +7 -0
- package/templates/astro/.vscode/extensions.json +3 -0
- package/templates/astro/.vscode/settings.json +12 -0
- package/templates/astro/AGENTS.md +100 -0
- package/templates/astro/README.md +42 -0
- package/templates/astro/_CLAUDE.md +1 -0
- package/templates/astro/_claude/launch.json +13 -0
- package/templates/astro/_claude/settings.json +22 -0
- package/templates/astro/_codex/environments/environment.toml +20 -0
- package/templates/astro/_gitignore +31 -0
- package/templates/astro/_npmrc +8 -0
- package/templates/astro/_super.engineering/config.json +8 -0
- package/templates/astro/_zed/tasks.json +5 -0
- package/templates/astro/astro.config.mjs +111 -0
- package/templates/astro/docs/README.md +7 -0
- package/templates/astro/docs/decisions.md +3 -0
- package/templates/astro/docs/inbox.md +7 -0
- package/templates/astro/docs/kit/agent-apps.md +15 -0
- package/templates/astro/docs/kit/analytics.md +13 -0
- package/templates/astro/docs/kit/deploy.md +9 -0
- package/templates/astro/docs/kit/images.md +10 -0
- package/templates/astro/docs/kit/languages.md +8 -0
- package/templates/astro/docs/kit/local.md +16 -0
- package/templates/astro/docs/kit/seo.md +15 -0
- package/templates/astro/docs/kit/structure.md +40 -0
- package/templates/astro/docs/kit/upgrade.md +19 -0
- package/templates/astro/functions/_middleware.js +25 -0
- package/templates/astro/intent.md +40 -0
- package/templates/astro/package.json +46 -0
- package/templates/astro/public/_headers +17 -0
- package/templates/astro/public/_routes.json +5 -0
- package/templates/astro/public/apple-touch-icon.png +0 -0
- package/templates/astro/public/favicon-16.png +0 -0
- package/templates/astro/public/favicon-32.png +0 -0
- package/templates/astro/public/favicon.ico +0 -0
- package/templates/astro/public/favicon.svg +4 -0
- package/templates/astro/public/icon-192.png +0 -0
- package/templates/astro/public/icon-512.png +0 -0
- package/templates/astro/public/og-image.png +0 -0
- package/templates/astro/scripts/chrome.mjs +138 -0
- package/templates/astro/scripts/deploy.sh +69 -0
- package/templates/astro/scripts/generate-icons.mjs +73 -0
- package/templates/astro/scripts/generate-og.mjs +66 -0
- package/templates/astro/scripts/lint-copy.mjs +67 -0
- package/templates/astro/scripts/local-domain.mjs +115 -0
- package/templates/astro/scripts/markdown-pages.mjs +142 -0
- package/templates/astro/scripts/og-template.html +73 -0
- package/templates/astro/scripts/shared.mjs +33 -0
- package/templates/astro/scripts/verify-build.mjs +283 -0
- package/templates/astro/scripts/verify.mjs +19 -0
- package/templates/astro/site.config.mjs +85 -0
- package/templates/astro/src/components/Analytics.astro +49 -0
- package/templates/astro/src/components/Consent.astro +52 -0
- package/templates/astro/src/components/Counter.tsx +20 -0
- package/templates/astro/src/data/README.md +18 -0
- package/templates/astro/src/dev/styleguide.astro +43 -0
- package/templates/astro/src/env.d.ts +1 -0
- package/templates/astro/src/i18n/ar.json +29 -0
- package/templates/astro/src/i18n/de.json +29 -0
- package/templates/astro/src/i18n/en.json +29 -0
- package/templates/astro/src/i18n/es.json +29 -0
- package/templates/astro/src/i18n/fr.json +29 -0
- package/templates/astro/src/i18n/he.json +29 -0
- package/templates/astro/src/i18n/hi.json +29 -0
- package/templates/astro/src/i18n/index.ts +80 -0
- package/templates/astro/src/i18n/it.json +29 -0
- package/templates/astro/src/i18n/ja.json +29 -0
- package/templates/astro/src/i18n/ko.json +29 -0
- package/templates/astro/src/i18n/nl.json +29 -0
- package/templates/astro/src/i18n/pl.json +29 -0
- package/templates/astro/src/i18n/pt-br.json +29 -0
- package/templates/astro/src/i18n/ro.json +29 -0
- package/templates/astro/src/i18n/ru.json +29 -0
- package/templates/astro/src/i18n/sv.json +29 -0
- package/templates/astro/src/i18n/tr.json +29 -0
- package/templates/astro/src/i18n/uk.json +29 -0
- package/templates/astro/src/i18n/zh-cn.json +29 -0
- package/templates/astro/src/layouts/BaseLayout.astro +205 -0
- package/templates/astro/src/lib/cn.ts +7 -0
- package/templates/astro/src/lib/consent.ts +32 -0
- package/templates/astro/src/lib/seo.ts +18 -0
- package/templates/astro/src/lib/theme.ts +5 -0
- package/templates/astro/src/pages/404.astro +7 -0
- package/templates/astro/src/pages/[...locale]/404.astro +25 -0
- package/templates/astro/src/pages/[...locale]/about.astro +25 -0
- package/templates/astro/src/pages/[...locale]/index.astro +30 -0
- package/templates/astro/src/pages/[...locale]/privacy.astro +28 -0
- package/templates/astro/src/pages/robots.txt.ts +16 -0
- package/templates/astro/src/pages/site.webmanifest.ts +26 -0
- package/templates/astro/src/styles/global.css +163 -0
- package/templates/astro/t3.json +22 -0
- package/templates/astro/tsconfig.json +13 -0
- package/templates/astro/wrangler.toml +8 -0
- package/templates/react/.editorconfig +15 -0
- package/templates/react/.env.example +2 -0
- package/templates/react/.nvmrc +1 -0
- package/templates/react/.prettierignore +11 -0
- package/templates/react/.prettierrc.json +5 -0
- package/templates/react/.vscode/extensions.json +3 -0
- package/templates/react/.vscode/settings.json +4 -0
- package/templates/react/AGENTS.md +64 -0
- package/templates/react/README.md +31 -0
- package/templates/react/_CLAUDE.md +1 -0
- package/templates/react/_claude/launch.json +13 -0
- package/templates/react/_claude/settings.json +21 -0
- package/templates/react/_codex/environments/environment.toml +20 -0
- package/templates/react/_gitignore +17 -0
- package/templates/react/_npmrc +8 -0
- package/templates/react/_super.engineering/config.json +8 -0
- package/templates/react/_zed/tasks.json +5 -0
- package/templates/react/docs/decisions.md +3 -0
- package/templates/react/docs/inbox.md +7 -0
- package/templates/react/index.html +14 -0
- package/templates/react/package.json +47 -0
- package/templates/react/public/favicon.svg +5 -0
- package/templates/react/scripts/lint-copy.mjs +46 -0
- package/templates/react/scripts/lint-tokens.mjs +44 -0
- package/templates/react/scripts/local-domain.mjs +115 -0
- package/templates/react/scripts/verify.mjs +20 -0
- package/templates/react/site.config.mjs +23 -0
- package/templates/react/src/App.test.tsx +15 -0
- package/templates/react/src/App.tsx +21 -0
- package/templates/react/src/components/ErrorBoundary.tsx +42 -0
- package/templates/react/src/components/SkipLink.tsx +10 -0
- package/templates/react/src/config/site.ts +5 -0
- package/templates/react/src/lib/cn.ts +7 -0
- package/templates/react/src/main.tsx +13 -0
- package/templates/react/src/pages/HomePage.tsx +71 -0
- package/templates/react/src/pages/NotFoundPage.tsx +21 -0
- package/templates/react/src/styles/global.css +96 -0
- package/templates/react/src/test-setup.ts +1 -0
- package/templates/react/t3.json +22 -0
- package/templates/{base → react}/tsconfig.json +3 -3
- package/templates/react/vite.config.ts +26 -0
- package/templates/shared/_claude/hooks/design-lint.mjs +67 -0
- package/templates/shared/_claude/skills/design-quality/SKILL.md +113 -0
- package/templates/shared/_claude/skills/design-quality/references/composition-palette.md +87 -0
- package/templates/shared/_claude/skills/design-quality/references/copy-tells.md +49 -0
- package/templates/shared/_claude/skills/design-quality/references/visual-critic.md +75 -0
- package/templates/shared/design.md +148 -0
- package/templates/shared/intent.md +28 -0
- package/dist/constants.d.ts +0 -71
- package/dist/constants.js +0 -128
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -229
- package/dist/prompts.d.ts +0 -16
- package/dist/prompts.js +0 -434
- package/dist/scaffold.d.ts +0 -19
- package/dist/scaffold.js +0 -303
- package/dist/ui.d.ts +0 -27
- package/dist/ui.js +0 -254
- package/templates/app/App.tsx +0 -21
- package/templates/base/CLAUDE.md +0 -332
- package/templates/base/eslint.config.js +0 -28
- package/templates/base/index.html +0 -17
- package/templates/base/package.json +0 -43
- package/templates/base/postcss.config.js +0 -6
- package/templates/base/tailwind.config.js +0 -81
- package/templates/base/vite.config.ts +0 -16
- package/templates/commands/brainstorm.md +0 -6
- package/templates/commands/build.md +0 -41
- package/templates/commands/execute-plan.md +0 -6
- package/templates/commands/lint.md +0 -41
- package/templates/commands/ralph.md +0 -113
- package/templates/commands/typecheck.md +0 -44
- package/templates/commands/write-plan.md +0 -6
- package/templates/components/ErrorBoundary.tsx +0 -49
- package/templates/components/ui/Button.tsx +0 -60
- package/templates/components/ui/CodeBlock.tsx +0 -46
- package/templates/components/ui/CopyCommand.tsx +0 -38
- package/templates/components/ui/FilePreview.tsx +0 -46
- package/templates/components/ui/SkipLink.tsx +0 -7
- package/templates/components/ui/ThemeSelector.tsx +0 -41
- package/templates/components/ui/UICarousel.tsx +0 -309
- package/templates/context/ThemeContext.tsx +0 -61
- package/templates/homepage/HomePage.tsx +0 -534
- package/templates/homepage/NotFoundPage.tsx +0 -17
- package/templates/hooks/README.md +0 -82
- package/templates/hooks/check-branch.js +0 -27
- package/templates/hooks/typecheck-after-edit.js +0 -51
- package/templates/index.css +0 -67
- package/templates/lib/utils.ts +0 -9
- package/templates/main.tsx +0 -16
- package/templates/settings/MCP_SETUP.md +0 -76
- package/templates/settings/settings.json +0 -16
- package/templates/settings/settings.local.json +0 -37
- package/templates/skills/design/a11y-audit/SKILL.md +0 -173
- package/templates/skills/design/design-polish/SKILL.md +0 -75
- package/templates/skills/design/figma-to-code/SKILL.md +0 -157
- package/templates/skills/design/json-ld/SKILL.md +0 -125
- package/templates/skills/design/microcopy/SKILL.md +0 -197
- package/templates/skills/design/og-image/SKILL.md +0 -157
- package/templates/skills/design/ralph-wiggum-loops/SKILL.md +0 -299
- package/templates/skills/design/react-best-practices/SKILL.md +0 -106
- package/templates/skills/design/react-best-practices/references/react-performance-guidelines.md +0 -143
- package/templates/skills/design/seo-review/SKILL.md +0 -96
- package/templates/skills/design/sitemap-generator/SKILL.md +0 -66
- package/templates/skills/design/testing-patterns/SKILL.md +0 -276
- package/templates/skills/design/ui-skills/SKILL.md +0 -85
- package/templates/skills/design/visual-iteration/SKILL.md +0 -88
- package/templates/skills/workflow/brainstorming/SKILL.md +0 -54
- package/templates/skills/workflow/dispatching-parallel-agents/SKILL.md +0 -180
- package/templates/skills/workflow/executing-plans/SKILL.md +0 -76
- package/templates/skills/workflow/finishing-a-development-branch/SKILL.md +0 -200
- package/templates/skills/workflow/receiving-code-review/SKILL.md +0 -213
- package/templates/skills/workflow/requesting-code-review/SKILL.md +0 -105
- package/templates/skills/workflow/requesting-code-review/code-reviewer.md +0 -146
- package/templates/skills/workflow/subagent-driven-development/SKILL.md +0 -240
- package/templates/skills/workflow/subagent-driven-development/code-quality-reviewer-prompt.md +0 -20
- package/templates/skills/workflow/subagent-driven-development/implementer-prompt.md +0 -78
- package/templates/skills/workflow/subagent-driven-development/spec-reviewer-prompt.md +0 -61
- package/templates/skills/workflow/systematic-debugging/CREATION-LOG.md +0 -119
- package/templates/skills/workflow/systematic-debugging/SKILL.md +0 -296
- package/templates/skills/workflow/systematic-debugging/condition-based-waiting-example.ts +0 -158
- package/templates/skills/workflow/systematic-debugging/condition-based-waiting.md +0 -115
- package/templates/skills/workflow/systematic-debugging/defense-in-depth.md +0 -122
- package/templates/skills/workflow/systematic-debugging/find-polluter.sh +0 -63
- package/templates/skills/workflow/systematic-debugging/root-cause-tracing.md +0 -169
- package/templates/skills/workflow/systematic-debugging/test-academic.md +0 -14
- package/templates/skills/workflow/systematic-debugging/test-pressure-1.md +0 -58
- package/templates/skills/workflow/systematic-debugging/test-pressure-2.md +0 -68
- package/templates/skills/workflow/systematic-debugging/test-pressure-3.md +0 -69
- package/templates/skills/workflow/test-driven-development/SKILL.md +0 -371
- package/templates/skills/workflow/test-driven-development/testing-anti-patterns.md +0 -299
- package/templates/skills/workflow/using-git-worktrees/SKILL.md +0 -217
- package/templates/skills/workflow/using-superpowers/SKILL.md +0 -87
- package/templates/skills/workflow/verification-before-completion/SKILL.md +0 -139
- package/templates/skills/workflow/writing-plans/SKILL.md +0 -116
- package/templates/skills/workflow/writing-skills/SKILL.md +0 -655
- package/templates/skills/workflow/writing-skills/anthropic-best-practices.md +0 -1150
- package/templates/skills/workflow/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
- package/templates/skills/workflow/writing-skills/graphviz-conventions.dot +0 -172
- package/templates/skills/workflow/writing-skills/persuasion-principles.md +0 -187
- package/templates/skills/workflow/writing-skills/render-graphs.js +0 -168
- package/templates/skills/workflow/writing-skills/testing-skills-with-subagents.md +0 -384
- package/templates/types/index.ts +0 -17
- /package/templates/{vite-env.d.ts → react/src/vite-env.d.ts} +0 -0
package/dist/answers.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export const VERSION = '2.0.0';
|
|
5
|
+
/** Placeholder canonical origin until a real domain exists. Astro's npm run deploy refuses it. */
|
|
6
|
+
export const DEFAULT_SITE_URL = 'http://localhost:4321/';
|
|
7
|
+
export const TEMPLATES = [
|
|
8
|
+
{
|
|
9
|
+
id: 'astro',
|
|
10
|
+
label: 'Astro 7 site',
|
|
11
|
+
detail: 'Static marketing/content · Tailwind 4 · day-0 SEO/AEO · i18n · Cloudflare Pages',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'react',
|
|
15
|
+
label: 'React 19 app',
|
|
16
|
+
detail: 'Vite + TypeScript 5.9 · Tailwind 4 · React Router 7 · Vitest',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export const DEFAULT_TEMPLATE_ID = 'astro';
|
|
20
|
+
export function parseTemplate(value) {
|
|
21
|
+
if (!value)
|
|
22
|
+
return DEFAULT_TEMPLATE_ID;
|
|
23
|
+
const normalized = value.trim().toLowerCase();
|
|
24
|
+
if (normalized === 'astro' || normalized === 'react')
|
|
25
|
+
return normalized;
|
|
26
|
+
throw new Error(`Unknown template "${value}". Use: ${TEMPLATES.map((t) => t.id).join(', ')}`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Dominant accent for a new project, from Tailwind 4: `hex` 600 (light accent), `soft` 100 (light
|
|
30
|
+
* selection), `on` 50 (text on the accent), `dark` 400 and `darkSoft` 950 (dark appearance).
|
|
31
|
+
*/
|
|
32
|
+
export const ACCENT_PALETTE = [
|
|
33
|
+
{ id: 'blue', label: 'Blue', hex: '#155dfc', soft: '#dbeafe', on: '#eff6ff', dark: '#51a2ff', darkSoft: '#162456' },
|
|
34
|
+
{ id: 'indigo', label: 'Indigo', hex: '#4f39f6', soft: '#e0e7ff', on: '#eef2ff', dark: '#7c86ff', darkSoft: '#1e1a4d' },
|
|
35
|
+
{ id: 'violet', label: 'Violet', hex: '#7f22fe', soft: '#ede9fe', on: '#f5f3ff', dark: '#a684ff', darkSoft: '#2f0d68' },
|
|
36
|
+
{ id: 'fuchsia', label: 'Fuchsia', hex: '#c800de', soft: '#fae8ff', on: '#fdf4ff', dark: '#ed6aff', darkSoft: '#4b004f' },
|
|
37
|
+
{ id: 'pink', label: 'Pink', hex: '#e60076', soft: '#fce7f3', on: '#fdf2f8', dark: '#fb64b6', darkSoft: '#510424' },
|
|
38
|
+
{ id: 'rose', label: 'Rose', hex: '#ec003f', soft: '#ffe4e6', on: '#fff1f2', dark: '#ff637e', darkSoft: '#4d0218' },
|
|
39
|
+
{ id: 'orange', label: 'Orange', hex: '#f54900', soft: '#ffedd4', on: '#fff7ed', dark: '#ff8904', darkSoft: '#441306' },
|
|
40
|
+
{ id: 'emerald', label: 'Emerald', hex: '#009966', soft: '#d0fae5', on: '#ecfdf5', dark: '#00d492', darkSoft: '#002c22' },
|
|
41
|
+
{ id: 'teal', label: 'Teal', hex: '#009689', soft: '#cbfbf1', on: '#f0fdfa', dark: '#00d5be', darkSoft: '#022f2e' },
|
|
42
|
+
{ id: 'cyan', label: 'Cyan', hex: '#0092b8', soft: '#cefafe', on: '#ecfeff', dark: '#00d3f2', darkSoft: '#053345' },
|
|
43
|
+
{ id: 'sky', label: 'Sky', hex: '#0084d1', soft: '#dff2fe', on: '#f0f9ff', dark: '#00bcff', darkSoft: '#052f4a' },
|
|
44
|
+
];
|
|
45
|
+
export const DEFAULT_ACCENT_ID = 'orange';
|
|
46
|
+
export function accentById(id) {
|
|
47
|
+
return ACCENT_PALETTE.find((a) => a.id === id) ?? ACCENT_PALETTE.find((a) => a.id === DEFAULT_ACCENT_ID);
|
|
48
|
+
}
|
|
49
|
+
export const TEMPLATES_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../templates');
|
|
50
|
+
export const SHARED_TEMPLATE_DIR = path.join(TEMPLATES_ROOT, 'shared');
|
|
51
|
+
export const templateDirFor = (template) => path.join(TEMPLATES_ROOT, template);
|
|
52
|
+
/** One file per language in the Astro template: src/i18n/<code>.json. */
|
|
53
|
+
const I18N_DIR = path.join(templateDirFor('astro'), 'src', 'i18n');
|
|
54
|
+
export const DEFAULT_LOCALE = 'en';
|
|
55
|
+
/** Catalog languages: English first, then by English name. */
|
|
56
|
+
export const LANGUAGES = readdirSync(I18N_DIR)
|
|
57
|
+
.filter((file) => file.endsWith('.json'))
|
|
58
|
+
.map((file) => {
|
|
59
|
+
const { meta } = JSON.parse(readFileSync(path.join(I18N_DIR, file), 'utf8'));
|
|
60
|
+
return { code: file.slice(0, -'.json'.length), name: meta.name, english: meta.english };
|
|
61
|
+
})
|
|
62
|
+
.sort((a, b) => a.code === DEFAULT_LOCALE ? -1 : b.code === DEFAULT_LOCALE ? 1 : a.english.localeCompare(b.english, 'en'));
|
|
63
|
+
/** "de,en,ar" → default de, then the rest in catalog order. Empty → English only. */
|
|
64
|
+
export function parseLocales(csv) {
|
|
65
|
+
const codes = [...new Set((csv ?? '').split(',').map((c) => c.trim().toLowerCase()).filter(Boolean))];
|
|
66
|
+
const unknown = codes.filter((c) => !LANGUAGES.some((l) => l.code === c));
|
|
67
|
+
if (unknown.length) {
|
|
68
|
+
throw new Error(`Unknown language "${unknown.join('", "')}". Use: ${LANGUAGES.map((l) => l.code).join(', ')}`);
|
|
69
|
+
}
|
|
70
|
+
const defaultLocale = codes[0] ?? DEFAULT_LOCALE;
|
|
71
|
+
const rest = LANGUAGES.filter((l) => l.code !== defaultLocale && codes.includes(l.code)).map((l) => l.code);
|
|
72
|
+
return { locales: [defaultLocale, ...rest], defaultLocale };
|
|
73
|
+
}
|
|
74
|
+
/** Agent apps the scaffold can add a project to. lib/apps.mjs holds what each one does. */
|
|
75
|
+
export const APP_IDS = ['super', 't3', 'claude', 'codex', 'cursor', 'zed'];
|
|
76
|
+
/** --add value: "claude,cursor", "all" (the apps on this machine) or "none". Empty → none. */
|
|
77
|
+
export function parseApps(csv, installed) {
|
|
78
|
+
const value = (csv ?? '').trim().toLowerCase();
|
|
79
|
+
if (!value || value === 'none')
|
|
80
|
+
return [];
|
|
81
|
+
if (value === 'all')
|
|
82
|
+
return [...installed];
|
|
83
|
+
const ids = [...new Set(value.split(',').map((id) => id.trim()).filter(Boolean))];
|
|
84
|
+
const unknown = ids.filter((id) => !APP_IDS.includes(id));
|
|
85
|
+
if (unknown.length) {
|
|
86
|
+
throw new Error(`Unknown app "${unknown.join('", "')}". Use: ${APP_IDS.join(', ')}, all or none`);
|
|
87
|
+
}
|
|
88
|
+
return APP_IDS.filter((id) => ids.includes(id));
|
|
89
|
+
}
|
|
90
|
+
/** --repo value: private, public, or none (also when missing). */
|
|
91
|
+
export function parseRepo(value) {
|
|
92
|
+
if (!value || value === 'none')
|
|
93
|
+
return null;
|
|
94
|
+
if (value === 'private' || value === 'public')
|
|
95
|
+
return value;
|
|
96
|
+
throw new Error(`Unknown --repo "${value}". Use: private, public, none`);
|
|
97
|
+
}
|
|
98
|
+
const NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
99
|
+
/** True for a name that can be the folder as is (my-app), false for a display name (Oak & Iron). */
|
|
100
|
+
export const isFolderName = (value) => NAME_RE.test(value);
|
|
101
|
+
export function prettifyName(name) {
|
|
102
|
+
return name
|
|
103
|
+
.replace(/^create-/, '')
|
|
104
|
+
.replace(/[-_]+/g, ' ')
|
|
105
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
106
|
+
}
|
|
107
|
+
const WINDOWS_RESERVED = /^(con|prn|aux|nul|com\d|lpt\d)$/;
|
|
108
|
+
const SPELLED = { ß: 'ss', æ: 'ae', œ: 'oe', ø: 'o', ł: 'l', đ: 'd', þ: 'th', ð: 'd' };
|
|
109
|
+
export function folderName(name) {
|
|
110
|
+
const slug = name
|
|
111
|
+
.normalize('NFKD')
|
|
112
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
113
|
+
.toLowerCase()
|
|
114
|
+
.replace(/[ßæœøłđþð]/g, (c) => SPELLED[c])
|
|
115
|
+
.replace(/&/g, ' and ')
|
|
116
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
117
|
+
.replace(/^-+|-+$/g, '')
|
|
118
|
+
.slice(0, 63)
|
|
119
|
+
.replace(/-+$/, '');
|
|
120
|
+
return WINDOWS_RESERVED.test(slug) ? `${slug}-app` : slug;
|
|
121
|
+
}
|
|
122
|
+
export function freeFolderName(name) {
|
|
123
|
+
const base = folderName(name);
|
|
124
|
+
if (!base)
|
|
125
|
+
return '';
|
|
126
|
+
let candidate = base;
|
|
127
|
+
for (let n = 2; existsSync(path.resolve(process.cwd(), candidate)); n++)
|
|
128
|
+
candidate = `${base.slice(0, 60)}-${n}`;
|
|
129
|
+
return candidate;
|
|
130
|
+
}
|
|
131
|
+
export function validateProjectName(value) {
|
|
132
|
+
if (!value)
|
|
133
|
+
return 'Folder name is required';
|
|
134
|
+
if (!NAME_RE.test(value))
|
|
135
|
+
return 'Use lowercase letters, numbers, and dashes (e.g. my-app)';
|
|
136
|
+
if (value.length > 63)
|
|
137
|
+
return 'Max 63 characters';
|
|
138
|
+
if (WINDOWS_RESERVED.test(value))
|
|
139
|
+
return `"${value}" is a reserved name on Windows`;
|
|
140
|
+
if (existsSync(path.resolve(process.cwd(), value)))
|
|
141
|
+
return `Directory "${value}" already exists`;
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
export function normalizeUrl(value) {
|
|
145
|
+
const raw = (value ?? '').trim();
|
|
146
|
+
const lower = raw.toLowerCase();
|
|
147
|
+
if (!raw || lower === 'skip' || lower === 'none' || lower === 'local' || lower === 'localhost') {
|
|
148
|
+
return DEFAULT_SITE_URL;
|
|
149
|
+
}
|
|
150
|
+
const withProto = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `https://${raw}`;
|
|
151
|
+
const url = new URL(withProto);
|
|
152
|
+
if (!['http:', 'https:'].includes(url.protocol)) {
|
|
153
|
+
throw new Error('URL must be http(s)');
|
|
154
|
+
}
|
|
155
|
+
url.pathname = '/';
|
|
156
|
+
url.search = '';
|
|
157
|
+
url.hash = '';
|
|
158
|
+
url.username = '';
|
|
159
|
+
url.password = '';
|
|
160
|
+
return url.href;
|
|
161
|
+
}
|
|
162
|
+
export function defaultsFromFlags(opts) {
|
|
163
|
+
const template = parseTemplate(opts.template);
|
|
164
|
+
const folderShaped = NAME_RE.test(opts.projectName);
|
|
165
|
+
const projectName = folderShaped ? opts.projectName : folderName(opts.projectName);
|
|
166
|
+
if (!projectName)
|
|
167
|
+
throw new Error(`Could not make a folder name from "${opts.projectName}". Pass one, e.g. my-app`);
|
|
168
|
+
const err = validateProjectName(projectName);
|
|
169
|
+
if (err)
|
|
170
|
+
throw new Error(err);
|
|
171
|
+
const repo = parseRepo(opts.repo);
|
|
172
|
+
if (repo && opts.git === false)
|
|
173
|
+
throw new Error('--repo needs git. Drop --no-git or --repo.');
|
|
174
|
+
if (opts.accent && !ACCENT_PALETTE.some((a) => a.id === opts.accent)) {
|
|
175
|
+
throw new Error(`Unknown accent "${opts.accent}". Use: ${ACCENT_PALETTE.map((a) => a.id).join(', ')}`);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
template,
|
|
179
|
+
projectName,
|
|
180
|
+
siteName: opts.siteName || (folderShaped ? prettifyName(projectName) : opts.projectName.trim()),
|
|
181
|
+
oneSentence: opts.oneSentence?.trim() || '',
|
|
182
|
+
siteUrl: normalizeUrl(opts.siteUrl),
|
|
183
|
+
accentId: accentById(opts.accent).id,
|
|
184
|
+
...parseLocales(template === 'astro' ? opts.lang : DEFAULT_LOCALE),
|
|
185
|
+
apps: parseApps(opts.add, opts.installed ?? []),
|
|
186
|
+
darkMode: opts.dark !== false,
|
|
187
|
+
git: opts.git !== false,
|
|
188
|
+
repo,
|
|
189
|
+
install: opts.install !== false,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** Values written into template {{PLACEHOLDERS}}. scaffold sets devPort first. */
|
|
193
|
+
export function templateVars(answers, published) {
|
|
194
|
+
const accent = accentById(answers.accentId);
|
|
195
|
+
return {
|
|
196
|
+
TEMPLATE: answers.template,
|
|
197
|
+
TOKENS_FILE: 'src/styles/global.css',
|
|
198
|
+
PROJECT_NAME: answers.projectName,
|
|
199
|
+
SITE_NAME: answers.siteName,
|
|
200
|
+
ONE_SENTENCE: answers.oneSentence.trim() || `${answers.siteName}: fill the one-sentence intent with your agent.`,
|
|
201
|
+
SITE_URL: answers.siteUrl || DEFAULT_SITE_URL,
|
|
202
|
+
PUBLISHED: published,
|
|
203
|
+
ACCENT: accent.hex,
|
|
204
|
+
ACCENT_SOFT: accent.soft,
|
|
205
|
+
ACCENT_ON: accent.on,
|
|
206
|
+
ACCENT_DARK: accent.dark,
|
|
207
|
+
ACCENT_DARK_SOFT: accent.darkSoft,
|
|
208
|
+
ACCENT_NAME: accent.label,
|
|
209
|
+
DARK_MODE: String(answers.darkMode),
|
|
210
|
+
DARK_THEME_ATTR: answers.darkMode ? 'auto' : 'light',
|
|
211
|
+
DEFAULT_LOCALE: answers.defaultLocale,
|
|
212
|
+
LOCALES: answers.locales,
|
|
213
|
+
DEV_PORT: String(answers.devPort),
|
|
214
|
+
};
|
|
215
|
+
}
|
package/dist/ink-prompts.d.ts
CHANGED
|
@@ -1,12 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AppId, type ProjectAnswers, type TemplateId } from './answers.js';
|
|
3
|
+
export declare const WIDTH = 76;
|
|
4
|
+
declare const ALL_STEPS: readonly [{
|
|
5
|
+
readonly id: "template";
|
|
6
|
+
readonly label: "Stack";
|
|
7
|
+
readonly title: "TEMPLATE";
|
|
8
|
+
}, {
|
|
9
|
+
readonly id: "name";
|
|
10
|
+
readonly label: "Name";
|
|
11
|
+
readonly title: "NAME";
|
|
12
|
+
}, {
|
|
13
|
+
readonly id: "folder";
|
|
14
|
+
readonly label: "Folder";
|
|
15
|
+
readonly title: "FOLDER";
|
|
16
|
+
}, {
|
|
17
|
+
readonly id: "line";
|
|
18
|
+
readonly label: "Line";
|
|
19
|
+
readonly title: "ONE-LINER (OPTIONAL)";
|
|
20
|
+
}, {
|
|
21
|
+
readonly id: "url";
|
|
22
|
+
readonly label: "URL";
|
|
23
|
+
readonly title: "SITE URL (OPTIONAL)";
|
|
24
|
+
}, {
|
|
25
|
+
readonly id: "languages";
|
|
26
|
+
readonly label: "Lang";
|
|
27
|
+
readonly title: "LANGUAGES";
|
|
28
|
+
}, {
|
|
29
|
+
readonly id: "accent";
|
|
30
|
+
readonly label: "Color";
|
|
31
|
+
readonly title: "COLOR";
|
|
32
|
+
}, {
|
|
33
|
+
readonly id: "apps";
|
|
34
|
+
readonly label: "Apps";
|
|
35
|
+
readonly title: "ADD TO";
|
|
36
|
+
}, {
|
|
37
|
+
readonly id: "git";
|
|
38
|
+
readonly label: "Git";
|
|
39
|
+
readonly title: "GIT";
|
|
40
|
+
}, {
|
|
41
|
+
readonly id: "install";
|
|
42
|
+
readonly label: "Install";
|
|
43
|
+
readonly title: "INSTALL DEPS";
|
|
44
|
+
}];
|
|
45
|
+
export type Step = (typeof ALL_STEPS)[number]['id'];
|
|
46
|
+
export declare const STEP_IDS: Step[];
|
|
47
|
+
export declare function Header({ steps, current, }: {
|
|
48
|
+
steps?: readonly (typeof ALL_STEPS)[number][];
|
|
49
|
+
current?: Step;
|
|
50
|
+
}): React.JSX.Element;
|
|
51
|
+
type HelpRow = readonly [string, string];
|
|
52
|
+
export declare const HELP: Record<Step, readonly HelpRow[]>;
|
|
53
|
+
export declare const helpRow: ([label, text]: HelpRow) => string;
|
|
54
|
+
export declare function typedHelpKey(prev: string, next: string): boolean;
|
|
55
|
+
export declare const PICK_ROWS = 8;
|
|
56
|
+
export type Pick = {
|
|
57
|
+
cursor: number;
|
|
58
|
+
top: number;
|
|
59
|
+
chosen: string[];
|
|
60
|
+
};
|
|
61
|
+
export type PickItem = {
|
|
62
|
+
value: string;
|
|
63
|
+
label: string;
|
|
64
|
+
};
|
|
65
|
+
export declare const picker: (values: readonly string[]) => (state: Pick, key: "up" | "down" | "toggle") => Pick;
|
|
66
|
+
export declare const LANGUAGE_ITEMS: PickItem[];
|
|
67
|
+
export declare function Picker({ items, initial, required, onSubmit, }: {
|
|
68
|
+
items: readonly PickItem[];
|
|
69
|
+
initial: readonly string[];
|
|
70
|
+
required?: string;
|
|
71
|
+
onSubmit: (values: string[]) => void;
|
|
72
|
+
}): React.JSX.Element;
|
|
73
|
+
export type AppChoice = {
|
|
74
|
+
id: AppId;
|
|
75
|
+
label: string;
|
|
76
|
+
};
|
|
77
|
+
export declare function WizardApp({ defaultName, defaultTemplate, apps, github, onComplete, initial, }: {
|
|
78
|
+
defaultName?: string;
|
|
79
|
+
defaultTemplate?: TemplateId;
|
|
80
|
+
apps?: readonly AppChoice[];
|
|
81
|
+
github?: boolean;
|
|
82
|
+
onComplete: (choices: ProjectAnswers) => void;
|
|
83
|
+
initial?: {
|
|
84
|
+
step: Step;
|
|
85
|
+
help?: boolean;
|
|
86
|
+
template?: TemplateId;
|
|
87
|
+
};
|
|
88
|
+
}): React.JSX.Element;
|
|
89
|
+
export declare function runInkPrompts(defaultName?: string, defaultTemplate?: TemplateId, apps?: readonly AppChoice[], github?: boolean): Promise<ProjectAnswers | null>;
|
|
90
|
+
export {};
|