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
|
#### Index signature
|
||||||
|
|
||||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner`: `string` }
|
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner?`: `string` }
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -303,7 +303,7 @@ Available Task Runners
|
|||||||
|
|
||||||
#### Index signature
|
#### Index signature
|
||||||
|
|
||||||
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner`: `string` }
|
▪ [tasksRunnerName: `string`]: { `options?`: `any` ; `runner?`: `string` }
|
||||||
|
|
||||||
#### Inherited from
|
#### 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';
|
import { NxArgs } from '../../utils/command-line-utils';
|
||||||
|
|
||||||
export function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration) {
|
export function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration) {
|
||||||
if (!nxJson.tasksRunnerOptions) {
|
const defaultRunner = nxJson.tasksRunnerOptions?.default?.runner;
|
||||||
// No tasks runner options:
|
|
||||||
|
if (!defaultRunner) {
|
||||||
|
// No tasks runner options OR no default runner defined:
|
||||||
// - If access token defined, uses cloud runner
|
// - If access token defined, uses cloud runner
|
||||||
// - If no access token defined, uses default
|
// - If no access token defined, uses default
|
||||||
return !nxJson.nxCloudAccessToken;
|
return !nxJson.nxCloudAccessToken;
|
||||||
}
|
}
|
||||||
const defaultRunner = nxJson.tasksRunnerOptions?.default;
|
|
||||||
if (
|
return defaultRunner === 'nx/tasks-runners/default';
|
||||||
!defaultRunner.runner ||
|
|
||||||
defaultRunner.runner === 'nx/tasks-runners/default'
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function connectToNxCloudIfExplicitlyAsked(
|
export async function connectToNxCloudIfExplicitlyAsked(
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|||||||
/**
|
/**
|
||||||
* Path to resolve the runner
|
* Path to resolve the runner
|
||||||
*/
|
*/
|
||||||
runner: string;
|
runner?: string;
|
||||||
/**
|
/**
|
||||||
* Default options for the runner
|
* Default options for the runner
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user