@react-native-windows/cli 0.0.0-canary.26 → 0.0.0-canary.261

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.
Files changed (145) hide show
  1. package/README.md +117 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +88 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +705 -0
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
  5. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
  6. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
  7. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
  8. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
  9. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +211 -0
  10. package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
  11. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
  12. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
  13. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
  14. package/lib-commonjs/{config → commands/config}/configUtils.d.ts +141 -93
  15. package/lib-commonjs/commands/config/configUtils.js +423 -0
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +38 -37
  18. package/lib-commonjs/commands/config/dependencyConfig.js +230 -0
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +28 -24
  21. package/lib-commonjs/commands/config/projectConfig.js +191 -0
  22. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  25. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  28. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js +275 -0
  31. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +16 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +42 -0
  34. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  35. package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
  36. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  37. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  38. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
  39. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
  40. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  41. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  42. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  43. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  45. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  46. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  48. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  49. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  50. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  51. package/lib-commonjs/e2etest/initWindows.test.js +110 -0
  52. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  54. package/lib-commonjs/e2etest/projectConfig.test.js +112 -0
  55. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  57. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  58. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  59. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  60. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  61. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  62. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  63. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  64. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  65. package/lib-commonjs/generator-common/index.d.ts +39 -23
  66. package/lib-commonjs/generator-common/index.js +242 -221
  67. package/lib-commonjs/generator-common/index.js.map +1 -1
  68. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  69. package/lib-commonjs/generator-windows/index.js +341 -364
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -47
  72. package/lib-commonjs/index.js +77 -39
  73. package/lib-commonjs/index.js.map +1 -1
  74. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
  75. package/lib-commonjs/{runWindows/utils → utils}/build.js +89 -91
  76. package/lib-commonjs/utils/build.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
  78. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
  79. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
  81. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
  82. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  83. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
  84. package/lib-commonjs/utils/deploy.js +354 -0
  85. package/lib-commonjs/utils/deploy.js.map +1 -0
  86. package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
  87. package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
  88. package/lib-commonjs/utils/info.js.map +1 -0
  89. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  90. package/lib-commonjs/utils/msbuildtools.js +281 -0
  91. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  92. package/lib-commonjs/utils/nameHelpers.d.ts +9 -0
  93. package/lib-commonjs/utils/nameHelpers.js +46 -0
  94. package/lib-commonjs/utils/nameHelpers.js.map +1 -0
  95. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  96. package/lib-commonjs/utils/pathHelpers.js +37 -0
  97. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  98. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  99. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  100. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  101. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
  102. package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
  103. package/lib-commonjs/utils/version.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
  105. package/lib-commonjs/utils/vsInstalls.js +102 -0
  106. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  107. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
  108. package/lib-commonjs/utils/vstools.js +190 -0
  109. package/lib-commonjs/utils/vstools.js.map +1 -0
  110. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
  111. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
  112. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  113. package/package.json +49 -31
  114. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  115. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  116. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  117. package/CHANGELOG.json +0 -413
  118. package/CHANGELOG.md +0 -200
  119. package/lib-commonjs/config/configUtils.js +0 -253
  120. package/lib-commonjs/config/configUtils.js.map +0 -1
  121. package/lib-commonjs/config/dependencyConfig.js +0 -167
  122. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  123. package/lib-commonjs/config/projectConfig.js +0 -121
  124. package/lib-commonjs/config/projectConfig.js.map +0 -1
  125. package/lib-commonjs/runWindows/runWindows.js +0 -159
  126. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  127. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  129. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  130. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  131. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  132. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  134. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  135. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  136. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  137. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  138. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  139. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  140. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  141. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  142. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  143. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  144. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  145. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
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.addProjectToSolution = exports.dotNetCoreProjectTypeGuid = void 0;
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ const chalk_1 = __importDefault(require("chalk"));
15
+ const telemetry_1 = require("@react-native-windows/telemetry");
16
+ const projectTypeGuidsByLanguage = {
17
+ cpp: '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}',
18
+ cs: '{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}',
19
+ };
20
+ exports.dotNetCoreProjectTypeGuid = '{9A19103F-16F7-4668-BE54-9A1E7A4F7556}';
21
+ /**
22
+ * Checks is the given block of lines exists within an array of lines.
23
+ * @param lines The array of lines to search.
24
+ * @param block The block of lines to search for.
25
+ * @return The starting index the block within lines, if it exists.
26
+ */
27
+ function linesContainsBlock(lines, block) {
28
+ if (block.length > 0) {
29
+ const startIndex = lines.findIndex(s => block[0] instanceof RegExp ? s.match(block[0]) : s === block[0]);
30
+ if (startIndex >= 0) {
31
+ for (let i = 1; i < block.length; i++) {
32
+ if (block[i] instanceof RegExp
33
+ ? !lines[startIndex + i].match(block[i])
34
+ : lines[startIndex + i] !== block[i]) {
35
+ return -1;
36
+ }
37
+ }
38
+ return startIndex;
39
+ }
40
+ }
41
+ return -1;
42
+ }
43
+ /**
44
+ * Insert the given block of lines into an array of lines.
45
+ * @param lines The array of lines to insert into.
46
+ * @param block The block of lines to insert.
47
+ * @param index The index to perform the insert.
48
+ */
49
+ function insertBlockIntoLines(lines, block, index) {
50
+ for (let i = 0; i < block.length; i++) {
51
+ lines.splice(index + i, 0, block[i]);
52
+ }
53
+ }
54
+ /**
55
+ * Overwrite the lines at the given index with the block.
56
+ * @param lines The destination array of lines to.
57
+ * @param block The source block of lines.
58
+ * @param index The index to perform the overwrite.
59
+ */
60
+ function overwriteLinesWithBlock(lines, block, index) {
61
+ for (let i = 0; i < block.length; i++) {
62
+ lines[index + i] = block[i];
63
+ }
64
+ }
65
+ /**
66
+ * Search through an array of lines for a block of lines starting with startLine and ending with endLine.
67
+ * @param lines The array of lines to search.
68
+ * @param startLine The first line of the block.
69
+ * @param endLine The last line of the block.
70
+ * @param includeStartEnd Include the start and end lines in the result.
71
+ * @return The found block of lines, if found.
72
+ */
73
+ function getBlockContentsFromLines(lines, startLine, endLine, includeStartEnd = true) {
74
+ const startIndex = lines.indexOf(startLine);
75
+ const endIndex = lines.indexOf(endLine, startIndex);
76
+ if (startIndex >= 0 && startIndex < endIndex) {
77
+ if (includeStartEnd) {
78
+ return lines.slice(startIndex, endIndex + 1);
79
+ }
80
+ else if (startIndex + 1 < endIndex) {
81
+ return lines.slice(startIndex + 1, endIndex);
82
+ }
83
+ }
84
+ return [];
85
+ }
86
+ /**
87
+ * Adds the necessary info from a VS project into a VS solution file so that it will build.
88
+ * @param slnFile The Absolute path to the target VS solution file.
89
+ * @param project The object representing the project info.
90
+ * @param verbose If true, enable verbose logging.
91
+ * @param checkMode It true, don't make any changes.
92
+ * @return Whether any changes were necessary.
93
+ */
94
+ function addProjectToSolution(slnFile, project, verbose = false, checkMode = false) {
95
+ if (project.projectLang === null) {
96
+ throw new telemetry_1.CodedError('AddProjectToSolution', 'Unable to add project to solution, projectLang is null');
97
+ }
98
+ if (project.projectGuid === null) {
99
+ throw new telemetry_1.CodedError('AddProjectToSolution', 'Unable to add project to solution, projectGuid is null');
100
+ }
101
+ if (verbose) {
102
+ console.log(`Processing ${chalk_1.default.bold(path_1.default.basename(project.projectFile))}...`);
103
+ }
104
+ const originalSlnContents = fs_1.default.readFileSync(slnFile).toString();
105
+ const isCRLF = originalSlnContents.includes('\r\n');
106
+ const slnLines = originalSlnContents.split(isCRLF ? '\r\n' : '\n');
107
+ let contentsChanged = false;
108
+ // Check for the project entry block
109
+ const slnDir = path_1.default.dirname(slnFile);
110
+ const relProjectFile = path_1.default.relative(slnDir, project.projectFile);
111
+ const projectTypeGuid = 'projectTypeGuid' in project
112
+ ? project.projectTypeGuid
113
+ : projectTypeGuidsByLanguage[project.projectLang];
114
+ const projectGuid = project.projectGuid.toUpperCase();
115
+ const projectEntryBlock = [
116
+ `Project("${projectTypeGuid}") = "${project.projectName}", "${relProjectFile}", "${projectGuid}"`,
117
+ 'EndProject',
118
+ ];
119
+ const projectEntryBlockRegex = [
120
+ new RegExp(`Project\\("${projectTypeGuid}"\\) = "${project.projectName}", "(.*)", "${projectGuid}"`),
121
+ 'EndProject',
122
+ ];
123
+ const blockIndex = linesContainsBlock(slnLines, projectEntryBlockRegex);
124
+ if (blockIndex < 0) {
125
+ // Regex didn't match, insert
126
+ if (verbose) {
127
+ console.log(chalk_1.default.yellow('Missing project entry block, inserting.'));
128
+ }
129
+ const globalIndex = slnLines.indexOf('Global');
130
+ insertBlockIntoLines(slnLines, projectEntryBlock, globalIndex);
131
+ contentsChanged = true;
132
+ }
133
+ else if (linesContainsBlock(slnLines, projectEntryBlock) < 0) {
134
+ // Regex matched but project path has changed, so correct it
135
+ if (verbose) {
136
+ console.log(chalk_1.default.yellow('Existing project entry block found, overwriting.'));
137
+ }
138
+ overwriteLinesWithBlock(slnLines, projectEntryBlock, blockIndex);
139
+ contentsChanged = true;
140
+ }
141
+ // Check for the project configuration platforms
142
+ const slnConfigs = getBlockContentsFromLines(slnLines, '\tGlobalSection(SolutionConfigurationPlatforms) = preSolution', '\tEndGlobalSection', false).map(line => line.match(/\s+([\w\s|]+)\s=/)[1]);
143
+ const projectConfigLines = [];
144
+ slnConfigs.forEach(slnConfig => {
145
+ if (!slnConfig.endsWith('|Any CPU')) {
146
+ projectConfigLines.push(`\t\t${projectGuid}.${slnConfig}.ActiveCfg = ${project.projectLang === 'cpp'
147
+ ? slnConfig.replace('x86', 'Win32')
148
+ : slnConfig}`);
149
+ projectConfigLines.push(`\t\t${projectGuid}.${slnConfig}.Build.0 = ${project.projectLang === 'cpp'
150
+ ? slnConfig.replace('x86', 'Win32')
151
+ : slnConfig}`);
152
+ }
153
+ });
154
+ const projectConfigStartIndex = slnLines.indexOf('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution');
155
+ projectConfigLines.forEach(projectConfigLine => {
156
+ if (!slnLines.includes(projectConfigLine)) {
157
+ if (verbose) {
158
+ const configLine = projectConfigLine.substr(projectConfigLine.indexOf('= ') + 2);
159
+ console.log(chalk_1.default.yellow(`Missing ${configLine} config block.`));
160
+ }
161
+ const projectConfigEndIndex = slnLines.indexOf('\tEndGlobalSection', projectConfigStartIndex);
162
+ slnLines.splice(projectConfigEndIndex, 0, projectConfigLine);
163
+ contentsChanged = true;
164
+ }
165
+ });
166
+ // Write out new solution file if there were changes
167
+ if (contentsChanged) {
168
+ if (verbose) {
169
+ console.log(chalk_1.default.yellow(`${chalk_1.default.bold(path_1.default.basename(slnFile))} needs to be updated.`));
170
+ }
171
+ if (!checkMode) {
172
+ if (verbose) {
173
+ console.log(`Writing changes to ${chalk_1.default.bold(path_1.default.basename(slnFile))}...`);
174
+ }
175
+ const slnContents = slnLines.join(isCRLF ? '\r\n' : '\n');
176
+ fs_1.default.writeFileSync(slnFile, slnContents, {
177
+ encoding: 'utf8',
178
+ flag: 'w',
179
+ });
180
+ }
181
+ }
182
+ else {
183
+ if (verbose) {
184
+ console.log(`No changes to ${chalk_1.default.bold(path_1.default.basename(slnFile))}.`);
185
+ }
186
+ }
187
+ return contentsChanged;
188
+ }
189
+ exports.addProjectToSolution = addProjectToSolution;
190
+ //# sourceMappingURL=vstools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vstools.js","sourceRoot":"","sources":["../../src/utils/vstools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AA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MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1D,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE;gBACrC,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,GAAG;aACV,CAAC,CAAC;SACJ;KACF;SAAM;QACL,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,GAAG,CAAC,iBAAiB,eAAK,CAAC,IAAI,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;SACrE;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AApKD,oDAoKC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {Project} from '../commands/config/projectConfig';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nconst projectTypeGuidsByLanguage = {\n cpp: '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}',\n cs: '{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}',\n};\n\nexport const dotNetCoreProjectTypeGuid =\n '{9A19103F-16F7-4668-BE54-9A1E7A4F7556}';\n\n/**\n * Checks is the given block of lines exists within an array of lines.\n * @param lines The array of lines to search.\n * @param block The block of lines to search for.\n * @return The starting index the block within lines, if it exists.\n */\nfunction linesContainsBlock(\n lines: string[],\n block: (string | RegExp)[],\n): number {\n if (block.length > 0) {\n const startIndex = lines.findIndex(s =>\n block[0] instanceof RegExp ? s.match(block[0]) : s === block[0],\n );\n\n if (startIndex >= 0) {\n for (let i = 1; i < block.length; i++) {\n if (\n block[i] instanceof RegExp\n ? !lines[startIndex + i].match(block[i])\n : lines[startIndex + i] !== block[i]\n ) {\n return -1;\n }\n }\n return startIndex;\n }\n }\n\n return -1;\n}\n\n/**\n * Insert the given block of lines into an array of lines.\n * @param lines The array of lines to insert into.\n * @param block The block of lines to insert.\n * @param index The index to perform the insert.\n */\nfunction insertBlockIntoLines(lines: string[], block: string[], index: number) {\n for (let i = 0; i < block.length; i++) {\n lines.splice(index + i, 0, block[i]);\n }\n}\n\n/**\n * Overwrite the lines at the given index with the block.\n * @param lines The destination array of lines to.\n * @param block The source block of lines.\n * @param index The index to perform the overwrite.\n */\nfunction overwriteLinesWithBlock(\n lines: string[],\n block: string[],\n index: number,\n) {\n for (let i = 0; i < block.length; i++) {\n lines[index + i] = block[i];\n }\n}\n\n/**\n * Search through an array of lines for a block of lines starting with startLine and ending with endLine.\n * @param lines The array of lines to search.\n * @param startLine The first line of the block.\n * @param endLine The last line of the block.\n * @param includeStartEnd Include the start and end lines in the result.\n * @return The found block of lines, if found.\n */\nfunction getBlockContentsFromLines(\n lines: string[],\n startLine: string,\n endLine: string,\n includeStartEnd: boolean = true,\n): string[] {\n const startIndex = lines.indexOf(startLine);\n const endIndex = lines.indexOf(endLine, startIndex);\n\n if (startIndex >= 0 && startIndex < endIndex) {\n if (includeStartEnd) {\n return lines.slice(startIndex, endIndex + 1);\n } else if (startIndex + 1 < endIndex) {\n return lines.slice(startIndex + 1, endIndex);\n }\n }\n\n return [];\n}\n\n/**\n * Adds the necessary info from a VS project into a VS solution file so that it will build.\n * @param slnFile The Absolute path to the target VS solution file.\n * @param project The object representing the project info.\n * @param verbose If true, enable verbose logging.\n * @param checkMode It true, don't make any changes.\n * @return Whether any changes were necessary.\n */\nexport function addProjectToSolution(\n slnFile: string,\n project: Project,\n verbose: boolean = false,\n checkMode: boolean = false,\n): boolean {\n if (project.projectLang === null) {\n throw new CodedError(\n 'AddProjectToSolution',\n 'Unable to add project to solution, projectLang is null',\n );\n }\n\n if (project.projectGuid === null) {\n throw new CodedError(\n 'AddProjectToSolution',\n 'Unable to add project to solution, projectGuid is null',\n );\n }\n\n if (verbose) {\n console.log(\n `Processing ${chalk.bold(path.basename(project.projectFile))}...`,\n );\n }\n\n const originalSlnContents = fs.readFileSync(slnFile).toString();\n\n const isCRLF = originalSlnContents.includes('\\r\\n');\n\n const slnLines = originalSlnContents.split(isCRLF ? '\\r\\n' : '\\n');\n\n let contentsChanged = false;\n\n // Check for the project entry block\n\n const slnDir = path.dirname(slnFile);\n const relProjectFile = path.relative(slnDir, project.projectFile);\n\n const projectTypeGuid =\n 'projectTypeGuid' in project\n ? project.projectTypeGuid!\n : projectTypeGuidsByLanguage[project.projectLang];\n\n const projectGuid = project.projectGuid.toUpperCase();\n\n const projectEntryBlock = [\n `Project(\"${projectTypeGuid}\") = \"${project.projectName}\", \"${relProjectFile}\", \"${projectGuid}\"`,\n 'EndProject',\n ];\n\n const projectEntryBlockRegex = [\n new RegExp(\n `Project\\\\(\"${projectTypeGuid}\"\\\\) = \"${project.projectName}\", \"(.*)\", \"${projectGuid}\"`,\n ),\n 'EndProject',\n ];\n\n const blockIndex = linesContainsBlock(slnLines, projectEntryBlockRegex);\n\n if (blockIndex < 0) {\n // Regex didn't match, insert\n if (verbose) {\n console.log(chalk.yellow('Missing project entry block, inserting.'));\n }\n\n const globalIndex = slnLines.indexOf('Global');\n insertBlockIntoLines(slnLines, projectEntryBlock, globalIndex);\n contentsChanged = true;\n } else if (linesContainsBlock(slnLines, projectEntryBlock) < 0) {\n // Regex matched but project path has changed, so correct it\n if (verbose) {\n console.log(\n chalk.yellow('Existing project entry block found, overwriting.'),\n );\n }\n\n overwriteLinesWithBlock(slnLines, projectEntryBlock, blockIndex);\n contentsChanged = true;\n }\n\n // Check for the project configuration platforms\n\n const slnConfigs = getBlockContentsFromLines(\n slnLines,\n '\\tGlobalSection(SolutionConfigurationPlatforms) = preSolution',\n '\\tEndGlobalSection',\n false,\n ).map(line => line.match(/\\s+([\\w\\s|]+)\\s=/)![1]);\n\n const projectConfigLines: string[] = [];\n\n slnConfigs.forEach(slnConfig => {\n if (!slnConfig.endsWith('|Any CPU')) {\n projectConfigLines.push(\n `\\t\\t${projectGuid}.${slnConfig}.ActiveCfg = ${\n project.projectLang === 'cpp'\n ? slnConfig.replace('x86', 'Win32')\n : slnConfig\n }`,\n );\n projectConfigLines.push(\n `\\t\\t${projectGuid}.${slnConfig}.Build.0 = ${\n project.projectLang === 'cpp'\n ? slnConfig.replace('x86', 'Win32')\n : slnConfig\n }`,\n );\n }\n });\n\n const projectConfigStartIndex = slnLines.indexOf(\n '\\tGlobalSection(ProjectConfigurationPlatforms) = postSolution',\n );\n\n projectConfigLines.forEach(projectConfigLine => {\n if (!slnLines.includes(projectConfigLine)) {\n if (verbose) {\n const configLine = projectConfigLine.substr(\n projectConfigLine.indexOf('= ') + 2,\n );\n console.log(chalk.yellow(`Missing ${configLine} config block.`));\n }\n\n const projectConfigEndIndex = slnLines.indexOf(\n '\\tEndGlobalSection',\n projectConfigStartIndex,\n );\n\n slnLines.splice(projectConfigEndIndex, 0, projectConfigLine);\n contentsChanged = true;\n }\n });\n\n // Write out new solution file if there were changes\n if (contentsChanged) {\n if (verbose) {\n console.log(\n chalk.yellow(\n `${chalk.bold(path.basename(slnFile))} needs to be updated.`,\n ),\n );\n }\n\n if (!checkMode) {\n if (verbose) {\n console.log(\n `Writing changes to ${chalk.bold(path.basename(slnFile))}...`,\n );\n }\n\n const slnContents = slnLines.join(isCRLF ? '\\r\\n' : '\\n');\n fs.writeFileSync(slnFile, slnContents, {\n encoding: 'utf8',\n flag: 'w',\n });\n }\n } else {\n if (verbose) {\n console.log(`No changes to ${chalk.bold(path.basename(slnFile))}.`);\n }\n }\n\n return contentsChanged;\n}\n"]}
@@ -1,24 +1,24 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- declare class DeviceInfo {
7
- readonly name: string;
8
- readonly guid: string;
9
- readonly ip: string;
10
- private index;
11
- private type;
12
- constructor(name: string, guid: string, ip: string, index: number, type: string);
13
- toString(): string;
14
- }
15
- export default class WinAppDeployTool {
16
- private path;
17
- constructor();
18
- get isAvailable(): boolean;
19
- findDevice(target: string): DeviceInfo;
20
- enumerateDevices(): DeviceInfo[];
21
- installAppPackage(pathToAppxPackage: string, targetDevice: DeviceInfo, shouldLaunch: boolean, shouldUpdate: boolean, pin: boolean, verbose?: boolean): Promise<void>;
22
- uninstallAppPackage(appName: string, targetDevice: DeviceInfo, verbose: boolean): Promise<void>;
23
- }
24
- export {};
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ declare class DeviceInfo {
7
+ readonly name: string;
8
+ readonly guid: string;
9
+ readonly ip: string;
10
+ private readonly index;
11
+ private readonly type;
12
+ constructor(name: string, guid: string, ip: string, index: number, type: string);
13
+ toString(): string;
14
+ }
15
+ export default class WinAppDeployTool {
16
+ private readonly path;
17
+ constructor();
18
+ get isAvailable(): boolean;
19
+ findDevice(target: string): DeviceInfo;
20
+ enumerateDevices(): DeviceInfo[];
21
+ installAppPackage(pathToAppxPackage: string, targetDevice: DeviceInfo, shouldLaunch: boolean, shouldUpdate: boolean, pin: boolean, verbose?: boolean): Promise<void>;
22
+ uninstallAppPackage(appName: string, targetDevice: DeviceInfo, verbose: boolean): Promise<void>;
23
+ }
24
+ export {};
@@ -1,106 +1,109 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- * @format
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const fs = require("fs");
9
- const path = require("path");
10
- const child_process_1 = require("child_process");
11
- const commandWithProgress_1 = require("./commandWithProgress");
12
- function sortDevices(l, r) {
13
- return l.toString().length - r.toString().length;
14
- }
15
- class DeviceInfo {
16
- constructor(name, guid, ip, index, type) {
17
- this.name = name;
18
- this.guid = guid;
19
- this.ip = ip;
20
- this.index = index;
21
- this.type = type;
22
- }
23
- toString() {
24
- return `${this.index}. ${this.name} (${this.type})`;
25
- }
26
- }
27
- class WinAppDeployTool {
28
- constructor() {
29
- const programFilesPath = process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;
30
- this.path = path.join(programFilesPath, 'Windows Kits', '10', 'bin', 'x86', 'WinAppDeployCmd.exe');
31
- }
32
- get isAvailable() {
33
- return fs.existsSync(this.path);
34
- }
35
- findDevice(target) {
36
- const devices = this.enumerateDevices();
37
- if (devices.length === 0) {
38
- throw new Error('No devices found');
39
- }
40
- if (target === 'emulator') {
41
- const sortedList = devices.sort(sortDevices);
42
- for (let i = 0; i < sortedList.length; i++) {
43
- const sortedItem = sortedList[i];
44
- if (sortedItem.toString().indexOf(target) > -1) {
45
- return sortedItem;
46
- }
47
- }
48
- }
49
- if (target === 'device') {
50
- return devices[0];
51
- }
52
- const candidateList = devices.filter(device => device.guid === target);
53
- if (candidateList.length > 0) {
54
- return candidateList[0];
55
- }
56
- else {
57
- throw new Error('No devices found');
58
- }
59
- }
60
- enumerateDevices() {
61
- // 127.0.0.1 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\r
62
- // maps to
63
- // [(line), '127.0.0.1', '00000015-b21e-0da9-0000-000000000000', 'Lumia 1520 (RM-940)']
64
- // The expansion is: IP address, spaces, GUID, spaces, text name
65
- const LINE_TEST = /^([\d\.]+?)\s+([\da-fA-F\-]+?)\s+(.+)$/m; // eslint-disable-line no-useless-escape
66
- const result = child_process_1.execSync(`"${this.path}" devices`).toString();
67
- const lines = result.split('\r\n');
68
- const matchedLines = lines.filter(line => LINE_TEST.test(line));
69
- const devices = matchedLines.map((line, arrayIndex) => {
70
- const match = line.match(LINE_TEST);
71
- if (!match) {
72
- throw new Error('Unexpected format of "devices" output');
73
- }
74
- const ip = match[1];
75
- const guid = match[2];
76
- const name = match[3];
77
- const type = 'device';
78
- const deviceInfo = new DeviceInfo(name, guid, ip, arrayIndex, type);
79
- return deviceInfo;
80
- });
81
- return devices;
82
- }
83
- async installAppPackage(pathToAppxPackage, targetDevice, shouldLaunch, shouldUpdate, pin, verbose = false) {
84
- const text = `Installing app to ${targetDevice.name}`;
85
- if (shouldLaunch) {
86
- commandWithProgress_1.newWarn('Cannot launch app with current version of Windows 10 SDK tools. You will have to launch the app after installation is completed.');
87
- }
88
- const args = [
89
- shouldUpdate ? 'update' : 'install',
90
- '-file',
91
- pathToAppxPackage,
92
- '-ip',
93
- targetDevice.ip,
94
- ];
95
- if (pin) {
96
- args.push('-pin', pin.toString());
97
- }
98
- await commandWithProgress_1.commandWithProgress(commandWithProgress_1.newSpinner(text), text, this.path, args, verbose);
99
- }
100
- async uninstallAppPackage(appName, targetDevice, verbose) {
101
- const text = `Uninstalling app from ${targetDevice.name}`;
102
- await commandWithProgress_1.commandWithProgress(commandWithProgress_1.newSpinner(text), text, this.path, `uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '), verbose);
103
- }
104
- }
105
- exports.default = WinAppDeployTool;
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
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const child_process_1 = require("child_process");
14
+ const commandWithProgress_1 = require("./commandWithProgress");
15
+ const telemetry_1 = require("@react-native-windows/telemetry");
16
+ function sortDevices(l, r) {
17
+ return l.toString().length - r.toString().length;
18
+ }
19
+ class DeviceInfo {
20
+ constructor(name, guid, ip, index, type) {
21
+ this.name = name;
22
+ this.guid = guid;
23
+ this.ip = ip;
24
+ this.index = index;
25
+ this.type = type;
26
+ }
27
+ toString() {
28
+ return `${this.index}. ${this.name} (${this.type})`;
29
+ }
30
+ }
31
+ class WinAppDeployTool {
32
+ constructor() {
33
+ const programFilesPath = process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;
34
+ this.path = path_1.default.join(programFilesPath, 'Windows Kits', '10', 'bin', 'x86', 'WinAppDeployCmd.exe');
35
+ }
36
+ get isAvailable() {
37
+ return fs_1.default.existsSync(this.path);
38
+ }
39
+ findDevice(target) {
40
+ const devices = this.enumerateDevices();
41
+ if (devices.length === 0) {
42
+ throw new telemetry_1.CodedError('NoDevice', 'No devices found');
43
+ }
44
+ if (target === 'emulator') {
45
+ const sortedList = devices.sort(sortDevices);
46
+ for (const sortedItem of sortedList) {
47
+ if (sortedItem.toString().includes(target)) {
48
+ return sortedItem;
49
+ }
50
+ }
51
+ }
52
+ if (target === 'device') {
53
+ return devices[0];
54
+ }
55
+ const candidateList = devices.filter(device => device.guid === target);
56
+ if (candidateList.length > 0) {
57
+ return candidateList[0];
58
+ }
59
+ else {
60
+ throw new telemetry_1.CodedError('NoDevice', 'No devices found');
61
+ }
62
+ }
63
+ enumerateDevices() {
64
+ // 127.0.0.1 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\r
65
+ // maps to
66
+ // [(line), '127.0.0.1', '00000015-b21e-0da9-0000-000000000000', 'Lumia 1520 (RM-940)']
67
+ // The expansion is: IP address, spaces, GUID, spaces, text name
68
+ const LINE_TEST = /^([\d\.]+?)\s+([\da-fA-F\-]+?)\s+(.+)$/m; // eslint-disable-line no-useless-escape
69
+ const result = (0, child_process_1.execSync)(`"${this.path}" devices`).toString();
70
+ const lines = result.split('\r\n');
71
+ const matchedLines = lines.filter(line => LINE_TEST.test(line));
72
+ const devices = matchedLines.map((line, arrayIndex) => {
73
+ const match = line.match(LINE_TEST);
74
+ if (!match) {
75
+ throw new telemetry_1.CodedError('InvalidDevicesOutput', 'Unexpected format of "devices" output');
76
+ }
77
+ const ip = match[1];
78
+ const guid = match[2];
79
+ const name = match[3];
80
+ const type = 'device';
81
+ const deviceInfo = new DeviceInfo(name, guid, ip, arrayIndex, type);
82
+ return deviceInfo;
83
+ });
84
+ return devices;
85
+ }
86
+ async installAppPackage(pathToAppxPackage, targetDevice, shouldLaunch, shouldUpdate, pin, verbose = false) {
87
+ const text = `Installing app to ${targetDevice.name}`;
88
+ if (shouldLaunch) {
89
+ (0, commandWithProgress_1.newWarn)('Cannot launch app with current version of Windows 10 SDK tools. You will have to launch the app after installation is completed.');
90
+ }
91
+ const args = [
92
+ shouldUpdate ? 'update' : 'install',
93
+ '-file',
94
+ pathToAppxPackage,
95
+ '-ip',
96
+ targetDevice.ip,
97
+ ];
98
+ if (pin) {
99
+ args.push('-pin', pin.toString());
100
+ }
101
+ await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, args, verbose, 'InstallAppToDeviceFailure');
102
+ }
103
+ async uninstallAppPackage(appName, targetDevice, verbose) {
104
+ const text = `Uninstalling app from ${targetDevice.name}`;
105
+ await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, `uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '), verbose, 'UninstallAppOnDeviceFailure');
106
+ }
107
+ }
108
+ exports.default = WinAppDeployTool;
106
109
  //# sourceMappingURL=winappdeploytool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"winappdeploytool.js","sourceRoot":"","sources":["../../src/utils/winappdeploytool.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,iDAAuC;AACvC,+DAA+E;AAC/E,+DAA2D;AAE3D,SAAS,WAAW,CAAC,CAAa,EAAE,CAAa;IAC/C,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC;AACnD,CAAC;AAED,MAAM,UAAU;IACd,YACkB,IAAY,EACZ,IAAY,EACZ,EAAU,EAET,KAAa,EACb,IAAY;QALb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QAET,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;IAC5B,CAA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AAqB,EACrB,YAAqB,EACrB,GAAY,EACZ,UAAmB,KAAK;QAExB,MAAM,IAAI,GAAG,qBAAqB,YAAY,CAAC,IAAI,EAAE,CAAC;QAEtD,IAAI,YAAY,EAAE;YAChB,IAAA,6BAAO,EACL,mIAAmI,CACpI,CAAC;SACH;QAED,MAAM,IAAI,GAAG;YACX,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACnC,OAAO;YACP,iBAAiB;YACjB,KAAK;YACL,YAAY,CAAC,EAAE;SAChB,CAAC;QAEF,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;SACnC;QACD,MAAM,IAAA,yCAAmB,EACvB,IAAA,gCAAU,EAAC,IAAI,CAAC,EAChB,IAAI,EACJ,IAAI,CAAC,IAAI,EACT,IAAI,EACJ,OAAO,EACP,2BAA2B,CAC5B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,OAAe,EACf,YAAwB,EACxB,OAAgB;QAEhB,MAAM,IAAI,GAAG,yBAAyB,YAAY,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,IAAA,yCAAmB,EACvB,IAAA,gCAAU,EAAC,IAAI,CAAC,EAChB,IAAI,EACJ,IAAI,CAAC,IAAI,EACT,sBAAsB,OAAO,yBAAyB,CAAC,KAAK,CAAC,GAAG,CAAC,EACjE,OAAO,EACP,6BAA6B,CAC9B,CAAC;IACJ,CAAC;CACF;AArID,mCAqIC","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';\nimport {execSync} from 'child_process';\nimport {newSpinner, commandWithProgress, newWarn} from './commandWithProgress';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nfunction sortDevices(l: DeviceInfo, r: DeviceInfo): number {\n return l.toString().length - r.toString().length;\n}\n\nclass DeviceInfo {\n constructor(\n public readonly name: string,\n public readonly guid: string,\n public readonly ip: string,\n\n private readonly index: number,\n private readonly type: string,\n ) {}\n\n toString() {\n return `${this.index}. ${this.name} (${this.type})`;\n }\n}\n\nexport default class WinAppDeployTool {\n private readonly path: string;\n\n constructor() {\n const programFilesPath =\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;\n this.path = path.join(\n programFilesPath!,\n 'Windows Kits',\n '10',\n 'bin',\n 'x86',\n 'WinAppDeployCmd.exe',\n );\n }\n\n get isAvailable() {\n return fs.existsSync(this.path);\n }\n\n findDevice(target: string): DeviceInfo {\n const devices = this.enumerateDevices();\n\n if (devices.length === 0) {\n throw new CodedError('NoDevice', 'No devices found');\n }\n\n if (target === 'emulator') {\n const sortedList = devices.sort(sortDevices);\n for (const sortedItem of sortedList) {\n if (sortedItem.toString().includes(target)) {\n return sortedItem;\n }\n }\n }\n\n if (target === 'device') {\n return devices[0];\n }\n\n const candidateList = devices.filter(device => device.guid === target);\n\n if (candidateList.length > 0) {\n return candidateList[0];\n } else {\n throw new CodedError('NoDevice', 'No devices found');\n }\n }\n\n enumerateDevices(): DeviceInfo[] {\n // 127.0.0.1 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\\r\n // maps to\n // [(line), '127.0.0.1', '00000015-b21e-0da9-0000-000000000000', 'Lumia 1520 (RM-940)']\n // The expansion is: IP address, spaces, GUID, spaces, text name\n const LINE_TEST = /^([\\d\\.]+?)\\s+([\\da-fA-F\\-]+?)\\s+(.+)$/m; // eslint-disable-line no-useless-escape\n\n const result = execSync(`\"${this.path}\" devices`).toString();\n const lines = result.split('\\r\\n');\n const matchedLines = lines.filter(line => LINE_TEST.test(line));\n\n const devices = matchedLines.map((line, arrayIndex) => {\n const match = line.match(LINE_TEST);\n if (!match) {\n throw new CodedError(\n 'InvalidDevicesOutput',\n 'Unexpected format of \"devices\" output',\n );\n }\n\n const ip = match[1];\n const guid = match[2];\n const name = match[3];\n const type = 'device';\n\n const deviceInfo = new DeviceInfo(name, guid, ip, arrayIndex, type);\n return deviceInfo;\n });\n\n return devices;\n }\n\n async installAppPackage(\n pathToAppxPackage: string,\n targetDevice: DeviceInfo,\n shouldLaunch: boolean,\n shouldUpdate: boolean,\n pin: boolean,\n verbose: boolean = false,\n ) {\n const text = `Installing app to ${targetDevice.name}`;\n\n if (shouldLaunch) {\n newWarn(\n 'Cannot launch app with current version of Windows 10 SDK tools. You will have to launch the app after installation is completed.',\n );\n }\n\n const args = [\n shouldUpdate ? 'update' : 'install',\n '-file',\n pathToAppxPackage,\n '-ip',\n targetDevice.ip,\n ];\n\n if (pin) {\n args.push('-pin', pin.toString());\n }\n await commandWithProgress(\n newSpinner(text),\n text,\n this.path,\n args,\n verbose,\n 'InstallAppToDeviceFailure',\n );\n }\n\n async uninstallAppPackage(\n appName: string,\n targetDevice: DeviceInfo,\n verbose: boolean,\n ) {\n const text = `Uninstalling app from ${targetDevice.name}`;\n await commandWithProgress(\n newSpinner(text),\n text,\n this.path,\n `uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '),\n verbose,\n 'UninstallAppOnDeviceFailure',\n );\n }\n}\n"]}
package/package.json CHANGED
@@ -1,72 +1,90 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.0.0-canary.26",
3
+ "version": "0.0.0-canary.261",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git@github.com:microsoft/react-native-windows.git",
8
+ "url": "https://github.com/microsoft/react-native-windows",
9
9
  "directory": "packages/@react-native-windows/cli"
10
10
  },
