@oyolincc/create 0.0.0-dev-20260922064135 → 0.0.0-dev-20261006065712

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 (126) hide show
  1. package/package.json +1 -1
  2. package/templates/hono-fullstack/.vscode/launch.json +14 -3
  3. package/templates/hono-fullstack/.vscode/settings.json +3 -1
  4. package/templates/hono-fullstack/AGENTS.md +7 -0
  5. package/templates/hono-fullstack/README.md +28 -14
  6. package/templates/hono-fullstack/_gitignore +4 -0
  7. package/templates/hono-fullstack/apps/server/.dev.vars.example +9 -0
  8. package/templates/hono-fullstack/apps/server/package.json +17 -9
  9. package/templates/hono-fullstack/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  10. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +3 -6
  11. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +17 -5
  12. package/templates/hono-fullstack/apps/server/src/app.ts +2 -2
  13. package/templates/hono-fullstack/apps/server/src/config.ts +47 -0
  14. package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +4 -0
  15. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/worker-entry.ts +4 -25
  16. package/templates/hono-fullstack/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  17. package/templates/{hono-server/apps/server/src/infra/work-runner/example → hono-fullstack/apps/server/src/infra/work-runner/piscina}/runner.ts +9 -9
  18. package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +7 -2
  19. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +7 -4
  20. package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +3 -5
  21. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +17 -5
  22. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +38 -15
  23. package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +3 -4
  24. package/templates/hono-fullstack/apps/server/tsconfig.json +1 -0
  25. package/templates/hono-fullstack/apps/server/vite.config.ts +8 -3
  26. package/templates/hono-fullstack/apps/server/wrangler.jsonc +29 -0
  27. package/templates/hono-fullstack/apps/stack/backend/cloudflare.ts +5 -0
  28. package/templates/hono-fullstack/apps/stack/backend/node.ts +3 -0
  29. package/templates/hono-fullstack/apps/stack/frontend/components/general/ErrorMessage.tsx +4 -0
  30. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/AppLayout.tsx +11 -0
  31. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Header.tsx +7 -0
  32. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Page.tsx +5 -0
  33. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/PageContainer.tsx +5 -0
  34. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx +45 -0
  35. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx +13 -0
  36. package/templates/hono-fullstack/apps/stack/frontend/routeTree.gen.ts +21 -4
  37. package/templates/hono-fullstack/apps/stack/frontend/routes/api/$.ts +18 -0
  38. package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +48 -2
  39. package/templates/hono-fullstack/apps/stack/frontend/vite-env.d.ts +5 -0
  40. package/templates/hono-fullstack/apps/stack/package.json +20 -5
  41. package/templates/hono-fullstack/apps/stack/tsconfig.json +2 -1
  42. package/templates/hono-fullstack/apps/stack/vite.config.ts +75 -26
  43. package/templates/hono-fullstack/apps/stack/wrangler.jsonc +20 -0
  44. package/templates/hono-fullstack/envs/.env.example.server +1 -1
  45. package/templates/hono-fullstack/envs/.env.example.sqlite-d1 +3 -0
  46. package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  47. package/templates/hono-fullstack/libs/db/package.json +8 -6
  48. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  49. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +5 -0
  50. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +2 -2
  51. package/templates/hono-fullstack/libs/db/vite.config.ts +1 -0
  52. package/templates/hono-fullstack/libs/definition/src/configs/defs/runtime.ts +1 -0
  53. package/templates/hono-fullstack/libs/definition/src/configs/defs/sqlite.ts +16 -3
  54. package/templates/hono-fullstack/oyo.config.json +2 -1
  55. package/templates/hono-fullstack/package.json +1 -1
  56. package/templates/hono-fullstack/pnpm-workspace.yaml +7 -5
  57. package/templates/hono-fullstack/turbo.json +25 -3
  58. package/templates/hono-fullstack/vite.config.ts +1 -0
  59. package/templates/hono-server/.vscode/launch.json +7 -3
  60. package/templates/hono-server/.vscode/settings.json +3 -1
  61. package/templates/hono-server/AGENTS.md +7 -0
  62. package/templates/hono-server/README.md +25 -12
  63. package/templates/hono-server/_gitignore +4 -0
  64. package/templates/hono-server/apps/server/.dev.vars.example +9 -0
  65. package/templates/hono-server/apps/server/package.json +18 -8
  66. package/templates/hono-server/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  67. package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +3 -3
  68. package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +24 -4
  69. package/templates/hono-server/apps/server/src/app.ts +2 -2
  70. package/templates/hono-server/apps/server/src/config.ts +47 -0
  71. package/templates/hono-server/apps/server/src/infra/logger/pino.ts +4 -0
  72. package/templates/hono-server/apps/server/src/infra/work-runner/example/worker-entry.ts +4 -25
  73. package/templates/hono-server/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  74. package/templates/{hono-fullstack/apps/server/src/infra/work-runner/example → hono-server/apps/server/src/infra/work-runner/piscina}/runner.ts +9 -9
  75. package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +7 -2
  76. package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +7 -4
  77. package/templates/hono-server/apps/server/src/modules/example/contracts.ts +4 -0
  78. package/templates/hono-server/apps/server/src/modules/example/routes.ts +32 -5
  79. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +17 -5
  80. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +38 -15
  81. package/templates/hono-server/apps/server/src/shared/app/types.ts +3 -4
  82. package/templates/hono-server/apps/server/tsconfig.json +1 -0
  83. package/templates/hono-server/apps/server/vite.config.ts +8 -3
  84. package/templates/hono-server/apps/server/wrangler.jsonc +29 -0
  85. package/templates/hono-server/docker/server.Dockerfile +3 -5
  86. package/templates/hono-server/envs/.env.example.server +1 -1
  87. package/templates/hono-server/envs/.env.example.sqlite +1 -0
  88. package/templates/hono-server/envs/.env.example.sqlite-d1 +3 -0
  89. package/templates/hono-server/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  90. package/templates/hono-server/libs/db/drizzle-kit/sqlite.config.ts +22 -0
  91. package/templates/hono-server/libs/db/package.json +42 -0
  92. package/templates/hono-server/libs/db/src/dialects/sqlite/client.ts +35 -0
  93. package/templates/hono-server/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  94. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/columns.ts +37 -0
  95. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
  96. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
  97. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
  98. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
  99. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
  100. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
  101. package/templates/hono-server/libs/db/src/dialects/sqlite/utils.ts +8 -0
  102. package/templates/hono-server/libs/db/src/shared/types.ts +26 -0
  103. package/templates/hono-server/libs/db/tsconfig.json +10 -0
  104. package/templates/hono-server/libs/db/vite.config.ts +22 -0
  105. package/templates/hono-server/libs/definition/src/configs/defs/runtime.ts +1 -0
  106. package/templates/hono-server/libs/definition/src/configs/defs/sqlite.ts +26 -0
  107. package/templates/hono-server/libs/definition/src/configs/index.ts +1 -0
  108. package/templates/hono-server/oyo.config.json +3 -1
  109. package/templates/hono-server/package.json +2 -3
  110. package/templates/hono-server/pnpm-workspace.yaml +12 -3
  111. package/templates/hono-server/turbo.json +25 -3
  112. package/templates/hono-server/vite.config.ts +1 -0
  113. package/templates/monorepo/.vscode/launch.json +0 -3
  114. package/templates/monorepo/.vscode/settings.json +3 -1
  115. package/templates/monorepo/AGENTS.md +7 -0
  116. package/templates/monorepo/_gitignore +4 -0
  117. package/templates/monorepo/pnpm-workspace.yaml +6 -3
  118. package/templates/monorepo/turbo.json +25 -3
  119. package/templates/monorepo/vite.config.ts +1 -0
  120. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/config.ts +0 -53
  121. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.test.ts +0 -56
  122. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExamplePage.tsx +0 -59
  123. package/templates/hono-fullstack/apps/stack/nitro/handlers/hono.ts +0 -1
  124. package/templates/hono-fullstack/apps/stack/nitro/plugins/hono.ts +0 -9
  125. package/templates/hono-server/apps/server/src/adapters/nodejs/config.ts +0 -53
  126. package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.test.ts +0 -56
