@valbuild/next 0.69.3 → 0.72.1

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.
Files changed (2) hide show
  1. package/README.md +89 -6
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -40,7 +40,9 @@
40
40
 
41
41
  # 🐉 HERE BE DRAGONS 🐉
42
42
 
43
- This version of Val is currently an alpha version - the API can be considered relatively stable, but expect some features to be broken and the UX to be changing.
43
+ Val is currently in beta - the API can be considered relatively stable, but expect some features to be broken and the UX to be changing.
44
+
45
+ Join us on [discord](https://discord.gg/cZzqPvaX8k) to get help or give us feedback.
44
46
 
45
47
  ## Table of contents
46
48
 
@@ -60,11 +62,17 @@ This version of Val is currently an alpha version - the API can be considered re
60
62
 
61
63
  ## Installation
62
64
 
63
- - Make sure you have TypeScript 5+, Next 14+, React 18.20.+
64
- - Install the packages (@valbuild/eslint-plugin is recommended but not required):
65
+ - Make sure your project is using
66
+ - Install the packages:
65
67
 
66
68
  ```sh
67
- npm install @valbuild/core@latest @valbuild/next@latest @valbuild/eslint-plugin@latest
69
+ npm install @valbuild/core@latest @valbuild/next@latest
70
+ ```
71
+
72
+ - Optionally, but recommend add the eslint-plugin package:
73
+
74
+ ```sh
75
+ npm install -D @valbuild/eslint-plugin@latest
68
76
  ```
69
77
 
70
78
  - Run the init script:
@@ -73,6 +81,14 @@ npm install @valbuild/core@latest @valbuild/next@latest @valbuild/eslint-plugin@
73
81
  npx @valbuild/init@latest
74
82
  ```
75
83
 
84
+ If you do not wish to use the init script, or having issues with it, checkout the [manual configuration guide](./MANUAL_CONFIGURATION.md).
85
+
86
+ ## Additional setup
87
+
88
+ - If you have a monorepo, or have a project where the project is located in a subdirectory relative to the github repository see the [monorepos](#monorepos) section
89
+ - See [formatting published content](#formatting-published-content) if you use prettier (or similar) Val to do it as well.
90
+ - If you want editors to update content in production, read up on how to setup [remote mode](#remote-mode).
91
+
76
92
  ## Getting started
77
93
 
78
94
  ### Create your first Val content file
@@ -179,8 +195,8 @@ Once your project is set up in [app.val.build](https://app.val.build), configure
179
195
 
180
196
  ### Environment Variables
181
197
 
182
- - **`VAL_API_KEY`**: Obtain this from your project's configuration page.
183
- - **`VAL_SECRET`**: Generate a random secret to secure communication between the UX client and your Next.js application.
198
+ - **`VAL_API_KEY`**: This is the API key used to authenticate server side API requests. You can find it under Settings in your project on [app.val.build](https://app.val.build).
199
+ - **`VAL_SECRET`**: In addition to the VAL_API_KEY, you need to generate a random secret to secure communication between the UX client and your Next.js application. You can use any random string for this, but if you have openssl installed you can run the following command: `openssl rand -hex 16`
184
200
 
185
201
  ### `val.config` Properties
186
202
 
@@ -189,6 +205,7 @@ Set these properties in the `val.config` file:
189
205
  - **`project`**: The fully qualified name of your project, formatted as `<team>/<name>`.
190
206
  - **`gitBranch`**: The Git branch your application uses. For Vercel, use `VERCEL_GIT_COMMIT_REF`.
191
207
  - **`gitCommit`**: The current Git commit your application is running on. For Vercel, use `VERCEL_GIT_COMMIT_SHA`.
208
+ - **`root`**: Optional. The path to the `val.config` file. Typically empty or undefined. If the project folder is under `web`, root would be: `/web`.
192
209
 
193
210
  ### Example `val.config.ts`
194
211
 
@@ -197,6 +214,7 @@ import { initVal } from "@valbuild/next";
197
214
 
198
215
  const { s, c, val, config } = initVal({
199
216
  project: "myteam/myproject",
217
+ //root: "/subdir", // only required for monorepos. Use the path where val.config is located. The path should start with /
200
218
  gitBranch: process.env.VERCEL_GIT_COMMIT_REF,
201
219
  gitCommit: process.env.VERCEL_GIT_COMMIT_SHA,
202
220
  });
@@ -205,6 +223,71 @@ export type { t } from "@valbuild/next";
205
223
  export { s, c, val, config };
206
224
  ```
207
225
 
226
+ # Formatting published content
227
+
228
+ If you are using `prettier` or another code formatting tool, it is recommended to setup formatting of code after changes have been applied.
229
+
230
+ ## Setting up formatting using Prettier
231
+
232
+ - Install `prettier` as **RUNTIME** dependency, by moving the `prettier` dependency from `devDependencies` to `dependencies`. The reason you need to do this, is that Val will be using it at runtime in production, and it has to be part of your build for this to work.
233
+ - Optionally create a `.prettierrc.json` file unless you have one already. We recommend doing this, so that you can be sure that formatting is applied consistently in both your development environment and by Val. You can set this to be an empty object, if you are want to keep using `prettier`s defaults:
234
+
235
+ ```json
236
+ {}
237
+ ```
238
+
239
+ - Add a formatter to the `/val/val.server`:
240
+
241
+ ```ts
242
+ formatter: (code: string, filePath: string) => {
243
+ return prettier.format(code, {
244
+ filepath: filePath,
245
+ ...prettierOptions, // <- use the same rules as in development
246
+ } as prettier.Options);
247
+ },
248
+ ```
249
+
250
+ Unless you have any modifications in your `val.server` file, the complete file should now look like this:
251
+
252
+ ```ts
253
+ import "server-only";
254
+ import { initValServer } from "@valbuild/next/server";
255
+ import { config } from "../val.config";
256
+ import { draftMode } from "next/headers";
257
+ import valModules from "../val.modules";
258
+ import prettier from "prettier";
259
+ import prettierOptions from "../.prettierrc.json";
260
+
261
+ const { valNextAppRouter } = initValServer(
262
+ valModules,
263
+ { ...config },
264
+ {
265
+ draftMode,
266
+ formatter: (code: string, filePath: string) => {
267
+ return prettier.format(code, {
268
+ filepath: filePath,
269
+ ...prettierOptions, // <- use the same rules as in development
270
+ } as prettier.Options);
271
+ },
272
+ },
273
+ );
274
+
275
+ export { valNextAppRouter };
276
+ ```
277
+
278
+ You should now be able to hit the save button locally and see prettier rules being applied.
279
+
280
+ ## Other formatters
281
+
282
+ Val is formatter agnostic, so it is possible to use the same flow as the one described for `prettier` above to any formatter you might want to use.
283
+
284
+ **NOTE**: this will be applied at runtime in production so you need make sure that the formatting dependencies are in the `dependencies` section of your `package.json`
285
+
286
+ # Monorepos
287
+
288
+ Val supports projects that are not under the root path in GitHub, and therefore monorepos.
289
+ To configure your project for monorepos, you can use the `root` parameter described in the [config](#valconfig-properties) section.
290
+
208
291
  # Schema types
209
292
 
210
293
  ## String
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.69.3",
11
+ "version": "0.72.1",
12
12
  "scripts": {
13
13
  "typecheck": "tsc --noEmit",
14
14
  "test": "jest"
@@ -45,11 +45,11 @@
45
45
  "exports": true
46
46
  },
47
47
  "dependencies": {
48
- "@valbuild/core": "~0.69.3",
49
- "@valbuild/react": "~0.69.3",
50
- "@valbuild/server": "~0.69.3",
51
- "@valbuild/shared": "~0.69.3",
52
- "@valbuild/ui": "~0.69.3",
48
+ "@valbuild/core": "~0.72.1",
49
+ "@valbuild/react": "~0.72.1",
50
+ "@valbuild/server": "~0.72.1",
51
+ "@valbuild/shared": "~0.72.1",
52
+ "@valbuild/ui": "~0.72.1",
53
53
  "client-only": "^0.0.1",
54
54
  "server-only": "^0.0.1"
55
55
  },