diff --git a/README.md b/README.md
index 856ec77..ea49d95 100644
--- a/README.md
+++ b/README.md
@@ -47,14 +47,35 @@ With that setup the file is updated when `npm start` and `npm build` are run.
## Receiving the versions
The script generates a TypeScript file at the location `./src/_versions.ts` if you haven't provided a different location.
-You'll be able to import the values just like any other package:
+You'll be able to import the values just like any other package, if you want use just versions information, like in environment.ts example file:
```
-import { versions, TsAppVersion } from '../_versions';
+import versions from '../_versions';
+```
+or you can import also TsAppVersion and use direclty in your template, like in app.component.ts example file
```
+import { TsAppVersion } from 'src/_versions.ts';
+import versions from 'src/_versions.ts';
+
+@Component({
+ selector: 'app-root',
+ templateUrl: './app.component.html',
+ styleUrls: ['./app.component.css']
+})
+export class AppComponent {
+ public readonly tsAppVersion: TsAppVersion;
+ constructor() {
+ this.tsAppVersion = versions;
+ }
+}
+```
+
+> backward compatibility with previous version is guarantee
The file will export an object with following variables:
* **version** is the version from the packages.json (e.g. v1.0.0)
+* **name** is the name from the packages.json (e.g. 'sample-app')
+* **description** is the description from the packages.json
* **versionDate** is the timestamp in ISO format when the compilation/package started.
* **versionLong** is the version from the packages.json PLUS the Hash of the current Git-Commit (e.g. v1.0.0-g63962e3) - will only be generated if your repository is a Git Repository
* **gitTag** is the latest Git tag
diff --git a/dist/index.js b/dist/index.js
index 8b80763..e2b3682 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -50,20 +50,33 @@ const outputFile = argv.hasOwnProperty('file') ? argv.file : path.join('src', '_
const versionFile = path.join(projectFolder, outputFile);
// pull version from package.json
-const appVersion = require(packageFile).version;
+const pkg = require(packageFile);
+const appVersion = pkg.version;
+const appName = pkg.name;
+const appDescription = pkg.description;
console.log('[TsAppVersion] ' + colors.green('Application version (from package.json): ') + colors.yellow(appVersion));
+console.log('[TsAppVersion] ' + colors.green('Application description (from package.json): ') + colors.yellow(appName));
+
+let src = `export interface TsAppVersion {
version: string;
+ name: string;
+ description?: string;
versionLong?: string;
versionDate: string;
gitCommitHash?: string;
gitCommitDate?: string;
gitTag?: string;
-}
-export const versions: TsAppVersion = {
+};
+const obj: TsAppVersion = {
version: '${appVersion}',
- versionDate: '${new Date().toISOString()}'
+ name: '${appName}',
+ versionDate: '${new Date().toISOString()}',
`;
+if (appDescription !== undefined && appDescription !== '') {
+ console.log('[TsAppVersion] ' + colors.green('Application description (from package.json): ') + colors.yellow(appDescription));
+ src += ` description: '${appDescription}',\n`;
+}
let enableGit = false;
let gitFolder = projectFolder;
@@ -120,6 +133,7 @@ if (enableGit) {
}
src += `};
+export default obj;
`;
console.log('[TsAppVersion] ' + colors.green('Writing version module to ') + colors.yellow(versionFile));
diff --git a/example/src/app/app.component.css b/example/src/app/app.component.css
index 902d115..16b6640 100644
--- a/example/src/app/app.component.css
+++ b/example/src/app/app.component.css
@@ -84,7 +84,7 @@ svg.material-icons:not(:last-child) {
width: 200px;
margin: 0 8px 16px;
padding: 16px;
- display: flex;
+ display: block;
flex-direction: row;
justify-content: center;
align-items: center;
@@ -97,7 +97,7 @@ svg.material-icons:not(:last-child) {
}
.card.card-small {
- height: 16px;
+ height: 180px;
width: 168px;
}
@@ -122,10 +122,7 @@ svg.material-icons:not(:last-child) {
width: auto;
min-width: 30%;
position: relative;
-}
-
-.card.card.highlight-card span {
- margin-left: 60px;
+ padding: 16px 16px 16px 75px;
}
svg#rocket {
diff --git a/example/src/app/app.component.html b/example/src/app/app.component.html
index 7eb1a6d..7141192 100644
--- a/example/src/app/app.component.html
+++ b/example/src/app/app.component.html
@@ -44,7 +44,14 @@
- This app is running with version {{ version }}
+ This app is running with version {{ version }} (from environment) / {{ tsAppVersion.version }} (from tsAppVersion direclty) and has following information:
+