Expand all template vars in postinstall and checklist messages
This commit is contained in:
@@ -127,8 +127,7 @@ function create() {
|
||||
}
|
||||
}
|
||||
|
||||
if (app.manifest.postInstallMessage) {
|
||||
let text = app.manifest.postInstallMessage;
|
||||
function expandTemplateVars(text) {
|
||||
// we chose - because underscore has special meaning in markdown
|
||||
text = text.replace(/\$CLOUDRON-APP-LOCATION/g, app.subdomain);
|
||||
text = text.replace(/\$CLOUDRON-APP-DOMAIN/g, app.domain);
|
||||
@@ -139,6 +138,12 @@ function create() {
|
||||
text = text.replace(/\$CLOUDRON-USERNAME/g, profile.username);
|
||||
text = text.replace(/\$CLOUDRON-APP-ID/g, app.id);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
if (app.manifest.postInstallMessage) {
|
||||
let text = expandTemplateVars(app.manifest.postInstallMessage);
|
||||
|
||||
// [^] matches even newlines. '?' makes it non-greedy
|
||||
if (app.sso) text = text.replace(/<nosso>[^]*?<\/nosso>/g, '');
|
||||
else text = text.replace(/<sso>[^]*?<\/sso>/g, '');
|
||||
@@ -146,6 +151,10 @@ function create() {
|
||||
app.manifest.postInstallMessage = text.trim();
|
||||
}
|
||||
|
||||
for (const key of Object.keys(app.checklist)) {
|
||||
app.checklist[key].message = expandTemplateVars(app.checklist[key].message);
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user