MCPcopy
hub / github.com/drizzle-team/drizzle-orm / certs

Function certs

drizzle-kit/src/utils/certs.ts:15–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15export const certs = async () => {
16 const res = await runCommand('mkcert --help');
17
18 if (res.exitCode === 0) {
19 const p = envPaths('drizzle-studio', {
20 suffix: '',
21 });
22
23 // create ~/.local/share/drizzle-studio
24 mkdirSync(p.data, { recursive: true });
25
26 // ~/.local/share/drizzle-studio
27 const keyPath = join(p.data, 'localhost-key.pem');
28 const certPath = join(p.data, 'localhost.pem');
29
30 try {
31 // check if the files exist
32 await Promise.all([access(keyPath), access(certPath)]);
33 } catch (e) {
34 // if not create them
35 await runCommand(`mkcert localhost`, { cwd: p.data });
36 }
37 const [key, cert] = await Promise.all([
38 readFile(keyPath, { encoding: 'utf-8' }),
39 readFile(certPath, { encoding: 'utf-8' }),
40 ]);
41 return key && cert ? { key, cert } : null;
42 }
43 return null;
44};

Callers 2

startServerFromSetupFunction · 0.90
schema.tsFile · 0.90

Calls 3

runCommandFunction · 0.85
joinFunction · 0.85
allMethod · 0.45

Tested by

no test coverage detected