zeke/package-json-to-readme

Missing license file

TiagoDanin opened this issue ยท 5 comments

Please add license file :)

zeke commented

Yeah still looking for an automated way to add LICENSE files to all my packages, by inferring from license in package.json...

Ooooh, hang on. I had something that did (part) of that. Hang on... https://github.com/wmhilton/create-node-module/blob/js/src/license.js

Here's what I'm thinking:

  • use something like packages-by-user to get all your packages. Or maybe just use the github API
  • for each repo
    • do a simple 404 check (e.g. https://github.com/{user}/{repo}/blob/master/LICENSE.md) and skip to next repo if not needed
    • clone repo
    • read package.json license field
    • use the spdx-license-list/full module to write a LICENSE file
      • replace "<year>" with new Date().getFullYear()
      • replace "<copyright holder>" with user name... either from Github profile or from package.json author field
    • git add LICENSE.md && git commit -m 'Add missing LICENSE' && git push

Part of me thinks this should be a Probot on Glitch... you can fork https://glitch.com/~isomorphic-git-bot which already does several of the above steps.

zeke commented

Part of me thinks this should be a Probot on Glitch...

That would be cool. Install it on an org and it opens PRs as necessary.

Install it on an org and it opens PRs as necessary.

Exactly.