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 10 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
8 changes: 7 additions & 1 deletion src/main/handlers/Utilities/Prerequisites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ 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; $PSVersionTable.PSVersion',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my powershell 7 despite policy being unrestricted I am getting following error

image
image

false
)
]
3 changes: 2 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,6 +128,7 @@ 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'))
Expand Down
46 changes: 42 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,44 @@ const PrereqsView = ({ sx }: Props) => {
.
</Typography>
)
} else if (status.id === 'ps1ExecutionPolicy') {
status.description = (
<Typography fontSize={14}>
<span style={{ fontSize: 14, opacity: 0.6 }}>
{
// Check if the user agent contains PowerShell version information
window.navigator.userAgent.includes('PowerShell')
? `Run the following command in PowerShell ${window.navigator.userAgent}:`
Copy link
Member

@hanzlamateen hanzlamateen Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change Run the following command in PowerShell:to 'Use PowerShell version_here for following instructions'.

image

: 'Run the following command in PowerShell:'
}
</span>
<br />
Abhijay007 marked this conversation as resolved.
Show resolved Hide resolved
<br />
<span style={{ fontSize: 14, opacity: 0.6 }}>
Check whether the execution policy is set to allow unsigned PowerShell scripts.
</span>
<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 commands:
<br />
<br />
<code>Get-ExecutionPolicy</code> - This command will show you the current execution policy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep the script. Remove - This command will show you the current execution policy.

<br />
<br />
<code>Set-ExecutionPolicy Unrestricted</code> - Use this command to set the execution policy to allow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep the script. Remove - Use this command to set the execution policy to allow

unsigned PowerShell scripts.
<br />
<br />
Refer to the Microsoft documentation for information on PowerShell execution policies and &nbsp;
</span>
<a style={{ color: 'white' }} target="_blank" href={'#'}>
Learn more
</a>
.
</Typography>
)
}
}

Expand Down