Giter Site home page Giter Site logo

generator-license's Introduction

generator-license

build GitHub package.json version Coverage Status NPM version

Generate LICENSE file for your project using Yeoman.

yo license

Getting started

  • Make sure you have yo installed: npm install -g yo
  • Install the generator: npm install -g generator-license
  • Run: yo license, enter your full name and choose a license

The generator will generate the LICENSE file and fill the license field of the package.json.

Compose with generator license in your own generator

generator-license can be easily embedded into your own generator using Yeoman composability.

First, install generator-license as a dependency of your own generator.

npm install --save generator-license

Then call it from your generator.

this.composeWith(require.resolve('generator-license'), {
  name: 'John Doe', // (optional) Owner's name
  email: '[email protected]', // (optional) Owner's email
  website: 'https://example.com', // (optional) Owner's website
  year: '1945', // (optional) License year (defaults to current year)
  licensePrompt: 'Which license do you want to use?', // (optional) customize license prompt text
  defaultLicense: 'MIT', // (optional) Select a default license
  license: 'MIT', // (optional) Select a license, so no license prompt will happen, in case you want to handle it outside of this generator
});

All the options are optional; the generator will prompt for answers when information is not provided.

Supported licenses

For Creative Commons Licenses (useful for media files, documentation and other creative works) you can use generator-license-cc.

License

MIT License

generator-license's People

Contributors

benjaminvanryseghem avatar christophehurpeau avatar dependabot[bot] avatar ek9 avatar fyrkant avatar greenkeeperio-bot avatar hutson avatar hypercubed avatar jozefizso avatar knpwrs avatar millette avatar oscarmarcelo avatar razzeee avatar sboudrias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

generator-license's Issues

composeWith instruction

I tried to use your generator with mine using composeWith and a bit hard. Can you add small instruction how to use it with other generators?

Audit packages

npm audit report

json-schema  <0.4.0
Severity: critical
json-schema is vulnerable to Prototype Pollution - https://github.com/advisories/GHSA-896r-f27r-55mw
fix available via `npm audit fix`
node_modules/json-schema
  jsprim  0.3.0 - 1.4.1 || 2.0.0 - 2.0.1
  Depends on vulnerable versions of json-schema
  node_modules/jsprim

path-parse  <1.0.7
Severity: moderate
Regular Expression Denial of Service in path-parse - https://github.com/advisories/GHSA-hj48-42vr-x3v9
fix available via `npm audit fix`
node_modules/resolve/node_modules/path-parse

qs  6.5.0 - 6.5.2
Severity: high
qs vulnerable to Prototype Pollution - https://github.com/advisories/GHSA-hrpp-h998-j3pp
fix available via `npm audit fix`
node_modules/qs

4 vulnerabilities (1 moderate, 1 high, 2 critical)

Issue migrating to TypeScript

Hi. I'm trying to migrate this generator to TypeScript. I get the following error when trying to migrate this generator to TypeScript:

npm run test

