@react-native-windows/cli 0.0.0-canary.2 → 0.0.0-canary.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/configUtils.d.ts +34 -6
- package/lib-commonjs/commands/config/configUtils.js +381 -0
- package/lib-commonjs/commands/config/configUtils.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +3 -3
- package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
- package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +6 -3
- package/lib-commonjs/{config → commands/config}/projectConfig.js +72 -12
- package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
- package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
- package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
- package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
- package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +17 -11
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +16 -11
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
- package/lib-commonjs/e2etest/autolink.test.js +367 -0
- package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
- package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
- package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/initWindows.test.js +43 -0
- package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
- package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/runWindows.test.js +61 -0
- package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
- package/lib-commonjs/generator-common/index.d.ts +17 -1
- package/lib-commonjs/generator-common/index.js +61 -40
- package/lib-commonjs/generator-common/index.js.map +1 -1
- package/lib-commonjs/generator-windows/index.d.ts +2 -2
- package/lib-commonjs/generator-windows/index.js +238 -187
- package/lib-commonjs/generator-windows/index.js.map +1 -1
- package/lib-commonjs/index.d.ts +7 -2
- package/lib-commonjs/index.js +51 -11
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +2 -3
- package/lib-commonjs/{runWindows/utils → utils}/build.js +26 -33
- package/lib-commonjs/utils/build.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +11 -7
- package/lib-commonjs/utils/checkRequirements.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +11 -3
- package/lib-commonjs/utils/commandWithProgress.js +150 -0
- package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +2 -2
- package/lib-commonjs/utils/deploy.js +354 -0
- package/lib-commonjs/utils/deploy.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/info.js +5 -2
- package/lib-commonjs/utils/info.js.map +1 -0
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
- package/lib-commonjs/utils/msbuildtools.js +274 -0
- package/lib-commonjs/utils/msbuildtools.js.map +1 -0
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
- package/lib-commonjs/utils/pathHelpers.js +37 -0
- package/lib-commonjs/utils/pathHelpers.js.map +1 -0
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
- package/lib-commonjs/utils/telemetryHelpers.js +121 -0
- package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +4 -4
- package/lib-commonjs/utils/version.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +5 -2
- package/lib-commonjs/utils/vsInstalls.js +100 -0
- package/lib-commonjs/utils/vsInstalls.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +2 -1
- package/lib-commonjs/utils/vstools.js +190 -0
- package/lib-commonjs/utils/vstools.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +3 -3
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +17 -14
- package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
- package/package.json +50 -28
- package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
- package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
- package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +11 -1
- package/CHANGELOG.json +0 -35
- package/CHANGELOG.md +0 -21
- package/lib-commonjs/config/configUtils.js +0 -265
- package/lib-commonjs/config/configUtils.js.map +0 -1
- package/lib-commonjs/config/dependencyConfig.js +0 -148
- package/lib-commonjs/config/dependencyConfig.js.map +0 -1
- package/lib-commonjs/config/projectConfig.js.map +0 -1
- package/lib-commonjs/runWindows/runWindows.js +0 -139
- package/lib-commonjs/runWindows/runWindows.js.map +0 -1
- package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
- package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
- package/lib-commonjs/runWindows/utils/autolink.js +0 -343
- package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
- package/lib-commonjs/runWindows/utils/build.js.map +0 -1
- package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
- package/lib-commonjs/runWindows/utils/commandWithProgress.js +0 -114
- package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
- package/lib-commonjs/runWindows/utils/deploy.js +0 -247
- package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
- package/lib-commonjs/runWindows/utils/info.js.map +0 -1
- package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
- package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -183
- package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/version.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -59
- package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vstools.js +0 -144
- package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
- package/templates/_gitignore +0 -92
- package/templates/b_gitignore +0 -1
- package/templates/cpp/keys/MyApp_TemporaryKey.pfx +0 -0
- package/templates/cpp/proj/MyApp.sln +0 -194
- package/templates/cpp/proj/MyApp.vcxproj +0 -220
- package/templates/cpp/proj/MyApp.vcxproj.filters +0 -63
- package/templates/cpp/proj/packages.config +0 -6
- package/templates/cpp/src/App.cpp +0 -80
- package/templates/cpp/src/App.h +0 -25
- package/templates/cpp/src/App.idl +0 -3
- package/templates/cpp/src/AutolinkedNativeModules.g.cpp +0 -13
- package/templates/cpp/src/AutolinkedNativeModules.g.h +0 -10
- package/templates/cpp/src/AutolinkedNativeModules.g.targets +0 -6
- package/templates/cpp/src/MainPage.cpp +0 -24
- package/templates/cpp/src/MainPage.h +0 -21
- package/templates/cpp/src/MainPage.idl +0 -8
- package/templates/cpp/src/PropertySheet.props +0 -16
- package/templates/cpp/src/ReactPackageProvider.cpp +0 -18
- package/templates/cpp/src/ReactPackageProvider.h +0 -15
- package/templates/cpp/src/pch.cpp +0 -1
- package/templates/cpp/src/pch.h +0 -26
- package/templates/cs/keys/MyApp_TemporaryKey.pfx +0 -0
- package/templates/cs/proj/MyApp.csproj +0 -190
- package/templates/cs/proj/MyApp.sln +0 -227
- package/templates/cs/src/App.xaml.cs +0 -51
- package/templates/cs/src/AutolinkedNativeModules.g.cs +0 -13
- package/templates/cs/src/AutolinkedNativeModules.g.targets +0 -6
- package/templates/cs/src/MainPage.xaml.cs +0 -33
- package/templates/cs/src/Properties/AssemblyInfo.cs +0 -29
- package/templates/cs/src/Properties/Default.rd.xml +0 -32
- package/templates/cs/src/ReactPackageProvider.cs +0 -17
- package/templates/index.windows.bundle +0 -9
- package/templates/metro.config.js +0 -29
- package/templates/shared/assets/LockScreenLogo.scale-200.png +0 -0
- package/templates/shared/assets/SplashScreen.scale-200.png +0 -0
- package/templates/shared/assets/Square150x150Logo.scale-200.png +0 -0
- package/templates/shared/assets/Square44x44Logo.scale-200.png +0 -0
- package/templates/shared/assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
- package/templates/shared/assets/StoreLogo.png +0 -0
- package/templates/shared/assets/Wide310x150Logo.scale-200.png +0 -0
- package/templates/shared/proj/NuGet.Config +0 -13
- package/templates/shared/src/App.xaml +0 -10
- package/templates/shared/src/MainPage.xaml +0 -21
- package/templates/shared/src/Package.appxmanifest +0 -50
- /package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +0 -0
- /package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +0 -0
- /package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +0 -0
- /package/lib-commonjs/{runWindows/utils → utils}/version.js +0 -0
package/lib-commonjs/index.js
CHANGED
|
@@ -4,15 +4,47 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
31
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
32
|
+
};
|
|
33
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
|
+
};
|
|
7
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
37
|
exports.projectConfig = exports.dependencyConfig = exports.commands = exports.generateWindows = void 0;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
38
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
11
40
|
const generator_windows_1 = require("./generator-windows");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
41
|
+
const pathHelpers = __importStar(require("./utils/pathHelpers"));
|
|
42
|
+
const autolinkWindows_1 = require("./commands/autolinkWindows/autolinkWindows");
|
|
43
|
+
const codegenWindows_1 = require("./commands/codegenWindows/codegenWindows");
|
|
44
|
+
const initWindows_1 = require("./commands/initWindows/initWindows");
|
|
45
|
+
const runWindows_1 = require("./commands/runWindows/runWindows");
|
|
46
|
+
const dependencyConfig_1 = require("./commands/config/dependencyConfig");
|
|
47
|
+
const projectConfig_1 = require("./commands/config/projectConfig");
|
|
16
48
|
/**
|
|
17
49
|
* Simple utility for running the Windows generator.
|
|
18
50
|
*
|
|
@@ -22,17 +54,25 @@ const projectConfig_1 = require("./config/projectConfig");
|
|
|
22
54
|
* @param options command line options container
|
|
23
55
|
*/
|
|
24
56
|
async function generateWindows(projectDir, name, ns, options) {
|
|
25
|
-
if (!
|
|
26
|
-
|
|
57
|
+
if (!fs_1.default.existsSync(projectDir)) {
|
|
58
|
+
fs_1.default.mkdirSync(projectDir);
|
|
27
59
|
}
|
|
28
|
-
generator_windows_1.
|
|
29
|
-
|
|
60
|
+
await (0, generator_windows_1.installScriptsAndDependencies)(options);
|
|
61
|
+
const rnwPackage = pathHelpers.resolveRnwRoot(projectDir);
|
|
62
|
+
const templateRoot = path_1.default.join(rnwPackage, 'template');
|
|
63
|
+
await (0, generator_windows_1.copyProjectTemplateAndReplace)(templateRoot, projectDir, name, ns, options);
|
|
30
64
|
}
|
|
31
65
|
exports.generateWindows = generateWindows;
|
|
32
66
|
// Assert the interface here doesn't change for the reasons above
|
|
33
67
|
const assertStableInterface = true;
|
|
34
68
|
assertStableInterface;
|
|
35
|
-
exports.commands = [
|
|
69
|
+
exports.commands = [
|
|
70
|
+
autolinkWindows_1.autolinkCommand,
|
|
71
|
+
codegenWindows_1.codegenCommand,
|
|
72
|
+
initWindows_1.initCommand,
|
|
73
|
+
runWindows_1.runWindowsCommand,
|
|
74
|
+
];
|
|
36
75
|
exports.dependencyConfig = dependencyConfig_1.dependencyConfigWindows;
|
|
37
76
|
exports.projectConfig = projectConfig_1.projectConfigWindows;
|
|
77
|
+
__exportStar(require("./commands/healthCheck/healthChecks"), exports);
|
|
38
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,2DAG6B;AAE7B,iEAAmD;AAEnD,gFAA2E;AAC3E,6EAAwE;AACxE,oEAA+D;AAC/D,iEAAmE;AACnE,yEAA2E;AAC3E,mEAAqE;AAiCrE;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,UAAkB,EAClB,IAAY,EACZ,EAAU,EACV,OAAwB;IAExB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC9B,YAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;KAC1B;IAED,MAAM,IAAA,iDAA6B,EAAC,OAAO,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,IAAA,iDAA6B,EACjC,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,EAAE,EACF,OAAO,CACR,CAAC;AACJ,CAAC;AArBD,0CAqBC;AAED,iEAAiE;AACjE,MAAM,qBAAqB,GAOf,IAAI,CAAC;AACjB,qBAAqB,CAAC;AAET,QAAA,QAAQ,GAAG;IACtB,iCAAe;IACf,+BAAc;IACd,yBAAW;IACX,8BAAiB;CAClB,CAAC;AACW,QAAA,gBAAgB,GAAG,0CAAuB,CAAC;AAC3C,QAAA,aAAa,GAAG,oCAAoB,CAAC;AAClD,sEAAoD","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {\n copyProjectTemplateAndReplace,\n installScriptsAndDependencies,\n} from './generator-windows';\n\nimport * as pathHelpers from './utils/pathHelpers';\n\nimport {autolinkCommand} from './commands/autolinkWindows/autolinkWindows';\nimport {codegenCommand} from './commands/codegenWindows/codegenWindows';\nimport {initCommand} from './commands/initWindows/initWindows';\nimport {runWindowsCommand} from './commands/runWindows/runWindows';\nimport {dependencyConfigWindows} from './commands/config/dependencyConfig';\nimport {projectConfigWindows} from './commands/config/projectConfig';\n\n/**\n * Project generation options\n *\n * _\n * | |\n * __| | __ _ _ __ __ _ ___ _ __\n * / _` |/ _` | '_ \\ / _` |/ _ \\ '__|\n * | (_| | (_| | | | | (_| | __/ |\n * \\__,_|\\__,_|_| |_|\\__, |\\___|_|\n * __/ |\n * |___/\n *\n *\n * Properties on this interface must remain stable, as new versions of\n * react-native-windows-init may be used with local-cli dating back to 0.61.\n * All existing arguments must work correctly when changing this interface.\n */\nexport interface GenerateOptions {\n overwrite: boolean;\n language: 'cpp' | 'cs';\n projectType: 'app' | 'lib';\n experimentalNuGetDependency: boolean;\n nuGetTestVersion?: string;\n nuGetTestFeed?: string;\n useWinUI3: boolean;\n useHermes: boolean;\n useDevMode: boolean;\n verbose: boolean;\n telemetry: boolean;\n}\n\n/**\n * Simple utility for running the Windows generator.\n *\n * @param projectDir root project directory (i.e. contains index.js)\n * @param name name of the root JS module for this app\n * @param ns namespace for the project\n * @param options command line options container\n */\nexport async function generateWindows(\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) {\n if (!fs.existsSync(projectDir)) {\n fs.mkdirSync(projectDir);\n }\n\n await installScriptsAndDependencies(options);\n\n const rnwPackage = pathHelpers.resolveRnwRoot(projectDir);\n const templateRoot = path.join(rnwPackage, 'template');\n await copyProjectTemplateAndReplace(\n templateRoot,\n projectDir,\n name,\n ns,\n options,\n );\n}\n\n// Assert the interface here doesn't change for the reasons above\nconst assertStableInterface: typeof generateWindows extends (\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) => Promise<void>\n ? true\n : never = true;\nassertStableInterface;\n\nexport const commands = [\n autolinkCommand,\n codegenCommand,\n initCommand,\n runWindowsCommand,\n];\nexport const dependencyConfig = dependencyConfigWindows;\nexport const projectConfig = projectConfigWindows;\nexport * from './commands/healthCheck/healthChecks';\n"]}
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
6
|
import MSBuildTools from './msbuildtools';
|
|
7
|
-
import { RunWindowsOptions, BuildConfig, BuildArch } from '../runWindowsOptions';
|
|
7
|
+
import { RunWindowsOptions, BuildConfig, BuildArch } from '../commands/runWindows/runWindowsOptions';
|
|
8
8
|
import { Config } from '@react-native-community/cli-types';
|
|
9
|
-
export declare function buildSolution(buildTools: MSBuildTools, slnFile: string, buildType: BuildConfig, buildArch: BuildArch, msBuildProps: Record<string, string>, verbose: boolean, target?: string,
|
|
10
|
-
export declare function restoreNuGetPackages(slnFile: string, buildTools: MSBuildTools, verbose: boolean): Promise<void>;
|
|
9
|
+
export declare function buildSolution(buildTools: MSBuildTools, slnFile: string, buildType: BuildConfig, buildArch: BuildArch, msBuildProps: Record<string, string>, verbose: boolean, target: 'build' | 'deploy', buildLogDirectory?: string, singleproc?: boolean): Promise<void>;
|
|
11
10
|
export declare function getAppSolutionFile(options: RunWindowsOptions, config: Config): string | null;
|
|
12
11
|
export declare function getAppProjectFile(options: RunWindowsOptions, config: Config): string | null;
|
|
13
12
|
export declare function parseMsBuildProps(options: RunWindowsOptions): Record<string, string>;
|
|
@@ -4,86 +4,79 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
7
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.parseMsBuildProps = exports.getAppProjectFile = exports.getAppSolutionFile = exports.
|
|
9
|
-
const
|
|
10
|
-
const msbuildtools_1 = require("./msbuildtools");
|
|
11
|
-
const version_1 = require("./version");
|
|
11
|
+
exports.parseMsBuildProps = exports.getAppProjectFile = exports.getAppSolutionFile = exports.buildSolution = void 0;
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const msbuildtools_1 = __importDefault(require("./msbuildtools"));
|
|
14
|
+
const version_1 = __importDefault(require("./version"));
|
|
12
15
|
const commandWithProgress_1 = require("./commandWithProgress");
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
17
|
+
async function buildSolution(buildTools, slnFile, buildType, buildArch, msBuildProps, verbose, target, buildLogDirectory, singleproc) {
|
|
18
|
+
const minVersion = new version_1.default(10, 0, 19041, 0);
|
|
15
19
|
const allVersions = msbuildtools_1.default.getAllAvailableUAPVersions();
|
|
16
20
|
if (!allVersions.some(v => v.gte(minVersion))) {
|
|
17
|
-
throw new
|
|
21
|
+
throw new telemetry_1.CodedError('MinSDKVersionNotMet', 'Must have a minimum Windows SDK version 10.0.19041.0 installed');
|
|
18
22
|
}
|
|
19
|
-
await buildTools.buildProject(slnFile, buildType, buildArch, msBuildProps, verbose, target, buildLogDirectory);
|
|
23
|
+
await buildTools.buildProject(slnFile, buildType, buildArch, msBuildProps, verbose, target, buildLogDirectory, singleproc);
|
|
20
24
|
}
|
|
21
25
|
exports.buildSolution = buildSolution;
|
|
22
|
-
async function restoreNuGetPackages(slnFile, buildTools, verbose) {
|
|
23
|
-
const text = 'Restoring NuGet packages ';
|
|
24
|
-
const spinner = commandWithProgress_1.newSpinner(text);
|
|
25
|
-
await commandWithProgress_1.commandWithProgress(spinner, text, require.resolve('nuget-exe'), [
|
|
26
|
-
'restore',
|
|
27
|
-
`${slnFile}`,
|
|
28
|
-
'-NonInteractive',
|
|
29
|
-
'-Verbosity',
|
|
30
|
-
verbose ? 'normal' : 'quiet',
|
|
31
|
-
'-MSBuildVersion',
|
|
32
|
-
buildTools.installationVersion,
|
|
33
|
-
], verbose);
|
|
34
|
-
}
|
|
35
|
-
exports.restoreNuGetPackages = restoreNuGetPackages;
|
|
36
26
|
const configErrorString = 'Error: ';
|
|
37
27
|
function getAppSolutionFile(options, config) {
|
|
38
28
|
// Use the solution file if specified
|
|
39
29
|
if (options.sln) {
|
|
40
|
-
return
|
|
30
|
+
return path_1.default.join(options.root, options.sln);
|
|
41
31
|
}
|
|
42
32
|
// Check the answer from react-native config
|
|
43
33
|
const windowsAppConfig = config.project.windows;
|
|
34
|
+
if (!windowsAppConfig) {
|
|
35
|
+
throw new telemetry_1.CodedError('NoWindowsConfig', "Couldn't determine Windows app config");
|
|
36
|
+
}
|
|
44
37
|
const configSolutionFile = windowsAppConfig.solutionFile;
|
|
45
38
|
if (configSolutionFile.startsWith(configErrorString)) {
|
|
46
|
-
commandWithProgress_1.newError(configSolutionFile.substr(configErrorString.length) +
|
|
39
|
+
(0, commandWithProgress_1.newError)(configSolutionFile.substr(configErrorString.length) +
|
|
47
40
|
' Optionally, use --sln {slnFile}.');
|
|
48
41
|
return null;
|
|
49
42
|
}
|
|
50
43
|
else {
|
|
51
|
-
return
|
|
44
|
+
return path_1.default.join(windowsAppConfig.folder, windowsAppConfig.sourceDir, configSolutionFile);
|
|
52
45
|
}
|
|
53
46
|
}
|
|
54
47
|
exports.getAppSolutionFile = getAppSolutionFile;
|
|
55
48
|
function getAppProjectFile(options, config) {
|
|
56
49
|
// Use the project file if specified
|
|
57
50
|
if (options.proj) {
|
|
58
|
-
return
|
|
51
|
+
return path_1.default.join(options.root, options.proj);
|
|
59
52
|
}
|
|
60
53
|
// Check the answer from react-native config
|
|
61
54
|
const windowsAppConfig = config.project.windows;
|
|
62
55
|
const configProject = windowsAppConfig.project;
|
|
63
56
|
if (typeof configProject === 'string' &&
|
|
64
57
|
configProject.startsWith(configErrorString)) {
|
|
65
|
-
commandWithProgress_1.newError(configProject.substr(configErrorString.length) +
|
|
58
|
+
(0, commandWithProgress_1.newError)(configProject.substr(configErrorString.length) +
|
|
66
59
|
' Optionally, use --proj {projFile}.');
|
|
67
60
|
return null;
|
|
68
61
|
}
|
|
69
62
|
else {
|
|
70
63
|
const configProjectFile = configProject.projectFile;
|
|
71
64
|
if (configProjectFile.startsWith(configErrorString)) {
|
|
72
|
-
commandWithProgress_1.newError(configProjectFile.substr(configErrorString.length) +
|
|
65
|
+
(0, commandWithProgress_1.newError)(configProjectFile.substr(configErrorString.length) +
|
|
73
66
|
' Optionally, use --proj {projFile}.');
|
|
74
67
|
return null;
|
|
75
68
|
}
|
|
76
|
-
return
|
|
69
|
+
return path_1.default.join(windowsAppConfig.folder, windowsAppConfig.sourceDir, configProjectFile);
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
72
|
exports.getAppProjectFile = getAppProjectFile;
|
|
80
73
|
function parseMsBuildProps(options) {
|
|
81
|
-
|
|
74
|
+
const result = {};
|
|
82
75
|
if (options.msbuildprops) {
|
|
83
76
|
const props = options.msbuildprops.split(',');
|
|
84
|
-
for (
|
|
85
|
-
const
|
|
86
|
-
result[
|
|
77
|
+
for (const prop of props) {
|
|
78
|
+
const propAssignment = prop.split('=');
|
|
79
|
+
result[propAssignment[0]] = propAssignment[1];
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
return result;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/utils/build.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,kEAA0C;AAC1C,wDAAgC;AAChC,+DAA+C;AAO/C,+DAA2D;AAEpD,KAAK,UAAU,aAAa,CACjC,UAAwB,EACxB,OAAe,EACf,SAAsB,EACtB,SAAoB,EACpB,YAAoC,EACpC,OAAgB,EAChB,MAA0B,EAC1B,iBAA0B,EAC1B,UAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE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AAG,CAAC,CAAC;YACvC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;SAC/C;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,8CAYC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport MSBuildTools from './msbuildtools';\nimport Version from './version';\nimport {newError} from './commandWithProgress';\nimport {\n RunWindowsOptions,\n BuildConfig,\n BuildArch,\n} from '../commands/runWindows/runWindowsOptions';\nimport {Config} from '@react-native-community/cli-types';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport async function buildSolution(\n buildTools: MSBuildTools,\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory?: string,\n singleproc?: boolean,\n) {\n const minVersion = new Version(10, 0, 19041, 0);\n const allVersions = MSBuildTools.getAllAvailableUAPVersions();\n if (!allVersions.some(v => v.gte(minVersion))) {\n throw new CodedError(\n 'MinSDKVersionNotMet',\n 'Must have a minimum Windows SDK version 10.0.19041.0 installed',\n );\n }\n\n await buildTools.buildProject(\n slnFile,\n buildType,\n buildArch,\n msBuildProps,\n verbose,\n target,\n buildLogDirectory,\n singleproc,\n );\n}\n\nconst configErrorString = 'Error: ';\n\nexport function getAppSolutionFile(options: RunWindowsOptions, config: Config) {\n // Use the solution file if specified\n if (options.sln) {\n return path.join(options.root, options.sln);\n }\n\n // Check the answer from react-native config\n const windowsAppConfig = config.project.windows;\n if (!windowsAppConfig) {\n throw new CodedError(\n 'NoWindowsConfig',\n \"Couldn't determine Windows app config\",\n );\n }\n const configSolutionFile = windowsAppConfig.solutionFile;\n\n if (configSolutionFile.startsWith(configErrorString)) {\n newError(\n configSolutionFile.substr(configErrorString.length) +\n ' Optionally, use --sln {slnFile}.',\n );\n return null;\n } else {\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n configSolutionFile,\n );\n }\n}\n\nexport function getAppProjectFile(options: RunWindowsOptions, config: Config) {\n // Use the project file if specified\n if (options.proj) {\n return path.join(options.root, options.proj);\n }\n\n // Check the answer from react-native config\n const windowsAppConfig = config.project.windows;\n const configProject = windowsAppConfig.project;\n\n if (\n typeof configProject === 'string' &&\n configProject.startsWith(configErrorString)\n ) {\n newError(\n configProject.substr(configErrorString.length) +\n ' Optionally, use --proj {projFile}.',\n );\n return null;\n } else {\n const configProjectFile = configProject.projectFile;\n if (configProjectFile.startsWith(configErrorString)) {\n newError(\n configProjectFile.substr(configErrorString.length) +\n ' Optionally, use --proj {projFile}.',\n );\n return null;\n }\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n configProjectFile,\n );\n }\n}\n\nexport function parseMsBuildProps(\n options: RunWindowsOptions,\n): Record<string, string> {\n const result: Record<string, string> = {};\n if (options.msbuildprops) {\n const props = options.msbuildprops.split(',');\n for (const prop of props) {\n const propAssignment = prop.split('=');\n result[propAssignment[0]] = propAssignment[1];\n }\n }\n return result;\n}\n"]}
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
7
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
11
|
exports.isWinSdkPresent = void 0;
|
|
12
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
9
13
|
const child_process_1 = require("child_process");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const version_1 = require("./version");
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const shelljs_1 = __importDefault(require("shelljs"));
|
|
16
|
+
const version_1 = __importDefault(require("./version"));
|
|
13
17
|
const REQUIRED_VERSIONS = {
|
|
14
18
|
'10.0': {
|
|
15
19
|
os: new version_1.default(6, 3),
|
|
@@ -30,7 +34,7 @@ function getInstalledWindowsSdks() {
|
|
|
30
34
|
const execString = 'reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows" /s /v InstallationFolder /reg:32';
|
|
31
35
|
let output;
|
|
32
36
|
try {
|
|
33
|
-
output = child_process_1.execSync(execString).toString();
|
|
37
|
+
output = (0, child_process_1.execSync)(execString).toString();
|
|
34
38
|
}
|
|
35
39
|
catch (e) {
|
|
36
40
|
return installedSdks;
|
|
@@ -39,10 +43,10 @@ function getInstalledWindowsSdks() {
|
|
|
39
43
|
let match;
|
|
40
44
|
while ((match = re.exec(output))) {
|
|
41
45
|
const sdkPath = match[2];
|
|
42
|
-
if (
|
|
46
|
+
if (shelljs_1.default.test('-e', path_1.default.join(sdkPath, 'SDKManifest.xml'))) {
|
|
43
47
|
const sdkVersion = version_1.default.tryParse(match[1]);
|
|
44
48
|
if (!sdkVersion) {
|
|
45
|
-
throw new
|
|
49
|
+
throw new telemetry_1.CodedError('BadSDKVersionFormat', `Unexpected SDK version format for '${match[1]}'`);
|
|
46
50
|
}
|
|
47
51
|
installedSdks.push(sdkVersion);
|
|
48
52
|
}
|
|
@@ -57,7 +61,7 @@ function checkWinSdk(windowsTargetVersion) {
|
|
|
57
61
|
return shortenVersion(requiredVersion);
|
|
58
62
|
}
|
|
59
63
|
const shortenedVersion = shortenVersion(requiredVersion);
|
|
60
|
-
throw new
|
|
64
|
+
throw new telemetry_1.CodedError('NoSDK', `Windows SDK not found. Ensure that you have installed Windows ${shortenedVersion} SDK along with Visual Studio or install Windows ${shortenedVersion} SDK separately from https://dev.windows.com/en-us/downloads`);
|
|
61
65
|
}
|
|
62
66
|
function isWinSdkPresent(target) {
|
|
63
67
|
return checkWinSdk(target);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkRequirements.js","sourceRoot":"","sources":["../../src/utils/checkRequirements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AAC,IAAI,CAAC,IAAI,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE;YAC3D,MAAM,UAAU,GAAG,iBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,CAAC,UAAU,EAAE;gBACf,MAAM,IAAI,sBAAU,CAClB,qBAAqB,EACrB,sCAAsC,KAAK,CAAC,CAAC,CAAC,GAAG,CAClD,CAAC;aACH;YACD,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAChC;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,oBAA4B;IAC/C,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,4BAA4B,CAClD,YAAY,EACZ,oBAAoB,CACrB,CAAC;IACF,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CACxD,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CACjC,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;KACxC;IAED,MAAM,gBAAgB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IACzD,MAAM,IAAI,sBAAU,CAClB,OAAO,EACP,iEAAiE,gBAAgB,oDAAoD,gBAAgB,8DAA8D,CACpN,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe,CAAC,MAAc;IAC5C,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAFD,0CAEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CodedError} from '@react-native-windows/telemetry';\nimport {execSync} from 'child_process';\nimport path from 'path';\nimport shell from 'shelljs';\nimport Version from './version';\n\ntype Requirement =\n | 'os'\n | 'msbuild'\n | 'visualstudio'\n | 'windowssdk'\n | 'phonesdk';\n\nconst REQUIRED_VERSIONS: Record<string, Record<Requirement, Version>> = {\n '10.0': {\n os: new Version(6, 3),\n msbuild: new Version(14, 0),\n visualstudio: new Version(14, 0),\n windowssdk: new Version(10, 0),\n phonesdk: new Version(10, 0),\n },\n};\n\nfunction shortenVersion(version: Version): string {\n return /^(\\d+(?:\\.\\d+)?)/.exec(version.toString())![1];\n}\n\nfunction getMinimalRequiredVersionFor(\n requirement: Requirement,\n windowsTargetVersion: keyof typeof REQUIRED_VERSIONS,\n): Version {\n return REQUIRED_VERSIONS[windowsTargetVersion][requirement];\n}\n\nfunction getInstalledWindowsSdks(): Version[] {\n const installedSdks: Version[] = [];\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\" /s /v InstallationFolder /reg:32';\n let output: string;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return installedSdks;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v(\\d+\\.\\d+)\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n let match: RegExpExecArray | null;\n while ((match = re.exec(output))) {\n const sdkPath = match[2];\n if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) {\n const sdkVersion = Version.tryParse(match[1]);\n if (!sdkVersion) {\n throw new CodedError(\n 'BadSDKVersionFormat',\n `Unexpected SDK version format for '${match[1]}'`,\n );\n }\n installedSdks.push(sdkVersion);\n }\n }\n\n return installedSdks;\n}\n\nfunction checkWinSdk(windowsTargetVersion: string): string {\n const installedSdks = getInstalledWindowsSdks();\n const requiredVersion = getMinimalRequiredVersionFor(\n 'windowssdk',\n windowsTargetVersion,\n );\n const hasSdkInstalled = installedSdks.some(installedSdk =>\n installedSdk.eq(requiredVersion),\n );\n\n if (hasSdkInstalled) {\n return shortenVersion(requiredVersion);\n }\n\n const shortenedVersion = shortenVersion(requiredVersion);\n throw new CodedError(\n 'NoSDK',\n `Windows SDK not found. Ensure that you have installed Windows ${shortenedVersion} SDK along with Visual Studio or install Windows ${shortenedVersion} SDK separately from https://dev.windows.com/en-us/downloads`,\n );\n}\n\nexport function isWinSdkPresent(target: string): string {\n return checkWinSdk(target);\n}\n"]}
|
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import { CodedErrorType } from '@react-native-windows/telemetry';
|
|
7
8
|
export declare function newSpinner(text: string): ora.Ora;
|
|
8
|
-
export declare
|
|
9
|
-
export declare function
|
|
9
|
+
export declare const powershell: string;
|
|
10
|
+
export declare function runPowerShellScriptFunction(taskDescription: string, script: string | null, funcName: string, verbose: boolean, errorCategory: CodedErrorType): Promise<void>;
|
|
11
|
+
export declare function commandWithProgress(spinner: ora.Ora, taskDoingName: string, command: string, args: string[], verbose: boolean, errorCategory: CodedErrorType): Promise<void>;
|
|
10
12
|
export declare function newError(text: string): void;
|
|
11
13
|
export declare function newWarn(text: string): void;
|
|
12
14
|
export declare function newSuccess(text: string): void;
|
|
13
15
|
export declare function newInfo(text: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the process exit code and offers some information at the end of a CLI command.
|
|
18
|
+
* @param loggingIsEnabled Is verbose logging enabled.
|
|
19
|
+
* @param error The error caught during the process, if any.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setExitProcessWithError(loggingIsEnabled?: boolean, error?: Error): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.setExitProcessWithError = exports.newInfo = exports.newSuccess = exports.newWarn = exports.newError = exports.commandWithProgress = exports.runPowerShellScriptFunction = exports.powershell = exports.newSpinner = void 0;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const ora_1 = __importDefault(require("ora"));
|
|
14
|
+
const cli_spinners_1 = __importDefault(require("cli-spinners"));
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
17
|
+
function setSpinnerText(spinner, prefix, text) {
|
|
18
|
+
text = prefix + spinnerString(text);
|
|
19
|
+
spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;
|
|
20
|
+
}
|
|
21
|
+
function spinnerString(msg) {
|
|
22
|
+
msg = msg.trim();
|
|
23
|
+
const lastLineIndex = msg.lastIndexOf('\n');
|
|
24
|
+
if (lastLineIndex > 0) {
|
|
25
|
+
msg = msg.slice(lastLineIndex + 1);
|
|
26
|
+
}
|
|
27
|
+
msg = msg.trim();
|
|
28
|
+
return msg;
|
|
29
|
+
}
|
|
30
|
+
function newSpinner(text) {
|
|
31
|
+
const options = {
|
|
32
|
+
text: text,
|
|
33
|
+
indent: 1,
|
|
34
|
+
// ora turns off emoji rendering by default on windows, since the default terminal
|
|
35
|
+
// doesn't render them. Turn them back on when running in the new windows terminal
|
|
36
|
+
...(process.env.WT_SESSION && { spinner: cli_spinners_1.default.dots }),
|
|
37
|
+
// By default, ora process.stderr as the output stream, however,the VS Code debugger
|
|
38
|
+
// Uses stdout to match success patterns
|
|
39
|
+
stream: process.stdout,
|
|
40
|
+
};
|
|
41
|
+
return (0, ora_1.default)(options).start();
|
|
42
|
+
}
|
|
43
|
+
exports.newSpinner = newSpinner;
|
|
44
|
+
exports.powershell = `${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
45
|
+
async function runPowerShellScriptFunction(taskDescription, script, funcName, verbose, errorCategory) {
|
|
46
|
+
try {
|
|
47
|
+
const printException = verbose ? '$_;' : '';
|
|
48
|
+
const importScript = script ? `Import-Module "${script}"; ` : '';
|
|
49
|
+
await commandWithProgress(newSpinner(taskDescription), taskDescription, exports.powershell, [
|
|
50
|
+
'-NoProfile',
|
|
51
|
+
'-ExecutionPolicy',
|
|
52
|
+
'RemoteSigned',
|
|
53
|
+
`${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,
|
|
54
|
+
], verbose, errorCategory);
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
// The error output from the process will be shown if verbose is set.
|
|
58
|
+
// We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.
|
|
59
|
+
throw new telemetry_1.CodedError(errorCategory, taskDescription);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.runPowerShellScriptFunction = runPowerShellScriptFunction;
|
|
63
|
+
function commandWithProgress(spinner, taskDoingName, command, args, verbose, errorCategory) {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const spawnOptions = verbose ? { stdio: 'inherit' } : {};
|
|
66
|
+
if (verbose) {
|
|
67
|
+
spinner.stop();
|
|
68
|
+
}
|
|
69
|
+
const cp = (0, child_process_1.spawn)(command, args, spawnOptions);
|
|
70
|
+
let firstErrorLine = null;
|
|
71
|
+
if (!verbose) {
|
|
72
|
+
cp.stdout.on('data', chunk => {
|
|
73
|
+
const text = chunk.toString();
|
|
74
|
+
setSpinnerText(spinner, taskDoingName + ': ', text);
|
|
75
|
+
});
|
|
76
|
+
cp.stderr.on('data', chunk => {
|
|
77
|
+
const text = chunk.toString();
|
|
78
|
+
if (!firstErrorLine) {
|
|
79
|
+
firstErrorLine = text;
|
|
80
|
+
}
|
|
81
|
+
if (text) {
|
|
82
|
+
setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);
|
|
83
|
+
}
|
|
84
|
+
reject(new telemetry_1.CodedError(errorCategory, firstErrorLine, {
|
|
85
|
+
taskName: taskDoingName,
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
cp.on('error', e => {
|
|
90
|
+
if (verbose) {
|
|
91
|
+
console.error(chalk_1.default.red(e.toString()));
|
|
92
|
+
}
|
|
93
|
+
spinner.fail(e.toString());
|
|
94
|
+
const ce = new telemetry_1.CodedError(errorCategory, e.message);
|
|
95
|
+
ce.stack = e.stack;
|
|
96
|
+
reject(ce);
|
|
97
|
+
}).on('close', code => {
|
|
98
|
+
if (code === 0) {
|
|
99
|
+
spinner.succeed(taskDoingName);
|
|
100
|
+
resolve();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
spinner.fail();
|
|
104
|
+
reject(new telemetry_1.CodedError(errorCategory, `${taskDoingName} - exit error code ${code}`, {
|
|
105
|
+
taskName: taskDoingName,
|
|
106
|
+
taskExitCode: code,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.commandWithProgress = commandWithProgress;
|
|
113
|
+
function newError(text) {
|
|
114
|
+
newSpinner(text).fail(text);
|
|
115
|
+
}
|
|
116
|
+
exports.newError = newError;
|
|
117
|
+
function newWarn(text) {
|
|
118
|
+
newSpinner(text).warn(text);
|
|
119
|
+
}
|
|
120
|
+
exports.newWarn = newWarn;
|
|
121
|
+
function newSuccess(text) {
|
|
122
|
+
newSpinner(text).succeed(text);
|
|
123
|
+
}
|
|
124
|
+
exports.newSuccess = newSuccess;
|
|
125
|
+
function newInfo(text) {
|
|
126
|
+
newSpinner(text).info(text);
|
|
127
|
+
}
|
|
128
|
+
exports.newInfo = newInfo;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the process exit code and offers some information at the end of a CLI command.
|
|
131
|
+
* @param loggingIsEnabled Is verbose logging enabled.
|
|
132
|
+
* @param error The error caught during the process, if any.
|
|
133
|
+
*/
|
|
134
|
+
function setExitProcessWithError(loggingIsEnabled, error) {
|
|
135
|
+
if (error) {
|
|
136
|
+
const errorType = error instanceof telemetry_1.CodedError ? error.type : 'Unknown';
|
|
137
|
+
process.exitCode = telemetry_1.CodedErrors[errorType];
|
|
138
|
+
if (loggingIsEnabled) {
|
|
139
|
+
console.log(`Command failed with error ${chalk_1.default.bold(errorType)}: ${error.message}`);
|
|
140
|
+
if (telemetry_1.Telemetry.isEnabled()) {
|
|
141
|
+
console.log(`Your telemetry sessionId was ${chalk_1.default.bold(telemetry_1.Telemetry.getSessionId())}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(`Command failed. Re-run the command with ${chalk_1.default.bold('--logging')} for more information.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.setExitProcessWithError = setExitProcessWithError;
|
|
150
|
+
//# sourceMappingURL=commandWithProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandWithProgress.js","sourceRoot":"","sources":["../../src/utils/commandWithProgress.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAkD;AAClD,8CAAsB;AACtB,gEAAoC;AACpC,kDAA0B;AAC1B,+DAKyC;AAEzC,SAAS,cAAc,CAAC,OAAgB,EAAE,MAAc,EAAE,IAAY;IACpE,IAAI,GAAG,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,MAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,aAAa,GAAG,CAAC,EAAE;Q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EC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAFD,0BAEC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,gBAA0B,EAC1B,KAAa;IAEb,IAAI,KAAK,EAAE;QACT,MAAM,SAAS,GACb,KAAK,YAAY,sBAAU,CAAC,CAAC,CAAE,KAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvE,OAAO,CAAC,QAAQ,GAAG,uBAAW,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,gBAAgB,EAAE;YACpB,OAAO,CAAC,GAAG,CACT,6BAA6B,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CACvE,CAAC;YACF,IAAI,qBAAS,CAAC,SAAS,EAAE,EAAE;gBACzB,OAAO,CAAC,GAAG,CACT,gCAAgC,eAAK,CAAC,IAAI,CACxC,qBAAS,CAAC,YAAY,EAAE,CACzB,EAAE,CACJ,CAAC;aACH;SACF;aAAM;YACL,OAAO,CAAC,GAAG,CACT,2CAA2C,eAAK,CAAC,IAAI,CACnD,WAAW,CACZ,wBAAwB,CAC1B,CAAC;SACH;KACF;AACH,CAAC;AA7BD,0DA6BC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {spawn, SpawnOptions} from 'child_process';\nimport ora from 'ora';\nimport spinners from 'cli-spinners';\nimport chalk from 'chalk';\nimport {\n Telemetry,\n CodedError,\n CodedErrors,\n CodedErrorType,\n} from '@react-native-windows/telemetry';\n\nfunction setSpinnerText(spinner: ora.Ora, prefix: string, text: string) {\n text = prefix + spinnerString(text);\n spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;\n}\n\nfunction spinnerString(msg: string) {\n msg = msg.trim();\n const lastLineIndex = msg.lastIndexOf('\\n');\n if (lastLineIndex > 0) {\n msg = msg.slice(lastLineIndex + 1);\n }\n msg = msg.trim();\n return msg;\n}\n\nexport function newSpinner(text: string) {\n const options: ora.Options = {\n text: text,\n indent: 1,\n\n // ora turns off emoji rendering by default on windows, since the default terminal\n // doesn't render them. Turn them back on when running in the new windows terminal\n ...(process.env.WT_SESSION && {spinner: spinners.dots}),\n\n // By default, ora process.stderr as the output stream, however,the VS Code debugger\n // Uses stdout to match success patterns\n stream: process.stdout,\n };\n\n return ora(options).start();\n}\n\nexport const powershell = `${process.env.SystemRoot}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`;\n\nexport async function runPowerShellScriptFunction(\n taskDescription: string,\n script: string | null,\n funcName: string,\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n try {\n const printException = verbose ? '$_;' : '';\n const importScript = script ? `Import-Module \"${script}\"; ` : '';\n await commandWithProgress(\n newSpinner(taskDescription),\n taskDescription,\n powershell,\n [\n '-NoProfile',\n '-ExecutionPolicy',\n 'RemoteSigned',\n `${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,\n ],\n verbose,\n errorCategory,\n );\n } catch {\n // The error output from the process will be shown if verbose is set.\n // We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.\n throw new CodedError(errorCategory, taskDescription);\n }\n}\n\nexport function commandWithProgress(\n spinner: ora.Ora,\n taskDoingName: string,\n command: string,\n args: string[],\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n return new Promise<void>((resolve, reject) => {\n const spawnOptions: SpawnOptions = verbose ? {stdio: 'inherit'} : {};\n\n if (verbose) {\n spinner.stop();\n }\n\n const cp = spawn(command, args, spawnOptions);\n let firstErrorLine: string | null = null;\n if (!verbose) {\n cp.stdout!.on('data', chunk => {\n const text = chunk.toString();\n setSpinnerText(spinner, taskDoingName + ': ', text);\n });\n cp.stderr!.on('data', chunk => {\n const text: string = chunk.toString();\n if (!firstErrorLine) {\n firstErrorLine = text;\n }\n if (text) {\n setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);\n }\n reject(\n new CodedError(errorCategory, firstErrorLine, {\n taskName: taskDoingName,\n }),\n );\n });\n }\n cp.on('error', e => {\n if (verbose) {\n console.error(chalk.red(e.toString()));\n }\n spinner.fail(e.toString());\n const ce = new CodedError(errorCategory, e.message);\n ce.stack = e.stack;\n reject(ce);\n }).on('close', code => {\n if (code === 0) {\n spinner.succeed(taskDoingName);\n resolve();\n } else {\n spinner.fail();\n reject(\n new CodedError(\n errorCategory,\n `${taskDoingName} - exit error code ${code}`,\n {\n taskName: taskDoingName,\n taskExitCode: code,\n },\n ),\n );\n }\n });\n });\n}\n\nexport function newError(text: string) {\n newSpinner(text).fail(text);\n}\n\nexport function newWarn(text: string) {\n newSpinner(text).warn(text);\n}\n\nexport function newSuccess(text: string) {\n newSpinner(text).succeed(text);\n}\n\nexport function newInfo(text: string) {\n newSpinner(text).info(text);\n}\n\n/**\n * Sets the process exit code and offers some information at the end of a CLI command.\n * @param loggingIsEnabled Is verbose logging enabled.\n * @param error The error caught during the process, if any.\n */\nexport function setExitProcessWithError(\n loggingIsEnabled?: boolean,\n error?: Error,\n): void {\n if (error) {\n const errorType =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n\n process.exitCode = CodedErrors[errorType];\n\n if (loggingIsEnabled) {\n console.log(\n `Command failed with error ${chalk.bold(errorType)}: ${error.message}`,\n );\n if (Telemetry.isEnabled()) {\n console.log(\n `Your telemetry sessionId was ${chalk.bold(\n Telemetry.getSessionId(),\n )}`,\n );\n }\n } else {\n console.log(\n `Command failed. Re-run the command with ${chalk.bold(\n '--logging',\n )} for more information.`,\n );\n }\n }\n}\n"]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
|
-
import { BuildConfig, RunWindowsOptions } from '../runWindowsOptions';
|
|
6
|
+
import { BuildConfig, RunWindowsOptions } from '../commands/runWindows/runWindowsOptions';
|
|
7
7
|
import MSBuildTools from './msbuildtools';
|
|
8
8
|
import { Config } from '@react-native-community/cli-types';
|
|
9
9
|
export declare function getBuildConfiguration(options: RunWindowsOptions): BuildConfig;
|
|
10
|
-
export declare function deployToDevice(options: RunWindowsOptions, verbose: boolean): Promise<void>;
|
|
10
|
+
export declare function deployToDevice(options: RunWindowsOptions, verbose: boolean, config: Config): Promise<void>;
|
|
11
11
|
export declare function deployToDesktop(options: RunWindowsOptions, verbose: boolean, config: Config, buildTools: MSBuildTools): Promise<void>;
|
|
12
12
|
export declare function startServerInNewWindow(options: RunWindowsOptions, verbose: boolean): Promise<void>;
|