deno.land / std@0.177.1 / _tools / check_deploy.ts

check_deploy.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.import { retry } from "../async/retry.ts";
const projectName = "std-deploy-compat-test";const branch = Deno.args[0];
if (!branch) { console.log("Usage: deno run deploy-check.ts <branch-name>"); Deno.exit(1);}
// branch name will be transformed by the following rules:// - separators (/, ., or _) are replaced to "-"// - non alphanumeric chars are removed (except "-")// - truncated to 26 chars// - trim the last "-"sconst branchId = branch .replace(/[_\/.]/g, "-") .replace(/[^a-zA-Z0-9-]/g, "") .slice(0, 26) .replace(/-+$/, "");
const deployName = branch === "main" ? projectName : `${projectName}--${branchId}`;
await retry(async () => { const hostname = `${deployName}.deno.dev`; console.log(`Checking ${hostname}`); const conn = await Deno.connectTls({ hostname, port: 443 }); new ReadableStream({ start(c) { c.enqueue( new TextEncoder().encode( `GET / HTTP/1.1\nHOST: ${hostname}\nConnection: close\n\n`, ), ); }, }).pipeTo(conn.writable); const text = await new Response(conn.readable).text(); if (!text.endsWith("\r\n\r\nok")) { console.log(`${hostname} is unavailable`); throw new Error("failed"); } console.log(`${hostname} is available`);});
std

Version Info

Tagged at
11 months ago