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

Only require tty-... gems that are used in the app #70

Open
slowbro opened this issue Sep 23, 2020 · 1 comment
Open

Only require tty-... gems that are used in the app #70

slowbro opened this issue Sep 23, 2020 · 1 comment

Comments

@slowbro
Copy link
Contributor

slowbro commented Sep 23, 2020

Describe the problem

Perhaps more of a feature suggestion than a problem :) I noticed that when making a new app with teletype, it adds all of the 'tty' gems as dependencies, even though (by default) none of them are used or required:

  spec.add_dependency "tty-box", "~> 0.4.1"
  spec.add_dependency "tty-color", "~> 0.5"
  spec.add_dependency "tty-command", "~> 0.9.0"
  spec.add_dependency "tty-config", "~> 0.3.2"
  spec.add_dependency "tty-cursor", "~> 0.7"
  spec.add_dependency "tty-editor", "~> 0.5"
  spec.add_dependency "tty-file", "~> 0.8.0"
  spec.add_dependency "tty-font", "~> 0.4.0"
  spec.add_dependency "tty-logger", "~> 0.2.0"
  spec.add_dependency "tty-markdown", "~> 0.6.0"
  spec.add_dependency "tty-pager", "~> 0.12"
  spec.add_dependency "tty-pie", "~> 0.3.0"
  spec.add_dependency "tty-platform", "~> 0.2"
  spec.add_dependency "tty-progressbar", "~> 0.17"
  spec.add_dependency "tty-prompt", "~> 0.19"
  spec.add_dependency "tty-screen", "~> 0.7"
  spec.add_dependency "tty-spinner", "~> 0.9"
  spec.add_dependency "tty-table", "~> 0.11.0"
  spec.add_dependency "tty-tree", "~> 0.3"
  spec.add_dependency "tty-which", "~> 0.4"

This seems inefficient; if I install this gem straight out of the box - no commands added, etc - I'd get 20 other gems along with it, even though none of them are used (seemingly).

Steps to reproduce the problem

teletype new test-app
grep 'dependency' test-app/test-app.gemspec

Expected Suggested behaviour

My initial thoughts were:

a) use the 'teletype' command to add a new component. for example, teletype require prompt (???)
b) when running rake build, scrape any requires that reference a tty gem

Option "b" sounds more automated (yay!) but hacky (boo!). Option "a" feels clunky (i.e. why would i need to run teletype instead of just adding a require 'tty/prompt' line..?)... so I'm not sure either suggestion is the best. Opening this more for discussion than anything!

Describe your environment

  • OS version: Arch Linux/kernel 5.8.9
  • Ruby version: 2.6.5
  • TTY version: 0.10.0
@piotrmurach
Copy link
Owner

💯 agree, teleteype needs to only add what's needed. There is a short and long term plan for handling this.

The short term plan is to inject tty dependencies as comments in the gemspec file for user to pick and choose. This is currently implemented in the master branch. If you could test against master branch that would be better as the v0.10.0 is pretty outdated and in dire need of new release as evidenced in Bundler issue.

The long term plan is to use tty-prompt to ask the user multiple choice question about which dependencies they would like to use and add these to the generated gemspec and as requirements in the command.rb file or some other place. However, this would need to wait for when I replace Bundler with custom gemspec generator. I want to as quickly as possible get to release v0.11.0 that has all the updated components(only 2 still left to do).

This comment I made in the referenced issue above explains the 3 stage plan of where I think I want to go with this project. So in the first stage, all tty components would be injected as commented out dependencies. It's kind of similar to how rails setups some of its dependencies.

Please let me know if you like this approach as a first step?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants