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

Checks for RNW environment #1733

Merged
merged 64 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d8c8702
added prepareAttachOptions function
Dec 1, 2021
04d31a3
added preparePackagerBeforeAttach function, modified attach Reauest
Dec 1, 2021
dfa2c77
fixed package-loc.json
Dec 2, 2021
30de479
fixed package-lock.json, package.json
Dec 2, 2021
bb08168
removed surplus else in attachRequest, modified preparePackagerBefore…
Dec 2, 2021
6ab81da
mrge branch 'tmp'
Dec 2, 2021
edb1290
added attach args preparation
Dec 2, 2021
a030d71
Merge branch 'master' into master
Dec 2, 2021
1ba4a41
wip
Dec 8, 2021
eb8cce9
Merge branch 'master' into master
Dec 8, 2021
5ea0659
removed redundant imports
Dec 8, 2021
3cd6ce3
Merge branch 'master' of https://github.com/Samriel/vscode-react-native
Dec 8, 2021
ee7675b
resolved comments
Dec 9, 2021
edfc5d6
simplified isDirect argument assignment
Dec 9, 2021
a2efd4c
polishing
Dec 9, 2021
af66379
modified package json
Dec 10, 2021
4c38606
modified direct attach in package json
Dec 10, 2021
68f471b
added description for env, envfile
Dec 13, 2021
17313b9
Merge branch 'master' of https://github.com/Samriel/vscode-react-native
Dec 13, 2021
a6dbd55
Update src/debugger/debugSessionBase.ts
Dec 13, 2021
c60a7f8
Update src/debugger/direct/directDebugSession.ts
Dec 13, 2021
e1adcba
Update src/debugger/rnDebugSession.ts
Dec 13, 2021
872c6a9
Merge branch 'master' into master
Dec 13, 2021
daec61c
Update src/debugger/debugSessionBase.ts
Dec 13, 2021
c954256
Update src/debugger/debugSessionBase.ts
Dec 13, 2021
f2f47aa
added winver check
AndreiLobanovich Jan 11, 2022
d874a9e
merged with main
AndreiLobanovich Jan 11, 2022
1368808
checks done, except studio
AndreiLobanovich Jan 19, 2022
210b753
added win ver check and util changes
AndreiLobanovich Jan 19, 2022
badfdea
added all checks
AndreiLobanovich Jan 26, 2022
4d7654d
fixed studio.ts
AndreiLobanovich Jan 26, 2022
7a316a5
fixed studio.ts
AndreiLobanovich Jan 26, 2022
bf7bc0a
Merge branch 'microsoft:master' into master
Jan 26, 2022
2a4c33f
removed redundant code from utils.ts
AndreiLobanovich Jan 26, 2022
aba79ce
modified testDevEnvironment function to handle RNW checks
AndreiLobanovich Jan 27, 2022
ded21e7
imported checks in checks/index.ts
AndreiLobanovich Jan 27, 2022
fb10c50
added rnw as additional package to check
AndreiLobanovich Jan 27, 2022
5d0fa92
Update src/extension/services/validationService/checks/devmode.ts
Jan 27, 2022
72ba74f
Update src/extension/services/validationService/checks/longPath.ts
Jan 27, 2022
c601176
Update src/extension/services/validationService/checks/studio.ts
Jan 27, 2022
7ae20d9
Update src/extension/services/validationService/checks/studio.ts
Jan 27, 2022
5772bd3
Update src/extension/services/validationService/checks/longPath.ts
Jan 27, 2022
65de504
improved code of testDevEnvironment
AndreiLobanovich Jan 27, 2022
146aed0
Merge branch 'master' of https://github.com/Samriel/vscode-react-native
AndreiLobanovich Jan 27, 2022
989e02c
change to checker
AndreiLobanovich Jan 27, 2022
ca6adaf
Update src/extension/services/validationService/checks/dotnet.ts
Jan 28, 2022
95113a8
Update src/extension/services/validationService/checks/studio.ts
Jan 28, 2022
eea8d21
Update src/extension/services/validationService/checks/studio.ts
Jan 28, 2022
3b3a4ce
Update src/extension/services/validationService/checks/devmode.ts
Jan 28, 2022
c455b2e
Update src/extension/services/validationService/checks/devmode.ts
Jan 28, 2022
cf21ee7
Update src/extension/services/validationService/checks/studio.ts
Jan 28, 2022
b2ed0a1
Update src/extension/services/validationService/checks/windows.ts
Jan 28, 2022
25e3d81
Update src/extension/services/validationService/checks/windows.ts
Jan 28, 2022
aa26800
reworked studio.ts
AndreiLobanovich Jan 31, 2022
bd7921a
removed redundant variable in commandPaletteHandler.ts
AndreiLobanovich Jan 31, 2022
1ad18cf
renamed studio into visualStudio
AndreiLobanovich Jan 31, 2022
a89e55f
added request to env for path to program files x86
AndreiLobanovich Jan 31, 2022
a5b54f2
renamed studio to visualStudio
AndreiLobanovich Jan 31, 2022
dda666e
Merge branch 'master' into master
Jan 31, 2022
9f26608
moved tolocale and nls.config closer to each other
AndreiLobanovich Jan 31, 2022
2c1bff5
Update src/extension/services/validationService/checks/visualStudio.ts
Feb 1, 2022
29ae952
improved visualStudio check + minor improvements
AndreiLobanovich Feb 1, 2022
99447c3
Merge branch 'master' of https://github.com/Samriel/vscode-react-native
AndreiLobanovich Feb 1, 2022
ccd3b61
minor improvement
AndreiLobanovich Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/extension/appLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
generateRandomPortNumber,
} from "../common/extensionHelper";
import { ReactNativeCDPProxy } from "../cdp-proxy/reactNativeCDPProxy";

