fix(core): only show cloud messaging when migrating if not using cloud (#19709)
This commit is contained in:
parent
f98ab3f820
commit
024abd2cdb
@ -223,7 +223,7 @@ Available Task Runners
|
||||
|
||||
#### Index signature
|
||||
|
||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner`: `string` }
|
||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner?`: `string` }
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -303,7 +303,7 @@ Available Task Runners
|
||||
|
||||
#### Index signature
|
||||
|
||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner`: `string` }
|
||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner?`: `string` }
|
||||
|
||||
#### Inherited from
|
||||
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
import { onlyDefaultRunnerIsUsed } from './connect-to-nx-cloud';
|
||||
|
||||
describe('connect-to-nx-cloud', () => {
|
||||
describe('onlyDefaultRunnerIsUsed', () => {
|
||||
it('should say no if tasks runner options is undefined and nxCloudAccessToken is set', () => {
|
||||
expect(
|
||||
onlyDefaultRunnerIsUsed({
|
||||
nxCloudAccessToken: 'xxx-xx-xxx',
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should say yes if tasks runner options is undefined and nxCloudAccessToken is not set', () => {
|
||||
expect(onlyDefaultRunnerIsUsed({})).toBe(true);
|
||||
});
|
||||
|
||||
it('should say yes if tasks runner options is set to default runner', () => {
|
||||
expect(
|
||||
onlyDefaultRunnerIsUsed({
|
||||
tasksRunnerOptions: {
|
||||
default: {
|
||||
runner: 'nx/tasks-runners/default',
|
||||
},
|
||||
},
|
||||
})
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should say no if tasks runner is set to a custom runner', () => {
|
||||
expect(
|
||||
onlyDefaultRunnerIsUsed({
|
||||
tasksRunnerOptions: {
|
||||
default: {
|
||||
runner: 'custom-runner',
|
||||
},
|
||||
},
|
||||
})
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should say yes if tasks runner has options, but no runner and not using cloud', () => {
|
||||
expect(
|
||||
onlyDefaultRunnerIsUsed({
|
||||
tasksRunnerOptions: {
|
||||
default: {
|
||||
options: {
|
||||
foo: 'bar',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should say no if tasks runner has options, but no runner and using cloud', () => {
|
||||
expect(
|
||||
onlyDefaultRunnerIsUsed({
|
||||
tasksRunnerOptions: {
|
||||
default: {
|
||||
options: {
|
||||
foo: 'bar',
|
||||
},
|
||||
},
|
||||
},
|
||||
nxCloudAccessToken: 'xxx-xx-xxx',
|
||||
})
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -10,20 +10,16 @@ import { NxJsonConfiguration } from '../../config/nx-json';
|
||||
import { NxArgs } from '../../utils/command-line-utils';
|
||||
|
||||
export function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration) {
|
||||
if (!nxJson.tasksRunnerOptions) {
|
||||
// No tasks runner options:
|
||||
const defaultRunner = nxJson.tasksRunnerOptions?.default?.runner;
|
||||
|
||||
if (!defaultRunner) {
|
||||
// No tasks runner options OR no default runner defined:
|
||||
// - If access token defined, uses cloud runner
|
||||
// - If no access token defined, uses default
|
||||
return !nxJson.nxCloudAccessToken;
|
||||
}
|
||||
const defaultRunner = nxJson.tasksRunnerOptions?.default;
|
||||
if (
|
||||
!defaultRunner.runner ||
|
||||
defaultRunner.runner === 'nx/tasks-runners/default'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return defaultRunner === 'nx/tasks-runners/default';
|
||||
}
|
||||
|
||||
export async function connectToNxCloudIfExplicitlyAsked(
|
||||
|
||||
@ -121,7 +121,7 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
||||
/**
|
||||
* Path to resolve the runner
|
||||
*/
|
||||
runner: string;
|
||||
runner?: string;
|
||||
/**
|
||||
* Default options for the runner
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user