@@ -0,0 +1,22 @@
1
+ import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
2
+ import { autoIncrementId, modifiedTimeCols } from '../../columns'
3
+ import type { SelectVOResults } from '@/shared/types'
4
+ import { defineVO } from '@/shared/types'
5
+
6
+ export const examples = sqliteTable('examples', {
7
+ id: autoIncrementId('id'),
8
+ message: text('message').notNull(),
9
+ ...modifiedTimeCols(),
10
+ })
11
+
12
+ export type InsertExample = typeof examples.$inferInsert
13
+
14
+ export const voExamples = defineVO({
15
+ id: examples.id,
16
+ message: examples.message,
17
+ createdAt: examples.createdAt,
18
+ updatedAt: examples.updatedAt,
19
+ })
20
+ export type IExamplesVO = SelectVOResults<typeof voExamples>
21
+
22
+ export const vcExamples = { default: voExamples } as const
@@ -0,0 +1,5 @@
1
+ import { defineRelations } from 'drizzle-orm'
2
+ import { sqliteTableDefs } from './tables'
3
+
4
+ /** The example table has no relationships; keep the relations entrypoint for future modules. */
5
+ export const relations = defineRelations(sqliteTableDefs)
@@ -0,0 +1,5 @@
1
+ export { examples, type InsertExample } from './modules/examples/examples'
2
+
3
+ import { examples } from './modules/examples/examples'
4
+
5
+ export const sqliteTableDefs = { examples } as const
@@ -0,0 +1,7 @@
1
+ import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'
2
+ import type { AnySQLiteColumn, AnySQLiteTable } from 'drizzle-orm/sqlite-core'
3
+ import type { relations } from './relations'
4
+
5
+ export type SqliteDBType = BetterSQLite3Database<typeof relations>
6
+ export type SqliteTableType = AnySQLiteTable
7
+ export type SqliteColType = AnySQLiteColumn
@@ -0,0 +1 @@
1
+ export { vcExamples, voExamples, type IExamplesVO } from './modules/examples/examples'
@@ -0,0 +1,8 @@
1
+ import { mkdirSync } from 'node:fs'
2
+ import { dirname } from 'node:path'
3
+
4
+ export function ensureDatabaseDirectory(databaseFile: string): void {
5
+ if (!databaseFile || databaseFile === ':memory:') return
6
+
7
+ mkdirSync(dirname(databaseFile), { recursive: true })
8
+ }
@@ -0,0 +1,26 @@
1
+ import type { AnyColumn, GetColumnData, InferModelFromColumns, Table } from 'drizzle-orm'
2
+
3
+ export type AnyTableType = Table
4
+ export type AnyColType = AnyColumn
5
+
6
+ export type TableColsMap<T extends AnyTableType> = T['_']['columns']
7
+ export type TableField<T extends AnyTableType> = keyof TableColsMap<T> & string
8
+ export type TableFieldValue<T extends AnyTableType, K extends TableField<T>> = GetColumnData<
9
+ TableColsMap<T>[K],
10
+ 'query'
11
+ >
12
+
13
+ export type VO<TColumn extends AnyColType = AnyColType> = Record<string, TColumn>
14
+ export type InsertModel<T extends AnyTableType> = InferModelFromColumns<TableColsMap<T>, 'insert'>
15
+
16
+ export function defineVO<T extends VO>(vo: T): T {
17
+ return vo
18
+ }
19
+
20
+ export type SelectVOResults<V extends VO> = {
21
+ [K in keyof V]: GetColumnData<V[K], 'query'>
22
+ }
23
+
24
+ export type VOColsOption<V extends VO> = {
25
+ [K in keyof V]: true
26
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@oyolincc/dev-config/tsconfig.bundler.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@/*": ["./src/*"]
6
+ }
7
+ },
8
+ "files": [],
9
+ "include": ["src", "drizzle-kit", "./*.ts", "./*.mts"]
10
+ }
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from 'vite-plus'
2
+ import { packConfig } from '@oyolincc/dev-config'
3
+ import path from 'node:path'
4
+
5
+ const __dirname = import.meta.dirname
6
+
7
+ export default defineConfig({
8
+ pack: {
9
+ ...packConfig,
10
+ entry: {
11
+ 'sqlite/schema': 'src/dialects/sqlite/schema/index.ts',
12
+ 'sqlite/sqlite': 'src/dialects/sqlite/client.ts',
13
+ 'sqlite/d1-client': 'src/dialects/sqlite/d1-client.ts',
14
+ },
15
+ exports: true,
16
+ },
17
+ resolve: {
18
+ alias: {
19
+ '@': path.resolve(__dirname, './src'),
20
+ },
21
+ },
22
+ })
@@ -2,6 +2,7 @@ import * as v from 'valibot'
2
2
  import { defineSchemaConfig } from '../proto'
3
3
 
4
4
  export const $S_RuntimeConfig = v.object({
5
+ serverBasePath: v.optional(v.string(), '/'),
5
6
  serverEnv: v.optional(
6
7
  v.union([v.literal('local'), v.literal('test'), v.literal('staging'), v.literal('main')]),
7
8
  'local',
@@ -0,0 +1,26 @@
1
+ import path from 'node:path'
2
+ import * as v from 'valibot'
3
+ import { defineSchemaConfig } from '../proto'
4
+ import { $S_NonEmptyString } from '../schema'
5
+
6
+ function defaultSqliteDbPath(): string {
7
+ const workspaceRoot = path.join(import.meta.dirname, '../../..')
8
+ return path.join(workspaceRoot, 'db-data', 'repo.sqlite')
9
+ }
10
+
11
+ export const $S_SqliteSchemaConfig = v.object({
12
+ dbPath: v.pipe(
13
+ v.optional($S_NonEmptyString),
14
+ v.transform((dbPath) => dbPath || defaultSqliteDbPath()),
15
+ ) as v.GenericSchema<string | undefined, string>,
16
+ })
17
+ export type SqliteSchemaConfig = v.InferOutput<typeof $S_SqliteSchemaConfig>
18
+ export const sqliteSchemaConfig = defineSchemaConfig($S_SqliteSchemaConfig)
19
+
20
+ export const $S_D1SchemaConfig = v.object({
21
+ cloudflareAccountId: $S_NonEmptyString,
22
+ cloudflareDatabaseId: $S_NonEmptyString,
23
+ cloudflareToken: $S_NonEmptyString,
24
+ })
25
+ export type D1SchemaConfig = v.InferOutput<typeof $S_D1SchemaConfig>
26
+ export const d1SchemaConfig = defineSchemaConfig($S_D1SchemaConfig)
@@ -2,3 +2,4 @@ export * from './defs/runtime'
2
2
  export * from './defs/log'
3
3
  export * from './defs/middleware'
4
4
  export * from './defs/worker'
5
+ export * from './defs/sqlite'
@@ -2,7 +2,9 @@
2
2
  "env": {
3
3
  "dir": "./envs/",
4
4
  "presets": {
5
- "server": [".env.server"]
5
+ "server": [".env.server", ".env.sqlite"],
6
+ "sqlite": [".env.sqlite"],
7
+ "sqlite-d1": [".env.sqlite-d1"]
6
8
  }
7
9
  },
8
10
  "codeGenerator": {
@@ -5,8 +5,8 @@
5
5
  "scripts": {
6
6
  "prepare": "vp config",
7
7
  "changeset": "vp exec changeset",
8
- "dev": "turbo build --filter=@repo/definition && concurrently -k -n definition,server -c blue,green \"pnpm --filter @repo/definition dev\" \"pnpm --filter @repo/server dev\"",
9
- "build": "turbo build"
8
+ "build": "turbo build",
9
+ "build:libs": "turbo build --filter=!@repo/stack --filter=!@repo/server"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@changesets/changelog-github": "catalog:",
@@ -14,7 +14,6 @@
14
14
  "@oyolincc/cli": "catalog:",
15
15
  "@oyolincc/dev-config": "catalog:",
16
16
  "@types/node": "catalog:",
17
- "concurrently": "catalog:",
18
17
  "tsx": "catalog:",
19
18
  "turbo": "catalog:",
20
19
  "vite-plus": "catalog:"
@@ -8,6 +8,7 @@ catalogPrune: true
8
8
  catalog:
9
9
  '@changesets/changelog-github': '0.5.0'
10
10
  '@changesets/cli': '2.27.12'
11
+ '@cloudflare/vite-plugin': '1.62.5'
11
12
  '@oyolincc/cli': '2.1.3'
12
13
  '@oyolincc/dev-config': '0.1.1'
13
14
  '@oyolincc/env-loader': '^0.2.0'
@@ -17,8 +18,9 @@ catalog:
17
18
  'tsx': '4.21.0'
18
19
  'turbo': '^2.9.14'
19
20
  'typescript': '7.0.2'
20
- 'vite': 'npm:@voidzero-dev/vite-plus-core@0.2.8'
21
- 'vite-plus': '0.2.8'
21
+ 'vite': 'npm:@voidzero-dev/vite-plus-core@0.3.1'
22
+ 'vite-plus': '0.3.1'
23
+ 'wrangler': '4.147.0'
22
24
 
23
25
  catalogs:
24
26
  shared:
@@ -43,9 +45,14 @@ catalogs:
43
45
  'pino-pretty': '^13.1.3'
44
46
  'pino-roll': '^4.0.0'
45
47
  'piscina': '^5.3.0'
48
+ db:
49
+ '@types/better-sqlite3': '^7.6.13'
50
+ 'better-sqlite3': '^12.11.1'
51
+ 'drizzle-kit': '1.0.0-rc.4'
52
+ 'drizzle-orm': '1.0.0-rc.4'
46
53
 
47
54
  overrides:
48
- 'vite': 'catalog:'
55
+ 'vite@*': 'catalog:'
49
56
 
50
57
  peerDependencyRules:
51
58
  allowAny:
@@ -54,4 +61,6 @@ peerDependencyRules:
54
61
  'vite': '*'
55
62
 
56
63
  allowBuilds:
64
+ 'better-sqlite3': true
57
65
  'esbuild': true
66
+ 'workerd': true
@@ -1,14 +1,36 @@
1
1
  {
2
2
  "$schema": "https://turbo.build/schema.json",
3
3
  "tasks": {
4
- "build": {
4
+ "dev": {
5
5
  "dependsOn": ["^build"],
6
- "outputs": ["dist/**", ".output/**"]
6
+ "cache": false,
7
+ "persistent": true
7
8
  },
8
- "dev": {
9
+ "dev:node": {
10
+ "dependsOn": ["^build"],
11
+ "env": ["DEPLOY_TARGET"],
12
+ "cache": false,
13
+ "persistent": true
14
+ },
15
+ "dev:cloudflare": {
9
16
  "dependsOn": ["^build"],
17
+ "env": ["DEPLOY_TARGET"],
10
18
  "cache": false,
11
19
  "persistent": true
20
+ },
21
+ "build": {
22
+ "dependsOn": ["^build"],
23
+ "outputs": ["dist/**", ".output/**"]
24
+ },
25
+ "build:node": {
26
+ "dependsOn": ["^build"],
27
+ "env": ["DEPLOY_TARGET"],
28
+ "outputs": ["dist/**", ".output/**"]
29
+ },
30
+ "build:cloudflare": {
31
+ "dependsOn": ["^build"],
32
+ "env": ["DEPLOY_TARGET"],
33
+ "outputs": ["dist/**", ".output/**"]
12
34
  }
13
35
  }
14
36
  }
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite-plus'
2
2
  import { lintConfig, fmtConfig } from '@oyolincc/dev-config'
3
3
 
4
4
  export default defineConfig({
5
+ create: { defaultTemplate: '@oyolincc' },
5
6
  staged: {
6
7
  '*': 'vp check --fix',
7
8
  },
@@ -18,8 +18,5 @@
18
18
  "type": "node"
19
19
  }
20
20
  ],
21
- // Use IntelliSense to learn about possible attributes.
22
- // Hover to view descriptions of existing attributes.
23
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
24
21
  "version": "0.2.0"
25
22
  }
@@ -20,5 +20,7 @@
20
20
  "editor.codeActionsOnSave": {
21
21
  "source.fixAll.oxc": "explicit"
22
22
  },
23
- "oxc.enable.oxlint": false
23
+ "oxc.enable.oxlint": false,
24
+ "oxc.disableNestedConfig": true,
25
+ "oxc.fmt.disableNestedConfig": true
24
26
  }
@@ -10,6 +10,13 @@ Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.de
10
10
 
11
11
  `vp <name>` runs a built-in command. `vp run <name>` runs a `package.json` script or a `vite.config.ts` task. Scripts cannot overwrite built-ins, so `vp dev` and `vp run dev` may do different things. Check `package.json` and `vite.config.ts` first, and run `vp run <name>` when the project defines a script or task with that name.
12
12
 
13
+ ## Tool Versions
14
+
15
+ Run `vp toolchain` to show versions and relationships in the active Vite+
16
+ release. Add a tool name to select part of the graph. For example, run
17
+ `vp toolchain vite`. Use `--global` to ignore the local `vite-plus` package. Use
18
+ `vp why <package>` to show the package-manager dependency graph.
19
+
13
20
  ## Review Checklist
14
21
 
15
22
  - [ ] Run `vp install` after pulling remote changes and before getting started.
@@ -10,6 +10,7 @@ lerna-debug.log*
10
10
  node_modules
11
11
  dist
12
12
  dist-ssr
13
+ .output
13
14
  *.local
14
15
 
15
16
  # Editor directories and files
@@ -28,3 +29,6 @@ dist-ssr
28
29
  .worktrees/
29
30
  **/temp/
30
31
  .turbo
32
+ .wrangler
33
+ .dev.vars
34
+ db-data
@@ -7,6 +7,7 @@ catalogPrune: true
7
7
  catalog:
8
8
  '@changesets/changelog-github': '0.5.0'
9
9
  '@changesets/cli': '2.27.12'
10
+ '@cloudflare/vite-plugin': '1.62.5'
10
11
  '@oyolincc/cli': '2.1.3'
11
12
  '@oyolincc/dev-config': '0.1.1'
12
13
  '@oyolincc/env-loader': '^0.2.0'
@@ -16,11 +17,12 @@ catalog:
16
17
  'tsx': '4.21.0'
17
18
  'turbo': '^2.9.14'
18
19
  'typescript': '7.0.2'
19
- 'vite': 'npm:@voidzero-dev/vite-plus-core@0.2.8'
20
- 'vite-plus': '0.2.8'
20
+ 'vite': 'npm:@voidzero-dev/vite-plus-core@0.3.1'
21
+ 'vite-plus': '0.3.1'
22
+ 'wrangler': '4.147.0'
21
23
 
22
24
  overrides:
23
- 'vite': 'catalog:'
25
+ 'vite@*': 'catalog:'
24
26
 
25
27
  peerDependencyRules:
26
28
  allowAny:
@@ -30,3 +32,4 @@ peerDependencyRules:
30
32
 
31
33
  allowBuilds:
32
34
  'esbuild': true
35
+ 'workerd': true
@@ -1,14 +1,36 @@
1
1
  {
2
2
  "$schema": "https://turbo.build/schema.json",
3
3
  "tasks": {
4
- "build": {
4
+ "dev": {
5
5
  "dependsOn": ["^build"],
6
- "outputs": ["dist/**", ".output/**"]
6
+ "cache": false,
7
+ "persistent": true
7
8
  },
8
- "dev": {
9
+ "dev:node": {
10
+ "dependsOn": ["^build"],
11
+ "env": ["DEPLOY_TARGET"],
12
+ "cache": false,
13
+ "persistent": true
14
+ },
15
+ "dev:cloudflare": {
9
16
  "dependsOn": ["^build"],
17
+ "env": ["DEPLOY_TARGET"],
10
18
  "cache": false,
11
19
  "persistent": true
20
+ },
21
+ "build": {
22
+ "dependsOn": ["^build"],
23
+ "outputs": ["dist/**", ".output/**"]
24
+ },
25
+ "build:node": {
26
+ "dependsOn": ["^build"],
27
+ "env": ["DEPLOY_TARGET"],
28
+ "outputs": ["dist/**", ".output/**"]
29
+ },
30
+ "build:cloudflare": {
31
+ "dependsOn": ["^build"],
32
+ "env": ["DEPLOY_TARGET"],
33
+ "outputs": ["dist/**", ".output/**"]
12
34
  }
13
35
  }
14
36
  }
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite-plus'
2
2
  import { lintConfig, fmtConfig } from '@oyolincc/dev-config'
3
3
 
4
4
  export default defineConfig({
5
+ create: { defaultTemplate: '@oyolincc' },
5
6
  staged: {
6
7
  '*': 'vp check --fix',
7
8
  },
@@ -1,53 +0,0 @@
1
- import type { AppConfig } from '@/shared/app/types'
2
- import {
3
- corsConfig,
4
- logBaseConfig,
5
- logPrettyRawConfig,
6
- logRollRawConfig,
7
- logRollSchemaConfig,
8
- runtimeConfig,
9
- workerConfig,
10
- type WorkerConfig,
11
- } from '@repo/definition/backend'
12
- import { flatten as flattenValiIssues, isValiError } from 'valibot'
13
-
14
- export function resolveConfig(context: Record<string, unknown>): AppConfig {
15
- try {
16
- const fromEnv = { context, matchContextKey: 'constantCase' as const }
17
- const runtime = runtimeConfig.resolve(fromEnv)
18
- const logBaseParsed = logBaseConfig.resolve(fromEnv)
19
- const logRollSchemaParsed = logRollSchemaConfig.resolve(fromEnv)
20
- const worker = workerConfig.resolve(fromEnv)
21
- const cors = corsConfig.resolve({
22
- context: { domains: context.CORS_DOMAINS },
23
- matchContextKey: 'camel',
24
- })
25
-
26
- return {
27
- runtime: { ...runtime, isLocal: runtime.serverEnv === 'local' },
28
- log: {
29
- base: logBaseParsed,
30
- roll: { ...logRollSchemaParsed, ...logRollRawConfig.resolve() },
31
- pretty: logPrettyRawConfig.resolve(),
32
- },
33
- middleware: { cors },
34
- worker,
35
- }
36
- } catch (error) {
37
- if (isValiError(error)) {
38
- throw new Error(`[resolveAppConfig] ${JSON.stringify(flattenValiIssues(error.issues))}`)
39
- }
40
- throw error
41
- }
42
- }
43
-
44
- export function resolveWorkerConfig(context: Record<string, unknown>): WorkerConfig {
45
- try {
46
- return workerConfig.resolve({ context, matchContextKey: 'constantCase' })
47
- } catch (error) {
48
- if (isValiError(error)) {
49
- throw new Error(`[resolveWorkerConfig] ${JSON.stringify(flattenValiIssues(error.issues))}`)
50
- }
51
- throw error
52
- }
53
- }
@@ -1,56 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
2
- import { WorkerErrorCode, WorkSubject } from '../constants'
3
- import { ExampleWorkRunner } from './runner'
4
-
5
- vi.mock('@/infra/logger/getter', () => ({
6
- getLogger: () =>
7
- new Proxy({ assign() {} }, { get: (target, key) => Reflect.get(target, key) || (() => {}) }),
8
- }))
9
- vi.mock('virtual:workers', () => ({ default: '/tmp' }))
10
- vi.mock('piscina', () => ({
11
- default: class PiscinaMock {
12
- idleThreads = 1
13
- threads: unknown[] = []
14
- queueSize = 0
15
- options = { maxQueue: 1 }
16
-
17
- run() {
18
- throw new Error('An aborted task must not reach the worker pool')
19
- }
20
-
21
- async close() {}
22
- },
23
- }))
24
-
25
- const config = {
26
- minThreads: 1,
27
- maxThreads: 1,
28
- concurrentTasksPerWorker: 1,
29
- maxQueue: 1,
30
- workerTaskTimeoutMs: 1_000,
31
- }
32
-
33
- describe('ExampleWorkRunner cancellation', () => {
34
- let runner: ExampleWorkRunner | undefined
35
-
36
- afterEach(async () => {
37
- await runner?.shutdown()
38
- runner = undefined
39
- })
40
-
41
- it('returns the task-aborted error model for an aborted signal', async () => {
42
- runner = ExampleWorkRunner.getInstance(config)
43
- const controller = new AbortController()
44
- controller.abort()
45
-
46
- await expect(
47
- runner.run(
48
- { subject: WorkSubject.PROCESS_EXAMPLE, input: { message: 'hello' } },
49
- { signal: controller.signal },
50
- ),
51
- ).resolves.toMatchObject({
52
- ok: false,
53
- error: { code: WorkerErrorCode.TASK_ABORTED },
54
- })
55
- })
56
- })
@@ -1,59 +0,0 @@
1
- import { useAtom } from 'jotai'
2
- import type { FormEvent } from 'react'
3
- import { useCreateExample, useExamples, useProcessExample } from '../hooks/api-hooks'
4
- import { exampleMessageAtom } from '../stores'
5
-
6
- export function ExamplePage() {
7
- const [message, setMessage] = useAtom(exampleMessageAtom)
8
- const examples = useExamples()
9
- const create = useCreateExample()
10
- const process = useProcessExample()
11
-
12
- const submit = async (event: FormEvent) => {
13
- event.preventDefault()
14
- await create.mutateAsync({ message })
15
- setMessage('')
16
- }
17
-
18
- return (
19
- <main className="mx-auto flex min-h-screen max-w-2xl flex-col gap-6 p-8">
20
- <header>
21
- <h1 className="text-3xl font-bold">Example workspace</h1>
22
- <p className="text-zinc-400">Nitro mounts the independent Hono server under /api.</p>
23
- </header>
24
- <form className="flex gap-2" onSubmit={submit}>
25
- <input
26
- className="min-w-0 flex-1 rounded border border-zinc-700 bg-zinc-900 px-3 py-2"
27
- value={message}
28
- onChange={(event) => setMessage(event.target.value)}
29
- placeholder="Message"
30
- />
31
- <button
32
- className="rounded bg-blue-600 px-4 py-2"
33
- disabled={!message.trim() || create.isPending}>
34
- Save
35
- </button>
36
- <button
37
- className="rounded bg-emerald-600 px-4 py-2"
38
- type="button"
39
- disabled={!message.trim() || process.isPending}
40
- onClick={() => process.mutate({ message })}>
41
- Process
42
- </button>
43
- </form>
44
- {process.data && (
45
- <pre className="rounded bg-zinc-900 p-4">{JSON.stringify(process.data, null, 2)}</pre>
46
- )}
47
- {(create.error || process.error || examples.error) && (
48
- <p className="text-red-400">{String(create.error || process.error || examples.error)}</p>
49
- )}
50
- <ul className="grid gap-2">
51
- {examples.data?.map((example) => (
52
- <li className="rounded border border-zinc-800 p-3" key={example.id}>
53
- {example.message}
54
- </li>
55
- ))}
56
- </ul>
57
- </main>
58
- )
59
- }
@@ -1 +0,0 @@
1
- export { default } from '@repo/server/node'
@@ -1,9 +0,0 @@
1
- import { definePlugin } from 'nitro'
2
- import { exampleWorkRunner, sqliteClient } from '@repo/server/node'
3
-
4
- export default definePlugin((nitro) => {
5
- nitro.hooks.hook('close', async () => {
6
- await exampleWorkRunner.shutdown()
7
- sqliteClient.close()
8
- })
9
- })
@@ -1,53 +0,0 @@
1
- import type { AppConfig } from '@/shared/app/types'
2
- import {
3
- corsConfig,
4
- logBaseConfig,
5
- logPrettyRawConfig,
6
- logRollRawConfig,
7
- logRollSchemaConfig,
8
- runtimeConfig,
9
- workerConfig,
10
- type WorkerConfig,
11
- } from '@repo/definition/backend'
12
- import { flatten as flattenValiIssues, isValiError } from 'valibot'
13
-
14
- export function resolveConfig(context: Record<string, unknown>): AppConfig {
15
- try {
16
- const fromEnv = { context, matchContextKey: 'constantCase' as const }
17
- const runtime = runtimeConfig.resolve(fromEnv)
18
- const logBaseParsed = logBaseConfig.resolve(fromEnv)
19
- const logRollSchemaParsed = logRollSchemaConfig.resolve(fromEnv)
20
- const worker = workerConfig.resolve(fromEnv)
21
- const cors = corsConfig.resolve({
22
- context: { domains: context.CORS_DOMAINS },
23
- matchContextKey: 'camel',
24
- })
25
-
26
- return {
27
- runtime: { ...runtime, isLocal: runtime.serverEnv === 'local' },
28
- log: {
29
- base: logBaseParsed,
30
- roll: { ...logRollSchemaParsed, ...logRollRawConfig.resolve() },
31
- pretty: logPrettyRawConfig.resolve(),
32
- },
33
- middleware: { cors },
34
- worker,
35
- }
36
- } catch (error) {
37
- if (isValiError(error)) {
38
- throw new Error(`[resolveAppConfig] ${JSON.stringify(flattenValiIssues(error.issues))}`)
39
- }
40
- throw error
41
- }
42
- }
43
-
44
- export function resolveWorkerConfig(context: Record<string, unknown>): WorkerConfig {
45
- try {
46
- return workerConfig.resolve({ context, matchContextKey: 'constantCase' })
47
- } catch (error) {
48
- if (isValiError(error)) {
49
- throw new Error(`[resolveWorkerConfig] ${JSON.stringify(flattenValiIssues(error.issues))}`)
50
- }
51
- throw error
52
- }
53
- }