Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define modulePaths in launchpad.html file #44

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Optionally you can configure the cds-launchpad-plugin by adding following config
"basePath": "", // Path under which you want the sandbox to be served
"appConfigPath": "", // External sandbox appconfig json file to be merged with generated appconfig
"locale": "", // Language to be used for the sandbox environment
"template": "" // 'legacy' (non-async launchpad, default) or 'async' (async launchpad)
"template": "" ,// 'legacy' (non-async launchpad, default) or 'async' (async launchpad),
"modulePaths": "" // object with module paths to be used in the launchpad.html file for "sap-ushell-config"
}
}
```
Expand Down Expand Up @@ -70,7 +71,8 @@ Call `setup({...})` method with the following object (configuration object can b
basePath: '', // Path under which you want the sandbox to be served
appConfigPath: '', // External sandbox appconfig json file to be merged with generated appconfig
locale: '', // Language to be used for the sandbox environment
template: '' // 'legacy' (non-async launchpad) or 'async' (async launchpad)
template: '', // 'legacy' (non-async launchpad) or 'async' (async launchpad)
modulePaths: '' // object with module paths to be used in the launchpad.html file for "sap-ushell-config"
}
```

Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export interface LaunchpadConfig {
basePath?: string,
appConfigPath?: string,
locale?: string, // TODO if it was possible to get sap-ui-language from request which retrieves the app config json, we wouldnt need this option
template?: string
template?: string,
modulePaths?: object
}

export class cds_launchpad_plugin{
Expand Down Expand Up @@ -92,7 +93,11 @@ export class cds_launchpad_plugin{
async prepareTemplate(options: LaunchpadConfig): Promise<string>{
let url = `https://ui5.sap.com`;
let template = options.template === 'legacy' || options.template === '' || options.template === undefined ? 'legacy' : options.template;
const htmltemplate = fs.readFileSync(__dirname + `/../templates/${template}/launchpad.html`).toString();
let htmltemplate = fs.readFileSync(__dirname + `/../templates/${template}/launchpad.html`).toString();
if(options.modulePaths) {
const modulePathsJson = JSON.stringify(options.modulePaths);
htmltemplate = htmltemplate.replace('/* MODULE_PATHS */', `modulePaths: ${modulePathsJson}`);
}
if (options.version && options.version.startsWith('https://')) {
url = options.version
} else if(options.version !== undefined && options.version !== ''){
Expand Down
3 changes: 2 additions & 1 deletion templates/async/launchpad.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
},
},
},
applications: {}
applications: {},
/* MODULE_PATHS */
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion templates/legacy/launchpad.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
},
},
},
applications: {}
applications: {},
/* MODULE_PATHS */
};
</script>

Expand Down
Loading