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

docs/Node: mention homebrew-npm-noob #2895

Merged
merged 1 commit into from Jul 15, 2017

Conversation

Projects
None yet
2 participants
@zmwangx
Copy link
Contributor

zmwangx commented Jul 14, 2017

I found myself writing quite a few node-based formulae recently, so I wrote a formula generator for npm packages, homebrew-npm-noob (which, as the name hints, is inspired by Tim's homebrew-pypi-poet; hats off). To try it, just

brew install zmwangx/npm-noob/noob

or

pip install homebrew-npm-noob

(Python 3.3+ required.) It generates formulae like

require "language/node"

class Svgo < Formula
  desc "Nodejs-based tool for optimizing SVG vector graphics files"
  homepage "https://github.com/svg/svgo"
  url "https://registry.npmjs.org/svgo/-/svgo-0.7.2.tgz"
  version "0.7.2"
  sha256 "e4fdae5cebe896bc90ec66acd4199495e0b826e55d5e8631c4ba6a0bf968d2ca"

  depends_on "node"

  def install
    system "npm", "install", *Language::Node.std_npm_install_args(libexec)
    bin.install_symlink Dir["#{libexec}/bin/*"]
  end

  test do
    raise "Test not implemented."
  end
end

or

require "language/node"

class BabelCli < Formula
  desc "Babel command line"
  homepage "https://babeljs.io/"
  url "https://registry.npmjs.org/babel-cli/-/babel-cli-6.24.1.tgz"
  version "6.24.1"
  sha256 "d69a00bdb4f35184cda1f5bfe8075cd4d569600b8e61d864d1f08e360367933b"

  devel do
    url "https://registry.npmjs.org/babel-cli/-/babel-cli-7.0.0-alpha.15.tgz"
    version "7.0.0-alpha.15"
    sha256 "e825b9fe8e578aa392a8b398950070d3816c4c75e99953adb07ccfe858aea454"
  end

  depends_on "node"

  def install
    system "npm", "install", *Language::Node.std_npm_install_args(libexec)
    bin.install_symlink Dir["#{libexec}/bin/*"]
  end

  test do
    raise "Test not implemented."
  end
end

It would be nice to "advertise" it in brew's docs so that other developers won't need to manually figure out tarball URLs on the npm registry (not trivial) and write boilerplate code.

docs/Node: mention homebrew-npm-noob
homebrew-npm-noob is a formula generator for npm packages.
@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Jul 15, 2017

Any chance of convincing you to add something to brew create for this?

@zmwangx

This comment has been minimized.

Copy link
Contributor

zmwangx commented Jul 15, 2017

brew create is centered around knowing the URL beforehand:

brew create URL [--autotools|--cmake|--meson] [--no-fetch] [--set-name name] [--set-version version] [--tap user/repo]:
    Generate a formula for the downloadable file at URL and open it in the editor.
    Homebrew will attempt to automatically derive the formula name
    and version, but if it fails, you'll have to make your own template. The wget
    formula serves as a simple example. For the complete API have a look at
    http://www.rubydoc.info/github/Homebrew/brew/master/Formula.
...

In this case we only take a package name, so an alternative syntax needs to be devised, and language/node being a niche (only 27 formulae in core at the moment), a special syntax doesn't seem to be worthwhile, and may even add confusion (trying to brew create <package name> rather than brew create <tarball url> is a quite natural to do).

@MikeMcQuaid MikeMcQuaid merged commit 9378e21 into Homebrew:master Jul 15, 2017

3 checks passed

codecov/patch Coverage not affected when comparing 4ca2efb...dfc4c2d
Details
codecov/project 65.65% remains the same compared to 4ca2efb
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Jul 15, 2017

Convinced me. Thanks again @zmwangx!

@zmwangx

This comment has been minimized.

Copy link
Contributor

zmwangx commented Jul 15, 2017

You're welcome.

@zmwangx zmwangx deleted the zmwangx:docs-mention-homebrew-npm-noob branch Jul 15, 2017

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.