nuxt-users 1.1.4 → 1.1.6
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 +50 -0
- package/dist/cli.mjs +29 -23
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -10
- package/dist/runtime/plugin.js +1 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v1.1.6
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.1.5...v1.1.6)
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
- **deps:** Exclude bcrypt from client-side bundle ([a678a96](https://github.com/rrd108/nuxt-users/commit/a678a96))
|
|
11
|
+
- **cli:** Exits process after successful user creation ([d71b779](https://github.com/rrd108/nuxt-users/commit/d71b779))
|
|
12
|
+
- Remove db releated code from client code ([114d360](https://github.com/rrd108/nuxt-users/commit/114d360))
|
|
13
|
+
|
|
14
|
+
### 💅 Refactors
|
|
15
|
+
|
|
16
|
+
- **cli:** Commands to load options ([403a281](https://github.com/rrd108/nuxt-users/commit/403a281))
|
|
17
|
+
|
|
18
|
+
### 🏡 Chore
|
|
19
|
+
|
|
20
|
+
- **release:** V1.1.5 ([98ab3d1](https://github.com/rrd108/nuxt-users/commit/98ab3d1))
|
|
21
|
+
|
|
22
|
+
### 🤖 CI
|
|
23
|
+
|
|
24
|
+
- Adds Nuxt 4 compatibility tests ([4132d86](https://github.com/rrd108/nuxt-users/commit/4132d86))
|
|
25
|
+
|
|
26
|
+
### ❤️ Contributors
|
|
27
|
+
|
|
28
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
29
|
+
|
|
30
|
+
## v1.1.5
|
|
31
|
+
|
|
32
|
+
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.1.4...v1.1.5)
|
|
33
|
+
|
|
34
|
+
### 🩹 Fixes
|
|
35
|
+
|
|
36
|
+
- **deps:** Exclude bcrypt from client-side bundle ([a678a96](https://github.com/rrd108/nuxt-users/commit/a678a96))
|
|
37
|
+
|
|
38
|
+
### 💅 Refactors
|
|
39
|
+
|
|
40
|
+
- **cli:** Commands to load options ([403a281](https://github.com/rrd108/nuxt-users/commit/403a281))
|
|
41
|
+
|
|
42
|
+
### 🏡 Chore
|
|
43
|
+
|
|
44
|
+
- **release:** V1.1.4 ([4980c98](https://github.com/rrd108/nuxt-users/commit/4980c98))
|
|
45
|
+
|
|
46
|
+
### ✅ Tests
|
|
47
|
+
|
|
48
|
+
- Ensures database cleanup on test completion ([a1a528c](https://github.com/rrd108/nuxt-users/commit/a1a528c))
|
|
49
|
+
|
|
50
|
+
### ❤️ Contributors
|
|
51
|
+
|
|
52
|
+
- Rrd108 ([@rrd108](https://github.com/rrd108))
|
|
53
|
+
|
|
4
54
|
## v1.1.4
|
|
5
55
|
|
|
6
56
|
[compare changes](https://github.com/rrd108/nuxt-users/compare/v1.1.0...v1.1.4)
|
package/dist/cli.mjs
CHANGED
|
@@ -70,6 +70,25 @@ const getOptionsFromEnv = () => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
+
const loadOptions = async () => {
|
|
74
|
+
try {
|
|
75
|
+
console.log("[Nuxt Users] Loading Nuxt project...");
|
|
76
|
+
const nuxt = await loadNuxt({ cwd: process.cwd() });
|
|
77
|
+
const nuxtUsersConfig = nuxt.options.runtimeConfig?.nuxtUsers;
|
|
78
|
+
await nuxt.close();
|
|
79
|
+
if (nuxtUsersConfig) {
|
|
80
|
+
console.log("[Nuxt Users] Using configuration from Nuxt project");
|
|
81
|
+
return nuxtUsersConfig;
|
|
82
|
+
} else {
|
|
83
|
+
console.log("[Nuxt Users] No nuxt-users configuration found, using environment variables");
|
|
84
|
+
return getOptionsFromEnv();
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.log("[Nuxt Users] Could not load Nuxt project, using environment variables");
|
|
88
|
+
console.error(error);
|
|
89
|
+
return getOptionsFromEnv();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
73
92
|
|
|
74
93
|
const migrate = defineCommand({
|
|
75
94
|
meta: {
|
|
@@ -78,24 +97,7 @@ const migrate = defineCommand({
|
|
|
78
97
|
},
|
|
79
98
|
async run() {
|
|
80
99
|
console.log("[Nuxt Users] Starting migration system...");
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
console.log("[Nuxt Users] Loading Nuxt project...");
|
|
84
|
-
const nuxt = await loadNuxt({ cwd: process.cwd() });
|
|
85
|
-
const nuxtUsersConfig = nuxt.options.runtimeConfig?.nuxtUsers;
|
|
86
|
-
await nuxt.close();
|
|
87
|
-
if (nuxtUsersConfig) {
|
|
88
|
-
console.log("[Nuxt Users] Using configuration from Nuxt project");
|
|
89
|
-
options = nuxtUsersConfig;
|
|
90
|
-
} else {
|
|
91
|
-
console.log("[Nuxt Users] No nuxt-users configuration found, using environment variables");
|
|
92
|
-
options = getOptionsFromEnv();
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.log("[Nuxt Users] Could not load Nuxt project, using environment variables");
|
|
96
|
-
console.error(error);
|
|
97
|
-
options = getOptionsFromEnv();
|
|
98
|
-
}
|
|
100
|
+
const options = await loadOptions();
|
|
99
101
|
try {
|
|
100
102
|
await runMigrations(options);
|
|
101
103
|
console.log("[Nuxt Users] Migration completed successfully!");
|
|
@@ -114,16 +116,19 @@ const createUser = defineCommand({
|
|
|
114
116
|
},
|
|
115
117
|
args: {
|
|
116
118
|
email: {
|
|
119
|
+
alias: "e",
|
|
117
120
|
type: "string",
|
|
118
121
|
description: "User email address",
|
|
119
122
|
required: true
|
|
120
123
|
},
|
|
121
124
|
name: {
|
|
125
|
+
alias: "n",
|
|
122
126
|
type: "string",
|
|
123
127
|
description: "User full name",
|
|
124
128
|
required: true
|
|
125
129
|
},
|
|
126
130
|
password: {
|
|
131
|
+
alias: "p",
|
|
127
132
|
type: "string",
|
|
128
133
|
description: "User password",
|
|
129
134
|
required: true
|
|
@@ -131,10 +136,11 @@ const createUser = defineCommand({
|
|
|
131
136
|
},
|
|
132
137
|
async run({ args }) {
|
|
133
138
|
const { email, name, password } = args;
|
|
134
|
-
const options =
|
|
139
|
+
const options = await loadOptions();
|
|
135
140
|
try {
|
|
136
141
|
const user = await createUser$1({ email, name, password }, options);
|
|
137
142
|
console.log(`[DB:Create User] User created successfully: ${user.email}`);
|
|
143
|
+
process.exit(0);
|
|
138
144
|
} catch (error) {
|
|
139
145
|
console.error("[DB:Create User] Error:", error);
|
|
140
146
|
process.exit(1);
|
|
@@ -149,7 +155,7 @@ const createUsersTable = defineCommand({
|
|
|
149
155
|
},
|
|
150
156
|
async run() {
|
|
151
157
|
console.log("[Nuxt Users] Creating users table...");
|
|
152
|
-
const options =
|
|
158
|
+
const options = await loadOptions();
|
|
153
159
|
try {
|
|
154
160
|
await createUsersTable$1(options);
|
|
155
161
|
console.log("[Nuxt Users] Users table created successfully!");
|
|
@@ -167,7 +173,7 @@ const createPersonalAccessTokensTable = defineCommand({
|
|
|
167
173
|
},
|
|
168
174
|
async run() {
|
|
169
175
|
console.log("[Nuxt Users] Creating personal access tokens table...");
|
|
170
|
-
const options =
|
|
176
|
+
const options = await loadOptions();
|
|
171
177
|
try {
|
|
172
178
|
await createPersonalAccessTokensTable$1(options);
|
|
173
179
|
console.log("[Nuxt Users] Personal access tokens table created successfully!");
|
|
@@ -185,7 +191,7 @@ const createPasswordResetTokensTable = defineCommand({
|
|
|
185
191
|
},
|
|
186
192
|
async run() {
|
|
187
193
|
console.log("[Nuxt Users] Creating password reset tokens table...");
|
|
188
|
-
const options =
|
|
194
|
+
const options = await loadOptions();
|
|
189
195
|
try {
|
|
190
196
|
await createPasswordResetTokensTable$1(options);
|
|
191
197
|
console.log("[Nuxt Users] Password reset tokens table created successfully!");
|
|
@@ -203,7 +209,7 @@ const createMigrationsTable = defineCommand({
|
|
|
203
209
|
},
|
|
204
210
|
async run() {
|
|
205
211
|
console.log("[Nuxt Users] Creating migrations table...");
|
|
206
|
-
const options =
|
|
212
|
+
const options = await loadOptions();
|
|
207
213
|
try {
|
|
208
214
|
await createMigrationsTable$1(options);
|
|
209
215
|
console.log("[Nuxt Users] Migrations table created successfully!");
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -49,16 +49,10 @@ const module = defineNuxtModule({
|
|
|
49
49
|
passwordResetTokens: options.tables?.passwordResetTokens || "password_reset_tokens"
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
users: options.tables?.users,
|
|
57
|
-
personalAccessTokens: options.tables?.personalAccessTokens,
|
|
58
|
-
passwordResetTokens: options.tables?.passwordResetTokens
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
52
|
+
addPlugin({
|
|
53
|
+
src: resolver.resolve("./runtime/plugin"),
|
|
54
|
+
mode: "server"
|
|
55
|
+
});
|
|
62
56
|
addServerHandler({
|
|
63
57
|
route: "/api/login",
|
|
64
58
|
method: "post",
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
2
|
import { checkTableExists } from "../utils";
|
|
3
3
|
export default defineNuxtPlugin(async (_nuxtApp) => {
|
|
4
|
-
if (import.meta.client) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
4
|
const { nuxtUsers } = useRuntimeConfig();
|
|
8
5
|
const options = nuxtUsers;
|
|
6
|
+
console.log({ nuxtUsers });
|
|
9
7
|
const hasMigrationsTable = await checkTableExists(options, options.tables.migrations);
|
|
10
8
|
if (!hasMigrationsTable) {
|
|
11
|
-
useRuntimeConfig().public.nuxtUsers.tables.migrations = "";
|
|
12
9
|
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");
|
|
13
10
|
}
|
|
14
11
|
});
|