create-warlock 5.2.4 → 5.3.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 (39) hide show
  1. package/esm/commands/create-warlock-app/index.mjs +1 -1
  2. package/esm/commands/create-warlock-app/index.mjs.map +1 -1
  3. package/esm/helpers/app.mjs +44 -17
  4. package/esm/helpers/app.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/templates/warlock/eslint.config.js +98 -98
  7. package/templates/warlock/postcss.config.mjs +6 -0
  8. package/templates/warlock/src/app/contact/controllers/contact.controller.ts +21 -0
  9. package/templates/warlock/src/app/contact/routes.ts +4 -0
  10. package/templates/warlock/src/app/{shared → home}/controllers/home-page.controller.ts +1 -7
  11. package/templates/warlock/src/app/home/services/home.service.ts +86 -0
  12. package/templates/warlock/src/app/locale/controllers/locale.controller.ts +16 -0
  13. package/templates/warlock/src/app/locale/routes.ts +4 -0
  14. package/templates/warlock/src/shared/contact.schema.ts +7 -0
  15. package/templates/warlock/src/shared/locale.schema.ts +11 -0
  16. package/templates/warlock/src/shared/locales.ts +7 -0
  17. package/templates/warlock/src/web/404.css +113 -0
  18. package/templates/warlock/src/web/404.page.tsx +23 -0
  19. package/templates/warlock/src/web/app.css +3 -0
  20. package/templates/warlock/src/web/home/components/contact-form-controls.tsx +42 -0
  21. package/templates/warlock/src/web/home/components/contact-section.tsx +108 -0
  22. package/templates/warlock/src/web/home/components/content-sections.tsx +61 -0
  23. package/templates/warlock/src/web/home/components/hero-section.tsx +68 -0
  24. package/templates/warlock/src/web/home/components/home-footer.tsx +35 -0
  25. package/templates/warlock/src/web/home/components/home-header.tsx +26 -0
  26. package/templates/warlock/src/web/home/components/logo.tsx +19 -0
  27. package/templates/warlock/src/web/home/components/runtime-preview.tsx +75 -0
  28. package/templates/warlock/src/web/home/hooks/use-contact-form.ts +57 -0
  29. package/templates/warlock/src/web/home/hooks/use-locale-switcher.ts +35 -0
  30. package/templates/warlock/src/web/home/index.page.tsx +44 -0
  31. package/templates/warlock/src/web/home/register.ts +30 -0
  32. package/templates/warlock/src/web/home/styles/home.css +1185 -0
  33. package/templates/warlock/src/web/root.tsx +49 -0
  34. package/templates/warlock/src/web/shared/utils/set-form-errors.ts +60 -0
  35. package/templates/warlock/tsconfig.json +3 -1
  36. package/templates/warlock/public/home.css +0 -523
  37. package/templates/warlock/src/app/shared/components/HomePageComponent.tsx +0 -229
  38. package/templates/warlock/src/app/shared/controllers/home-page.controller.tsx +0 -17
  39. /package/templates/warlock/src/app/{shared → home}/routes.ts +0 -0
