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

existing and new generator now claims to be "not installed" when it IS installed #234

Closed
yankeeinlondon opened this issue May 29, 2020 · 8 comments

Comments

@yankeeinlondon
Copy link

I have a generator that i've used for years and a new one that's close to "out of the box" and they both are experiencing a mind-boggling error. I've created a video of this problem here:

https://www.screencast.com/t/2aY1Npmu

In a nutshell, both of my generators can be installed with npm i -g generator-my-generator and when I just run yo they show up as options, they can also be updated via yo's interactive menu, but when I go to run them they say that the Generator is not installed!

In my most recent case -- regarding the repo generator-lambda-typescript the exact message it says is:

You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/.
Install them with npm install generator-lambda-typescript:app.

This suggestion of installing via npm install generator-lambda-typescript:app is clearly a syntax error as the :app will not be recognized by NPM. Instead it seems to appear to be a reference to the "default generator" name ... which is defined in the repo.

Where the transpiled version of index.js is as follows:
CODE

I used Rollup (and the typescript plugin to rollup) to transpile but I also tried with transpiling with just Typescripts tsc and that behaved the same.

@yankeeinlondon yankeeinlondon changed the title working and new generator now claims to be "not installed" when it IS installed existing and new generator now claims to be "not installed" when it IS installed May 29, 2020
@yankeeinlondon
Copy link
Author

Also forgot to mention that i checked with the doctor:

image

@yankeeinlondon
Copy link
Author

Also had two other developers try it as well ... same result

@mshima
Copy link
Member

mshima commented May 29, 2020

https://github.com/inocan-group/generator-lambda-typescript/blob/59d3e142882c090132040a820ef9496d5aee68c9/generators/app/index.js#L61

I think it should be exports = Generator; or exports.default = Generator;.

@mshima mshima transferred this issue from yeoman/yeoman May 29, 2020
@mshima
Copy link
Member

mshima commented May 29, 2020

A exception should be thrown at:

return Generator;

When typeof Generator !== 'function'

@yankeeinlondon
Copy link
Author

Ok, this is helpful and reassuring to have a baseline to aim at. Now I need to understand why Typescript and Rollup transpilations have changed and how to ensure they get back to this contract.

@yankeeinlondon
Copy link
Author

It would seem that you used to be able define a named export like so:

import Base from "yeoman-generator";
export class Generator extends Base {
  constructor(args: any[], opts: any) {
    super(args, opts);
  }
}

and this would be usable but now you're required to export a default:

export { Generator as default } from "./Generator"

Not sure when this happened or whether it qualifies as a breaking change in semver but it feels like it probably should. Certainly broke my generator :)

@yankeeinlondon
Copy link
Author

As I looked for an answer it may be that at some point I changed my tsconfig.json settings to include the allowSynethicDefaultImports which can be helpful a lot of times but in this case definitely was not helpful. My generator now looks like this:

import * as YeomanGenerator from "yeoman-generator";
import * as chalk from "chalk";

import { computerText, install } from "./private";

export class Generator extends YeomanGenerator {
  constructor(args: any[], opts: any) {
    super(args, opts);
  }

  initializing() {
    console.log(computerText);
    console.log(chalk`\nStarting the {green Lambda Typescript} generator. {italic For AWS functions with attitude!}\n`);
  }

  install() {
    install(this);
  }
}

and my tsconfig.json like this:

export { Generator as default } from "./Generator";

Is there anywhere in the docs that some baseline config would be helpful?

@mshima
Copy link
Member

mshima commented May 30, 2020

Not sure when this happened or whether it qualifies as a breaking change in semver but it feels like it probably should. Certainly broke my generator :)

I don't think yeoman is to blame about this, looks like yeoman-environment didn't supported exports.Generator at 2.0.0.

Is there anywhere in the docs that some baseline config would be helpful?

I don't think we have TS example at our docs, a full TS example would be helpful.

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