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

Enable commands to report progress #95

Closed
wants to merge 2 commits into from

Conversation

maliroteh-sf
Copy link
Contributor

This PR enabled the Setup requirements to be executed in parallel and have their progress reported visually. It also adds progress report (i.e. cli.action) to other commands.

"listr": "^0.14.3",
"shelljs": "^0.8.3",
"enquirer": "^2.3.6",
"listr2": "^3.3.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of shelljs since we are not using it (a long time ago we were, but not anymore). Also instead of listr I'm going to use listr2 (and enquirer which listr2 needs).

listr is a nice library that we can use to print command progress but is seems to be dead, as it has not taken fixes/updates in a long time. listr2 is an effort by someone else to update listr and add more features to it.

In fact, there is a thread where the creator of listr and the creator of listr2 and few others are discussing the idea of merging all of these back into one library at some point.

But until then, we should use listr2 b/c it has the same MIT license, has all of the listr features, has many more bug fixes, and has more features that are useful to us (such as being able to use Promises as tasks).

expect(createNewDeviceMock).toHaveBeenCalledWith(
deviceName,
iOSDeviceType,
iOSSupportedRuntimes[0]
);
});

test('Logger must be initialized and invoked', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no value in this test. create command extends setup and we already test this in setup.

@@ -24,44 +23,31 @@ export interface Requirement {
logger: Logger;
}

export interface SetupTestCase {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can simplify things by merging testResult message supplementalMessage

}

export interface RequirementList {
requirements: Requirement[];
executeSetup(): Promise<SetupTestResult>;
}

export interface Launcher {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Launcher is not used anywhere

launchNativeBrowser(url: string): Promise<void>;
}

export interface WrappedPromiseResult {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to have different result types and mapping between them.

};

let totalDuration = 0;
const setupTasks = new Listr(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a Listr object for Setup which itself holds another Lister object for all of the subtasks (resulting in auto-indentation when printing output)

testResult.hasMetAllRequirements = false;
}

subTask.title = this.getFormattedTitle(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll start with requirement.title as the task title, but will update the title (with colored passed/failed messages) after a task is completed.

@@ -20,7 +20,7 @@ export class CommonUtils {
return Promise.resolve();
}

public static delay(ms: number): Promise<void> {
public static async delay(ms: number): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL I find this a little amusing after your last epic code clean-up. 😉 Nice catch! 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looks like I'm the one who's been contributing to the problem 😆

@maliroteh-sf
Copy link
Contributor Author

maliroteh-sf commented Feb 5, 2021

Closing this PR since most of this will now go into lwc-dev-mobile-core (see this PR)

@maliroteh-sf maliroteh-sf deleted the progress-repot branch February 10, 2021 18:46
@maliroteh-sf maliroteh-sf restored the progress-repot branch January 30, 2023 13:28
@maliroteh-sf maliroteh-sf deleted the progress-repot branch January 30, 2023 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants