Skip to content

Move Terminal from node-core-library to the terminal package. #3176

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

Merged
merged 18 commits into from
Feb 17, 2024
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
1 change: 1 addition & 0 deletions apps/heft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@rushstack/node-core-library": "workspace:*",
"@rushstack/operation-graph": "workspace:*",
"@rushstack/rig-package": "workspace:*",
"@rushstack/terminal": "workspace:*",
"@rushstack/ts-command-line": "workspace:*",
"@types/tapable": "1.0.6",
"chokidar": "~3.4.0",
Expand Down
26 changes: 10 additions & 16 deletions apps/heft/src/cli/HeftActionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ import { performance } from 'perf_hooks';
import { createInterface, type Interface as ReadlineInterface } from 'readline';
import os from 'os';

import {
AlreadyReportedError,
Colors,
ConsoleTerminalProvider,
InternalError,
type ITerminal,
type IPackageJson
} from '@rushstack/node-core-library';
import { AlreadyReportedError, InternalError, type IPackageJson } from '@rushstack/node-core-library';
import { Colorize, ConsoleTerminalProvider, type ITerminal } from '@rushstack/terminal';
import {
type IOperationExecutionOptions,
type IWatchLoopState,
Expand Down Expand Up @@ -93,7 +87,7 @@ export function ensureCliAbortSignal(terminal: ITerminal): AbortSignal {
process.exit(1);
} else {
terminal.writeLine(
Colors.yellow(Colors.bold(`Canceling... Press Ctrl+C again to forcibly terminate.`))
Colorize.yellow(Colorize.bold(`Canceling... Press Ctrl+C again to forcibly terminate.`))
);
}

Expand Down Expand Up @@ -150,8 +144,8 @@ export async function runWithLoggingAsync(
const durationSeconds: number = Math.round(duration) / 1000;
const finishedLoggingLine: string = `-------------------- ${finishedLoggingWord} (${durationSeconds}s) --------------------`;
terminal.writeLine(
Colors.bold(
(encounteredError ? Colors.red : encounteredWarnings ? Colors.yellow : Colors.green)(
Colorize.bold(
(encounteredError ? Colorize.red : encounteredWarnings ? Colorize.yellow : Colorize.green)(
finishedLoggingLine
)
)
Expand Down Expand Up @@ -313,7 +307,7 @@ export class HeftActionRunner {
await watchLoop.runIPCAsync();
} else {
await watchLoop.runUntilAbortedAsync(cliAbortSignal, () => {
terminal.writeLine(Colors.bold('Waiting for changes. Press CTRL + C to exit...'));
terminal.writeLine(Colorize.bold('Waiting for changes. Press CTRL + C to exit...'));
terminal.writeLine('');
});
}
Expand All @@ -336,16 +330,16 @@ export class HeftActionRunner {
// Write an empty line to the terminal for separation between iterations. We've already iterated
// at this point, so log out that we're about to start a new run.
terminal.writeLine('');
terminal.writeLine(Colors.bold('Starting incremental build...'));
terminal.writeLine(Colorize.bold('Starting incremental build...'));
},
executeAsync: (state: IWatchLoopState): Promise<OperationStatus> => {
return this._executeOnceAsync(executionManager, state.abortSignal, state.requestRun);
},
onRequestRun: (requestor?: string) => {
terminal.writeLine(Colors.bold(`New run requested by ${requestor || 'unknown task'}`));
terminal.writeLine(Colorize.bold(`New run requested by ${requestor || 'unknown task'}`));
},
onAbort: () => {
terminal.writeLine(Colors.bold(`Cancelling incremental build...`));
terminal.writeLine(Colorize.bold(`Cancelling incremental build...`));
}
});
return watchLoop;
Expand Down Expand Up @@ -392,7 +386,7 @@ export class HeftActionRunner {
// Only write once, and write with yellow to make it stand out without writing a warning to stderr
hasWarnedAboutSkippedPhases = true;
this._terminal.writeLine(
Colors.bold(
Colorize.bold(
'The provided list of phases does not contain all phase dependencies. You may need to run the ' +
'excluded phases manually.'
)
Expand Down
9 changes: 2 additions & 7 deletions apps/heft/src/cli/HeftCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ import {
type CommandLineFlagParameter,
type CommandLineAction
} from '@rushstack/ts-command-line';
import {
Terminal,
InternalError,
ConsoleTerminalProvider,
AlreadyReportedError,
type ITerminal
} from '@rushstack/node-core-library';
import { InternalError, AlreadyReportedError } from '@rushstack/node-core-library';
import { Terminal, ConsoleTerminalProvider, type ITerminal } from '@rushstack/terminal';

import { MetricsCollector } from '../metrics/MetricsCollector';
import { HeftConfiguration } from '../configuration/HeftConfiguration';
Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/AliasAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { ITerminal } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';
import {
AliasCommandLineAction,
type IAliasCommandLineActionOptions,
Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/CleanAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type CommandLineFlagParameter,
type CommandLineStringListParameter
} from '@rushstack/ts-command-line';
import type { ITerminal } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';
import { OperationStatus } from '@rushstack/operation-graph';

import type { IHeftAction, IHeftActionOptions } from './IHeftAction';
Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/IHeftAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See LICENSE in the project root for license information.

import type { CommandLineAction } from '@rushstack/ts-command-line';
import type { ITerminal } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import type { HeftConfiguration } from '../../configuration/HeftConfiguration';
import type { MetricsCollector } from '../../metrics/MetricsCollector';
Expand Down
3 changes: 2 additions & 1 deletion apps/heft/src/cli/actions/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
type CommandLineParameterProvider,
type CommandLineStringListParameter
} from '@rushstack/ts-command-line';
import { AlreadyReportedError, type ITerminal } from '@rushstack/node-core-library';
import { AlreadyReportedError } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import { Selection } from '../../utilities/Selection';
import { HeftActionRunner } from '../HeftActionRunner';
Expand Down
10 changes: 2 additions & 8 deletions apps/heft/src/configuration/HeftConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
// See LICENSE in the project root for license information.

import * as path from 'path';
import {
Terminal,
type ITerminalProvider,
type IPackageJson,
PackageJsonLookup,
InternalError,
type ITerminal
} from '@rushstack/node-core-library';
import { type IPackageJson, PackageJsonLookup, InternalError } from '@rushstack/node-core-library';
import { Terminal, type ITerminalProvider, type ITerminal } from '@rushstack/terminal';
import { trueCasePathSync } from 'true-case-path';
import { type IRigConfig, RigConfig } from '@rushstack/rig-package';

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/configuration/RigPackageResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import * as path from 'path';
import {
PackageJsonLookup,
Import,
type ITerminal,
type INodePackageJson,
type IPackageJson
} from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';
import type { IRigConfig } from '@rushstack/rig-package';

/**
Expand Down
3 changes: 2 additions & 1 deletion apps/heft/src/pluginFramework/HeftPluginHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// See LICENSE in the project root for license information.

import { SyncHook } from 'tapable';
import { InternalError, type ITerminal } from '@rushstack/node-core-library';
import { InternalError, } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import type { HeftPluginDefinitionBase } from '../configuration/HeftPluginDefinition';
import type { IHeftPlugin } from './IHeftPlugin';
Expand Down
3 changes: 1 addition & 2 deletions apps/heft/src/pluginFramework/logging/LoggingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { ScopedLogger } from './ScopedLogger';
import {
FileError,
type FileLocationStyle,
type ITerminalProvider,
type IFileErrorFormattingOptions
} from '@rushstack/node-core-library';

import type { ITerminalProvider } from '@rushstack/terminal';
export interface ILoggingManagerOptions {
terminalProvider: ITerminalProvider;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { ITerminal } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import type { IScopedLogger } from './ScopedLogger';

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/pluginFramework/logging/ScopedLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Terminal,
type ITerminalProvider,
type ITerminal
} from '@rushstack/node-core-library';
} from '@rushstack/terminal';

import { LoggingManager } from './LoggingManager';

Expand Down
3 changes: 2 additions & 1 deletion apps/heft/src/plugins/CopyFilesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import type * as fs from 'fs';
import * as path from 'path';
import { AlreadyExistsBehavior, FileSystem, Async, type ITerminal } from '@rushstack/node-core-library';
import { AlreadyExistsBehavior, FileSystem, Async } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import { Constants } from '../utilities/Constants';
import {
Expand Down
3 changes: 2 additions & 1 deletion apps/heft/src/plugins/DeleteFilesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// See LICENSE in the project root for license information.

import type * as fs from 'fs';
import { FileSystem, Async, type ITerminal } from '@rushstack/node-core-library';
import { FileSystem, Async } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';

import { Constants } from '../utilities/Constants';
import {
Expand Down
3 changes: 2 additions & 1 deletion apps/heft/src/utilities/CoreConfigFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
PathResolutionMethod,
type IJsonPathMetadataResolverOptions
} from '@rushstack/heft-config-file';
import { Import, PackageJsonLookup, type ITerminal, InternalError } from '@rushstack/node-core-library';
import { Import, PackageJsonLookup, InternalError } from '@rushstack/node-core-library';
import type { ITerminal } from '@rushstack/terminal';
import type { IRigConfig } from '@rushstack/rig-package';

import type { IDeleteOperation } from '../plugins/DeleteFilesPlugin';
Expand Down
3 changes: 2 additions & 1 deletion apps/rush/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"@microsoft/rush-lib": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"colors": "~1.2.1",
"semver": "~7.5.4"
"semver": "~7.5.4",
"@rushstack/terminal": "workspace:*"
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions apps/rush/src/start-dev-docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import { Colors, ConsoleTerminalProvider, Terminal } from '@rushstack/node-core-library';
import { Colorize, ConsoleTerminalProvider, Terminal } from '@rushstack/terminal';

const terminal: Terminal = new Terminal(new ConsoleTerminalProvider());

terminal.writeLine('For instructions on debugging Rush, please see this documentation:');
terminal.writeLine(Colors.bold('https://rushjs.io/pages/contributing/debugging/'));
terminal.writeLine(Colorize.bold('https://rushjs.io/pages/contributing/debugging/'));
8 changes: 2 additions & 6 deletions apps/rush/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ import colors from 'colors/safe';
import * as os from 'os';
import * as semver from 'semver';

import {
ConsoleTerminalProvider,
Text,
PackageJsonLookup,
type ITerminalProvider
} from '@rushstack/node-core-library';
import { Text, PackageJsonLookup } from '@rushstack/node-core-library';
import { ConsoleTerminalProvider, type ITerminalProvider } from '@rushstack/terminal';
import { EnvironmentVariableNames } from '@microsoft/rush-lib';
import * as rushLib from '@microsoft/rush-lib';

Expand Down
3 changes: 2 additions & 1 deletion build-tests/install-test-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"devDependencies": {
"@microsoft/rush-lib": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"@rushstack/rush-sdk": "workspace:*"
"@rushstack/rush-sdk": "workspace:*",
"@rushstack/terminal": "workspace:*"
}
}
Loading