Skip to content

Commit c190e76

Browse files
authored
Merge pull request #498 from devforth/test
Test
2 parents 734a5d9 + 6cd3333 commit c190e76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+12524
-14556
lines changed

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@ npx adminforth create-app
5858

5959
The most convenient way to add new features or fixes is using `dev-demo`. It imports the source code of the repository and plugins so you can edit them and see changes on the fly.
6060

61+
# Requirements
62+
63+
- **Node.js 20**
64+
- **Docker**
65+
- **pnpm**
66+
- **Taskfile**
67+
6168
To run dev demo:
6269
```sh
6370
cd dev-demo
6471

65-
npm run setup-dev-demo
66-
npm run migrate:all
72+
pnpm setup-dev-demo
73+
pnpm migrate:all
6774

68-
npm start
75+
pnpm start
6976
```
7077

7178
## Adding columns to a database in dev-demo
@@ -77,13 +84,13 @@ To make migration add to the .prisma file in folder with database you need and a
7784

7885

7986
```
80-
npm run makemigration:sqlite -- --name init
87+
pnpm makemigration:sqlite -- --name init
8188
```
8289

8390
and
8491

8592
```
86-
npm run migrate:sqlite
93+
pnpm migrate:sqlite
8794
```
8895

8996
to apply migration
@@ -96,7 +103,7 @@ In order to make migration for the clickhouse, go to the `./migrations/clickhous
96103

97104
Then run
98105
```
99-
npm run migrate:clickhouse
106+
pnpm migrate:clickhouse
100107
```
101108

102109
to apply the migration.
@@ -108,18 +115,17 @@ Make sure you have not `adminforth` globally installed. If you have it, remove i
108115

109116

110117
```sh
111-
npm uninstall -g adminforth
118+
pnpm uninstall -g adminforth
112119
```
113120

114121
Then, in the root of the project, run once:
115122

116123
```
117124
cd adminforth/adminforth
118-
npm run build
125+
pnpm build
126+
pnpm link
119127
```
120128

121-
This will automatically make an npm link to the `adminforth` package in the root of the project.
122-
123129
Then, go to testing app, e.g. created with CLI, and use next command:
124130

125131
```

adminforth/commands/bundle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ async function bundle() {
1616
`);
1717

1818
} catch (e) {
19-
console.log(`Running budndle failed`, e);
19+
console.log(`Running bundle failed`, e);
20+
throw new Error(`Failed to bundle admin SPA: ${e.message}`);
2021
}
2122
}
2223

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
2+
{{#unless useNpm}}
3+
FROM devforth/node20-pnpm:latest
4+
WORKDIR /code/
5+
ADD package.json pnpm-lock.yaml pnpm-workspace.yaml /code/
6+
RUN pnpm i
7+
ADD . /code/
8+
RUN pnpm exec adminforth bundle
9+
CMD ["sh", "-c", "pnpm migrate:prod && pnpm prod"]
10+
{{/unless}}
11+
{{#if useNpm}}
112
FROM node:{{nodeMajor}}-slim
213
WORKDIR /code/
314
ADD package.json package-lock.json /code/
415
RUN npm ci
516
ADD . /code/
617
RUN npx adminforth bundle
718
CMD ["sh", "-c", "npm run migrate:prod && npm run prod"]
19+
{{/if}}

adminforth/commands/createApp/templates/package.json.hbs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@
88
"license": "ISC",
99
"description": "",
1010
"scripts": {
11-
"dev": "npm run _env:dev -- tsx watch index.ts",
12-
"prod": "npm run _env:prod -- tsx index.ts",
13-
"start": "npm run dev",
14-
"makemigration": "npm run _env:dev -- npx --yes prisma migrate dev --create-only",
15-
"migrate:local": "npm run _env:dev -- npx --yes prisma migrate deploy",
16-
"migrate:prod": "npm run _env:prod -- npx --yes prisma migrate deploy",
11+
{{#unless useNpm}}
12+
"dev": "pnpm _env:dev tsx watch index.ts",
13+
"prod": "pnpm _env:prod tsx index.ts",
14+
"start": "pnpm dev",
15+
"makemigration": "pnpm _env:dev npx --yes prisma migrate dev --create-only",
16+
"migrate:local": "pnpm _env:dev npx --yes prisma migrate deploy",
17+
"migrate:prod": "pnpm _env:prod npx --yes prisma migrate deploy",
1718
"_env:dev": "dotenvx run -f .env -f .env.local --",
1819
"_env:prod": "dotenvx run -f .env.prod --"
20+
{{/unless}}
21+
{{#if useNpm}}
22+
"dev": "npm run _env:dev -- tsx watch index.ts",
23+
"prod": "npm run _env:prod -- tsx index.ts",
24+
"start": "npm run dev",
25+
"makemigration": "npm run _env:dev -- npx --yes prisma migrate dev --create-only",
26+
"migrate:local": "npm run _env:dev -- npx --yes prisma migrate deploy",
27+
"migrate:prod": "npm run _env:prod -- npx --yes prisma migrate deploy",
28+
"_env:dev": "dotenvx run -f .env -f .env.local --",
29+
"_env:prod": "dotenvx run -f .env.prod --"
30+
{{/if}}
1931
},
2032
"engines": {
2133
"node": ">=20"

adminforth/commands/createApp/templates/pnpm_templates/pnpm-lock.yaml.hbs

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
onlyBuiltDependencies:
2+
- better-sqlite3

adminforth/commands/createApp/templates/readme.md.hbs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## Starting the application
22

33
Install dependencies:
4-
4+
{{#if useNpm}}
55
```bash
6-
npm ci
6+
npm i
77
```
88

99
Migrate the database:
@@ -17,6 +17,25 @@ Start the server:
1717
```bash
1818
npm run dev
1919
```
20+
{{/if}}
21+
22+
{{#unless useNpm}}
23+
```bash
24+
pnpm i
25+
```
26+
27+
Migrate the database:
28+
29+
```bash
30+
pnpm migrate:local
31+
```
32+
33+
Start the server:
34+
35+
```bash
36+
pnpm dev
37+
```
38+
{{/unless}}
2039

2140
{{#if prismaDbUrl}}
2241
## Changing schema
@@ -26,10 +45,10 @@ Open `schema.prisma` and change schema as needed: add new tables, columns, etc (
2645
Run the following command to generate a new migration and apply it instantly in local database:
2746

2847
```bash
29-
npm run makemigration -- --name <name_of_changes>
48+
pnpm makemigration --name <name_of_changes>
3049
```
3150

32-
Your colleagues will need to pull the changes and run `npm run migrateLocal` to apply the migration in their local database.
51+
Your colleagues will need to pull the changes and run `pnpm migrate:local` to apply the migration in their local database.
3352
{{/if}}
3453

3554
## Deployment tips

0 commit comments

Comments
 (0)