Skip to content

Commit c94a26e

Browse files
committed
Test revert verdaccio change
1 parent 1419c96 commit c94a26e

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

WORKSPACE

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,8 @@ npm_translate_lock(
193193
},
194194
pnpm_lock = "//:pnpm-lock.yaml",
195195
public_hoist_packages = {
196-
# Pino of Verdaccio can't be bundled, so we make it loadable as runtime dep.
197-
# Similarly, logger-prettify is dynamically loaded at runtime.
198-
"pino": [""],
196+
# TODO: Remove when https://github.com/verdaccio/verdaccio/commit/bf0e09a509e8e0a74167b0307d129202bc3f40d2 is available.
199197
"@verdaccio/config": [""],
200-
"@verdaccio/logger-prettify": [""],
201198
},
202199
update_pnpm_lock = True,
203200
verify_node_modules_ignored = "//:.bazelignore",

tests/legacy-cli/BUILD.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ e2e_suites(
7575
"package.json",
7676

7777
# Dynamically loaded.
78-
"//:node_modules/verdaccio-auth-memory",
7978
"//tests/legacy-cli/e2e/assets",
79+
"//:node_modules/verdaccio",
80+
"//:node_modules/verdaccio-auth-memory",
8081

81-
# Runtime deps due to bundling issues
82+
# Extra runtime deps due to bundling issues.
83+
# TODO: Clean this up.
8284
"//:node_modules/@verdaccio/config",
83-
"//:node_modules/@verdaccio/logger-prettify",
84-
"//:node_modules/pino",
85+
"//:node_modules/express",
8586
],
8687
runner = ":runner_entrypoint",
8788
)

tests/legacy-cli/e2e/utils/registry.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1+
import { ChildProcess, fork } from 'node:child_process';
2+
import { on } from 'node:events';
13
import { join } from 'node:path';
24
import { getGlobalVariable } from './env';
35
import { writeFile, readFile } from './fs';
46
import { mktempd } from './utils';
5-
import { runServer as runVerdaccioServer } from 'verdaccio';
6-
import { setup as setupVerdaccioLogger } from 'verdaccio/build/lib/logger';
77

88
export async function createNpmRegistry(
99
port: number,
1010
httpsPort: number,
1111
withAuthentication = false,
12-
): Promise<void> {
12+
): Promise<ChildProcess> {
1313
// Setup local package registry
1414
const registryPath = await mktempd('angular-cli-e2e-registry-');
1515

1616
let configContent = await readFile(
17-
join('tests/legacy-cli', withAuthentication ? 'verdaccio_auth.yaml' : 'verdaccio.yaml'),
17+
join(__dirname, '../', withAuthentication ? 'verdaccio_auth.yaml' : 'verdaccio.yaml'),
1818
);
1919
configContent = configContent.replace(/\$\{HTTP_PORT\}/g, String(port));
2020
configContent = configContent.replace(/\$\{HTTPS_PORT\}/g, String(httpsPort));
2121
const configPath = join(registryPath, 'verdaccio.yaml');
2222
await writeFile(configPath, configContent);
2323

24-
const instancePort = withAuthentication ? httpsPort : port;
25-
26-
// Verdaccio config `log` section is not respected by the programmatic API.
27-
setupVerdaccioLogger({
28-
type: 'stdout',
29-
level: 'warn',
30-
format: 'pretty',
31-
});
32-
33-
const server = await runVerdaccioServer(configPath);
34-
35-
await new Promise<void>((resolve) => {
36-
server.listen(instancePort, () => resolve());
37-
});
24+
const verdaccioServer = fork(require.resolve('verdaccio/bin/verdaccio'), ['-c', configPath]);
25+
for await (const events of on(verdaccioServer, 'message', {
26+
signal: AbortSignal.timeout(30_000),
27+
})) {
28+
if (
29+
events.some(
30+
(event: unknown) =>
31+
event &&
32+
typeof event === 'object' &&
33+
'verdaccio_started' in event &&
34+
event.verdaccio_started,
35+
)
36+
) {
37+
break;
38+
}
39+
}
3840

39-
console.log(`Verdaccio running on: http://localhost:${instancePort}`);
41+
return verdaccioServer;
4042
}
4143

4244
// Token was generated using `echo -n 'testing:s3cret' | openssl base64`.

tests/legacy-cli/e2e_runner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ Promise.all([findFreePort(), findFreePort(), findPackageTars()])
223223
setGlobalVariable('package-tars', packageTars);
224224

225225
// NPM registries for the lifetime of the test execution
226-
await createNpmRegistry(httpPort, httpPort);
227-
await createNpmRegistry(httpPort, httpsPort, true);
226+
const registryProcess = await createNpmRegistry(httpPort, httpPort);
227+
const secureRegistryProcess = await createNpmRegistry(httpPort, httpsPort, true);
228228

229229
try {
230230
await runSteps(runSetup, allSetups, 'setup');
@@ -261,8 +261,8 @@ Promise.all([findFreePort(), findFreePort(), findPackageTars()])
261261

262262
process.exitCode = 1;
263263
} finally {
264-
// Note: Need to exit as Verdaccio API does not expose a way to stop the server.
265-
process.exit();
264+
registryProcess.kill();
265+
secureRegistryProcess.kill();
266266
}
267267
})
268268
.catch((err) => {

tests/legacy-cli/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for (const file of testFiles) {
2525

2626
export default {
2727
input: chunks,
28-
external: ['pino', '@verdaccio/logger-prettify'],
28+
external: [],
2929
plugins: [
3030
nodeResolve({
3131
preferBuiltins: true,

0 commit comments

Comments
 (0)