@react-native-windows/cli 0.73.2 → 0.74.0-preview.2
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/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -87
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +654 -654
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -14
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +32 -32
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -27
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +205 -205
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -12
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +22 -22
- package/lib-commonjs/commands/config/configUtils.d.ts +123 -123
- package/lib-commonjs/commands/config/configUtils.js +380 -380
- package/lib-commonjs/commands/config/dependencyConfig.d.ts +37 -37
- package/lib-commonjs/commands/config/dependencyConfig.js +227 -227
- package/lib-commonjs/commands/config/projectConfig.d.ts +27 -27
- package/lib-commonjs/commands/config/projectConfig.js +180 -180
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -6
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +20 -20
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -1
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -7
- package/lib-commonjs/commands/healthCheck/healthChecks.js +123 -123
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -46
- package/lib-commonjs/commands/initWindows/initWindows.js +243 -243
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -15
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +37 -37
- package/lib-commonjs/commands/runWindows/runWindows.d.ts +10 -10
- package/lib-commonjs/commands/runWindows/runWindows.js +321 -321
- package/lib-commonjs/commands/runWindows/runWindowsOptions.d.ts +56 -56
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js +132 -132
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
- package/lib-commonjs/e2etest/autolink.test.js +366 -366
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -129
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -6
- package/lib-commonjs/e2etest/healthChecks.test.js +30 -30
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/initWindows.test.js +42 -42
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/projectConfig.test.js +110 -110
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -8
- package/lib-commonjs/e2etest/projectConfig.utils.js +76 -76
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/runWindows.test.js +60 -60
- package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
- package/lib-commonjs/generator-common/index.d.ts +39 -39
- package/lib-commonjs/generator-common/index.js +242 -242
- package/lib-commonjs/generator-windows/index.d.ts +10 -10
- package/lib-commonjs/generator-windows/index.js +316 -316
- package/lib-commonjs/index.d.ts +50 -50
- package/lib-commonjs/index.js +77 -77
- package/lib-commonjs/utils/build.d.ts +12 -12
- package/lib-commonjs/utils/build.js +84 -84
- package/lib-commonjs/utils/checkRequirements.d.ts +6 -6
- package/lib-commonjs/utils/checkRequirements.js +69 -69
- package/lib-commonjs/utils/commandWithProgress.d.ts +21 -21
- package/lib-commonjs/utils/commandWithProgress.js +149 -149
- package/lib-commonjs/utils/deploy.d.ts +12 -12
- package/lib-commonjs/utils/deploy.js +353 -353
- package/lib-commonjs/utils/info.d.ts +6 -6
- package/lib-commonjs/utils/info.js +28 -28
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -28
- package/lib-commonjs/utils/msbuildtools.js +273 -273
- package/lib-commonjs/utils/msbuildtools.js.map +1 -1
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -9
- package/lib-commonjs/utils/pathHelpers.js +36 -36
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -29
- package/lib-commonjs/utils/telemetryHelpers.js +120 -120
- package/lib-commonjs/utils/version.d.ts +19 -19
- package/lib-commonjs/utils/version.js +109 -109
- package/lib-commonjs/utils/vsInstalls.d.ts +34 -34
- package/lib-commonjs/utils/vsInstalls.js +99 -99
- package/lib-commonjs/utils/vstools.d.ts +16 -16
- package/lib-commonjs/utils/vstools.js +189 -189
- package/lib-commonjs/utils/winappdeploytool.d.ts +24 -24
- package/lib-commonjs/utils/winappdeploytool.js +108 -108
- package/package.json +16 -16
|
@@ -1,317 +1,317 @@
|
|
|
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.installScriptsAndDependencies = exports.copyProjectTemplateAndReplace = void 0;
|
|
12
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const username_1 = __importDefault(require("username"));
|
|
15
|
-
const uuid_1 = __importDefault(require("uuid"));
|
|
16
|
-
const child_process_1 = __importDefault(require("child_process"));
|
|
17
|
-
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
18
|
-
const semver_1 = __importDefault(require("semver"));
|
|
19
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
20
|
-
const find_up_1 = __importDefault(require("find-up"));
|
|
21
|
-
const configUtils_1 = require("../commands/config/configUtils");
|
|
22
|
-
const generator_common_1 = require("../generator-common");
|
|
23
|
-
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
24
|
-
const package_utils_1 = require("@react-native-windows/package-utils");
|
|
25
|
-
const windowsDir = 'windows';
|
|
26
|
-
const bundleDir = 'Bundle';
|
|
27
|
-
function pascalCase(str) {
|
|
28
|
-
const camelCase = lodash_1.default.camelCase(str);
|
|
29
|
-
return camelCase[0].toUpperCase() + camelCase.substr(1);
|
|
30
|
-
}
|
|
31
|
-
function resolveRnwPath(subpath) {
|
|
32
|
-
return require.resolve(path_1.default.join('react-native-windows', subpath), {
|
|
33
|
-
paths: [process.cwd()],
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
// Existing high cyclomatic complexity
|
|
37
|
-
// eslint-disable-next-line complexity
|
|
38
|
-
async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectName, namespace, options) {
|
|
39
|
-
if (!srcRootPath) {
|
|
40
|
-
throw new telemetry_1.CodedError('CopyProjectTemplateNoSourcePath', 'Need a path to copy from');
|
|
41
|
-
}
|
|
42
|
-
if (!destPath) {
|
|
43
|
-
throw new telemetry_1.CodedError('CopyProjectTemplateNoDestPath', 'Need a path to copy to');
|
|
44
|
-
}
|
|
45
|
-
if (!newProjectName) {
|
|
46
|
-
throw new telemetry_1.CodedError('CopyProjectTemplateNoProjectName', 'Need a project name');
|
|
47
|
-
}
|
|
48
|
-
const projectType = options.projectType;
|
|
49
|
-
const language = options.language;
|
|
50
|
-
// React-native init only allows alphanumerics in project names, but other
|
|
51
|
-
// new project tools (like create-react-native-module) are less strict.
|
|
52
|
-
if (projectType === 'lib') {
|
|
53
|
-
newProjectName = pascalCase(newProjectName);
|
|
54
|
-
}
|
|
55
|
-
// Similar to the above, but we want to retain namespace separators
|
|
56
|
-
if (projectType === 'lib') {
|
|
57
|
-
namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');
|
|
58
|
-
}
|
|
59
|
-
// Checking if we're overwriting an existing project and re-uses their projectGUID
|
|
60
|
-
const existingProjectPath = path_1.default.join(destPath, windowsDir, newProjectName, newProjectName + (language === 'cs' ? '.csproj' : '.vcxproj'));
|
|
61
|
-
let existingProjectGuid;
|
|
62
|
-
if (fs_1.default.existsSync(existingProjectPath)) {
|
|
63
|
-
console.log('Found existing project, extracting ProjectGuid.');
|
|
64
|
-
existingProjectGuid = (0, configUtils_1.findPropertyValue)((0, configUtils_1.readProjectFile)(existingProjectPath), 'ProjectGuid', existingProjectPath).replace(/[{}]/g, '');
|
|
65
|
-
}
|
|
66
|
-
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir));
|
|
67
|
-
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName));
|
|
68
|
-
if (projectType === 'app') {
|
|
69
|
-
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, bundleDir));
|
|
70
|
-
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));
|
|
71
|
-
}
|
|
72
|
-
const namespaceCpp = toCppNamespace(namespace);
|
|
73
|
-
if (options.experimentalNuGetDependency) {
|
|
74
|
-
console.log('Using experimental NuGet dependency.');
|
|
75
|
-
}
|
|
76
|
-
const experimentalPropsPath = path_1.default.join(destPath, windowsDir, 'ExperimentalFeatures.props');
|
|
77
|
-
let existingUseHermes = null;
|
|
78
|
-
if (fs_1.default.existsSync(experimentalPropsPath)) {
|
|
79
|
-
existingUseHermes = (0, configUtils_1.tryFindPropertyValueAsBoolean)((0, configUtils_1.readProjectFile)(experimentalPropsPath), 'UseHermes');
|
|
80
|
-
}
|
|
81
|
-
if (existingUseHermes === false) {
|
|
82
|
-
console.warn('Hermes is now the default JS engine and will be enabled for this project. Support for Chakra will be deprecated in the future. To disable Hermes and keep using Chakra for now, see https://microsoft.github.io/react-native-windows/docs/hermes#disabling-hermes.');
|
|
83
|
-
}
|
|
84
|
-
options.useHermes = true;
|
|
85
|
-
if (options.useWinUI3) {
|
|
86
|
-
throw new telemetry_1.CodedError('IncompatibleOptions', 'Experimental WinUI 3 project has been deprecated.');
|
|
87
|
-
}
|
|
88
|
-
const projDir = 'proj';
|
|
89
|
-
const srcPath = path_1.default.join(srcRootPath, `${language}-${projectType}`);
|
|
90
|
-
const sharedPath = path_1.default.join(srcRootPath, `shared-${projectType}`);
|
|
91
|
-
const projectGuid = existingProjectGuid || uuid_1.default.v4();
|
|
92
|
-
const rnwVersion = require(resolveRnwPath('package.json')).version;
|
|
93
|
-
const nugetVersion = options.nuGetTestVersion || rnwVersion;
|
|
94
|
-
const packageGuid = uuid_1.default.v4();
|
|
95
|
-
const currentUser = username_1.default.sync(); // Gets the current username depending on the platform.
|
|
96
|
-
let mainComponentName = newProjectName;
|
|
97
|
-
const appJsonPath = await (0, find_up_1.default)('app.json', { cwd: destPath });
|
|
98
|
-
if (appJsonPath) {
|
|
99
|
-
const appJson = await fs_1.default.readJsonFile(appJsonPath);
|
|
100
|
-
mainComponentName = appJson.name;
|
|
101
|
-
}
|
|
102
|
-
// We should prefer putting new, necessary PackageReference dependencies into the appropriate
|
|
103
|
-
// external property sheets, but this is here if we "must" inject the dependency into the project file
|
|
104
|
-
const csNugetPackages = [];
|
|
105
|
-
const cppNugetPackages = [];
|
|
106
|
-
const templateVars = {
|
|
107
|
-
useMustache: true,
|
|
108
|
-
regExpPatternsToRemove: [],
|
|
109
|
-
name: newProjectName,
|
|
110
|
-
namespace: namespace,
|
|
111
|
-
namespaceCpp: namespaceCpp,
|
|
112
|
-
languageIsCpp: language === 'cpp',
|
|
113
|
-
rnwVersion: await (0, telemetry_1.getVersionOfNpmPackage)('react-native-windows'),
|
|
114
|
-
mainComponentName: mainComponentName,
|
|
115
|
-
// Visual Studio is very picky about the casing of the guids for projects, project references and the solution
|
|
116
|
-
// https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531
|
|
117
|
-
// we therefore have to precariously use the right casing in the right place or risk building in VS breaking.
|
|
118
|
-
projectGuidLower: `{${projectGuid.toLowerCase()}}`,
|
|
119
|
-
projectGuidUpper: `{${projectGuid.toUpperCase()}}`,
|
|
120
|
-
// packaging and signing variables:
|
|
121
|
-
packageGuid: packageGuid,
|
|
122
|
-
currentUser: currentUser,
|
|
123
|
-
useExperimentalNuget: options.experimentalNuGetDependency,
|
|
124
|
-
nuGetTestFeed: options.nuGetTestFeed,
|
|
125
|
-
nuGetADOFeed: nugetVersion.startsWith('0.0.0-'),
|
|
126
|
-
// cpp template variables
|
|
127
|
-
useWinUI3: options.useWinUI3,
|
|
128
|
-
useHermes: options.useHermes,
|
|
129
|
-
cppNugetPackages: cppNugetPackages,
|
|
130
|
-
// cs template variables
|
|
131
|
-
csNugetPackages: csNugetPackages,
|
|
132
|
-
// autolinking template variables
|
|
133
|
-
autolinkPropertiesForProps: '',
|
|
134
|
-
autolinkProjectReferencesForTargets: '',
|
|
135
|
-
autolinkCsUsingNamespaces: '',
|
|
136
|
-
autolinkCsReactPackageProviders: '',
|
|
137
|
-
autolinkCppIncludes: '',
|
|
138
|
-
autolinkCppPackageProviders: '\n UNREFERENCED_PARAMETER(packageProviders);', // CODESYNC: vnext\local-cli\runWindows\utils\autolink.js
|
|
139
|
-
};
|
|
140
|
-
const commonMappings = projectType === 'app'
|
|
141
|
-
? [
|
|
142
|
-
// app common mappings
|
|
143
|
-
{
|
|
144
|
-
from: path_1.default.join(srcRootPath, options.useDevMode
|
|
145
|
-
? 'metro.devMode.config.js'
|
|
146
|
-
: 'metro.config.js'),
|
|
147
|
-
to: 'metro.config.js',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
from: path_1.default.join(srcRootPath, '_gitignore'),
|
|
151
|
-
to: path_1.default.join(windowsDir, '.gitignore'),
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
from: path_1.default.join(srcRootPath, 'b_gitignore'),
|
|
155
|
-
to: path_1.default.join(windowsDir, newProjectName, '.gitignore'),
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
from: path_1.default.join(srcRootPath, 'index.windows.bundle'),
|
|
159
|
-
to: path_1.default.join(windowsDir, newProjectName, bundleDir, 'index.windows.bundle'),
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
from: path_1.default.join(srcPath, projDir, 'MyApp.sln'),
|
|
163
|
-
to: path_1.default.join(windowsDir, newProjectName + '.sln'),
|
|
164
|
-
},
|
|
165
|
-
]
|
|
166
|
-
: [
|
|
167
|
-
// lib common mappings
|
|
168
|
-
{
|
|
169
|
-
from: path_1.default.join(srcRootPath, '_gitignore'),
|
|
170
|
-
to: path_1.default.join(windowsDir, '.gitignore'),
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
from: path_1.default.join(srcPath, projDir, 'MyLib.sln'),
|
|
174
|
-
to: path_1.default.join(windowsDir, newProjectName + '.sln'),
|
|
175
|
-
},
|
|
176
|
-
];
|
|
177
|
-
for (const mapping of commonMappings) {
|
|
178
|
-
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
179
|
-
}
|
|
180
|
-
if (language === 'cs') {
|
|
181
|
-
const csMappings = projectType === 'app'
|
|
182
|
-
? [
|
|
183
|
-
// cs app mappings
|
|
184
|
-
{
|
|
185
|
-
from: path_1.default.join(srcPath, projDir, 'MyApp.csproj'),
|
|
186
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.csproj'),
|
|
187
|
-
},
|
|
188
|
-
]
|
|
189
|
-
: [
|
|
190
|
-
// cs lib mappings
|
|
191
|
-
{
|
|
192
|
-
from: path_1.default.join(srcPath, projDir, 'MyLib.csproj'),
|
|
193
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.csproj'),
|
|
194
|
-
},
|
|
195
|
-
];
|
|
196
|
-
for (const mapping of csMappings) {
|
|
197
|
-
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
const cppMappings = projectType === 'app'
|
|
202
|
-
? [
|
|
203
|
-
// cpp app mappings
|
|
204
|
-
{
|
|
205
|
-
from: path_1.default.join(srcPath, projDir, 'MyApp.vcxproj'),
|
|
206
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj'),
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
from: path_1.default.join(srcPath, projDir, 'MyApp.vcxproj.filters'),
|
|
210
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj.filters'),
|
|
211
|
-
},
|
|
212
|
-
]
|
|
213
|
-
: [
|
|
214
|
-
// cpp lib mappings
|
|
215
|
-
{
|
|
216
|
-
from: path_1.default.join(srcPath, projDir, 'MyLib.vcxproj'),
|
|
217
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj'),
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
from: path_1.default.join(srcPath, projDir, 'MyLib.vcxproj.filters'),
|
|
221
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj.filters'),
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
from: path_1.default.join(srcPath, projDir, 'MyLib.def'),
|
|
225
|
-
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.def'),
|
|
226
|
-
},
|
|
227
|
-
];
|
|
228
|
-
for (const mapping of cppMappings) {
|
|
229
|
-
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// shared proj
|
|
233
|
-
if (fs_1.default.existsSync(path_1.default.join(sharedPath, projDir))) {
|
|
234
|
-
const sharedProjMappings = [];
|
|
235
|
-
sharedProjMappings.push({
|
|
236
|
-
from: path_1.default.join(sharedPath, projDir, 'NuGet_Config'),
|
|
237
|
-
to: path_1.default.join(windowsDir, 'NuGet.Config'),
|
|
238
|
-
});
|
|
239
|
-
if (fs_1.default.existsSync(path_1.default.join(sharedPath, projDir, 'ExperimentalFeatures.props'))) {
|
|
240
|
-
sharedProjMappings.push({
|
|
241
|
-
from: path_1.default.join(sharedPath, projDir, 'ExperimentalFeatures.props'),
|
|
242
|
-
to: path_1.default.join(windowsDir, 'ExperimentalFeatures.props'),
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
for (const mapping of sharedProjMappings) {
|
|
246
|
-
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// shared assets
|
|
250
|
-
if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'assets'))) {
|
|
251
|
-
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'assets'), destPath, path_1.default.join(windowsDir, newProjectName, 'Assets'), templateVars, options.overwrite);
|
|
252
|
-
}
|
|
253
|
-
// shared src
|
|
254
|
-
if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'src'))) {
|
|
255
|
-
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
|
|
256
|
-
}
|
|
257
|
-
// src
|
|
258
|
-
if (fs_1.default.existsSync(path_1.default.join(srcPath, 'src'))) {
|
|
259
|
-
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(srcPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
|
|
260
|
-
}
|
|
261
|
-
if (projectType === 'app') {
|
|
262
|
-
console.log(chalk_1.default.white.bold('To run your app on UWP:'));
|
|
263
|
-
console.log(chalk_1.default.white(' npx react-native run-windows'));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
exports.copyProjectTemplateAndReplace = copyProjectTemplateAndReplace;
|
|
267
|
-
function toCppNamespace(namespace) {
|
|
268
|
-
return namespace.replace(/\./g, '::');
|
|
269
|
-
}
|
|
270
|
-
async function installScriptsAndDependencies(options) {
|
|
271
|
-
var _a;
|
|
272
|
-
const projectPackage = await package_utils_1.WritableNpmPackage.fromPath(process.cwd());
|
|
273
|
-
if (!projectPackage) {
|
|
274
|
-
throw new Error(`The current directory '${process.cwd()}' is not the root of an npm package`);
|
|
275
|
-
}
|
|
276
|
-
await projectPackage.mergeProps({
|
|
277
|
-
scripts: { windows: 'react-native run-windows' },
|
|
278
|
-
});
|
|
279
|
-
const rnwPackage = await (0, package_utils_1.findPackage)('react-native-windows');
|
|
280
|
-
if (!rnwPackage) {
|
|
281
|
-
throw new Error('Could not locate the package for react-native-windows');
|
|
282
|
-
}
|
|
283
|
-
const rnPackage = await (0, package_utils_1.findPackage)('react-native');
|
|
284
|
-
if (!rnPackage) {
|
|
285
|
-
throw new Error('Could not locate the package for react-native');
|
|
286
|
-
}
|
|
287
|
-
// We add an exclusionList from metro config. This will be hoisted, but add
|
|
288
|
-
// an explicit dep because we require it directly.
|
|
289
|
-
const cliPackage = await (0, package_utils_1.findPackage)('@react-native-community/cli', {
|
|
290
|
-
searchPath: rnPackage.path,
|
|
291
|
-
});
|
|
292
|
-
const metroConfigPackage = await (0, package_utils_1.findPackage)('metro-config', {
|
|
293
|
-
searchPath: (cliPackage === null || cliPackage === void 0 ? void 0 : cliPackage.path) || rnPackage.path,
|
|
294
|
-
});
|
|
295
|
-
if (metroConfigPackage) {
|
|
296
|
-
await projectPackage.mergeProps({
|
|
297
|
-
devDependencies: {
|
|
298
|
-
'metro-config': `^${metroConfigPackage.json.version}`,
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
const rnPeerDependency = rnwPackage.json.peerDependencies['react-native'];
|
|
303
|
-
if (!semver_1.default.satisfies(rnPackage.json.version, rnPeerDependency) &&
|
|
304
|
-
((_a = projectPackage.json.dependencies) === null || _a === void 0 ? void 0 : _a['react-native'])) {
|
|
305
|
-
console.log(chalk_1.default.green('Installing a compatible version of react-native:'));
|
|
306
|
-
console.log(chalk_1.default.white(` ${rnPeerDependency}`));
|
|
307
|
-
// Patch package.json to have proper react-native version and install
|
|
308
|
-
await projectPackage.mergeProps({
|
|
309
|
-
dependencies: { 'react-native': rnPeerDependency },
|
|
310
|
-
});
|
|
311
|
-
// Install dependencies using correct package manager
|
|
312
|
-
const isYarn = fs_1.default.existsSync(path_1.default.join(process.cwd(), 'yarn.lock'));
|
|
313
|
-
child_process_1.default.execSync(isYarn ? 'yarn' : 'npm i', options.verbose ? { stdio: 'inherit' } : {});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
exports.installScriptsAndDependencies = installScriptsAndDependencies;
|
|
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.installScriptsAndDependencies = exports.copyProjectTemplateAndReplace = void 0;
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const username_1 = __importDefault(require("username"));
|
|
15
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
16
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
17
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
18
|
+
const semver_1 = __importDefault(require("semver"));
|
|
19
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
20
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
21
|
+
const configUtils_1 = require("../commands/config/configUtils");
|
|
22
|
+
const generator_common_1 = require("../generator-common");
|
|
23
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
24
|
+
const package_utils_1 = require("@react-native-windows/package-utils");
|
|
25
|
+
const windowsDir = 'windows';
|
|
26
|
+
const bundleDir = 'Bundle';
|
|
27
|
+
function pascalCase(str) {
|
|
28
|
+
const camelCase = lodash_1.default.camelCase(str);
|
|
29
|
+
return camelCase[0].toUpperCase() + camelCase.substr(1);
|
|
30
|
+
}
|
|
31
|
+
function resolveRnwPath(subpath) {
|
|
32
|
+
return require.resolve(path_1.default.join('react-native-windows', subpath), {
|
|
33
|
+
paths: [process.cwd()],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Existing high cyclomatic complexity
|
|
37
|
+
// eslint-disable-next-line complexity
|
|
38
|
+
async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectName, namespace, options) {
|
|
39
|
+
if (!srcRootPath) {
|
|
40
|
+
throw new telemetry_1.CodedError('CopyProjectTemplateNoSourcePath', 'Need a path to copy from');
|
|
41
|
+
}
|
|
42
|
+
if (!destPath) {
|
|
43
|
+
throw new telemetry_1.CodedError('CopyProjectTemplateNoDestPath', 'Need a path to copy to');
|
|
44
|
+
}
|
|
45
|
+
if (!newProjectName) {
|
|
46
|
+
throw new telemetry_1.CodedError('CopyProjectTemplateNoProjectName', 'Need a project name');
|
|
47
|
+
}
|
|
48
|
+
const projectType = options.projectType;
|
|
49
|
+
const language = options.language;
|
|
50
|
+
// React-native init only allows alphanumerics in project names, but other
|
|
51
|
+
// new project tools (like create-react-native-module) are less strict.
|
|
52
|
+
if (projectType === 'lib') {
|
|
53
|
+
newProjectName = pascalCase(newProjectName);
|
|
54
|
+
}
|
|
55
|
+
// Similar to the above, but we want to retain namespace separators
|
|
56
|
+
if (projectType === 'lib') {
|
|
57
|
+
namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');
|
|
58
|
+
}
|
|
59
|
+
// Checking if we're overwriting an existing project and re-uses their projectGUID
|
|
60
|
+
const existingProjectPath = path_1.default.join(destPath, windowsDir, newProjectName, newProjectName + (language === 'cs' ? '.csproj' : '.vcxproj'));
|
|
61
|
+
let existingProjectGuid;
|
|
62
|
+
if (fs_1.default.existsSync(existingProjectPath)) {
|
|
63
|
+
console.log('Found existing project, extracting ProjectGuid.');
|
|
64
|
+
existingProjectGuid = (0, configUtils_1.findPropertyValue)((0, configUtils_1.readProjectFile)(existingProjectPath), 'ProjectGuid', existingProjectPath).replace(/[{}]/g, '');
|
|
65
|
+
}
|
|
66
|
+
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir));
|
|
67
|
+
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName));
|
|
68
|
+
if (projectType === 'app') {
|
|
69
|
+
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, bundleDir));
|
|
70
|
+
(0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));
|
|
71
|
+
}
|
|
72
|
+
const namespaceCpp = toCppNamespace(namespace);
|
|
73
|
+
if (options.experimentalNuGetDependency) {
|
|
74
|
+
console.log('Using experimental NuGet dependency.');
|
|
75
|
+
}
|
|
76
|
+
const experimentalPropsPath = path_1.default.join(destPath, windowsDir, 'ExperimentalFeatures.props');
|
|
77
|
+
let existingUseHermes = null;
|
|
78
|
+
if (fs_1.default.existsSync(experimentalPropsPath)) {
|
|
79
|
+
existingUseHermes = (0, configUtils_1.tryFindPropertyValueAsBoolean)((0, configUtils_1.readProjectFile)(experimentalPropsPath), 'UseHermes');
|
|
80
|
+
}
|
|
81
|
+
if (existingUseHermes === false) {
|
|
82
|
+
console.warn('Hermes is now the default JS engine and will be enabled for this project. Support for Chakra will be deprecated in the future. To disable Hermes and keep using Chakra for now, see https://microsoft.github.io/react-native-windows/docs/hermes#disabling-hermes.');
|
|
83
|
+
}
|
|
84
|
+
options.useHermes = true;
|
|
85
|
+
if (options.useWinUI3) {
|
|
86
|
+
throw new telemetry_1.CodedError('IncompatibleOptions', 'Experimental WinUI 3 project has been deprecated.');
|
|
87
|
+
}
|
|
88
|
+
const projDir = 'proj';
|
|
89
|
+
const srcPath = path_1.default.join(srcRootPath, `${language}-${projectType}`);
|
|
90
|
+
const sharedPath = path_1.default.join(srcRootPath, `shared-${projectType}`);
|
|
91
|
+
const projectGuid = existingProjectGuid || uuid_1.default.v4();
|
|
92
|
+
const rnwVersion = require(resolveRnwPath('package.json')).version;
|
|
93
|
+
const nugetVersion = options.nuGetTestVersion || rnwVersion;
|
|
94
|
+
const packageGuid = uuid_1.default.v4();
|
|
95
|
+
const currentUser = username_1.default.sync(); // Gets the current username depending on the platform.
|
|
96
|
+
let mainComponentName = newProjectName;
|
|
97
|
+
const appJsonPath = await (0, find_up_1.default)('app.json', { cwd: destPath });
|
|
98
|
+
if (appJsonPath) {
|
|
99
|
+
const appJson = await fs_1.default.readJsonFile(appJsonPath);
|
|
100
|
+
mainComponentName = appJson.name;
|
|
101
|
+
}
|
|
102
|
+
// We should prefer putting new, necessary PackageReference dependencies into the appropriate
|
|
103
|
+
// external property sheets, but this is here if we "must" inject the dependency into the project file
|
|
104
|
+
const csNugetPackages = [];
|
|
105
|
+
const cppNugetPackages = [];
|
|
106
|
+
const templateVars = {
|
|
107
|
+
useMustache: true,
|
|
108
|
+
regExpPatternsToRemove: [],
|
|
109
|
+
name: newProjectName,
|
|
110
|
+
namespace: namespace,
|
|
111
|
+
namespaceCpp: namespaceCpp,
|
|
112
|
+
languageIsCpp: language === 'cpp',
|
|
113
|
+
rnwVersion: await (0, telemetry_1.getVersionOfNpmPackage)('react-native-windows'),
|
|
114
|
+
mainComponentName: mainComponentName,
|
|
115
|
+
// Visual Studio is very picky about the casing of the guids for projects, project references and the solution
|
|
116
|
+
// https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531
|
|
117
|
+
// we therefore have to precariously use the right casing in the right place or risk building in VS breaking.
|
|
118
|
+
projectGuidLower: `{${projectGuid.toLowerCase()}}`,
|
|
119
|
+
projectGuidUpper: `{${projectGuid.toUpperCase()}}`,
|
|
120
|
+
// packaging and signing variables:
|
|
121
|
+
packageGuid: packageGuid,
|
|
122
|
+
currentUser: currentUser,
|
|
123
|
+
useExperimentalNuget: options.experimentalNuGetDependency,
|
|
124
|
+
nuGetTestFeed: options.nuGetTestFeed,
|
|
125
|
+
nuGetADOFeed: nugetVersion.startsWith('0.0.0-'),
|
|
126
|
+
// cpp template variables
|
|
127
|
+
useWinUI3: options.useWinUI3,
|
|
128
|
+
useHermes: options.useHermes,
|
|
129
|
+
cppNugetPackages: cppNugetPackages,
|
|
130
|
+
// cs template variables
|
|
131
|
+
csNugetPackages: csNugetPackages,
|
|
132
|
+
// autolinking template variables
|
|
133
|
+
autolinkPropertiesForProps: '',
|
|
134
|
+
autolinkProjectReferencesForTargets: '',
|
|
135
|
+
autolinkCsUsingNamespaces: '',
|
|
136
|
+
autolinkCsReactPackageProviders: '',
|
|
137
|
+
autolinkCppIncludes: '',
|
|
138
|
+
autolinkCppPackageProviders: '\n UNREFERENCED_PARAMETER(packageProviders);', // CODESYNC: vnext\local-cli\runWindows\utils\autolink.js
|
|
139
|
+
};
|
|
140
|
+
const commonMappings = projectType === 'app'
|
|
141
|
+
? [
|
|
142
|
+
// app common mappings
|
|
143
|
+
{
|
|
144
|
+
from: path_1.default.join(srcRootPath, options.useDevMode
|
|
145
|
+
? 'metro.devMode.config.js'
|
|
146
|
+
: 'metro.config.js'),
|
|
147
|
+
to: 'metro.config.js',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
from: path_1.default.join(srcRootPath, '_gitignore'),
|
|
151
|
+
to: path_1.default.join(windowsDir, '.gitignore'),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
from: path_1.default.join(srcRootPath, 'b_gitignore'),
|
|
155
|
+
to: path_1.default.join(windowsDir, newProjectName, '.gitignore'),
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
from: path_1.default.join(srcRootPath, 'index.windows.bundle'),
|
|
159
|
+
to: path_1.default.join(windowsDir, newProjectName, bundleDir, 'index.windows.bundle'),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
from: path_1.default.join(srcPath, projDir, 'MyApp.sln'),
|
|
163
|
+
to: path_1.default.join(windowsDir, newProjectName + '.sln'),
|
|
164
|
+
},
|
|
165
|
+
]
|
|
166
|
+
: [
|
|
167
|
+
// lib common mappings
|
|
168
|
+
{
|
|
169
|
+
from: path_1.default.join(srcRootPath, '_gitignore'),
|
|
170
|
+
to: path_1.default.join(windowsDir, '.gitignore'),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
from: path_1.default.join(srcPath, projDir, 'MyLib.sln'),
|
|
174
|
+
to: path_1.default.join(windowsDir, newProjectName + '.sln'),
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
for (const mapping of commonMappings) {
|
|
178
|
+
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
179
|
+
}
|
|
180
|
+
if (language === 'cs') {
|
|
181
|
+
const csMappings = projectType === 'app'
|
|
182
|
+
? [
|
|
183
|
+
// cs app mappings
|
|
184
|
+
{
|
|
185
|
+
from: path_1.default.join(srcPath, projDir, 'MyApp.csproj'),
|
|
186
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.csproj'),
|
|
187
|
+
},
|
|
188
|
+
]
|
|
189
|
+
: [
|
|
190
|
+
// cs lib mappings
|
|
191
|
+
{
|
|
192
|
+
from: path_1.default.join(srcPath, projDir, 'MyLib.csproj'),
|
|
193
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.csproj'),
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
for (const mapping of csMappings) {
|
|
197
|
+
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const cppMappings = projectType === 'app'
|
|
202
|
+
? [
|
|
203
|
+
// cpp app mappings
|
|
204
|
+
{
|
|
205
|
+
from: path_1.default.join(srcPath, projDir, 'MyApp.vcxproj'),
|
|
206
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj'),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
from: path_1.default.join(srcPath, projDir, 'MyApp.vcxproj.filters'),
|
|
210
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj.filters'),
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
: [
|
|
214
|
+
// cpp lib mappings
|
|
215
|
+
{
|
|
216
|
+
from: path_1.default.join(srcPath, projDir, 'MyLib.vcxproj'),
|
|
217
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj'),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
from: path_1.default.join(srcPath, projDir, 'MyLib.vcxproj.filters'),
|
|
221
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj.filters'),
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
from: path_1.default.join(srcPath, projDir, 'MyLib.def'),
|
|
225
|
+
to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.def'),
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
for (const mapping of cppMappings) {
|
|
229
|
+
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// shared proj
|
|
233
|
+
if (fs_1.default.existsSync(path_1.default.join(sharedPath, projDir))) {
|
|
234
|
+
const sharedProjMappings = [];
|
|
235
|
+
sharedProjMappings.push({
|
|
236
|
+
from: path_1.default.join(sharedPath, projDir, 'NuGet_Config'),
|
|
237
|
+
to: path_1.default.join(windowsDir, 'NuGet.Config'),
|
|
238
|
+
});
|
|
239
|
+
if (fs_1.default.existsSync(path_1.default.join(sharedPath, projDir, 'ExperimentalFeatures.props'))) {
|
|
240
|
+
sharedProjMappings.push({
|
|
241
|
+
from: path_1.default.join(sharedPath, projDir, 'ExperimentalFeatures.props'),
|
|
242
|
+
to: path_1.default.join(windowsDir, 'ExperimentalFeatures.props'),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
for (const mapping of sharedProjMappings) {
|
|
246
|
+
await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// shared assets
|
|
250
|
+
if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'assets'))) {
|
|
251
|
+
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'assets'), destPath, path_1.default.join(windowsDir, newProjectName, 'Assets'), templateVars, options.overwrite);
|
|
252
|
+
}
|
|
253
|
+
// shared src
|
|
254
|
+
if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'src'))) {
|
|
255
|
+
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
|
|
256
|
+
}
|
|
257
|
+
// src
|
|
258
|
+
if (fs_1.default.existsSync(path_1.default.join(srcPath, 'src'))) {
|
|
259
|
+
await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(srcPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
|
|
260
|
+
}
|
|
261
|
+
if (projectType === 'app') {
|
|
262
|
+
console.log(chalk_1.default.white.bold('To run your app on UWP:'));
|
|
263
|
+
console.log(chalk_1.default.white(' npx react-native run-windows'));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.copyProjectTemplateAndReplace = copyProjectTemplateAndReplace;
|
|
267
|
+
function toCppNamespace(namespace) {
|
|
268
|
+
return namespace.replace(/\./g, '::');
|
|
269
|
+
}
|
|
270
|
+
async function installScriptsAndDependencies(options) {
|
|
271
|
+
var _a;
|
|
272
|
+
const projectPackage = await package_utils_1.WritableNpmPackage.fromPath(process.cwd());
|
|
273
|
+
if (!projectPackage) {
|
|
274
|
+
throw new Error(`The current directory '${process.cwd()}' is not the root of an npm package`);
|
|
275
|
+
}
|
|
276
|
+
await projectPackage.mergeProps({
|
|
277
|
+
scripts: { windows: 'react-native run-windows' },
|
|
278
|
+
});
|
|
279
|
+
const rnwPackage = await (0, package_utils_1.findPackage)('react-native-windows');
|
|
280
|
+
if (!rnwPackage) {
|
|
281
|
+
throw new Error('Could not locate the package for react-native-windows');
|
|
282
|
+
}
|
|
283
|
+
const rnPackage = await (0, package_utils_1.findPackage)('react-native');
|
|
284
|
+
if (!rnPackage) {
|
|
285
|
+
throw new Error('Could not locate the package for react-native');
|
|
286
|
+
}
|
|
287
|
+
// We add an exclusionList from metro config. This will be hoisted, but add
|
|
288
|
+
// an explicit dep because we require it directly.
|
|
289
|
+
const cliPackage = await (0, package_utils_1.findPackage)('@react-native-community/cli', {
|
|
290
|
+
searchPath: rnPackage.path,
|
|
291
|
+
});
|
|
292
|
+
const metroConfigPackage = await (0, package_utils_1.findPackage)('metro-config', {
|
|
293
|
+
searchPath: (cliPackage === null || cliPackage === void 0 ? void 0 : cliPackage.path) || rnPackage.path,
|
|
294
|
+
});
|
|
295
|
+
if (metroConfigPackage) {
|
|
296
|
+
await projectPackage.mergeProps({
|
|
297
|
+
devDependencies: {
|
|
298
|
+
'metro-config': `^${metroConfigPackage.json.version}`,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const rnPeerDependency = rnwPackage.json.peerDependencies['react-native'];
|
|
303
|
+
if (!semver_1.default.satisfies(rnPackage.json.version, rnPeerDependency) &&
|
|
304
|
+
((_a = projectPackage.json.dependencies) === null || _a === void 0 ? void 0 : _a['react-native'])) {
|
|
305
|
+
console.log(chalk_1.default.green('Installing a compatible version of react-native:'));
|
|
306
|
+
console.log(chalk_1.default.white(` ${rnPeerDependency}`));
|
|
307
|
+
// Patch package.json to have proper react-native version and install
|
|
308
|
+
await projectPackage.mergeProps({
|
|
309
|
+
dependencies: { 'react-native': rnPeerDependency },
|
|
310
|
+
});
|
|
311
|
+
// Install dependencies using correct package manager
|
|
312
|
+
const isYarn = fs_1.default.existsSync(path_1.default.join(process.cwd(), 'yarn.lock'));
|
|
313
|
+
child_process_1.default.execSync(isYarn ? 'yarn' : 'npm i', options.verbose ? { stdio: 'inherit' } : {});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.installScriptsAndDependencies = installScriptsAndDependencies;
|
|
317
317
|
//# sourceMappingURL=index.js.map
|