@shophost/rest-api 2.0.21 → 2.0.22
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/README.md +1 -1
- package/package.json +2 -1
- package/scripts/shophost-rest-api.mjs +21 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ import { ManufacturerSchema } from "@shophost/rest-api/schemas";
|
|
|
46
46
|
|
|
47
47
|
The published package now includes a small CLI so a fresh project can push the packaged Prisma schema to its own database.
|
|
48
48
|
|
|
49
|
-
1. Set one of these environment variables in your app
|
|
49
|
+
1. Set one of these environment variables in your app shell, `.env`, or `.env.local`:
|
|
50
50
|
- `DATABASE_URL`
|
|
51
51
|
- `POSTGRES_PRISMA_URL`
|
|
52
52
|
2. Run:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shophost/rest-api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"shophost-rest-api": "./scripts/shophost-rest-api.mjs"
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"axios": "^1.8.2",
|
|
77
77
|
"better-auth": "^1.5.5",
|
|
78
78
|
"date-fns": "^4.1.0",
|
|
79
|
+
"dotenv": "^16.4.7",
|
|
79
80
|
"hono": "^4.10.6",
|
|
80
81
|
"http-status-codes": "^2.3.0",
|
|
81
82
|
"nanoid": "^5.1.3",
|
|
@@ -5,6 +5,7 @@ import { existsSync } from "node:fs";
|
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
import dotenv from "dotenv";
|
|
8
9
|
|
|
9
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
const packageRoot = join(__dirname, "..");
|
|
@@ -26,6 +27,8 @@ Examples:
|
|
|
26
27
|
shophost-rest-api db push --url "postgres://..."
|
|
27
28
|
|
|
28
29
|
Environment:
|
|
30
|
+
.env.local
|
|
31
|
+
.env
|
|
29
32
|
DATABASE_URL
|
|
30
33
|
POSTGRES_PRISMA_URL
|
|
31
34
|
`);
|
|
@@ -56,6 +59,21 @@ function getDbPushArgs(argv) {
|
|
|
56
59
|
return argv.slice(2);
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
function loadEnvFiles() {
|
|
63
|
+
for (const envFile of [".env", ".env.local"]) {
|
|
64
|
+
const envPath = join(process.cwd(), envFile);
|
|
65
|
+
|
|
66
|
+
if (!existsSync(envPath)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
dotenv.config({
|
|
71
|
+
path: envPath,
|
|
72
|
+
override: envFile === ".env.local",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
const argv = process.argv.slice(2);
|
|
60
78
|
|
|
61
79
|
if (
|
|
@@ -89,6 +107,8 @@ if (reservedFlag) {
|
|
|
89
107
|
process.exit(1);
|
|
90
108
|
}
|
|
91
109
|
|
|
110
|
+
loadEnvFiles();
|
|
111
|
+
|
|
92
112
|
if (!existsSync(schemaPath)) {
|
|
93
113
|
console.error(`Missing Prisma schema at ${schemaPath}`);
|
|
94
114
|
process.exit(1);
|
|
@@ -113,7 +133,7 @@ if (
|
|
|
113
133
|
!process.env.POSTGRES_PRISMA_URL
|
|
114
134
|
) {
|
|
115
135
|
console.error(
|
|
116
|
-
"Set DATABASE_URL or POSTGRES_PRISMA_URL before running `shophost-rest-api db push`."
|
|
136
|
+
"Set DATABASE_URL or POSTGRES_PRISMA_URL, or add it to `.env.local` / `.env`, before running `shophost-rest-api db push`."
|
|
117
137
|
);
|
|
118
138
|
process.exit(1);
|
|
119
139
|
}
|