11
11
  "scripts": {
12
- "build": "just-scripts build",
13
- "clean": "just-scripts clean",
14
- "lint": "just-scripts lint",
15
- "lint:fix": "just-scripts lint:fix",
16
- "test": "just-scripts test",
17
- "watch": "just-scripts watch"
12
+ "build": "rnw-scripts build",
13
+ "clean": "rnw-scripts clean",
14
+ "lint": "rnw-scripts lint",
15
+ "lint:fix": "rnw-scripts lint:fix",
16
+ "test": "rnw-scripts test",
17
+ "watch": "rnw-scripts watch"
18
18
  },
19
19
  "dependencies": {
20
+ "@react-native-windows/codegen": "0.0.0-canary.120",
21
+ "@react-native-windows/fs": "^0.0.0-canary.62",
22
+ "@react-native-windows/package-utils": "^0.0.0-canary.88",
23
+ "@react-native-windows/telemetry": "^0.0.0-canary.117",
24
+ "@xmldom/xmldom": "^0.7.7",
20
25
  "chalk": "^4.1.0",
21
26
  "cli-spinners": "^2.2.0",
22
27
  "envinfo": "^7.5.0",
28
+ "find-up": "^4.1.0",
23
29
  "glob": "^7.1.1",
24
- "inquirer": "^3.0.6",
30
+ "lodash": "^4.17.15",
25
31
  "mustache": "^4.0.1",
26
- "nuget-exe": "4.9.2",
27
32
  "ora": "^3.4.0",
33
+ "prompts": "^2.4.1",
28
34
  "semver": "^7.3.2",
29
35
  "shelljs": "^0.8.4",
30
36
  "username": "^5.1.0",
31
- "uuid": "^3.3.2",
37
+ "xml-formatter": "^2.4.0",
32
38
  "xml-parser": "^1.2.1",
33
- "xmldom": "^0.3.0",
34
39
  "xpath": "^0.0.27"
35
40
  },