> [email protected] test
> node --experimental-vm-modules node_modules/jest/bin/jest.js

 FAIL  __tests__/app.spec.ts
  โ— Test suite failed to run

    ReferenceError: exports is not defined

      3 | import { createHelpers } from 'yeoman-test';
      4 |
    > 5 | describe('license:app', () => {
        |                       ^
      6 |   let runResult: any;
      7 |   const helpers = createHelpers({});
      8 |

      at __tests__/app.spec.ts:5:23

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.232 s
Ran all test suites.
(node:47283) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Building the generator with npm run build works. And the built package is executed as before. I'm just encountering an error in the tests. There might be an issue in the Jest configuration. I managed to fix it in a project using mocha but I'm not a Jest expert.

The branch to test the problem is there: https://github.com/groovytron/generator-license/tree/migrate-to-typescript

Maybe @mischah could give us a hand on this.

Thanks for your help.

Move to Node.js v14 LTS

generator-license v5.5 declares compatibility with Node.js v10.

We should move to the oldest LTS which is v14 now. Although its maintenance will end in two months, the v14 is a good base runtime for this package.

The yeoman-generator dependency declares compatibility with Node.js v12. Customer still on v12 can use the generator-license v5.5.

See https://endoflife.date/nodejs

Configuration for users

I would like to set website and defaultLicense globally for my convenience. I tried adding a .yo-rc.json to my home directory with { "generator-license": ... } but yo license still doesn't show these values in the prompts. Is this supported?

ESLint for the project

As we are getting contributions, I would suggest to setup eslint as part of tests so the code is linted. It will help keeping the codebase clean and make sure the code does not contain anti-patterns.

Please let me know what you think, I could submit a PR for this.

Update build configuration

The code does not work on NodeJS 4 anymore.

We should update .travis.yml, remove the NodeJS 4 and test on NodeJS 10.

Options not honored when using composeWith()

I'm trying to compose a generator with generator-license but my generator already asks for name and email. I passed these values to composeWith(), but generator-license is still asking for them regardless.

    this.composeWith(
      require.resolve('generator-license', {
        defaultLicense: 'MIT',
        name: this.props.name,
        email: this.props.email
      })
    );

It is also not picking MIT as the default license. Options doesn't seem to be honored at all.

Tests always fail locally

Tests awlays fail locally due posttest script in package.json trying to push data to coveralls.

This should be changed so only travis runs this, otherwise the tests fail locally.

Unlicense is broken

Original report on yeoman/generator-generator#143

Seems to be an error with the filename:

events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/app/templates/Unlicense.txt
    at EditionInterface.exports._copySingle (/home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:44:3)
    at EditionInterface.exports.copy (/home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:22:17)
    at EditionInterface.module.exports [as copyTpl] (/home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy-tpl.js:9:8)
    at module.exports.generators.Base.extend.writing.license (/home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/app/index.js:98:15)
    at /home/username/node_modules/lib/node_modules/generator-generator/node_modules/generator-node/node_modules/generator-license/node_modules/yeoman-generator/lib/base.js:421:16
    at processImmediate [as _immediateCallback] (timers.js:367:17)

Vulnerable dependency - hapijs/hoek package

Github reports that https://github.com/hapijs/hoek package we use has a vulnerability.

Known vulnerability found
CVE-2018-3728
Moderate severity
hoek node module before 5.0.3 or 4.2.1 suffers from a Modification of Assumed-Immutable Data (MAID) vulnerability via...

package-lock.json update suggested:
hoek ~> 4.2.1
Always verify the validity and compatibility of suggestions with your codebase.

We should update the package and make a new release.

Deleting license field when value is UNLICENSED seems to be incorrect

According to https://docs.npmjs.com/files/package.json#license:

Finally, if you do not wish to grant others the right to use a private or unpublished package under any terms:
{ "license": "UNLICENSED" }
Consider also setting "private": true to prevent accidental publication.

Sorry if I miss something, but seem to me that license field must exist and, if desired, to prevent accidental publication, private field should by set to true.

Unlicense Crashes Generator

Tried running yo license and chose the Unlicense option.

AssertionError: Trying to copy from a source that does not exist: /home/hutson/Workspace/generator-license/app/templates/Unlicense.txt

Adding good compasability support

Hey, would you merge a major pull request rehauling this generator to allow easy composability?

We're completely redoing the official generator-node, and we'd love to compose with this generator. But the code in here is pretty old and will not play super well with our.

Additional LICENSEs

I decided to open an issue to discuss addition of a few more licenses:

  • LGPL 3.0 GNU Lesser General Public License - allows use and distribution of modified software without revealing the source code. Useful permissive license for some libraries.
  • Eclipse Public License 1.0 - an Open Source Initiative approve license, derived from CPL (Common Public License). Endorsed and used by Eclipse Foundation.
  1. I can issue issue a PR for LGPL 3.0.With LGPL 3.0 would then have all the licenses from choosealicense.com

  2. I can issue a PR for ( Eclipse Public License 1.0 if you think it would be worth including it.

This would make most popular and open-source initiative approved / OSD compliante licenses available in the generator.

Feel free to use this to discuss what licenses can be added.
Looking forward to comments.

p.s. I just published my Creative Commons LICENSE generator which was inspired by this one. Feel free to check it if you are using Creative Commons LICENSES (they are good to license documentation or written material, but not for actual code): https://github.com/ek9/generator-license-cc

Coveralls.io integration for test coverage tracking

I suggest to add coveralls.io integration for the project. This would allow us to track code coverage and see which tests are remaining to write. This information would also be displayed in the PRs.

Let me know what you think, I can submit a PR for this.

Any ideas on using hookFor?

This generator is nice. I'd like to include it in my generator (https://github.com/Hypercubed/generator-commander). I can use the hookFor and peerDependencies to run generator-license from generator-commander but it will ask again for the author name (that I am pulling from github) and license. Is there a way to skip these prompts when using hookFor? One option is to accept an author name and license from the command line arguments in generator-license.

This seams line a common potential use for generator-license. Any ideas?

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.