Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DLCM
UI
DLCM-Portal
Commits
22070a71
Commit
22070a71
authored
Mar 19, 2020
by
Florent POITTEVIN
Browse files
feat: 1191 Display version form pom.xml
(cherry picked from commit 51525f9971854839693b3b9695ccc499563c2ea6)
parent
decf4cec
Changes
2
Hide whitespace changes
Inline
Side-by-side
git.version.ts
View file @
22070a71
import
{
writeFileSync
}
from
"
fs
"
;
/* tslint:disable:no-trailing-whitespace */
import
{
promises
as
fsPromises
,
writeFileSync
,
}
from
"
fs
"
;
import
{
dedent
}
from
"
tslint/lib/utils
"
;
import
{
parseString
}
from
"
xml2js
"
;
const
util
=
require
(
"
util
"
);
const
exec
=
util
.
promisify
(
require
(
"
child_process
"
).
exec
);
async
function
createVersionsFile
(
filename
:
string
)
{
async
function
createVersionsFile
(
filename
:
string
):
Promise
<
void
>
{
let
version
=
undefined
;
// process.env.npm_package_version;
fsPromises
.
readFile
(
"
./pom.xml
"
,
"
utf-8
"
)
.
then
((
xml
)
=>
{
parseString
(
xml
,
(
err
,
result
)
=>
{
if
(
err
)
{
// tslint:disable-next-line:no-console
console
.
log
(
"
There was an error when parsing the file pom.xml to json:
"
+
err
);
}
else
{
version
=
result
.
project
.
version
;
}
});
})
.
catch
((
reason
)
=>
{
// tslint:disable-next-line:no-console
console
.
log
(
"
There was some problem reading the file pom.xml:
"
+
reason
);
});
const
revision
=
(
await
exec
(
"
git rev-parse --short HEAD
"
)).
stdout
.
toString
().
trim
();
const
branch
=
(
await
exec
(
"
git rev-parse --abbrev-ref HEAD
"
)).
stdout
.
toString
().
trim
();
console
.
log
(
`version: '
${
process
.
env
.
npm_package_version
}
', revision: '
${
revision
}
', branch: '
${
branch
}
'`
);
// tslint:disable-next-line
console
.
log
(
`version: '
${
version
}
', revision: '
${
revision
}
', branch: '
${
branch
}
'`
);
const
content
=
dedent
`
// this file is automatically generated by git.version.ts script
export const versions: Versions = {
version: "
${
process
.
env
.
npm_package_
version
}
",
version: "
${
version
}
",
revision: "
${
revision
}
",
branch: "
${
branch
}
"
};
...
...
package-lock.json
View file @
22070a71
{
"name"
:
"dlcm-frontend"
,
"version"
:
"
2.0.0-SNAPSHOT
"
,
"version"
:
"
1.9.0
"
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
...
...
@@ -5508,17 +5508,6 @@
"readable-stream"
:
"^2.0.0"
}
},
"fs-extra"
:
{
"version"
:
"7.0.1"
,
"resolved"
:
"https://packages.dlcm.ch/repository/npm-group/fs-extra/-/fs-extra-7.0.1.tgz"
,
"integrity"
:
"sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw=="
,
"dev"
:
true
,
"requires"
:
{
"graceful-fs"
:
"^4.1.2"
,
"jsonfile"
:
"^4.0.0"
,
"universalify"
:
"^0.1.0"
}
},
"fs-minipass"
:
{
"version"
:
"1.2.7"
,
"resolved"
:
"https://packages.dlcm.ch/repository/npm-group/fs-minipass/-/fs-minipass-1.2.7.tgz"
,
...
...
@@ -11708,6 +11697,17 @@
"ms"
:
"^2.1.1"
}
},
"fs-extra"
:
{
"version"
:
"7.0.1"
,
"resolved"
:
"https://nexus.unige.ch/repository/npm-all/fs-extra/-/fs-extra-7.0.1.tgz"
,
"integrity"
:
"sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw=="
,
"dev"
:
true
,
"requires"
:
{
"graceful-fs"
:
"^4.1.2"
,
"jsonfile"
:
"^4.0.0"
,
"universalify"
:
"^0.1.0"
}
},
"ms"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment