feat(core): disable tui when output style is set to an incompatible style (#30873)

This commit is contained in:
Craigory Coppola 2025-04-30 21:00:46 -04:00 committed by GitHub
parent 912a257982
commit 5222a067b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 415 additions and 271 deletions

View File

@ -86,7 +86,7 @@ Print the task graph to the console:
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ~~`--all`~~ | boolean | **Deprecated:** Use `nx run-many` instead |
| `--base` | string | Base of the current branch (usually main). |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
@ -99,7 +99,7 @@ Print the task graph to the console:
| `--help` | boolean | Show help. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |
| `--skipNxCache`, `--disableNxCache` | boolean | Rerun the tasks even when the results are available in the cache. (Default: `false`) |

View File

@ -117,7 +117,7 @@ nx release publish
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--access` | `public`, `restricted` | Overrides the access level of the published package. Unscoped packages cannot be set to restricted. See the npm publish documentation for more information. |
| `--all` | boolean | [deprecated] `run-many` runs all targets on all projects in the workspace if no projects are provided. This option is no longer required. (Default: `true`) |
| `--exclude` | string | Exclude certain projects from being processed. |
@ -128,7 +128,7 @@ nx release publish
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--otp` | number | A one-time password for publishing to a registry that requires 2FA. |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--projects`, `--p` | string | Projects to run. (comma/space delimited project names and/or patterns). |
| `--registry` | string | The registry to publish to. |

View File

@ -92,7 +92,7 @@ Print the task graph to the console:
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--all` | boolean | [deprecated] `run-many` runs all targets on all projects in the workspace if no projects are provided. This option is no longer required. (Default: `true`) |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
| `--configuration`, `--c` | string | This is the configuration to use when performing tasks on projects. |
@ -102,7 +102,7 @@ Print the task graph to the console:
| `--help` | boolean | Show help. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--projects`, `--p` | string | Projects to run. (comma/space delimited project names and/or patterns). |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |

View File

@ -68,7 +68,7 @@ Run's a target named build:test for the myapp project. Note the quotes around th
## Options
| Option | Type | Description |
| ------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
| `--configuration`, `--c` | string | This is the configuration to use when performing tasks on projects. |
| `--exclude` | string | Exclude certain projects from being processed. |
@ -76,7 +76,7 @@ Run's a target named build:test for the myapp project. Note the quotes around th
| `--graph` | string | Show the task graph of the command. Pass a file path to save the graph data instead of viewing it in the browser. Pass "stdout" to print the results to the terminal. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes`, `compact` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `tui`, `dynamic`, `dynamic-legacy`, `static`, `stream`, `stream-without-prefixes`, `compact` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--project` | string | Target project. |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |

View File

@ -86,7 +86,7 @@ Print the task graph to the console:
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ~~`--all`~~ | boolean | **Deprecated:** Use `nx run-many` instead |
| `--base` | string | Base of the current branch (usually main). |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
@ -99,7 +99,7 @@ Print the task graph to the console:
| `--help` | boolean | Show help. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |
| `--skipNxCache`, `--disableNxCache` | boolean | Rerun the tasks even when the results are available in the cache. (Default: `false`) |

View File

@ -117,7 +117,7 @@ nx release publish
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--access` | `public`, `restricted` | Overrides the access level of the published package. Unscoped packages cannot be set to restricted. See the npm publish documentation for more information. |
| `--all` | boolean | [deprecated] `run-many` runs all targets on all projects in the workspace if no projects are provided. This option is no longer required. (Default: `true`) |
| `--exclude` | string | Exclude certain projects from being processed. |
@ -128,7 +128,7 @@ nx release publish
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--otp` | number | A one-time password for publishing to a registry that requires 2FA. |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--projects`, `--p` | string | Projects to run. (comma/space delimited project names and/or patterns). |
| `--registry` | string | The registry to publish to. |

View File

@ -92,7 +92,7 @@ Print the task graph to the console:
## Options
| Option | Type | Description |
| ------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--all` | boolean | [deprecated] `run-many` runs all targets on all projects in the workspace if no projects are provided. This option is no longer required. (Default: `true`) |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
| `--configuration`, `--c` | string | This is the configuration to use when performing tasks on projects. |
@ -102,7 +102,7 @@ Print the task graph to the console:
| `--help` | boolean | Show help. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `dynamic-legacy`, `dynamic`, `tui`, `static`, `stream`, `stream-without-prefixes` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--projects`, `--p` | string | Projects to run. (comma/space delimited project names and/or patterns). |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |

View File

@ -68,7 +68,7 @@ Run's a target named build:test for the myapp project. Note the quotes around th
## Options
| Option | Type | Description |
| ------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--batch` | boolean | Run task(s) in batches for executors which support batches. (Default: `false`) |
| `--configuration`, `--c` | string | This is the configuration to use when performing tasks on projects. |
| `--exclude` | string | Exclude certain projects from being processed. |
@ -76,7 +76,7 @@ Run's a target named build:test for the myapp project. Note the quotes around th
| `--graph` | string | Show the task graph of the command. Pass a file path to save the graph data instead of viewing it in the browser. Pass "stdout" to print the results to the terminal. |
| `--nxBail` | boolean | Stop command execution after the first failed task. (Default: `false`) |
| `--nxIgnoreCycles` | boolean | Ignore cycles in the task graph. (Default: `false`) |
| `--output-style` | `dynamic`, `static`, `stream`, `stream-without-prefixes`, `compact` | Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--output-style` | `tui`, `dynamic`, `dynamic-legacy`, `static`, `stream`, `stream-without-prefixes`, `compact` | Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. |
| `--parallel` | string | Max number of parallel processes [default is 3]. |
| `--project` | string | Target project. |
| `--runner` | string | This is the name of the tasks runner configured in nx.json. |

View File

@ -1,6 +1,11 @@
import * as yargs from 'yargs';
import { withAffectedOptions, withRunManyOptions } from './shared-options';
import {
withAffectedOptions,
withOutputStyleOption,
withRunManyOptions,
} from './shared-options';
import { withEnvironmentVariables } from '../../internal-testing-utils/with-environment';
const argv = yargs.default([]);
@ -77,4 +82,51 @@ describe('shared-options', () => {
);
});
});
describe('withOutputStyle', () => {
it('should coerce outputStyle based on NX_TUI', () =>
withEnvironmentVariables(
{
NX_TUI: 'true',
CI: 'false',
NX_TUI_SKIP_CAPABILITY_CHECK: 'true',
},
() => {
const command = withOutputStyleOption(argv);
const result = command.parseSync([]);
expect(result['output-style']).toEqual('tui');
}
));
it('should set NX_TUI if using not set', () =>
withEnvironmentVariables(
{
NX_TUI: false,
CI: 'false',
NX_TUI_SKIP_CAPABILITY_CHECK: 'true',
},
() => {
const command = withOutputStyleOption(argv);
const result = command.parseSync([]);
expect(process.env.NX_TUI).toEqual('true');
}
));
it.each(['dynamic', 'tui'])(
'should set NX_TUI if using output-style=%s',
() =>
withEnvironmentVariables(
{
NX_TUI: false,
CI: 'false',
NX_TUI_SKIP_CAPABILITY_CHECK: 'true',
},
() => {
const command = withOutputStyleOption(argv);
const result = command.parseSync(['--output-style', 'dynamic']);
expect(process.env.NX_TUI).toEqual('true');
}
)
);
});
});