@@ -27,7 +27,7 @@ async function createWarlockApp(application) {
27
27
  application.init().use("warlock").updatePackageJson(versions).updateDotEnv();
28
28
  if (noDatabase) application.removeDatabaseConfig();
29
29
  else application.configureDatabaseEnv(databaseDriver);
30
- application.configureHomePage(features.includes("react"));
30
+ application.configureWebStarter(features.includes("web"));
31
31
  } catch (error) {
32
32
  templateSpinner.stop(spinnerMessages.templateFailed);
33
33
  failFatally({
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../create-warlock/src/commands/create-warlock-app/index.ts"],"sourcesContent":["import { spinner } from \"@clack/prompts\";\nimport {\n getDatabaseLabel,\n isNoDatabase,\n} from \"../../features/database-drivers\";\nimport { App } from \"../../helpers/app\";\nimport { CommandResult, takeLastCommandOutput } from \"../../helpers/exec\";\nimport {\n getPackageManager,\n runPackageManagerCommand,\n} from \"../../helpers/package-manager\";\nimport { resolveWarlockVersions } from \"../../helpers/warlock-versions\";\nimport { showSuccessScreen } from \"../../ui/banner\";\nimport {\n failFatally,\n installFailureHints,\n Problem,\n showNotes,\n showPartialScreen,\n showProblems,\n} from \"../../ui/report\";\nimport { spinnerMessages } from \"../../ui/spinners\";\n\n/**\n * What the scaffold actually achieved. `ok` is false when ANY step the user\n * asked for did not happen; the caller turns that into a non-zero exit code so\n * a script never mistakes a half-built project for a finished one.\n */\nexport type ScaffoldOutcome = {\n ok: boolean;\n problems: Problem[];\n};\n\n/** One-line \"why did this fail\" pulled out of a captured command. */\nfunction reasonFrom(result: CommandResult | undefined): string {\n if (!result) return \"the command reported a failure (no output captured)\";\n\n if (result.error) {\n return result.error.message || String(result.error);\n }\n\n const lastLine = `${result.stderr}\\n${result.stdout}`\n .split(/\\r?\\n/)\n .map(line => line.trim())\n .filter(Boolean)\n .pop();\n\n const status =\n result.code === null\n ? `killed by ${result.signal ?? \"an unknown signal\"}`\n : `exit code ${result.code}`;\n\n return lastLine ? `${status} — ${lastLine}` : status;\n}\n\nexport async function createWarlockApp(\n application: App,\n): Promise<ScaffoldOutcome> {\n const options = application.options;\n const { useGit, useJWT, features, aiProviders, databaseDriver } = options;\n const noDatabase = isNoDatabase(databaseDriver);\n const problems: Problem[] = [];\n\n // Resolve the versions to pin BEFORE anything is written. The scaffolder's\n // own version is only used when the registry confirms it exists — see\n // helpers/warlock-versions.ts for why an unverified pin broke every install.\n const { versions, notes } = await resolveWarlockVersions();\n\n // Step 1: Initialize and copy template\n const templateSpinner = spinner();\n templateSpinner.start(spinnerMessages.copyingTemplate);\n\n try {\n application\n .init()\n .use(\"warlock\")\n .updatePackageJson(versions)\n .updateDotEnv();\n\n // Wire the chosen database driver into .env — or, when the user opted out,\n // strip the database config entirely so the app boots with no database.\n if (noDatabase) {\n application.removeDatabaseConfig();\n } else {\n application.configureDatabaseEnv(databaseDriver);\n }\n\n application.configureHomePage(features.includes(\"react\"));\n } catch (error) {\n templateSpinner.stop(spinnerMessages.templateFailed);\n\n failFatally({\n step: \"Template copy\",\n detail: `The project files could not be written: ${(error as Error).message}`,\n hints: [\n \"Check that the target directory is writable and that no file is locked by another process.\",\n ],\n });\n }\n\n templateSpinner.stop(spinnerMessages.templateCopied);\n\n showNotes(notes);\n\n // Step 2: Install base dependencies (so the `warlock` binary is available).\n // Nothing downstream works without this, so a failure ends the run — loudly,\n // with the command, its exit code and its output.\n const installSpinner = spinner();\n installSpinner.start(spinnerMessages.installingDeps);\n\n const baseInstall = application.install();\n const baseInstalled = await baseInstall.install;\n const baseInstallResult = await baseInstall.result;\n\n if (!baseInstalled) {\n installSpinner.stop(spinnerMessages.depsFailed);\n\n failFatally({\n step: \"Dependency install\",\n detail: \"The project's dependencies were not installed.\",\n result: baseInstallResult,\n hints: installFailureHints(baseInstallResult),\n });\n }\n\n installSpinner.stop(spinnerMessages.depsInstalled);\n\n // Step 3: Add features via `warlock add --no-install`, then one batched install.\n // The DB driver, optional features, and AI providers all go through the single\n // source of truth (core's feature map) so versions never drift. When no\n // database was chosen, the driver is omitted (there is no `none` feature).\n const selectedFeatures = [\n ...(noDatabase ? [] : [databaseDriver]),\n ...features,\n ...aiProviders,\n ];\n\n // Features the user asked for that are not in the project when we finish.\n const failedFeatures: { feature: string; reason: string }[] = [];\n\n if (selectedFeatures.length > 0) {\n const featuresSpinner = spinner();\n featuresSpinner.start(spinnerMessages.addingFeatures);\n\n let addedFeatures = selectedFeatures;\n\n if (!(await application.installFeatures(selectedFeatures))) {\n // The batch is all-or-nothing, so it cannot say WHICH feature broke it.\n // Retry them one at a time: every feature that can be added still gets\n // added, and every one that cannot gets its own reason.\n const batchFailure = takeLastCommandOutput();\n\n addedFeatures = [];\n\n for (const feature of selectedFeatures) {\n if (await application.installFeatures([feature])) {\n addedFeatures.push(feature);\n } else {\n failedFeatures.push({\n feature,\n reason: reasonFrom(takeLastCommandOutput() ?? batchFailure),\n });\n }\n }\n }\n\n let featureInstall: CommandResult | undefined;\n\n if (addedFeatures.length > 0) {\n // `warlock add` records the feature dependencies but does not reconcile\n // them with each other. The `web` feature brings `vite` while the\n // template always brings `vitest`, whose own vite range resolves to a\n // different major — two copies, and yarn 1 aborts the whole link phase\n // on them. Pin one copy BEFORE the batched install, not after.\n application.pinViteResolution();\n\n const install = application.install();\n const installed = await install.install;\n\n featureInstall = await install.result;\n\n if (!installed) {\n // The dependencies were recorded but never fetched — the features are\n // not usable, so they are failures, not successes.\n const reason = `their packages were not installed (${reasonFrom(featureInstall)})`;\n\n for (const feature of addedFeatures) {\n failedFeatures.push({ feature, reason });\n }\n\n addedFeatures = [];\n }\n }\n\n if (failedFeatures.length === 0) {\n featuresSpinner.stop(spinnerMessages.featuresAdded);\n } else {\n featuresSpinner.stop(\n addedFeatures.length > 0\n ? spinnerMessages.featuresPartial\n : spinnerMessages.featuresFailed,\n );\n\n problems.push({\n step: \"Features\",\n detail: failedFeatures\n .map(({ feature, reason }) => `${feature}: ${reason}`)\n .join(\"\\n \"),\n result: featureInstall?.ok === false ? featureInstall : undefined,\n hints: [\n `Retry inside the project with: npx warlock add ${failedFeatures\n .map(({ feature }) => feature)\n .join(\" \")}`,\n ],\n });\n }\n }\n\n // Step 4: Initialize Git repository if requested\n if (useGit) {\n const gitSpinner = spinner();\n gitSpinner.start(spinnerMessages.initializingGit);\n\n const initialized = await application.git();\n\n gitSpinner.stop(\n initialized ? spinnerMessages.gitInitialized : spinnerMessages.gitFailed,\n );\n\n if (!initialized) {\n const failure = takeLastCommandOutput();\n\n problems.push({\n step: \"Git repository\",\n detail: `The repository was not initialized: ${reasonFrom(failure)}`,\n result: failure,\n hints: [\n \"Check that git is installed and that user.name / user.email are configured, then run `git init` yourself.\",\n ],\n });\n }\n }\n\n // Step 5: Generate JWT or warm cache\n if (useJWT) {\n const jwtSpinner = spinner();\n jwtSpinner.start(spinnerMessages.generatingJwt);\n\n const command = runPackageManagerCommand(\"jwt\");\n const generated = await application.exec(command);\n\n jwtSpinner.stop(\n generated ? spinnerMessages.jwtGenerated : spinnerMessages.jwtFailed,\n );\n\n if (!generated) {\n const failure = takeLastCommandOutput();\n\n problems.push({\n step: \"JWT secrets\",\n detail: `No JWT secrets were written to .env: ${reasonFrom(failure)}`,\n result: failure,\n hints: [`Run \\`${command}\\` inside the project before starting it.`],\n });\n }\n } else {\n // The warm cache is a start-up optimisation, not something the user asked\n // for: report it, but it does not make the scaffold a failure.\n const warmSpinner = spinner();\n warmSpinner.start(spinnerMessages.warmingCache);\n\n const warmed = await application.exec(\"npx warlock --warm-cache\");\n\n warmSpinner.stop(\n warmed ? spinnerMessages.cacheWarmed : spinnerMessages.cacheWarmFailed,\n );\n\n if (!warmed) takeLastCommandOutput();\n }\n\n // Step 6: Report what actually happened — the summary may only advertise\n // features that are really in the project.\n const requestedFeatures = [...features, ...aiProviders];\n const missingFeatures = failedFeatures\n .map(({ feature }) => feature)\n .filter(feature => requestedFeatures.includes(feature));\n const installedFeatures = requestedFeatures.filter(\n feature => !missingFeatures.includes(feature),\n );\n\n if (problems.length > 0) {\n showProblems(problems);\n\n showPartialScreen({\n projectName: application.name,\n database: getDatabaseLabel(databaseDriver),\n features: installedFeatures,\n missingFeatures,\n packageManager: getPackageManager(),\n });\n\n return { ok: false, problems };\n }\n\n showSuccessScreen({\n projectName: application.name,\n database: getDatabaseLabel(databaseDriver),\n features: installedFeatures,\n packageManager: getPackageManager(),\n });\n\n return { ok: true, problems };\n}\n"],"mappings":";;;;;;;;;;;AAkCA,SAAS,WAAW,QAA2C;CAC7D,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,OAAO,OACT,OAAO,OAAO,MAAM,WAAW,OAAO,OAAO,KAAK;CAGpD,MAAM,WAAW,GAAG,OAAO,OAAO,IAAI,OAAO,SAC1C,MAAM,OAAO,CAAC,CACd,KAAI,SAAQ,KAAK,KAAK,CAAC,CAAC,CACxB,OAAO,OAAO,CAAC,CACf,IAAI;CAEP,MAAM,SACJ,OAAO,SAAS,OACZ,aAAa,OAAO,UAAU,wBAC9B,aAAa,OAAO;CAE1B,OAAO,WAAW,GAAG,OAAO,KAAK,aAAa;AAChD;AAEA,eAAsB,iBACpB,aAC0B;CAE1B,MAAM,EAAE,QAAQ,QAAQ,UAAU,aAAa,mBAD/B,YAAY;CAE5B,MAAM,aAAa,aAAa,cAAc;CAC9C,MAAM,WAAsB,CAAC;CAK7B,MAAM,EAAE,UAAU,UAAU,MAAM,uBAAuB;CAGzD,MAAM,kBAAkB,QAAQ;CAChC,gBAAgB,MAAM,gBAAgB,eAAe;CA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AY,MAAM,YAAY,KAAK,OAAO;EAEhD,WAAW,KACT,YAAY,gBAAgB,eAAe,gBAAgB,SAC7D;EAEA,IAAI,CAAC,WAAW;GACd,MAAM,UAAU,sBAAsB;GAEtC,SAAS,KAAK;IACZ,MAAM;IACN,QAAQ,wCAAwC,WAAW,OAAO;IAClE,QAAQ;IACR,OAAO,CAAC,SAAS,QAAQ,0CAA0C;GACrE,CAAC;EACH;CACF,OAAO;EAGL,MAAM,cAAc,QAAQ;EAC5B,YAAY,MAAM,gBAAgB,YAAY;EAE9C,MAAM,SAAS,MAAM,YAAY,KAAK,0BAA0B;EAEhE,YAAY,KACV,SAAS,gBAAgB,cAAc,gBAAgB,eACzD;EAEA,IAAI,CAAC,QAAQ,sBAAsB;CACrC;CAIA,MAAM,oBAAoB,CAAC,GAAG,UAAU,GAAG,WAAW;CACtD,MAAM,kBAAkB,eACrB,KAAK,EAAE,cAAc,OAAO,CAAC,CAC7B,QAAO,YAAW,kBAAkB,SAAS,OAAO,CAAC;CACxD,MAAM,oBAAoB,kBAAkB,QAC1C,YAAW,CAAC,gBAAgB,SAAS,OAAO,CAC9C;CAEA,IAAI,SAAS,SAAS,GAAG;EACvB,aAAa,QAAQ;EAErB,kBAAkB;GAChB,aAAa,YAAY;GACzB,UAAU,iBAAiB,cAAc;GACzC,UAAU;GACV;GACA,gBAAgB,kBAAkB;EACpC,CAAC;EAED,OAAO;GAAE,IAAI;GAAO;EAAS;CAC/B;CAEA,kBAAkB;EAChB,aAAa,YAAY;EACzB,UAAU,iBAAiB,cAAc;EACzC,UAAU;EACV,gBAAgB,kBAAkB;CACpC,CAAC;CAED,OAAO;EAAE,IAAI;EAAM;CAAS;AAC9B"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../create-warlock/src/commands/create-warlock-app/index.ts"],"sourcesContent":["import { spinner } from \"@clack/prompts\";\nimport {\n getDatabaseLabel,\n isNoDatabase,\n} from \"../../features/database-drivers\";\nimport { App } from \"../../helpers/app\";\nimport { CommandResult, takeLastCommandOutput } from \"../../helpers/exec\";\nimport {\n getPackageManager,\n runPackageManagerCommand,\n} from \"../../helpers/package-manager\";\nimport { resolveWarlockVersions } from \"../../helpers/warlock-versions\";\nimport { showSuccessScreen } from \"../../ui/banner\";\nimport {\n failFatally,\n installFailureHints,\n Problem,\n showNotes,\n showPartialScreen,\n showProblems,\n} from \"../../ui/report\";\nimport { spinnerMessages } from \"../../ui/spinners\";\n\n/**\n * What the scaffold actually achieved. `ok` is false when ANY step the user\n * asked for did not happen; the caller turns that into a non-zero exit code so\n * a script never mistakes a half-built project for a finished one.\n */\nexport type ScaffoldOutcome = {\n ok: boolean;\n problems: Problem[];\n};\n\n/** One-line \"why did this fail\" pulled out of a captured command. */\nfunction reasonFrom(result: CommandResult | undefined): string {\n if (!result) return \"the command reported a failure (no output captured)\";\n\n if (result.error) {\n return result.error.message || String(result.error);\n }\n\n const lastLine = `${result.stderr}\\n${result.stdout}`\n .split(/\\r?\\n/)\n .map(line => line.trim())\n .filter(Boolean)\n .pop();\n\n const status =\n result.code === null\n ? `killed by ${result.signal ?? \"an unknown signal\"}`\n : `exit code ${result.code}`;\n\n return lastLine ? `${status} — ${lastLine}` : status;\n}\n\nexport async function createWarlockApp(\n application: App,\n): Promise<ScaffoldOutcome> {\n const options = application.options;\n const { useGit, useJWT, features, aiProviders, databaseDriver } = options;\n const noDatabase = isNoDatabase(databaseDriver);\n const problems: Problem[] = [];\n\n // Resolve the versions to pin BEFORE anything is written. The scaffolder's\n // own version is only used when the registry confirms it exists — see\n // helpers/warlock-versions.ts for why an unverified pin broke every install.\n const { versions, notes } = await resolveWarlockVersions();\n\n // Step 1: Initialize and copy template\n const templateSpinner = spinner();\n templateSpinner.start(spinnerMessages.copyingTemplate);\n\n try {\n application\n .init()\n .use(\"warlock\")\n .updatePackageJson(versions)\n .updateDotEnv();\n\n // Wire the chosen database driver into .env — or, when the user opted out,\n // strip the database config entirely so the app boots with no database.\n if (noDatabase) {\n application.removeDatabaseConfig();\n } else {\n application.configureDatabaseEnv(databaseDriver);\n }\n\n application.configureWebStarter(features.includes(\"web\"));\n } catch (error) {\n templateSpinner.stop(spinnerMessages.templateFailed);\n\n failFatally({\n step: \"Template copy\",\n detail: `The project files could not be written: ${(error as Error).message}`,\n hints: [\n \"Check that the target directory is writable and that no file is locked by another process.\",\n ],\n });\n }\n\n templateSpinner.stop(spinnerMessages.templateCopied);\n\n showNotes(notes);\n\n // Step 2: Install base dependencies (so the `warlock` binary is available).\n // Nothing downstream works without this, so a failure ends the run — loudly,\n // with the command, its exit code and its output.\n const installSpinner = spinner();\n installSpinner.start(spinnerMessages.installingDeps);\n\n const baseInstall = application.install();\n const baseInstalled = await baseInstall.install;\n const baseInstallResult = await baseInstall.result;\n\n if (!baseInstalled) {\n installSpinner.stop(spinnerMessages.depsFailed);\n\n failFatally({\n step: \"Dependency install\",\n detail: \"The project's dependencies were not installed.\",\n result: baseInstallResult,\n hints: installFailureHints(baseInstallResult),\n });\n }\n\n installSpinner.stop(spinnerMessages.depsInstalled);\n\n // Step 3: Add features via `warlock add --no-install`, then one batched install.\n // The DB driver, optional features, and AI providers all go through the single\n // source of truth (core's feature map) so versions never drift. When no\n // database was chosen, the driver is omitted (there is no `none` feature).\n const selectedFeatures = [\n ...(noDatabase ? [] : [databaseDriver]),\n ...features,\n ...aiProviders,\n ];\n\n // Features the user asked for that are not in the project when we finish.\n const failedFeatures: { feature: string; reason: string }[] = [];\n\n if (selectedFeatures.length > 0) {\n const featuresSpinner = spinner();\n featuresSpinner.start(spinnerMessages.addingFeatures);\n\n let addedFeatures = selectedFeatures;\n\n if (!(await application.installFeatures(selectedFeatures))) {\n // The batch is all-or-nothing, so it cannot say WHICH feature broke it.\n // Retry them one at a time: every feature that can be added still gets\n // added, and every one that cannot gets its own reason.\n const batchFailure = takeLastCommandOutput();\n\n addedFeatures = [];\n\n for (const feature of selectedFeatures) {\n if (await application.installFeatures([feature])) {\n addedFeatures.push(feature);\n } else {\n failedFeatures.push({\n feature,\n reason: reasonFrom(takeLastCommandOutput() ?? batchFailure),\n });\n }\n }\n }\n\n let featureInstall: CommandResult | undefined;\n\n if (addedFeatures.length > 0) {\n // `warlock add` records the feature dependencies but does not reconcile\n // them with each other. The `web` feature brings `vite` while the\n // template always brings `vitest`, whose own vite range resolves to a\n // different major — two copies, and yarn 1 aborts the whole link phase\n // on them. Pin one copy BEFORE the batched install, not after.\n application.pinViteResolution();\n\n const install = application.install();\n const installed = await install.install;\n\n featureInstall = await install.result;\n\n if (!installed) {\n // The dependencies were recorded but never fetched — the features are\n // not usable, so they are failures, not successes.\n const reason = `their packages were not installed (${reasonFrom(featureInstall)})`;\n\n for (const feature of addedFeatures) {\n failedFeatures.push({ feature, reason });\n }\n\n addedFeatures = [];\n }\n }\n\n if (failedFeatures.length === 0) {\n featuresSpinner.stop(spinnerMessages.featuresAdded);\n } else {\n featuresSpinner.stop(\n addedFeatures.length > 0\n ? spinnerMessages.featuresPartial\n : spinnerMessages.featuresFailed,\n );\n\n problems.push({\n step: \"Features\",\n detail: failedFeatures\n .map(({ feature, reason }) => `${feature}: ${reason}`)\n .join(\"\\n \"),\n result: featureInstall?.ok === false ? featureInstall : undefined,\n hints: [\n `Retry inside the project with: npx warlock add ${failedFeatures\n .map(({ feature }) => feature)\n .join(\" \")}`,\n ],\n });\n }\n }\n\n // Step 4: Initialize Git repository if requested\n if (useGit) {\n const gitSpinner = spinner();\n gitSpinner.start(spinnerMessages.initializingGit);\n\n const initialized = await application.git();\n\n gitSpinner.stop(\n initialized ? spinnerMessages.gitInitialized : spinnerMessages.gitFailed,\n );\n\n if (!initialized) {\n const failure = takeLastCommandOutput();\n\n problems.push({\n step: \"Git repository\",\n detail: `The repository was not initialized: ${reasonFrom(failure)}`,\n result: failure,\n hints: [\n \"Check that git is installed and that user.name / user.email are configured, then run `git init` yourself.\",\n ],\n });\n }\n }\n\n // Step 5: Generate JWT or warm cache\n if (useJWT) {\n const jwtSpinner = spinner();\n jwtSpinner.start(spinnerMessages.generatingJwt);\n\n const command = runPackageManagerCommand(\"jwt\");\n const generated = await application.exec(command);\n\n jwtSpinner.stop(\n generated ? spinnerMessages.jwtGenerated : spinnerMessages.jwtFailed,\n );\n\n if (!generated) {\n const failure = takeLastCommandOutput();\n\n problems.push({\n step: \"JWT secrets\",\n detail: `No JWT secrets were written to .env: ${reasonFrom(failure)}`,\n result: failure,\n hints: [`Run \\`${command}\\` inside the project before starting it.`],\n });\n }\n } else {\n // The warm cache is a start-up optimisation, not something the user asked\n // for: report it, but it does not make the scaffold a failure.\n const warmSpinner = spinner();\n warmSpinner.start(spinnerMessages.warmingCache);\n\n const warmed = await application.exec(\"npx warlock --warm-cache\");\n\n warmSpinner.stop(\n warmed ? spinnerMessages.cacheWarmed : spinnerMessages.cacheWarmFailed,\n );\n\n if (!warmed) takeLastCommandOutput();\n }\n\n // Step 6: Report what actually happened — the summary may only advertise\n // features that are really in the project.\n const requestedFeatures = [...features, ...aiProviders];\n const missingFeatures = failedFeatures\n .map(({ feature }) => feature)\n .filter(feature => requestedFeatures.includes(feature));\n const installedFeatures = requestedFeatures.filter(\n feature => !missingFeatures.includes(feature),\n );\n\n if (problems.length > 0) {\n showProblems(problems);\n\n showPartialScreen({\n projectName: application.name,\n database: getDatabaseLabel(databaseDriver),\n features: installedFeatures,\n missingFeatures,\n packageManager: getPackageManager(),\n });\n\n return { ok: false, problems };\n }\n\n showSuccessScreen({\n projectName: application.name,\n database: getDatabaseLabel(databaseDriver),\n features: installedFeatures,\n packageManager: getPackageManager(),\n });\n\n return { ok: true, problems };\n}\n"],"mappings":";;;;;;;;;;;AAkCA,SAAS,WAAW,QAA2C;CAC7D,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,OAAO,OACT,OAAO,OAAO,MAAM,WAAW,OAAO,OAAO,KAAK;CAGpD,MAAM,WAAW,GAAG,OAAO,OAAO,IAAI,OAAO,SAC1C,MAAM,OAAO,CAAC,CACd,KAAI,SAAQ,KAAK,KAAK,CAA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;GACzC,UAAU;GACV;GACA,gBAAgB,kBAAkB;EACpC,CAAC;EAED,OAAO;GAAE,IAAI;GAAO;EAAS;CAC/B;CAEA,kBAAkB;EAChB,aAAa,YAAY;EACzB,UAAU,iBAAiB,cAAc;EACzC,UAAU;EACV,gBAAgB,kBAAkB;CACpC,CAAC;CAED,OAAO;EAAE,IAAI;EAAM;CAAS;AAC9B"}
@@ -4,7 +4,7 @@ import { getPackageManager } from "./package-manager.mjs";
4
4
  import { packageRoot, template } from "./paths.mjs";
5
5
  import { fallbackRange } from "./warlock-versions.mjs";
6
6
  import { copyDirectory, copyFile, fileExists, getFile, getJsonFile, putFile, putJsonFile, renameFile } from "@warlock.js/fs";
7
- import { unlinkSync } from "node:fs";
7
+ import { existsSync, rmSync, unlinkSync } from "node:fs";
8
8
  import path from "path";
9
9
 
10
10
  //#region ../create-warlock/src/helpers/app.ts
@@ -133,26 +133,53 @@ var App = class {
133
133
  return this;
134
134
  }
135
135
  /**
136
- * Pick the home page implementation based on whether React was selected.
136
+ * Configure the web starter only when the web feature owns `/`.
137
137
  *
138
- * The template ships BOTH a plain JSON controller (`home-page.controller.ts`)
139
- * and a React-rendered page (`home-page.controller.tsx` + `HomePageComponent.tsx`).
140
- * Exactly one survives the scaffold: React projects keep the `.tsx` page (its
141
- * `react`/`react-dom` deps come from the `react` feature), every other project
142
- * keeps the dependency-free JSON controller — so a fresh project never imports
143
- * `react` unless it asked for it.
138
+ * A dependency-free HTTP response is retained without web; otherwise the
139
+ * SSR page loader owns the route.
140
+ * Exactly one survives the scaffold: web projects keep the SSR page and API
141
+ * example; every other project keeps the dependency-free JSON controller.
144
142
  */
