`noteplan-cli plugin:create` fails because of "missing" .gitconfig, and using different email addresses
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 204
- Forks
- 82
- Merge medio
- 22 h 27 min
- PR fusionados (30 d)
- 3
Descripción
Describe the bug
I wanted to explore plugin development for fun but ran into a issues
noteplan-cli plugin:create
(node:72118) UnhandledPromiseRejectionWarning: Error: [git-user-local]: cannot find .gitconfig file on the system`
And additionally
(node:96392) UnhandledPromiseRejectionWarning: Error: Couldn't find username for `my.email@domain.com`
(with my.email@domain.com being a placeholder for my actual one)
noteplan-cli implicitly relies on the existence of the $HOME/.gitconfig in two places [3], [4], to then use the extracted email to lookup the Github username. It fails when it can't find the .gitconfig and it fails if it can't find a username.
As far as I can see that username is used at [5] to greet the user and at [6] as a default as plugin author.
Basically
This approach creates some issues for my setup
Technical issue
In my opinion the used git-user-local module has two issues:
- The file resolution of the used module is not really correct (at least in my case). See [1] It looks under a given path, defaulting to
$HOMEfor a.gitconfig. - Furthermore it parses the config file as an ini file, ignoring gitconfig constructs like
includeandincludeIfwhich in my opinion are often used to switch out usernames and email addresses based on the current working directory.
My git config lives at $HOME/.config/git/config as it makes dot files managment a bit easier and makes my $HOME a lot cleaner. As outlined at [2] that location is a valid "second user-specific configuration file".
"Email" issue
I use different email addresses for projects using the git config includeIf future to switch out my email address and defaulting to my work address when I am not in any git repository. That means noteplan-cli tries to find the Github account based on my work email address which doesn't work.
"Organizational" issue
I might want to just locally experiment on a plugin without having a Github account. Since I think it's only used for [3], and [4] I don't see the hard requirement on it. A fallback on just asking for a name at [4] might be enough.
"Offline" issue
Furthermore I can't create a plugin when I am not online.
Workaround
I can work around it by symlinking ln -s $HOME/.config/git/config $HOME/.gitconfig by I would rather avoid that.
Additionally I have to change my default email address in $HOME/.config/git/config
Solutions space
I wanted to ask what a good approach would be to make it more friendly to different git config structures and "offline" usage. I see these options
- Instead of using the
git-user-localmodule call git directlygit config --global user.emailfrom within node. - Allow to pass a parameter to noteplan-cli
- Don't fail on missing git email address or Github username. Ask when it's needed
I personally would prefer a combination of 1 (addressing the technical downsides of git-user-local and 3 for the email and offline issue.
[1] https://github.com/LasaleFamine/git-user-local/blob/master/src/index.js#L8
[2] https://git-scm.com/docs/git-config#Documentation/git-config.txt-XDGCONFIGHOMEgitconfig
[3] https://github.com/NotePlan/plugins/blob/760d4e746b9d9706607ad08bda3cdf1375cc6f39/src/commands/support/plugin-create.js#L22
[4] https://github.com/NotePlan/plugins/blob/760d4e746b9d9706607ad08bda3cdf1375cc6f39/src/commands/PluginCreate.js#L60
[5] https://github.com/NotePlan/plugins/blob/760d4e746b9d9706607ad08bda3cdf1375cc6f39/src/commands/support/plugin-create.js#L25
[6] https://github.com/NotePlan/plugins/blob/760d4e746b9d9706607ad08bda3cdf1375cc6f39/src/commands/support/plugin-create.js#L44
To Reproduce
Have your git config in a XDG_CONFIG_HOME compatible location, or be offline, or don't have a Github account (at this point). Try to create plugin.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con src/commands/support/plugin-create.js y src/commands/PluginCreate.js, y después reproduce noteplan-cli plugin:create con una configuración de Git XDG, sin una cuenta de GitHub o sin acceso a la red. Define el comportamiento esperado para la configuración de Git ausente, las direcciones de correo electrónico específicas del proyecto, los nombres de usuario de GitHub no disponibles y el uso sin conexión antes de implementar y probar el enfoque elegido.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- git, github, javascript, node.js
- Área
- cli, developer-experience
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100