2022-09-02 13:40:12 -05:00
|
|
|
import { SpawnOptions } from 'child_process';
|
2022-08-03 01:01:27 -05:00
|
|
|
import { join } from 'path';
|
|
|
|
|
|
|
|
import { exec } from '@verdaccio/test-cli-commons';
|
2022-09-24 01:53:03 -05:00
|
|
|
import { addRegistry } from '@verdaccio/test-cli-commons';
|
2022-08-03 01:01:27 -05:00
|
|
|
|
2022-09-24 01:53:03 -05:00
|
|
|
function getCommand() {
|
2022-08-03 01:01:27 -05:00
|
|
|
return join(__dirname, './node_modules/.bin/pnpm');
|
|
|
|
}
|
|
|
|
|
2022-09-24 01:53:03 -05:00
|
|
|
function pnpm(options: SpawnOptions, ...args: string[]) {
|
2022-09-02 13:40:12 -05:00
|
|
|
return exec(options, getCommand(), args);
|
2022-08-03 01:01:27 -05:00
|
|
|
}
|
2022-09-24 01:53:03 -05:00
|
|
|
|
|
|
|
async function bumbUp(tempFolder, registry) {
|
|
|
|
await pnpm({ cwd: tempFolder }, 'version', 'minor', ...addRegistry(registry.getRegistryUrl()));
|
|
|
|
}
|
|
|
|
|
|
|
|
async function publish(tempFolder, pkgName, registry, arg: string[] = []) {
|
|
|
|
const resp = await pnpm(
|
|
|
|
{ cwd: tempFolder },
|
|
|
|
'publish',
|
|
|
|
...arg,
|
|
|
|
'--json',
|
|
|
|
...addRegistry(registry.getRegistryUrl())
|
|
|
|
);
|
|
|
|
const parsedBody = JSON.parse(resp.stdout as string);
|
|
|
|
expect(parsedBody.name).toEqual(pkgName);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getInfoVersions(pkgName, registry) {
|
|
|
|
const infoResp = await pnpm(
|
|
|
|
{},
|
|
|
|
'info',
|
|
|
|
pkgName,
|
|
|
|
'--json',
|
|
|
|
...addRegistry(registry.getRegistryUrl())
|
|
|
|
);
|
|
|
|
const infoBody = JSON.parse(infoResp.stdout as string);
|
|
|
|
return infoBody;
|
|
|
|
}
|
|
|
|
|
|
|
|
export { getInfoVersions, pnpm, publish, bumbUp };
|