View File

@ -1,3 +1,6 @@
import { readNxJson } from '../../config/nx-json';
import { shouldUseTui } from '../../tasks-runner/is-tui-enabled';
import { NxArgs } from '../../utils/command-line-utils';
import { Argv, ParserConfigurationOptions } from 'yargs';
interface ExcludeOptions {
@ -286,7 +289,9 @@ export function withOverrides<T extends { _: Array<string | number> }>(
}
const allOutputStyles = [
'tui',
'dynamic',
'dynamic-legacy',
'static',
'stream',
'stream-without-prefixes',
@ -298,17 +303,32 @@ export type OutputStyle = (typeof allOutputStyles)[number];
export function withOutputStyleOption(
yargs: Argv,
choices: ReadonlyArray<OutputStyle> = [
'dynamic-legacy',
'dynamic',
'tui',
'static',
'stream',
'stream-without-prefixes',
]
) {
return yargs.option('output-style', {
describe: `Defines how Nx emits outputs tasks logs. **dynamic**: use dynamic output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended on your local development environments. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output.`,
return yargs
.option('output-style', {
describe: `Defines how Nx emits outputs tasks logs. **tui**: enables the Nx Terminal UI, recommended for local development environments. **dynamic-legacy**: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. **static**: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. **stream**: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. **stream-without-prefixes**: nx prefixes the project name the target is running on, use this option remove the project name prefix from output.`,
type: 'string',
choices,
});
})
.middleware([
(args) => {
const useTui = shouldUseTui(readNxJson(), args as NxArgs);
if (useTui) {
// We have to set both of these because `check` runs after the normalization that
// handles the kebab-case'd args -> camelCase'd args translation.
args['output-style'] = 'tui';
(args as any).outputStyle = 'tui';
}
process.env.NX_TUI = useTui.toString();
},
]);
}
export function withRunOneOptions(yargs: Argv) {

View File

@ -1,60 +1,115 @@
describe('isTuiEnabled', () => {
let originalTuiEnv: string | undefined;
let originalCIEnv: string | undefined;
let isTuiEnabled: typeof import('./is-tui-enabled').isTuiEnabled;
beforeEach(async () => {
jest.resetModules();
isTuiEnabled = await import('./is-tui-enabled').then((m) => m.isTuiEnabled);
originalTuiEnv = process.env.NX_TUI;
originalCIEnv = process.env.CI;
process.env.CI = 'false';
delete process.env.NX_TUI;
});
import { withEnvironmentVariables } from '../internal-testing-utils/with-environment';
import { shouldUseTui } from './is-tui-enabled';
afterEach(() => {
if (originalTuiEnv) {
process.env.NX_TUI = originalTuiEnv;
} else {
delete process.env.NX_TUI;
}
if (originalCIEnv) {
process.env.CI = originalCIEnv;
} else {
delete process.env.CI;
}
});
it('should return true by default', () => {
describe('shouldUseTui', () => {
it('should return true by default', () =>
withEnvironmentVariables(
{
NX_TUI: null,
CI: 'false',
},
() => {
// default is false in nx.json
expect(isTuiEnabled({}, true)).toBe(true);
});
expect(shouldUseTui({}, {}, true)).toBe(true);
}
));
it('should return true if the TUI is enabled', () => {
process.env.NX_TUI = 'true';
expect(isTuiEnabled({}, true)).toBe(true);
});
it('should return true if the TUI is enabled', () =>
withEnvironmentVariables(
{
NX_TUI: 'true',
CI: 'false',
},
() => {
expect(shouldUseTui({}, {}, true)).toBe(true);
}
));
it('should return false if the TUI is disabled', () => {
process.env.NX_TUI = 'false';
expect(isTuiEnabled({}, true)).toBe(false);
});
it('should return false if the TUI is disabled', () =>
withEnvironmentVariables(
{
NX_TUI: 'false',
CI: 'false',
},
() => {
expect(shouldUseTui({}, {}, true)).toBe(false);
}
));
it('should return false in CI', () => {
process.env.CI = 'true';
expect(isTuiEnabled({}, true)).toBe(false);
});
it('should return false in CI', () =>
withEnvironmentVariables(
{
CI: 'true',
},
() => {
expect(shouldUseTui({}, {}, true)).toBe(false);
}
));
it('should return true if TUI is enabled in CI', () => {
process.env.NX_TUI = 'true';
process.env.CI = 'true';
expect(isTuiEnabled({}, true)).toBe(true);
});
it('should return true if TUI is enabled in CI', () =>
withEnvironmentVariables(
{
NX_TUI: 'true',
CI: 'true',
},
() => {
expect(shouldUseTui({}, {}, true)).toBe(true);
}
));
it('should return true if the TUI is enabled in nx.json', () => {
expect(isTuiEnabled({ tui: { enabled: true } }, true)).toBe(true);
});
it('should return true if the TUI is enabled in nx.json', () =>
withEnvironmentVariables(
{
NX_TUI: null,
CI: 'false',
},
() => {
expect(shouldUseTui({ tui: { enabled: true } }, {}, true)).toBe(true);
}
));
it('should return false if the TUI is disabled in nx.json', () => {
expect(isTuiEnabled({ tui: { enabled: false } }, true)).toBe(false);
});
it('should return false if the TUI is disabled in nx.json', () =>
withEnvironmentVariables(
{
NX_TUI: null,
CI: 'false',
},
() => {
expect(shouldUseTui({ tui: { enabled: false } }, {}, true)).toBe(false);
}
));
it.each(['dynamic-legacy', 'static', 'stream'])(
'should be disabled if output-style=%s',
(outputStyle) =>
withEnvironmentVariables(
{
NX_TUI: null,
CI: 'false',
},
() => {
expect(
shouldUseTui({ tui: { enabled: true } }, { outputStyle }, true)
).toBe(false);
}
)
);
it.each(['dynamic', 'tui'])('should be enabled if output-style=%s', () =>
withEnvironmentVariables(
{
NX_TUI: null,
CI: 'false',
},
() => {
expect(
shouldUseTui(
{ tui: { enabled: true } },
{ outputStyle: 'dynamic' },
true
)
).toBe(true);
}
)
);
});

View File

@ -1,60 +1,74 @@
import type { NxJsonConfiguration } from '../config/nx-json';
import { readNxJsonFromDisk } from '../devkit-internals';
import { IS_WASM } from '../native';
import { NxArgs } from '../utils/command-line-utils';
import { isCI } from '../utils/is-ci';
let tuiEnabled = undefined;
export function isTuiEnabled(
nxJson?: NxJsonConfiguration,
skipCapableCheck = false
) {
if (tuiEnabled !== undefined) {
return tuiEnabled;
/**
* @returns If tui is enabled
*/
export function isTuiEnabled() {
return process.env.NX_TUI === 'true';
}
/**
* Determines if the TUI should be enabled for the current environment.
*
* **Note:** This function should almost never be called directly. Instead, use the `isTuiEnabled` function.
*
* @param nxJson `nx.json`
* @param nxArgs CLI Flags passed into Nx
* @param skipCapabilityCheck Mainly used for unit tests.
* @returns `true` if the TUI should be enabled, `false` otherwise.
*/
export function shouldUseTui(
nxJson: NxJsonConfiguration,
nxArgs: NxArgs,
skipCapabilityCheck = process.env.NX_TUI_SKIP_CAPABILITY_CHECK === 'true'
) {
// If the current terminal/environment is not capable of displaying the TUI, we don't run it
const isWindows = process.platform === 'win32';
const isCapable =
skipCapableCheck || (process.stderr.isTTY && isUnicodeSupported());
skipCapabilityCheck || (process.stderr.isTTY && isUnicodeSupported());
if (!isCapable) {
tuiEnabled = false;
process.env.NX_TUI = 'false';
return tuiEnabled;
return false;
}
// The environment variable takes precedence over the nx.json config
if (typeof process.env.NX_TUI === 'string') {
tuiEnabled = process.env.NX_TUI === 'true';
return tuiEnabled;
return process.env.NX_TUI === 'true';
}
// Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
if (['static', 'stream', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
// If the user has specified a non-TUI output style, we disable the TUI
return false;
}
if (
// Interactive TUI doesn't make sense on CI
isCI() ||
// TODO(@JamesHenry): Remove this check once Windows issues are fixed.
if (isCI() || isWindows || IS_WASM) {
tuiEnabled = false;
process.env.NX_TUI = 'false';
return tuiEnabled;
// Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
isWindows ||
// WASM needs further testing
IS_WASM
) {
return false;
}
// Only read from disk if nx.json config is not already provided (and we have not been able to determine tuiEnabled based on the above checks)
if (!nxJson) {
nxJson = readNxJsonFromDisk();
if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
return true;
}
// Respect user config
if (typeof nxJson.tui?.enabled === 'boolean') {
tuiEnabled = Boolean(nxJson.tui?.enabled);
} else {
// Default to enabling the TUI if the system is capable of displaying it
tuiEnabled = true;
return Boolean(nxJson.tui?.enabled);
}
// Also set the environment variable for consistency and ease of checking on the rust side, for example
process.env.NX_TUI = tuiEnabled.toString();
return tuiEnabled;
// Default to enabling the TUI if the system is capable of displaying it
return true;
}
// Credit to https://github.com/sindresorhus/is-unicode-supported/blob/e0373335038856c63034c8eef6ac43ee3827a601/index.js

View File

@ -92,7 +92,7 @@ async function getTerminalOutputLifeCycle(
const isRunOne = initiatingProject != null;
if (isTuiEnabled(nxJson)) {
if (isTuiEnabled()) {
const interceptedNxCloudLogs: (string | Uint8Array<ArrayBufferLike>)[] = [];
const createPatchedConsoleMethod = (

View File

@ -50,7 +50,7 @@ import { SharedRunningTask } from './running-tasks/shared-running-task';
export class TaskOrchestrator {
private taskDetails: TaskDetails | null = getTaskDetails();
private cache: DbCache | Cache = getCache(this.options);
private readonly tuiEnabled = isTuiEnabled(this.nxJson);
private readonly tuiEnabled = isTuiEnabled();
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(
this.options,
this.tuiEnabled

View File

@ -1,6 +1,9 @@
export function isCI() {
if (process.env.CI === 'false') {
return false;
}
return (
(process.env.CI && process.env.CI !== 'false') ||
process.env.CI ||
process.env.TF_BUILD === 'true' ||
process.env.GITHUB_ACTIONS === 'true' ||
process.env.BUILDKITE === 'true' ||