phantomas icon indicating copy to clipboard operation
phantomas copied to clipboard

Slimmer Phantomas with a plugin/extension model

Open EFF opened this issue 8 years ago • 18 comments

This is just a simple suggestion but I think it could be good to adopt an "extension model" for reporters and engines.

Concretely, I'm suggesting to split the code base and keep the essentials here as the project will no doubt continue to grow both in code size and popularity. The idea would be to extract most of reporters in different npm modules just like grunt or gulp did (default would be json). Same goes for engines (default would be webkit).

Why? Simple answer : In some cases I need a complexe reporter and in some cases I don't. Like most of modern developer, I like to keep my number of external dependencies as small as possible. Moreover, this change will drastically decrease install time.

Tell me what you think.

EFF avatar Feb 01 '16 18:02 EFF

@macbre It makes sens to you ?

If yes, I can start to design something on my free time. If not, I won't push any further

EFF avatar Feb 03 '16 14:02 EFF

I guess we've reached the milestone where phantomas can be considered quite a large and complex project. And it's worth to refactor it into smaller components.

@EFF, your suggestion does make sense. Let's discuss the details.

macbre avatar Feb 07 '16 10:02 macbre

We can start with extracting custom reporters into separate npm modules and just leave plain and json ones in the core.

I can start with phantomas-reporter-elasticsearch.

macbre avatar Mar 24 '16 18:03 macbre

Sorry I was pretty busy lately. I should be able to tackle a couple of reporters this weekend as well. Please make sure that you specify every you do on this so we don't do the job twice.

More over, what was your plan ? simply require the write "phantomas-extension" when and if not installed to throw a basic error like "please make sure to install before using it" ?

EFF avatar Mar 25 '16 02:03 EFF

I'd replace the import of a "local" reporter in reporter.js with a require("phantomas-reporter-<reporter name>"). And of course update the error message.

macbre avatar Mar 25 '16 11:03 macbre

@macbre what do you think if we do it gradually. What I mean by that is while we migrate to this model, we should have both "local" and "external" reporters. Concretely we could add the require("phantomas-reporter-<reporterName>") in a try catch block, if the reporter is not installed as an "external" we try the old "local" import. Then, once we're done, we remove the local reporter import (or not if you want to stay extensible)

EFF avatar Mar 27 '16 18:03 EFF

:+1: for the suggestion above

macbre avatar Mar 27 '16 20:03 macbre

@macbre where do you want to extract the reporters ? Do you want to create a phantomas organization in order to keep most of phantomas development at the same place on GitHub ?

EFF avatar Mar 28 '16 01:03 EFF

Development of phantomas reporters in "private" repositories (i.e. not under github.com/macbre or github.com/phantomas) is fine to me. npm will be used to install reporters. As long as we keep using phantomas in the package names and keywords section in package.json we should be fine. Let's see how it goes :)

macbre avatar Mar 28 '16 20:03 macbre

@EFF - unfortunately github.com/phantomas is already taken :(

macbre avatar Mar 30 '16 19:03 macbre

@macbre let me ask github customer support , the account appears to be empty and inactive. If it is in fact, they might give it away.

EFF avatar Mar 30 '16 21:03 EFF

@EFF: sure, go ahead :)

macbre avatar Mar 31 '16 09:03 macbre

After running the following I'm even more for it :)

macbre@debian:~/github/phantomas$ du -hs node_modules/
202M    node_modules/

macbre avatar Apr 04 '16 17:04 macbre

@macbre I wrote to GitHub, the phantomas account is not qualified as 'dormant' in their records but they contacted the person for me just in case.

see : https://github.com/EFF/phantomas-reporter-cloudwatch for cloudwatch reporter.

I'll continue with statsd another day

EFF avatar Apr 05 '16 17:04 EFF

@EFF thanks x3!

As for the phantomas-reporter-cloudwatch: the package is on npm, I guess we can now remove this reporter (and its dependency) from the main phantomas repo.

macbre avatar Apr 05 '16 18:04 macbre

@EFF, I might have misunderstood the point of this ticket, but shouldn't we exclude phantomas-reporter-cloudwatch package from package.json? If someone wants to report to cloudwatch, then just run npm install phantomas-reporter-cloudwatch. Otherwise the size of all dependencies needed for phantomas to be installed will stay the same.

macbre avatar Apr 06 '16 15:04 macbre

Wo ! my mistake ! Sorry about that ! I'll fix this

EFF avatar Apr 06 '16 16:04 EFF

No worries, we're on the same page now :)

macbre avatar Apr 06 '16 17:04 macbre