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

cleanup(core): migrate to picospinner #29138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/nx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"yargs": "^17.6.2",
"yargs-parser": "21.1.1",
"node-machine-id": "1.1.12",
"ora": "5.3.0"
"picospinner": "2.0.0"
},
"peerDependencies": {
"@swc-node/register": "^1.8.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/nx/src/command-line/add/add.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec } from 'child_process';
import { existsSync } from 'fs';
import * as ora from 'ora';
import { Spinner } from 'picospinner';
import { isAngularPluginInstalled } from '../../adapter/angular-json';
import type { GeneratorsJsonEntry } from '../../config/misc-interfaces';
import { readNxJson, type NxJsonConfiguration } from '../../config/nx-json';
Expand Down Expand Up @@ -42,7 +42,7 @@ async function installPackage(
version: string,
nxJson: NxJsonConfiguration
): Promise<void> {
const spinner = ora(`Installing ${pkgName}@${version}...`);
const spinner = new Spinner(`Installing ${pkgName}@${version}...`);
spinner.start();

if (existsSync('package.json')) {
Expand Down Expand Up @@ -126,7 +126,7 @@ async function initializePlugin(
return;
}

const spinner = ora(`Initializing ${pkgName}...`);
const spinner = new Spinner(`Initializing ${pkgName}...`);
spinner.start();

try {
Expand Down
7 changes: 4 additions & 3 deletions packages/nx/src/command-line/connect/connect-to-nx-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { nxVersion } from '../../utils/versions';
import { workspaceRoot } from '../../utils/workspace-root';
import chalk = require('chalk');
import * as ora from 'ora';
import { Spinner } from 'picospinner';
import * as open from 'open';

export function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration) {
Expand Down Expand Up @@ -116,9 +116,10 @@ export async function connectToNxCloudCommand(
options?.generateToken !== true
);
try {
const cloudConnectSpinner = ora(
const cloudConnectSpinner = new Spinner(
`Opening Nx Cloud ${connectCloudUrl} in your browser to connect your workspace.`
).start();
);
cloudConnectSpinner.start();
await sleep(2000);
await open(connectCloudUrl);
cloudConnectSpinner.succeed();
Expand Down
13 changes: 8 additions & 5 deletions packages/nx/src/command-line/import/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { stat, mkdir, rm } from 'node:fs/promises';
import { tmpdir } from 'tmp';
import { prompt } from 'enquirer';
import { output } from '../../utils/output';
import * as createSpinner from 'ora';
import { Spinner } from 'picospinner';
import { detectPlugins, installPlugins } from '../init/init-v2';
import { readNxJson } from '../../config/nx-json';
import { workspaceRoot } from '../../utils/workspace-root';
Expand Down Expand Up @@ -108,9 +108,10 @@ export async function importHandler(options: ImportOptions) {
}

const sourceTempRepoPath = join(tempImportDirectory, 'repo');
const spinner = createSpinner(
const spinner = new Spinner(
`Cloning ${sourceRepository} into a temporary directory: ${sourceTempRepoPath} (Use --depth to limit commit history and speed up clone times)`
).start();
);
spinner.start();
try {
await rm(tempImportDirectory, { recursive: true });
} catch {}
Expand Down Expand Up @@ -200,9 +201,10 @@ export async function importHandler(options: ImportOptions) {
await sourceGitClient.addFetchRemote(importRemoteName, ref);
await sourceGitClient.fetch(importRemoteName, ref);
spinner.succeed(`Fetched ${ref} from ${sourceRepository}`);
spinner.start(
spinner.setText(
`Checking out a temporary branch, ${tempImportBranch} based on ${ref}`
);
spinner.start();
await sourceGitClient.checkout(tempImportBranch, {
new: true,
base: `${importRemoteName}/${ref}`,
Expand Down Expand Up @@ -254,7 +256,8 @@ export async function importHandler(options: ImportOptions) {
ref
);

spinner.start('Cleaning up temporary files and remotes');
spinner.setText('Cleaning up temporary files and remotes');
spinner.start();
await rm(tempImportDirectory, { recursive: true });
await destinationGitClient.deleteGitRemote(importRemoteName);
spinner.succeed('Cleaned up temporary files and remotes');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GitRepository } from '../../../utils/git-utils';
import * as createSpinner from 'ora';
import { Spinner } from 'picospinner';

export async function mergeRemoteSource(
destinationGitClient: GitRepository,
Expand All @@ -9,18 +9,19 @@ export async function mergeRemoteSource(
remoteName: string,
branchName: string
) {
const spinner = createSpinner();
spinner.start(
const spinner = new Spinner(
`Merging ${branchName} from ${sourceRemoteUrl} into ${destination}`
);

spinner.start(`Fetching ${tempBranch} from ${remoteName}`);
spinner.setText(`Fetching ${tempBranch} from ${remoteName}`);
spinner.start();
await destinationGitClient.fetch(remoteName, tempBranch);
spinner.succeed(`Fetched ${tempBranch} from ${remoteName}`);

spinner.start(
spinner.setText(
`Merging files and git history from ${branchName} from ${sourceRemoteUrl} into ${destination}`
);
spinner.start();
await destinationGitClient.mergeUnrelatedHistories(
`${remoteName}/${tempBranch}`,
`feat(repo): merge ${branchName} from ${sourceRemoteUrl}`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as createSpinner from 'ora';
import { Spinner } from 'picospinner';
import { dirname, join, relative } from 'path';
import { mkdir, rm } from 'node:fs/promises';
import { GitRepository } from '../../../utils/git-utils';
Expand All @@ -11,9 +11,8 @@ export async function prepareSourceRepo(
tempImportBranch: string,
sourceRemoteUrl: string
) {
const spinner = createSpinner().start(
`Fetching ${ref} from ${sourceRemoteUrl}`
);
const spinner = new Spinner(`Fetching ${ref} from ${sourceRemoteUrl}`);
spinner.start();
const relativeSourceDir = relative(
gitClient.root,
join(gitClient.root, source)
Expand All @@ -24,10 +23,10 @@ export async function prepareSourceRepo(
: `Filtering git history`;

if (await gitClient.hasFilterRepoInstalled()) {
spinner.start(message);
spinner.setText(message);
await gitClient.filterRepo(relativeSourceDir, relativeDestination);
} else {
spinner.start(
spinner.setText(
`${message} (this might take a few minutes -- install git-filter-repo for faster performance)`
);
await gitClient.filterBranch(
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/src/command-line/sync/sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ora from 'ora';
import { Spinner } from 'picospinner';
import { readNxJson } from '../../config/nx-json';
import { createProjectGraphAsync } from '../../project-graph/project-graph';
import { output } from '../../utils/output';
Expand Down Expand Up @@ -106,7 +106,7 @@ export function syncHandler(options: SyncOptions): Promise<number> {
bodyLines: resultBodyLines,
});

const spinner = ora('Syncing the workspace...');
const spinner = new Spinner('Syncing the workspace...');
spinner.start();

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/src/tasks-runner/run-command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { prompt } from 'enquirer';
import * as ora from 'ora';
import { Spinner } from 'picospinner';
import { join } from 'path';
import {
NxJsonConfiguration,
Expand Down Expand Up @@ -403,7 +403,7 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(
(await promptForApplyingSyncGeneratorChanges());

if (applyChanges) {
const spinner = ora('Syncing the workspace...');
const spinner = new Spinner('Syncing the workspace...');
spinner.start();

// Flush sync generator changes to disk
Expand Down