@ykdz/template 0.0.18 → 0.0.20

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 (77) hide show
  1. package/dist/cli.js +61 -24
  2. package/node_modules/@ykdz/template-builtin-source/dist/templates/registry.js +0 -2
  3. package/node_modules/@ykdz/template-builtin-source/dist/templates/vike-app/projection.js +13 -2
  4. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-app/projection.js +5 -73
  5. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-hono-app/projection.js +3 -2
  6. package/node_modules/@ykdz/template-builtin-source/package.json +36 -3
  7. package/node_modules/@ykdz/template-builtin-source/templates/preset-source.json +69 -282
  8. package/node_modules/@ykdz/template-builtin-source/templates/rust-bin/src/main.rs +5 -2
  9. package/node_modules/@ykdz/template-builtin-source/templates/rust-bin/turbo.json +2 -1
  10. package/node_modules/@ykdz/template-builtin-source/templates/ts-lib/turbo.json +2 -1
  11. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{drizzle.config.ts → db/drizzle.config.ts} +2 -2
  12. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{database → db/src}/db.ts +1 -1
  13. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/db/src/index.ts +1 -0
  14. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{database → db/src}/queries/todos.ts +4 -8
  15. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{test → db/test}/todos.test.ts +2 -2
  16. package/node_modules/@ykdz/template-builtin-source/templates/{hono-api → vike-app/db}/turbo.json +2 -1
  17. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/index/+Page.telefunc.ts +3 -1
  18. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/index/+Page.vue +1 -2
  19. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/web/playwright.config.ts +43 -0
  20. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/web/scripts/run-playwright.ts +62 -0
  21. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{server → web/server}/app.ts +1 -1
  22. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{test → web/test}/e2e/app.spec.ts +1 -1
  23. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/web/turbo.json +12 -0
  24. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{types → web/types}/global.d.ts +1 -1
  25. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{vite.config.ts → web/vite.config.ts} +1 -0
  26. package/node_modules/@ykdz/template-builtin-source/templates/vue-app/playwright.config.ts +16 -3
  27. package/node_modules/@ykdz/template-builtin-source/templates/vue-app/scripts/run-playwright.ts +38 -1
  28. package/node_modules/@ykdz/template-builtin-source/templates/vue-app/turbo.json +1 -0
  29. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/api/turbo.json +1 -0
  30. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/playwright.config.ts +7 -9
  31. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/scripts/run-playwright.ts +79 -1
  32. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/src/App.vue +4 -5
  33. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/src/api.ts +9 -3
  34. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/test/e2e/app.spec.ts +1 -1
  35. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/turbo.json +1 -0
  36. package/node_modules/@ykdz/template-core/dist/Cargo.lock +16 -0
  37. package/node_modules/@ykdz/template-core/dist/Cargo.toml +12 -0
  38. package/node_modules/@ykdz/template-core/dist/dependency-catalog.d.ts +8 -0
  39. package/node_modules/@ykdz/template-core/dist/dependency-catalog.js +63 -2
  40. package/node_modules/@ykdz/template-core/dist/generated-scenarios.d.ts +1 -1
  41. package/node_modules/@ykdz/template-core/dist/generated-scenarios.js +104 -26
  42. package/node_modules/@ykdz/template-core/dist/next-step-instructions.d.ts +8 -0
  43. package/node_modules/@ykdz/template-core/dist/next-step-instructions.js +65 -0
  44. package/node_modules/@ykdz/template-core/dist/package-addition.js +5 -9
  45. package/node_modules/@ykdz/template-core/dist/package-linking.d.ts +24 -0
  46. package/node_modules/@ykdz/template-core/dist/package-linking.js +35 -0
  47. package/node_modules/@ykdz/template-core/dist/preset-source.d.ts +2 -2
  48. package/node_modules/@ykdz/template-core/dist/projection-capabilities.js +225 -139
  49. package/node_modules/@ykdz/template-core/dist/template-boundary-check.js +46 -10
  50. package/node_modules/@ykdz/template-core/package.json +5 -1
  51. package/node_modules/@ykdz/template-shared/dist/index.d.ts +3 -152
  52. package/node_modules/@ykdz/template-shared/dist/index.js +49 -305
  53. package/node_modules/@ykdz/template-shared/package.json +4 -0
  54. package/package.json +2 -2
  55. package/node_modules/@ykdz/template-builtin-source/dist/templates/hono-api/projection.d.ts +0 -6
  56. package/node_modules/@ykdz/template-builtin-source/dist/templates/hono-api/projection.js +0 -213
  57. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/.github/dependabot.yml +0 -23
  58. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/.github/workflows/check.yml +0 -19
  59. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/src/app.ts +0 -5
  60. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/src/server.ts +0 -15
  61. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/test/app.test.ts +0 -10
  62. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/vitest.config.ts +0 -15
  63. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/playwright.config.ts +0 -23
  64. package/node_modules/@ykdz/template-builtin-source/templates/vue-app/playwright.package-addition.config.ts +0 -22
  65. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{database → db/src}/schema.ts +0 -0
  66. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{+server.ts → web/+server.ts} +0 -0
  67. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{.env.example → web/.env.example} +0 -0
  68. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{assets → web/assets}/logo.svg +0 -0
  69. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{components → web/components}/CounterButton.vue +0 -0
  70. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{components → web/components}/PageShell.vue +0 -0
  71. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/+Head.vue +0 -0
  72. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/+Layout.vue +0 -0
  73. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/+config.ts +0 -0
  74. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{pages → web/pages}/tailwind.css +0 -0
  75. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{server → web/server}/api.ts +0 -0
  76. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{types → web/types}/env.d.ts +0 -0
  77. /package/node_modules/@ykdz/template-builtin-source/templates/vike-app/{vitest.config.ts → web/vitest.config.ts} +0 -0
