Skip to content

Commit 99b896d

Browse files
authored
Merge branch 'main' into main
2 parents 7372e45 + 138691d commit 99b896d

32 files changed

Lines changed: 556 additions & 297 deletions

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
steps:
1717
- name: Clone repository
1818
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
1921

2022
- name: Set up Deno
2123
uses: denoland/setup-deno@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ _site
22
_cache
33
_broken_links.json
44

5+
.claude
56
.idea
67

78
node_modules

_components/Feedback.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function Feedback({ file }: { file: string | undefined }) {
77
return (
88
<section
99
id="feedback-section"
10-
class="flex flex-col mt-12 gap-2 p-4 sm:p-8 bg-blue-splash dark:bg-deploy-900 rounded-md mx-auto"
10+
class="flex flex-col mt-12 gap-2 p-4 sm:p-8 bg-blue-splash dark:bg-background-secondary rounded-md mx-auto"
1111
>
1212
<h2 class="text-xl mb-2 pb-2 font-normal">
1313
Did you find what you needed?

_config.ts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ const site = lume(
9191
createMarkdownSourceMiddleware({ root: "_site" }),
9292
createRoutingMiddleware(),
9393
createGAMiddleware({
94-
addr: { transport: "tcp", hostname: "localhost", port: 3000 },
94+
addr: {
95+
transport: "tcp",
96+
hostname: "localhost",
97+
port: parseInt(Deno.env.get("PORT") || "3000"),
98+
},
9599
}),
96100
createLlmsFilesMiddleware({ root: "_site" }),
97101
apiDocumentContentTypeMiddleware,
@@ -451,6 +455,37 @@ site.ignore(
451455
// the default layout if no other layout is specified
452456
site.data("layout", "doc.tsx");
453457

458+
// Populate lastModified from git history using a single git command
459+
site.preprocess([".md", ".mdx"], (filteredPages) => {
460+
const result = Deno.spawnAndWaitSync("git", [
461+
"log",
462+
"--pretty=format:%aI",
463+
"--name-only",
464+
"--diff-filter=ACMR",
465+
"HEAD",
466+
]);
467+
468+
const output = new TextDecoder().decode(result.stdout);
469+
const lastModified = new Map<string, string>();
470+
let currentDate = "";
471+
472+
for (const line of output.split("\n")) {
473+
if (!line) continue;
474+
if (line.match(/^\d{4}-/)) {
475+
currentDate = line;
476+
} else if (!lastModified.has(line)) {
477+
lastModified.set(line, currentDate);
478+
}
479+
}
480+
481+
for (const page of filteredPages) {
482+
const src = page.sourcePath?.replace(/^\//, "");
483+
if (src && lastModified.has(src)) {
484+
page.data.lastModified = new Date(lastModified.get(src)!);
485+
}
486+
}
487+
});
488+
454489
// Load API categories data globally
455490
import denoCategories from "./reference_gen/deno-categories.json" with {
456491
type: "json",
@@ -499,9 +534,6 @@ site.data("apiCategories", {
499534

500535
// Do more expensive operations if we're building the full site
501536
if (Deno.env.get("BUILD_TYPE") == "FULL" && !Deno.env.has("SKIP_OG")) {
502-
// Use Lume's built in date function to get the last modified date of the file
503-
// site.data("date", "Git Last Modified");;
504-
505537
// Generate Open Graph images
506538
site.data("openGraphLayout", "/open_graph/default.jsx");
507539
site.use(
@@ -546,7 +578,7 @@ site.scopedUpdates(
546578

547579
site.addEventListener("afterStartServer", () => {
548580
log.warn(
549-
`${cliNow()} Server available at <green>http://localhost:3000</green>`,
581+
`${cliNow()} Server available at <green>http://localhost:${site.server.options.port}</green>`,
550582
);
551583
});
552584

_includes/doc.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ export default function Doc(data: Lume.Data, helpers: Lume.Helpers) {
101101
{data.children}
102102
</div>
103103
</article>
104+
{data.lastModified && !isReference && !isLintRule && (
105+
<p class="text-sm text-foreground-secondary mt-8">
106+
Last updated on{" "}
107+
<time dateTime={data.lastModified.toISOString()}>
108+
{data.lastModified.toLocaleDateString("en-US", {
109+
year: "numeric",
110+
month: "long",
111+
day: "numeric",
112+
})}
113+
</time>
114+
</p>
115+
)}
104116
<data.comp.Feedback file={file} />
105117
</div>
106118
</main>

api/deno/index.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,22 +777,52 @@ Deno supports browser compatible lifecycle events:
777777
Scheduling more asynchronous work (like timers or network requests) will cause
778778
the program to continue.
779779
- [`unload`](https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event):
780-
fired when the document or a child resource is being unloaded.
780+
fired when the program has no more work to do. Scheduling more asynchronous
781+
work (like timers or network requests) **does not** keep the program alive.
781782
- [`unhandledrejection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event):
782783
fired when a promise that has no rejection handler is rejected, ie. a promise
783784
that has no `.catch()` handler or a second argument to `.then()`.
784785
- [`rejectionhandled`](https://developer.mozilla.org/en-US/docs/Web/API/Window/rejectionhandled_event):
785-
fired when a `.catch()` handler is added to a a promise that has already
786+
fired when a `.catch()` handler is added to a promise that has already been
786787
rejected. This event is fired only if there's `unhandledrejection` listener
787788
installed that prevents propagation of the event (which would result in the
788789
program terminating with an error).
790+
- [`error`](https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event):
791+
fired when an uncaught exception occurs. If a listener is registered, it
792+
prevents the default behavior of printing the error to the console and
793+
terminating the program.
794+
795+
Deno also supports Node.js compatible lifecycle events:
796+
797+
- [`process.on("beforeExit")`](https://nodejs.org/api/process.html#event-beforeexit):
798+
fired when the event loop has no more work to do and is about to exit.
799+
Scheduling more asynchronous work (like timers or network requests) will cause
800+
the program to continue. Counterpart to `beforeunload` Web event. Fires
801+
immediately after `beforeunload` event.
802+
- [`process.on("exit")`](https://nodejs.org/api/process.html#event-exit): fired
803+
when the program has no more work to do. Scheduling more asynchronous work
804+
(like timers or network requests) **does not** keep the program alive.
805+
Counterpart to `unload` Web event. Fired immediately after `unload` event.
806+
- [`process.on("rejectionHandled")`](https://nodejs.org/api/process.html#event-rejectionhandled):
807+
fired when a `.catch()` handler is added to a promise that has already been
808+
rejected. Counterpart to `rejectionhandled` Web event. Fired immediately after
809+
`rejectionhandled` event.
810+
- [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#event-uncaughtexception):
811+
fired when an uncaught exception bubbles up. If a listener is registered, it
812+
prevents the default behavior of printing the stack trace and exiting.
813+
Counterpart to `error` Web event. Fired immediately after `error` event.
814+
- [`process.on("unhandledRejection")`](https://nodejs.org/api/process.html#event-unhandledrejection):
815+
fired when a promise is rejected and no rejection handler is attached.
816+
Counterpart to `unhandledrejection` Web event. Fired immediately after
817+
`unhandledrejection` event.
789818
790819
You can use these events to provide setup and cleanup code in your program.
791820
792-
Listeners for `load` events can be asynchronous and will be awaited, this event
821+
Listeners for `load` events can be asynchronous and will be awaited. This event
793822
cannot be canceled. Listeners for `beforeunload` need to be synchronous and can
794823
be cancelled to keep the program running. Listeners for `unload` events need to
795-
be synchronous and cannot be cancelled.
824+
be synchronous and cannot be cancelled. The same rules apply to their Node.js
825+
counterparts (`beforeExit` and `exit`).
796826
797827
## main.ts
798828

deploy/getting_started.md

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -135,73 +135,17 @@ To add environment variables:
135135

136136
![Screenshot of the Deploy env variables config screen](./images/env_var.png)
137137

138+
You can re-open the drawer to edit / remove environment variables you have
139+
added. You can also edit the app name on this page, and select which region(s)
140+
the application should be served from.
141+
138142
## Build and deploy your app
139143

140144
1. Click `Create App` to create the application and start the first build
141145
2. Watch the build progress through the live logs:
142146

143147
![Screenshot of app build logs](./images/build_logs.png)
144148

145-
The build logs show these stages:
146-
147-
- **Prepare**: Cloning the repository and restoring caches
148-
- **Install**: Running the install command and framework-specific setup
149-
- **Build**: Executing the build command and preparing the deployment artifact
150-
- **Warm up**: Testing the deployment with a request
151-
- **Route**: Deploying the build to global regions
152-
153-
You can cancel a build with the button in the top-left corner, or restart failed
154-
builds from the same location.
155-
156-
After completion, the top-right shows the preview URL, and below that, all
157-
timelines where the build is deployed.
158-
159-
## Monitor your application
160-
161-
After deploying, use the observability tools to monitor your application:
162-
163-
### Logs
164-
165-
View application logs with filtering options for context, revision, and text
166-
content:
167-
168-
![Screenshot of the Logs page](./images/logs.png)
169-
170-
Use the search bar to filter logs (e.g., `context:production`, `revision:<id>`).
171-
The time picker adjusts the displayed time range.
172-
173-
If a log is associated with a trace, you can click "View trace" to see the
174-
corresponding trace information.
175-
176-
### Traces
177-
178-
View request traces with detailed timing information:
179-
180-
![Screenshot of the Traces page](./images/traces.png)
181-
182-
Click any trace to open the trace view showing all spans in a waterfall
183-
visualization:
184-
185-
![Screenshot of the Trace view](./images/trace.png)
186-
187-
The trace view shows:
188-
189-
- Timeline of spans with duration
190-
- Span details including attributes
191-
- Logs emitted during the span To save the environment variables, press the save
192-
button. You can re-open the drawer to edit / remove environment variables you
193-
have added.
194-
195-
You can also edit the app name on this page, and select which region(s) the
196-
application should be served from.
197-
198-
## Build and deploy your app
199-
200-
Finally, you can press the `Create App` button to create the app. This will
201-
create the app and immediately trigger the first build:
202-
203-
![Screenshot of app build logs](./images/build_logs.png)
204-
205149
On the build page you can see live streaming build logs split into multiple
206150
sections:
207151

@@ -219,9 +163,9 @@ sections:
219163
In the top left of this build is a button to cancel the build. For failed
220164
builds, there is also a button to restart the build.
221165

222-
For completed builds, the top right shows the preview URL of the build. Further
223-
down all timelines that this build is deployed to are shown, such as
224-
`Production`, or `Git Branch` timelines.
166+
For completed builds, the top right shows the preview URL. Further down all
167+
timelines that this build is deployed to are shown, such as `Production`, or
168+
`Git Branch` timelines.
225169

226170
You can also see how the build was triggered on this page. This can either be
227171
`manual action`, for builds triggered through the UI, or `GitHub repo` for
@@ -232,12 +176,15 @@ URLs shown in the timelines list.
232176

233177
## Monitor your application
234178

235-
After visiting your application, you can view telemetry about your application
236-
in the form of the logs and traces available in our observability panels. You
237-
can visit these pages by clicking the respective buttons in the left sidebar.
179+
After deploying, you can view telemetry about your application in the form of
180+
the logs and traces available in our observability panels. You can visit these
181+
pages by clicking the respective buttons in the left sidebar.
238182

239183
### Logs
240184

185+
View application logs with filtering options for context, revision, and text
186+
content:
187+
241188
![Screenshot of the Logs page](./images/logs.png)
242189

243190
The logs page shows all recent logs in the project. By default logs from all
@@ -246,7 +193,7 @@ search bar at the top, the shown logs can be restricted. For example, to filter
246193
to only production logs, add `context:production` to the search bar. To only
247194
show logs from a certain revision, use `revision:<id>` etc.
248195

249-
You can also use full text search in the search bar. The full text search fill
196+
You can also use full text search in the search bar. The full text search will
250197
filter down the log entries to only those containing the text written,
251198
case-insensitively.
252199

@@ -260,6 +207,8 @@ trace. Clicking this button will open the respective trace as an overlay.
260207

261208
### Traces
262209

210+
View request traces with detailed timing information:
211+
263212
![Screenshot of the Traces page](./images/traces.png)
264213

265214
The traces page shows all recent traces in the project. By default traces from

deploy/kv/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To close the database connection, use the
3737
```ts
3838
const kv = await Deno.openKv();
3939
// Execute some queries ...
40-
await kv.close();
40+
kv.close();
4141
```
4242

4343
## Creating, updating, and reading a key-value pair

examples/tutorials/basic_opentelemetry.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ To run the server with OpenTelemetry, use these flags:
123123
OTEL_DENO=true OTEL_SERVICE_NAME=my-server deno run --allow-net server.ts
124124
```
125125

126+
:::tip
127+
128+
To quickly see telemetry output without setting up a collector, you can use the
129+
built-in console exporter which prints spans, logs, and metrics directly to
130+
stderr:
131+
132+
```sh
133+
OTEL_DENO=true OTEL_EXPORTER_OTLP_PROTOCOL=console OTEL_SERVICE_NAME=my-server deno run --allow-net server.ts
134+
```
135+
136+
:::
137+
126138
## Step 3: Create a Test Client
127139

128140
Let's create a simple client to send requests to our server:

examples/tutorials/snapshot_test.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Deno.test("isSnapshotMatch", async (t) => {
5050

5151
You will need to grant read and write file permissions in order for Deno to
5252
write a snapshot file and then read it to test the assertion. If it is the first
53-
time you are running the test a do not already have a snapshot, add the
53+
time you are running the test and you do not already have a snapshot, add the
5454
`--update` flag:
5555

5656
```bash
@@ -143,7 +143,7 @@ Deno.test("isSnapshotMatch", async (t) => {
143143
When you run a test with `assertSnapshot`, the data you're testing needs to be
144144
converted to a string format that can be written to the snapshot file (when
145145
creating or updating snapshots) and compared with the existing snapshot (when
146-
validating), this is called serialization.
146+
validating). This is called serialization.
147147

148148
The `serializer` option allows you to provide a custom serializer function. This
149149
custom function will be called by `assertSnapshot` and be passed the value being

0 commit comments

Comments
 (0)