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

features: host override, dynamic pull and commit msg body #41

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

shcarrico
Copy link

This is a somewhat opinionated pull. 😺

TLDR, this makes it possible to run just santari --token your_token. (You can also still use environment variable as before). All other required info is derived from your projects package.json by default.

It also creates dynamic PR and commit messages by using a diff of the existing vs updated dependency lists.

  • read repo / host from package.json if not specified
    • will read package.json and parse out the github host, repository by default
    • can also add repo to your config file, or specify on cli as before
  • accept api token on cli as --token as well as GITHUB_KEY environment variable
  • will attempt to read a local .santari.json without specifying via --config, -c first, then will look for argument path
  • merges config file props with cli so props can be specified similarly
    • defaults are picked first (mostly null except for the GITHUB_KEY env variable, then config file props, then cli args to allow for override, ie, the CLI arguments always win, then config file, then environment var.
  • accept command line or config file arguments for similar props
    • updated cli yargs to follow convention for aliases and work similarly for all props by adding aliases and using .option call
  • generates pull request body and commit message body dynamically based on diff of what was updated
  • documentation updates to match above
  • relaxes a few onerous eslint rules

example commit message:

 chore(package.json): update dependencies

Dev dependencies updated:
* `@types/jasmine : ^3.3.4 -> ^3.3.5`
* `@types/node : ^10.12.12 -> ^10.12.18`

example pull request body:

Dev dependencies updated:

    @types/jasmine : ^3.3.4 -> ^3.3.5
    @types/node : ^10.12.12 -> ^10.12.18

Stan Carrico added 4 commits January 9, 2019 18:23
* read repo / host from package.json if not specified
* accept command line or config file arguments for similar props
* generates pull request body and commit message body dynamically based on diff of what was updated
* documentation updates to match above
@jeremyrajan
Copy link
Owner

jeremyrajan commented Jan 10, 2019

Thanks for the PR @shcarrico 😄 . I was actually planning on adding messages in the PR body, since you did it, its wonderful 🎉 . I will give it a shot later today and merge it! I don't think there is a breaking change right? I was thinking to bump the version to 2.6.0.

@jeremyrajan jeremyrajan self-requested a review January 10, 2019 09:04
@jeremyrajan
Copy link
Owner

hey @shcarrico, apologies in delay in going thru this. Everything looks good, except few changes I put in comments :). I tried to update it, but dont have access to the repo you are PR'ing from. Would be nice you can update and I can merge 🎉 and also resolve conflicts 👼

if (pkg) {
const pkgRepo = pkg.repository.url || pkg.repository;
const pkgGit = gitUrl(pkgRepo);
host = `${pkgGit.host}/api/v3`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think, we need to override it. Because normally the API path should be api.github.com, unless you setup the host in .santari.json.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to match the api path with the supported api version for the client.. normally, this is done for you because you don't supply the host, but in this case if you do supply it i need it with the /api/v3 to work in the later call to github.client(config.token, { hostname: config.host }). The host is being read from the package.json repository settings here, specifically so you don't have to override it in .santari.json. this may be confusing because I am both loading package.json and .santari.json in the same function..

"title": "PR title",
"body": "PR Body"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove title and body from demo config :). Atleast we can show the pr body being populated.

@jeremyrajan
Copy link
Owner

Example here: jeremyrajan/json-markdown#23

this.masterSHA = ''; // master SHA
this.packageSHA = ''; // package JSON SHA
this.packagePath = ''; // package path from repo
this.packageJSON = ''; // JSON parsed version of repo package
this.packageTempPath = ''; // package path where temp package is stored. To be used by ncu
this.depBranchName = `update-deps-santari-${Math.ceil(Math.random() * 100000)}`;
this.mainBranch = 'master';
this.mainBranch = config.branch || 'master';
this.commitMsg = config.msg || 'chore(package.json): update dependencies\n';
Copy link
Owner

@jeremyrajan jeremyrajan Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we can use a different key, like commitMessage instead of msg ?

@shcarrico
Copy link
Author

I will get on this tomorrow!

@jeremyrajan
Copy link
Owner

@shcarrico did you get some time to update this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants