Git Product home page Git Product logo

Comments (13)

ek9 avatar ek9 commented on June 1, 2024 1

I believe this one can be closed now. It might not be too bad idea to add the above comment by @SBoudrias to README.md as it's useful information when composing generators with this one.

from generator-license.

SBoudrias avatar SBoudrias commented on June 1, 2024

@razzeee you can get it from the generated package.json license field.

this.fs.readJSON(this.destinationPath('package.json')).license;

from generator-license.

razzeee avatar razzeee commented on June 1, 2024

Unfortunatly I need it before I write the files, as I need to write it to one of the files I'm writing it too. Not sure how to do it. My code is here: https://github.com/Razzeee/generator-kodi/blob/master/generators/app/index.js

from generator-license.

ek9 avatar ek9 commented on June 1, 2024

@razzeee you use this.props.license after the prompt has been answered it will be populated with value from licenses (so it will be MIT or Apache-2.0 or GPL-3.0 etc.).

You can see how filename is generated by appending .txt to what you chose on https://github.com/jozefizso/generator-license/blob/master/app/index.js#L100

Hope this helps.

from generator-license.

razzeee avatar razzeee commented on June 1, 2024

@ek9
the variable doesn't seem to be filed, probably due to the scope being a different one

from generator-license.

SBoudrias avatar SBoudrias commented on June 1, 2024

Yeoman generators run in isolation. They don't return values.

The only way to get the selected license is from reading the value from the package.json.

You should read about the run loop here http://yeoman.io/authoring/running-context.html and order your tasks in a way where you'll be able to grab the license value from package.json to add it elsewhere.

from generator-license.

razzeee avatar razzeee commented on June 1, 2024

@SBoudrias
so your saying that I need a package.json to solve this? I'm creating python code, so I'm not creating a package.json

from generator-license.

SBoudrias avatar SBoudrias commented on June 1, 2024

@razzeee so you want the license to include in setup.py?

Maybe we could add support for adding the license inside setup.py directly in this generator.

from generator-license.

razzeee avatar razzeee commented on June 1, 2024

nope, I want to add it to a addon.xml as it's a generator for a kodi addon :/

from generator-license.

ek9 avatar ek9 commented on June 1, 2024

Well adding things to addon.xml isn't part of this package's scope. What I believe you should be doing:

  1. Show the prompt in your generator, where user can pick license
  2. Use this generator as a sub generator and pass the license as an option, so this generator uses it.

However, this is likely to require some updates to this package too, as even when provided with some options, it still asks you to confirm things or would provide the questions multiple times. To avoid this, there needs to be some updating on when certain prompts are shown.

I plan to play around with some generators later this week, and wanted to use this one as sub-generator. Perhaps I can answer in more detail later or provide a PR which would make it possible to implement it with this.

from generator-license.

razzeee avatar razzeee commented on June 1, 2024

Well could I just have my own license list and just add a matching license to options when running composeWith? If the generator does the rest of work needed, I'm fine.
Will try and update later.

from generator-license.

ek9 avatar ek9 commented on June 1, 2024

You can find an example on how generator-node uses this module when asking which license to pick

https://github.com/yeoman/generator-node/blob/master/generators/app/index.js#L277

This also happens if you run yo generator (need generator-generator installed for that) as it calls generator-node::app which in turn calls generator-license::app)

The PR that is needed for you need is ability to provide "license" as an option (same way you can do with name etc.), so the license can be skipped. That way, you can have prompt in your own generator and only supply a license value to this generator. Otherwise, it will ask you for license 2nd time.

Also useful documentation on composability of Yeoman Generators: http://yeoman.io/authoring/composability.html

from generator-license.

SBoudrias avatar SBoudrias commented on June 1, 2024

require('generator-license').licenses is the list of license this generator supports. So you can use that.

from generator-license.

Related Issues (20)

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.