mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
WEbsite: revert changes to Fleet maintained apps configuration (#27093)
Changes: - Reverted the changes from #27049 until the file structure of the ee/maintained-apps folder has been settled and JSON files exist for all apps listed in the `/ee/maintained-apps/outputs/apps.json`.
This commit is contained in:
parent
f3924b9129
commit
b9c0f97026
1 changed files with 24 additions and 21 deletions
45
website/scripts/build-static-content.js
vendored
45
website/scripts/build-static-content.js
vendored
|
|
@ -1292,35 +1292,35 @@ module.exports = {
|
|||
// ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
||||
//
|
||||
async()=>{
|
||||
// FUTURE: add support for multiple platforms when they are added to Fleet maintained apps.
|
||||
let appLibrary = [];
|
||||
// Get app library json
|
||||
let appsJsonData = await sails.helpers.fs.readJson(path.join(topLvlRepoPath, '/ee/maintained-apps/outputs/apps.json'));
|
||||
let appsJsonData = await sails.helpers.fs.readJson(path.join(topLvlRepoPath, '/server/mdm/maintainedapps/apps.json'));
|
||||
// Then for each item in the json, build a configuration object to add to the sails.builtStaticContent.appLibrary array.
|
||||
await sails.helpers.flow.simultaneouslyForEach(appsJsonData.apps, async(app)=>{
|
||||
await sails.helpers.flow.simultaneouslyForEach(appsJsonData, async(app)=>{
|
||||
let appInformation = {
|
||||
name: app.name,
|
||||
identifier: app.slug.split('/darwin')[0],// Note: apps in the maintained apps json have the platform postfixed to the identifier in their slug.
|
||||
bundleIdentifier: app.unique_identifier,
|
||||
description: app.description,
|
||||
identifier: app.identifier,
|
||||
bundleIdentifier: app.bundle_identifier,
|
||||
installerFormat: app.installer_format,
|
||||
};
|
||||
|
||||
// Grab the latest information about these apps from the the ee/maintained-apps folder in the repo.
|
||||
let detailedInformationAboutThisApp = await sails.helpers.fs.readJson(path.join(topLvlRepoPath, '/ee/maintained-apps/outputs/darwin/'+appInformation.identifier+'.json'))
|
||||
// Note: This method of getting information about the apps will be out of date until the JSON files in the /server/mdm/maintainedapps/testdata/ folder are updated.
|
||||
let detailedInformationAboutThisApp = await sails.helpers.fs.readJson(path.join(topLvlRepoPath, '/server/mdm/maintainedapps/testdata/'+app.identifier+'.json'))
|
||||
.intercept('doesNotExist', ()=>{
|
||||
return new Error(`Could not build app library configuration from ee/maintained-apps folder. When attempting to read a JSON configuration file for ${appInformation.identifier}, no file was found at ${path.join(topLvlRepoPath, '/ee/maintained-apps/outputs/darwin/'+app.identifier+'.json. Was it moved?')}.`);
|
||||
return new Error(`Could not build app library configuration from testdata folder. When attempting to read a JSON configuration file for ${app.identifier}, no file was found at ${path.join(topLvlRepoPath, '/server/mdm/maintainedapps/testdata/'+app.identifier+'.json. Was it moved?')}.`);
|
||||
});
|
||||
// Get the latest version of the app from the versions array.
|
||||
let latestVersionOfThisApp = detailedInformationAboutThisApp.versions[0];
|
||||
// get the ref that is used as the key for this version's uninstall script in the `refs` array.
|
||||
let latestUninstallScriptRef = latestVersionOfThisApp.uninstall_script_ref;
|
||||
// Get the uninstall script for this version.
|
||||
let scriptToUninstallThisApp = detailedInformationAboutThisApp.refs[latestUninstallScriptRef];
|
||||
// Modify the latest uninstall script to be on a single line.
|
||||
|
||||
// Grab the latest information about these apps from the Homebrew API.
|
||||
// let detailedInformationAboutThisApp = await sails.helpers.http.get(`https://formulae.brew.sh/api/cask/${app.identifier}.json`)
|
||||
// .intercept((error)=>{
|
||||
// return new Error(`Could not build app library configuration. When attempting to send a request to the homebrew API to get the latest information about ${app.identifier}, an error occured. Full error: ${util.inspect(error, {depth: null})}`);
|
||||
// });
|
||||
let scriptToUninstallThisApp = await sails.helpers.fs.read(path.join(topLvlRepoPath, `/server/mdm/maintainedapps/testdata/scripts/${app.identifier}_uninstall.golden.sh`))
|
||||
.intercept('doesNotExist', ()=>{
|
||||
return new Error(`Could not build app library configuration from testdata folder. When attempting to read an uninstall script for ${app.identifier}, no file was found at ${path.join(topLvlRepoPath, '/server/mdm/maintainedapps/testdata/scripts/'+app.identifier+'_uninstall.golden.sh. Was it moved?')}.`);
|
||||
});
|
||||
// Remove lines that only contain comments.
|
||||
scriptToUninstallThisApp = scriptToUninstallThisApp.replace(/^\s*#.*$/gm, '');
|
||||
// Condense functions in the uninstall script onto a single line.
|
||||
|
||||
// Condense functions onto a single line.
|
||||
// For each function in the script:
|
||||
scriptToUninstallThisApp = scriptToUninstallThisApp.replace(/(\w+)\s*\(\)\s*\{([\s\S]*?)^\}/gm, (match, functionName, functionContent)=> {
|
||||
// Split the function content into an array
|
||||
|
|
@ -1348,12 +1348,15 @@ module.exports = {
|
|||
// Return the condensed single-line function.
|
||||
return `${functionName}() { ${condensedBodyOfFunction} }`;
|
||||
});
|
||||
|
||||
// Remove newlines with "&&" and remove any that are added to the end and beginning of the condensed command.
|
||||
scriptToUninstallThisApp = scriptToUninstallThisApp.replace(/\n\s*/g, ' && ').replace(/ && $/, '').replace(/^ && /, '');
|
||||
|
||||
// Add the uninstall script and the latest version to this app's configuration.
|
||||
|
||||
appInformation.uninstallScript = scriptToUninstallThisApp;
|
||||
appInformation.version = latestVersionOfThisApp.version.split(',')[0];
|
||||
appInformation.version = detailedInformationAboutThisApp.version.split(',')[0];
|
||||
appInformation.description = detailedInformationAboutThisApp.desc;
|
||||
appInformation.name = detailedInformationAboutThisApp.name[0];
|
||||
appLibrary.push(appInformation);
|
||||
});
|
||||
builtStaticContent.appLibrary = appLibrary;
|
||||
|
|
|
|||
Loading…
Reference in a new issue