Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Fix local repro publishing #18977

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions code/lib/cli/src/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,20 @@ export abstract class JsPackageManager {

public abstract getRunCommand(command: string): string;

public abstract setRegistryURL(url: string): void;
// NOTE: for some reason yarn prefers the npm registry in
// local development, so always use npm
setRegistryURL(url: string) {
if (url) {
this.executeCommand('npm', ['config', 'set', 'registry', url]);
} else {
this.executeCommand('npm', ['config', 'delete', 'registry']);
}
}

public abstract getRegistryURL(): string;
getRegistryURL() {
const url = this.executeCommand('npm', ['config', 'get', 'registry']).trim();
return url === 'undefined' ? undefined : url;
}

public readonly cwd?: string;

Expand Down
13 changes: 0 additions & 13 deletions code/lib/cli/src/js-package-manager/NPMProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ export class NPMProxy extends JsPackageManager {
return this.uninstallArgs;
}

setRegistryURL(url: string) {
if (url) {
this.executeCommand('npm', ['config', 'set', 'registry', url]);
} else {
this.executeCommand('npm', ['config', 'delete', 'registry']);
}
}

getRegistryURL() {
const url = this.executeCommand('npm', ['config', 'get', 'registry']).trim();
return url === 'undefined' ? undefined : url;
}

protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
return {
overrides: {
Expand Down
4 changes: 2 additions & 2 deletions code/lib/cli/src/js-package-manager/Yarn1Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ describe('Yarn 1 Proxy', () => {

yarn1Proxy.setRegistryURL('https://foo.bar');

expect(executeCommandSpy).toHaveBeenCalledWith('yarn', [
expect(executeCommandSpy).toHaveBeenCalledWith('npm', [
'config',
'set',
'npmRegistryServer',
'registry',
'https://foo.bar',
]);
});
Expand Down
13 changes: 0 additions & 13 deletions code/lib/cli/src/js-package-manager/Yarn1Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ export class Yarn1Proxy extends JsPackageManager {
return `yarn ${command}`;
}

setRegistryURL(url: string) {
if (url) {
this.executeCommand('yarn', ['config', 'set', 'npmRegistryServer', url]);
yannbf marked this conversation as resolved.
Show resolved Hide resolved
} else {
this.executeCommand('yarn', ['config', 'delete', 'npmRegistryServer']);
}
}

getRegistryURL() {
const url = this.executeCommand('yarn', ['config', 'get', 'npmRegistryServer']).trim();
return url === 'undefined' ? undefined : url;
}

protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
return {
resolutions: {
Expand Down
4 changes: 2 additions & 2 deletions code/lib/cli/src/js-package-manager/Yarn2Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ describe('Yarn 2 Proxy', () => {

yarn2Proxy.setRegistryURL('https://foo.bar');

expect(executeCommandSpy).toHaveBeenCalledWith('yarn', [
expect(executeCommandSpy).toHaveBeenCalledWith('npm', [
'config',
'set',
'npmRegistryServer',
'registry',
'https://foo.bar',
]);
});
Expand Down
13 changes: 0 additions & 13 deletions code/lib/cli/src/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ export class Yarn2Proxy extends JsPackageManager {
return `yarn ${command}`;
}

setRegistryURL(url: string) {
if (url) {
this.executeCommand('yarn', ['config', 'set', 'npmRegistryServer', url]);
} else {
this.executeCommand('yarn', ['config', 'delete', 'npmRegistryServer']);
}
}

getRegistryURL() {
const url = this.executeCommand('yarn', ['config', 'get', 'npmRegistryServer']).trim();
return url === 'undefined' ? undefined : url;
}

protected getResolutions(packageJson: PackageJson, versions: Record<string, string>) {
return {
resolutions: {
Expand Down