nuxt-users 1.34.6 → 1.34.7

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/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.34.7
5
+
6
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.34.6...v1.34.7)
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - Scopes CSS rules to nuxt-users components ([fa98529](https://github.com/rrd108/nuxt-users/commit/fa98529))
11
+ - Prevents database connection issues during build ([b80e6c7](https://github.com/rrd108/nuxt-users/commit/b80e6c7))
12
+
13
+ ### 📖 Documentation
14
+
15
+ - Fix github link ([3bc8e96](https://github.com/rrd108/nuxt-users/commit/3bc8e96))
16
+
17
+ ### 🏡 Chore
18
+
19
+ - **release:** V1.34.6 ([b84a188](https://github.com/rrd108/nuxt-users/commit/b84a188))
20
+ - Lint fix ([5cfb830](https://github.com/rrd108/nuxt-users/commit/5cfb830))
21
+
22
+ ### ❤️ Contributors
23
+
24
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
25
+
4
26
  ## v1.34.6
5
27
 
6
28
  [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.34.5...v1.34.6)
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
3
  "configKey": "nuxtUsers",
4
- "version": "1.34.6",
4
+ "version": "1.34.7",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -208,6 +208,14 @@ const module = defineNuxtModule({
208
208
  nitroConfig.experimental.tasks = true;
209
209
  nitroConfig.scanDirs = nitroConfig.scanDirs || [];
210
210
  nitroConfig.scanDirs.push(resolver.resolve("./runtime/server/tasks"));
211
+ nitroConfig.prerender = nitroConfig.prerender || {};
212
+ nitroConfig.prerender.ignore = nitroConfig.prerender.ignore || [];
213
+ const apiBasePath = nuxt.options.runtimeConfig.nuxtUsers.apiBasePath || defaultOptions.apiBasePath;
214
+ const ignorePattern = `${apiBasePath}/**`;
215
+ if (!nitroConfig.prerender.ignore.includes(ignorePattern)) {
216
+ nitroConfig.prerender.ignore.push(ignorePattern);
217
+ console.log(`[Nuxt Users] \u{1F527} Automatically excluding "${ignorePattern}" from prerendering to prevent build hangs`);
218
+ }
211
219
  });
212
220
  addComponentsDir({
213
221
  path: resolver.resolve("./runtime/components"),
@@ -1,10 +1,18 @@
1
1
  import { defineNuxtPlugin, useRuntimeConfig } from "#app";
2
- import { checkTableExists } from "./server/utils/index.js";
2
+ import { checkTableExists, isBuildTime } from "./server/utils/index.js";
3
3
  export default defineNuxtPlugin(async (_nuxtApp) => {
4
4
  const { nuxtUsers } = useRuntimeConfig();
5
5
  const options = nuxtUsers;
6
- const hasMigrationsTable = await checkTableExists(options, options.tables.migrations);
7
- if (!hasMigrationsTable) {
8
- console.warn("[Nuxt Users] \u26A0\uFE0F Migrations table does not exist, you should run the migration script to create it by running: npx nuxt-users migrate");
6
+ if (isBuildTime()) {
7
+ console.log("[Nuxt Users] \u{1F527} Build-time detected, skipping database connection checks");
8
+ return;
9
+ }
10
+ try {
11
+ const hasMigrationsTable = await checkTableExists(options, options.tables.migrations);
12
+ if (!hasMigrationsTable) {
13
+ console.warn("[Nuxt Users] \u26A0\uFE0F Migrations table does not exist, you should run the migration script to create it by running: npx nuxt-users migrate");
14
+ }
15
+ } catch (error) {
16
+ console.warn("[Nuxt Users] \u26A0\uFE0F Database connection failed during initialization:", error instanceof Error ? error.message : "Unknown error");
9
17
  }
10
18
  });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detects if we're running during build/prerendering phase
3
+ * During prerendering, Nuxt starts a temporary server that should not connect to the database
4
+ */
5
+ export declare const isBuildTime: () => boolean;
@@ -0,0 +1,12 @@
1
+ export const isBuildTime = () => {
2
+ if (process.env.NITRO_PRESET === "nitro-prerender" || process.env.NUXT_ENV === "prerender") {
3
+ return true;
4
+ }
5
+ if (process.env.NODE_ENV === "production" && process.argv.includes("--prerender")) {
6
+ return true;
7
+ }
8
+ const buildIndicators = ["prerender", "build", "generate"];
9
+ return buildIndicators.some(
10
+ (indicator) => process.argv.join(" ").toLowerCase().includes(indicator) || process.env.npm_lifecycle_event?.includes(indicator)
11
+ );
12
+ };
@@ -1,4 +1,5 @@
1
1
  import { createDatabase } from "db0";
2
+ import { isBuildTime } from "./build-time.js";
2
3
  const dbCache = /* @__PURE__ */ new Map();
3
4
  export const closeAllDbConnections = async () => {
4
5
  for (const db of dbCache.values()) {
@@ -31,6 +32,9 @@ export const getConnector = async (name) => {
31
32
  }
32
33
  };
33
34
  export const useDb = async (options) => {
35
+ if (isBuildTime()) {
36
+ throw new Error("[Nuxt Users] Database connections are not available during build/prerendering phase. This should not happen - please check your prerender configuration.");
37
+ }
34
38
  const cacheKey = JSON.stringify(options.connector);
35
39
  if (dbCache.has(cacheKey)) {
36
40
  return dbCache.get(cacheKey);
@@ -1,4 +1,5 @@
1
1
  export { useDb, checkTableExists } from './db.js';
2
+ export { isBuildTime } from './build-time.js';
2
3
  export { createUser, findUserByEmail, updateUserPassword, getCurrentUserFromToken, hasAnyUsers, deleteExpiredPersonalAccessTokens, deleteTokensWithoutExpiration, cleanupPersonalAccessTokens, revokeUserTokens, getLastLoginTime, findUserById, updateUser, deleteUser } from './user.js';
3
4
  export { createUsersTable } from './create-users-table.js';
4
5
  export { createPersonalAccessTokensTable } from './create-personal-access-tokens-table.js';
@@ -1,4 +1,5 @@
1
1
  export { useDb, checkTableExists } from "./db.js";
2
+ export { isBuildTime } from "./build-time.js";
2
3
  export { createUser, findUserByEmail, updateUserPassword, getCurrentUserFromToken, hasAnyUsers, deleteExpiredPersonalAccessTokens, deleteTokensWithoutExpiration, cleanupPersonalAccessTokens, revokeUserTokens, getLastLoginTime, findUserById, updateUser, deleteUser } from "./user.js";
3
4
  export { createUsersTable } from "./create-users-table.js";
4
5
  export { createPersonalAccessTokensTable } from "./create-personal-access-tokens-table.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.34.6",
3
+ "version": "1.34.7",
4
4
  "description": "A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools",
5
5
  "keywords": [
6
6
  "nuxt",