docker-react 0.1.0-modernization-hotfix.0 → 0.1.0
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 +11 -14
- package/dist/prep.js +5 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,14 +21,11 @@ CLI & base image to deploy React applications with docker containers.
|
|
|
21
21
|
|
|
22
22
|
## Supported Tooling
|
|
23
23
|
|
|
24
|
-
-
|
|
25
|
-
- [x] Vite
|
|
26
|
-
- [ ] React Static
|
|
24
|
+
- Vite
|
|
27
25
|
|
|
28
26
|
## Supported Validation
|
|
29
27
|
|
|
30
|
-
-
|
|
31
|
-
- [ ] Yup
|
|
28
|
+
- Zod
|
|
32
29
|
|
|
33
30
|
## Other TODOs
|
|
34
31
|
|
|
@@ -43,23 +40,23 @@ CLI & base image to deploy React applications with docker containers.
|
|
|
43
40
|
|
|
44
41
|
## Implementation Instructions
|
|
45
42
|
|
|
46
|
-
1. Install `docker-react` and `
|
|
43
|
+
1. Install `docker-react` and `zod` (zod version should match the peer dependency version exactly)
|
|
47
44
|
|
|
48
45
|
```sh
|
|
49
|
-
npm i -S docker-react
|
|
46
|
+
npm i -S docker-react zod@4.1.12
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
2. Create environment variable schema (currently only
|
|
49
|
+
2. Create environment variable schema (currently only Zod supported but the future others will be available)
|
|
53
50
|
|
|
54
51
|
```js
|
|
55
52
|
// env.schema.js
|
|
56
|
-
const
|
|
53
|
+
const { z } = require('zod');
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
const envSchema = z.object({
|
|
56
|
+
VITE_API_URL: z.string().uri().required(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
module.exports = envSchema;
|
|
63
60
|
```
|
|
64
61
|
|
|
65
62
|
3. Add env import to your `index.html` head (in a future version this will be generated for you)
|
package/dist/prep.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
const ENVIRONMENT_DEFINITION_FILE_NAME = 'window.env.js';
|
|
4
4
|
export function addPrepCommand(program) {
|
|
5
5
|
return program
|
|
@@ -13,15 +13,11 @@ export function addPrepCommand(program) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function validateEnvironmentVariables(schema, environmentVariables) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
stripUnknown: true,
|
|
20
|
-
});
|
|
21
|
-
if (joiResult.error) {
|
|
22
|
-
throw new Error(joiResult.error.message);
|
|
16
|
+
const zodResult = schema.safeParse(environmentVariables);
|
|
17
|
+
if (zodResult.error) {
|
|
18
|
+
throw new Error(zodResult.error.message);
|
|
23
19
|
}
|
|
24
|
-
return
|
|
20
|
+
return zodResult.data;
|
|
25
21
|
}
|
|
26
22
|
async function generateEnvironmentFile(schemaPath, destinationPath) {
|
|
27
23
|
// Perform environment variable validation.
|
package/package.json
CHANGED