mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
add setRegistryURL to jspackagemanager
This commit is contained in:
parent
e3a7dbfb97
commit
a13f330517
@ -36,6 +36,8 @@ export abstract class JsPackageManager {
|
||||
|
||||
public abstract getRunCommand(command: string): string;
|
||||
|
||||
public abstract setRegistryURL(url: string): void;
|
||||
|
||||
/**
|
||||
* Install dependencies listed in `package.json`
|
||||
*/
|
||||
|
@ -21,6 +21,21 @@ describe('NPM Proxy', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setRegistryUrl', () => {
|
||||
it('should run `npm config set registry https://foo.bar`', () => {
|
||||
const executeCommandSpy = jest.spyOn(npmProxy, 'executeCommand').mockReturnValue('');
|
||||
|
||||
npmProxy.setRegistryURL('https://foo.bar');
|
||||
|
||||
expect(executeCommandSpy).toHaveBeenCalledWith('npm', [
|
||||
'config',
|
||||
'set',
|
||||
'registry',
|
||||
'https://foo.bar',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('installDependencies', () => {
|
||||
describe('npm6', () => {
|
||||
it('should run `npm install`', () => {
|
||||
|
@ -61,6 +61,11 @@ export class NPMProxy extends JsPackageManager {
|
||||
return this.uninstallArgs;
|
||||
}
|
||||
|
||||
setRegistryURL(url: string) {
|
||||
const args = ['config', 'set', 'registry', url];
|
||||
this.executeCommand('npm', args);
|
||||
}
|
||||
|
||||
protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
|
||||
return {
|
||||
overrides: {
|
||||
|
@ -21,6 +21,21 @@ describe('Yarn 1 Proxy', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setRegistryUrl', () => {
|
||||
it('should run `yarn config set npmRegistryServer https://foo.bar`', () => {
|
||||
const executeCommandSpy = jest.spyOn(yarn1Proxy, 'executeCommand').mockReturnValue('');
|
||||
|
||||
yarn1Proxy.setRegistryURL('https://foo.bar');
|
||||
|
||||
expect(executeCommandSpy).toHaveBeenCalledWith('yarn', [
|
||||
'config',
|
||||
'set',
|
||||
'npmRegistryServer',
|
||||
'https://foo.bar',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('installDependencies', () => {
|
||||
it('should run `yarn`', () => {
|
||||
const executeCommandSpy = jest.spyOn(yarn1Proxy, 'executeCommand').mockReturnValue('');
|
||||
|
@ -16,6 +16,11 @@ export class Yarn1Proxy extends JsPackageManager {
|
||||
return `yarn ${command}`;
|
||||
}
|
||||
|
||||
setRegistryURL(url: string) {
|
||||
const args = ['config', 'set', 'npmRegistryServer', url];
|
||||
this.executeCommand('yarn', args);
|
||||
}
|
||||
|
||||
protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
|
||||
return {
|
||||
resolutions: {
|
||||
|
@ -31,6 +31,21 @@ describe('Yarn 2 Proxy', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setRegistryUrl', () => {
|
||||
it('should run `yarn config set npmRegistryServer https://foo.bar`', () => {
|
||||
const executeCommandSpy = jest.spyOn(yarn2Proxy, 'executeCommand').mockReturnValue('');
|
||||
|
||||
yarn2Proxy.setRegistryURL('https://foo.bar');
|
||||
|
||||
expect(executeCommandSpy).toHaveBeenCalledWith('yarn', [
|
||||
'config',
|
||||
'set',
|
||||
'npmRegistryServer',
|
||||
'https://foo.bar',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addDependencies', () => {
|
||||
it('with devDep it should run `yarn install -D @storybook/addons`', () => {
|
||||
const executeCommandSpy = jest.spyOn(yarn2Proxy, 'executeCommand').mockReturnValue('');
|
||||
|
@ -16,6 +16,11 @@ export class Yarn2Proxy extends JsPackageManager {
|
||||
return `yarn ${command}`;
|
||||
}
|
||||
|
||||
setRegistryURL(url: string) {
|
||||
const args = ['config', 'set', 'npmRegistryServer', url];
|
||||
this.executeCommand('yarn', args);
|
||||
}
|
||||
|
||||
protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
|
||||
return {
|
||||
resolutions: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user