@batijs/cli 0.0.649 → 0.0.651
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boilerplates/@batijs/auth0/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/authjs/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/authjs/files/server/authjs-handler.ts +1 -1
- package/dist/boilerplates/@batijs/aws/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/aws/files/cdk/bin/infrastructure.ts +1 -1
- package/dist/boilerplates/@batijs/better-auth/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/better-auth/files/database/better-auth/migrate.ts +1 -3
- package/dist/boilerplates/@batijs/better-auth/files/database/drizzle/schema/auth.ts +5 -5
- package/dist/boilerplates/@batijs/better-auth/files/server/better-auth-handler.ts +2 -2
- package/dist/boilerplates/@batijs/better-auth/files/server/better-auth.ts +8 -8
- package/dist/boilerplates/@batijs/biome/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/cloudflare/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/cloudflare/files/$vite.config.ts.js +9 -9
- package/dist/boilerplates/@batijs/compiled/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/compiled/files/$vite.config.ts.js +9 -9
- package/dist/boilerplates/@batijs/d1/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/d1-kysely/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/d1-sqlite/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/docker-compose/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/docker-compose/files/$Dockerfile.js +5 -44
- package/dist/boilerplates/@batijs/docker-compose/files/docker-compose.yml +6 -6
- package/dist/boilerplates/@batijs/dokploy/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/drizzle/bati.config.mjs +6 -1
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/db.ts +3 -3
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/queries/todos.ts +10 -10
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/schema/todos.ts +2 -2
- package/dist/boilerplates/@batijs/drizzle/files/drizzle.config.ts +3 -3
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/queries/todos.d.mts +6 -6
- package/dist/boilerplates/@batijs/edgeone/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/edgeone/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/elysia/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/elysia/files/+server.ts +1 -1
- package/dist/boilerplates/@batijs/elysia/files/server/elysia.ts +9 -9
- package/dist/boilerplates/@batijs/eslint/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/eslint/files/eslint.config.ts +14 -14
- package/dist/boilerplates/@batijs/express/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/express/files/+server.ts +10 -10
- package/dist/boilerplates/@batijs/fastify/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/fastify/files/+server.ts +10 -10
- package/dist/boilerplates/@batijs/google-analytics/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/hono/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/hono/files/+server.ts +2 -2
- package/dist/boilerplates/@batijs/hono/files/entry_aws_lambda.ts +1 -3
- package/dist/boilerplates/@batijs/hono/files/server/hono.ts +9 -9
- package/dist/boilerplates/@batijs/kysely/bati.config.mjs +2 -1
- package/dist/boilerplates/@batijs/kysely/files/$vite.config.ts.js +9 -12
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/db.ts +5 -5
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/migrate.ts +5 -6
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/migrations/001_create_todos_table.ts +2 -3
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/queries/todos.ts +8 -8
- package/dist/boilerplates/@batijs/kysely/files/vite-plugin-input.ts +1 -2
- package/dist/boilerplates/@batijs/kysely/types/database/kysely/queries/todos.d.mts +8 -8
- package/dist/boilerplates/@batijs/mantine/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/netlify/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/netlify/files/$vite.config.ts.js +8 -8
- package/dist/boilerplates/@batijs/oxlint/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/plausible.io/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/pnpm/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/postgres/bati.config.mjs +2 -1
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/db.ts +1 -1
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/schema/todos.ts +1 -1
- package/dist/boilerplates/@batijs/prettier/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/prisma/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/react/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/react/files/pages/+Head.tsx +6 -6
- package/dist/boilerplates/@batijs/react/files/pages/+Layout.tsx +14 -14
- package/dist/boilerplates/@batijs/react/files/pages/+config.ts +3 -3
- package/dist/boilerplates/@batijs/react/files/pages/index/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +3 -3
- package/dist/boilerplates/@batijs/react/files/pages/todo/TodoList.tsx +6 -6
- package/dist/boilerplates/@batijs/react-better-auth/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/account/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/login/+Page.tsx +4 -4
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/signup/+Page.tsx +4 -4
- package/dist/boilerplates/@batijs/react-sentry/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/sentry/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/sentry/files/$vite.config.ts.js +10 -10
- package/dist/boilerplates/@batijs/sentry/files/pages/$+client.ts.js +12 -18
- package/dist/boilerplates/@batijs/shadcn-ui/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shadcn-ui/files/$vite.config.ts.js +5 -27
- package/dist/boilerplates/@batijs/shared/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shared/files/vite.config.ts +1 -1
- package/dist/boilerplates/@batijs/shared-db/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shared-db/files/server/db-middleware.ts +21 -21
- package/dist/boilerplates/@batijs/shared-db/types/server/db-middleware.d.mts +10 -10
- package/dist/boilerplates/@batijs/shared-env/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shared-env/files/server/env.ts +6 -4
- package/dist/boilerplates/@batijs/shared-env/files/server/load.ts +1 -1
- package/dist/boilerplates/@batijs/shared-env/types/server/env.d.mts +2 -2
- package/dist/boilerplates/@batijs/shared-server/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shared-server/files/server/create-todo-handler.ts +16 -16
- package/dist/boilerplates/@batijs/shared-server/types/server/create-todo-handler.d.mts +10 -10
- package/dist/boilerplates/@batijs/shared-todo/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/shared-todo/files/global.d.ts +11 -11
- package/dist/boilerplates/@batijs/shared-todo/files/pages/todo/+config.ts +1 -4
- package/dist/boilerplates/@batijs/shared-todo/files/pages/todo/+data.ts +5 -5
- package/dist/boilerplates/@batijs/solid/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/solid/files/pages/+Head.tsx +3 -4
- package/dist/boilerplates/@batijs/solid/files/pages/+Layout.tsx +10 -10
- package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +3 -3
- package/dist/boilerplates/@batijs/solid/files/pages/index/Counter.tsx +2 -2
- package/dist/boilerplates/@batijs/solid/files/pages/todo/TodoList.tsx +6 -6
- package/dist/boilerplates/@batijs/solid-better-auth/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/account/+Page.tsx +1 -1
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/login/+Page.tsx +4 -4
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/signup/+Page.tsx +4 -4
- package/dist/boilerplates/@batijs/solid-sentry/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/sqlite/bati.config.mjs +2 -1
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/db.ts +1 -1
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/todos.ts +1 -1
- package/dist/boilerplates/@batijs/storybook/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/tailwindcss/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/tailwindcss/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/tailwindcss/files/pages/tailwind.css +2 -2
- package/dist/boilerplates/@batijs/telefunc/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/telefunc/files/$vite.config.ts.js +8 -8
- package/dist/boilerplates/@batijs/telefunc/files/global.d.ts +12 -12
- package/dist/boilerplates/@batijs/telefunc/files/pages/todo/TodoList.telefunc.ts +5 -5
- package/dist/boilerplates/@batijs/telefunc/files/server/telefunc-handler.ts +12 -12
- package/dist/boilerplates/@batijs/trpc/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/trpc/files/server/trpc-handler.ts +4 -4
- package/dist/boilerplates/@batijs/trpc/files/trpc/server.ts +15 -15
- package/dist/boilerplates/@batijs/ts-rest/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +15 -15
- package/dist/boilerplates/@batijs/universal-deploy/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/vercel/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/vercel/files/$vite.config.ts.js +8 -8
- package/dist/boilerplates/@batijs/vue/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/vue/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/vue/files/components/Content.vue +2 -2
- package/dist/boilerplates/@batijs/vue/files/components/Counter.vue +3 -3
- package/dist/boilerplates/@batijs/vue/files/components/Logo.vue +2 -2
- package/dist/boilerplates/@batijs/vue/files/components/Sidebar.vue +2 -2
- package/dist/boilerplates/@batijs/vue/files/pages/+Head.vue +2 -3
- package/dist/boilerplates/@batijs/vue/files/pages/+Layout.vue +3 -3
- package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +3 -3
- package/dist/boilerplates/@batijs/vue/files/pages/+onCreateApp.ts +1 -1
- package/dist/boilerplates/@batijs/vue/files/pages/todo/TodoList.vue +8 -8
- package/dist/boilerplates/@batijs/vue-better-auth/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/account/+Page.vue +1 -1
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/login/+Page.vue +3 -3
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/signup/+Page.vue +2 -2
- package/dist/boilerplates/@batijs/vue-sentry/bati.config.mjs +1 -1
- package/dist/index.js +49 -47
- package/package.json +5 -5
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { defineConfigArg, mergeObject, transformConfig } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/shadcn-ui/dist/files/$vite.config.ts.mjs
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return mod.generate().code.replace(`"{{PLACEHOLDER_ALIAS}}"`, replacement);
|
|
10
|
-
}
|
|
11
|
-
function addResolveAlias(mod, find, replacement) {
|
|
12
|
-
const alias = mod.exports.default.$args[0]?.resolve?.alias ?? {};
|
|
13
|
-
const warnMsg = `${yellow("WARN")}: new resolve.alias: \`"${find}":${replacement}\` replaced existing in vite.config.ts.`;
|
|
14
|
-
if (alias?.length === void 0) {
|
|
15
|
-
if (alias[find]) console.warn(warnMsg);
|
|
16
|
-
alias[find] = "{{PLACEHOLDER_ALIAS}}";
|
|
17
|
-
} else {
|
|
18
|
-
const newAlias = {
|
|
19
|
-
find,
|
|
20
|
-
replacement: "{{PLACEHOLDER_ALIAS}}"
|
|
21
|
-
};
|
|
22
|
-
const index = alias.findIndex((a) => a?.find === find);
|
|
23
|
-
if (index >= 0) {
|
|
24
|
-
console.warn(warnMsg);
|
|
25
|
-
alias.splice(index, 1);
|
|
26
|
-
}
|
|
27
|
-
alias.push(newAlias);
|
|
28
|
-
}
|
|
29
|
-
if (!mod.exports.default.$args[0]?.resolve) mod.exports.default.$args[0].resolve = {};
|
|
30
|
-
mod.exports.default.$args[0].resolve.alias = alias;
|
|
5
|
+
function getViteConfig(props) {
|
|
6
|
+
return transformConfig(props, (root) => {
|
|
7
|
+
mergeObject(defineConfigArg(root), { resolve: { alias: { "@": `new URL("./", import.meta.url).pathname` } } });
|
|
8
|
+
});
|
|
31
9
|
}
|
|
32
10
|
//#endregion
|
|
33
11
|
export { getViteConfig as default };
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/* $$.keepFileIfImported */
|
|
2
2
|
|
|
3
3
|
import { getDbFromRuntime } from "@batijs/d1/database/d1/helpers";
|
|
4
4
|
import { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
@@ -7,20 +7,20 @@ import { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
|
7
7
|
import { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
8
8
|
import { enhance, type UniversalMiddleware } from "@universal-middleware/core";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// $$.BATI.hasDatabase
|
|
11
11
|
declare global {
|
|
12
12
|
namespace Universal {
|
|
13
13
|
interface Context {
|
|
14
|
-
db:
|
|
15
|
-
'BATI.has("drizzle") && BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
16
|
-
'BATI.has("kysely") && BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
17
|
-
'BATI.has("postgres") &&
|
|
18
|
-
'BATI.has("sqlite") &&
|
|
19
|
-
'BATI.has("drizzle") &&
|
|
20
|
-
'BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
21
|
-
'BATI.has("kysely") &&
|
|
22
|
-
'BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
23
|
-
"BATI.hasD1 &&
|
|
14
|
+
db: $$.If<{
|
|
15
|
+
'$$.BATI.has("drizzle") && $$.BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
16
|
+
'$$.BATI.has("kysely") && $$.BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
17
|
+
'$$.BATI.has("postgres") && !$$.BATI.hasOrm': ReturnType<typeof pgDb>;
|
|
18
|
+
'$$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm': ReturnType<typeof sqliteDb>;
|
|
19
|
+
'$$.BATI.has("drizzle") && !$$.BATI.hasD1': ReturnType<typeof dbSqlite>;
|
|
20
|
+
'$$.BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
21
|
+
'$$.BATI.has("kysely") && !$$.BATI.hasD1': ReturnType<typeof dbKysely>;
|
|
22
|
+
'$$.BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
23
|
+
"$$.BATI.hasD1 && !$$.BATI.hasOrm": D1Database;
|
|
24
24
|
}>;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -34,28 +34,28 @@ export const dbMiddleware: UniversalMiddleware = enhance(
|
|
|
34
34
|
// The context we add here is automatically merged into pageContext
|
|
35
35
|
async (_request, context, _runtime) => {
|
|
36
36
|
const db =
|
|
37
|
-
BATI.has("drizzle") && BATI.has("postgres")
|
|
37
|
+
$$.BATI.has("drizzle") && $$.BATI.has("postgres")
|
|
38
38
|
? dbPostgres()
|
|
39
|
-
: BATI.has("kysely") && BATI.has("postgres")
|
|
39
|
+
: $$.BATI.has("kysely") && $$.BATI.has("postgres")
|
|
40
40
|
? dbKyselyPostgres()
|
|
41
|
-
: BATI.has("postgres") &&
|
|
41
|
+
: $$.BATI.has("postgres") && !$$.BATI.hasOrm
|
|
42
42
|
? pgDb()
|
|
43
|
-
: BATI.has("sqlite") &&
|
|
43
|
+
: $$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm
|
|
44
44
|
? sqliteDb()
|
|
45
|
-
: BATI.has("drizzle") &&
|
|
45
|
+
: $$.BATI.has("drizzle") && !$$.BATI.hasD1
|
|
46
46
|
? dbSqlite()
|
|
47
|
-
: BATI.has("kysely") &&
|
|
47
|
+
: $$.BATI.has("kysely") && !$$.BATI.hasD1
|
|
48
48
|
? dbKysely()
|
|
49
|
-
: BATI.has("kysely")
|
|
49
|
+
: $$.BATI.has("kysely")
|
|
50
50
|
? dbKyselyD1(await getDbFromRuntime(_runtime))
|
|
51
|
-
: BATI.has("drizzle")
|
|
51
|
+
: $$.BATI.has("drizzle")
|
|
52
52
|
? dbD1(await getDbFromRuntime(_runtime))
|
|
53
53
|
: await getDbFromRuntime(_runtime);
|
|
54
54
|
|
|
55
55
|
return {
|
|
56
56
|
...context,
|
|
57
57
|
// Sets pageContext.db
|
|
58
|
-
db: db as
|
|
58
|
+
db: db as $$.Any,
|
|
59
59
|
};
|
|
60
60
|
},
|
|
61
61
|
{
|
|
@@ -8,16 +8,16 @@ import { UniversalMiddleware } from "@universal-middleware/core";
|
|
|
8
8
|
declare global {
|
|
9
9
|
namespace Universal {
|
|
10
10
|
interface Context {
|
|
11
|
-
db:
|
|
12
|
-
'BATI.has("drizzle") && BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
13
|
-
'BATI.has("kysely") && BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
14
|
-
'BATI.has("postgres") &&
|
|
15
|
-
'BATI.has("sqlite") &&
|
|
16
|
-
'BATI.has("drizzle") &&
|
|
17
|
-
'BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
18
|
-
'BATI.has("kysely") &&
|
|
19
|
-
'BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
20
|
-
"BATI.hasD1 &&
|
|
11
|
+
db: $$.If<{
|
|
12
|
+
'$$.BATI.has("drizzle") && $$.BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
13
|
+
'$$.BATI.has("kysely") && $$.BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
14
|
+
'$$.BATI.has("postgres") && !$$.BATI.hasOrm': ReturnType<typeof db>;
|
|
15
|
+
'$$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm': ReturnType<typeof db$1>;
|
|
16
|
+
'$$.BATI.has("drizzle") && !$$.BATI.hasD1': ReturnType<typeof dbSqlite>;
|
|
17
|
+
'$$.BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
18
|
+
'$$.BATI.has("kysely") && !$$.BATI.hasD1': ReturnType<typeof dbKysely>;
|
|
19
|
+
'$$.BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
20
|
+
"$$.BATI.hasD1 && !$$.BATI.hasOrm": D1Database;
|
|
21
21
|
}>;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* $$.keepFileIfImported */
|
|
2
2
|
import { env as cloudflareEnv } from "cloudflare:workers";
|
|
3
|
-
|
|
3
|
+
// !$$.BATI.has("cloudflare")
|
|
4
4
|
import "./load.js";
|
|
5
5
|
|
|
6
|
-
export const env:
|
|
7
|
-
|
|
6
|
+
export const env: $$.If<{ '!$$.BATI.has("cloudflare")': Record<string, string | undefined> }> = $$.BATI.has(
|
|
7
|
+
"cloudflare",
|
|
8
|
+
)
|
|
9
|
+
? (cloudflareEnv as $$.Any)
|
|
8
10
|
: typeof process?.env !== "undefined"
|
|
9
11
|
? process.env
|
|
10
12
|
: {};
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/* $$.keepFileIfImported */
|
|
2
2
|
|
|
3
3
|
import * as d1Queries from "@batijs/d1-sqlite/database/d1/queries/todos";
|
|
4
4
|
import type { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
@@ -14,16 +14,16 @@ import { enhance, type UniversalHandler } from "@universal-middleware/core";
|
|
|
14
14
|
// Note: You can directly define a server middleware instead of defining a Universal Middleware. (You can remove @universal-middleware/* — Vike's scaffolder uses it only to simplify its internal logic, see https://github.com/vikejs/vike/discussions/3116)
|
|
15
15
|
export const createTodoHandler: UniversalHandler<
|
|
16
16
|
Universal.Context &
|
|
17
|
-
|
|
18
|
-
'BATI.has("drizzle") && BATI.has("postgres")': { db: ReturnType<typeof dbPostgres> };
|
|
19
|
-
'BATI.has("kysely") && BATI.has("postgres")': { db: ReturnType<typeof dbKyselyPostgres> };
|
|
20
|
-
'BATI.has("postgres") &&
|
|
21
|
-
'BATI.has("sqlite") &&
|
|
22
|
-
'BATI.has("drizzle") &&
|
|
23
|
-
'BATI.has("drizzle")': { db: ReturnType<typeof dbD1> };
|
|
24
|
-
'BATI.has("kysely") &&
|
|
25
|
-
'BATI.has("kysely")': { db: ReturnType<typeof dbKyselyD1> };
|
|
26
|
-
"BATI.hasD1 &&
|
|
17
|
+
$$.If<{
|
|
18
|
+
'$$.BATI.has("drizzle") && $$.BATI.has("postgres")': { db: ReturnType<typeof dbPostgres> };
|
|
19
|
+
'$$.BATI.has("kysely") && $$.BATI.has("postgres")': { db: ReturnType<typeof dbKyselyPostgres> };
|
|
20
|
+
'$$.BATI.has("postgres") && !$$.BATI.hasOrm': { db: ReturnType<typeof pgDb> };
|
|
21
|
+
'$$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm': { db: ReturnType<typeof sqliteDb> };
|
|
22
|
+
'$$.BATI.has("drizzle") && !$$.BATI.hasD1': { db: ReturnType<typeof dbSqlite> };
|
|
23
|
+
'$$.BATI.has("drizzle")': { db: ReturnType<typeof dbD1> };
|
|
24
|
+
'$$.BATI.has("kysely") && !$$.BATI.hasD1': { db: ReturnType<typeof dbKysely> };
|
|
25
|
+
'$$.BATI.has("kysely")': { db: ReturnType<typeof dbKyselyD1> };
|
|
26
|
+
"$$.BATI.hasD1 && !$$.BATI.hasOrm": { db: D1Database };
|
|
27
27
|
_: object;
|
|
28
28
|
}>
|
|
29
29
|
> = enhance(
|
|
@@ -31,15 +31,15 @@ export const createTodoHandler: UniversalHandler<
|
|
|
31
31
|
// In a real case, user-provided data should ALWAYS be validated with tools like zod
|
|
32
32
|
const newTodo = (await request.json()) as { text: string };
|
|
33
33
|
|
|
34
|
-
if (BATI.has("drizzle")) {
|
|
34
|
+
if ($$.BATI.has("drizzle")) {
|
|
35
35
|
await drizzleQueries.insertTodo(_context.db, newTodo.text);
|
|
36
|
-
} else if (BATI.has("sqlite") &&
|
|
36
|
+
} else if ($$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm) {
|
|
37
37
|
sqliteQueries.insertTodo(_context.db, newTodo.text);
|
|
38
|
-
} else if (BATI.has("kysely")) {
|
|
38
|
+
} else if ($$.BATI.has("kysely")) {
|
|
39
39
|
await kyselyQueries.insertTodo(_context.db, newTodo.text);
|
|
40
|
-
} else if (BATI.hasD1 &&
|
|
40
|
+
} else if ($$.BATI.hasD1 && !$$.BATI.hasOrm) {
|
|
41
41
|
await d1Queries.insertTodo(_context.db, newTodo.text);
|
|
42
|
-
} else if (BATI.has("postgres") &&
|
|
42
|
+
} else if ($$.BATI.has("postgres") && !$$.BATI.hasOrm) {
|
|
43
43
|
await pgQueries.insertTodo(_context.db, newTodo.text);
|
|
44
44
|
} else {
|
|
45
45
|
// This is where you'd persist the data
|
|
@@ -5,32 +5,32 @@ import { db as db$1 } from "@batijs/sqlite/database/sqlite/db";
|
|
|
5
5
|
import { UniversalHandler } from "@universal-middleware/core";
|
|
6
6
|
|
|
7
7
|
//#region files/server/create-todo-handler.d.ts
|
|
8
|
-
declare const createTodoHandler: UniversalHandler<Universal.Context &
|
|
9
|
-
'BATI.has("drizzle") && BATI.has("postgres")': {
|
|
8
|
+
declare const createTodoHandler: UniversalHandler<Universal.Context & $$.If<{
|
|
9
|
+
'$$.BATI.has("drizzle") && $$.BATI.has("postgres")': {
|
|
10
10
|
db: ReturnType<typeof dbPostgres>;
|
|
11
11
|
};
|
|
12
|
-
'BATI.has("kysely") && BATI.has("postgres")': {
|
|
12
|
+
'$$.BATI.has("kysely") && $$.BATI.has("postgres")': {
|
|
13
13
|
db: ReturnType<typeof dbKyselyPostgres>;
|
|
14
14
|
};
|
|
15
|
-
'BATI.has("postgres") &&
|
|
15
|
+
'$$.BATI.has("postgres") && !$$.BATI.hasOrm': {
|
|
16
16
|
db: ReturnType<typeof db>;
|
|
17
17
|
};
|
|
18
|
-
'BATI.has("sqlite") &&
|
|
18
|
+
'$$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm': {
|
|
19
19
|
db: ReturnType<typeof db$1>;
|
|
20
20
|
};
|
|
21
|
-
'BATI.has("drizzle") &&
|
|
21
|
+
'$$.BATI.has("drizzle") && !$$.BATI.hasD1': {
|
|
22
22
|
db: ReturnType<typeof dbSqlite>;
|
|
23
23
|
};
|
|
24
|
-
'BATI.has("drizzle")': {
|
|
24
|
+
'$$.BATI.has("drizzle")': {
|
|
25
25
|
db: ReturnType<typeof dbD1>;
|
|
26
26
|
};
|
|
27
|
-
'BATI.has("kysely") &&
|
|
27
|
+
'$$.BATI.has("kysely") && !$$.BATI.hasD1': {
|
|
28
28
|
db: ReturnType<typeof dbKysely>;
|
|
29
29
|
};
|
|
30
|
-
'BATI.has("kysely")': {
|
|
30
|
+
'$$.BATI.has("kysely")': {
|
|
31
31
|
db: ReturnType<typeof dbKyselyD1>;
|
|
32
32
|
};
|
|
33
|
-
"BATI.hasD1 &&
|
|
33
|
+
"$$.BATI.hasD1 && !$$.BATI.hasOrm": {
|
|
34
34
|
db: D1Database;
|
|
35
35
|
};
|
|
36
36
|
_: object;
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -3,20 +3,20 @@ import type { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/data
|
|
|
3
3
|
import type { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
4
4
|
import type { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// $$.BATI.hasDbDemo
|
|
7
7
|
declare global {
|
|
8
8
|
namespace Vike {
|
|
9
9
|
interface PageContextServer {
|
|
10
|
-
db:
|
|
11
|
-
'BATI.has("drizzle") && BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
12
|
-
'BATI.has("kysely") && BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
13
|
-
'BATI.has("postgres") &&
|
|
14
|
-
'BATI.has("sqlite") &&
|
|
15
|
-
'BATI.has("drizzle") &&
|
|
16
|
-
'BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
17
|
-
'BATI.has("kysely") &&
|
|
18
|
-
'BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
19
|
-
"BATI.hasD1 &&
|
|
10
|
+
db: $$.If<{
|
|
11
|
+
'$$.BATI.has("drizzle") && $$.BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
12
|
+
'$$.BATI.has("kysely") && $$.BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
13
|
+
'$$.BATI.has("postgres") && !$$.BATI.hasOrm': ReturnType<typeof pgDb>;
|
|
14
|
+
'$$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm': ReturnType<typeof sqliteDb>;
|
|
15
|
+
'$$.BATI.has("drizzle") && !$$.BATI.hasD1': ReturnType<typeof dbSqlite>;
|
|
16
|
+
'$$.BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
17
|
+
'$$.BATI.has("kysely") && !$$.BATI.hasD1': ReturnType<typeof dbKysely>;
|
|
18
|
+
'$$.BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
19
|
+
"$$.BATI.hasD1 && !$$.BATI.hasOrm": D1Database;
|
|
20
20
|
}>;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -10,23 +10,23 @@ import type { PageContextServer } from "vike/types";
|
|
|
10
10
|
export type Data = Awaited<ReturnType<typeof data>>;
|
|
11
11
|
|
|
12
12
|
export async function data(_pageContext: PageContextServer) {
|
|
13
|
-
if (BATI.has("drizzle")) {
|
|
13
|
+
if ($$.BATI.has("drizzle")) {
|
|
14
14
|
const todoItemsInitial = await drizzleQueries.getAllTodos(_pageContext.db);
|
|
15
15
|
|
|
16
16
|
return { todoItemsInitial };
|
|
17
|
-
} else if (BATI.has("sqlite") &&
|
|
17
|
+
} else if ($$.BATI.has("sqlite") && !$$.BATI.hasD1 && !$$.BATI.hasOrm) {
|
|
18
18
|
const todoItemsInitial = sqliteQueries.getAllTodos(_pageContext.db);
|
|
19
19
|
|
|
20
20
|
return { todoItemsInitial };
|
|
21
|
-
} else if (BATI.has("kysely")) {
|
|
21
|
+
} else if ($$.BATI.has("kysely")) {
|
|
22
22
|
const todoItemsInitial = await kyselyQueries.getAllTodos(_pageContext.db);
|
|
23
23
|
|
|
24
24
|
return { todoItemsInitial };
|
|
25
|
-
} else if (BATI.hasD1 &&
|
|
25
|
+
} else if ($$.BATI.hasD1 && !$$.BATI.hasOrm) {
|
|
26
26
|
const todoItemsInitial = await d1Queries.getAllTodos(_pageContext.db);
|
|
27
27
|
|
|
28
28
|
return { todoItemsInitial };
|
|
29
|
-
} else if (BATI.has("postgres") &&
|
|
29
|
+
} else if ($$.BATI.has("postgres") && !$$.BATI.hasOrm) {
|
|
30
30
|
const todoItemsInitial = await pgQueries.getAllTodos(_pageContext.db);
|
|
31
31
|
|
|
32
32
|
return { todoItemsInitial };
|
|
@@ -3,7 +3,7 @@ function e(e, t) {
|
|
|
3
3
|
if (!e) throw Error(t);
|
|
4
4
|
}
|
|
5
5
|
function t(t) {
|
|
6
|
-
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), `deploy` in t && e(Array.isArray(t.deploy) || typeof t.deploy == `function`, `'deploy' must be an array or a function of meta`), t;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region bati.config.ts
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { addVitePlugin,
|
|
3
|
+
import { addVitePlugin, transformConfig } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/solid/dist/files/$vite.config.ts.mjs
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function getViteConfig(props) {
|
|
6
|
+
return transformConfig(props, (root) => {
|
|
7
|
+
addVitePlugin(root, {
|
|
8
|
+
from: "vike-solid/vite",
|
|
9
|
+
constructor: "vikeSolid"
|
|
10
|
+
});
|
|
10
11
|
});
|
|
11
|
-
return mod.generate().code;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { getViteConfig as default };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/* eslint-disable solid/no-innerhtml */
|
|
2
|
-
|
|
3
1
|
// https://vike.dev/Head
|
|
4
2
|
|
|
5
3
|
import logoUrl from "../assets/logo.svg";
|
|
6
4
|
|
|
7
5
|
export function Head() {
|
|
8
|
-
if (BATI.has("plausible.io")) {
|
|
6
|
+
if ($$.BATI.has("plausible.io")) {
|
|
9
7
|
return (
|
|
10
8
|
<>
|
|
11
9
|
<link rel="icon" href={logoUrl} />
|
|
@@ -14,7 +12,7 @@ export function Head() {
|
|
|
14
12
|
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.js" />
|
|
15
13
|
</>
|
|
16
14
|
);
|
|
17
|
-
} else if (BATI.has("google-analytics")) {
|
|
15
|
+
} else if ($$.BATI.has("google-analytics")) {
|
|
18
16
|
return (
|
|
19
17
|
<>
|
|
20
18
|
<script
|
|
@@ -22,6 +20,7 @@ export function Head() {
|
|
|
22
20
|
src={`https://www.googletagmanager.com/gtag/js?id=${import.meta.env.PUBLIC_ENV__GOOGLE_ANALYTICS}`}
|
|
23
21
|
/>
|
|
24
22
|
<script
|
|
23
|
+
// eslint-disable-next-line solid/no-innerhtml
|
|
25
24
|
innerHTML={`window.dataLayer = window.dataLayer || [];
|
|
26
25
|
function gtag(){dataLayer.push(arguments);}
|
|
27
26
|
gtag('js', new Date());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://vike.dev/Layout
|
|
2
2
|
|
|
3
3
|
import "./Layout.css";
|
|
4
|
-
|
|
4
|
+
// $$.BATI.has("tailwindcss")
|
|
5
5
|
import "./tailwind.css";
|
|
6
6
|
import { AuthNav } from "@batijs/solid-better-auth/components/AuthNav";
|
|
7
7
|
import type { JSX } from "solid-js";
|
|
@@ -11,9 +11,9 @@ import { Link } from "../components/Link";
|
|
|
11
11
|
export default function Layout(props: { children?: JSX.Element }) {
|
|
12
12
|
return (
|
|
13
13
|
<div
|
|
14
|
-
|
|
14
|
+
// $$.BATI.has("tailwindcss")
|
|
15
15
|
class={"flex max-w-5xl m-auto"}
|
|
16
|
-
|
|
16
|
+
// !$$.BATI.has("tailwindcss")
|
|
17
17
|
style={{
|
|
18
18
|
display: "flex",
|
|
19
19
|
"max-width": "900px",
|
|
@@ -25,7 +25,7 @@ export default function Layout(props: { children?: JSX.Element }) {
|
|
|
25
25
|
<Link href="/">Welcome</Link>
|
|
26
26
|
<Link href="/todo">Todo</Link>
|
|
27
27
|
<Link href="/star-wars">Data Fetching</Link>
|
|
28
|
-
{BATI.has("better-auth") ? <AuthNav /> : null}
|
|
28
|
+
{$$.BATI.has("better-auth") ? <AuthNav /> : null}
|
|
29
29
|
</Sidebar>
|
|
30
30
|
<Content>{props.children}</Content>
|
|
31
31
|
</div>
|
|
@@ -36,9 +36,9 @@ function Sidebar(props: { children: JSX.Element }) {
|
|
|
36
36
|
return (
|
|
37
37
|
<div
|
|
38
38
|
id="sidebar"
|
|
39
|
-
|
|
39
|
+
// $$.BATI.has("tailwindcss")
|
|
40
40
|
class={"p-5 flex flex-col shrink-0 border-r-2 border-r-gray-200"}
|
|
41
|
-
|
|
41
|
+
// !$$.BATI.has("tailwindcss")
|
|
42
42
|
style={{
|
|
43
43
|
padding: "20px",
|
|
44
44
|
"flex-shrink": 0,
|
|
@@ -58,9 +58,9 @@ function Content(props: { children: JSX.Element }) {
|
|
|
58
58
|
<div id="page-container">
|
|
59
59
|
<div
|
|
60
60
|
id="page-content"
|
|
61
|
-
|
|
61
|
+
// $$.BATI.has("tailwindcss")
|
|
62
62
|
class={"p-5 pb-12 min-h-screen"}
|
|
63
|
-
|
|
63
|
+
// !$$.BATI.has("tailwindcss")
|
|
64
64
|
style={{
|
|
65
65
|
padding: "20px",
|
|
66
66
|
"padding-bottom": "50px",
|
|
@@ -76,9 +76,9 @@ function Content(props: { children: JSX.Element }) {
|
|
|
76
76
|
function Logo() {
|
|
77
77
|
return (
|
|
78
78
|
<div
|
|
79
|
-
|
|
79
|
+
// $$.BATI.has("tailwindcss")
|
|
80
80
|
class={"p-5 mb-2"}
|
|
81
|
-
|
|
81
|
+
// !$$.BATI.has("tailwindcss")
|
|
82
82
|
style={{
|
|
83
83
|
"margin-top": "20px",
|
|
84
84
|
"margin-bottom": "10px",
|
|
@@ -9,14 +9,14 @@ const config: Config = {
|
|
|
9
9
|
title: "My Vike App",
|
|
10
10
|
description: "Demo showcasing Vike",
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// $$.BATI.has("auth0") || $$.BATI.has("authjs") || $$.BATI.has("better-auth")
|
|
13
13
|
passToClient: ["user"],
|
|
14
14
|
extends: [vikeSolid],
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// $$.BATI.has("vercel")
|
|
17
17
|
prerender: true,
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// $$.BATI.hasUD && !$$.BATI.hasServer
|
|
20
20
|
// https://vike.dev/server
|
|
21
21
|
server: true,
|
|
22
22
|
};
|
|
@@ -8,9 +8,9 @@ function Counter() {
|
|
|
8
8
|
return (
|
|
9
9
|
<button
|
|
10
10
|
type="button"
|
|
11
|
-
|
|
11
|
+
// $$.BATI.has("tailwindcss")
|
|
12
12
|
class={
|
|
13
|
-
BATI.has("daisyui")
|
|
13
|
+
$$.BATI.has("daisyui")
|
|
14
14
|
? "btn"
|
|
15
15
|
: "inline-block border border-black rounded bg-gray-200 px-2 py-1 text-xs font-medium uppercase leading-normal"
|
|
16
16
|
}
|