nurev 0.0.7 β 0.0.8
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/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
import { spawnPromise } from "./utils/cmd.js";
|
|
8
8
|
import { writeEnvFile } from "./utils/file.js";
|
|
9
9
|
|
|
10
|
-
console.log(
|
|
11
|
-
console.log("Template generator 'on demanding revalidation' with Nuxt");
|
|
10
|
+
console.log(`\n${kleur.bgGreen().bold("πNUREVπ")}`);
|
|
11
|
+
console.log("Template generator 'on demanding revalidation' with Nuxt\n");
|
|
12
12
|
|
|
13
13
|
const questionsBase = [
|
|
14
14
|
{
|
|
@@ -60,6 +60,8 @@ const questionsPocketbase = [
|
|
|
60
60
|
style: "password",
|
|
61
61
|
name: "adminpassword",
|
|
62
62
|
message: "Password for superadmin",
|
|
63
|
+
validate: (password) =>
|
|
64
|
+
password.length > 7 ? true : `8 characters needed or more`,
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
type: "text",
|
|
@@ -71,6 +73,8 @@ const questionsPocketbase = [
|
|
|
71
73
|
style: "password",
|
|
72
74
|
name: "userpassword",
|
|
73
75
|
message: "Password for API user",
|
|
76
|
+
validate: (userpassword) =>
|
|
77
|
+
userpassword.length > 7 ? true : `8 characters needed or more`,
|
|
74
78
|
},
|
|
75
79
|
];
|
|
76
80
|
|
|
@@ -93,9 +97,11 @@ const questionsPocketbase = [
|
|
|
93
97
|
import.meta.url,
|
|
94
98
|
),
|
|
95
99
|
),
|
|
96
|
-
destination:
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
destination: {
|
|
101
|
+
base: process.cwd(),
|
|
102
|
+
env: `${process.cwd()}/.env`,
|
|
103
|
+
envExample: `${process.cwd()}/.env.example`,
|
|
104
|
+
},
|
|
99
105
|
};
|
|
100
106
|
|
|
101
107
|
if (responseBase.backend === "pocketbase") {
|
|
@@ -115,22 +121,31 @@ const questionsPocketbase = [
|
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
try {
|
|
118
|
-
await fs.copy(paths.base, paths.destination);
|
|
119
|
-
await fs.copy(paths.backend, paths.destination);
|
|
120
|
-
await fs.copy(paths.packageManager, paths.destination);
|
|
121
|
-
await spawnPromise("
|
|
122
|
-
await fs.copy(paths.
|
|
124
|
+
await fs.copy(paths.base, paths.destination.base);
|
|
125
|
+
await fs.copy(paths.backend, paths.destination.base);
|
|
126
|
+
await fs.copy(paths.packageManager, paths.destination.base);
|
|
127
|
+
await spawnPromise("make", ["install"]);
|
|
128
|
+
await fs.copy(paths.destination.envExample, paths.destination.env);
|
|
129
|
+
await spawnPromise("make", ["setup"]);
|
|
123
130
|
switch (responseBase.backend) {
|
|
124
131
|
case "pocketbase":
|
|
125
|
-
await writeEnvFile(paths.
|
|
132
|
+
await writeEnvFile(paths.destination.env, {
|
|
126
133
|
NUXT_POCKETBASE_USER: responseBase.user,
|
|
127
134
|
NUXT_POCKETBASE_PASSWORD: responseBase.userpassword,
|
|
128
135
|
NUXT_JWT_SECRET: Buffer.from(
|
|
129
136
|
crypto.getRandomValues(new Uint8Array(32)),
|
|
130
137
|
).toString("hex"),
|
|
131
138
|
});
|
|
139
|
+
await spawnPromise("make", [
|
|
140
|
+
"-s",
|
|
141
|
+
"backend-superuser",
|
|
142
|
+
`email=${responseBase.admin}`,
|
|
143
|
+
`password=${responseBase.adminpassword}`,
|
|
144
|
+
]);
|
|
145
|
+
//TODO: ADD USERAPI AND POSTS TABLE
|
|
132
146
|
break;
|
|
133
147
|
}
|
|
148
|
+
console.log("\nπ Your template is ready! π\n");
|
|
134
149
|
} catch (error) {
|
|
135
150
|
console.log(error);
|
|
136
151
|
}
|
package/package.json
CHANGED
|
@@ -47,33 +47,25 @@ Tech stack:
|
|
|
47
47
|
NUXT_JWT_SECRET=secretjwt
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
2.
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
make setup
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
3. Start backend dev mode
|
|
50
|
+
2. Start backend dev mode
|
|
57
51
|
|
|
58
52
|
```bash
|
|
59
53
|
make backend-dev
|
|
60
54
|
```
|
|
61
55
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
5. Create a user inside `users` collection with the same values inside `NUXT_POCKETBASE_USER` and `NUXT_POCKETBASE_PASSWORD`
|
|
56
|
+
3. Create a user inside `users` collection with the same values inside `NUXT_POCKETBASE_USER` and `NUXT_POCKETBASE_PASSWORD`
|
|
65
57
|
|
|
66
|
-
|
|
58
|
+
4. Create a collection named `posts` and change API Rules for give permissions with `@request.auth.id != ""`
|
|
67
59
|
|
|
68
|
-
|
|
60
|
+
5. Create a new post
|
|
69
61
|
|
|
70
|
-
|
|
62
|
+
6. Start frontend dev mode
|
|
71
63
|
|
|
72
64
|
```bash
|
|
73
65
|
make frontend-dev
|
|
74
66
|
```
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
7. Open `http://localhost:3000/posts/[id]` and replace `[id]` with the post id created in the 6. step
|
|
77
69
|
|
|
78
70
|
## Build
|
|
79
71
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
|
|
2
2
|
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
3
|
help setup build install
|
|
4
4
|
|
|
@@ -26,6 +26,10 @@ backend-dev: backend-update
|
|
|
26
26
|
backend-run: backend-build
|
|
27
27
|
@echo "Running backend..."
|
|
28
28
|
cd backend && ./backend serve
|
|
29
|
+
|
|
30
|
+
backend-superuser: backend-update
|
|
31
|
+
@echo "Adding superuser..."
|
|
32
|
+
cd backend && go run . superuser create $(email) $(password)
|
|
29
33
|
|
|
30
34
|
# Frontend targets
|
|
31
35
|
frontend-setup:
|
|
@@ -64,6 +68,7 @@ help:
|
|
|
64
68
|
@echo " make backend-dev - Run the backend development only"
|
|
65
69
|
@echo " make backend-run - Run the backend only"
|
|
66
70
|
@echo " make backend-update - Update backend dependencies"
|
|
71
|
+
@echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
|
|
67
72
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
73
|
@echo " make frontend-install - Install frontend dependencies"
|
|
69
74
|
@echo " make frontend-dev - Start frontend development server"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
|
|
2
2
|
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
3
|
help setup build install
|
|
4
4
|
|
|
@@ -27,6 +27,9 @@ backend-run: backend-build
|
|
|
27
27
|
@echo "Running backend..."
|
|
28
28
|
cd backend && ./backend serve
|
|
29
29
|
|
|
30
|
+
backend-superuser: backend-update
|
|
31
|
+
@echo "Adding superuser..."
|
|
32
|
+
cd backend && go run . superuser create $(email) $(password)
|
|
30
33
|
# Frontend targets
|
|
31
34
|
frontend-setup:
|
|
32
35
|
@echo "Preparing frontend..."
|
|
@@ -64,6 +67,7 @@ help:
|
|
|
64
67
|
@echo " make backend-dev - Run the backend development only"
|
|
65
68
|
@echo " make backend-run - Run the backend only"
|
|
66
69
|
@echo " make backend-update - Update backend dependencies"
|
|
70
|
+
@echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
|
|
67
71
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
72
|
@echo " make frontend-install - Install frontend dependencies"
|
|
69
73
|
@echo " make frontend-dev - Start frontend development server"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
|
|
2
2
|
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
3
|
help setup build install
|
|
4
4
|
|
|
@@ -27,6 +27,10 @@ backend-run: backend-build
|
|
|
27
27
|
@echo "Running backend..."
|
|
28
28
|
cd backend && ./backend serve
|
|
29
29
|
|
|
30
|
+
backend-superuser: backend-update
|
|
31
|
+
@echo "Adding superuser..."
|
|
32
|
+
cd backend && go run . superuser create $(email) $(password)
|
|
33
|
+
|
|
30
34
|
# Frontend targets
|
|
31
35
|
frontend-setup:
|
|
32
36
|
@echo "Preparing frontend..."
|
|
@@ -64,6 +68,7 @@ help:
|
|
|
64
68
|
@echo " make backend-dev - Run the backend development only"
|
|
65
69
|
@echo " make backend-run - Run the backend only"
|
|
66
70
|
@echo " make backend-update - Update backend dependencies"
|
|
71
|
+
@echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
|
|
67
72
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
73
|
@echo " make frontend-install - Install frontend dependencies"
|
|
69
74
|
@echo " make frontend-dev - Start frontend development server"
|