@@ -1,12 +1,11 @@
1
1
  import { readFileSync } from "node:fs";
2
- import { readFile } from "node:fs/promises";
3
2
  import path from "node:path";
4
3
  import { normalizePresetProjectionDeclaration, projectionCapabilityIssues, validatePresetProjectionDeclaration as validateProjectionCapabilities, } from "@ykdz/template-shared";
5
- import { collectGeneratedManifestCatalogDependencies, collectGeneratedManifestCatalogReferences, renderGeneratedPnpmWorkspaceYaml, } from "./dependency-catalog.js";
4
+ import { collectGeneratedManifestCatalogDependencies, collectGeneratedManifestCatalogReferences, renderCargoLockForPackage, renderGeneratedPnpmWorkspaceYaml, renderCargoDependencyTomlEntries, } from "./dependency-catalog.js";
6
5
  import { browserTestToolLayer, checkedDockerfileFirstNodePnpmDevcontainer, dockerfileFirstRustPnpmDevcontainer, nodePnpmToolLayer, rustToolLayer, } from "./devcontainer.js";
7
6
  import { editorCustomizationForCapabilities, loadEditorCustomizationDeclarations, } from "./editor-customization.js";
8
7
  import { playwrightBrowserAssetsEnvironmentNeed, renderCheckLeafCommand, renderFixCommand, renderFixLeafCommand, renderRootCheckCommand, renderTurboRunCommand, } from "./module-graph.js";
9
- import { packageManifestExposureFields, packageTurboTasks, planPackageLinks, } from "./package-linking.js";
8
+ import { packageManifestExposureFields, packageTurboConfig, planPackageLinks, } from "./package-linking.js";
10
9
  export { normalizePresetProjectionDeclaration, projectionCapabilityIssues, validateProjectionCapabilities, };
11
10
  const strictTypescriptRootBoundary = {
12
11
  kind: "workspace-orchestration",
@@ -362,26 +361,12 @@ export async function planPresetSourcePackageAddition(options) {
362
361
  packageSourcePreset: additionCapability.packageSourcePreset,
363
362
  sourceRoot: templateSourceRootForPreset(state, additionCapability.sourcePreset),
364
363
  sourceRoots: state.sourceRoots,
365
- operations: [
366
- ...packageAdditionOperationsForCapability({
367
- capability: additionCapability,
368
- packageName: options.addition.packageName,
369
- packagePath: options.addition.packagePath,
370
- nodeVersion: options.addition.nodeVersion,
371
- }),
372
- ...(additionCapability.packageSourcePreset === "vue-app"
373
- ? [
374
- {
375
- kind: "writeTextTemplate",
376
- from: "playwright.package-addition.config.ts",
377
- to: `${options.addition.packagePath}/playwright.config.ts`,
378
- replacements: {
379
- VUE_PREVIEW_PORT: String(await nextVuePreviewPort(options.addition.root, options.addition.blueprint)),
380
- },
381
- },
382
- ]
383
- : []),
384
- ],
364
+ operations: packageAdditionOperationsForCapability({
365
+ capability: additionCapability,
366
+ packageName: options.addition.packageName,
367
+ packagePath: options.addition.packagePath,
368
+ nodeVersion: options.addition.nodeVersion,
369
+ }),
385
370
  };
386
371
  }
387
372
  export function defaultPackagePathForPresetSourcePackageAddition(preset, packageLeafName, sourceRoots) {
@@ -680,49 +665,13 @@ function vueAppPackageAdditionOperations(options) {
680
665
  }), options.packageName, options.capability.packageScripts),
681
666
  },
682
667
  ...vueAppTsconfigOperations(options.packagePath),
