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

Automate "bower install" after "npm install" #12

Closed
martellaj opened this issue Aug 28, 2015 · 7 comments
Closed

Automate "bower install" after "npm install" #12

martellaj opened this issue Aug 28, 2015 · 7 comments

Comments

@martellaj
Copy link
Contributor

I think you should add the following snippet into the package.json file to automatically run bower install after running npm install. I know this is done when you first use the generator, but if I do a fresh clone of a project that has used the generator and run npm install, I'll be left without any of my bower components. It's a pretty simple addition and I can submit a PR if you think this would be beneficial.

"scripts": {
    "postinstall": "node_modules/.bin/bower install"
  }
@andrewconnell
Copy link
Contributor

Are you referring to the actual generator's package.json or the genratED file? If the latter, I like... the challenge: bower is typically installed globally (esp. if you follow the installation instructions in this & other generators) but the script you have assumes it's installed locally.

If the former, I would prefer if we left it the way it is. The way we have done it, we're following the same model that other generators are following (see generator-angular for instance). That model doesn't have the tool install anything extra... rather you provide instructions to install everything. That's why in the instructions we tell them to do npm install -g generator-office bower. When / if we do a TypeScript option, we would likely add typescript and tsd to the list of globally installed NPM packages.

In addition most developers using Yeoman already have this installed as well as other dependencies.

@martellaj
Copy link
Contributor Author

I meant from the generated file. I thought if it's installed globally, you can run it from anywhere and it'll work as expected as long as there is a bower.json file. The script I was thinking would just be:

"scripts": {
    "postinstall": "bower install"
}

If it sounds good to you, feel free to assign it to me and I will submit a PR by EOD tomorrow.

@andrewconnell
Copy link
Contributor

Sounds good to me... assigned!

Btw when you submit the PR, please be sure to submit to the dev branch as we want to keep the master branch a reflection of what's currently published on NPM's registry. @jthake & I need to formalize the contributor guidelines...

@martellaj
Copy link
Contributor Author

Will do. Thanks, Andrew!

@martellaj
Copy link
Contributor Author

How can I run the generator locally to test if my changes are working as expected? I tried gulp run-yo and it runs the generator, but doesn't create a new package.json file unfortunately. If that's the way to do it, it might be a new bug.

@andrewconnell
Copy link
Contributor

Nope you don't do it like that. it's sort of explained here at the end: http://yeoman.io/authoring/

So to do local dev of a generator, first uninstall the one you got from NPM's registry because you want to test YOUR code, not the globally installed one you got from the public distro.

Then on the command line run npm link within the root of the repo where you have the generator. That's like installing it globally, but without pulling from NPMJS. If you run npm list -g --depth=0 after doing this, you should see the globally installed generator-office, but it will point to your local path where you pulled the repo down.

From there, you want to make sure the run-yo task has the right path pointing to your Yeoman install. You can get this from running which yo from the command line... for example I don't have NPM installed the same way the Node.js distro installs it because I want all my global NPM modules installed in my profile directory so I don't have to run sudo every time I work with global packages.

Make sense?

Once you're finished debugging, you go back to that folder & run npm unlink and then you can install the public generator again using npm install -g generator-office.

@andrewconnell
Copy link
Contributor

Added in f609c24

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