Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

WIP: feat(versionpage): added version page for static and SSR #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KevinDanikowski
Copy link

@KevinDanikowski KevinDanikowski commented Jan 16, 2020

added version page Fixes #108

@amclin
Copy link
Owner

amclin commented Jan 21, 2020

I'm not seeing any version info being written out in this example.
Screen Shot 2020-01-21 at 11 41 53 AM

I would expect to see:

  • git commit hash
  • git branch name
  • git tag (if the current version has a tag) and/or the version number retrieved from package.json

@KevinDanikowski
Copy link
Author

I'm not seeing any version info being written out in this example.
Screen Shot 2020-01-21 at 11 41 53 AM

I would expect to see:

  • git commit hash
  • git branch name
  • git tag (if the current version has a tag) and/or the version number retrieved from package.json

Excellent point, I wasn't sure what should be included so I just stuck with some environment and app info. I agree that the information you just suggested should be included. I will add that.

@KevinDanikowski
Copy link
Author

FYI to add branch info, this is the code at a minimum I would need to add. This gets the branch name:

const find = require('findup-sync')

function gitHeadPath(cwd) {
  const filepath = find('.git/HEAD', { cwd: cwd || process.cwd() });
  if (!fs.existsSync(filepath)) {
    throw new Error('.git/HEAD does not exist');
  }
  return filepath;
}

function parseBranch(buf) {
  const match = /ref: refs\/heads\/([^\n]+)/.exec(buf.toString());
  return match ? match[1] : null;
}

console.log(parseBranch(fs.readFileSync(gitHeadPath(process.cwd()))))```

Which I got from https://github.com/jonschlinkert/git-branch/blob/master/index.js , but i wouldn't import directly because it isn't currently maintained and would thus be a vulnerability, better to bring it in house. 

@amclin
Copy link
Owner

amclin commented Jan 21, 2020

There's an NPM module that makes it easy to get the details without having to parse them from the filesystem yourself:
https://www.npmjs.com/package/git-repo-info

@KevinDanikowski
Copy link
Author

@amclin as long as you sign off on it i have no issue using that. so i'll use that one.

@amclin
Copy link
Owner

amclin commented Jan 23, 2020

@KevinDanikowski yes, please use a library for reading git properties. Also, let's be careful about displaying environment variables, as protected values like security tokens may come from the environment. It would be better to only explicitly list specific properties.

@amclin amclin added the enhancement New feature or request label Jan 23, 2020
@amclin
Copy link
Owner

amclin commented Jan 24, 2020

@KevinDanikowski yes, please use a library for reading git properties. Also, let's be careful about displaying environment variables, as protected values like security tokens may come from the environment. It would be better to only explicitly list specific properties.

Currently using git-user-name in the generator to retrieve the user name. There's similar small libraries recommended for other git properties: https://www.npmjs.com/package/git-user-name

I'm ok with either using 1 library with multiple git functions, or a library per function if they're single-function libraries

@amclin amclin changed the title feat(versionpage): added version page for static and SSR WIP: feat(versionpage): added version page for static and SSR Feb 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add version page
2 participants