Expand all template vars in postinstall and checklist messages

This commit is contained in:
Johannes Zellner
2025-05-15 15:04:13 +02:00
parent ee0ac7cbed
commit 8f2b6cf44e

View File

@@ -127,8 +127,7 @@ function create() {
} }
} }
if (app.manifest.postInstallMessage) { function expandTemplateVars(text) {
let text = app.manifest.postInstallMessage;
// we chose - because underscore has special meaning in markdown // we chose - because underscore has special meaning in markdown
text = text.replace(/\$CLOUDRON-APP-LOCATION/g, app.subdomain); text = text.replace(/\$CLOUDRON-APP-LOCATION/g, app.subdomain);
text = text.replace(/\$CLOUDRON-APP-DOMAIN/g, app.domain); 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-USERNAME/g, profile.username);
text = text.replace(/\$CLOUDRON-APP-ID/g, app.id); 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 // [^] matches even newlines. '?' makes it non-greedy
if (app.sso) text = text.replace(/<nosso>[^]*?<\/nosso>/g, ''); if (app.sso) text = text.replace(/<nosso>[^]*?<\/nosso>/g, '');
else text = text.replace(/<sso>[^]*?<\/sso>/g, ''); else text = text.replace(/<sso>[^]*?<\/sso>/g, '');
@@ -146,6 +151,10 @@ function create() {
app.manifest.postInstallMessage = text.trim(); app.manifest.postInstallMessage = text.trim();
} }
for (const key of Object.keys(app.checklist)) {
app.checklist[key].message = expandTemplateVars(app.checklist[key].message);
}
return app; return app;
} }