145
- configureHomePage(useReact) {
146
- const controllers = this.path + "/src/app/shared/controllers";
147
- const components = this.path + "/src/app/shared/components";
148
- const remove = (file) => {
149
- if (fileExists(file)) unlinkSync(file);
143
+ configureWebStarter(useWeb) {
144
+ const remove = (relativePath) => {
145
+ const target = path.resolve(this.path, relativePath);
146
+ if (existsSync(target)) rmSync(target, {
147
+ recursive: true,
148
+ force: true
149
+ });
150
150
  };
151
- if (useReact) remove(controllers + "/home-page.controller.ts");
152
- else {
153
- remove(controllers + "/home-page.controller.tsx");
154
- remove(components + "/HomePageComponent.tsx");
151
+ if (!useWeb) {
152
+ for (const entry of [
153
+ "src/web",
154
+ "src/app/contact",
155
+ "src/app/locale",
156
+ "src/shared/contact.schema.ts",
157
+ "src/shared/locale.schema.ts",
158
+ "src/shared/locales.ts",
159
+ "postcss.config.mjs"
160
+ ]) remove(entry);
161
+ const tsconfigPath = path.resolve(this.path, "tsconfig.json");
162
+ putFile(tsconfigPath, getFile(tsconfigPath).replace(" \"web/*\": [\"./src/web/*\"],\n", "").replace(" \"@shared/*\": [\"./src/shared/*\"]\n", ""));
163
+ return this;
155
164
  }
165
+ remove("src/app/home/controllers/home-page.controller.ts");
166
+ remove("src/app/home/routes.ts");
167
+ const packageJsonPath = path.resolve(this.path, "package.json");
168
+ const packageJson = getJsonFile(packageJsonPath);
169
+ packageJson.dependencies = {
170
+ ...packageJson.dependencies,
171
+ "@mongez/http": "^3.5.0",
172
+ "@mongez/react-form": "^4.0.0"
173
+ };
174
+ packageJson.devDependencies = {
175
+ ...packageJson.devDependencies,
176
+ "@tailwindcss/postcss": "^4.1.16",
177
+ tailwindcss: "^4.1.16"
178
+ };
179
+ putJsonFile(packageJsonPath, packageJson);
180
+ const configPath = path.resolve(this.path, "warlock.config.ts");
181
+ const config = getFile(configPath);
182
+ if (!config.includes("\"@warlock.js/web/connector\"")) putFile(configPath, `import { webConnector } from "@warlock.js/web/connector";\n${config}`.replace("export default defineConfig({", "export default defineConfig({\n connectors: [webConnector()],"));
156
183
  return this;
157
184
  }
158
185
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"app.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/app.ts"],"sourcesContent":["import {\r\n copyDirectory,\r\n copyFile,\r\n fileExists,\r\n getFile,\r\n getJsonFile,\r\n putFile,\r\n putJsonFile,\r\n renameFile,\r\n} from \"@warlock.js/fs\";\r\nimport { unlinkSync } from \"node:fs\";\r\nimport path from \"path\";\r\nimport { AppOptions, Application } from \"../commands/create-new-app/types\";\r\nimport { getDatabaseDriver } from \"../features/database-drivers\";\r\nimport { executeCommand, runCommand } from \"./exec\";\r\nimport { getPackageManager } from \"./package-manager\";\r\nimport { packageRoot, Template, template } from \"./paths\";\r\nimport { fallbackRange } from \"./warlock-versions\";\r\n\r\n/**\r\n * Environment for every install the scaffolder spawns.\r\n *\r\n * A shell that exports `NODE_ENV=production` makes the package managers skip\r\n * every devDependency — and still exit 0. The scaffolded project needs its dev\r\n * toolchain (typescript, vitest, eslint) to be usable at all, so the install\r\n * child is pinned to `development` regardless of the ambient environment. A\r\n * silently incomplete install that reports success is the exact failure mode\r\n * this file exists to prevent.\r\n */\r\nexport function installEnvironment(): NodeJS.ProcessEnv {\r\n return { NODE_ENV: \"development\" };\r\n}\r\n\r\nexport class App {\r\n /**\r\n * Resolved files\r\n */\r\n protected files: Record<string, FileManager> = {};\r\n\r\n /**\r\n * Resolved JSON files\r\n */\r\n protected jsonFiles: Record<string, JsonFileManager> = {};\r\n\r\n public isInstalled = false;\r\n\r\n public constructor(protected app: Application) {}\r\n\r\n public get options(): AppOptions {\r\n return this.app.options;\r\n }\r\n\r\n public use(templateName: Template) {\r\n copyDirectory(template(templateName), this.path);\r\n\r\n if (fileExists(this.path + \"/.env.example\")) {\r\n copyFile(this.path + \"/.env.example\", this.path + \"/.env\");\r\n }\r\n\r\n renameFile(this.path + \"/_.gitignore\", this.path + \"/.gitignore\");\r\n\r\n return this;\r\n }\r\n\r\n public init() {\r\n return this;\r\n }\r\n\r\n public terminate() {\r\n // No longer using outro, using showSuccessScreen instead\r\n }\r\n\r\n public install() {\r\n return runCommand(getPackageManager(), [\"install\"], this.path, {\r\n env: installEnvironment(),\r\n });\r\n }\r\n\r\n public async exec(command: string) {\r\n const [commandName, ...optionsList] = command.split(\" \");\r\n return await executeCommand(commandName, optionsList, this.path);\r\n }\r\n\r\n public async git() {\r\n const { initializeGitRepository } = await import(\r\n \"./project-builder-helpers\"\r\n );\r\n return await initializeGitRepository(this.path);\r\n }\r\n\r\n /**\r\n * Write the project's `package.json`: the project name, the chosen package\r\n * manager, and the version of every `@warlock.js/*` dependency.\r\n *\r\n * `versions` comes from {@link resolveWarlockVersions} — versions the\r\n * registry has confirmed exist. It is optional because the fluent chain is\r\n * synchronous; without it every sibling gets the caret range floored to the\r\n * scaffolder's major, which is always satisfiable by a published release.\r\n *\r\n * What it must NEVER do again is stamp the scaffolder's own version blind:\r\n * the release tooling bumps that version on every build, published or not,\r\n * so an unverified pin resolves to nothing and the install dies with ETARGET.\r\n */\r\n public updatePackageJson(versions: Record<string, string> = {}) {\r\n const packageManager = getPackageManager();\r\n\r\n const pkg = this.package.replace(\"name\", this.name.replaceAll(\"/\", \"-\"));\r\n\r\n const content: any = pkg.content;\r\n\r\n // Substitute the chosen package manager ONLY into the fields the template\r\n // writes it into literally — the `serve` script and the huskier hooks — by\r\n // path, never with a blanket substring replace over the serialized JSON. A\r\n // raw `replaceAll(\"yarn\", pm)` rewrites every occurrence of the substring\r\n // \"yarn\" anywhere in the document, so a project named `my-yarn-app`, or any\r\n // dependency/path containing \"yarn\", is silently corrupted (`--pm=npm`\r\n // turned `my-yarn-app` into `my-npm-app`). Field-scoped rewriting is also\r\n // order-independent: the name lives in `content.name` and these tokens live\r\n // in `scripts.serve` / `huskier.hooks`, disjoint fields that cannot collide\r\n // with the name substitution above regardless of which runs first.\r\n if (typeof content.scripts?.serve === \"string\") {\r\n content.scripts.serve = content.scripts.serve.replaceAll(\r\n \"yarn\",\r\n packageManager,\r\n );\r\n }\r\n\r\n const hooks = content.huskier?.hooks as\r\n | Record<string, unknown>\r\n | undefined;\r\n\r\n if (hooks) {\r\n for (const hook of Object.keys(hooks)) {\r\n const commands = hooks[hook];\r\n\r\n if (!Array.isArray(commands)) continue;\r\n\r\n hooks[hook] = commands.map(command =>\r\n typeof command === \"string\"\r\n ? command.replaceAll(\"yarn\", packageManager)\r\n : command,\r\n );\r\n }\r\n }\r\n\r\n const warlockVersion: string = (\r\n getJsonFile(packageRoot(\"package.json\")) as { version: string }\r\n ).version;\r\n const defaultRange = fallbackRange(warlockVersion);\r\n\r\n for (const field of [\"dependencies\", \"devDependencies\"] as const) {\r\n const deps = content[field] as Record<string, string> | undefined;\r\n if (!deps) continue;\r\n\r\n for (const dependency of Object.keys(deps)) {\r\n if (dependency.startsWith(\"@warlock.js/\")) {\r\n deps[dependency] = versions[dependency] ?? defaultRange;\r\n }\r\n }\r\n }\r\n\r\n pkg.save();\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Configure the chosen database driver: wire `DB_DRIVER` / `DB_PORT` into\r\n * `.env`, AND pin the driver's npm package (`mongodb` / `pg`) into the\r\n * project's `package.json` dependencies.\r\n *\r\n * The dependency is written HERE — before the base `yarn install` — so the\r\n * driver is pulled deterministically by the very first install. We do NOT\r\n * rely on the post-copy `warlock add <driver> --no-install` + separate\r\n * batched install, which can be skipped or fail and leave the driver\r\n * missing (the \"mongodb package is not installed\" runtime error).\r\n */\r\n public configureDatabaseEnv(driverValue: string) {\r\n const driver = getDatabaseDriver(driverValue);\r\n\r\n if (!driver) return this;\r\n\r\n // Pin the driver package into dependencies (idempotent — never downgrade).\r\n const packageJsonPath = path.resolve(this.path, \"package.json\");\r\n const packageJson = getJsonFile(packageJsonPath) as {\r\n dependencies?: Record<string, string>;\r\n };\r\n packageJson.dependencies = packageJson.dependencies ?? {};\r\n if (!packageJson.dependencies[driver.package]) {\r\n packageJson.dependencies[driver.package] = driver.packageVersion;\r\n putJsonFile(packageJsonPath, packageJson);\r\n }\r\n\r\n let envContent = getFile(this.path + \"/.env\") as string;\r\n\r\n envContent = envContent.replace(/DB_PORT=\\d+/, `DB_PORT=${driver.defaultPort}`);\r\n\r\n if (envContent.includes(\"DB_DRIVER=\")) {\r\n envContent = envContent.replace(/DB_DRIVER=\\w*/, `DB_DRIVER=${driver.value}`);\r\n } else {\r\n envContent = envContent.replace(\r\n /DB_PORT=\\d+/,\r\n `DB_PORT=${driver.defaultPort}\\nDB_DRIVER=${driver.value}`,\r\n );\r\n }\r\n\r\n putFile(this.path + \"/.env\", envContent);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Remove the database layer for a \"no database\" scaffold.\r\n *\r\n * Deletes `src/config/database.ts` (and a `.tsx` variant if present) from the\r\n * freshly-copied template. The framework's database connector is config-gated\r\n * on that file — with it gone, `config.get(\"database\")` is undefined and the\r\n * connector no-ops, so the app boots with no database wired and no driver\r\n * package pulled. The `DB_*` lines in `.env` are left in place (harmless: no\r\n * config reads them) as a ready template for adding a database back later.\r\n */\r\n public removeDatabaseConfig() {\r\n const configDir = path.resolve(this.path, \"src/config\");\r\n\r\n for (const fileName of [\"database.ts\", \"database.tsx\"]) {\r\n const filePath = path.resolve(configDir, fileName);\r\n\r\n if (fileExists(filePath)) {\r\n unlinkSync(filePath);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Pick the home page implementation based on whether React was selected.\r\n *\r\n * The template ships BOTH a plain JSON controller (`home-page.controller.ts`)\r\n * and a React-rendered page (`home-page.controller.tsx` + `HomePageComponent.tsx`).\r\n * Exactly one survives the scaffold: React projects keep the `.tsx` page (its\r\n * `react`/`react-dom` deps come from the `react` feature), every other project\r\n * keeps the dependency-free JSON controller — so a fresh project never imports\r\n * `react` unless it asked for it.\r\n */\r\n public configureHomePage(useReact: boolean) {\r\n const controllers = this.path + \"/src/app/shared/controllers\";\r\n const components = this.path + \"/src/app/shared/components\";\r\n\r\n const remove = (file: string) => {\r\n if (fileExists(file)) unlinkSync(file);\r\n };\r\n\r\n if (useReact) {\r\n remove(controllers + \"/home-page.controller.ts\");\r\n } else {\r\n remove(controllers + \"/home-page.controller.tsx\");\r\n remove(components + \"/HomePageComponent.tsx\");\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Install the selected optional features by delegating to the project's own\r\n * `warlock add`. `--no-install` records every dependency in package.json and\r\n * ejects configs / scripts / setup hooks WITHOUT installing — the caller runs\r\n * one batched install afterwards. Versions come from core's feature map, so\r\n * the scaffolder never duplicates them.\r\n *\r\n * `--no-install` is passed LAST on purpose: the CLI parser treats the\r\n * positional after a bare flag as that flag's value, so it must follow the\r\n * feature list, not precede it.\r\n */\r\n public async installFeatures(features: string[]) {\r\n if (features.length === 0) return true;\r\n\r\n return this.exec(`npx warlock add ${features.join(\" \")} --no-install`);\r\n }\r\n\r\n /**\r\n * Force a single copy of `vite` when the project ends up with BOTH `vite`\r\n * (written by the `web` feature) and `vitest` (always in the template).\r\n *\r\n * `vitest` depends on vite through a wide range of its own\r\n * (`^6 || ^7 || ^8`), which resolves to a DIFFERENT major than the range the\r\n * feature map pins. Yarn 1 then has to nest the second copy under\r\n * `vitest/node_modules` and dies on its own linker invariant:\r\n *\r\n * error Invariant Violation: could not find a copy of vite to link in\r\n * <project>/node_modules/vitest/node_modules\r\n *\r\n * It aborts BEFORE `node_modules/.bin` is written, so `warlock` is never\r\n * linked and the very first `yarn dev` fails with \"'warlock' is not\r\n * recognized\". npm and pnpm nest happily and never hit this — for them the\r\n * `overrides` twin below is one copy instead of two, not a crash fix.\r\n *\r\n * The pin is READ BACK from whatever range the project's own package.json\r\n * declares, never re-stated as a literal here: the feature map in\r\n * `@warlock.js/core` owns the version, and a second copy of it would drift\r\n * the moment that one moves.\r\n *\r\n * Returns whether a pin was written, so the caller (and its spec) can assert\r\n * it instead of assuming it.\r\n */\r\n public pinViteResolution() {\r\n const packageJsonPath = path.resolve(this.path, \"package.json\");\r\n\r\n if (!fileExists(packageJsonPath)) return false;\r\n\r\n const packageJson = getJsonFile(packageJsonPath) as {\r\n dependencies?: Record<string, string>;\r\n devDependencies?: Record<string, string>;\r\n resolutions?: Record<string, string>;\r\n overrides?: Record<string, string>;\r\n };\r\n\r\n const declaredRange = (name: string) =>\r\n packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];\r\n\r\n const viteRange = declaredRange(\"vite\");\r\n\r\n // No vite, or no vitest to conflict with it — nothing to pin. Writing a\r\n // resolution for a package the project does not depend on would only\r\n // freeze a transitive tree nobody asked us to freeze.\r\n if (!viteRange || !declaredRange(\"vitest\")) return false;\r\n\r\n // yarn 1 / yarn berry read `resolutions`; npm 8+ and pnpm read `overrides`.\r\n packageJson.resolutions = { ...packageJson.resolutions, vite: viteRange };\r\n packageJson.overrides = { ...packageJson.overrides, vite: viteRange };\r\n\r\n putJsonFile(packageJsonPath, packageJson);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Get package json file\r\n */\r\n public get package() {\r\n return this.json(\"package.json\");\r\n }\r\n\r\n public updateDotEnv() {\r\n this.file(\".env\").replaceAll(\"appName\", this.name).save();\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Get env file to update\r\n */\r\n public get env() {\r\n return this.file(\".env\");\r\n }\r\n\r\n public get name() {\r\n return this.app.appName;\r\n }\r\n\r\n public get path() {\r\n return this.app.appPath;\r\n }\r\n\r\n public file(relativePath: string) {\r\n const fullPath = path.resolve(this.path, relativePath);\r\n\r\n if (!this.files[fullPath]) {\r\n this.files[fullPath] = file(fullPath);\r\n }\r\n\r\n return this.files[fullPath];\r\n }\r\n\r\n public json(relativePath: string): JsonFileManager {\r\n const fullPath = path.resolve(this.path, relativePath);\r\n\r\n if (!this.jsonFiles[fullPath]) {\r\n this.jsonFiles[fullPath] = jsonFile(fullPath);\r\n }\r\n\r\n return this.jsonFiles[fullPath];\r\n }\r\n}\r\n\r\nexport function app(app: Application) {\r\n return new App(app);\r\n}\r\n\r\nexport class FileManager {\r\n public content!: string;\r\n public constructor(protected filePath: string) {\r\n this.parseContent();\r\n }\r\n\r\n protected parseContent() {\r\n this.content = getFile(this.filePath) as string;\r\n }\r\n\r\n public replace(search: string, replace: string) {\r\n this.content = this.content.replace(search, replace);\r\n\r\n return this;\r\n }\r\n\r\n public replaceAll(search: string, replace: string) {\r\n this.content = this.content.replaceAll(search, replace);\r\n\r\n return this;\r\n }\r\n\r\n public save() {\r\n putFile(this.filePath, this.content);\r\n }\r\n}\r\n\r\nexport class JsonFileManager extends FileManager {\r\n protected parseContent() {\r\n this.content = getJsonFile(this.filePath);\r\n }\r\n\r\n public save() {\r\n putJsonFile(this.filePath, this.content);\r\n }\r\n\r\n public has(key: string) {\r\n return this.content[key] !== undefined;\r\n }\r\n\r\n public replace(key: string, value: any) {\r\n this.content[key] = value;\r\n\r\n return this;\r\n }\r\n\r\n public replaceAll(key: string, value: any) {\r\n const contentAsString = JSON.stringify(this.content);\r\n\r\n this.content = JSON.parse(contentAsString.replaceAll(key, value));\r\n\r\n return this;\r\n }\r\n}\r\n\r\nexport function file(path: string) {\r\n return new FileManager(path);\r\n}\r\n\r\nexport function jsonFile(path: string) {\r\n return new JsonFileManager(path);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,qBAAwC;CACtD,OAAO,EAAE,UAAU,cAAc;AACnC;AAEA,IAAa,MAAb,MAAiB;CAaf,AAAO,YAAY,AAAU,KAAkB;EAAlB;eATkB,CAAC;mBAKO,CAAC;qBAEnC;CAE2B;CAEhD,IAAW,UAAsB;EAC/B,OAAO,KAAK,IAAI;CAClB;CAEA,AAAO,IAAI,cAAwB;EACjC,cAAc,SAAS,YAAY,GAAG,KAAK,IAAI;EAE/C,IAAI,WAAW,KAAK,OAAO,eAAe,GACxC,SAAS,KAAK,OAAO,iBAAiB,KAAK,OAAO,OAAO;EAG3D,WAAW,KAAK,OAAO,gBAAgB,KAAK,OAAO,aAAa;EAEhE,OAAO;CACT;CAEA,AAAO,OAAO;EACZ,OAAO;CACT;CAEA,AAAO,YAAY,CAEnB;CAEA,AAAO,UAAU;EACf,OAAO,WAAW,kBAAkB,GAAG,CAAC,SAAS,GAAG,KAAK,MAAM,EAC7D,KAAK,mBAAmB,EAC1B,CAAC;CACH;CAEA,MAAa,KAAK,SAAiB;EACjC,MAAM,CAAC,aAAa,G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AAK,QAAQ;CACtC;CAEA,AAAO,QAAQ,QAAgB,SAAiB;EAC9C,KAAK,UAAU,KAAK,QAAQ,QAAQ,QAAQ,OAAO;EAEnD,OAAO;CACT;CAEA,AAAO,WAAW,QAAgB,SAAiB;EACjD,KAAK,UAAU,KAAK,QAAQ,WAAW,QAAQ,OAAO;EAEtD,OAAO;CACT;CAEA,AAAO,OAAO;EACZ,QAAQ,KAAK,UAAU,KAAK,OAAO;CACrC;AACF;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAC/C,AAAU,eAAe;EACvB,KAAK,UAAU,YAAY,KAAK,QAAQ;CAC1C;CAEA,AAAO,OAAO;EACZ,YAAY,KAAK,UAAU,KAAK,OAAO;CACzC;CAEA,AAAO,IAAI,KAAa;EACtB,OAAO,KAAK,QAAQ,SAAS;CAC/B;CAEA,AAAO,QAAQ,KAAa,OAAY;EACtC,KAAK,QAAQ,OAAO;EAEpB,OAAO;CACT;CAEA,AAAO,WAAW,KAAa,OAAY;EACzC,MAAM,kBAAkB,KAAK,UAAU,KAAK,OAAO;EAEnD,KAAK,UAAU,KAAK,MAAM,gBAAgB,WAAW,KAAK,KAAK,CAAC;EAEhE,OAAO;CACT;AACF;AAEA,SAAgB,KAAK,MAAc;CACjC,OAAO,IAAI,YAAY,IAAI;AAC7B;AAEA,SAAgB,SAAS,MAAc;CACrC,OAAO,IAAI,gBAAgB,IAAI;AACjC"}
1
+ {"version":3,"file":"app.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/app.ts"],"sourcesContent":["import {\r\n copyDirectory,\r\n copyFile,\r\n fileExists,\r\n getFile,\r\n getJsonFile,\r\n putFile,\r\n putJsonFile,\r\n renameFile,\r\n} from \"@warlock.js/fs\";\r\nimport { existsSync, rmSync, unlinkSync } from \"node:fs\";\r\nimport path from \"path\";\r\nimport { Application, AppOptions } from \"../commands/create-new-app/types\";\r\nimport { getDatabaseDriver } from \"../features/database-drivers\";\r\nimport { executeCommand, runCommand } from \"./exec\";\r\nimport { getPackageManager } from \"./package-manager\";\r\nimport { packageRoot, Template, template } from \"./paths\";\r\nimport { fallbackRange } from \"./warlock-versions\";\r\n\r\n/**\r\n * Environment for every install the scaffolder spawns.\r\n *\r\n * A shell that exports `NODE_ENV=production` makes the package managers skip\r\n * every devDependency — and still exit 0. The scaffolded project needs its dev\r\n * toolchain (typescript, vitest, eslint) to be usable at all, so the install\r\n * child is pinned to `development` regardless of the ambient environment. A\r\n * silently incomplete install that reports success is the exact failure mode\r\n * this file exists to prevent.\r\n */\r\nexport function installEnvironment(): NodeJS.ProcessEnv {\r\n return { NODE_ENV: \"development\" };\r\n}\r\n\r\nexport class App {\r\n /**\r\n * Resolved files\r\n */\r\n protected files: Record<string, FileManager> = {};\r\n\r\n /**\r\n * Resolved JSON files\r\n */\r\n protected jsonFiles: Record<string, JsonFileManager> = {};\r\n\r\n public isInstalled = false;\r\n\r\n public constructor(protected app: Application) {}\r\n\r\n public get options(): AppOptions {\r\n return this.app.options;\r\n }\r\n\r\n public use(templateName: Template) {\r\n copyDirectory(template(templateName), this.path);\r\n\r\n if (fileExists(this.path + \"/.env.example\")) {\r\n copyFile(this.path + \"/.env.example\", this.path + \"/.env\");\r\n }\r\n\r\n renameFile(this.path + \"/_.gitignore\", this.path + \"/.gitignore\");\r\n\r\n return this;\r\n }\r\n\r\n public init() {\r\n return this;\r\n }\r\n\r\n public terminate() {\r\n // No longer using outro, using showSuccessScreen instead\r\n }\r\n\r\n public install() {\r\n return runCommand(getPackageManager(), [\"install\"], this.path, {\r\n env: installEnvironment(),\r\n });\r\n }\r\n\r\n public async exec(command: string) {\r\n const [commandName, ...optionsList] = command.split(\" \");\r\n return await executeCommand(commandName, optionsList, this.path);\r\n }\r\n\r\n public async git() {\r\n const { initializeGitRepository } =\r\n await import(\"./project-builder-helpers\");\r\n return await initializeGitRepository(this.path);\r\n }\r\n\r\n /**\r\n * Write the project's `package.json`: the project name, the chosen package\r\n * manager, and the version of every `@warlock.js/*` dependency.\r\n *\r\n * `versions` comes from {@link resolveWarlockVersions} — versions the\r\n * registry has confirmed exist. It is optional because the fluent chain is\r\n * synchronous; without it every sibling gets the caret range floored to the\r\n * scaffolder's major, which is always satisfiable by a published release.\r\n *\r\n * What it must NEVER do again is stamp the scaffolder's own version blind:\r\n * the release tooling bumps that version on every build, published or not,\r\n * so an unverified pin resolves to nothing and the install dies with ETARGET.\r\n */\r\n public updatePackageJson(versions: Record<string, string> = {}) {\r\n const packageManager = getPackageManager();\r\n\r\n const pkg = this.package.replace(\"name\", this.name.replaceAll(\"/\", \"-\"));\r\n\r\n const content: any = pkg.content;\r\n\r\n // Substitute the chosen package manager ONLY into the fields the template\r\n // writes it into literally — the `serve` script and the huskier hooks — by\r\n // path, never with a blanket substring replace over the serialized JSON. A\r\n // raw `replaceAll(\"yarn\", pm)` rewrites every occurrence of the substring\r\n // \"yarn\" anywhere in the document, so a project named `my-yarn-app`, or any\r\n // dependency/path containing \"yarn\", is silently corrupted (`--pm=npm`\r\n // turned `my-yarn-app` into `my-npm-app`). Field-scoped rewriting is also\r\n // order-independent: the name lives in `content.name` and these tokens live\r\n // in `scripts.serve` / `huskier.hooks`, disjoint fields that cannot collide\r\n // with the name substitution above regardless of which runs first.\r\n if (typeof content.scripts?.serve === \"string\") {\r\n content.scripts.serve = content.scripts.serve.replaceAll(\r\n \"yarn\",\r\n packageManager,\r\n );\r\n }\r\n\r\n const hooks = content.huskier?.hooks as Record<string, unknown> | undefined;\r\n\r\n if (hooks) {\r\n for (const hook of Object.keys(hooks)) {\r\n const commands = hooks[hook];\r\n\r\n if (!Array.isArray(commands)) continue;\r\n\r\n hooks[hook] = commands.map(command =>\r\n typeof command === \"string\"\r\n ? command.replaceAll(\"yarn\", packageManager)\r\n : command,\r\n );\r\n }\r\n }\r\n\r\n const warlockVersion: string = (\r\n getJsonFile(packageRoot(\"package.json\")) as { version: string }\r\n ).version;\r\n const defaultRange = fallbackRange(warlockVersion);\r\n\r\n for (const field of [\"dependencies\", \"devDependencies\"] as const) {\r\n const deps = content[field] as Record<string, string> | undefined;\r\n if (!deps) continue;\r\n\r\n for (const dependency of Object.keys(deps)) {\r\n if (dependency.startsWith(\"@warlock.js/\")) {\r\n deps[dependency] = versions[dependency] ?? defaultRange;\r\n }\r\n }\r\n }\r\n\r\n pkg.save();\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Configure the chosen database driver: wire `DB_DRIVER` / `DB_PORT` into\r\n * `.env`, AND pin the driver's npm package (`mongodb` / `pg`) into the\r\n * project's `package.json` dependencies.\r\n *\r\n * The dependency is written HERE — before the base `yarn install` — so the\r\n * driver is pulled deterministically by the very first install. We do NOT\r\n * rely on the post-copy `warlock add <driver> --no-install` + separate\r\n * batched install, which can be skipped or fail and leave the driver\r\n * missing (the \"mongodb package is not installed\" runtime error).\r\n */\r\n public configureDatabaseEnv(driverValue: string) {\r\n const driver = getDatabaseDriver(driverValue);\r\n\r\n if (!driver) return this;\r\n\r\n // Pin the driver package into dependencies (idempotent — never downgrade).\r\n const packageJsonPath = path.resolve(this.path, \"package.json\");\r\n const packageJson = getJsonFile(packageJsonPath) as {\r\n dependencies?: Record<string, string>;\r\n };\r\n packageJson.dependencies = packageJson.dependencies ?? {};\r\n if (!packageJson.dependencies[driver.package]) {\r\n packageJson.dependencies[driver.package] = driver.packageVersion;\r\n putJsonFile(packageJsonPath, packageJson);\r\n }\r\n\r\n let envContent = getFile(this.path + \"/.env\") as string;\r\n\r\n envContent = envContent.replace(\r\n /DB_PORT=\\d+/,\r\n `DB_PORT=${driver.defaultPort}`,\r\n );\r\n\r\n if (envContent.includes(\"DB_DRIVER=\")) {\r\n envContent = envContent.replace(\r\n /DB_DRIVER=\\w*/,\r\n `DB_DRIVER=${driver.value}`,\r\n );\r\n } else {\r\n envContent = envContent.replace(\r\n /DB_PORT=\\d+/,\r\n `DB_PORT=${driver.defaultPort}\\nDB_DRIVER=${driver.value}`,\r\n );\r\n }\r\n\r\n putFile(this.path + \"/.env\", envContent);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Remove the database layer for a \"no database\" scaffold.\r\n *\r\n * Deletes `src/config/database.ts` (and a `.tsx` variant if present) from the\r\n * freshly-copied template. The framework's database connector is config-gated\r\n * on that file — with it gone, `config.get(\"database\")` is undefined and the\r\n * connector no-ops, so the app boots with no database wired and no driver\r\n * package pulled. The `DB_*` lines in `.env` are left in place (harmless: no\r\n * config reads them) as a ready template for adding a database back later.\r\n */\r\n public removeDatabaseConfig() {\r\n const configDir = path.resolve(this.path, \"src/config\");\r\n\r\n for (const fileName of [\"database.ts\", \"database.tsx\"]) {\r\n const filePath = path.resolve(configDir, fileName);\r\n\r\n if (fileExists(filePath)) {\r\n unlinkSync(filePath);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Configure the web starter only when the web feature owns `/`.\r\n *\r\n * A dependency-free HTTP response is retained without web; otherwise the\r\n * SSR page loader owns the route.\r\n * Exactly one survives the scaffold: web projects keep the SSR page and API\r\n * example; every other project keeps the dependency-free JSON controller.\r\n */\r\n public configureWebStarter(useWeb: boolean) {\r\n const remove = (relativePath: string) => {\r\n const target = path.resolve(this.path, relativePath);\r\n if (existsSync(target)) rmSync(target, { recursive: true, force: true });\r\n };\r\n\r\n if (!useWeb) {\r\n for (const entry of [\r\n \"src/web\",\r\n \"src/app/contact\",\r\n \"src/app/locale\",\r\n \"src/shared/contact.schema.ts\",\r\n \"src/shared/locale.schema.ts\",\r\n \"src/shared/locales.ts\",\r\n \"postcss.config.mjs\",\r\n ]) {\r\n remove(entry);\r\n }\r\n\r\n const tsconfigPath = path.resolve(this.path, \"tsconfig.json\");\r\n const tsconfig = getFile(tsconfigPath) as string;\r\n putFile(\r\n tsconfigPath,\r\n tsconfig\r\n .replace(' \"web/*\": [\"./src/web/*\"],\\n', \"\")\r\n .replace(' \"@shared/*\": [\"./src/shared/*\"]\\n', \"\"),\r\n );\r\n\r\n return this;\r\n }\r\n\r\n // The SSR page owns `/`; its loader still uses src/app/home/services.\r\n remove(\"src/app/home/controllers/home-page.controller.ts\");\r\n remove(\"src/app/home/routes.ts\");\r\n\r\n const packageJsonPath = path.resolve(this.path, \"package.json\");\r\n const packageJson = getJsonFile(packageJsonPath) as {\r\n dependencies?: Record<string, string>;\r\n devDependencies?: Record<string, string>;\r\n };\r\n packageJson.dependencies = {\r\n ...packageJson.dependencies,\r\n \"@mongez/http\": \"^3.5.0\",\r\n \"@mongez/react-form\": \"^4.0.0\",\r\n };\r\n packageJson.devDependencies = {\r\n ...packageJson.devDependencies,\r\n \"@tailwindcss/postcss\": \"^4.1.16\",\r\n tailwindcss: \"^4.1.16\",\r\n };\r\n putJsonFile(packageJsonPath, packageJson);\r\n\r\n const configPath = path.resolve(this.path, \"warlock.config.ts\");\r\n const config = getFile(configPath) as string;\r\n if (!config.includes('\"@warlock.js/web/connector\"')) {\r\n putFile(\r\n configPath,\r\n `import { webConnector } from \"@warlock.js/web/connector\";\\n${config}`.replace(\r\n \"export default defineConfig({\",\r\n \"export default defineConfig({\\n connectors: [webConnector()],\",\r\n ),\r\n );\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Install the selected optional features by delegating to the project's own\r\n * `warlock add`. `--no-install` records every dependency in package.json and\r\n * ejects configs / scripts / setup hooks WITHOUT installing — the caller runs\r\n * one batched install afterwards. Versions come from core's feature map, so\r\n * the scaffolder never duplicates them.\r\n *\r\n * `--no-install` is passed LAST on purpose: the CLI parser treats the\r\n * positional after a bare flag as that flag's value, so it must follow the\r\n * feature list, not precede it.\r\n */\r\n public async installFeatures(features: string[]) {\r\n if (features.length === 0) return true;\r\n\r\n return this.exec(`npx warlock add ${features.join(\" \")} --no-install`);\r\n }\r\n\r\n /**\r\n * Force a single copy of `vite` when the project ends up with BOTH `vite`\r\n * (written by the `web` feature) and `vitest` (always in the template).\r\n *\r\n * `vitest` depends on vite through a wide range of its own\r\n * (`^6 || ^7 || ^8`), which resolves to a DIFFERENT major than the range the\r\n * feature map pins. Yarn 1 then has to nest the second copy under\r\n * `vitest/node_modules` and dies on its own linker invariant:\r\n *\r\n * error Invariant Violation: could not find a copy of vite to link in\r\n * <project>/node_modules/vitest/node_modules\r\n *\r\n * It aborts BEFORE `node_modules/.bin` is written, so `warlock` is never\r\n * linked and the very first `yarn dev` fails with \"'warlock' is not\r\n * recognized\". npm and pnpm nest happily and never hit this — for them the\r\n * `overrides` twin below is one copy instead of two, not a crash fix.\r\n *\r\n * The pin is READ BACK from whatever range the project's own package.json\r\n * declares, never re-stated as a literal here: the feature map in\r\n * `@warlock.js/core` owns the version, and a second copy of it would drift\r\n * the moment that one moves.\r\n *\r\n * Returns whether a pin was written, so the caller (and its spec) can assert\r\n * it instead of assuming it.\r\n */\r\n public pinViteResolution() {\r\n const packageJsonPath = path.resolve(this.path, \"package.json\");\r\n\r\n if (!fileExists(packageJsonPath)) return false;\r\n\r\n const packageJson = getJsonFile(packageJsonPath) as {\r\n dependencies?: Record<string, string>;\r\n devDependencies?: Record<string, string>;\r\n resolutions?: Record<string, string>;\r\n overrides?: Record<string, string>;\r\n };\r\n\r\n const declaredRange = (name: string) =>\r\n packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];\r\n\r\n const viteRange = declaredRange(\"vite\");\r\n\r\n // No vite, or no vitest to conflict with it — nothing to pin. Writing a\r\n // resolution for a package the project does not depend on would only\r\n // freeze a transitive tree nobody asked us to freeze.\r\n if (!viteRange || !declaredRange(\"vitest\")) return false;\r\n\r\n // yarn 1 / yarn berry read `resolutions`; npm 8+ and pnpm read `overrides`.\r\n packageJson.resolutions = { ...packageJson.resolutions, vite: viteRange };\r\n packageJson.overrides = { ...packageJson.overrides, vite: viteRange };\r\n\r\n putJsonFile(packageJsonPath, packageJson);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Get package json file\r\n */\r\n public get package() {\r\n return this.json(\"package.json\");\r\n }\r\n\r\n public updateDotEnv() {\r\n this.file(\".env\").replaceAll(\"appName\", this.name).save();\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Get env file to update\r\n */\r\n public get env() {\r\n return this.file(\".env\");\r\n }\r\n\r\n public get name() {\r\n return this.app.appName;\r\n }\r\n\r\n public get path() {\r\n return this.app.appPath;\r\n }\r\n\r\n public file(relativePath: string) {\r\n const fullPath = path.resolve(this.path, relativePath);\r\n\r\n if (!this.files[fullPath]) {\r\n this.files[fullPath] = file(fullPath);\r\n }\r\n\r\n return this.files[fullPath];\r\n }\r\n\r\n public json(relativePath: string): JsonFileManager {\r\n const fullPath = path.resolve(this.path, relativePath);\r\n\r\n if (!this.jsonFiles[fullPath]) {\r\n this.jsonFiles[fullPath] = jsonFile(fullPath);\r\n }\r\n\r\n return this.jsonFiles[fullPath];\r\n }\r\n}\r\n\r\nexport function app(app: Application) {\r\n return new App(app);\r\n}\r\n\r\nexport class FileManager {\r\n public content!: string;\r\n public constructor(protected filePath: string) {\r\n this.parseContent();\r\n }\r\n\r\n protected parseContent() {\r\n this.content = getFile(this.filePath) as string;\r\n }\r\n\r\n public replace(search: string, replace: string) {\r\n this.content = this.content.replace(search, replace);\r\n\r\n return this;\r\n }\r\n\r\n public replaceAll(search: string, replace: string) {\r\n this.content = this.content.replaceAll(search, replace);\r\n\r\n return this;\r\n }\r\n\r\n public save() {\r\n putFile(this.filePath, this.content);\r\n }\r\n}\r\n\r\nexport class JsonFileManager extends FileManager {\r\n protected parseContent() {\r\n this.content = getJsonFile(this.filePath);\r\n }\r\n\r\n public save() {\r\n putJsonFile(this.filePath, this.content);\r\n }\r\n\r\n public has(key: string) {\r\n return this.content[key] !== undefined;\r\n }\r\n\r\n public replace(key: string, value: any) {\r\n this.content[key] = value;\r\n\r\n return this;\r\n }\r\n\r\n public replaceAll(key: string, value: any) {\r\n const contentAsString = JSON.stringify(this.content);\r\n\r\n this.content = JSON.parse(contentAsString.replaceAll(key, value));\r\n\r\n return this;\r\n }\r\n}\r\n\r\nexport function file(path: string) {\r\n return new FileManager(path);\r\n}\r\n\r\nexport function jsonFile(path: string) {\r\n return new JsonF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ACF;AAMA,IAAa,cAAb,MAAyB;CAEvB,AAAO,YAAY,AAAU,UAAkB;EAAlB;EAC3B,KAAK,aAAa;CACpB;CAEA,AAAU,eAAe;EACvB,KAAK,UAAU,QAAQ,KAAK,QAAQ;CACtC;CAEA,AAAO,QAAQ,QAAgB,SAAiB;EAC9C,KAAK,UAAU,KAAK,QAAQ,QAAQ,QAAQ,OAAO;EAEnD,OAAO;CACT;CAEA,AAAO,WAAW,QAAgB,SAAiB;EACjD,KAAK,UAAU,KAAK,QAAQ,WAAW,QAAQ,OAAO;EAEtD,OAAO;CACT;CAEA,AAAO,OAAO;EACZ,QAAQ,KAAK,UAAU,KAAK,OAAO;CACrC;AACF;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAC/C,AAAU,eAAe;EACvB,KAAK,UAAU,YAAY,KAAK,QAAQ;CAC1C;CAEA,AAAO,OAAO;EACZ,YAAY,KAAK,UAAU,KAAK,OAAO;CACzC;CAEA,AAAO,IAAI,KAAa;EACtB,OAAO,KAAK,QAAQ,SAAS;CAC/B;CAEA,AAAO,QAAQ,KAAa,OAAY;EACtC,KAAK,QAAQ,OAAO;EAEpB,OAAO;CACT;CAEA,AAAO,WAAW,KAAa,OAAY;EACzC,MAAM,kBAAkB,KAAK,UAAU,KAAK,OAAO;EAEnD,KAAK,UAAU,KAAK,MAAM,gBAAgB,WAAW,KAAK,KAAK,CAAC;EAEhE,OAAO;CACT;AACF;AAEA,SAAgB,KAAK,MAAc;CACjC,OAAO,IAAI,YAAY,IAAI;AAC7B;AAEA,SAAgB,SAAS,MAAc;CACrC,OAAO,IAAI,gBAAgB,IAAI;AACjC"}
package/package.json CHANGED
@@ -12,13 +12,13 @@
12
12
  "dependencies": {
13
13
  "@clack/prompts": "^0.7.0",
14
14
  "@mongez/copper": "^2.1.2",
15
- "@warlock.js/fs": "5.2.4",
15
+ "@warlock.js/fs": "5.3.0",
16
16
  "@mongez/reinforcements": "^4.0.1",
17
17
  "cross-spawn": "^7.0.3",
18
18
  "rimraf": "^6.0.1",
19
19
  "which-pm-runs": "^1.1.0"
20
20
  },
21
- "version": "5.2.4",
21
+ "version": "5.3.0",
22
22
  "type": "module",
23
23
  "main": "./esm/index.mjs",
24
24
  "module": "./esm/index.mjs",
@@ -1,98 +1,98 @@
1
- import tsPlugin from "@typescript-eslint/eslint-plugin";
2
- import tsParser from "@typescript-eslint/parser";
3
- import prettierConfig from "eslint-config-prettier";
4
- import prettierPlugin from "eslint-plugin-prettier";
5
- import unusedImports from "eslint-plugin-unused-imports";
6
-
7
- export default [
8
- // Global configuration
9
- {
10
- languageOptions: {
11
- ecmaVersion: "latest",
12
- sourceType: "module",
13
- globals: {
14
- // Node.js globals
15
- console: "readonly",
16
- process: "readonly",
17
- Buffer: "readonly",
18
- __dirname: "readonly",
19
- __filename: "readonly",
20
- global: "readonly",
21
- module: "readonly",
22
- require: "readonly",
23
- exports: "readonly",
24
- // ES2021 globals
25
- Promise: "readonly",
26
- // Jest globals
27
- describe: "readonly",
28
- it: "readonly",
29
- test: "readonly",
30
- expect: "readonly",
31
- beforeEach: "readonly",
32
- afterEach: "readonly",
33
- beforeAll: "readonly",
34
- afterAll: "readonly",
35
- jest: "readonly",
36
- },
37
- },
38
- },
39
-
40
- // TypeScript files configuration
41
- {
42
- files: ["**/*.ts", "**/*.tsx", "**/*.css"],
43
- languageOptions: {
44
- parser: tsParser,
45
- parserOptions: {
46
- ecmaVersion: "latest",
47
- sourceType: "module",
48
- },
49
- },
50
- plugins: {
51
- "@typescript-eslint": tsPlugin,
52
- prettier: prettierPlugin,
53
- "unused-imports": unusedImports,
54
- },
55
- rules: {
56
- // Prettier integration
57
- ...prettierConfig.rules,
58
- "prettier/prettier": "error",
59
-
60
- // TypeScript rules
61
- "@typescript-eslint/no-explicit-any": "off",
62
- "@typescript-eslint/no-unused-vars": "off",
63
- "no-unused-vars": "off",
64
- "unused-imports/no-unused-vars": [
65
- "warn",
66
- {
67
- vars: "all",
68
- varsIgnorePattern: "^_",
69
- args: "after-used",
70
- argsIgnorePattern: "^_",
71
- },
72
- ],
73
- "unused-imports/no-unused-imports": "error",
74
- "@typescript-eslint/explicit-member-accessibility": [
75
- "error",
76
- { accessibility: "explicit" },
77
- ],
78
- "@typescript-eslint/consistent-type-imports": [
79
- "error",
80
- {
81
- prefer: "type-imports",
82
- disallowTypeAnnotations: false,
83
- },
84
- ],
85
- },
86
- },
87
-
88
- // Ignore patterns
89
- {
90
- ignores: [
91
- "dist/",
92
- "node_modules/",
93
- "**/*.js",
94
- "!**/*.config.js",
95
- "!eslint.config.js",
96
- ],
97
- },
98
- ];
1
+ import tsPlugin from "@typescript-eslint/eslint-plugin";
2
+ import tsParser from "@typescript-eslint/parser";
3
+ import prettierConfig from "eslint-config-prettier";
4
+ import prettierPlugin from "eslint-plugin-prettier";
5
+ import unusedImports from "eslint-plugin-unused-imports";
6
+
7
+ export default [
8
+ // Global configuration
9
+ {
10
+ languageOptions: {
11
+ ecmaVersion: "latest",
12
+ sourceType: "module",
13
+ globals: {
14
+ // Node.js globals
15
+ console: "readonly",
16
+ process: "readonly",
17
+ Buffer: "readonly",
18
+ __dirname: "readonly",
19
+ __filename: "readonly",
20
+ global: "readonly",
21
+ module: "readonly",
22
+ require: "readonly",
23
+ exports: "readonly",
24
+ // ES2021 globals
25
+ Promise: "readonly",
26
+ // Jest globals
27
+ describe: "readonly",
28
+ it: "readonly",
29
+ test: "readonly",
30
+ expect: "readonly",
31
+ beforeEach: "readonly",
32
+ afterEach: "readonly",
33
+ beforeAll: "readonly",
34
+ afterAll: "readonly",
35
+ jest: "readonly",
36
+ },
37
+ },
38
+ },
39
+
40
+ // TypeScript files configuration
41
+ {
42
+ files: ["**/*.ts", "**/*.tsx"],
43
+ languageOptions: {
44
+ parser: tsParser,
45
+ parserOptions: {
46
+ ecmaVersion: "latest",
47
+ sourceType: "module",
48
+ },
49
+ },
50
+ plugins: {
51
+ "@typescript-eslint": tsPlugin,
52
+ prettier: prettierPlugin,
53
+ "unused-imports": unusedImports,
54
+ },
55
+ rules: {
56
+ // Prettier integration
57
+ ...prettierConfig.rules,
58
+ "prettier/prettier": "error",
59
+
60
+ // TypeScript rules
61
+ "@typescript-eslint/no-explicit-any": "off",
62
+ "@typescript-eslint/no-unused-vars": "off",
63
+ "no-unused-vars": "off",
64
+ "unused-imports/no-unused-vars": [
65
+ "warn",
66
+ {
67
+ vars: "all",
68
+ varsIgnorePattern: "^_",
69
+ args: "after-used",
70
+ argsIgnorePattern: "^_",
71
+ },
72
+ ],
73
+ "unused-imports/no-unused-imports": "error",
74
+ "@typescript-eslint/explicit-member-accessibility": [
75
+ "error",
76
+ { accessibility: "explicit" },
77
+ ],
78
+ "@typescript-eslint/consistent-type-imports": [
79
+ "error",
80
+ {
81
+ prefer: "type-imports",
82
+ disallowTypeAnnotations: false,
83
+ },
84
+ ],
85
+ },
86
+ },
87
+
88
+ // Ignore patterns
89
+ {
90
+ ignores: [
91
+ "dist/",
92
+ "node_modules/",
93
+ "**/*.js",
94
+ "!**/*.config.js",
95
+ "!eslint.config.js",
96
+ ],
97
+ },
98
+ ];
@@ -0,0 +1,6 @@
1
+ /** Tailwind v4's PostCSS adapter is used by the imported web root stylesheet. */
2
+ export default {
3
+ plugins: {
4
+ "@tailwindcss/postcss": {},
5
+ },
6
+ };
@@ -0,0 +1,21 @@
1
+ import { contactSchema } from "@shared/contact.schema";
2
+ import { type Request, type RequestHandler } from "@warlock.js/core";
3
+ import { type Infer } from "@warlock.js/seal";
4
+
5
+ export type ContactSchema = Infer.Output<typeof contactSchema>;
6
+
7
+ /** POST /api/contact — validates the starter contact form. */
8
+ export const contactController: RequestHandler<Request<ContactSchema>> = async ({
9
+ request,
10
+ response,
11
+ }) => {
12
+ const contact = request.validated();
13
+
14
+ // Replace this with delivery/persistence for your app. Keeping the accepted
15
+ // payload visible makes the endpoint useful while remaining side-effect free.
16
+ return response.success({
17
+ message: "Thanks, " + contact.name + ". Your message has been received.",
18
+ });
19
+ };
20
+
21
+ contactController.validation = { schema: contactSchema };
@@ -0,0 +1,4 @@
1
+ import { router } from "@warlock.js/core";
2
+ import { contactController } from "./controllers/contact.controller";
3
+
4
+ router.post("/api/contact", contactController);
@@ -1,12 +1,6 @@
1
1
  import { Application, type RequestHandler } from "@warlock.js/core";
2
2
 
3
- /**
4
- * Default welcome route — a dependency-free JSON response.
5
- *
6
- * Projects scaffolded with the `react` feature get the richer HTML welcome
7
- * page (`home-page.controller.tsx` + `HomePageComponent.tsx`) instead; this
8
- * plain controller is removed at scaffold time when React is selected.
9
- */
3
+ /** The dependency-free home response for applications without the web feature. */
10
4
  export const homePageController: RequestHandler = async ({ response }) => {
11
5
  return response.success({
12
6
  message: "Welcome to Warlock 🧙 — your app is up and running!",
@@ -0,0 +1,86 @@
1
+ const capabilities = [
2
+ {
3
+ index: "01",
4
+ eyebrow: "Runtime",
5
+ title: "One server. Every layer.",
6
+ body: "HTTP, SSR React, queues, schedules, and agents share one typed runtime instead of a stack of disconnected tools.",
7
+ },
8
+ {
9
+ index: "02",
10
+ eyebrow: "Types",
11
+ title: "Confidence at the edges.",
12
+ body: "Validation, request data, page loaders, and tool calls stay typed from input to response.",
13
+ },
14
+ {
15
+ index: "03",
16
+ eyebrow: "Architecture",
17
+ title: "Packages that compose.",
18
+ body: "Start with Core, then reach for Cascade, Auth, Cache, Scheduler, Seal, or AI only when the product needs them.",
19
+ },
20
+ {
21
+ index: "04",
22
+ eyebrow: "Developer loop",
23
+ title: "Fast where it matters.",
24
+ body: "File-based pages, hot updates, generators, and project-local skills keep momentum inside the codebase.",
25
+ },
26
+ ] as const;
27
+
28
+ const packages = [
29
+ {
30
+ name: "core",
31
+ area: "Foundation",
32
+ description:
33
+ "The application runtime for configuration, commands, connectors, and the development loop.",
34
+ },
35
+ {
36
+ name: "web",
37
+ area: "Full-stack React",
38
+ description:
39
+ "Server-rendered pages, loaders, metadata, layouts, and client-side navigation in one package.",
40
+ },
41
+ {
42
+ name: "cascade",
43
+ area: "Data",
44
+ description:
45
+ "Models, queries, relationships, and migrations for applications that need durable data.",
46
+ },
47
+ {
48
+ name: "seal",
49
+ area: "Validation",
50
+ description: "Composable schemas that validate and shape data at every application boundary.",
51
+ },
52
+ {
53
+ name: "auth",
54
+ area: "Identity",
55
+ description:
56
+ "Authentication primitives for protecting routes and carrying user identity through requests.",
57
+ },
58
+ {
59
+ name: "cache",
60
+ area: "Performance",
61
+ description:
62
+ "A consistent caching layer with replaceable drivers and predictable key management.",
63
+ },
64
+ {
65
+ name: "scheduler",
66
+ area: "Automation",
67
+ description:
68
+ "Declare recurring application work and run it alongside the same Warlock runtime.",
69
+ },
70
+ {
71
+ name: "ai",
72
+ area: "Intelligence",
73
+ description:
74
+ "Build agents, tool-driven workflows, and model-backed product capabilities with typed contracts.",
75
+ },
76
+ ] as const;
77
+
78
+ export async function getHomeService() {
79
+ return {
80
+ packages,
81
+ capabilities,
82
+ statusMessage: "Ready to build.",
83
+ };
84
+ }
85
+
86
+ export type HomePageData = Awaited<ReturnType<typeof getHomeService>>;
@@ -0,0 +1,16 @@
1
+ import { localeSchema, type LocaleSchema } from "@shared/locale.schema";
2
+ import { type Request, type RequestHandler } from "@warlock.js/core";
3
+
4
+ /** POST /api/locale — persists the visitor's locale preference in a cookie. */
5
+ export const localeController: RequestHandler<Request<LocaleSchema>> = async ({
6
+ request,
7
+ response,
8
+ }) => {
9
+ const { locale } = request.validated();
10
+
11
+ response.cookie("locale", locale, { raw: true, path: "/" });
12
+
13
+ return response.success({ locale });
14
+ };
15
+
16
+ localeController.validation = { schema: localeSchema };