Browse Source

generate git version info

feature/settings-cleanup
Ryexandra 1 year ago
parent
commit
31dacab732
  1. 10
      .eslintrc.json
  2. 1
      .gitignore
  3. 28
      generate_git_verison.js
  4. 5
      package.json
  5. 3
      src/components/footer.tsx
  6. 3
      src/components/navbar.tsx
  7. 13
      yarn.lock

10
.eslintrc.json

@ -54,5 +54,13 @@
"prefer-rest-params": 0,
"quote-props": 0,
"unicorn/filename-case": 0
}
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": 0
}
}
]
}

1
.gitignore

@ -25,3 +25,4 @@ test/data/result.json
package-lock.json
*.orig
src/git-version.ts

28
generate_git_verison.js

@ -0,0 +1,28 @@
const { gitDescribeSync } = require('git-describe');
const { version } = require('./package.json');
const { resolve, relative } = require('path');
const { writeFileSync } = require('fs-extra');
const gitInfo = gitDescribeSync({
dirtySemver: false,
});
gitInfo.version = version;
const file = resolve(__dirname, 'src', 'git-version.ts'); // eslint-disable-line no-undef
writeFileSync(
file,
`// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
/* tslint:disable */
export const VERSION = ${JSON.stringify(gitInfo, null, 4)};
/* tslint:enable */
`,
{ encoding: 'utf-8' }
);
console.log(
`Wrote version info ${gitInfo.raw} to ${relative(
resolve(__dirname, '..'), // eslint-disable-line no-undef
file
)}`
);

5
package.json

@ -9,8 +9,8 @@
"api-test": "jest src/api_tests/api.spec.ts",
"build": "node fuse prod",
"lint": "tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src",
"prebuild": "node generate_translations.js",
"prestart": "node generate_translations.js",
"prebuild": "node generate_translations.js && node generate_git_verison.js",
"prestart": "node generate_translations.js && node generate_git_verison.js",
"start": "node fuse dev"
},
"keywords": [],
@ -29,6 +29,7 @@
"choices.js": "^9.0.1",
"classcat": "^4.0.2",
"emoji-short-name": "^1.0.0",
"git-describe": "^4.0.4",
"husky": "^4.2.5",
"i18next": "^19.4.1",
"inferno": "^7.4.2",

3
src/components/footer.tsx

@ -2,6 +2,7 @@ import { Component } from 'inferno';
import { Link } from 'inferno-router';
import { repoUrl } from '../utils';
import { version } from '../version';
import { VERSION as git_version } from '../git-version';
import { i18n } from '../i18next';
export class Footer extends Component<any, any> {
@ -15,7 +16,7 @@ export class Footer extends Component<any, any> {
<div className="navbar-collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<span class="navbar-text">{version}</span>
<span class="navbar-text">{git_version.raw}</span>
</li>
<li class="nav-item">
<Link class="nav-link" to="/about">

3
src/components/navbar.tsx

@ -32,6 +32,7 @@ import {
imagesDownsize,
} from '../utils';
import { version } from '../version';
import { VERSION as git_version } from '../git-version';
import { i18n } from '../i18next';
import { User } from './user';
import { Icon } from './icon';
@ -179,7 +180,7 @@ class UnwrappedNavbar extends Component<any, NavbarState> {
alt="vaporwave hammer and sickle logo, courtesy of ancestral potato"
/>
</a>
<Link title={version} class="navbar-brand" to="/">
<Link title={git_version.raw} class="navbar-brand" to="/">
{this.state.siteName}
</Link>
{this.state.isLoggedIn && (

13
yarn.lock

@ -3219,6 +3219,15 @@ [email protected]^0.1.1:
dependencies:
assert-plus "^1.0.0"
[email protected]^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/git-describe/-/git-describe-4.0.4.tgz#f3d55bce309becf6dc27fed535d380a621967e8c"
integrity sha512-L1X9OO1e4MusB4PzG9LXeXCQifRvyuoHTpuuZ521Qyxn/B0kWHWEOtsT4LsSfSNacZz0h4ZdYDsDG7f+SrA3hg==
dependencies:
lodash "^4.17.11"
optionalDependencies:
semver "^5.6.0"
[email protected]^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
@ -4771,7 +4780,7 @@ [email protected]^4.2.0:
resolved "https://registry.yarnpkg.com/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020"
integrity sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=
[email protected]^4.17.10:
[email protected]^4.17.10, [email protected]^4.17.11:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
@ -6331,7 +6340,7 @@ [email protected]^2.0.0:
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338"
integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==
"[email protected] || 3 || 4 || 5", [email protected]^5.4.1, [email protected]^5.5.0:
"[email protected] || 3 || 4 || 5", [email protected]^5.4.1, [email protected]^5.5.0, [email protected]^5.6.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

Loading…
Cancel
Save