@ykdz/template 0.0.32 → 0.0.35

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 (40) hide show
  1. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +2 -0
  2. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +40 -14
  3. package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/development-container.d.ts +1 -0
  4. package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/development-container.js +17 -0
  5. package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/vue.js +1 -1
  6. package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.js +9 -10
  7. package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-app/definition.js +6 -1
  8. package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-hono-app/definition.js +6 -1
  9. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment-diagnostics.yml +81 -0
  10. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment.yml +55 -0
  11. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-diagnostics.yml +64 -0
  12. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check.yml +24 -5
  13. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/gitignore +1 -0
  14. package/node_modules/@ykdz/template-builtin-presets/templates/shared/devcontainer/github-cli.Dockerfile +9 -0
  15. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/src/readiness.ts +1 -1
  16. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/test/global-setup.ts +21 -0
  17. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/tsconfig.json +6 -1
  18. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/vitest.config.ts +7 -0
  19. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/drizzle.config.ts +5 -1
  20. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/playwright.config.ts +103 -22
  21. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/test/playwright-teardown.ts +12 -0
  22. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/vite.config.ts +39 -1
  23. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/playwright.config.ts +50 -8
  24. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/playwright.config.ts +61 -8
  25. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.d.ts +19 -0
  26. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.js +68 -0
  27. package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +3 -0
  28. package/node_modules/@ykdz/template-core/dist/package-contribution.js +7 -0
  29. package/node_modules/@ykdz/template-core/dist/project-github.d.ts +50 -6
  30. package/node_modules/@ykdz/template-core/dist/project-github.js +83 -47
  31. package/node_modules/@ykdz/template-core/dist/template-boundary-check.d.ts +15 -1
  32. package/node_modules/@ykdz/template-core/dist/template-boundary-check.js +162 -1
  33. package/package.json +1 -1
  34. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-playwright.yml +0 -20
  35. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-rust.yml +0 -23
  36. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check.dynamic.template +0 -19
  37. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/scripts/prepare-database.ts +0 -45
  38. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/scripts/run-playwright.ts +0 -151
  39. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/scripts/run-playwright.ts +0 -62
  40. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/scripts/run-playwright.ts +0 -103
@@ -1,3 +1,4 @@
1
+ import type { CiDiagnosticArtifactDeclaration } from "#template-core/ci-diagnostic-artifact";
1
2
  import { type DevelopmentContainerToolLayerBuildArgument, type DevelopmentContainerToolLayerMount, type DevelopmentContainerToolLayerProbe, type PlannedDevelopmentContainerToolLayer } from "#template-core/development-container-tool-layer";
2
3
  import type { CheckEnvironmentNeed, DeploymentEnvironmentNeed } from "#template-core/module-graph";
3
4
  import { type PackageContribution } from "#template-core/package-contribution";
@@ -42,6 +43,7 @@ export type GeneratedRepositoryPlan = {
42
43
  };
43
44
  readonly environmentNeeds: readonly CheckEnvironmentNeed[];
44
45
  readonly deploymentEnvironmentNeeds: readonly DeploymentEnvironmentNeed[];
46
+ readonly ciDiagnosticArtifacts: readonly CiDiagnosticArtifactDeclaration[];
45
47
  /** Structured manifests used to derive the generated Dependency Catalog. */
46
48
  readonly manifests: readonly Readonly<Record<string, unknown>>[];
47
49
  readonly dependencyCatalog: Readonly<Record<string, string>>;
@@ -1,16 +1,18 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
+ import { composeCiDiagnosticArtifacts } from "#template-core/ci-diagnostic-artifact";
4
5
  import { collectGeneratedManifestCatalogReferences, selectTemplateDependencyCatalogEntries, } from "#template-core/dependency-catalog";
5
6
  import { planDevelopmentContainerToolLayersSync, } from "#template-core/development-container-tool-layer";
6
7
  import { editorCustomizationForCapabilities, loadEditorCustomizationDeclarations, } from "#template-core/editor-customization";
