Skip to content

Commit a51a2aa

Browse files
mydeaclaude
andcommitted
refactor: Move publish logic to lib/publishPackages.ts and call directly
Extract the tarball publishing logic into an importable function in lib/publishPackages.ts and call it directly from registrySetup instead of spawning a subprocess. Remove the old publish-packages.ts script. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8013cc6 commit a51a2aa

3 files changed

Lines changed: 44 additions & 53 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-disable no-console */
2+
import * as childProcess from 'child_process';
3+
import { readFileSync } from 'fs';
4+
import { globSync } from 'glob';
5+
import * as path from 'path';
6+
7+
const repositoryRoot = path.resolve(__dirname, '../../..');
8+
9+
/**
10+
* Publishes all built Sentry package tarballs to the local Verdaccio test registry.
11+
*/
12+
export function publishPackages(): void {
13+
const version = (
14+
JSON.parse(readFileSync(path.join(__dirname, '../package.json'), 'utf8')) as { version: string }
15+
).version;
16+
17+
// Get absolute paths of all the packages we want to publish to the fake registry
18+
// Only include the current versions, to avoid getting old tarballs published as well
19+
const packageTarballPaths = globSync(`packages/*/sentry-*-${version}.tgz`, {
20+
cwd: repositoryRoot,
21+
absolute: true,
22+
});
23+
24+
if (packageTarballPaths.length === 0) {
25+
throw new Error(`No packages to publish for version ${version}, did you run "yarn build:tarballs"?`);
26+
}
27+
28+
const npmrc = path.join(__dirname, '../test-registry.npmrc');
29+
30+
for (const tarballPath of packageTarballPaths) {
31+
console.log(`Publishing tarball ${tarballPath} ...`);
32+
const result = childProcess.spawnSync('npm', ['--userconfig', npmrc, 'publish', tarballPath], {
33+
cwd: repositoryRoot,
34+
encoding: 'utf8',
35+
stdio: 'inherit',
36+
});
37+
38+
if (result.status !== 0) {
39+
throw new Error(`Error publishing tarball ${tarballPath}`);
40+
}
41+
}
42+
}

dev-packages/e2e-tests/publish-packages.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

dev-packages/e2e-tests/registrySetup.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-console */
22
import * as childProcess from 'child_process';
33
import { TEST_REGISTRY_CONTAINER_NAME, VERDACCIO_VERSION } from './lib/constants';
4+
import { publishPackages } from './lib/publishPackages';
45

56
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
67
function groupCIOutput(groupTitle: string, fn: () => void): void {
@@ -41,16 +42,7 @@ export function registrySetup(): void {
4142
throw new Error('Start Registry Process failed.');
4243
}
4344

44-
// Publish packages to fake registry
45-
const publishResult = childProcess.spawnSync('yarn', ['ts-node', 'publish-packages.ts', '--transpile-only'], {
46-
cwd: __dirname,
47-
encoding: 'utf8',
48-
stdio: 'inherit',
49-
});
50-
51-
if (publishResult.status !== 0) {
52-
throw new Error(`Publishing packages to test registry failed with exit code ${publishResult.status}`);
53-
}
45+
publishPackages();
5446
});
5547

5648
console.log('');

0 commit comments

Comments
 (0)