@batijs/cli 0.0.175 → 0.0.177

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 (30) hide show
  1. package/dist/boilerplates/@batijs/auth0/files/$.env.js +19 -0
  2. package/dist/boilerplates/@batijs/auth0/files/$README.md.js +43 -0
  3. package/dist/boilerplates/@batijs/auth0/files/vike.d.ts +11 -0
  4. package/dist/boilerplates/@batijs/edgedb/files/$package.json.js +2 -2
  5. package/dist/boilerplates/@batijs/eslint/files/$package.json.js +2 -2
  6. package/dist/boilerplates/@batijs/express/files/$package.json.js +7 -3
  7. package/dist/boilerplates/@batijs/express/files/express-entry.ts +33 -11
  8. package/dist/boilerplates/@batijs/express/files/vike.d.ts +10 -0
  9. package/dist/boilerplates/@batijs/express/types/express-entry.d.ts +1 -1
  10. package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +1 -7
  11. package/dist/boilerplates/@batijs/firebase-auth/files/firebase/$service-account.json.js +20 -0
  12. package/dist/boilerplates/@batijs/firebase-auth/files/pages/+firebaseApp.ts +2 -1
  13. package/dist/boilerplates/@batijs/firebase-auth/files/{types.ts → vike.d.ts} +0 -9
  14. package/dist/boilerplates/@batijs/h3/files/$package.json.js +11 -3
  15. package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +37 -16
  16. package/dist/boilerplates/@batijs/h3/files/vike.d.ts +22 -0
  17. package/dist/boilerplates/@batijs/h3/types/h3-entry.d.ts +1 -6
  18. package/dist/boilerplates/@batijs/hattip/files/$package.json.js +1 -1
  19. package/dist/boilerplates/@batijs/react/files/$package.json.js +3 -3
  20. package/dist/boilerplates/@batijs/react/files/pages/+config.ts +1 -1
  21. package/dist/boilerplates/@batijs/shared/files/package.json +1 -1
  22. package/dist/boilerplates/@batijs/solid/files/$package.json.js +1 -1
  23. package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +1 -1
  24. package/dist/boilerplates/@batijs/vue/files/$package.json.js +3 -3
  25. package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +1 -1
  26. package/dist/boilerplates/boilerplates.json +11 -0
  27. package/dist/index.js +77 -52
  28. package/package.json +7 -7
  29. package/dist/boilerplates/@batijs/firebase-auth/files/firebase/service-account-example.json +0 -13
  30. package/dist/boilerplates/@batijs/firebase-auth/types/types.d.ts +0 -18
