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

CLI improvement #303 #327

Merged
merged 6 commits into from Oct 22, 2019

Conversation

@bukharim96
Copy link
Contributor

bukharim96 commented Oct 17, 2019

This update adds the init command to the CLI. But, it pretty much does plenty useful things so far:

  • creates test suite structure
  • installs dependencies
  • creates starter template
  • sets up the jest reporter

More features could definitely be added. But I'd like to do that gradually.

It could be used as follows: unmock init.

init [options] [dirname] Sets up a new test suite

  • --installer [installer] Specify Package Manager (yarn/npm)
  • --offline Specify whether to allow install from cache
  • --verbose Specify verbosity of output messages

Read more.

@bukharim96 bukharim96 referenced this pull request Oct 17, 2019
Closed
Copy link
Contributor

ksaaskil left a comment

Thanks a lot for the contribution! You made a very good job as the task was not that clearly defined: some of the commands are now outdated but we can remove them later on. We'll probably also want to add tests and consider if we want to use another CLI framework like oclif, but this is a very good starting point 👍

### Commands:
- `init [options] [dirname]` Sets up a new test suite
- `--installer [installer]` Specify Package Manager (yarn/npm)

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

In future, maybe the CLI could also check existing package-lock.json or yarn.lock to automatically determine the manager?

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

I just added a fix: bd97f36.

return data;
};

export const curl = async (url: string, options: any) => {

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

We probably don't want to do network calls from the CLI curl anymore, maybe the internal curl could use unmock-fetch to mock network calls with in-memory faking. But this is fine now as is!

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

OK

// Basic unmock test
const { u } = unmock;
signs = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'];

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

const?

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

I wasn't sure what would be a great starter template, so I just pulled that of the site.

* This is just to get you started, feel free to delete this.
* Place your tests in this file.
*/
const unmock = require("unmock");

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

In future, we could also support creating TS templates with ES6 imports etc.

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

Perhaps we could have a flag for it: unmock init --useTs

[key: string]: string[];
}

export const listInternal = (logger: ILogger): Promise<undefined> => {

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

Not sure how relevant this is anymore...

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

That makes two of us.

import * as glob from "glob";
import WinstonLogger from "../utils/logger";

export const open = (hash: string, options: any) => {

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

Also this is not relevant anymore, I think.

program.usage("unmock <command>");
program.command("init");

program

This comment has been minimized.

Copy link
@ksaaskil

ksaaskil Oct 18, 2019

Contributor

Not for this PR, but I have very much enjoyed using oclif from Heroku, it makes it easy to create modular CLIs with easy testability.

This comment has been minimized.

Copy link
@bukharim96

bukharim96 Oct 18, 2019

Author Contributor

I'll note that.

@bukharim96

This comment has been minimized.

Copy link
Contributor Author

bukharim96 commented Oct 18, 2019

Thanks @ksaaskil. I wasn't sure of the relativity of the previous commands either. Nevertheless, I just preserved them. I haven't used oclif before, it looks great, and I'd be willing to use it next time round.

@mikesol

This comment has been minimized.

Copy link
Contributor

mikesol commented Oct 22, 2019

Great work! Let's try to get this documented fast before the knowledge gets stale.

@mikesol mikesol merged commit 4da3103 into unmock:dev Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.