36
41
  "devDependencies": {
37
- "@react-native-community/cli-types": "^4.10.1",
38
- "@rnw-scripts/eslint-config": "0.1.4",
39
- "@rnw-scripts/jest-unittest-config": "0.1.1",
40
- "@rnw-scripts/just-task": "0.0.6",
41
- "@rnw-scripts/ts-config": "0.1.0",
42
+ "@react-native-community/cli-doctor": "15.0.0-alpha.2",
43
+ "@react-native-community/cli-types": "15.0.0-alpha.2",
44
+ "@rnw-scripts/eslint-config": "1.2.33",
45
+ "@rnw-scripts/jest-unittest-config": "1.5.11",
46
+ "@rnw-scripts/just-task": "2.3.50",
47
+ "@rnw-scripts/ts-config": "2.0.5",
42
48
  "@types/chalk": "^2.2.0",
43
- "@types/inquirer": "^6.5.0",
44
- "@types/jest": "^26.0.13",
45
- "@types/mustache": "^4.0.1",
49
+ "@types/jest": "^29.2.2",
50
+ "@types/lodash": "^4.14.168",
51
+ "@types/mustache": "^4.1.1",
52
+ "@types/node": "^18.0.0",
46
53
  "@types/ora": "^3.2.0",
54
+ "@types/prompts": "2.0.10",
47
55
  "@types/semver": "^7.3.3",
48
56
  "@types/shelljs": "^0.8.8",
49
- "@types/uuid": "^8.0.0",
50
57
  "@types/xml-parser": "^1.2.29",
51
- "@types/xmldom": "^0.1.29",
52
- "babel-jest": "^26.3.0",
53
- "eslint": "6.8.0",
54
- "jest": "^26.4.2",
55
- "just-scripts": "^0.44.7",
56
- "prettier": "1.19.1",
57
- "typescript": "^3.8.3"
58
+ "@types/xmldom": "^0.1.30",
59
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
60
+ "@typescript-eslint/parser": "^7.1.1",
61
+ "babel-jest": "^29.6.3",
62
+ "eslint": "^8.19.0",
63
+ "jest": "^29.7.0",
64
+ "prettier": "2.8.8",
65
+ "typescript": "5.0.4"
66
+ },
67
+ "peerDependencies": {
68
+ "react-native": "*"
58
69
  },
59
70
  "files": [
60
71
  "lib-commonjs",
61
- "powershell"
72
+ "src/powershell"
62
73
  ],
63
74
  "beachball": {
64
75
  "defaultNpmTag": "canary",
65
76
  "disallowedChangeTypes": [
66
77
  "major",
67
78
  "minor",
68
- "patch"
79
+ "patch",
80
+ "premajor",
81
+ "preminor",
82
+ "prepatch"
69
83
  ]
70
84
  },
71
- "promoteRelease": true
85
+ "promoteRelease": true,
86
+ "windowsOnly": true,
87
+ "engines": {
88
+ "node": ">= 18"
89
+ }
72
90
  }