Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Signature Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Electronic Signature Service
Signature Frontend
Commits
1bf53554
Commit
1bf53554
authored
4 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Reuse some rollup helper functions from the toolkit
parent
8bf5bc16
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rollup.config.js
+4
-62
4 additions, 62 deletions
rollup.config.js
rollup.utils.js
+21
-0
21 additions, 0 deletions
rollup.utils.js
with
25 additions
and
62 deletions
rollup.config.js
+
4
−
62
View file @
1bf53554
import
path
from
'
path
'
;
import
fs
from
'
fs
'
;
import
url
from
'
url
'
;
import
glob
from
'
glob
'
;
import
resolve
from
'
@rollup/plugin-node-resolve
'
;
...
...
@@ -14,8 +13,9 @@ import license from 'rollup-plugin-license';
import
del
from
'
rollup-plugin-delete
'
;
import
emitEJS
from
'
rollup-plugin-emit-ejs
'
import
{
getBabelOutputPlugin
}
from
'
@rollup/plugin-babel
'
;
import
selfsigned
from
'
selfsigned
'
;
import
appConfig
from
'
./app.config.js
'
;
import
{
getPackagePath
,
getBuildInfo
}
from
'
./vendor/toolkit/rollup.utils.js
'
;
import
{
generateTLSConfig
}
from
'
./rollup.utils.js
'
;
// -------------------------------
...
...
@@ -70,64 +70,6 @@ if (config.nextcloudBaseURL) {
config
.
nextcloudWebDavURL
=
''
;
}
/**
* Creates a server certificate and caches it in the .cert directory
*/
function
generateTLSConfig
()
{
fs
.
mkdirSync
(
'
.cert
'
,
{
recursive
:
true
});
if
(
!
fs
.
existsSync
(
'
.cert/server.key
'
)
||
!
fs
.
existsSync
(
'
.cert/server.cert
'
))
{
const
attrs
=
[{
name
:
'
commonName
'
,
value
:
'
dbp-dev.localhost
'
}];
const
pems
=
selfsigned
.
generate
(
attrs
,
{
algorithm
:
'
sha256
'
,
days
:
9999
});
fs
.
writeFileSync
(
'
.cert/server.key
'
,
pems
.
private
);
fs
.
writeFileSync
(
'
.cert/server.cert
'
,
pems
.
cert
);
}
return
{
key
:
fs
.
readFileSync
(
'
.cert/server.key
'
),
cert
:
fs
.
readFileSync
(
'
.cert/server.cert
'
)
}
}
function
getBuildInfo
()
{
const
child_process
=
require
(
'
child_process
'
);
const
url
=
require
(
'
url
'
);
let
remote
=
child_process
.
execSync
(
'
git config --get remote.origin.url
'
).
toString
().
trim
();
let
commit
=
child_process
.
execSync
(
'
git rev-parse --short HEAD
'
).
toString
().
trim
();
let
parsed
=
url
.
parse
(
remote
);
// convert git urls
if
(
parsed
.
protocol
===
null
)
{
parsed
=
url
.
parse
(
'
git://
'
+
remote
.
replace
(
"
:
"
,
"
/
"
));
parsed
.
protocol
=
'
https:
'
;
}
let
newPath
=
parsed
.
path
.
slice
(
0
,
parsed
.
path
.
lastIndexOf
(
'
.
'
));
let
newUrl
=
parsed
.
protocol
+
'
//
'
+
parsed
.
host
+
newPath
+
'
/commit/
'
+
commit
;
return
{
info
:
commit
,
url
:
newUrl
,
time
:
new
Date
().
toISOString
(),
env
:
appEnv
}
}
export
async
function
getPackagePath
(
packageName
,
assetPath
)
{
const
r
=
resolve
();
const
resolved
=
await
r
.
resolveId
(
packageName
);
let
packageRoot
;
if
(
resolved
!==
null
)
{
const
id
=
(
await
r
.
resolveId
(
packageName
)).
id
;
const
packageInfo
=
r
.
getPackageInfoForId
(
id
);
packageRoot
=
packageInfo
.
root
;
}
else
{
// Non JS packages
packageRoot
=
path
.
dirname
(
require
.
resolve
(
packageName
+
'
/package.json
'
));
}
return
path
.
relative
(
process
.
cwd
(),
path
.
join
(
packageRoot
,
assetPath
));
}
export
default
(
async
()
=>
{
return
{
input
:
(
appEnv
!=
'
test
'
)
?
[
'
src/
'
+
pkg
.
name
+
'
.js
'
,
...
...
@@ -167,7 +109,7 @@ export default (async () => {return {
}),
consts
({
environment
:
appEnv
,
buildinfo
:
getBuildInfo
(),
buildinfo
:
getBuildInfo
(
appEnv
),
nextcloudBaseURL
:
config
.
nextcloudBaseURL
,
}),
emitEJS
({
...
...
@@ -194,7 +136,7 @@ export default (async () => {return {
environment
:
appEnv
,
matomoUrl
:
config
.
matomoUrl
,
matomoSiteId
:
config
.
matomoSiteId
,
buildInfo
:
getBuildInfo
()
buildInfo
:
getBuildInfo
(
appEnv
)
}
}),
resolve
({
...
...
This diff is collapsed.
Click to expand it.
rollup.utils.js
0 → 100644
+
21
−
0
View file @
1bf53554
import
fs
from
'
fs
'
;
import
selfsigned
from
'
selfsigned
'
;
/**
* Creates a server certificate and caches it in the .cert directory
*/
export
function
generateTLSConfig
()
{
fs
.
mkdirSync
(
'
.cert
'
,
{
recursive
:
true
});
if
(
!
fs
.
existsSync
(
'
.cert/server.key
'
)
||
!
fs
.
existsSync
(
'
.cert/server.cert
'
))
{
const
attrs
=
[{
name
:
'
commonName
'
,
value
:
'
dbp-dev.localhost
'
}];
const
pems
=
selfsigned
.
generate
(
attrs
,
{
algorithm
:
'
sha256
'
,
days
:
9999
});
fs
.
writeFileSync
(
'
.cert/server.key
'
,
pems
.
private
);
fs
.
writeFileSync
(
'
.cert/server.cert
'
,
pems
.
cert
);
}
return
{
key
:
fs
.
readFileSync
(
'
.cert/server.key
'
),
cert
:
fs
.
readFileSync
(
'
.cert/server.cert
'
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment