nurev 0.0.5 → 0.0.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/.forgejo/workflows/publish.yml +17 -0
- package/bun.lock +0 -5
- package/index.js +77 -24
- package/package.json +1 -1
- package/templates/base/frontend/server/utils/auth.ts +0 -2
- package/templates/pocketbase/.env.example +2 -2
- package/templates/pocketbase/README.md +8 -6
- package/templates/pocketbase-bun/Makefile +10 -12
- package/templates/pocketbase-npm/Makefile +11 -13
- package/templates/pocketbase-pnpm/Makefile +11 -13
- package/utils/cmd.js +23 -0
- package/utils/file.js +25 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
on:
|
|
2
|
+
push:
|
|
3
|
+
tags: ["v*"]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
publish:
|
|
7
|
+
runs-on: codeberg-tiny-lazy
|
|
8
|
+
container:
|
|
9
|
+
image: node:25-alpine
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v6
|
|
12
|
+
- name: publish version to npm
|
|
13
|
+
run: |
|
|
14
|
+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
|
|
15
|
+
npm publish --access public
|
|
16
|
+
env:
|
|
17
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/bun.lock
CHANGED
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
"fs-extra": "^11.3.4",
|
|
9
9
|
"prompts": "^2.4.2",
|
|
10
10
|
},
|
|
11
|
-
"peerDependencies": {
|
|
12
|
-
"typescript": "^5",
|
|
13
|
-
},
|
|
14
11
|
},
|
|
15
12
|
},
|
|
16
13
|
"packages": {
|
|
@@ -26,8 +23,6 @@
|
|
|
26
23
|
|
|
27
24
|
"sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="],
|
|
28
25
|
|
|
29
|
-
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
30
|
-
|
|
31
26
|
"universalify": ["universalify@2.0.1", "", {}, "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw=="],
|
|
32
27
|
}
|
|
33
28
|
}
|
package/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import kleur from "kleur";
|
|
3
4
|
import { default as prompts } from "prompts";
|
|
4
5
|
import { default as fs } from "fs-extra";
|
|
5
6
|
import { fileURLToPath } from "url";
|
|
6
|
-
import
|
|
7
|
+
import { spawnPromise } from "./utils/cmd.js";
|
|
8
|
+
import { writeEnvFile } from "./utils/file.js";
|
|
7
9
|
|
|
8
10
|
console.log(`${kleur.bgGreen().bold("[Nurev]")}`);
|
|
9
11
|
console.log("Template generator 'on demanding revalidation' with Nuxt");
|
|
10
12
|
|
|
11
|
-
const
|
|
13
|
+
const questionsBase = [
|
|
12
14
|
{
|
|
13
15
|
type: "select",
|
|
14
16
|
name: "manager",
|
|
@@ -47,37 +49,88 @@ const questions = [
|
|
|
47
49
|
},
|
|
48
50
|
];
|
|
49
51
|
|
|
52
|
+
const questionsPocketbase = [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
name: "admin",
|
|
56
|
+
message: "Email address to assign to the Pocketbase superadmin",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "text",
|
|
60
|
+
style: "password",
|
|
61
|
+
name: "adminpassword",
|
|
62
|
+
message: "Password for superadmin",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: "text",
|
|
66
|
+
name: "user",
|
|
67
|
+
message: "Email for the API user",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
style: "password",
|
|
72
|
+
name: "userpassword",
|
|
73
|
+
message: "Password for API user",
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
|
|
50
77
|
(async () => {
|
|
51
|
-
const
|
|
78
|
+
const responseBase = await prompts(questionsBase);
|
|
52
79
|
|
|
53
|
-
if (Object.keys(
|
|
80
|
+
if (Object.keys(questionsBase).length !== Object.keys(responseBase).length) {
|
|
54
81
|
console.log("Script finished");
|
|
55
82
|
return;
|
|
56
83
|
}
|
|
57
84
|
|
|
58
|
-
const
|
|
59
|
-
new URL("./templates/base", import.meta.url),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const paths = {
|
|
86
|
+
base: fileURLToPath(new URL("./templates/base", import.meta.url)),
|
|
87
|
+
backend: fileURLToPath(
|
|
88
|
+
new URL(`./templates/${responseBase.backend}`, import.meta.url),
|
|
89
|
+
),
|
|
90
|
+
packageManager: fileURLToPath(
|
|
91
|
+
new URL(
|
|
92
|
+
`./templates/${responseBase.backend}-${responseBase.manager}`,
|
|
93
|
+
import.meta.url,
|
|
94
|
+
),
|
|
68
95
|
),
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
destination: process.cwd(),
|
|
97
|
+
destinationEnvExample: process.cwd() + "/.env.example",
|
|
98
|
+
destinationEnv: process.cwd() + "/.env",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (responseBase.backend === "pocketbase") {
|
|
102
|
+
const responsePocketbase = await prompts(questionsPocketbase);
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
Object.keys(questionsPocketbase).length !==
|
|
106
|
+
Object.keys(responsePocketbase).length
|
|
107
|
+
) {
|
|
108
|
+
console.log("Script finished");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (const key in responsePocketbase) {
|
|
113
|
+
responseBase[key] = responsePocketbase[key];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
71
116
|
|
|
72
117
|
try {
|
|
73
|
-
await fs.copy(
|
|
74
|
-
await fs.copy(
|
|
75
|
-
await fs.copy(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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("/usr/bin/make", ["install"]);
|
|
122
|
+
await fs.copy(paths.destinationEnvExample, paths.destinationEnv);
|
|
123
|
+
switch (responseBase.backend) {
|
|
124
|
+
case "pocketbase":
|
|
125
|
+
await writeEnvFile(paths.destinationEnv, {
|
|
126
|
+
NUXT_POCKETBASE_USER: responseBase.user,
|
|
127
|
+
NUXT_POCKETBASE_PASSWORD: responseBase.userpassword,
|
|
128
|
+
NUXT_JWT_SECRET: Buffer.from(
|
|
129
|
+
crypto.getRandomValues(new Uint8Array(32)),
|
|
130
|
+
).toString("hex"),
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
81
134
|
} catch (error) {
|
|
82
135
|
console.log(error);
|
|
83
136
|
}
|
package/package.json
CHANGED
|
@@ -38,10 +38,8 @@ export const defineAuthResponseHandler = <T extends EventHandlerRequest, D>(
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const response = await handler(event);
|
|
41
|
-
// do something after the route handler
|
|
42
41
|
return { response };
|
|
43
42
|
} catch (err) {
|
|
44
|
-
// Error handling
|
|
45
43
|
return { err };
|
|
46
44
|
}
|
|
47
45
|
});
|
|
@@ -9,7 +9,7 @@ Tech stack:
|
|
|
9
9
|
|
|
10
10
|
## Setup
|
|
11
11
|
|
|
12
|
-
1.
|
|
12
|
+
1. Check if your `.env` file is correct
|
|
13
13
|
|
|
14
14
|
- `TABLES_TRIGGER`: collections that trigger the Nuxt cache to be cleared when collections are updated, a new row is added or a row is removed
|
|
15
15
|
- **Example**
|
|
@@ -31,17 +31,17 @@ Tech stack:
|
|
|
31
31
|
```bash
|
|
32
32
|
NUXT_POCKETBASE_URL=http://localhost:8090
|
|
33
33
|
```
|
|
34
|
-
- `NUXT_POCKETBASE_USER`: PocketBase user created in `user` collection for login to the API
|
|
34
|
+
- `NUXT_POCKETBASE_USER`: PocketBase user created in `user` collection for login to the API (requested)
|
|
35
35
|
- **Example**
|
|
36
36
|
```bash
|
|
37
37
|
NUXT_POCKETBASE_USER=paco@paco.me
|
|
38
38
|
```
|
|
39
|
-
- `NUXT_POCKETBASE_PASSWORD`: PocketBase password user created in `user` collection for login to the API
|
|
39
|
+
- `NUXT_POCKETBASE_PASSWORD`: PocketBase password user created in `user` collection for login to the API (requested)
|
|
40
40
|
- **Example**
|
|
41
41
|
```bash
|
|
42
42
|
NUXT_POCKETBASE_PASSWORD=secretpassword
|
|
43
43
|
```
|
|
44
|
-
- `NUXT_JWT_SECRET`: JWT secret for signing and validating tokens
|
|
44
|
+
- `NUXT_JWT_SECRET`: JWT secret for signing and validating tokens (autogenerated)
|
|
45
45
|
- **Example**
|
|
46
46
|
```bash
|
|
47
47
|
NUXT_JWT_SECRET=secretjwt
|
|
@@ -63,9 +63,11 @@ make backend-dev
|
|
|
63
63
|
|
|
64
64
|
5. Create a user inside `users` collection with the same values inside `NUXT_POCKETBASE_USER` and `NUXT_POCKETBASE_PASSWORD`
|
|
65
65
|
|
|
66
|
-
6. Create a collection named `posts` and
|
|
66
|
+
6. Create a collection named `posts` and change API Rules for give permissions with `@request.auth.id != ""`
|
|
67
67
|
|
|
68
|
-
7.
|
|
68
|
+
7. Create a new post
|
|
69
|
+
|
|
70
|
+
8. Start frontend dev mode
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
73
|
make frontend-dev
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-
|
|
2
|
-
frontend-install frontend-dev frontend-build frontend-preview frontend-
|
|
3
|
-
setup build
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
2
|
+
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
|
+
help setup build install
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
# Default target
|
|
@@ -27,10 +27,6 @@ backend-run: backend-build
|
|
|
27
27
|
@echo "Running backend..."
|
|
28
28
|
cd backend && ./backend serve
|
|
29
29
|
|
|
30
|
-
backend-clean:
|
|
31
|
-
@echo "Cleaning backend..."
|
|
32
|
-
cd backend && rm -f backend
|
|
33
|
-
|
|
34
30
|
# Frontend targets
|
|
35
31
|
frontend-setup:
|
|
36
32
|
@echo "Preparing frontend..."
|
|
@@ -38,7 +34,7 @@ frontend-setup:
|
|
|
38
34
|
|
|
39
35
|
frontend-install:
|
|
40
36
|
@echo "Installing frontend dependencies..."
|
|
41
|
-
cd frontend && bun install
|
|
37
|
+
cd frontend && bun --bun install
|
|
42
38
|
|
|
43
39
|
frontend-dev: frontend-install
|
|
44
40
|
@echo "Starting frontend development server..."
|
|
@@ -52,10 +48,9 @@ frontend-preview: frontend-build
|
|
|
52
48
|
@echo "Previewing frontend production build..."
|
|
53
49
|
cd frontend && bun --bun run preview
|
|
54
50
|
|
|
55
|
-
frontend-
|
|
56
|
-
@echo "
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
install: backend-update frontend-install
|
|
52
|
+
@echo "Dependencies installed"
|
|
53
|
+
|
|
59
54
|
setup: backend-setup frontend-setup
|
|
60
55
|
@echo "Setup ready"
|
|
61
56
|
|
|
@@ -68,10 +63,13 @@ help:
|
|
|
68
63
|
@echo " make backend-build - Build the backend only"
|
|
69
64
|
@echo " make backend-dev - Run the backend development only"
|
|
70
65
|
@echo " make backend-run - Run the backend only"
|
|
66
|
+
@echo " make backend-update - Update backend dependencies"
|
|
71
67
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
|
+
@echo " make frontend-install - Install frontend dependencies"
|
|
72
69
|
@echo " make frontend-dev - Start frontend development server"
|
|
73
70
|
@echo " make frontend-build - Build frontend for production"
|
|
74
71
|
@echo " make frontend-preview - Preview frontend production build"
|
|
72
|
+
@echo " make install - Install all dependencies"
|
|
75
73
|
@echo " make help - Show this help message"
|
|
76
74
|
@echo " make setup - Prepare the project for dev mode and build"
|
|
77
75
|
@echo " make build - Build frontend and backend"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-
|
|
2
|
-
frontend-install frontend-dev frontend-build frontend-preview frontend-
|
|
3
|
-
setup build
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
2
|
+
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
|
+
help setup build install
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
# Default target
|
|
@@ -13,7 +13,7 @@ backend-setup:
|
|
|
13
13
|
|
|
14
14
|
backend-build:
|
|
15
15
|
@echo "Building backend..."
|
|
16
|
-
cd backend && go build -o
|
|
16
|
+
cd backend && go build -o backend
|
|
17
17
|
|
|
18
18
|
backend-update:
|
|
19
19
|
@echo "Updating backend..."
|
|
@@ -25,11 +25,7 @@ backend-dev: backend-update
|
|
|
25
25
|
|
|
26
26
|
backend-run: backend-build
|
|
27
27
|
@echo "Running backend..."
|
|
28
|
-
cd backend && ./
|
|
29
|
-
|
|
30
|
-
backend-clean:
|
|
31
|
-
@echo "Cleaning backend..."
|
|
32
|
-
cd backend && rm -f nupo-backend
|
|
28
|
+
cd backend && ./backend serve
|
|
33
29
|
|
|
34
30
|
# Frontend targets
|
|
35
31
|
frontend-setup:
|
|
@@ -52,10 +48,9 @@ frontend-preview: frontend-build
|
|
|
52
48
|
@echo "Previewing frontend production build..."
|
|
53
49
|
cd frontend && npm run preview
|
|
54
50
|
|
|
55
|
-
frontend-
|
|
56
|
-
@echo "
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
install: backend-update frontend-install
|
|
52
|
+
@echo "Dependencies installed"
|
|
53
|
+
|
|
59
54
|
setup: backend-setup frontend-setup
|
|
60
55
|
@echo "Setup ready"
|
|
61
56
|
|
|
@@ -68,10 +63,13 @@ help:
|
|
|
68
63
|
@echo " make backend-build - Build the backend only"
|
|
69
64
|
@echo " make backend-dev - Run the backend development only"
|
|
70
65
|
@echo " make backend-run - Run the backend only"
|
|
66
|
+
@echo " make backend-update - Update backend dependencies"
|
|
71
67
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
|
+
@echo " make frontend-install - Install frontend dependencies"
|
|
72
69
|
@echo " make frontend-dev - Start frontend development server"
|
|
73
70
|
@echo " make frontend-build - Build frontend for production"
|
|
74
71
|
@echo " make frontend-preview - Preview frontend production build"
|
|
72
|
+
@echo " make install - Install all dependencies"
|
|
75
73
|
@echo " make help - Show this help message"
|
|
76
74
|
@echo " make setup - Prepare the project for dev mode and build"
|
|
77
75
|
@echo " make build - Build frontend and backend"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
.PHONY: all backend-build backend-update backend-dev backend-run backend-
|
|
2
|
-
frontend-install frontend-dev frontend-build frontend-preview frontend-
|
|
3
|
-
setup build
|
|
1
|
+
.PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
|
|
2
|
+
frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
|
|
3
|
+
help setup build install
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
# Default target
|
|
@@ -13,7 +13,7 @@ backend-setup:
|
|
|
13
13
|
|
|
14
14
|
backend-build:
|
|
15
15
|
@echo "Building backend..."
|
|
16
|
-
cd backend && go build -o
|
|
16
|
+
cd backend && go build -o backend
|
|
17
17
|
|
|
18
18
|
backend-update:
|
|
19
19
|
@echo "Updating backend..."
|
|
@@ -25,11 +25,7 @@ backend-dev: backend-update
|
|
|
25
25
|
|
|
26
26
|
backend-run: backend-build
|
|
27
27
|
@echo "Running backend..."
|
|
28
|
-
cd backend && ./
|
|
29
|
-
|
|
30
|
-
backend-clean:
|
|
31
|
-
@echo "Cleaning backend..."
|
|
32
|
-
cd backend && rm -f nupo-backend
|
|
28
|
+
cd backend && ./backend serve
|
|
33
29
|
|
|
34
30
|
# Frontend targets
|
|
35
31
|
frontend-setup:
|
|
@@ -52,10 +48,9 @@ frontend-preview: frontend-build
|
|
|
52
48
|
@echo "Previewing frontend production build..."
|
|
53
49
|
cd frontend && pnpm run preview
|
|
54
50
|
|
|
55
|
-
frontend-
|
|
56
|
-
@echo "
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
install: backend-update frontend-install
|
|
52
|
+
@echo "Dependencies installed"
|
|
53
|
+
|
|
59
54
|
setup: backend-setup frontend-setup
|
|
60
55
|
@echo "Setup ready"
|
|
61
56
|
|
|
@@ -68,10 +63,13 @@ help:
|
|
|
68
63
|
@echo " make backend-build - Build the backend only"
|
|
69
64
|
@echo " make backend-dev - Run the backend development only"
|
|
70
65
|
@echo " make backend-run - Run the backend only"
|
|
66
|
+
@echo " make backend-update - Update backend dependencies"
|
|
71
67
|
@echo " make frontend-setup - Create a symbolic link for frontend"
|
|
68
|
+
@echo " make frontend-install - Install frontend dependencies"
|
|
72
69
|
@echo " make frontend-dev - Start frontend development server"
|
|
73
70
|
@echo " make frontend-build - Build frontend for production"
|
|
74
71
|
@echo " make frontend-preview - Preview frontend production build"
|
|
72
|
+
@echo " make install - Install all dependencies"
|
|
75
73
|
@echo " make help - Show this help message"
|
|
76
74
|
@echo " make setup - Prepare the project for dev mode and build"
|
|
77
75
|
@echo " make build - Build frontend and backend"
|
package/utils/cmd.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
|
|
3
|
+
export function spawnPromise(command, args) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const processChild = spawn(command, args);
|
|
6
|
+
|
|
7
|
+
processChild.stdout.pipe(process.stdout);
|
|
8
|
+
processChild.stderr.pipe(process.stderr);
|
|
9
|
+
|
|
10
|
+
processChild.on("close", (code) => {
|
|
11
|
+
if (code === 0) {
|
|
12
|
+
resolve({ code });
|
|
13
|
+
} else {
|
|
14
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
processChild.on("error", (err) => {
|
|
19
|
+
console.error(`Error: `, err);
|
|
20
|
+
reject(err);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
package/utils/file.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { default as fs } from "fs-extra";
|
|
2
|
+
|
|
3
|
+
export function writeEnvFile(filePath, params) {
|
|
4
|
+
return new Promise(async (resolve, reject) => {
|
|
5
|
+
try {
|
|
6
|
+
let content = await fs.readFile(filePath, "utf8");
|
|
7
|
+
|
|
8
|
+
for (const key in params) {
|
|
9
|
+
const value = params[key];
|
|
10
|
+
const regex = new RegExp(`^${key}=.*`, "m");
|
|
11
|
+
|
|
12
|
+
if (regex.test(content) === true) {
|
|
13
|
+
content = content.replace(regex, `${key}=${value}`);
|
|
14
|
+
} else {
|
|
15
|
+
reject(new Error(`Param ${key} not found inside .env`));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
await fs.writeFile(filePath, content, `utf8`);
|
|
20
|
+
resolve();
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(error);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|