| 107 | } |
| 108 | |
| 109 | function writeAuthFiles(): void { |
| 110 | // Pre-seed htpasswd with a known user so verdaccio accepts publishes |
| 111 | // without any interactive login. Format: username:{SHA}base64(sha1(password)) |
| 112 | const passwordHash = |
| 113 | "{SHA}" + createHash("sha1").update("test").digest("base64"); |
| 114 | |
| 115 | writeFileSync(VERDACCIO_HTPASSWD, `test:${passwordHash}\n`); |
| 116 | |
| 117 | // Write .npmrc with basic auth (base64 of "test:test") scoped to the registry |
| 118 | const basicAuth = Buffer.from("test:test").toString("base64"); |
| 119 | |
| 120 | writeFileSync( |
| 121 | VERDACCIO_NPMRC, |
| 122 | `//${VERDACCIO_HOST}:${VERDACCIO_PORT}/:_auth=${basicAuth}\n`, |
| 123 | ); |
| 124 | } |
| 125 | |
| 126 | function startVerdaccio(background: boolean): void { |
| 127 | logStep("Starting Verdaccio"); |