Comments (10)
@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.
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.
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.
@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.
@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.
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.
@tmattio I quickly hacked something together, this is what it looks like:
from spin.
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.
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.
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)
- Prompts unreadable on light themes HOT 5
- Validate that used variables are defined HOT 1
- Support specifying the files that are actual templates and just copy the rest of the files mode? HOT 9
- change default license? HOT 2
- Use dune runtest for rely HOT 2
- Generator documenation HOT 2
- Update template rules for `project_description`
- Cannot spin Dream template with opam 2.0.8
- Improve prompts
- Improve error reporting
- Community templates housekeeping
- Global config `(create_switch false)` ignored
- Update hello project generator's docstrings
- Reading terminal input and escaping characters
- Add a section in the `hello` project generator with how-tos
- Handle short versions of GitHub URLS
- Can not build newly generated "bin" or "hello" project HOT 2
- When the description end with a `.`, text UI is broken.
- "Create switches when generating project" config value is not respected
- Leave traces on the project about the tool (spin) and template used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spin.