Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

(Chore) : Added new prerequisite permission to run ps1 scripts. #77

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
4 changes: 3 additions & 1 deletion src/constants/Endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const Endpoints = {
MICROK8S_REGISTRY_CATALOG: 'http://localhost:32000/v2/_catalog',
MICROK8S_WINDOWS_REGISTRY_CATALOG: 'http://microk8s.registry:32000/v2/_catalog',
SUPPORT_GITHUB: 'https://github.com/EtherealEngine/etherealengine-control-center/issues',
SUPPORT_DISCORD: 'https://discord.gg/xrf'
SUPPORT_DISCORD: 'https://discord.gg/xrf',
SET_EXECUTION_POLICY:
'https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies'
},
Paths: {
ENGINE_ENV: '.env.local',
Expand Down
3 changes: 2 additions & 1 deletion src/main/handlers/Utilities/Prerequisites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const WindowsPrerequisites: AppModel[] = [
getAppModel('wsl', 'Windows Subsystem for Linux (WSL)', 'wsl --status;', false),
getAppModel('wslUbuntu', 'WSL Ubuntu Distribution', 'wsl --status;', false),
getAppModel('dockerDesktop', 'Docker Desktop', 'docker version;', false),
getAppModel('dockerDesktopUbuntu', 'Docker Desktop WSL Ubuntu Integration', 'wsl docker version;', false)
getAppModel('dockerDesktopUbuntu', 'Docker Desktop WSL Ubuntu Integration', 'wsl docker version;', false),
getAppModel('ps1ExecutionPolicy', 'PowerShell Execution Policy', 'Get-ExecutionPolicy;', false)
]
8 changes: 7 additions & 1 deletion src/main/handlers/Utilities/Utilities.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Utilities {
return WindowsPrerequisites
}
} catch (err) {
log.error('Failed to get pre requisites.', err)
log.error('Failed to get prerequisites.', err)
}

return []
Expand All @@ -128,13 +128,19 @@ class Utilities {

if (
(prerequisite.id === 'wsl' && stdOutput) ||
(prerequisite.id === 'ps1ExecutionPolicy' &&
stdOutput.includes('Unrestricted')) ||
(prerequisite.id === 'wslUbuntu' && stdOutput.includes(': Ubuntu')) ||
((prerequisite.id === 'dockerDesktop' || prerequisite.id === 'dockerDesktopUbuntu') &&
stdOutput.includes('Server: Docker Desktop'))
) {
status = AppStatus.Configured
}

if (prerequisite.id === 'ps1ExecutionPolicy' && !stdOutput.includes('Unrestricted')) {
Abhijay007 marked this conversation as resolved.
Show resolved Hide resolved
status = AppStatus.NotConfigured
}

return {
...prerequisite,
detail: stderr ? stderr : stdOutput,
Expand Down
29 changes: 25 additions & 4 deletions src/renderer/components/Config/PrereqsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const PrereqsView = ({ sx }: Props) => {
status.description = (
<Typography fontSize={14}>
<span style={{ fontSize: 14, opacity: 0.6 }}>
Make sure WSL is installed and Ubuntu is selected as default distribution.{' '}
Make sure WSL is installed and Ubuntu is selected as the default distribution.{' '}
</span>
<a style={{ color: 'var(--textColor)' }} target="_blank" href={Endpoints.Docs.INSTALL_WSL}>
Install WSL
Expand All @@ -63,15 +63,15 @@ const PrereqsView = ({ sx }: Props) => {
<br />
<br />
<span style={{ fontSize: 14, opacity: 0.6 }}>
To ensure 'Ubuntu' is set as default WSL distribution. You can check your default distribution by
running following command in Powershell/CMD:
To ensure 'Ubuntu' is set as the default WSL distribution, you can check your default distribution by
running the following command in PowerShell/CMD:
</span>
<br />
<code>wsl -l</code>
<br />
<br />
<span style={{ fontSize: 14, opacity: 0.6 }}>
Afterwards, if Ubuntu is not selected as default, then you can do so by running following command:
Afterwards, if Ubuntu is not selected as the default, you can do so by running the following command:
</span>
<br />
<code>wsl -s Ubuntu</code>
Expand All @@ -91,6 +91,27 @@ const PrereqsView = ({ sx }: Props) => {
.
</Typography>
)
} else if (status.id === 'ps1ExecutionPolicy') {
status.description = (
<Typography fontSize={14}>
<span style={{ fontSize: 14, opacity: 0.6 }}>
Check whether the execution policy is set to allow unsigned PowerShell scripts.
</span>
<a style={{ color: 'white' }} target="_blank" href={Endpoints.Urls.SET_EXECUTION_POLICY}>
Learn more
</a>
.
<br />
Abhijay007 marked this conversation as resolved.
Show resolved Hide resolved
<br />
<br />
<span style={{ fontSize: 14, opacity: 0.6 }}>
Afterwards, if the execution policy is not set to allow unsigned PowerShell scripts, you can do so by
Abhijay007 marked this conversation as resolved.
Show resolved Hide resolved
running the following command:
</span>
<br />
<code>Set-ExecutionPolicy Unrestricted</code>
</Typography>
)
}
}

Expand Down