import { MultipleLifetimesAppWorker } from "../debugger/appWorker";
import { ProjectsStorage } from "./projectsStorage";
import { PlatformResolver } from "./platformResolver";
Expand Down
18 changes: 18 additions & 0 deletions src/extension/commandPaletteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isWorkspaceTrusted } from "../common/extensionHelper";
import { ErrorHelper } from "../common/error/errorHelper";
import { InternalErrorCode } from "../common/error/internalErrorCode";
import { CONTEXT_VARIABLES_NAMES } from "../common/contextVariablesNames";
import { RNProjectObserver } from "./rnProjectObserver";
import { TipNotificationService } from "./services/tipsNotificationsService/tipsNotificationService";
import * as XDL from "./exponent/xdlInterface";
import { SettingsHelper } from "./settingsHelper";
Expand Down Expand Up @@ -545,14 +546,31 @@ export class CommandPaletteHandler {
}

public static async testDevEnvironment(): Promise<void> {
const createRNProjectObserver = async (
project: AppLauncher,
): Promise<RNProjectObserver> => {
const nodeModulesRoot = project.getOrUpdateNodeModulesRoot();
const projectRootPath = SettingsHelper.getReactNativeProjectRoot(
project.getWorkspaceFolderUri().fsPath,
);
const versions =
await ProjectVersionHelper.getReactNativePackageVersionsFromNodeModules(
nodeModulesRoot,
[REACT_NATIVE_PACKAGES.REACT_NATIVE_WINDOWS],
);
return new RNProjectObserver(projectRootPath, versions);
};
const project = await this.selectProject().catch(() => undefined);
const projectObserver =
project && (await createRNProjectObserver(project).catch(() => undefined));
const shouldCheck = {
[ValidationCategoryE.Expo]:
(await project
?.getPackager()
.getExponentHelper()
.isExpoManagedApp(false)
.catch(() => false)) || false,
[ValidationCategoryE.Windows]: projectObserver?.isRNWindowsProject || false,
} as const;

await runChecks(shouldCheck);
Expand Down
44 changes: 44 additions & 0 deletions src/extension/services/validationService/checks/devmode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as nls from "vscode-nls";
import { executeCommand } from "../util";
import { IValidation, ValidationCategoryE, ValidationResultT } from "./types";

nls.config({
messageFormat: nls.MessageFormat.bundle,
bundleFormat: nls.BundleFormat.standalone,
})();
const toLocale = nls.loadMessageBundle();

const label = "DeveloperMode";

async function test(): Promise<ValidationResultT> {
const command =
"reg query HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock /v AllowDevelopmentWithoutDevLicense";
const data = await executeCommand(command);
if (data.stdout) {
if (data.stdout.includes(" 0x1"))
return {
status: "success",
};
}

return {
status: "failure",
comment: "Developer mode is disabled",
};
}

const main: IValidation = {
label,
platform: ["win32"],
description: toLocale(
"DeveloperModeTestDescription",
"Required for launching and debugging RNW apps",
),
category: ValidationCategoryE.Windows,
exec: test,
};

export default main;
43 changes: 43 additions & 0 deletions src/extension/services/validationService/checks/dotnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as nls from "vscode-nls";
import { createNotFoundMessage, createVersionErrorMessage, executeCommand } from "../util";
import { IValidation, ValidationCategoryE, ValidationResultT } from "./types";

nls.config({
messageFormat: nls.MessageFormat.bundle,
bundleFormat: nls.BundleFormat.standalone,
})();
const toLocale = nls.loadMessageBundle();

const label = ".NET Core 3.1";

async function test(): Promise<ValidationResultT> {
const command = "dotnet --info";
const data = await executeCommand(command);
if (data.stdout) {
if (data.stdout.includes("Microsoft.NETCore.App 3.1"))
return {
status: "success",
};
return {
status: "failure",
comment: createVersionErrorMessage(label),
};
}
return {
status: "failure",
comment: createNotFoundMessage(label),
};
}

const main: IValidation = {
label,
platform: ["win32"],
description: toLocale("DotNetTestDescription", "Required for building RNW apps"),
category: ValidationCategoryE.Windows,
exec: test,
};

export default main;
11 changes: 11 additions & 0 deletions src/extension/services/validationService/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import watchman from "./watchman";
import iosDeploy from "./iosDeploy";
import xcodebuild from "./xcodebuild";
import expoCli from "./expoCli";
import devmode from "./devmode";
import visualStudio from "./visualStudio";
import longPath from "./longPath";
import windows from "./windows";
import dotnet from "./dotnet";

import { IValidation } from "./types";

export const getChecks = (): IValidation[] => {
Expand All @@ -36,6 +42,11 @@ export const getChecks = (): IValidation[] => {
watchman,
xcodebuild,
expoCli,
devmode,
visualStudio,
longPath,
windows,
dotnet,
] as const;

return checks.filter(it => (it.platform ? it.platform.includes(process.platform) : true));
Expand Down
40 changes: 40 additions & 0 deletions src/extension/services/validationService/checks/longPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as nls from "vscode-nls";
import { executeCommand } from "../util";
import { IValidation, ValidationCategoryE, ValidationResultT } from "./types";

nls.config({
messageFormat: nls.MessageFormat.bundle,
bundleFormat: nls.BundleFormat.standalone,
})();
const toLocale = nls.loadMessageBundle();

const label = "LongPathSupport";

async function test(): Promise<ValidationResultT> {
const command =
"reg query HKLM\\SYSTEM\\CurrentControlSet\\Control\\FileSystem /v LongPathsEnabled";
const data = await executeCommand(command);
if (data.stdout) {
if (data.stdout.includes(" 0x1"))
return {
status: "success",
};
}
return {
status: "failure",
comment: "Long path support is disabled",
};
}

const main: IValidation = {
label,
platform: ["win32"],
description: toLocale("LongPathSupportTestDescription", "Required for building RNW apps"),
category: ValidationCategoryE.Windows,
exec: test,
};

export default main;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ValidationCategoryE {
Android = "Android",
iOS = "iOS",
Expo = "Expo",
Windows = "Windows",
}

export type ValidationResultT = {
Expand Down
78 changes: 78 additions & 0 deletions src/extension/services/validationService/checks/visualStudio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as nls from "vscode-nls";
import * as semver from "semver";
import { createNotFoundMessage, executeCommand, normizeStr } from "../util";
import { IValidation, ValidationCategoryE, ValidationResultT } from "./types";

nls.config({
messageFormat: nls.MessageFormat.bundle,
bundleFormat: nls.BundleFormat.standalone,
})();
const toLocale = nls.loadMessageBundle();

const label = "Compilers, build tools, SDKs and Visual Studio";

async function test(): Promise<ValidationResultT> {
let vswherePath = ``;
if (process.env["ProgramFiles(x86)"]) {
vswherePath = `"${process.env["ProgramFiles(x86)"]}\\Microsoft Visual Studio\\Installer\\vswhere.exe"`;
} else {
vswherePath = `"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe"`;
}
const components = [
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.ComponentGroup.UWP.Support",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
];
const command = `${vswherePath} -property catalog_productDisplayVersion`;
const result = await executeCommand(command);
if (result) {
const versions = normizeStr(result.stdout).split("\n");
let valid = false;
for (const version of versions) {
if (version) {
if (semver.gtr(version, "16.5")) valid = true;
}
}
if (valid) {
for (const comp of components) {
const pathToComponent = await executeCommand(
`${vswherePath} -requires ${comp} -property productPath`,
);
if (!pathToComponent.stdout) {
return {
status: "failure",
comment: `Please check if ${comp} is installed`,
};
}
}
return {
status: "success",
};
}
return {
status: "partial-success",
comment:
"Detected version is older than 16.5. " +
"Please update Visual Studio in case of errors",
};
}
return {
status: "failure",
comment: createNotFoundMessage(label),
};
}

const main: IValidation = {
label,
platform: ["win32"],
description: toLocale("VisualStudioCheckDescription", "Required for testing RNW apps"),
AndreiLobanovich marked this conversation as resolved.
Show resolved Hide resolved
category: ValidationCategoryE.Windows,
exec: test,
};

export default main;
40 changes: 40 additions & 0 deletions src/extension/services/validationService/checks/windows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as os from "os";
import * as nls from "vscode-nls";
import * as semver from "semver";
import { createVersionErrorMessage } from "../util";
import { IValidation, ValidationCategoryE, ValidationResultT } from "./types";

nls.config({
messageFormat: nls.MessageFormat.bundle,
bundleFormat: nls.BundleFormat.standalone,
})();
const toLocale = nls.loadMessageBundle();

const label = "Windows version > 10.0.16299.0";

async function test(): Promise<ValidationResultT> {
const version = os.release();

if (semver.gte(version, "10.0.16299")) {
return {
status: "success",
};
}
return {
status: "failure",
comment: createVersionErrorMessage(label),
};
}

const main: IValidation = {
label,
platform: ["win32"],
description: toLocale("RNWBuildTestDescription", "Required for running RNW apps"),
category: ValidationCategoryE.Windows,
exec: test,
};

export default main;