@@ -0,0 +1,19 @@
1
+ // files/$.env.ts
2
+ import { appendToEnv, randomBytes } from "@batijs/core";
3
+ async function getEnv(props) {
4
+ const auth0ClientId = process.env.TEST_AUTH0_CLIENT_ID;
5
+ const auth0BaseUrl = process.env.TEST_AUTH0_ISSUER_BASE_URL;
6
+ let envContent = await props.readfile?.();
7
+ envContent = appendToEnv(
8
+ envContent,
9
+ "SECRET",
10
+ randomBytes(32).toString("hex"),
11
+ "Randomly generated by Bati CLI, used by Auth0"
12
+ );
13
+ envContent = appendToEnv(envContent, "CLIENT_ID", auth0ClientId ?? "", "Auth0 Client ID");
14
+ envContent = appendToEnv(envContent, "ISSUER_BASE_URL", auth0BaseUrl ?? "", "Auth0 base URL");
15
+ return envContent;
16
+ }
17
+ export {
18
+ getEnv as default
19
+ };
@@ -0,0 +1,43 @@
1
+ // files/$README.md.ts
2
+ import { loadReadme } from "@batijs/core";
3
+ async function getReadme(props) {
4
+ const content = await loadReadme(props);
5
+ const todo = `
6
+ ## *Auth0*
7
+ - Sign up or login to an Auth0 account, then go to [your Dashboard](https://manage.auth0.com/dashboard/)
8
+ - Create Application -> Regular Web Application
9
+ - What technology are you using for your project? -> Node.js (Express) -> Integrate Now
10
+ - Configure Auth0:
11
+ - Allowed Callback URL: http://localhost:3000/api/auth/callback
12
+ - Allowed Logout URLs: http://localhost:3000
13
+ - Save Changes
14
+ - Copy your \`clientID\` and \`issuerBaseURL\` and paste it in \`.env\` file like this:
15
+
16
+ \`\`\`env
17
+ // .env
18
+ SECRET=<random string>
19
+ CLIENT_ID=<Client ID>
20
+ ISSUER_BASE_URL=https://<your-auth0-domain>.<eu>.auth0.com
21
+ \`\`\`
22
+
23
+ > [!NOTE]
24
+ > Environment variables that are automatically made available to Auth0 :
25
+ > - \`SECRET\`
26
+ > - \`ISSUER_BASE_URL\`
27
+ > - \`BASE_URL\`
28
+ > - \`CLIENT_ID\`
29
+ > - \`CLIENT_SECRET\`
30
+
31
+ > [!NOTE]
32
+ > Login route is \`http://localhost:3000/api/auth/login\`.
33
+ > Logout route is \`http://localhost:3000/api/auth/logout\`.
34
+
35
+ - Read more [Auth0 Express SDK Quickstarts: Login](https://auth0.com/docs/quickstart/webapp/express)
36
+ - Read more [Auth0 Express SDK Quickstarts: Add Login to your Express App](https://auth0.com/docs/quickstart/webapp/express/interactive)
37
+ `;
38
+ content.addTodo(todo);
39
+ return content.finalize();
40
+ }
41
+ export {
42
+ getReadme as default
43
+ };
@@ -0,0 +1,11 @@
1
+ import type { RequestContext } from "express-openid-connect";
2
+
3
+ declare global {
4
+ namespace Vike {
5
+ interface PageContext {
6
+ user?: RequestContext["user"] | null;
7
+ }
8
+ }
9
+ }
10
+
11
+ export {};
@@ -42,11 +42,11 @@ var require_package = __commonJS({
42
42
  license: "MIT",
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:*",
45
- "@edgedb/generate": "^0.4.1",
45
+ "@edgedb/generate": "^0.5.2",
46
46
  "@prisma/client": "^5.12.1",
47
47
  "@types/node": "^18.19.14",
48
48
  colorette: "^2.0.20",
49
- edgedb: "^1.4.1"
49
+ edgedb: "^1.5.0"
50
50
  },
51
51
  dependencies: {
52
52
  "@batijs/core": "workspace:*"
@@ -42,8 +42,8 @@ var require_package = __commonJS({
42
42
  },
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:^",
45
- "@typescript-eslint/eslint-plugin": "^7.5.0",
46
- "@typescript-eslint/parser": "^7.5.0",
45
+ "@typescript-eslint/eslint-plugin": "^7.6.0",
46
+ "@typescript-eslint/parser": "^7.6.0",
47
47
  eslint: "^8.57.0"
48
48
  },
49
49
  dependencies: {
@@ -41,7 +41,7 @@ var require_package = __commonJS({
41
41
  author: "",
42
42
  license: "MIT",
43
43
  devDependencies: {
44
- "@auth/core": "^0.28.2",
44
+ "@auth/core": "^0.29.0",
45
45
  "@batijs/compile": "workspace:*",
46
46
  "@batijs/firebase-auth": "workspace:*",
47
47
  "@batijs/trpc": "workspace:*",
@@ -51,7 +51,9 @@ var require_package = __commonJS({
51
51
  "@types/express": "^4.17.21",
52
52
  "@types/node": "^18.19.14",
53
53
  "cookie-parser": "^1.4.6",
54
+ dotenv: "^16.4.5",
54
55
  express: "^4.19.2",
56
+ "express-openid-connect": "^2.17.1",
55
57
  "firebase-admin": "^12.0.0",
56
58
  telefunc: "^0.1.71",
57
59
  tsx: "^4.7.2",
@@ -109,7 +111,8 @@ async function getPackageJson(props) {
109
111
  return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)), {
110
112
  devDependencies: [
111
113
  "@types/express",
112
- ...props.meta.BATI.has("firebase-auth") ? ["@types/cookie-parser"] : []
114
+ ...props.meta.BATI.has("firebase-auth") ? ["@types/cookie-parser"] : [],
115
+ ...props.meta.BATI.has("auth0") ? ["dotenv"] : []
113
116
  ],
114
117
  dependencies: [
115
118
  "@hattip/adapter-node",
@@ -118,7 +121,8 @@ async function getPackageJson(props) {
118
121
  "vite",
119
122
  "vike",
120
123
  ...props.meta.BATI.has("authjs") ? ["@auth/core", "vike-authjs"] : [],
121
- ...props.meta.BATI.has("firebase-auth") ? ["cookie-parser"] : []
124
+ ...props.meta.BATI.has("firebase-auth") ? ["cookie-parser"] : [],
125
+ ...props.meta.BATI.has("auth0") ? ["express-openid-connect"] : []
122
126
  ]
123
127
  });
124
128
  }
@@ -1,3 +1,5 @@
1
+ // BATI.has("auth0")
2
+ import "dotenv/config";
1
3
  import { dirname } from "node:path";
2
4
  import { fileURLToPath } from "node:url";
3
5
  import CredentialsProvider from "@auth/core/providers/credentials";
@@ -7,6 +9,7 @@ import { createMiddleware } from "@hattip/adapter-node";
7
9
  import * as trpcExpress from "@trpc/server/adapters/express";
8
10
  import cookieParser from "cookie-parser";
9
11
  import express, { type Request } from "express";
12
+ import { auth, type ConfigParams } from "express-openid-connect";
10
13
  import { getAuth } from "firebase-admin/auth";
11
14
  import { telefunc } from "telefunc";
12
15
  import { VikeAuth } from "vike-authjs";
@@ -16,6 +19,8 @@ const __filename = fileURLToPath(import.meta.url);
16
19
  const __dirname = dirname(__filename);
17
20
  const isProduction = process.env.NODE_ENV === "production";
18
21
  const root = __dirname;
22
+ const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
23
+ const hmrPort = process.env.HMR_PORT ? parseInt(process.env.HMR_PORT, 10) : 24678;
19
24
 
20
25
  startServer();
21
26
 
@@ -32,7 +37,7 @@ async function startServer() {
32
37
  const viteDevMiddleware = (
33
38
  await vite.createServer({
34
39
  root,
35
- server: { middlewareMode: true },
40
+ server: { middlewareMode: true, hmr: { port: hmrPort } },
36
41
  })
37
42
  ).middlewares;
38
43
  app.use(viteDevMiddleware);
@@ -88,7 +93,7 @@ async function startServer() {
88
93
  const user = await auth.getUser(decodedIdToken.sub);
89
94
  req.user = user;
90
95
  } catch (error) {
91
- console.error("verifySessionCookie:", error);
96
+ console.debug("verifySessionCookie:", error);
92
97
  req.user = null;
93
98
  }
94
99
 
@@ -123,6 +128,21 @@ async function startServer() {
123
128
  });
124
129
  }
125
130
 
131
+ if (BATI.has("auth0")) {
132
+ const config: ConfigParams = {
133
+ authRequired: false, // Controls whether authentication is required for all routes
134
+ auth0Logout: true, // Uses Auth0 logout feature
135
+ baseURL: process.env.BASE_URL?.startsWith("http") ? process.env.BASE_URL : `http://localhost:${port}`, // The URL where the application is served
136
+ routes: {
137
+ login: "/api/auth/login", // Custom login route, default is : "/login"
138
+ logout: "/api/auth/logout", // Custom logout route, default is : "/logout"
139
+ callback: "/api/auth/callback", // Custom callback route, default is "/callback"
140
+ },
141
+ };
142
+
143
+ app.use(auth(config));
144
+ }
145
+
126
146
  if (BATI.has("trpc")) {
127
147
  /**
128
148
  * tRPC route
@@ -177,24 +197,26 @@ async function startServer() {
177
197
  * @link {@see https://vike.dev}
178
198
  **/
179
199
  app.all("*", async (req: Request, res, next) => {
180
- const pageContextInit = BATI.has("firebase-auth")
181
- ? { urlOriginal: req.originalUrl, user: req.user }
182
- : { urlOriginal: req.originalUrl };
200
+ const pageContextInit = BATI.has("auth0")
201
+ ? { urlOriginal: req.originalUrl, user: req.oidc.user }
202
+ : BATI.has("firebase-auth")
203
+ ? { urlOriginal: req.originalUrl, user: req.user }
204
+ : { urlOriginal: req.originalUrl };
183
205
 
184
206
  const pageContext = await renderPage(pageContextInit);
185
- const { httpResponse } = pageContext
207
+ const { httpResponse } = pageContext;
186
208
 
187
209
  if (!httpResponse) {
188
- return next()
210
+ return next();
189
211
  } else {
190
212
  const { statusCode, headers } = httpResponse;
191
- headers.forEach(([name, value]) => res.setHeader(name, value))
192
- res.status(statusCode)
213
+ headers.forEach(([name, value]) => res.setHeader(name, value));
214
+ res.status(statusCode);
193
215
  httpResponse.pipe(res);
194
216
  }
195
217
  });
196
218
 
197
- app.listen(process.env.PORT ? parseInt(process.env.PORT) : 3000, () => {
198
- console.log("Server listening on http://localhost:3000");
219
+ app.listen(port, () => {
220
+ console.log(`Server listening on http://localhost:${port}`);
199
221
  });
200
222
  }
@@ -0,0 +1,10 @@
1
+ import type { UserRecord } from "firebase-admin/auth";
2
+
3
+ //# BATI.has("firebase-auth")
4
+ declare module "express" {
5
+ interface Request {
6
+ user?: UserRecord | null;
7
+ }
8
+ }
9
+
10
+ export {};
@@ -1 +1 @@
1
- export {};
1
+ import "dotenv/config";
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  "@batijs/compile": "workspace:*",
45
45
  "@types/node": "^18.19.14",
46
46
  dotenv: "^16.4.5",
47
- firebase: "^10.10.0",
47
+ firebase: "^10.11.0",
48
48
  "firebase-admin": "^12.0.0",
49
49
  firebaseui: "^6.1.0",
50
50
  vike: "^0.4.168",
@@ -62,9 +62,6 @@ var require_package = __commonJS({
62
62
  }
63
63
  },
64
64
  exports: {
65
- "./types": {
66
- types: "./dist/types/types.d.ts"
67
- },
68
65
  "./libs/firebaseAdmin": {
69
66
  types: "./dist/types/libs/firebaseAdmin.d.ts"
70
67
  },
@@ -83,9 +80,6 @@ var require_package = __commonJS({
83
80
  },
84
81
  typesVersions: {
85
82
  "*": {
86
- types: [
87
- "./dist/types/types.d.ts"
88
- ],
89
83
  "libs/firebaseAdmin": [
90
84
  "./dist/types/libs/firebaseAdmin.d.ts"
91
85
  ],
@@ -0,0 +1,20 @@
1
+ // files/firebase/$service-account.json.ts
2
+ async function getPackageJson() {
3
+ const firebaseAccountStringified = process.env.TEST_FIREBASE_ACCOUNT;
4
+ return firebaseAccountStringified ? JSON.parse(firebaseAccountStringified) : {
5
+ type: "",
6
+ project_id: "",
7
+ private_key_id: "",
8
+ private_key: "",
9
+ client_email: "",
10
+ client_id: "",
11
+ auth_uri: "",
12
+ token_uri: "",
13
+ auth_provider_x509_cert_url: "",
14
+ client_x509_cert_url: "",
15
+ universe_domain: ""
16
+ };
17
+ }
18
+ export {
19
+ getPackageJson as default
20
+ };
@@ -2,7 +2,8 @@
2
2
  import { deleteApp, getApp, getApps, initializeApp, type FirebaseApp } from "firebase/app";
3
3
  import { getAuth, inMemoryPersistence } from "firebase/auth";
4
4
 
5
- // Your web app's Firebase configuration
5
+ // TODO: Fill your web app's Firebase configuration
6
+ // See https://firebase.google.com/docs/web/learn-more?hl=fr#config-object
6
7
  const firebaseConfig = {
7
8
  apiKey: "",
8
9
  authDomain: "",
@@ -2,14 +2,6 @@ import type { UserRecord } from "firebase-admin/auth";
2
2
  import type { FirebaseApp } from "firebase/app";
3
3
 
4
4
  declare global {
5
- /*{ @if (it.BATI.has("express")) }*/
6
- // eslint-disable-next-line
7
- namespace Express {
8
- interface Request {
9
- user?: UserRecord | null;
10
- }
11
- }
12
- /*{ /if }*/
13
5
  // eslint-disable-next-line
14
6
  namespace Vike {
15
7
  interface PageContext {
@@ -21,5 +13,4 @@ declare global {
21
13
  }
22
14
  }
23
15
 
24
- // Tell TypeScript that this file isn't an ambient module
25
16
  export {};
@@ -41,14 +41,18 @@ var require_package = __commonJS({
41
41
  author: "",
42
42
  license: "MIT",
43
43
  devDependencies: {
44
- "@auth/core": "^0.28.2",
44
+ "@auth/core": "^0.29.0",
45
45
  "@batijs/compile": "workspace:*",
46
46
  "@batijs/firebase-auth": "workspace:*",
47
47
  "@batijs/trpc": "workspace:^",
48
48
  "@hattip/polyfills": "^0.0.45",
49
49
  "@trpc/server": "^10.45.2",
50
+ "@types/express": "^4.17.21",
50
51
  "@types/node": "^18.19.14",
51
52
  "@types/serve-static": "^1.15.7",
53
+ dotenv: "^16.4.5",
54
+ express: "^4.19.2",
55
+ "express-openid-connect": "^2.17.1",
52
56
  "firebase-admin": "^12.0.0",
53
57
  h3: "~1.11.1",
54
58
  "serve-static": "^1.15.0",
@@ -106,7 +110,10 @@ async function getPackageJson(props) {
106
110
  }
107
111
  });
108
112
  return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)), {
109
- devDependencies: ["@types/serve-static"],
113
+ devDependencies: [
114
+ "@types/serve-static",
115
+ ...props.meta.BATI.has("auth0") ? ["@types/express", "dotenv"] : []
116
+ ],
110
117
  dependencies: [
111
118
  "@hattip/polyfills",
112
119
  "h3",
@@ -114,7 +121,8 @@ async function getPackageJson(props) {
114
121
  "tsx",
115
122
  "vike",
116
123
  "vite",
117
- ...props.meta.BATI.has("authjs") ? ["@auth/core", "vike-authjs"] : []
124
+ ...props.meta.BATI.has("authjs") ? ["@auth/core", "vike-authjs"] : [],
125
+ ...props.meta.BATI.has("auth0") ? ["express", "express-openid-connect"] : []
118
126
  ]
119
127
  });
120
128
  }
@@ -1,3 +1,5 @@
1
+ // BATI.has("auth0")
2
+ import "dotenv/config";
1
3
  import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
2
4
  import { dirname } from "node:path";
3
5
  import { fileURLToPath } from "node:url";
@@ -8,7 +10,9 @@ import installCrypto from "@hattip/polyfills/crypto";
8
10
  import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
9
11
  import installWhatwgNodeFetch from "@hattip/polyfills/whatwg-node";
10
12
  import { nodeHTTPRequestHandler, type NodeHTTPCreateContextFnOptions } from "@trpc/server/adapters/node-http";
11
- import { getAuth, type UserRecord } from "firebase-admin/auth";
13
+ import express from "express";
14
+ import { auth, type ConfigParams } from "express-openid-connect";
15
+ import { getAuth } from "firebase-admin/auth";
12
16
  import {
13
17
  createApp,
14
18
  createRouter,
@@ -38,14 +42,8 @@ const __filename = fileURLToPath(import.meta.url);
38
42
  const __dirname = dirname(__filename);
39
43
  const isProduction = process.env.NODE_ENV === "production";
40
44
  const root = __dirname;
41
-
42
- /*{ @if (it.BATI.has("firebase-auth")) }*/
43
- declare module "h3" {
44
- interface H3EventContext {
45
- user: UserRecord | null;
46
- }
47
- }
48
- /*{ /if }*/
45
+ const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
46
+ const hmrPort = process.env.HMR_PORT ? parseInt(process.env.HMR_PORT, 10) : 24678;
49
47
 
50
48
  startServer();
51
49
 
@@ -62,7 +60,7 @@ async function startServer() {
62
60
  const viteDevMiddleware = (
63
61
  await vite.createServer({
64
62
  root,
65
- server: { middlewareMode: true },
63
+ server: { middlewareMode: true, hmr: { port: hmrPort } },
66
64
  })
67
65
  ).middlewares;
68
66
  app.use(fromNodeMiddleware(viteDevMiddleware));
@@ -122,7 +120,7 @@ async function startServer() {
122
120
  const user = await auth.getUser(decodedIdToken.sub);
123
121
  event.context.user = user;
124
122
  } catch (error) {
125
- console.error("verifySessionCookie:", error);
123
+ console.debug("verifySessionCookie:", error);
126
124
  event.context.user = null;
127
125
  }
128
126
  }
@@ -176,6 +174,23 @@ async function startServer() {
176
174
  );
177
175
  }
178
176
 
177
+ if (BATI.has("auth0")) {
178
+ const config: ConfigParams = {
179
+ authRequired: false, // Controls whether authentication is required for all routes
180
+ auth0Logout: true, // Uses Auth0 logout feature
181
+ baseURL: process.env.BASE_URL?.startsWith("http") ? process.env.BASE_URL : `http://localhost:${port}`, // The URL where the application is served
182
+ routes: {
183
+ login: "/api/auth/login", // Custom login route, default is "/login"
184
+ logout: "/api/auth/logout", // Custom logout route, default is "/logout"
185
+ callback: "/api/auth/callback", // Custom callback route, default is "/callback"
186
+ },
187
+ };
188
+
189
+ const expressApp = express();
190
+
191
+ app.use(fromNodeMiddleware(expressApp.use(auth(config))));
192
+ }
193
+
179
194
  if (BATI.has("trpc")) {
180
195
  /**
181
196
  * tRPC route
@@ -234,12 +249,18 @@ async function startServer() {
234
249
  router.use(
235
250
  "/**",
236
251
  eventHandler(async (event) => {
237
- const pageContextInit = BATI.has("firebase-auth")
252
+ const pageContextInit = BATI.has("auth0")
238
253
  ? {
239
254
  urlOriginal: event.node.req.originalUrl || event.node.req.url!,
240
- user: event.context.user,
255
+ user: event.node.req.oidc.user,
241
256
  }
242
- : { urlOriginal: event.node.req.originalUrl || event.node.req.url! };
257
+ : BATI.has("firebase-auth")
258
+ ? {
259
+ urlOriginal: event.node.req.originalUrl || event.node.req.url!,
260
+ user: event.context.user,
261
+ }
262
+ : { urlOriginal: event.node.req.originalUrl || event.node.req.url! };
263
+
243
264
  const pageContext = await renderPage(pageContextInit);
244
265
  const response = pageContext.httpResponse;
245
266
 
@@ -252,9 +273,9 @@ async function startServer() {
252
273
 
253
274
  app.use(router);
254
275
 
255
- const server = createServer(toNodeListener(app)).listen(process.env.PORT || 3000);
276
+ const server = createServer(toNodeListener(app)).listen(port);
256
277
 
257
278
  server.on("listening", () => {
258
- console.log(`Server listening on http://localhost:${process.env.PORT || 3000}`);
279
+ console.log(`Server listening on http://localhost:${port}`);
259
280
  });
260
281
  }
@@ -0,0 +1,22 @@
1
+ import type { RequestContext, ResponseContext } from "express-openid-connect";
2
+ import type { UserRecord } from "firebase-admin/auth";
3
+
4
+ //# BATI.has("auth0")
5
+ declare module "node:http" {
6
+ interface IncomingMessage {
7
+ oidc: RequestContext;
8
+ }
9
+
10
+ interface ServerResponse {
11
+ oidc: ResponseContext;
12
+ }
13
+ }
14
+
15
+ //# BATI.has("firebase-auth")
16
+ declare module "h3" {
17
+ interface H3EventContext {
18
+ user: UserRecord | null;
19
+ }
20
+ }
21
+
22
+ export {};
@@ -1,6 +1 @@
1
- import { type UserRecord } from "firebase-admin/auth";
2
- declare module "h3" {
3
- interface H3EventContext {
4
- user: UserRecord | null;
5
- }
6
- }
1
+ import "dotenv/config";
@@ -41,7 +41,7 @@ var require_package = __commonJS({
41
41
  author: "",
42
42
  license: "MIT",
43
43
  devDependencies: {
44
- "@auth/core": "^0.28.2",
44
+ "@auth/core": "^0.29.0",
45
45
  "@batijs/compile": "workspace:*",
46
46
  "@batijs/trpc": "workspace:^",
47
47
  "@hattip/adapter-node": "^0.0.45",
@@ -46,15 +46,15 @@ var require_package = __commonJS({
46
46
  "@babel/plugin-transform-react-jsx": "^7.23.4",
47
47
  "@batijs/compile": "workspace:*",
48
48
  "@types/node": "^18.19.14",
49
- "@types/react": "^18.2.74",
50
- "@types/react-dom": "^18.2.24",
49
+ "@types/react": "^18.2.78",
50
+ "@types/react-dom": "^18.2.25",
51
51
  "@vitejs/plugin-react": "^4.2.1",
52
52
  "cross-fetch": "^4.0.0",
53
53
  "eslint-plugin-react": "^7.34.1",
54
54
  react: "^18.2.0",
55
55
  "react-dom": "^18.2.0",
56
56
  tailwindcss: "^3.4.3",
57
- typescript: "^5.4.4",
57
+ typescript: "^5.4.5",
58
58
  vike: "^0.4.168",
59
59
  "vike-react": "^0.4.6",
60
60
  vite: "^5.2.8"
@@ -7,7 +7,7 @@ import Layout from "../layouts/LayoutDefault";
7
7
  export default {
8
8
  Layout,
9
9
  Head,
10
- /*{ @if (it.BATI.has("firebase-auth")) }*/
10
+ /*{ @if (it.BATI.has("auth0") || it.BATI.has("firebase-auth")) }*/
11
11
  passToClient: ["user"],
12
12
  /*{ /if }*/
13
13
  // <title>
@@ -11,7 +11,7 @@
11
11
  "keywords": [],
12
12
  "author": "",
13
13
  "devDependencies": {
14
- "typescript": "^5.4.4",
14
+ "typescript": "^5.4.5",
15
15
  "vike": "^0.4.168",
16
16
  "vite": "^5.2.8"
17
17
  },
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  "eslint-plugin-solid": "^0.13.2",
48
48
  "solid-js": "^1.8.16",
49
49
  tailwindcss: "^3.4.3",
50
- typescript: "^5.4.4",
50
+ typescript: "^5.4.5",
51
51
  vike: "^0.4.168",
52
52
  "vike-solid": "^0.4.3",
53
53
  vite: "^5.2.8",
@@ -8,7 +8,7 @@ export default {
8
8
  Layout,
9
9
  Head,
10
10
  // <title>
11
- /*{ @if (it.BATI.has("firebase-auth")) }*/
11
+ /*{ @if (it.BATI.has("auth0") || it.BATI.has("firebase-auth")) }*/
12
12
  passToClient: ["user"],
13
13
  /*{ /if }*/
14
14
  title: "My Vike App",
@@ -47,10 +47,10 @@ var require_package = __commonJS({
47
47
  "@vue/compiler-sfc": "^3.4.21",
48
48
  "@vue/server-renderer": "^3.4.21",
49
49
  "cross-fetch": "^4.0.0",
50
- "eslint-plugin-vue": "^9.24.1",
50
+ "eslint-plugin-vue": "^9.25.0",
51
51
  tailwindcss: "^3.4.3",
52
- typescript: "^5.4.4",
53
- "unplugin-vue-markdown": "^0.26.0",
52
+ typescript: "^5.4.5",
53
+ "unplugin-vue-markdown": "^0.26.1",
54
54
  vike: "^0.4.168",
55
55
  "vike-vue": "^0.6.3",
56
56
  vite: "^5.2.8",
@@ -8,7 +8,7 @@ export default {
8
8
  Layout,
9
9
  Head,
10
10
  // <title>
11
- /*{ @if (it.BATI.has("firebase-auth")) }*/
11
+ /*{ @if (it.BATI.has("auth0") || it.BATI.has("firebase-auth")) }*/
12
12
  passToClient: ["user"],
13
13
  /*{ /if }*/
14
14
  title: "My Vike App",
@@ -1,4 +1,15 @@
1
1
  [
2
+ {
3
+ "config": {
4
+ "if": {
5
+ "flag": "auth0"
6
+ }
7
+ },
8
+ "folder": "@batijs/auth0",
9
+ "subfolders": [
10
+ "files"
11
+ ]
12
+ },
2
13
  {
3
14
  "config": {
4
15
  "if": {
package/dist/index.js CHANGED
@@ -457,9 +457,40 @@ async function runMain(cmd, opts = {}) {
457
457
 
458
458
  // ../build/dist/index.js
459
459
  import { existsSync } from "fs";
460
- import { mkdir, opendir, readFile, writeFile } from "fs/promises";
460
+ import { mkdir, opendir, readFile as readFile2, writeFile } from "fs/promises";
461
461
  import path from "path";
462
- import { transformAndFormat } from "@batijs/core";
462
+ import { transformAndFormat as transformAndFormat2 } from "@batijs/core";
463
+ import { readFile } from "fs/promises";
464
+ import { parseModule, transformAndFormat } from "@batijs/core";
465
+ async function mergeDts({
466
+ target,
467
+ fileContent,
468
+ filepath,
469
+ meta
470
+ }) {
471
+ const previousCode = await readFile(target, { encoding: "utf-8" });
472
+ const previousAst = parseModule(previousCode);
473
+ const currentAst = parseModule(fileContent);
474
+ for (const imp of previousAst.imports.$items) {
475
+ currentAst.imports[imp.local] = imp;
476
+ }
477
+ const index = currentAst.$ast.body.findIndex(
478
+ (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
479
+ );
480
+ for (const node of previousAst.$ast.body) {
481
+ if (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
482
+ continue;
483
+ }
484
+ if (index === -1) {
485
+ currentAst.$ast.body.push(node);
486
+ } else {
487
+ currentAst.$ast.body.splice(index, 0, node);
488
+ }
489
+ }
490
+ return transformAndFormat(currentAst.generate().code, meta, {
491
+ filepath
492
+ });
493
+ }
463
494
  function queue() {
464
495
  const tasks = [];
465
496
  return {
@@ -535,7 +566,7 @@ async function importTransformer(p) {
535
566
  async function main(options, meta) {
536
567
  const sources = Array.isArray(options.source) ? options.source : [options.source];
537
568
  const targets = /* @__PURE__ */ new Set();
538
- const simpleCopyQ = queue();
569
+ const priorityQ = queue();
539
570
  const transformAndWriteQ = queue();
540
571
  for (const source of sources) {
541
572
  for await (const p of walk(source)) {
@@ -546,13 +577,13 @@ async function main(options, meta) {
546
577
  } else if (parsed.name.startsWith("$") && parsed.ext.match(/\.tsx?$/)) {
547
578
  throw new Error(
548
579
  `Typescript file needs to be compiled before it can be executed: '${p}'.
549
- Please report this issue to https://github.com/magne4000/bati`
580
+ Please report this issue to https://github.com/batijs/bati`
550
581
  );
551
582
  } else if (parsed.name.startsWith("$") && parsed.ext.match(/\.jsx?$/)) {
552
583
  transformAndWriteQ.add(async () => {
553
584
  const transformer = await importTransformer(p);
554
585
  const rf = () => {
555
- return readFile(target, { encoding: "utf-8" });
586
+ return readFile2(target, { encoding: "utf-8" });
556
587
  };
557
588
  const fileContent = transformFileAfterExec(
558
589
  target,
@@ -569,27 +600,36 @@ Please report this issue to https://github.com/magne4000/bati`
569
600
  }
570
601
  });
571
602
  } else {
572
- transformAndWriteQ.add(async () => {
573
- const code = await readFile(p, { encoding: "utf-8" });
574
- const fileContent = await transformAndFormat(code, meta, {
575
- filepath: path.relative(source, p)
603
+ priorityQ.add(async () => {
604
+ const code = await readFile2(p, { encoding: "utf-8" });
605
+ const filepath = path.relative(source, p);
606
+ let fileContent = await transformAndFormat2(code, meta, {
607
+ filepath
576
608
  });
609
+ if (p.endsWith(".d.ts") && targets.has(target)) {
610
+ fileContent = await mergeDts({
611
+ fileContent,
612
+ target,
613
+ meta,
614
+ filepath
615
+ });
616
+ }
577
617
  if (fileContent) {
578
- await safeWriteFile(target, fileContent);
618
+ await safeWriteFile(target, fileContent.trimStart());
579
619
  targets.add(target);
580
620
  }
581
621
  });
582
622
  }
583
623
  }
584
624
  }
585
- await simpleCopyQ.run();
625
+ await priorityQ.run();
586
626
  await transformAndWriteQ.run();
587
627
  }
588
628
 
589
629
  // package.json
590
630
  var package_default = {
591
631
  name: "@batijs/cli",
592
- version: "0.0.175",
632
+ version: "0.0.177",
593
633
  type: "module",
594
634
  scripts: {
595
635
  "check-types": "tsc --noEmit",
@@ -612,9 +652,9 @@ var package_default = {
612
652
  esbuild: "^0.20.2",
613
653
  execa: "^8.0.1",
614
654
  rimraf: "^5.0.5",
615
- sift: "^17.1.0",
655
+ sift: "^17.1.2",
616
656
  tsup: "^8.0.2",
617
- typescript: "^5.4.4",
657
+ typescript: "^5.4.5",
618
658
  vite: "^5.2.8"
619
659
  },
620
660
  dependencies: {
@@ -637,7 +677,7 @@ import { execRules } from "@batijs/features/rules";
637
677
  import { existsSync as existsSync2 } from "fs";
638
678
  import { fileURLToPath } from "url";
639
679
  import { dirname, join, parse } from "path";
640
- import { access, constants, lstat, readdir, readFile as readFile2 } from "fs/promises";
680
+ import { access, constants, lstat, readdir, readFile as readFile3 } from "fs/promises";
641
681
 
642
682
  // ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
643
683
  import * as tty from "tty";
@@ -780,7 +820,7 @@ var rulesMessages = {
780
820
  [RulesMessage.INFO_HATTIP]: info(`${inverse(bold("HatTip"))} is an experimental project`)
781
821
  };
782
822
 
783
- // ../../node_modules/.pnpm/sift@17.1.0/node_modules/sift/es5m/index.js
823
+ // ../../node_modules/.pnpm/sift@17.1.2/node_modules/sift/es5m/index.js
784
824
  var extendStatics = function(d, b) {
785
825
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
786
826
  d2.__proto__ = b2;
@@ -825,6 +865,9 @@ var coercePotentiallyNull = function(value) {
825
865
  var isArray = typeChecker("Array");
826
866
  var isObject = typeChecker("Object");
827
867
  var isFunction = typeChecker("Function");
868
+ var isProperty = function(item, key) {
869
+ return item.hasOwnProperty(key) && !isFunction(item[key]);
870
+ };
828
871
  var isVanillaObject = function(value) {
829
872
  return value && (value.constructor === Object || value.constructor === Array || value.constructor.toString() === "function Object() { [native code] }" || value.constructor.toString() === "function Array() { [native code] }") && !value.toJSON;
830
873
  };
@@ -861,7 +904,7 @@ var equals = function(a, b) {
861
904
  };
862
905
  var walkKeyPathValues = function(item, keyPath, next, depth, key, owner) {
863
906
  var currentKey = keyPath[depth];
864
- if (isArray(item) && isNaN(Number(currentKey))) {
907
+ if (isArray(item) && isNaN(Number(currentKey)) && !isProperty(item, currentKey)) {
865
908
  for (var i = 0, length_1 = item.length; i < length_1; i++) {
866
909
  if (!walkKeyPathValues(item[i], keyPath, next, depth, i, item)) {
867
910
  return false;
@@ -1042,7 +1085,7 @@ var createNamedOperation = function(name, params, parentQuery, options) {
1042
1085
  return operationCreator(params, parentQuery, options, name);
1043
1086
  };
1044
1087
  var throwUnsupportedOperation = function(name) {
1045
- throw new Error("Unsupported operation: " + name);
1088
+ throw new Error("Unsupported operation: ".concat(name));
1046
1089
  };
1047
1090
  var containsOperation = function(query, options) {
1048
1091
  for (var key in query) {
@@ -1095,7 +1138,7 @@ var createQueryOperations = function(query, parentKey, options) {
1095
1138
  var op = createNamedOperation(key, query[key], query, options);
1096
1139
  if (op) {
1097
1140
  if (!op.propop && parentKey && !options.operations[parentKey]) {
1098
- throw new Error("Malformed query. " + key + " cannot be matched against property.");
1141
+ throw new Error("Malformed query. ".concat(key, " cannot be matched against property."));
1099
1142
  }
1100
1143
  }
1101
1144
  if (op != null) {
@@ -1297,7 +1340,7 @@ var $In = (
1297
1340
  var params = Array.isArray(this.params) ? this.params : [this.params];
1298
1341
  this._testers = params.map(function(value) {
1299
1342
  if (containsOperation(value, _this.options)) {
1300
- throw new Error("cannot nest $ under " + _this.name.toLowerCase());
1343
+ throw new Error("cannot nest $ under ".concat(_this.name.toLowerCase()));
1301
1344
  }
1302
1345
  return createTester(value, _this.options.compare);
1303
1346
  });
@@ -1522,26 +1565,26 @@ var $where = function(params, ownerQuery, options) {
1522
1565
  var defaultOperations = /* @__PURE__ */ Object.freeze({
1523
1566
  __proto__: null,
1524
1567
  $Size,
1525
- $eq,
1526
- $ne,
1527
- $or,
1528
- $nor,
1568
+ $all,
1569
+ $and,
1529
1570
  $elemMatch,
1530
- $nin,
1571
+ $eq,
1572
+ $exists,
1573
+ $gt,
1574
+ $gte,
1531
1575
  $in,
1532
1576
  $lt,
1533
1577
  $lte,
1534
- $gt,
1535
- $gte,
1536
1578
  $mod,
1537
- $exists,
1538
- $regex,
1579
+ $ne,
1580
+ $nin,
1581
+ $nor,
1539
1582
  $not,
1540
- $type,
1541
- $and,
1542
- $all,
1543
- $size,
1544
1583
  $options,
1584
+ $or,
1585
+ $regex,
1586
+ $size,
1587
+ $type,
1545
1588
  $where
1546
1589
  });
1547
1590
  var createDefaultQueryOperation = function(query, ownerQuery, _a) {
@@ -1572,7 +1615,7 @@ function boilerplatesDir() {
1572
1615
  throw new Error("Missing boilerplates.json file. Run `pnpm run build`");
1573
1616
  }
1574
1617
  async function parseBoilerplates(dir) {
1575
- return JSON.parse(await readFile2(join(dir, "boilerplates.json"), "utf-8"));
1618
+ return JSON.parse(await readFile3(join(dir, "boilerplates.json"), "utf-8"));
1576
1619
  }
1577
1620
  function toArg(flag, description) {
1578
1621
  if (!flag)
@@ -1799,21 +1842,3 @@ run().then(() => {
1799
1842
  export {
1800
1843
  yn as default
1801
1844
  };
1802
- /*! Bundled license information:
1803
-
1804
- sift/es5m/index.js:
1805
- (*! *****************************************************************************
1806
- Copyright (c) Microsoft Corporation.
1807
-
1808
- Permission to use, copy, modify, and/or distribute this software for any
1809
- purpose with or without fee is hereby granted.
1810
-
1811
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1812
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1813
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1814
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1815
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1816
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1817
- PERFORMANCE OF THIS SOFTWARE.
1818
- ***************************************************************************** *)
1819
- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@batijs/cli",
3
- "version": "0.0.175",
3
+ "version": "0.0.177",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "description": "Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want",
@@ -15,16 +15,16 @@
15
15
  "esbuild": "^0.20.2",
16
16
  "execa": "^8.0.1",
17
17
  "rimraf": "^5.0.5",
18
- "sift": "^17.1.0",
18
+ "sift": "^17.1.2",
19
19
  "tsup": "^8.0.2",
20
- "typescript": "^5.4.4",
20
+ "typescript": "^5.4.5",
21
21
  "vite": "^5.2.8",
22
- "@batijs/build": "0.0.175",
23
- "@batijs/compile": "0.0.175"
22
+ "@batijs/build": "0.0.177",
23
+ "@batijs/compile": "0.0.177"
24
24
  },
25
25
  "dependencies": {
26
- "@batijs/core": "0.0.175",
27
- "@batijs/features": "0.0.175"
26
+ "@batijs/core": "0.0.177",
27
+ "@batijs/features": "0.0.177"
28
28
  },
29
29
  "bin": "./dist/index.js",
30
30
  "exports": {
@@ -1,13 +0,0 @@
1
- {
2
- "type": "",
3
- "project_id": "",
4
- "private_key_id": "",
5
- "private_key": "",
6
- "client_email": "",
7
- "client_id": "",
8
- "auth_uri": "",
9
- "token_uri": "",
10
- "auth_provider_x509_cert_url": "",
11
- "client_x509_cert_url": "",
12
- "universe_domain": ""
13
- }
@@ -1,18 +0,0 @@
1
- import type { UserRecord } from "firebase-admin/auth";
2
- import type { FirebaseApp } from "firebase/app";
3
- declare global {
4
- namespace Express {
5
- interface Request {
6
- user?: UserRecord | null;
7
- }
8
- }
9
- namespace Vike {
10
- interface PageContext {
11
- user?: UserRecord | null;
12
- }
13
- interface Config {
14
- firebaseApp?: FirebaseApp;
15
- }
16
- }
17
- }
18
- export {};