Skip to content

Commit

Permalink
feat: define modulePaths in launchpad.html file (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo authored May 27, 2024
1 parent 11a2b4e commit 3a5429d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
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

0 comments on commit 3a5429d

Please sign in to comment.