7
8
  import { checkEnvironmentNeedFact, checkEnvironmentNeedFromFact, deploymentEnvironmentNeedFact, deploymentEnvironmentNeedFromFact, renderDeploymentCheckCommand, renderFixCommand, renderRootCheckCommand, } from "#template-core/module-graph";
8
9
  import { assertPackageContribution, } from "#template-core/package-contribution";
9
10
  import { assertProjectBlueprintV2, validateProjectBlueprintV2 as validateCoreProjectBlueprintV2, } from "#template-core/project-blueprint-v2";
10
- import { projectCheckWorkflowTemplateReplacements, projectDependabotTemplateReplacements, } from "#template-core/project-github";
11
+ import { projectCheckWorkflowTemplateSource, projectCheckWorkflowTemplateReplacements, projectDependabotTemplateReplacements, } from "#template-core/project-github";
11
12
  import { planExplicitProjectLinks } from "#template-core/project-linking-v2";
12
13
  import { resolveTemplateSource, } from "#template-core/renderer";
13
14
  import { rustBinDefinition } from "./rust-bin/definition.js";
15
+ import { githubCliDevelopmentContainerToolLayer } from "./shared/development-container.js";
14
16
  import { typescriptConfigContribution, typescriptConfigPackageDefinition, typescriptConfigPackageName, } from "./shared/typescript.js";
15
17
  import { vuePnpmDependencyOverrides } from "./shared/vue.js";
16
18
  import { templateSources } from "./template-sources.js";
@@ -498,7 +500,7 @@ function contributedDevcontainerComposition(options) {
498
500
  },
499
501
  ],
500
502
  },
501
- layers: options.layers,
503
+ layers: [githubCliDevelopmentContainerToolLayer(), ...options.layers],
502
504
  });
503
505
  return {
504
506
  operations: [
@@ -720,12 +722,22 @@ function foundationPlan(options) {
720
722
  scripts !== null &&
721
723
  typeof scripts.deployment === "string");
722
724
  });
723
- const packagePaths = contributions.map((contribution) => contribution.definition.path);
724
- if (new Set(packagePaths).size !== packagePaths.length)
725
+ const contributionPackagePaths = contributions.map((contribution) => contribution.definition.path);
726
+ if (new Set(contributionPackagePaths).size !== contributionPackagePaths.length)
725
727
  throw new Error("Package Contributions must have unique Package Paths");
728
+ const blueprintPackagePaths = options.blueprint.packages.map((definition) => definition.path);
729
+ if (contributionPackagePaths.length !== blueprintPackagePaths.length ||
730
+ contributionPackagePaths.some((packagePath) => !blueprintPackagePaths.includes(packagePath))) {
731
+ throw new Error("Package Contributions must exactly match Project Blueprint Package Paths");
732
+ }
726
733
  const packageNames = contributions.map((contribution) => contribution.definition.name);
727
734
  if (new Set(packageNames).size !== packageNames.length)
728
735
  throw new Error("Package Contributions must have unique package names");
736
+ const ciDiagnosticArtifactDeclarations = contributions.flatMap((contribution) => contribution.ciDiagnosticArtifacts ?? []);
737
+ const ciDiagnosticArtifacts = composeCiDiagnosticArtifacts({
738
+ packagePaths: blueprintPackagePaths,
739
+ declarations: ciDiagnosticArtifactDeclarations,
740
+ });
729
741
  assertCompatibleRustToolchainFacts(contributions);
730
742
  const contributedToolLayers = contributions.flatMap((contribution) => contribution.foundation.developmentContainerToolLayers ?? []);
731
743
  const developmentContainer = contributedDevcontainerComposition({
@@ -810,16 +822,29 @@ function foundationPlan(options) {
810
822
  ].join("\n"),
811
823
  },
812
824
  };
