deno.land / x / netzo@0.5.16 / plugins / utils.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { blue, bold, green, red, white, yellow,} from "https://deno.land/std@0.208.0/fmt/colors.ts";import type { Project } from "./types.ts";
/** * Silence globalThis.console for selected messages by substrings * * @param substringsToSkip {string[]} - substrings to skip * @returns {Proxy} - a proxied console object */export const proxyConsole = (...substringsToSkip: string[]) => { return new Proxy(console, { get(target, prop, _receiver) { const method = target[prop as keyof typeof console]; // intercept method calls // deno-lint-ignore no-explicit-any return (...args: any[]) => { const message = args.join(" "); const skip = substringsToSkip.some((s) => message.includes(s)); if (!skip) method.apply(target, args); }; }, });};
export function log(message: string) { console.log(white(message));}
export function logInfo(message: string) { console.info(blue(`${bold("info")}: ${message}`));}
export function logSuccess(message: string) { console.log(green(`${bold("success")}: ${message}`));}
export function logWarning(message: string) { console.warn(yellow(`${bold("warning")}: ${message}`));}
export function logError(message: string) { console.error(red(`${bold("error")}: ${message}`));}
export function error(message: string): never { // IMPORTANT: cannot use at runtime because Deno.exit is not allowed in Deploy/Subhosting if (Deno.env.get("DENO_REGION")) throw new Error(message); logError(message); Deno.exit(1);}
export const LOGS = { missingApiKey: () => { return "Missing API Key. Set NETZO_API_KEY environment variable or --api-key flag."; }, buildFailed: () => { return "Build failed. Check the project logs for details."; }, envNoticeDevelopment: () => { return "Running locally... Set NETZO_PROJECT_ID and NETZO_API_KEY to connect to remote project."; }, envNoticeProduction: (count: number) => { return `Connected to remote Netzo project. Loaded ${count} environment variables.`; }, notFoundProject: () => { return "Project not found. Check the project ID and API key."; }, notFoundEntrypoint: (entrypoint: string) => { return `Entrypoint file "${entrypoint}" not found. Check the file path.`; }, openInNetzo: (appUrl: string, { _id, workspaceId }: Project) => { const url = `${appUrl}/workspaces/${workspaceId}/projects/${_id}`; return `Open at ${url}`; },} as const;
netzo

Version Info

Tagged at
3 weeks ago