683
- ...options.capability.sourceFiles
684
- .filter((sourceFile) => path.basename(sourceFile) !== "playwright.config.ts")
685
- .map((sourceFile) => ({
668
+ ...options.capability.sourceFiles.map((sourceFile) => ({
686
669
  kind: "copyFile",
687
670
  from: sourceFile,
688
671
  to: `${options.packagePath}/${sourceFile}`,
689
672
  })),
690
673
  ];
691
674
  }
692
- function localPortsFromText(text) {
693
- return [
694
- ...text.matchAll(/--port\s+(\d+)/g),
695
- ...text.matchAll(/https?:\/\/(?:localhost|127\.0\.0\.1):(\d+)/g),
696
- ].map((match) => Number(match[1]));
697
- }
698
- async function usedPlaywrightPorts(root, blueprint) {
699
- const ports = new Set();
700
- for (const projectPackage of blueprint.packages ?? []) {
701
- try {
702
- const configText = await readFile(path.join(root, projectPackage.path, "playwright.config.ts"), "utf8");
703
- for (const port of localPortsFromText(configText)) {
704
- ports.add(port);
705
- }
706
- }
707
- catch (error) {
708
- if (!isNodeError(error) || error.code !== "ENOENT") {
709
- throw error;
710
- }
711
- }
712
- }
713
- return ports;
714
- }
715
- async function nextVuePreviewPort(root, blueprint) {
716
- const usedPorts = await usedPlaywrightPorts(root, blueprint);
717
- let port = 4173;
718
- while (usedPorts.has(port)) {
719
- port += 1;
720
- }
721
- return port;
722
- }
723
- function isNodeError(error) {
724
- return error instanceof Error && "code" in error;
725
- }
726
675
  function completePlanCapabilityFlags(flags) {
727
676
  const missing = requiredPlanCapabilityProviders.filter((requirement) => flags[requirement.flag] !== true);
728
677
  if (missing.length > 0) {
@@ -782,6 +731,9 @@ function workspaceGlobBoundary(workspacePackageGlob) {
782
731
  function hasVuePackage(capability) {
783
732
  return findVuePackage(capability) !== undefined;
784
733
  }
734
+ function hasVikePackage(capability) {
735
+ return capability.packages.some((nodePackage) => nodePackage.kind === "vike-app");
736
+ }
785
737
  function findVuePackage(capability) {
786
738
  return capability.packages.find((nodePackage) => nodePackage.kind === "vue-app" || nodePackage.kind === "vike-app");
787
739
  }
@@ -799,11 +751,12 @@ function projectRootPackageScripts(checkPlan, fixPlan, fragments) {
799
751
  const leafFragments = leafScriptFragments(fragments);
800
752
  const directFragments = directScriptFragments(fragments);
801
753
  return {
802
- check: renderRootCheckCommand(checkPlan),
754
+ check: `pnpm run check:boundaries && ${renderRootCheckCommand(checkPlan)}`,
803
755
  fix: renderFixCommand(fixPlan),
804
756
  ...rootTaskEntrypoints(checkPlan, fixPlan),
805
757
  ...directFragments,
806
758
  ...leafFragments,
759
+ "check:boundaries": "turbo boundaries --no-color",
807
760
  "check:run": noopTaskCommand(),
808
761
  "fix:run": noopTaskCommand(),
809
762
  };
@@ -931,7 +884,7 @@ function packageLinkPlanFor(context, capability) {
931
884
  ]);
932
885
  }
933
886
  function nodePackageDefinitions(context, capability) {
934
- return capability.packages
887
+ const nodeDefinitions = capability.packages
935
888
  .filter((nodePackage) => nodePackage.kind === "hono-api")
936
889
  .map((nodePackage) => ({
937
890
  name: nodePackageName(context, nodePackage),
@@ -939,6 +892,18 @@ function nodePackageDefinitions(context, capability) {
939
892
  role: "runtime-service",
940
893
  sourcePreset: "hono-api",
941
894
  }));
895
+ if (hasVikePackage(capability)) {
896
+ return [
897
+ ...nodeDefinitions,
898
+ {
899
+ name: vikeDbPackageName(context),
900
+ path: vikeDbPackagePath(),
901
+ role: "shared-library",
902
+ sourcePreset: "ts-lib",
903
+ },
904
+ ];
905
+ }
906
+ return nodeDefinitions;
942
907
  }
943
908
  function nodePackageName(context, nodePackage) {
944
909
  const packageDefinition = context.blueprint.packages?.find((pkg) => pkg.path === nodePackage.path);
@@ -948,16 +913,16 @@ function nodePackageName(context, nodePackage) {
948
913
  const leaf = nodePackage.path.split("/").at(-1) ?? nodePackage.path;
949
914
  return `@${context.projectName.value}/${leaf}`;
950
915
  }
951
- function packageScopeFromNodeWorkspace(context) {
952
- const apiPackage = context.blueprint.packages?.find((pkg) => pkg.path === "apps/api");
953
- if (apiPackage?.name.startsWith("@") && apiPackage.name.endsWith("/api")) {
954
- return apiPackage.name.slice(1, -"/api".length);
955
- }
956
- return context.projectName.value;
957
- }
958
916
  function nodePackageLinkPlan(context, capability) {
959
917
  return planPackageLinks(nodePackageDefinitions(context, capability), capability.packageLinks ?? []);
960
918
  }
919
+ function vikeDbPackagePath() {
920
+ return "packages/db";
921
+ }
922
+ function vikeDbPackageName(context) {
923
+ const packageDefinition = context.blueprint.packages?.find((pkg) => pkg.path === vikeDbPackagePath());
924
+ return packageDefinition?.name ?? `@${context.projectName.value}/db`;
925
+ }
961
926
  function rootPackageJson(context, packageScripts, state) {
962
927
  return {
963
928
  name: context.projectName.value,
@@ -1076,7 +1041,7 @@ function vuePackageJson(context, packageName, scripts, packageLinkDependencies =
1076
1041
  },
1077
1042
  };
1078
1043
  }
1079
- function vikePackageJson(context, packageName, scripts) {
1044
+ function vikePackageJson(context, packageName, scripts, packageLinkDependencies = {}) {
1080
1045
  return {
1081
1046
  name: packageName,
1082
1047
  version: "0.0.0",
@@ -1090,8 +1055,8 @@ function vikePackageJson(context, packageName, scripts) {
1090
1055
  },
1091
1056
  scripts,
1092
1057
  dependencies: {
1058
+ ...packageLinkDependencies,
1093
1059
  "@vikejs/hono": "catalog:",
1094
- "drizzle-orm": "catalog:",
1095
1060
  hono: "catalog:",
1096
1061
  telefunc: "catalog:",
1097
1062
  vike: "catalog:",
@@ -1104,7 +1069,6 @@ function vikePackageJson(context, packageName, scripts) {
1104
1069
  "@types/node": "catalog:",
1105
1070
  "@vitejs/plugin-vue": "catalog:",
1106
1071
  "@vue/tsconfig": "catalog:",
1107
- "drizzle-kit": "catalog:",
1108
1072
  oxfmt: "catalog:",
1109
1073
  oxlint: "catalog:",
1110
1074
  "oxlint-tsgolint": "catalog:",
@@ -1121,6 +1085,65 @@ function vikePackageJson(context, packageName, scripts) {
1121
1085
  packageManager: context.toolchain.packageManagerPin.value,
1122
1086
  };
1123
1087
  }
1088
+ function vikeDbPackageJson(context) {
1089
+ return {
1090
+ name: vikeDbPackageName(context),
1091
+ version: "0.0.0",
1092
+ private: true,
1093
+ type: "module",
1094
+ imports: {
1095
+ "#db/*": {
1096
+ default: "./src/*.ts",
1097
+ types: "./src/*.ts",
1098
+ },
1099
+ },
1100
+ exports: {
1101
+ ".": {
1102
+ default: "./src/index.ts",
1103
+ types: "./src/index.ts",
1104
+ },
1105
+ "./schema": {
1106
+ default: "./src/schema.ts",
1107
+ types: "./src/schema.ts",
1108
+ },
1109
+ "./queries/todos": {
1110
+ default: "./src/queries/todos.ts",
1111
+ types: "./src/queries/todos.ts",
1112
+ },
1113
+ },
1114
+ dependencies: {
1115
+ "drizzle-orm": "catalog:",
1116
+ },
1117
+ scripts: vikeDbPackageScripts(),
1118
+ devDependencies: {
1119
+ "@types/node": "catalog:",
1120
+ "drizzle-kit": "catalog:",
1121
+ oxfmt: "catalog:",
1122
+ oxlint: "catalog:",
1123
+ "oxlint-tsgolint": "catalog:",
1124
+ typescript: "catalog:",
1125
+ vitest: "catalog:",
1126
+ },
1127
+ engines: {
1128
+ node: context.toolchain.nodeLtsMajor.value,
1129
+ },
1130
+ };
1131
+ }
1132
+ function vikeDbPackageScripts() {
1133
+ return {
1134
+ "build:run": "tsc -p tsconfig.json --noEmit",
1135
+ "db:push": "mkdir -p data node_modules/.tmp && drizzle-kit push",
1136
+ "drizzle:generate": "drizzle-kit generate",
1137
+ "drizzle:migrate": "drizzle-kit migrate",
1138
+ "drizzle:studio": "drizzle-kit studio",
1139
+ "format:check:run": "oxfmt --list-different --config ../../oxfmt.config.ts .",
1140
+ "format:write:run": "oxfmt --write --config ../../oxfmt.config.ts .",
1141
+ "lint:run": "oxlint --quiet --format=unix --config ../../oxlint.config.ts .",
1142
+ "lint:fix:run": "oxlint --format=unix --config ../../oxlint.config.ts . --fix",
1143
+ "test:run": "DATABASE_FILE=./node_modules/.tmp/test.sqlite pnpm run db:push && DATABASE_FILE=./node_modules/.tmp/test.sqlite vitest run --reporter=agent --silent=passed-only",
1144
+ "typecheck:run": "tsc -p tsconfig.json --noEmit --pretty false",
1145
+ };
1146
+ }
1124
1147
  function catalogDependencies(dependencies) {
1125
1148
  return Object.fromEntries([...dependencies].toSorted().map((dependency) => [dependency, "catalog:"]));
1126
1149
  }
@@ -1136,7 +1159,7 @@ function generationRecord(context) {
1136
1159
  },
1137
1160
  };
1138
1161
  }
1139
- function rustCargoToml(projectName) {
1162
+ function rustCargoToml(projectName, dependencies = []) {
1140
1163
  return [
1141
1164
  "[package]",
1142
1165
  `name = "${projectName}"`,
@@ -1144,6 +1167,7 @@ function rustCargoToml(projectName) {
1144
1167
  'edition = "2024"',
1145
1168
  "",
1146
1169
  "[dependencies]",
1170
+ ...renderCargoDependencyTomlEntries(dependencies),
1147
1171
  "",
1148
1172
  "[lints]",
1149
1173
  "workspace = true",
@@ -1168,16 +1192,10 @@ function rustCargoToml(projectName) {
1168
1192
  ].join("\n");
1169
1193
  }
1170
1194
  function rustCargoLock(projectName) {
1171
- return [
1172
- "# This file is automatically @generated by Cargo.",
1173
- "# It is not intended for manual editing.",
1174
- "version = 4",
1175
- "",
1176
- "[[package]]",
1177
- `name = "${projectName}"`,
1178
- 'version = "0.1.0"',
1179
- "",
1180
- ].join("\n");
1195
+ return renderCargoLockForPackage({
1196
+ packageName: projectName,
1197
+ packageVersion: "0.1.0",
1198
+ });
1181
1199
  }
1182
1200
  function rustRootPackageJson(context, packageScripts, state) {
1183
1201
  return {
@@ -1223,7 +1241,6 @@ function workspaceLibraryPackageOperations({ context, state, packageScripts, pac
1223
1241
  }
1224
1242
  const rootManifest = rootPackageJson(context, packageScripts, state);
1225
1243
  const packageManifest = libraryPackageJson(context, state, capability, workspacePackageScripts);
1226
- const packageLinkPlan = packageLinkPlanFor(context, capability);
1227
1244
  return [
1228
1245
  {
1229
1246
  kind: "writeJson",
@@ -1244,11 +1261,7 @@ function workspaceLibraryPackageOperations({ context, state, packageScripts, pac
1244
1261
  {
1245
1262
  kind: "writeJson",
1246
1263
  to: "turbo.json",
1247
- value: {
1248
- tasks: {
1249
- ...packageLinkPlan.turboTasks,
1250
- },
1251
- },
1264
+ value: packageTurboConfig({ dependencyBuildsRequired: false }),
1252
1265
  },
1253
1266
  {
1254
1267
  kind: "writeJson",
@@ -1327,9 +1340,7 @@ function rustBinaryWorkspaceOperations({ context, state, packageScripts, }) {
1327
1340
  {
1328
1341
  kind: "writeJson",
1329
1342
  to: "turbo.json",
1330
- value: {
1331
- tasks: packageTurboTasks({ dependencyBuildsRequired: false }),
1332
- },
1343
+ value: packageTurboConfig({ dependencyBuildsRequired: false }),
1333
1344
  },
1334
1345
  {
1335
1346
  kind: "writeJson",
@@ -1339,7 +1350,7 @@ function rustBinaryWorkspaceOperations({ context, state, packageScripts, }) {
1339
1350
  {
1340
1351
  kind: "writeText",
1341
1352
  to: `${packagePath}/Cargo.toml`,
1342
- text: rustCargoToml(rustProjectName(context)),
1353
+ text: rustCargoToml(rustProjectName(context), capability.cargoDependencies ?? []),
1343
1354
  },
1344
1355
  {
1345
1356
  kind: "writeText",
@@ -1429,7 +1440,7 @@ function workspaceNodePackagesOperations({ context, state, packageScripts, }) {
1429
1440
  }
1430
1441
  const capability = state.nodeWorkspace;
1431
1442
  const packageLinkPlan = nodePackageLinkPlan(context, capability);
1432
- const packageManifests = capability.packages.map((nodePackage) => {
1443
+ const nodePackageManifests = capability.packages.map((nodePackage) => {
1433
1444
  const scripts = nodePackageScripts(nodePackage, capability);
1434
1445
  const packageName = nodePackageName(context, nodePackage);
1435
1446
  if (nodePackage.kind === "hono-api") {
@@ -1439,10 +1450,16 @@ function workspaceNodePackagesOperations({ context, state, packageScripts, }) {
1439
1450
  : packageManifestExposureFields(exposure));
1440
1451
  }
1441
1452
  if (nodePackage.kind === "vike-app") {
1442
- return vikePackageJson(context, packageName, scripts);
1453
+ return vikePackageJson(context, packageName, scripts, packageLinkPlan.manifestDependenciesByPackagePath.get(nodePackage.path));
1443
1454
  }
1444
1455
  return vuePackageJson(context, packageName, scripts, packageLinkPlan.manifestDependenciesByPackagePath.get(nodePackage.path));
1445
1456
  });
1457
+ const vikeDbManifest = hasVikePackage(capability)
1458
+ ? vikeDbPackageJson(context)
1459
+ : undefined;
1460
+ const packageManifests = vikeDbManifest === undefined
1461
+ ? nodePackageManifests
1462
+ : [...nodePackageManifests, vikeDbManifest];
1446
1463
  const rootManifest = rootPackageJson(context, packageScripts, state);
1447
1464
  if (rootManifest === undefined) {
1448
1465
  throw new Error("workspace-node-packages rendered no package manifests");
@@ -1457,7 +1474,7 @@ function workspaceNodePackagesOperations({ context, state, packageScripts, }) {
1457
1474
  kind: "writeText",
1458
1475
  to: "pnpm-workspace.yaml",
1459
1476
  text: renderGeneratedPnpmWorkspaceYaml({
1460
- packages: [capability.workspacePackageGlob],
1477
+ packages: workspacePackageGlobsForNodeWorkspace(capability),
1461
1478
  dependencies: capability.packageLinks === undefined
1462
1479
  ? collectGeneratedManifestCatalogDependencies([
1463
1480
  rootManifest,
@@ -1491,6 +1508,9 @@ function workspaceNodePackagesOperations({ context, state, packageScripts, }) {
1491
1508
  }
1492
1509
  : {}),
1493
1510
  },
1511
+ boundaries: packageTurboConfig({
1512
+ dependencyBuildsRequired: false,
1513
+ }).boundaries,
1494
1514
  },
1495
1515
  },
1496
1516
  {
@@ -1502,16 +1522,17 @@ function workspaceNodePackagesOperations({ context, state, packageScripts, }) {
1502
1522
  {
1503
1523
  kind: "writeJson",
1504
1524
  to: `${nodePackage.path}/package.json`,
1505
- value: packageManifests[index],
1525
+ value: nodePackageManifests[index],
1506
1526
  },
1507
1527
  ...nodePackageTsconfigOperations(nodePackage, capability),
1508
- ...nodePackage.sourceFiles.map((sourceFile) => ({
1509
- kind: "copyFile",
1510
- from: sourceFile,
1511
- to: nodePackageTargetPath(nodePackage, sourceFile, capability),
1528
+ ...nodePackage.sourceFiles.flatMap((sourceFile) => vikeTemplateSourceOperation({
1529
+ context,
1530
+ nodePackage,
1531
+ sourceFile,
1532
+ workspace: capability,
1512
1533
  })),
1513
1534
  ]),
1514
- ...fullStackApiAnchorOperations(context, capability),
1535
+ ...(vikeDbManifest === undefined ? [] : vikeDbPackageOperations(context)),
1515
1536
  {
1516
1537
  kind: "writeJson",
1517
1538
  to: ".template/blueprint.json",
@@ -1544,21 +1565,18 @@ function nodePackageScripts(nodePackage, workspace) {
1544
1565
  };
1545
1566
  }
1546
1567
  if (nodePackage.kind === "vike-app") {
1568
+ const dbCommand = "DATABASE_FILE=../../apps/web/data/app.sqlite pnpm --dir ../../packages/db run db:push";
1547
1569
  return {
1548
1570
  "build:run": "vike build",
1549
- dev: "pnpm run db:push && vike dev",
1550
- "db:push": "mkdir -p data node_modules/.tmp && drizzle-kit push",
1551
- "drizzle:generate": "drizzle-kit generate",
1552
- "drizzle:migrate": "drizzle-kit migrate",
1553
- "drizzle:studio": "drizzle-kit studio",
1571
+ dev: `${dbCommand} && vike dev`,
1554
1572
  "format:check:run": "oxfmt --list-different --config ../../oxfmt.config.ts .",
1555
1573
  "format:write:run": "oxfmt --write --config ../../oxfmt.config.ts .",
1556
1574
  "lint:run": "oxlint --quiet --format=unix --type-aware --config ../../oxlint.config.ts .",
1557
1575
  "lint:fix:run": "oxlint --type-aware --format=unix --config ../../oxlint.config.ts . --fix",
1558
- preview: "pnpm run db:push && vike preview",
1576
+ preview: `${dbCommand} && vike preview`,
1559
1577
  start: "node ./dist/server/index.mjs",
1560
- "test:run": "DATABASE_FILE=./node_modules/.tmp/test.sqlite pnpm run db:push && DATABASE_FILE=./node_modules/.tmp/test.sqlite vitest run --reporter=agent --silent=passed-only",
1561
- "test:e2e:run": "playwright test --config playwright.config.ts",
1578
+ "test:run": "vitest run --reporter=agent --silent=passed-only --passWithNoTests",
1579
+ "test:e2e:run": "node --experimental-strip-types scripts/run-playwright.ts",
1562
1580
  "typecheck:run": "vue-tsc --build --noEmit --pretty false",
1563
1581
  };
1564
1582
  }
@@ -1583,6 +1601,7 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1583
1601
  value: {
1584
1602
  files: [],
1585
1603
  references: [
1604
+ { path: "../../packages/db" },
1586
1605
  { path: "./tsconfig.app.json" },
1587
1606
  { path: "./tsconfig.test.json" },
1588
1607
  { path: "./tsconfig.node.json" },
@@ -1597,8 +1616,8 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1597
1616
  compilerOptions: {
1598
1617
  ...strictTypeScriptCompilerOptions({
1599
1618
  composite: true,
1600
- module: "ESNext",
1601
- moduleResolution: "Bundler",
1619
+ module: "esnext",
1620
+ moduleResolution: "bundler",
1602
1621
  paths: { "#/*": ["./*"] },
1603
1622
  tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
1604
1623
  types: ["node"],
@@ -1609,7 +1628,6 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1609
1628
  "+server.ts",
1610
1629
  "assets/**/*.svg",
1611
1630
  "components/**/*.vue",
1612
- "database/**/*.ts",
1613
1631
  "pages/**/*.ts",
1614
1632
  "pages/**/*.vue",
1615
1633
  "server/**/*.ts",
@@ -1629,7 +1647,7 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1629
1647
  tsBuildInfoFile: "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
1630
1648
  types: ["node", "vitest/globals"],
1631
1649
  },
1632
- include: ["database/**/*.ts", "test/**/*.ts", "vitest.config.ts"],
1650
+ include: ["test/**/*.ts", "vitest.config.ts"],
1633
1651
  },
1634
1652
  },
1635
1653
  {
@@ -1640,8 +1658,8 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1640
1658
  compilerOptions: {
1641
1659
  ...strictTypeScriptCompilerOptions({
1642
1660
  composite: true,
1643
- module: "ESNext",
1644
- moduleResolution: "Bundler",
1661
+ module: "esnext",
1662
+ moduleResolution: "bundler",
1645
1663
  lib: ["ESNext", "DOM", "DOM.Iterable"],
1646
1664
  paths: { "#/*": ["./*"] },
1647
1665
  tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
@@ -1650,7 +1668,6 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1650
1668
  skipLibCheck: true,
1651
1669
  },
1652
1670
  include: [
1653
- "drizzle.config.ts",
1654
1671
  "playwright.config.ts",
1655
1672
  "scripts/**/*.ts",
1656
1673
  "vite.config.ts",
@@ -1713,8 +1730,8 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1713
1730
  extends: "@vue/tsconfig/tsconfig.dom.json",
1714
1731
  compilerOptions: strictTypeScriptCompilerOptions({
1715
1732
  composite: true,
1716
- module: "ESNext",
1717
- moduleResolution: "Bundler",
1733
+ module: "esnext",
1734
+ moduleResolution: "bundler",
1718
1735
  tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
1719
1736
  types: ["web-bluetooth"],
1720
1737
  }),
@@ -1741,8 +1758,8 @@ function nodePackageTsconfigOperations(nodePackage, workspace) {
1741
1758
  value: {
1742
1759
  compilerOptions: strictTypeScriptCompilerOptions({
1743
1760
  composite: true,
1744
- module: "ESNext",
1745
- moduleResolution: "Bundler",
1761
+ module: "esnext",
1762
+ moduleResolution: "bundler",
1746
1763
  lib: ["ESNext", "DOM", "DOM.Iterable"],
1747
1764
  ...(workspace.packages.length > 1
1748
1765
  ? { outDir: "./node_modules/.tmp/tsconfig.node" }
@@ -1803,7 +1820,7 @@ function vueAppTsconfigOperations(packagePath) {
1803
1820
  }));
1804
1821
  }
1805
1822
  function sourcePathWithinNodePackage(sourceFile, workspace) {
1806
- if (workspace.packages.length === 1) {
1823
+ if (workspace.packages.length === 1 && !sourceFile.startsWith("web/")) {
1807
1824
  return sourceFile;
1808
1825
  }
1809
1826
  return sourceFile.replace(/^(api|web)\//, "");
@@ -1812,6 +1829,91 @@ function nodePackageTargetPath(nodePackage, sourceFile, workspace) {
1812
1829
  const packageRelativePath = sourcePathWithinNodePackage(sourceFile, workspace);
1813
1830
  return `${nodePackage.path}/${packageRelativePath}`;
1814
1831
  }
1832
+ function vikeTemplateSourceOperation(options) {
1833
+ const to = nodePackageTargetPath(options.nodePackage, options.sourceFile, options.workspace);
1834
+ const copyOperation = {
1835
+ kind: "copyFile",
1836
+ from: options.sourceFile,
1837
+ to,
1838
+ };
1839
+ if (options.nodePackage.kind === "vike-app" &&
1840
+ [
1841
+ "web/pages/index/+Page.telefunc.ts",
1842
+ "web/server/app.ts",
1843
+ "web/types/global.d.ts",
1844
+ ].includes(options.sourceFile)) {
1845
+ const dbPackageName = vikeDbPackageName(options.context);
1846
+ const replacements = {
1847
+ "web/pages/index/+Page.telefunc.ts": `import { createTodo, listTodos } from "${dbPackageName}/queries/todos";`,
1848
+ "web/server/app.ts": `import { createDatabase } from "${dbPackageName}";`,
1849
+ "web/types/global.d.ts": `import type { Database } from "${dbPackageName}";`,
1850
+ };
1851
+ return [
1852
+ copyOperation,
1853
+ {
1854
+ kind: "replaceAnchors",
1855
+ path: to,
1856
+ language: "typescript",
1857
+ replacements: {
1858
+ "db-package-import": replacements[options.sourceFile],
1859
+ },
1860
+ },
1861
+ ];
1862
+ }
1863
+ return [copyOperation];
1864
+ }
1865
+ const vikeDbSourceFiles = [
1866
+ "db/turbo.json",
1867
+ "db/drizzle.config.ts",
1868
+ "db/src/db.ts",
1869
+ "db/src/index.ts",
1870
+ "db/src/queries/todos.ts",
1871
+ "db/src/schema.ts",
1872
+ "db/test/todos.test.ts",
1873
+ ];
1874
+ function vikeDbPackageOperations(context) {
1875
+ const packagePath = vikeDbPackagePath();
1876
+ return [
1877
+ {
1878
+ kind: "writeJson",
1879
+ to: `${packagePath}/package.json`,
1880
+ value: vikeDbPackageJson(context),
1881
+ },
1882
+ {
1883
+ kind: "writeJson",
1884
+ to: `${packagePath}/tsconfig.json`,
1885
+ value: vikeDbTsconfigJson(),
1886
+ },
1887
+ ...vikeDbSourceFiles.map((sourceFile) => ({
1888
+ kind: "copyFile",
1889
+ from: sourceFile,
1890
+ to: `${packagePath}/${sourceFile.replace(/^db\//, "")}`,
1891
+ })),
1892
+ ];
1893
+ }
1894
+ function vikeDbTsconfigJson() {
1895
+ return {
1896
+ compilerOptions: {
1897
+ ...strictTypeScriptCompilerOptions({
1898
+ composite: true,
1899
+ declaration: true,
1900
+ declarationMap: true,
1901
+ module: "esnext",
1902
+ moduleResolution: "bundler",
1903
+ paths: { "#db/*": ["./src/*"] },
1904
+ rootDir: ".",
1905
+ types: ["node"],
1906
+ }),
1907
+ skipLibCheck: true,
1908
+ },
1909
+ include: ["src/**/*.ts", "test/**/*.ts", "drizzle.config.ts"],
1910
+ };
1911
+ }
1912
+ function workspacePackageGlobsForNodeWorkspace(workspace) {
1913
+ return hasVikePackage(workspace)
1914
+ ? [workspace.workspacePackageGlob, "packages/*"]
1915
+ : [workspace.workspacePackageGlob];
1916
+ }
1815
1917
  function gitignoreForNodeWorkspace(workspace) {
1816
1918
  return [
1817
1919
  "node_modules",
@@ -1823,23 +1925,6 @@ function gitignoreForNodeWorkspace(workspace) {
1823
1925
  "",
1824
1926
  ].join("\n");
1825
1927
  }
1826
- function fullStackApiAnchorOperations(context, workspace) {
1827
- if (workspace.packageLinks?.some((link) => link.consumerPackagePath === "apps/web" &&
1828
- link.providerPackagePath === "apps/api") !== true) {
1829
- return [];
1830
- }
1831
- const packageScope = packageScopeFromNodeWorkspace(context);
1832
- return [
1833
- {
1834
- kind: "replaceAnchors",
1835
- path: "apps/web/src/api.ts",
1836
- language: "typescript",
1837
- replacements: {
1838
- "api-type-imports": `import type { AppType } from "@${packageScope}/api";\nimport { hc } from "hono/client";`,
1839
- },
1840
- },
1841
- ];
1842
- }
1843
1928
  function strictTypescriptOperations({ context, state, }) {
1844
1929
  if (state.package === undefined && state.nodeWorkspace === undefined) {
1845
1930
  throw new Error("strict-typescript-root requires a workspace package layout");
@@ -1894,6 +1979,7 @@ function rootTsconfigReferences(workspace) {
1894
1979
  }
1895
1980
  if (nodePackage.kind === "vike-app") {
1896
1981
  return [
1982
+ { path: "./packages/db" },
1897
1983
  { path: `./${nodePackage.path}/tsconfig.app.json` },
1898
1984
  { path: `./${nodePackage.path}/tsconfig.test.json` },
1899
1985
  { path: `./${nodePackage.path}/tsconfig.node.json` },