813
- const workflowOperation = {
814
- kind: "writeTextTemplate",
815
- source: templateSources.foundation,
816
- from: ".github/workflows/check.dynamic.template",
817
- to: ".github/workflows/check.yml",
818
- replacements: projectCheckWorkflowTemplateReplacements({
819
- deploymentEnvironmentNeeds,
820
- hasDeploymentTask,
821
- }),
822
- };
825
+ const workflowTemplateSource = projectCheckWorkflowTemplateSource({
826
+ packagePaths: blueprintPackagePaths,
827
+ deploymentEnvironmentNeeds,
828
+ hasDeploymentTask,
829
+ diagnosticArtifacts: ciDiagnosticArtifacts,
830
+ });
831
+ const workflowOperation = ciDiagnosticArtifacts.length === 0
832
+ ? {
833
+ kind: "copyFile",
834
+ source: templateSources.foundation,
835
+ from: workflowTemplateSource,
836
+ to: ".github/workflows/check.yml",
837
+ }
838
+ : {
839
+ kind: "writeTextTemplate",
840
+ source: templateSources.foundation,
841
+ from: workflowTemplateSource,
842
+ to: ".github/workflows/check.yml",
843
+ replacements: projectCheckWorkflowTemplateReplacements({
844
+ packagePaths: blueprintPackagePaths,
845
+ diagnosticArtifacts: ciDiagnosticArtifacts,
846
+ }),
847
+ };
823
848
  const workflowOperations = [
824
849
  workflowOperation,
825
850
  {
@@ -1021,6 +1046,7 @@ function foundationPlan(options) {
1021
1046
  },
1022
1047
  environmentNeeds,
1023
1048
  deploymentEnvironmentNeeds,
1049
+ ciDiagnosticArtifacts,
1024
1050
  manifests: [...contributions.map((item) => item.manifest), rootManifest],
1025
1051
  dependencyCatalog,
1026
1052
  dependencyMaintenancePolicy,
@@ -1,2 +1,3 @@
1
1
  import type { DevelopmentContainerToolLayer } from "#template-core/development-container-tool-layer";
2
+ export declare function githubCliDevelopmentContainerToolLayer(): DevelopmentContainerToolLayer;
2
3
  export declare function browserTestDevelopmentContainerToolLayer(): DevelopmentContainerToolLayer;
@@ -1,5 +1,22 @@
1
1
  import { loadTemplateDependencyCatalog } from "#template-core/dependency-catalog";
2
2
  import { templateSources } from "../template-sources.js";
3
+ export function githubCliDevelopmentContainerToolLayer() {
4
+ return {
5
+ identity: "github-cli",
6
+ dockerfile: {
7
+ source: templateSources.sharedDevcontainer,
8
+ from: "github-cli.Dockerfile",
9
+ },
10
+ requires: ["node-pnpm"],
11
+ probes: [
12
+ {
13
+ identity: "github-cli",
14
+ command: "gh",
15
+ args: ["--version"],
16
+ },
17
+ ],
18
+ };
19
+ }
3
20
  export function browserTestDevelopmentContainerToolLayer() {
4
21
  const playwrightTestVersion = loadTemplateDependencyCatalog()["@playwright/test"];
5
22
  if (playwrightTestVersion === undefined) {
@@ -32,7 +32,7 @@ export function vueApplicationScripts() {
32
32
  "lint:fix": "oxlint --format=unix --config ../../oxlint.config.ts . --fix",
33
33
  preview: "vite preview",
34
34
  test: "vitest run --reporter=agent --silent=passed-only",
35
- "test:e2e": "node --conditions=source scripts/run-playwright.ts",
35
+ "test:e2e": "playwright test",
36
36
  };
37
37
  }
38
38
  export function sharedVueSourceOperations(context, packagePath) {
@@ -82,19 +82,18 @@ function dockerClientDevelopmentContainerToolLayer() {
82
82
  };
83
83
  }
84
84
  function webScripts() {
85
- const prepareDatabase = "DATABASE_FILE=../../apps/web/data/app.sqlite pnpm --dir ../../packages/db-migrations run db:prepare:dev";
86
85
  return {
87
86
  build: "vike build",
88
87
  deployment: "node --conditions=source scripts/check-standalone-deployment.ts",
89
- dev: `${prepareDatabase} && vike dev`,
88
+ dev: "vike dev",
90
89
  "format:check": "oxfmt --list-different --config ../../oxfmt.config.ts .",
91
90
  "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
92
91
  lint: "shellcheck scripts/container-entrypoint.sh && oxlint --quiet --format=unix --type-aware --config ../../oxlint.config.ts .",
93
92
  "lint:fix": "oxlint --type-aware --format=unix --config ../../oxlint.config.ts . --fix",
94
- preview: `${prepareDatabase} && vike preview`,
93
+ preview: "vike preview",
95
94
  start: "node ./dist/server/index.mjs",
96
95
  test: "vitest run --reporter=agent --silent=passed-only --passWithNoTests",
97
- "test:e2e": "node --conditions=source scripts/run-playwright.ts",
96
+ "test:e2e": "playwright test",
98
97
  typecheck: "node --conditions=source scripts/run-vue-tsc.ts --build --noEmit --pretty false",
99
98
  };
100
99
  }
@@ -106,7 +105,7 @@ function databaseScripts() {
106
105
  "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
107
106
  lint: "oxlint --quiet --format=unix --config ../../oxlint.config.ts .",
108
107
  "lint:fix": "oxlint --format=unix --config ../../oxlint.config.ts . --fix",
109
- test: 'DATABASE_FILE="$(pwd)/node_modules/.tmp/test.sqlite" pnpm --dir ../db-migrations run db:prepare:test && DATABASE_FILE="$(pwd)/node_modules/.tmp/test.sqlite" vitest run --reporter=agent --silent=passed-only; status=$?; rm -f ./node_modules/.tmp/test.sqlite; exit $status',
108
+ test: "vitest run --reporter=agent --silent=passed-only",
110
109
  typecheck: "tsc -p tsconfig.json --noEmit --pretty false",
111
110
  };
112
111
  }
@@ -117,9 +116,7 @@ function migrationScripts(databasePackageName) {
117
116
  "db:generate": withDatabasePackage("drizzle-kit generate"),
118
117
  "db:migrate": withDatabasePackage("drizzle-kit migrate"),
119
118
  "db:prepare:deploy": "pnpm run db:migrate",
120
- "db:prepare:dev": `DATABASE_PACKAGE_NAME=${databasePackageName} node --conditions=source scripts/prepare-database.ts dev`,
121
- "db:prepare:test": `DATABASE_PACKAGE_NAME=${databasePackageName} node --conditions=source scripts/prepare-database.ts test`,
122
- "db:push": withDatabasePackage("mkdir -p data node_modules/.tmp && drizzle-kit push"),
119
+ "db:push": withDatabasePackage("drizzle-kit push"),
123
120
  "db:studio": withDatabasePackage("drizzle-kit studio"),
124
121
  "format:check": "oxfmt --list-different --config ../../oxfmt.config.ts .",
125
122
  "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
@@ -169,8 +166,8 @@ function webContribution(context) {
169
166
  "web/playwright.config.ts",
170
167
  "web/scripts/check-standalone-deployment.ts",
171
168
  "web/scripts/container-entrypoint.sh",
172
- "web/scripts/run-playwright.ts",
173
169
  "web/server/api.ts",
170
+ "web/test/playwright-teardown.ts",
174
171
  "web/test/e2e/app.spec.ts",
175
172
  "web/turbo.json",
176
173
  "web/types/env.d.ts",
@@ -315,6 +312,7 @@ function webContribution(context) {
315
312
  playwrightBrowserAssetsEnvironmentNeed({ browser: "chromium", owner }),
316
313
  shellCheckEnvironmentNeed(owner),
317
314
  ],
315
+ ciDiagnosticArtifacts: [{ kind: "playwright", owner }],
318
316
  deploymentEnvironmentNeeds: [dockerEngineEnvironmentNeed()],
319
317
  foundation: {
320
318
  ...foundation(),
@@ -333,6 +331,8 @@ function databaseContribution(context) {
333
331
  "db/tsconfig.json",
334
332
  "db/tsconfig.build.json",
335
333
  "db/scripts/seed-example.ts",
334
+ "db/vitest.config.ts",
335
+ "db/test/global-setup.ts",
336
336
  "db/src/db.ts",
337
337
  "db/src/index.ts",
338
338
  "db/src/queries/todos.ts",
@@ -395,7 +395,6 @@ function migrationsContribution(context) {
395
395
  "db-migrations/tsconfig.build.json",
396
396
  "db-migrations/drizzle/migrations/20260709120325_old_captain_flint/migration.sql",
397
397
  "db-migrations/drizzle/migrations/20260709120325_old_captain_flint/snapshot.json",
398
- "db-migrations/scripts/prepare-database.ts",
399
398
  "db-migrations/turbo.json",
400
399
  ];
401
400
  return {
@@ -20,7 +20,6 @@ function appContribution(options) {
20
20
  "vite.config.ts",
21
21
  "vitest.config.ts",
22
22
  "turbo.json",
23
- "scripts/run-playwright.ts",
24
23
  "src/App.vue",
25
24
  "test/e2e/app.spec.ts",
26
25
  ];
@@ -44,6 +43,12 @@ function appContribution(options) {
44
43
  }),
45
44
  operations,
46
45
  environmentNeeds: vueApplicationEnvironmentNeeds(definition.path),
46
+ ciDiagnosticArtifacts: [
47
+ {
48
+ kind: "playwright",
49
+ owner: { kind: "package-boundary", path: definition.path },
50
+ },
51
+ ],
47
52
  foundation: {
48
53
  toolchains: {},
49
54
  editorCapabilities: ["oxc-format-lint", "vue", "tailwind", "vitest"],
@@ -115,7 +115,6 @@ function webContribution(context) {
115
115
  "vite.config.ts",
116
116
  "vitest.config.ts",
117
117
  "turbo.json",
118
- "scripts/run-playwright.ts",
119
118
  "src/api.ts",
120
119
  "src/App.vue",
121
120
  "test/e2e/app.spec.ts",
@@ -140,6 +139,12 @@ function webContribution(context) {
140
139
  }),
141
140
  operations,
142
141
  environmentNeeds: vueApplicationEnvironmentNeeds(definition.path),
142
+ ciDiagnosticArtifacts: [
143
+ {
144
+ kind: "playwright",
145
+ owner: { kind: "package-boundary", path: definition.path },
146
+ },
147
+ ],
143
148
  foundation: {
144
149
  ...packageFoundation(),
145
150
  developmentContainerToolLayers: vueApplicationDevelopmentContainerToolLayers(),
@@ -0,0 +1,81 @@
1
+ name: Check
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ check:
18
+ name: ${{ matrix.job_name }}
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: ${{ matrix.timeout_minutes }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ include:
25
+ - capability: root
26
+ job_name: Root Check
27
+ task_entrypoint: pnpm run check
28
+ timeout_minutes: 30
29
+ requires_docker: false
30
+ - capability: deployment
31
+ job_name: Deployment Check
32
+ task_entrypoint: pnpm run check:deployment
33
+ timeout_minutes: 45
34
+ requires_docker: true
35
+ steps:
36
+ - name: Checkout source
37
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
38
+ with:
39
+ persist-credentials: false
40
+ fetch-depth: 1
41
+ - name: Set up Node.js
42
+ uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
43
+ with:
44
+ node-version-file: package.json
45
+ - name: Set up pnpm
46
+ uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
47
+ with:
48
+ cache: true
49
+ - name: Set up Docker Buildx
50
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
51
+ if: matrix.requires_docker
52
+ - name: Install dependencies
53
+ run: pnpm install --frozen-lockfile
54
+ - name: Run selected Check
55
+ run: ${{ matrix.task_entrypoint }}
56
+ - name: Stage Root Check diagnostics
57
+ if: failure() && matrix.capability == 'root'
58
+ env:
59
+ DIAGNOSTIC_OWNER_PATHS: |-
60
+ {{DIAGNOSTIC_OWNER_PATHS}}
61
+ run: |
62
+ rm -rf .template-ci-diagnostics
63
+ mkdir -p .template-ci-diagnostics
64
+ printf '%s\n' "$DIAGNOSTIC_OWNER_PATHS" | while IFS= read -r owner_path; do
65
+ for diagnostic_directory in test-results playwright-report; do
66
+ source_path="$owner_path/$diagnostic_directory"
67
+ destination_path=".template-ci-diagnostics/$owner_path/$diagnostic_directory"
68
+ if [ -d "$source_path" ]; then
69
+ mkdir -p "$(dirname "$destination_path")"
70
+ cp -R "$source_path" "$destination_path"
71
+ fi
72
+ done
73
+ done
74
+ - name: Upload Root Check diagnostics
75
+ if: failure() && matrix.capability == 'root'
76
+ uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
77
+ with:
78
+ name: root-check-diagnostics
79
+ path: .template-ci-diagnostics
80
+ if-no-files-found: ignore
81
+ retention-days: 7
@@ -0,0 +1,55 @@
1
+ name: Check
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ check:
18
+ name: ${{ matrix.job_name }}
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: ${{ matrix.timeout_minutes }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ include:
25
+ - capability: root
26
+ job_name: Root Check
27
+ task_entrypoint: pnpm run check
28
+ timeout_minutes: 30
29
+ requires_docker: false
30
+ - capability: deployment
31
+ job_name: Deployment Check
32
+ task_entrypoint: pnpm run check:deployment
33
+ timeout_minutes: 45
34
+ requires_docker: true
35
+ steps:
36
+ - name: Checkout source
37
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
38
+ with:
39
+ persist-credentials: false
40
+ fetch-depth: 1
41
+ - name: Set up Node.js
42
+ uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
43
+ with:
44
+ node-version-file: package.json
45
+ - name: Set up pnpm
46
+ uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
47
+ with:
48
+ cache: true
49
+ - name: Set up Docker Buildx
50
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
51
+ if: matrix.requires_docker
52
+ - name: Install dependencies
53
+ run: pnpm install --frozen-lockfile
54
+ - name: Run selected Check
55
+ run: ${{ matrix.task_entrypoint }}
@@ -0,0 +1,64 @@
1
+ name: Check
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ check:
18
+ name: Root Check
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 30
21
+ steps:
22
+ - name: Checkout source
23
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
24
+ with:
25
+ persist-credentials: false
26
+ fetch-depth: 1
27
+ - name: Set up Node.js
28
+ uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
29
+ with:
30
+ node-version-file: package.json
31
+ - name: Set up pnpm
32
+ uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
33
+ with:
34
+ cache: true
35
+ - name: Install dependencies
36
+ run: pnpm install --frozen-lockfile
37
+ - name: Run Root Check
38
+ run: pnpm run check
39
+ - name: Stage Root Check diagnostics
40
+ if: failure()
41
+ env:
42
+ DIAGNOSTIC_OWNER_PATHS: |-
43
+ {{DIAGNOSTIC_OWNER_PATHS}}
44
+ run: |
45
+ rm -rf .template-ci-diagnostics
46
+ mkdir -p .template-ci-diagnostics
47
+ printf '%s\n' "$DIAGNOSTIC_OWNER_PATHS" | while IFS= read -r owner_path; do
48
+ for diagnostic_directory in test-results playwright-report; do
49
+ source_path="$owner_path/$diagnostic_directory"
50
+ destination_path=".template-ci-diagnostics/$owner_path/$diagnostic_directory"
51
+ if [ -d "$source_path" ]; then
52
+ mkdir -p "$(dirname "$destination_path")"
53
+ cp -R "$source_path" "$destination_path"
54
+ fi
55
+ done
56
+ done
57
+ - name: Upload Root Check diagnostics
58
+ if: failure()
59
+ uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
60
+ with:
61
+ name: root-check-diagnostics
62
+ path: .template-ci-diagnostics
63
+ if-no-files-found: ignore
64
+ retention-days: 7
@@ -6,14 +6,33 @@ on:
6
6
  branches:
7
7
  - main
8
8
 
9
+ permissions:
10
+ contents: read
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
9
16
  jobs:
10
17
  check:
18
+ name: Root Check
11
19
  runs-on: ubuntu-latest
20
+ timeout-minutes: 30
12
21
  steps:
13
- - uses: actions/checkout@v7
14
- - uses: actions/setup-node@v7
22
+ - name: Checkout source
23
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
24
+ with:
25
+ persist-credentials: false
26
+ fetch-depth: 1
27
+ - name: Set up Node.js
28
+ uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
15
29
  with:
16
30
  node-version-file: package.json
17
- - run: corepack enable
18
- - run: pnpm install
19
- - run: pnpm run check
31
+ - name: Set up pnpm
32
+ uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
33
+ with:
34
+ cache: true
35
+ - name: Install dependencies
36
+ run: pnpm install --frozen-lockfile
37
+ - name: Run Root Check
38
+ run: pnpm run check
@@ -6,5 +6,6 @@ target/
6
6
  coverage/
7
7
  .env
8
8
  .template/
9
+ data/
9
10
  playwright-report/
10
11
  test-results/
@@ -0,0 +1,9 @@
1
+ RUN apt-get update \
2
+ && apt-get install -y --no-install-recommends curl \
3
+ && install -m 0755 -d /etc/apt/keyrings \
4
+ && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \
5
+ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
6
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list \
7
+ && apt-get update \
8
+ && apt-get install -y --no-install-recommends gh \
9
+ && rm -rf /var/lib/apt/lists/*
@@ -13,7 +13,7 @@ export function assertDatabaseReady(db: Database) {
13
13
  throw new Error(
14
14
  [
15
15
  "Database is not ready.",
16
- "For local development, run `pnpm --dir packages/db-migrations run db:prepare:dev`.",
16
+ "For local development, run `pnpm --dir apps/web dev`.",
17
17
  "For deployment, run `pnpm --dir packages/db-migrations run db:prepare:deploy` before starting the app.",
18
18
  ].join(" "),
19
19
  { cause },
@@ -0,0 +1,21 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { rmSync } from "node:fs";
3
+ import path from "node:path";
4
+
5
+ const packageRoot = path.resolve(import.meta.dirname, "..");
6
+ const migrationsRoot = path.resolve(packageRoot, "../db-migrations");
7
+ const databaseFile = path.join(packageRoot, "node_modules/.tmp/test.sqlite");
8
+
9
+ export function setup(): void {
10
+ rmSync(databaseFile, { force: true });
11
+ process.env.DATABASE_FILE = databaseFile;
12
+ execFileSync("pnpm", ["run", "db:push"], {
13
+ cwd: migrationsRoot,
14
+ env: process.env,
15
+ stdio: "inherit",
16
+ });
17
+ }
18
+
19
+ export function teardown(): void {
20
+ rmSync(databaseFile, { force: true });
21
+ }
@@ -13,5 +13,10 @@
13
13
  "target": "es2023",
14
14
  "types": ["node"]
15
15
  },
16
- "include": ["src/**/*.ts", "scripts/**/*.ts", "test/**/*.ts"]
16
+ "include": [
17
+ "src/**/*.ts",
18
+ "scripts/**/*.ts",
19
+ "test/**/*.ts",
20
+ "vitest.config.ts"
21
+ ]
17
22
  }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globalSetup: ["./test/global-setup.ts"],
6
+ },
7
+ });
@@ -1,3 +1,5 @@
1
+ import { mkdirSync } from "node:fs";
2
+ import path from "node:path";
1
3
  import { fileURLToPath } from "node:url";
2
4
 
3
5
  import { defineConfig } from "drizzle-kit";
@@ -6,12 +8,14 @@ const databasePackageName = process.env.DATABASE_PACKAGE_NAME ?? "@database";
6
8
  const schemaFile = fileURLToPath(
7
9
  import.meta.resolve(`${databasePackageName}/schema`),
8
10
  );
11
+ const databaseFile = process.env.DATABASE_FILE ?? "./data/app.sqlite";
12
+ mkdirSync(path.dirname(databaseFile), { recursive: true });
9
13
 
10
14
  export default defineConfig({
11
15
  dialect: "sqlite",
12
16
  schema: schemaFile,
13
17
  out: "./drizzle/migrations",
14
18
  dbCredentials: {
15
- url: process.env.DATABASE_FILE ?? "./data/app.sqlite",
19
+ url: databaseFile,
16
20
  },
17
21
  });