MCPcopy Index your code
hub / github.com/angular/angular-cli / createNpmRegistry

Function createNpmRegistry

tests/e2e/utils/registry.ts:9–47  ·  view source on GitHub ↗
(
  port: number,
  httpsPort: number,
  withAuthentication = false,
)

Source from the content-addressed store, hash-verified

7import { existsSync } from 'node:fs';
8
9export async function createNpmRegistry(
10 port: number,
11 httpsPort: number,
12 withAuthentication = false,
13): Promise<ChildProcess> {
14 // Setup local package registry
15 const registryPath = join(getGlobalVariable('tmp-root'), 'registry');
16 if (!existsSync(registryPath)) {
17 await mkdir(registryPath);
18 }
19
20 const configFileName = withAuthentication ? 'verdaccio_auth.yaml' : 'verdaccio.yaml';
21 let configContent = await readFile(join(__dirname, '../', configFileName));
22 configContent = configContent
23 .replace(/\$\{HTTP_PORT\}/g, String(port))
24 .replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
25 const configPath = join(registryPath, configFileName);
26
27 await writeFile(configPath, configContent);
28
29 const verdaccioServer = fork(require.resolve('verdaccio/bin/verdaccio'), ['-c', configPath]);
30 for await (const events of on(verdaccioServer, 'message', {
31 signal: AbortSignal.timeout(30_000),
32 })) {
33 if (
34 events.some(
35 (event: unknown) =>
36 event &&
37 typeof event === 'object' &&
38 'verdaccio_started' in event &&
39 event.verdaccio_started,
40 )
41 ) {
42 break;
43 }
44 }
45
46 return verdaccioServer;
47}
48
49// Token was generated using `echo -n 'testing:s3cret' | openssl base64`.
50const VALID_TOKEN = `dGVzdGluZzpzM2NyZXQ=`;

Callers 1

e2e_runner.tsFile · 0.90

Calls 6

getGlobalVariableFunction · 0.90
readFileFunction · 0.90
writeFileFunction · 0.90
joinFunction · 0.85
existsSyncFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected