Skip to content

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

Open
shcarrico wants to merge 6 commits into
jeremyrajan:masterfrom
shcarrico:master
Open

features: host override, dynamic pull and commit msg body#41
shcarrico wants to merge 6 commits into
jeremyrajan:masterfrom
shcarrico:master

Conversation

@shcarrico

Copy link
Copy Markdown

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

jeremyrajan commented Jan 10, 2019

Copy link
Copy Markdown
Owner

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
Copy Markdown
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 👼

Comment thread src/libs/utils.js
if (pkg) {
const pkgRepo = pkg.repository.url || pkg.repository;
const pkgGit = gitUrl(pkgRepo);
host = `${pkgGit.host}/api/v3`;

Copy link
Copy Markdown
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
Copy Markdown
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..

Comment thread .santari.json
}
} No newline at end of file
"title": "PR title",
"body": "PR Body"

Copy link
Copy Markdown
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
Copy Markdown
Owner

Example here: jeremyrajan/json-markdown#23

Comment thread src/tasks/santari.js
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';

@jeremyrajan jeremyrajan Jan 21, 2019

Copy link
Copy Markdown
Owner

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
Copy Markdown
Author

I will get on this tomorrow!

@jeremyrajan

Copy link
Copy Markdown
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