Giter VIP home page Giter VIP logo

Comments (10)

citizen428 avatar citizen428 commented on August 21, 2024 2

@tmattio While not quite as convenient, skipping the post-install command and outputting a message like "Please run yarn/npm install to install all dependencies" seems like an option that could at least be considered.

from spin.

tmattio avatar tmattio commented on August 21, 2024

Hi @johnridesabike, thanks for reporting the issue!

Without adding extra complexity and detecting installed commands, a fix for this could be to use npm instead of yarn, since I think it comes by default when installing node, so it would be safer to assume that users have npm installed on their systems.

from spin.

johnridesabike avatar johnridesabike commented on August 21, 2024

Would it make sense to make an option for it? I’m imagining something like:

Install dependencies with npm? [Y/n]

And if you select n it can say something like:

Setup complete. Before you begin development, you’ll need to install the dependencies with npm or yarn.

I imagine that anyone with yarn installed is familiar enough with it to know how to run it themselves. This approach is still flexible enough to let users use whichever package manager they want.

from spin.

tmattio avatar tmattio commented on August 21, 2024

@johnridesabike I'm a bit hesitant to add new prompts. I feel like Spin already asks too many questions when generating projects. If there is a satisfying solution to this that does not require adding a new prompt, I'd prefer to look into it.

In fact, thinking about your first suggestion, I think the cost of the added complexity of using one command or the other depending on the user's system will be justified if the alternative is to add another prompt.

from spin.

tmattio avatar tmattio commented on August 21, 2024

@citizen428 Good idea! Actually, we could tweak the behavior of the post-install commands to make them optional. If the post-install command is optional, it will run only if the user has the command on its system, otherwise, it would just ignore it, or eventually write a non-error message. What do you think?

EDIT: Maybe that's what you meant by "skipping the post-install"?

from spin.

citizen428 avatar citizen428 commented on August 21, 2024

Your proposed solution is slightly more sophisticated than what I had in mind, I wouldn't even have attempted to run the command, just unconditionally output the message.

I like your approach though, as we'd essentially just have to change the following pattern match:

        switch (
          Utils.Sys.exec("which", ~args=[|el.command|]) |> Lwt_main.run
        ) {
        | WEXITED(0) => ()
        | _ => raise(Errors.External_command_unavailable(el.command))
        };

Instead of raising Errors.External_command_unavailable we could just print an error like

${command} unvailable.
Please run ${command} ${args}" 

On second thought, there's a lot happening after that switch, which we may need to move into the first match clause.

from spin.

citizen428 avatar citizen428 commented on August 21, 2024

@tmattio I quickly hacked something together, this is what it looks like:

Screen Shot 2020-03-26 at 23 24 58

from spin.

johnridesabike avatar johnridesabike commented on August 21, 2024

For what it's worth, Create React App will automatically use either yarn or npm: https://github.com/facebook/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L333

from spin.

citizen428 avatar citizen428 commented on August 21, 2024

Thanks @johnridesabike! But I do think it makes more sense for Spin to have consistent handling of all post-install commands rather than a special case for npm/yarn.

from spin.

tmattio avatar tmattio commented on August 21, 2024

A fix for this is implemented in #74. The bs-react template will use yarn if it is available, or npm if not.

We define this in the template like this:

(post_gen
  (actions 
    (run yarn install))
  (message "🎁  Installing packages. This might take a couple minutes.")
  (enabled_if (not (run which yarn))))

(post_gen
  (actions 
    (run npm install))
  (message "🎁  Installing packages. This might take a couple minutes.")
  (enabled_if (run which yarn)))

Closing this now since I want to merge the PR in the next days (and tidy up the issue board at the same time).

from spin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.