yeet
This commit is contained in:
88
node_modules/@react-native-community/cli/build/commands/bundle/assetPathUtils.js
generated
vendored
Normal file
88
node_modules/@react-native-community/cli/build/commands/bundle/assetPathUtils.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
|
||||
* floating point numbers imprecision.
|
||||
*/
|
||||
function getAndroidAssetSuffix(scale) {
|
||||
switch (scale) {
|
||||
case 0.75:
|
||||
return 'ldpi';
|
||||
|
||||
case 1:
|
||||
return 'mdpi';
|
||||
|
||||
case 1.5:
|
||||
return 'hdpi';
|
||||
|
||||
case 2:
|
||||
return 'xhdpi';
|
||||
|
||||
case 3:
|
||||
return 'xxhdpi';
|
||||
|
||||
case 4:
|
||||
return 'xxxhdpi';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
} // See https://developer.android.com/guide/topics/resources/drawable-resource.html
|
||||
|
||||
|
||||
const drawableFileTypes = new Set(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);
|
||||
|
||||
function getAndroidResourceFolderName(asset, scale) {
|
||||
if (!drawableFileTypes.has(asset.type)) {
|
||||
return 'raw';
|
||||
}
|
||||
|
||||
const suffix = getAndroidAssetSuffix(scale);
|
||||
|
||||
if (!suffix) {
|
||||
throw new Error(`Don't know which android drawable suffix to use for asset: ${JSON.stringify(asset)}`);
|
||||
}
|
||||
|
||||
const androidFolder = `drawable-${suffix}`;
|
||||
return androidFolder;
|
||||
}
|
||||
|
||||
function getAndroidResourceIdentifier(asset) {
|
||||
const folderPath = getBasePath(asset);
|
||||
return `${folderPath}/${asset.name}`.toLowerCase().replace(/\//g, '_') // Encode folder structure in file name
|
||||
.replace(/([^a-z0-9_])/g, '') // Remove illegal chars
|
||||
.replace(/^assets_/, ''); // Remove "assets_" prefix
|
||||
}
|
||||
|
||||
function getBasePath(asset) {
|
||||
let basePath = asset.httpServerLocation;
|
||||
|
||||
if (basePath[0] === '/') {
|
||||
basePath = basePath.substr(1);
|
||||
}
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
var _default = {
|
||||
getAndroidAssetSuffix,
|
||||
getAndroidResourceFolderName,
|
||||
getAndroidResourceIdentifier,
|
||||
getBasePath
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=assetPathUtils.js.map
|
124
node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js
generated
vendored
Normal file
124
node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _Server() {
|
||||
const data = _interopRequireDefault(require("metro/src/Server"));
|
||||
|
||||
_Server = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _bundle() {
|
||||
const data = _interopRequireDefault(require("metro/src/shared/output/bundle"));
|
||||
|
||||
_bundle = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _saveAssets = _interopRequireDefault(require("./saveAssets"));
|
||||
|
||||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// @ts-ignore - no typed definition for the package
|
||||
// @ts-ignore - no typed definition for the package
|
||||
async function buildBundle(args, ctx, output = _bundle().default) {
|
||||
const config = await (0, _loadMetroConfig.default)(ctx, {
|
||||
maxWorkers: args.maxWorkers,
|
||||
resetCache: args.resetCache,
|
||||
config: args.config
|
||||
});
|
||||
|
||||
if (config.resolver.platforms.indexOf(args.platform) === -1) {
|
||||
_cliTools().logger.error(`Invalid platform ${args.platform ? `"${_chalk().default.bold(args.platform)}" ` : ''}selected.`);
|
||||
|
||||
_cliTools().logger.info(`Available platforms are: ${config.resolver.platforms.map(x => `"${_chalk().default.bold(x)}"`).join(', ')}. If you are trying to bundle for an out-of-tree platform, it may not be installed.`);
|
||||
|
||||
throw new Error('Bundling failed');
|
||||
} // This is used by a bazillion of npm modules we don't control so we don't
|
||||
// have other choice than defining it as an env variable here.
|
||||
|
||||
|
||||
process.env.NODE_ENV = args.dev ? 'development' : 'production';
|
||||
let sourceMapUrl = args.sourcemapOutput;
|
||||
|
||||
if (sourceMapUrl && !args.sourcemapUseAbsolutePath) {
|
||||
sourceMapUrl = _path().default.basename(sourceMapUrl);
|
||||
}
|
||||
|
||||
const requestOpts = {
|
||||
entryFile: args.entryFile,
|
||||
sourceMapUrl,
|
||||
dev: args.dev,
|
||||
minify: args.minify !== undefined ? args.minify : !args.dev,
|
||||
platform: args.platform
|
||||
};
|
||||
const server = new (_Server().default)(config);
|
||||
|
||||
try {
|
||||
const bundle = await output.build(server, requestOpts);
|
||||
await output.save(bundle, args, _cliTools().logger.info); // Save the assets of the bundle
|
||||
|
||||
const outputAssets = await server.getAssets({ ..._Server().default.DEFAULT_BUNDLE_OPTIONS,
|
||||
...requestOpts,
|
||||
bundleType: 'todo'
|
||||
}); // When we're done saving bundle output and the assets, we're done.
|
||||
|
||||
return await (0, _saveAssets.default)(outputAssets, args.platform, args.assetsDest);
|
||||
} finally {
|
||||
server.end();
|
||||
}
|
||||
}
|
||||
|
||||
var _default = buildBundle;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=buildBundle.js.map
|
42
node_modules/@react-native-community/cli/build/commands/bundle/bundle.js
generated
vendored
Normal file
42
node_modules/@react-native-community/cli/build/commands/bundle/bundle.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.withOutput = exports.default = void 0;
|
||||
|
||||
var _buildBundle = _interopRequireDefault(require("./buildBundle"));
|
||||
|
||||
var _bundleCommandLineArgs = _interopRequireDefault(require("./bundleCommandLineArgs"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||
*/
|
||||
function bundleWithOutput(_, config, args, output) // untyped metro/src/shared/output/bundle or metro/src/shared/output/RamBundle
|
||||
{
|
||||
return (0, _buildBundle.default)(args, config, output);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'bundle',
|
||||
description: 'builds the javascript bundle for offline use',
|
||||
func: bundleWithOutput,
|
||||
options: _bundleCommandLineArgs.default,
|
||||
// Used by `ramBundle.js`
|
||||
withOutput: bundleWithOutput
|
||||
};
|
||||
exports.default = _default;
|
||||
const withOutput = bundleWithOutput;
|
||||
exports.withOutput = withOutput;
|
||||
|
||||
//# sourceMappingURL=bundle.js.map
|
85
node_modules/@react-native-community/cli/build/commands/bundle/bundleCommandLineArgs.js
generated
vendored
Normal file
85
node_modules/@react-native-community/cli/build/commands/bundle/bundleCommandLineArgs.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
var _default = [{
|
||||
name: '--entry-file <path>',
|
||||
description: 'Path to the root JS file, either absolute or relative to JS root'
|
||||
}, {
|
||||
name: '--platform [string]',
|
||||
description: 'Either "ios" or "android"',
|
||||
default: 'ios'
|
||||
}, {
|
||||
name: '--transformer [string]',
|
||||
description: 'Specify a custom transformer to be used'
|
||||
}, {
|
||||
name: '--dev [boolean]',
|
||||
description: 'If false, warnings are disabled and the bundle is minified',
|
||||
parse: val => val !== 'false',
|
||||
default: true
|
||||
}, {
|
||||
name: '--minify [boolean]',
|
||||
description: 'Allows overriding whether bundle is minified. This defaults to ' + 'false if dev is true, and true if dev is false. Disabling minification ' + 'can be useful for speeding up production builds for testing purposes.',
|
||||
parse: val => val !== 'false'
|
||||
}, {
|
||||
name: '--bundle-output <string>',
|
||||
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle'
|
||||
}, {
|
||||
name: '--bundle-encoding [string]',
|
||||
description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).',
|
||||
default: 'utf8'
|
||||
}, {
|
||||
name: '--max-workers [number]',
|
||||
description: 'Specifies the maximum number of workers the worker-pool ' + 'will spawn for transforming files. This defaults to the number of the ' + 'cores available on your machine.',
|
||||
parse: workers => Number(workers)
|
||||
}, {
|
||||
name: '--sourcemap-output [string]',
|
||||
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map'
|
||||
}, {
|
||||
name: '--sourcemap-sources-root [string]',
|
||||
description: "Path to make sourcemap's sources entries relative to, ex. /root/dir"
|
||||
}, {
|
||||
name: '--sourcemap-use-absolute-path',
|
||||
description: 'Report SourceMapURL using its full path',
|
||||
default: false
|
||||
}, {
|
||||
name: '--assets-dest [string]',
|
||||
description: 'Directory name where to store assets referenced in the bundle'
|
||||
}, {
|
||||
name: '--reset-cache',
|
||||
description: 'Removes cached files',
|
||||
default: false
|
||||
}, {
|
||||
name: '--read-global-cache',
|
||||
description: 'Try to fetch transformed JS code from the global cache, if configured.',
|
||||
default: false
|
||||
}, {
|
||||
name: '--config [string]',
|
||||
description: 'Path to the CLI configuration file',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}];
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=bundleCommandLineArgs.js.map
|
53
node_modules/@react-native-community/cli/build/commands/bundle/filterPlatformAssetScales.js
generated
vendored
Normal file
53
node_modules/@react-native-community/cli/build/commands/bundle/filterPlatformAssetScales.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
const ALLOWED_SCALES = {
|
||||
ios: [1, 2, 3]
|
||||
};
|
||||
|
||||
function filterPlatformAssetScales(platform, scales) {
|
||||
const whitelist = ALLOWED_SCALES[platform];
|
||||
|
||||
if (!whitelist) {
|
||||
return scales;
|
||||
}
|
||||
|
||||
const result = scales.filter(scale => whitelist.indexOf(scale) > -1);
|
||||
|
||||
if (result.length === 0 && scales.length > 0) {
|
||||
// No matching scale found, but there are some available. Ideally we don't
|
||||
// want to be in this situation and should throw, but for now as a fallback
|
||||
// let's just use the closest larger image
|
||||
const maxScale = whitelist[whitelist.length - 1];
|
||||
|
||||
for (const scale of scales) {
|
||||
if (scale > maxScale) {
|
||||
result.push(scale);
|
||||
break;
|
||||
}
|
||||
} // There is no larger scales available, use the largest we have
|
||||
|
||||
|
||||
if (result.length === 0) {
|
||||
result.push(scales[scales.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var _default = filterPlatformAssetScales;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=filterPlatformAssetScales.js.map
|
40
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathAndroid.js
generated
vendored
Normal file
40
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathAndroid.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _assetPathUtils = _interopRequireDefault(require("./assetPathUtils"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getAssetDestPathAndroid(asset, scale) {
|
||||
const androidFolder = _assetPathUtils.default.getAndroidResourceFolderName(asset, scale);
|
||||
|
||||
const fileName = _assetPathUtils.default.getAndroidResourceIdentifier(asset);
|
||||
|
||||
return _path().default.join(androidFolder, `${fileName}.${asset.type}`);
|
||||
}
|
||||
|
||||
var _default = getAssetDestPathAndroid;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=getAssetDestPathAndroid.js.map
|
39
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathIOS.js
generated
vendored
Normal file
39
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathIOS.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getAssetDestPathIOS(asset, scale) {
|
||||
const suffix = scale === 1 ? '' : `@${scale}x`;
|
||||
const fileName = `${asset.name + suffix}.${asset.type}`;
|
||||
return _path().default.join( // Assets can have relative paths outside of the project root.
|
||||
// Replace `../` with `_` to make sure they don't end up outside of
|
||||
// the expected assets directory.
|
||||
asset.httpServerLocation.substr(1).replace(/\.\.\//g, '_'), fileName);
|
||||
}
|
||||
|
||||
var _default = getAssetDestPathIOS;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=getAssetDestPathIOS.js.map
|
52
node_modules/@react-native-community/cli/build/commands/bundle/ramBundle.js
generated
vendored
Normal file
52
node_modules/@react-native-community/cli/build/commands/bundle/ramBundle.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _RamBundle() {
|
||||
const data = _interopRequireDefault(require("metro/src/shared/output/RamBundle"));
|
||||
|
||||
_RamBundle = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _bundle = require("./bundle");
|
||||
|
||||
var _bundleCommandLineArgs = _interopRequireDefault(require("./bundleCommandLineArgs"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// @ts-ignore - no typed definition for the package
|
||||
|
||||
/**
|
||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||
*/
|
||||
function ramBundle(argv, config, args) {
|
||||
return (0, _bundle.withOutput)(argv, config, args, _RamBundle().default);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'ram-bundle',
|
||||
description: 'builds javascript as a "Random Access Module" bundle for offline use',
|
||||
func: ramBundle,
|
||||
options: _bundleCommandLineArgs.default.concat({
|
||||
name: '--indexed-ram-bundle',
|
||||
description: 'Force the "Indexed RAM" bundle file format, even when building for android',
|
||||
default: false
|
||||
})
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=ramBundle.js.map
|
138
node_modules/@react-native-community/cli/build/commands/bundle/saveAssets.js
generated
vendored
Normal file
138
node_modules/@react-native-community/cli/build/commands/bundle/saveAssets.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _mkdirp() {
|
||||
const data = _interopRequireDefault(require("mkdirp"));
|
||||
|
||||
_mkdirp = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _filterPlatformAssetScales = _interopRequireDefault(require("./filterPlatformAssetScales"));
|
||||
|
||||
var _getAssetDestPathAndroid = _interopRequireDefault(require("./getAssetDestPathAndroid"));
|
||||
|
||||
var _getAssetDestPathIOS = _interopRequireDefault(require("./getAssetDestPathIOS"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function saveAssets(assets, platform, assetsDest) {
|
||||
if (!assetsDest) {
|
||||
_cliTools().logger.warn('Assets destination folder is not set, skipping...');
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const getAssetDestPath = platform === 'android' ? _getAssetDestPathAndroid.default : _getAssetDestPathIOS.default;
|
||||
const filesToCopy = Object.create(null); // Map src -> dest
|
||||
|
||||
assets.forEach(asset => {
|
||||
const validScales = new Set((0, _filterPlatformAssetScales.default)(platform, asset.scales));
|
||||
asset.scales.forEach((scale, idx) => {
|
||||
if (!validScales.has(scale)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const src = asset.files[idx];
|
||||
|
||||
const dest = _path().default.join(assetsDest, getAssetDestPath(asset, scale));
|
||||
|
||||
filesToCopy[src] = dest;
|
||||
});
|
||||
});
|
||||
return copyAll(filesToCopy);
|
||||
}
|
||||
|
||||
function copyAll(filesToCopy) {
|
||||
const queue = Object.keys(filesToCopy);
|
||||
|
||||
if (queue.length === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Copying ${queue.length} asset files`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const copyNext = error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue.length === 0) {
|
||||
_cliTools().logger.info('Done copying assets');
|
||||
|
||||
resolve();
|
||||
} else {
|
||||
// queue.length === 0 is checked in previous branch, so this is string
|
||||
const src = queue.shift();
|
||||
const dest = filesToCopy[src];
|
||||
copy(src, dest, copyNext);
|
||||
}
|
||||
};
|
||||
|
||||
copyNext();
|
||||
});
|
||||
}
|
||||
|
||||
function copy(src, dest, callback) {
|
||||
const destDir = _path().default.dirname(dest);
|
||||
|
||||
(0, _mkdirp().default)(destDir, err => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
_fs().default.createReadStream(src).pipe(_fs().default.createWriteStream(dest)).on('finish', callback);
|
||||
});
|
||||
}
|
||||
|
||||
var _default = saveAssets;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=saveAssets.js.map
|
32
node_modules/@react-native-community/cli/build/commands/config/config.js
generated
vendored
Normal file
32
node_modules/@react-native-community/cli/build/commands/config/config.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function isValidRNDependency(config) {
|
||||
return Object.keys(config.platforms).filter(key => Boolean(config.platforms[key])).length !== 0 || config.hooks && Object.keys(config.hooks).length !== 0 || config.assets && config.assets.length !== 0 || config.params && config.params.length !== 0;
|
||||
}
|
||||
|
||||
function filterConfig(config) {
|
||||
const filtered = { ...config
|
||||
};
|
||||
Object.keys(filtered.dependencies).forEach(item => {
|
||||
if (!isValidRNDependency(filtered.dependencies[item])) {
|
||||
delete filtered.dependencies[item];
|
||||
}
|
||||
});
|
||||
return filtered;
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'config',
|
||||
description: 'Print CLI configuration',
|
||||
func: async (_argv, ctx) => {
|
||||
console.log(JSON.stringify(filterConfig(ctx), null, 2));
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=config.js.map
|
60
node_modules/@react-native-community/cli/build/commands/doctor/checkInstallation.js
generated
vendored
Normal file
60
node_modules/@react-native-community/cli/build/commands/doctor/checkInstallation.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.doesSoftwareNeedToBeFixed = exports.isSoftwareNotInstalled = exports.PACKAGE_MANAGERS = void 0;
|
||||
|
||||
function _semver() {
|
||||
const data = _interopRequireDefault(require("semver"));
|
||||
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _commandExists() {
|
||||
const data = _interopRequireDefault(require("command-exists"));
|
||||
|
||||
_commandExists = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
let PACKAGE_MANAGERS;
|
||||
exports.PACKAGE_MANAGERS = PACKAGE_MANAGERS;
|
||||
|
||||
(function (PACKAGE_MANAGERS) {
|
||||
PACKAGE_MANAGERS["YARN"] = "YARN";
|
||||
PACKAGE_MANAGERS["NPM"] = "NPM";
|
||||
})(PACKAGE_MANAGERS || (exports.PACKAGE_MANAGERS = PACKAGE_MANAGERS = {}));
|
||||
|
||||
const isSoftwareNotInstalled = async command => {
|
||||
try {
|
||||
await (0, _commandExists().default)(command);
|
||||
return false;
|
||||
} catch (_ignored) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
exports.isSoftwareNotInstalled = isSoftwareNotInstalled;
|
||||
|
||||
const doesSoftwareNeedToBeFixed = ({
|
||||
version,
|
||||
versionRange
|
||||
}) => {
|
||||
const coercedVersion = _semver().default.coerce(version);
|
||||
|
||||
return version === 'Not Found' || coercedVersion === null || !_semver().default.satisfies(coercedVersion, versionRange);
|
||||
};
|
||||
|
||||
exports.doesSoftwareNeedToBeFixed = doesSoftwareNeedToBeFixed;
|
||||
|
||||
//# sourceMappingURL=checkInstallation.js.map
|
257
node_modules/@react-native-community/cli/build/commands/doctor/doctor.js
generated
vendored
Normal file
257
node_modules/@react-native-community/cli/build/commands/doctor/doctor.js
generated
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _healthchecks = require("./healthchecks");
|
||||
|
||||
var _loader = require("../../tools/loader");
|
||||
|
||||
var _printFixOptions = _interopRequireWildcard(require("./printFixOptions"));
|
||||
|
||||
var _runAutomaticFix = _interopRequireWildcard(require("./runAutomaticFix"));
|
||||
|
||||
var _envinfo = _interopRequireDefault(require("../../tools/envinfo"));
|
||||
|
||||
var _common = require("./healthchecks/common");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const printCategory = ({
|
||||
label,
|
||||
key
|
||||
}) => {
|
||||
if (key > 0) {
|
||||
_cliTools().logger.log();
|
||||
}
|
||||
|
||||
_cliTools().logger.log(_chalk().default.dim(label));
|
||||
};
|
||||
|
||||
const printVersions = ({
|
||||
version,
|
||||
versions,
|
||||
versionRange
|
||||
}) => {
|
||||
if (versions) {
|
||||
const versionsToShow = Array.isArray(versions) ? versions.join(', ') : 'N/A';
|
||||
(0, _common.logMessage)(`- Versions found: ${_chalk().default.red(versionsToShow)}`);
|
||||
(0, _common.logMessage)(`- Version supported: ${_chalk().default.green(versionRange)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const versionsToShow = version && version !== 'Not Found' ? version : 'N/A';
|
||||
(0, _common.logMessage)(`- Version found: ${_chalk().default.red(versionsToShow)}`);
|
||||
(0, _common.logMessage)(`- Version supported: ${_chalk().default.green(versionRange)}`);
|
||||
return;
|
||||
};
|
||||
|
||||
const printIssue = ({
|
||||
label,
|
||||
needsToBeFixed,
|
||||
version,
|
||||
versions,
|
||||
versionRange,
|
||||
isRequired,
|
||||
description
|
||||
}) => {
|
||||
const symbol = needsToBeFixed ? isRequired ? _chalk().default.red('✖') : _chalk().default.yellow('●') : _chalk().default.green('✓');
|
||||
const descriptionToShow = description ? ` - ${description}` : '';
|
||||
|
||||
_cliTools().logger.log(` ${symbol} ${label}${descriptionToShow}`);
|
||||
|
||||
if (needsToBeFixed && versionRange) {
|
||||
return printVersions({
|
||||
version,
|
||||
versions,
|
||||
versionRange
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const printOverallStats = ({
|
||||
errors,
|
||||
warnings
|
||||
}) => {
|
||||
_cliTools().logger.log(`\n${_chalk().default.bold('Errors:')} ${errors}`);
|
||||
|
||||
_cliTools().logger.log(`${_chalk().default.bold('Warnings:')} ${warnings}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a `healthcheck` and a `platform`, returns the specific fix for
|
||||
* it or the fallback one if there is not one (`runAutomaticFix`).
|
||||
*/
|
||||
const getAutomaticFixForPlatform = (healthcheck, platform) => {
|
||||
switch (platform) {
|
||||
case 'win32':
|
||||
return healthcheck.win32AutomaticFix || healthcheck.runAutomaticFix;
|
||||
|
||||
case 'darwin':
|
||||
return healthcheck.darwinAutomaticFix || healthcheck.runAutomaticFix;
|
||||
|
||||
case 'linux':
|
||||
return healthcheck.linuxAutomaticFix || healthcheck.runAutomaticFix;
|
||||
|
||||
default:
|
||||
return healthcheck.runAutomaticFix;
|
||||
}
|
||||
};
|
||||
|
||||
var _default = async (_, options) => {
|
||||
const Loader = (0, _loader.getLoader)();
|
||||
const loader = new Loader();
|
||||
loader.start('Running diagnostics...');
|
||||
const environmentInfo = await (0, _envinfo.default)();
|
||||
|
||||
const iterateOverHealthChecks = async ({
|
||||
label,
|
||||
healthchecks
|
||||
}) => ({
|
||||
label,
|
||||
healthchecks: (await Promise.all(healthchecks.map(async healthcheck => {
|
||||
if (healthcheck.visible === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
needsToBeFixed,
|
||||
version,
|
||||
versions,
|
||||
versionRange
|
||||
} = await healthcheck.getDiagnostics(environmentInfo); // Assume that it's required unless specified otherwise
|
||||
|
||||
const isRequired = healthcheck.isRequired !== false;
|
||||
const isWarning = needsToBeFixed && !isRequired;
|
||||
return {
|
||||
label: healthcheck.label,
|
||||
needsToBeFixed: Boolean(needsToBeFixed),
|
||||
version,
|
||||
versions,
|
||||
versionRange,
|
||||
description: healthcheck.description,
|
||||
runAutomaticFix: getAutomaticFixForPlatform(healthcheck, process.platform),
|
||||
isRequired,
|
||||
type: needsToBeFixed ? isWarning ? _healthchecks.HEALTHCHECK_TYPES.WARNING : _healthchecks.HEALTHCHECK_TYPES.ERROR : undefined
|
||||
};
|
||||
}))).filter(healthcheck => healthcheck !== undefined)
|
||||
}); // Remove all the categories that don't have any healthcheck with
|
||||
// `needsToBeFixed` so they don't show when the user taps to fix encountered
|
||||
// issues
|
||||
|
||||
|
||||
const removeFixedCategories = categories => categories.filter(category => category.healthchecks.some(healthcheck => healthcheck.needsToBeFixed));
|
||||
|
||||
const iterateOverCategories = categories => Promise.all(categories.map(iterateOverHealthChecks));
|
||||
|
||||
const healthchecksPerCategory = await iterateOverCategories(Object.values((0, _healthchecks.getHealthchecks)(options)).filter(category => category !== undefined));
|
||||
loader.stop();
|
||||
const stats = {
|
||||
errors: 0,
|
||||
warnings: 0
|
||||
};
|
||||
healthchecksPerCategory.forEach((issueCategory, key) => {
|
||||
printCategory({ ...issueCategory,
|
||||
key
|
||||
});
|
||||
issueCategory.healthchecks.forEach(healthcheck => {
|
||||
printIssue(healthcheck);
|
||||
|
||||
if (healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.WARNING) {
|
||||
stats.warnings++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.ERROR) {
|
||||
stats.errors++;
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
printOverallStats(stats);
|
||||
|
||||
if (options.fix) {
|
||||
return await (0, _runAutomaticFix.default)({
|
||||
healthchecks: removeFixedCategories(healthchecksPerCategory),
|
||||
automaticFixLevel: _runAutomaticFix.AUTOMATIC_FIX_LEVELS.ALL_ISSUES,
|
||||
stats,
|
||||
loader,
|
||||
environmentInfo
|
||||
});
|
||||
}
|
||||
|
||||
const removeKeyPressListener = () => {
|
||||
if (typeof process.stdin.setRawMode === 'function') {
|
||||
process.stdin.setRawMode(false);
|
||||
}
|
||||
|
||||
process.stdin.removeAllListeners('data');
|
||||
};
|
||||
|
||||
const onKeyPress = async key => {
|
||||
if (key === _printFixOptions.KEYS.EXIT || key === '\u0003') {
|
||||
removeKeyPressListener();
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ([_printFixOptions.KEYS.FIX_ALL_ISSUES, _printFixOptions.KEYS.FIX_ERRORS, _printFixOptions.KEYS.FIX_WARNINGS].includes(key)) {
|
||||
removeKeyPressListener();
|
||||
|
||||
try {
|
||||
const automaticFixLevel = {
|
||||
[_printFixOptions.KEYS.FIX_ALL_ISSUES]: _runAutomaticFix.AUTOMATIC_FIX_LEVELS.ALL_ISSUES,
|
||||
[_printFixOptions.KEYS.FIX_ERRORS]: _runAutomaticFix.AUTOMATIC_FIX_LEVELS.ERRORS,
|
||||
[_printFixOptions.KEYS.FIX_WARNINGS]: _runAutomaticFix.AUTOMATIC_FIX_LEVELS.WARNINGS
|
||||
};
|
||||
await (0, _runAutomaticFix.default)({
|
||||
healthchecks: removeFixedCategories(healthchecksPerCategory),
|
||||
automaticFixLevel: automaticFixLevel[key],
|
||||
stats,
|
||||
loader,
|
||||
environmentInfo
|
||||
});
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
// TODO: log error
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (stats.errors || stats.warnings) {
|
||||
(0, _printFixOptions.default)({
|
||||
onKeyPress
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=doctor.js.map
|
55
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidHomeEnvVariable.js
generated
vendored
Normal file
55
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidHomeEnvVariable.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// List of answers on how to set `ANDROID_HOME` for each platform
|
||||
const URLS = {
|
||||
darwin: 'https://stackoverflow.com/a/28296325/4252781',
|
||||
win32: 'https://stackoverflow.com/a/54888107/4252781',
|
||||
linux: 'https://stackoverflow.com/a/39228100/4252781'
|
||||
};
|
||||
const label = 'ANDROID_HOME'; // Force the options for the platform to avoid providing a link
|
||||
// for `ANDROID_HOME` for every platform NodeJS supports
|
||||
|
||||
const platform = process.platform;
|
||||
const message = `Read more about how to set the ${label} at ${_chalk().default.dim(URLS[platform])}`;
|
||||
var _default = {
|
||||
label,
|
||||
getDiagnostics: async () => ({
|
||||
needsToBeFixed: !process.env.ANDROID_HOME
|
||||
}),
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
// Variable could have been added if installing Android Studio so double checking
|
||||
if (process.env.ANDROID_HOME) {
|
||||
loader.succeed();
|
||||
return;
|
||||
}
|
||||
|
||||
loader.fail();
|
||||
(0, _common.logManualInstallation)({
|
||||
message
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=androidHomeEnvVariable.js.map
|
65
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidNDK.js
generated
vendored
Normal file
65
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidNDK.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
label: 'Android NDK',
|
||||
description: 'Required for building React Native from the source',
|
||||
getDiagnostics: async ({
|
||||
SDKs
|
||||
}) => {
|
||||
const androidSdk = SDKs['Android SDK'];
|
||||
const version = androidSdk === 'Not Found' ? androidSdk : androidSdk['Android NDK'];
|
||||
return {
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version,
|
||||
versionRange: _versionRanges.default.ANDROID_NDK
|
||||
}),
|
||||
version,
|
||||
versionRange: _versionRanges.default.ANDROID_NDK
|
||||
};
|
||||
},
|
||||
runAutomaticFix: async ({
|
||||
loader,
|
||||
environmentInfo
|
||||
}) => {
|
||||
const androidSdk = environmentInfo.SDKs['Android SDK'];
|
||||
const isNDKInstalled = androidSdk !== 'Not Found' && androidSdk['Android NDK'] !== 'Not Found';
|
||||
loader.fail();
|
||||
|
||||
if (isNDKInstalled) {
|
||||
return (0, _common.logManualInstallation)({
|
||||
message: `Read more about how to update Android NDK at ${_chalk().default.dim('https://developer.android.com/ndk/downloads')}`
|
||||
});
|
||||
}
|
||||
|
||||
return (0, _common.logManualInstallation)({
|
||||
healthcheck: 'Android NDK',
|
||||
url: 'https://developer.android.com/ndk/downloads'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=androidNDK.js.map
|
198
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidSDK.js
generated
vendored
Normal file
198
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidSDK.js
generated
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _findProjectRoot = _interopRequireDefault(require("../../../tools/config/findProjectRoot"));
|
||||
|
||||
var _androidWinHelpers = require("../../../tools/windows/androidWinHelpers");
|
||||
|
||||
var _downloadAndUnzip = require("../../../tools/downloadAndUnzip");
|
||||
|
||||
var _environmentVariables = require("../../../tools/windows/environmentVariables");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const getBuildToolsVersion = () => {
|
||||
let projectRoot = '';
|
||||
|
||||
try {
|
||||
// doctor is a detached command, so we may not be in a RN project.
|
||||
projectRoot = (0, _findProjectRoot.default)();
|
||||
} catch (_unused) {
|
||||
_cliTools().logger.log(); // for extra space
|
||||
|
||||
|
||||
_cliTools().logger.warn("We couldn't find a package.json in this directory. Android SDK checks may fail. Doctor works best in a React Native project root.");
|
||||
}
|
||||
|
||||
const gradleBuildFilePath = _path().default.join(projectRoot, 'android/build.gradle');
|
||||
|
||||
const buildToolsVersionEntry = 'buildToolsVersion';
|
||||
|
||||
if (!_fs().default.existsSync(gradleBuildFilePath)) {
|
||||
return 'Not Found';
|
||||
} // Read the content of the `build.gradle` file
|
||||
|
||||
|
||||
const gradleBuildFile = _fs().default.readFileSync(gradleBuildFilePath, 'utf-8');
|
||||
|
||||
const buildToolsVersionIndex = gradleBuildFile.indexOf(buildToolsVersionEntry);
|
||||
const buildToolsVersion = (gradleBuildFile // Get only the portion of the declaration of `buildToolsVersion`
|
||||
.substring(buildToolsVersionIndex).split('\n')[0] // Get only the the value of `buildToolsVersion`
|
||||
.match(/\d|\../g) || []).join('');
|
||||
return buildToolsVersion || 'Not Found';
|
||||
};
|
||||
|
||||
const installMessage = `Read more about how to update Android SDK at ${_chalk().default.dim('https://developer.android.com/studio')}`;
|
||||
|
||||
const isSDKInstalled = environmentInfo => {
|
||||
const version = environmentInfo.SDKs['Android SDK'];
|
||||
return version !== 'Not Found';
|
||||
};
|
||||
|
||||
var _default = {
|
||||
label: 'Android SDK',
|
||||
description: 'Required for building and installing your app on Android',
|
||||
getDiagnostics: async ({
|
||||
SDKs
|
||||
}) => {
|
||||
const requiredVersion = getBuildToolsVersion();
|
||||
const buildTools = typeof SDKs['Android SDK'] === 'string' ? SDKs['Android SDK'] : SDKs['Android SDK']['Build Tools'];
|
||||
const isAndroidSDKInstalled = Array.isArray(buildTools);
|
||||
const isRequiredVersionInstalled = isAndroidSDKInstalled ? buildTools.includes(requiredVersion) : false;
|
||||
return {
|
||||
versions: isAndroidSDKInstalled ? buildTools : SDKs['Android SDK'],
|
||||
versionRange: requiredVersion,
|
||||
needsToBeFixed: !isRequiredVersionInstalled
|
||||
};
|
||||
},
|
||||
win32AutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
// Need a GitHub action to update automatically. See #1180
|
||||
const cliToolsUrl = 'https://dl.google.com/android/repository/commandlinetools-win-6200805_latest.zip';
|
||||
const systemImage = 'system-images;android-28;google_apis;x86_64'; // Installing 29 as well so Android Studio does not complain on first boot
|
||||
|
||||
const componentsToInstall = ['platform-tools', 'build-tools;29.0.3', 'platforms;android-29', // Is 28 still needed?
|
||||
'build-tools;28.0.3', 'platforms;android-28', 'emulator', systemImage, '--licenses' // Accept any pending licenses at the end
|
||||
];
|
||||
const androidSDKRoot = (0, _androidWinHelpers.getAndroidSdkRootInstallation)();
|
||||
|
||||
if (androidSDKRoot === '') {
|
||||
loader.fail('There was an error finding the Android SDK root');
|
||||
return;
|
||||
}
|
||||
|
||||
await (0, _downloadAndUnzip.downloadAndUnzip)({
|
||||
loader,
|
||||
downloadUrl: cliToolsUrl,
|
||||
component: 'Android Command Line Tools',
|
||||
installPath: androidSDKRoot
|
||||
});
|
||||
|
||||
for (const component of componentsToInstall) {
|
||||
loader.text = `Installing "${component}" (this may take a few minutes)`;
|
||||
|
||||
try {
|
||||
await (0, _androidWinHelpers.installComponent)(component, androidSDKRoot);
|
||||
} catch (e) {// Is there a way to persist a line in loader and continue the execution?
|
||||
}
|
||||
}
|
||||
|
||||
loader.text = 'Updating environment variables'; // Required for the emulator to work from the CLI
|
||||
|
||||
await (0, _environmentVariables.setEnvironment)('ANDROID_SDK_ROOT', androidSDKRoot);
|
||||
await (0, _environmentVariables.setEnvironment)('ANDROID_HOME', androidSDKRoot);
|
||||
await (0, _environmentVariables.updateEnvironment)('PATH', _path().default.join(androidSDKRoot, 'tools'));
|
||||
await (0, _environmentVariables.updateEnvironment)('PATH', _path().default.join(androidSDKRoot, 'platform-tools'));
|
||||
loader.text = 'Configuring Hypervisor for faster emulation, this might prompt UAC';
|
||||
const {
|
||||
hypervisor,
|
||||
installed
|
||||
} = await (0, _androidWinHelpers.getBestHypervisor)(androidSDKRoot);
|
||||
|
||||
if (!installed) {
|
||||
if (hypervisor === 'none') {
|
||||
loader.warn('Android SDK configured but virtualization could not be enabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (hypervisor === 'AMDH') {
|
||||
await (0, _androidWinHelpers.enableAMDH)(androidSDKRoot);
|
||||
} else if (hypervisor === 'HAXM') {
|
||||
await (0, _androidWinHelpers.enableHAXM)(androidSDKRoot);
|
||||
} else if (hypervisor === 'WHPX') {
|
||||
await (0, _androidWinHelpers.enableWHPX)();
|
||||
}
|
||||
}
|
||||
|
||||
loader.text = 'Creating AVD';
|
||||
await (0, _androidWinHelpers.createAVD)(androidSDKRoot, 'pixel_9.0', 'pixel', systemImage);
|
||||
loader.succeed('Android SDK configured. You might need to restart your PC for all changes to take effect.');
|
||||
},
|
||||
runAutomaticFix: async ({
|
||||
loader,
|
||||
environmentInfo
|
||||
}) => {
|
||||
loader.fail();
|
||||
|
||||
if (isSDKInstalled(environmentInfo)) {
|
||||
return (0, _common.logManualInstallation)({
|
||||
message: installMessage
|
||||
});
|
||||
}
|
||||
|
||||
return (0, _common.logManualInstallation)({
|
||||
healthcheck: 'Android SDK',
|
||||
url: 'https://reactnative.dev/docs/getting-started'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=androidSDK.js.map
|
92
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidStudio.js
generated
vendored
Normal file
92
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/androidStudio.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _downloadAndUnzip = require("../../../tools/downloadAndUnzip");
|
||||
|
||||
var _executeWinCommand = require("../../../tools/windows/executeWinCommand");
|
||||
|
||||
var _androidWinHelpers = require("../../../tools/windows/androidWinHelpers");
|
||||
|
||||
var _createShortcut = require("../../../tools/windows/create-shortcut");
|
||||
|
||||
var _default = {
|
||||
label: 'Android Studio',
|
||||
description: 'Required for building and installing your app on Android',
|
||||
getDiagnostics: async ({
|
||||
IDEs
|
||||
}) => {
|
||||
const needsToBeFixed = IDEs['Android Studio'] === 'Not Found';
|
||||
const missing = {
|
||||
needsToBeFixed,
|
||||
version: IDEs['Android Studio']
|
||||
}; // On Windows `doctor` installs Android Studio locally in a well-known place
|
||||
|
||||
if (needsToBeFixed && process.platform === 'win32') {
|
||||
const androidStudioPath = (0, _path().join)((0, _androidWinHelpers.getUserAndroidPath)(), 'android-studio', 'bin', 'studio.exe').replace(/\\/g, '\\\\');
|
||||
const {
|
||||
stdout
|
||||
} = await (0, _executeWinCommand.executeCommand)(`wmic datafile where name="${androidStudioPath}" get Version`);
|
||||
const version = stdout.replace(/(\r\n|\n|\r)/gm, '').trim();
|
||||
|
||||
if (version === '') {
|
||||
return missing;
|
||||
}
|
||||
|
||||
return {
|
||||
needsToBeFixed: false,
|
||||
version
|
||||
};
|
||||
}
|
||||
|
||||
return missing;
|
||||
},
|
||||
win32AutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
// Need a GitHub action to update automatically. See #1180
|
||||
const androidStudioUrl = 'https://redirector.gvt1.com/edgedl/android/studio/ide-zips/3.6.3.0/android-studio-ide-192.6392135-windows.zip';
|
||||
const installPath = (0, _androidWinHelpers.getUserAndroidPath)();
|
||||
await (0, _downloadAndUnzip.downloadAndUnzip)({
|
||||
loader,
|
||||
downloadUrl: androidStudioUrl,
|
||||
component: 'Android Studio',
|
||||
installPath: installPath
|
||||
});
|
||||
const prefix = process.arch === 'x64' ? '64' : '';
|
||||
const binFolder = (0, _path().join)(installPath, 'android-studio', 'bin');
|
||||
await (0, _createShortcut.createShortcut)({
|
||||
path: (0, _path().join)(binFolder, `studio${prefix}.exe`),
|
||||
name: 'Android Studio',
|
||||
ico: (0, _path().join)(binFolder, 'studio.ico')
|
||||
});
|
||||
loader.succeed(`Android Studio installed successfully in "${installPath}".`);
|
||||
},
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
loader.fail();
|
||||
return (0, _common.logManualInstallation)({
|
||||
healthcheck: 'Android Studio',
|
||||
url: 'https://reactnative.dev/docs/environment-setup'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=androidStudio.js.map
|
86
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/cocoaPods.js
generated
vendored
Normal file
86
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/cocoaPods.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _installPods = require("../../../tools/installPods");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _brewInstall = require("../../../tools/brewInstall");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const label = 'CocoaPods';
|
||||
var _default = {
|
||||
label,
|
||||
description: 'Required for installing iOS dependencies',
|
||||
getDiagnostics: async () => ({
|
||||
needsToBeFixed: await (0, _checkInstallation.isSoftwareNotInstalled)('pod')
|
||||
}),
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
loader.stop();
|
||||
const {
|
||||
installMethod,
|
||||
promptQuestion
|
||||
} = await (0, _installPods.promptCocoaPodsInstallationQuestion)(); // Capitalise `Homebrew` when printing on the screen
|
||||
|
||||
const installMethodCapitalized = installMethod === 'homebrew' ? installMethod.substr(0, 1).toUpperCase() + installMethod.substr(1) : installMethod;
|
||||
const loaderInstallationMessage = `${label} (installing with ${installMethodCapitalized})`;
|
||||
const loaderSucceedMessage = `${label} (installed with ${installMethodCapitalized})`; // Remove the prompt after the question of how to install CocoaPods is answered
|
||||
|
||||
(0, _common.removeMessage)(promptQuestion);
|
||||
|
||||
if (installMethod === 'gem') {
|
||||
loader.start(loaderInstallationMessage);
|
||||
const options = ['install', 'cocoapods', '--no-document'];
|
||||
|
||||
try {
|
||||
// First attempt to install `cocoapods`
|
||||
await (0, _execa().default)('gem', options);
|
||||
return loader.succeed(loaderSucceedMessage);
|
||||
} catch (_error) {
|
||||
// If that doesn't work then try with sudo
|
||||
try {
|
||||
await (0, _installPods.runSudo)(`gem ${options.join(' ')}`);
|
||||
return loader.succeed(loaderSucceedMessage);
|
||||
} catch (error) {
|
||||
(0, _common.logError)({
|
||||
healthcheck: label,
|
||||
loader,
|
||||
error,
|
||||
command: 'sudo gem install cocoapods'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (installMethod === 'homebrew') {
|
||||
return await (0, _brewInstall.brewInstall)({
|
||||
pkg: 'cocoapods',
|
||||
label: loaderInstallationMessage,
|
||||
loader,
|
||||
onSuccess: () => loader.succeed(loaderSucceedMessage)
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=cocoaPods.js.map
|
139
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/common.js
generated
vendored
Normal file
139
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/common.js
generated
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.removeMessage = removeMessage;
|
||||
exports.logError = exports.logManualInstallation = exports.logMessage = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _readline() {
|
||||
const data = _interopRequireDefault(require("readline"));
|
||||
|
||||
_readline = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _wcwidth() {
|
||||
const data = _interopRequireDefault(require("wcwidth"));
|
||||
|
||||
_wcwidth = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _stripAnsi() {
|
||||
const data = _interopRequireDefault(require("strip-ansi"));
|
||||
|
||||
_stripAnsi = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Space is necessary to keep correct ordering on screen
|
||||
const logMessage = message => {
|
||||
const indentation = ' ';
|
||||
|
||||
if (typeof message !== 'string') {
|
||||
_cliTools().logger.log();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const messageByLine = message.split('\n');
|
||||
return _cliTools().logger.log(`${indentation}${messageByLine.join(`\n${indentation}`)}`);
|
||||
};
|
||||
|
||||
exports.logMessage = logMessage;
|
||||
|
||||
const addBlankLine = () => logMessage();
|
||||
|
||||
const logManualInstallation = ({
|
||||
healthcheck,
|
||||
url,
|
||||
command,
|
||||
message
|
||||
}) => {
|
||||
if (message) {
|
||||
return logMessage(message);
|
||||
}
|
||||
|
||||
if (url) {
|
||||
logMessage(`Read more about how to download ${healthcheck} at ${_chalk().default.dim.underline(url)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (command) {
|
||||
logMessage(`Please install ${healthcheck} by running ${_chalk().default.bold(command)}`);
|
||||
}
|
||||
};
|
||||
|
||||
exports.logManualInstallation = logManualInstallation;
|
||||
|
||||
const logError = ({
|
||||
healthcheck,
|
||||
loader,
|
||||
error,
|
||||
message,
|
||||
command
|
||||
}) => {
|
||||
if (loader) {
|
||||
loader.fail();
|
||||
}
|
||||
|
||||
addBlankLine();
|
||||
logMessage(_chalk().default.dim(error.message));
|
||||
|
||||
if (message) {
|
||||
logMessage(message);
|
||||
addBlankLine();
|
||||
return;
|
||||
}
|
||||
|
||||
logMessage(`The error above occured while trying to install ${healthcheck}. Please try again manually: ${_chalk().default.bold(command)}`);
|
||||
addBlankLine();
|
||||
}; // Calculate the size of a message on terminal based on rows
|
||||
|
||||
|
||||
exports.logError = logError;
|
||||
|
||||
function calculateMessageSize(message) {
|
||||
return Math.max(1, Math.ceil((0, _wcwidth().default)((0, _stripAnsi().default)(message)) / (process.stdout.columns || 80)));
|
||||
} // Clear the message from the terminal
|
||||
|
||||
|
||||
function removeMessage(message) {
|
||||
_readline().default.moveCursor(process.stdout, 0, -calculateMessageSize(message));
|
||||
|
||||
_readline().default.clearScreenDown(process.stdout);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=common.js.map
|
61
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/index.js
generated
vendored
Normal file
61
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/index.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getHealthchecks = exports.HEALTHCHECK_TYPES = void 0;
|
||||
|
||||
var _nodeJS = _interopRequireDefault(require("./nodeJS"));
|
||||
|
||||
var _packageManagers = require("./packageManagers");
|
||||
|
||||
var _jdk = _interopRequireDefault(require("./jdk"));
|
||||
|
||||
var _python = _interopRequireDefault(require("./python"));
|
||||
|
||||
var _watchman = _interopRequireDefault(require("./watchman"));
|
||||
|
||||
var _androidHomeEnvVariable = _interopRequireDefault(require("./androidHomeEnvVariable"));
|
||||
|
||||
var _androidStudio = _interopRequireDefault(require("./androidStudio"));
|
||||
|
||||
var _androidSDK = _interopRequireDefault(require("./androidSDK"));
|
||||
|
||||
var _androidNDK = _interopRequireDefault(require("./androidNDK"));
|
||||
|
||||
var _xcode = _interopRequireDefault(require("./xcode"));
|
||||
|
||||
var _cocoaPods = _interopRequireDefault(require("./cocoaPods"));
|
||||
|
||||
var _iosDeploy = _interopRequireDefault(require("./iosDeploy"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const HEALTHCHECK_TYPES = {
|
||||
ERROR: 'ERROR',
|
||||
WARNING: 'WARNING'
|
||||
};
|
||||
exports.HEALTHCHECK_TYPES = HEALTHCHECK_TYPES;
|
||||
|
||||
const getHealthchecks = ({
|
||||
contributor
|
||||
}) => ({
|
||||
common: {
|
||||
label: 'Common',
|
||||
healthchecks: [_nodeJS.default, _packageManagers.yarn, _packageManagers.npm, ...(process.platform === 'darwin' ? [_watchman.default] : []), ...(process.platform === 'win32' ? [_python.default] : [])]
|
||||
},
|
||||
android: {
|
||||
label: 'Android',
|
||||
healthchecks: [_jdk.default, _androidStudio.default, _androidSDK.default, _androidHomeEnvVariable.default, ...(contributor ? [_androidNDK.default] : [])]
|
||||
},
|
||||
...(process.platform === 'darwin' ? {
|
||||
ios: {
|
||||
label: 'iOS',
|
||||
healthchecks: [_xcode.default, _cocoaPods.default, _iosDeploy.default]
|
||||
}
|
||||
} : {})
|
||||
});
|
||||
|
||||
exports.getHealthchecks = getHealthchecks;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
138
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/iosDeploy.js
generated
vendored
Normal file
138
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/iosDeploy.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _inquirer() {
|
||||
const data = _interopRequireDefault(require("inquirer"));
|
||||
|
||||
_inquirer = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _packageManagers = require("./packageManagers");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// @ts-ignore untyped
|
||||
const label = 'ios-deploy';
|
||||
const installationWithYarn = 'yarn global add ios-deploy';
|
||||
const installationWithNpm = 'npm install ios-deploy --global';
|
||||
|
||||
const identifyInstallationCommand = () => {
|
||||
if (_packageManagers.packageManager === _checkInstallation.PACKAGE_MANAGERS.YARN) {
|
||||
return installationWithYarn;
|
||||
}
|
||||
|
||||
if (_packageManagers.packageManager === _checkInstallation.PACKAGE_MANAGERS.NPM) {
|
||||
return installationWithNpm;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const installLibrary = async ({
|
||||
installationCommand,
|
||||
packageManagerToUse,
|
||||
loader
|
||||
}) => {
|
||||
try {
|
||||
loader.start(`${label} (installing with ${packageManagerToUse})`);
|
||||
const installationCommandArgs = installationCommand.split(' ');
|
||||
await (0, _execa().default)(installationCommandArgs[0], installationCommandArgs.splice(1));
|
||||
loader.succeed(`${label} (installed with ${packageManagerToUse})`);
|
||||
} catch (error) {
|
||||
(0, _common.logError)({
|
||||
healthcheck: label,
|
||||
loader,
|
||||
error,
|
||||
command: installationCommand
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var _default = {
|
||||
label,
|
||||
isRequired: false,
|
||||
description: 'Required for installing your app on a physical device with the CLI',
|
||||
getDiagnostics: async () => ({
|
||||
needsToBeFixed: await (0, _checkInstallation.isSoftwareNotInstalled)('ios-deploy')
|
||||
}),
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
loader.stop();
|
||||
const installationCommand = identifyInstallationCommand(); // This means that we couldn't "guess" the package manager
|
||||
|
||||
if (installationCommand === undefined) {
|
||||
const promptQuestion = `ios-deploy needs to be installed either by ${_chalk().default.bold('yarn')} ${_chalk().default.reset('or')} ${_chalk().default.bold('npm')} ${_chalk().default.reset()}, which one do you want to use?`;
|
||||
const installWithYarn = 'yarn';
|
||||
const installWithNpm = 'npm';
|
||||
const skipInstallation = 'Skip installation';
|
||||
const {
|
||||
chosenPackageManager
|
||||
} = await _inquirer().default.prompt([{
|
||||
type: 'list',
|
||||
name: 'chosenPackageManager',
|
||||
message: promptQuestion,
|
||||
choices: [installWithYarn, installWithNpm, skipInstallation]
|
||||
}]);
|
||||
(0, _common.removeMessage)(`? ${promptQuestion} ${chosenPackageManager}`);
|
||||
|
||||
if (chosenPackageManager === skipInstallation) {
|
||||
loader.fail(); // Then we just print out the URL that the user can head to download the library
|
||||
|
||||
(0, _common.logManualInstallation)({
|
||||
healthcheck: 'ios-deploy',
|
||||
url: 'https://github.com/ios-control/ios-deploy#readme'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const shouldInstallWithYarn = chosenPackageManager === installWithYarn;
|
||||
return installLibrary({
|
||||
installationCommand: shouldInstallWithYarn ? installationWithYarn : installationWithNpm,
|
||||
loader,
|
||||
packageManagerToUse: chosenPackageManager
|
||||
});
|
||||
}
|
||||
|
||||
return installLibrary({
|
||||
installationCommand,
|
||||
packageManagerToUse: _packageManagers.packageManager.toLowerCase(),
|
||||
loader
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=iosDeploy.js.map
|
74
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/jdk.js
generated
vendored
Normal file
74
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/jdk.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _downloadAndUnzip = require("../../../tools/downloadAndUnzip");
|
||||
|
||||
var _environmentVariables = require("../../../tools/windows/environmentVariables");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
label: 'JDK',
|
||||
getDiagnostics: async ({
|
||||
Languages
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: typeof Languages.Java === 'string' ? Languages.Java : Languages.Java.version,
|
||||
versionRange: _versionRanges.default.JAVA
|
||||
}),
|
||||
version: typeof Languages.Java === 'string' ? Languages.Java : Languages.Java.version,
|
||||
versionRange: _versionRanges.default.JAVA
|
||||
}),
|
||||
win32AutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
try {
|
||||
// Installing JDK 11 because later versions seem to cause issues with gradle at the moment
|
||||
const installerUrl = 'https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_windows-x64_bin.zip';
|
||||
const installPath = process.env.LOCALAPPDATA || ''; // The zip is in a folder `jdk-11.02` so it can be unzipped directly there
|
||||
|
||||
await (0, _downloadAndUnzip.downloadAndUnzip)({
|
||||
loader,
|
||||
downloadUrl: installerUrl,
|
||||
component: 'JDK',
|
||||
installPath
|
||||
});
|
||||
loader.text = 'Updating environment variables';
|
||||
const jdkPath = (0, _path().join)(installPath, 'jdk-11.0.2');
|
||||
await (0, _environmentVariables.setEnvironment)('JAVA_HOME', jdkPath);
|
||||
await (0, _environmentVariables.updateEnvironment)('PATH', (0, _path().join)(jdkPath, 'bin'));
|
||||
loader.succeed('JDK installed successfully. Please restart your shell to see the changes');
|
||||
} catch (e) {
|
||||
loader.fail(e);
|
||||
}
|
||||
},
|
||||
runAutomaticFix: async () => {
|
||||
(0, _common.logManualInstallation)({
|
||||
healthcheck: 'JDK',
|
||||
url: 'https://openjdk.java.net/'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=jdk.js.map
|
40
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/nodeJS.js
generated
vendored
Normal file
40
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/nodeJS.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
label: 'Node.js',
|
||||
getDiagnostics: async ({
|
||||
Binaries
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: Binaries.Node.version,
|
||||
versionRange: _versionRanges.default.NODE_JS
|
||||
}),
|
||||
version: Binaries.Node.version,
|
||||
versionRange: _versionRanges.default.NODE_JS
|
||||
}),
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
loader.fail();
|
||||
(0, _common.logManualInstallation)({
|
||||
healthcheck: 'Node.js',
|
||||
url: 'https://nodejs.org/en/download/'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=nodeJS.js.map
|
90
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/packageManagers.js
generated
vendored
Normal file
90
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/packageManagers.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.npm = exports.yarn = exports.packageManager = void 0;
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _install = require("../../../tools/install");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const packageManager = (() => {
|
||||
if (_fs().default.existsSync('yarn.lock')) {
|
||||
return _checkInstallation.PACKAGE_MANAGERS.YARN;
|
||||
}
|
||||
|
||||
if (_fs().default.existsSync('package-lock.json')) {
|
||||
return _checkInstallation.PACKAGE_MANAGERS.NPM;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
})();
|
||||
|
||||
exports.packageManager = packageManager;
|
||||
const yarn = {
|
||||
label: 'yarn',
|
||||
getDiagnostics: async ({
|
||||
Binaries
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: Binaries.Yarn.version,
|
||||
versionRange: _versionRanges.default.YARN
|
||||
}),
|
||||
version: Binaries.Yarn.version,
|
||||
versionRange: _versionRanges.default.YARN
|
||||
}),
|
||||
// Only show `yarn` if there's a `yarn.lock` file in the current directory
|
||||
// or if we can't identify that the user uses yarn or npm
|
||||
visible: packageManager === _checkInstallation.PACKAGE_MANAGERS.YARN || packageManager === undefined,
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => await (0, _install.install)({
|
||||
pkg: 'yarn',
|
||||
label: 'yarn',
|
||||
url: 'https://yarnpkg.com/docs/install',
|
||||
loader
|
||||
})
|
||||
};
|
||||
exports.yarn = yarn;
|
||||
const npm = {
|
||||
label: 'npm',
|
||||
getDiagnostics: async ({
|
||||
Binaries
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: Binaries.npm.version,
|
||||
versionRange: _versionRanges.default.NPM
|
||||
}),
|
||||
version: Binaries.npm.version,
|
||||
versionRange: _versionRanges.default.NPM
|
||||
}),
|
||||
// Only show `yarn` if there's a `package-lock.json` file in the current directory
|
||||
// or if we can't identify that the user uses yarn or npm
|
||||
visible: packageManager === _checkInstallation.PACKAGE_MANAGERS.NPM || packageManager === undefined,
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => await (0, _install.install)({
|
||||
pkg: 'node',
|
||||
label: 'node',
|
||||
url: 'https://nodejs.org/',
|
||||
loader
|
||||
})
|
||||
};
|
||||
exports.npm = npm;
|
||||
|
||||
//# sourceMappingURL=packageManagers.js.map
|
86
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/python.js
generated
vendored
Normal file
86
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/python.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
var _environmentVariables = require("../../../tools/windows/environmentVariables");
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _executeWinCommand = require("../../../tools/windows/executeWinCommand");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
label: 'Python',
|
||||
getDiagnostics: async ({
|
||||
Languages
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: typeof Languages.Python === 'string' ? Languages.Python : Languages.Python.version,
|
||||
versionRange: _versionRanges.default.PYTHON
|
||||
}),
|
||||
version: typeof Languages.Python === 'string' ? Languages.Python : Languages.Python.version,
|
||||
versionRange: _versionRanges.default.PYTHON
|
||||
}),
|
||||
win32AutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
try {
|
||||
const arch = process.arch === 'x64' ? 'amd64.' : '';
|
||||
const installerUrl = `https://www.python.org/ftp/python/2.7.9/python-2.7.9.${arch}msi`;
|
||||
const installPath = (0, _path().join)(process.env.LOCALAPPDATA || '', 'python2');
|
||||
loader.start(`Downloading Python installer from "${installerUrl}"`);
|
||||
const installer = await (0, _cliTools().fetchToTemp)(installerUrl);
|
||||
loader.text = `Installing Python in "${installPath}"`;
|
||||
const command = `msiexec.exe /i "${installer}" TARGETDIR="${installPath}" /qn /L*P "python-log.txt"`;
|
||||
await (0, _executeWinCommand.executeCommand)(command);
|
||||
loader.text = 'Updating environment variables';
|
||||
await (0, _environmentVariables.updateEnvironment)('PATH', installPath);
|
||||
await (0, _environmentVariables.updateEnvironment)('PATH', (0, _path().join)(installPath, 'scripts'));
|
||||
loader.succeed('Python installed successfully');
|
||||
} catch (e) {
|
||||
loader.fail(e);
|
||||
}
|
||||
},
|
||||
runAutomaticFix: async () => {
|
||||
/**
|
||||
* Python is only needed on Windows so this method should never be called.
|
||||
* Leaving it in case that changes and as an example of how to have a
|
||||
* fallback.
|
||||
*/
|
||||
(0, _common.logManualInstallation)({
|
||||
healthcheck: 'Python',
|
||||
url: 'https://www.python.org/downloads/'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=python.js.map
|
41
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/watchman.js
generated
vendored
Normal file
41
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/watchman.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _install = require("../../../tools/install");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const label = 'Watchman';
|
||||
var _default = {
|
||||
label,
|
||||
description: 'Used for watching changes in the filesystem when in development mode',
|
||||
getDiagnostics: async ({
|
||||
Binaries
|
||||
}) => ({
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version: Binaries.Watchman.version,
|
||||
versionRange: _versionRanges.default.WATCHMAN
|
||||
}),
|
||||
version: Binaries.Watchman.version,
|
||||
versionRange: _versionRanges.default.WATCHMAN
|
||||
}),
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => await (0, _install.install)({
|
||||
pkg: 'watchman',
|
||||
label,
|
||||
url: 'https://facebook.github.io/watchman/docs/install.html',
|
||||
loader
|
||||
})
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=watchman.js.map
|
44
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/xcode.js
generated
vendored
Normal file
44
node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/xcode.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _versionRanges = _interopRequireDefault(require("../versionRanges"));
|
||||
|
||||
var _checkInstallation = require("../checkInstallation");
|
||||
|
||||
var _common = require("./common");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
label: 'Xcode',
|
||||
description: 'Required for building and installing your app on iOS',
|
||||
getDiagnostics: async ({
|
||||
IDEs
|
||||
}) => {
|
||||
const version = IDEs.Xcode.version.split('/')[0];
|
||||
return {
|
||||
needsToBeFixed: (0, _checkInstallation.doesSoftwareNeedToBeFixed)({
|
||||
version,
|
||||
versionRange: _versionRanges.default.XCODE
|
||||
}),
|
||||
version,
|
||||
versionRange: _versionRanges.default.XCODE
|
||||
};
|
||||
},
|
||||
runAutomaticFix: async ({
|
||||
loader
|
||||
}) => {
|
||||
loader.fail();
|
||||
(0, _common.logManualInstallation)({
|
||||
healthcheck: 'Xcode',
|
||||
url: 'https://developer.apple.com/xcode/'
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=xcode.js.map
|
27
node_modules/@react-native-community/cli/build/commands/doctor/index.js
generated
vendored
Normal file
27
node_modules/@react-native-community/cli/build/commands/doctor/index.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _doctor = _interopRequireDefault(require("./doctor"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
func: _doctor.default,
|
||||
detached: true,
|
||||
name: 'doctor',
|
||||
description: '[EXPERIMENTAL] Diagnose and fix common Node.js, iOS, Android & React Native issues.',
|
||||
options: [{
|
||||
name: '--fix',
|
||||
description: 'Attempt to fix all diagnosed issues.'
|
||||
}, {
|
||||
name: '--contributor',
|
||||
description: 'Add healthchecks required to installations required for contributing to React Native.'
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
67
node_modules/@react-native-community/cli/build/commands/doctor/printFixOptions.js
generated
vendored
Normal file
67
node_modules/@react-native-community/cli/build/commands/doctor/printFixOptions.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.KEYS = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const KEYS = {
|
||||
FIX_ALL_ISSUES: 'f',
|
||||
FIX_ERRORS: 'e',
|
||||
FIX_WARNINGS: 'w',
|
||||
EXIT: '\r'
|
||||
};
|
||||
exports.KEYS = KEYS;
|
||||
|
||||
const printOption = option => _cliTools().logger.log(` \u203A ${option}`);
|
||||
|
||||
const printOptions = () => {
|
||||
_cliTools().logger.log();
|
||||
|
||||
_cliTools().logger.log(_chalk().default.bold('Usage'));
|
||||
|
||||
printOption(`${_chalk().default.dim('Press')} ${KEYS.FIX_ALL_ISSUES} ${_chalk().default.dim('to try to fix issues.')}`);
|
||||
printOption(`${_chalk().default.dim('Press')} ${KEYS.FIX_ERRORS} ${_chalk().default.dim('to try to fix errors.')}`);
|
||||
printOption(`${_chalk().default.dim('Press')} ${KEYS.FIX_WARNINGS} ${_chalk().default.dim('to try to fix warnings.')}`);
|
||||
printOption(`${_chalk().default.dim('Press')} Enter ${_chalk().default.dim('to exit.')}`);
|
||||
};
|
||||
|
||||
var _default = ({
|
||||
onKeyPress
|
||||
}) => {
|
||||
printOptions();
|
||||
|
||||
if (process.stdin.setRawMode) {
|
||||
process.stdin.setRawMode(true);
|
||||
}
|
||||
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.on('data', onKeyPress);
|
||||
};
|
||||
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=printFixOptions.js.map
|
115
node_modules/@react-native-community/cli/build/commands/doctor/runAutomaticFix.js
generated
vendored
Normal file
115
node_modules/@react-native-community/cli/build/commands/doctor/runAutomaticFix.js
generated
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
exports.AUTOMATIC_FIX_LEVELS = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _ora() {
|
||||
const data = _interopRequireDefault(require("ora"));
|
||||
|
||||
_ora = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _healthchecks = require("./healthchecks");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
let AUTOMATIC_FIX_LEVELS;
|
||||
exports.AUTOMATIC_FIX_LEVELS = AUTOMATIC_FIX_LEVELS;
|
||||
|
||||
(function (AUTOMATIC_FIX_LEVELS) {
|
||||
AUTOMATIC_FIX_LEVELS["ALL_ISSUES"] = "ALL_ISSUES";
|
||||
AUTOMATIC_FIX_LEVELS["ERRORS"] = "ERRORS";
|
||||
AUTOMATIC_FIX_LEVELS["WARNINGS"] = "WARNINGS";
|
||||
})(AUTOMATIC_FIX_LEVELS || (exports.AUTOMATIC_FIX_LEVELS = AUTOMATIC_FIX_LEVELS = {}));
|
||||
|
||||
async function _default({
|
||||
healthchecks,
|
||||
automaticFixLevel,
|
||||
stats,
|
||||
environmentInfo
|
||||
}) {
|
||||
// Remove the fix options from screen
|
||||
if (process.stdout.isTTY) {
|
||||
// @ts-ignore
|
||||
process.stdout.moveCursor(0, -6); // @ts-ignore
|
||||
|
||||
process.stdout.clearScreenDown();
|
||||
}
|
||||
|
||||
const totalIssuesBasedOnFixLevel = {
|
||||
[AUTOMATIC_FIX_LEVELS.ALL_ISSUES]: stats.errors + stats.warnings,
|
||||
[AUTOMATIC_FIX_LEVELS.ERRORS]: stats.errors,
|
||||
[AUTOMATIC_FIX_LEVELS.WARNINGS]: stats.warnings
|
||||
};
|
||||
const issuesCount = totalIssuesBasedOnFixLevel[automaticFixLevel];
|
||||
|
||||
_cliTools().logger.log(`\nAttempting to fix ${_chalk().default.bold(issuesCount.toString())} issue${issuesCount > 1 ? 's' : ''}...`);
|
||||
|
||||
for (const category of healthchecks) {
|
||||
const healthchecksToRun = category.healthchecks.filter(healthcheck => {
|
||||
if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.ALL_ISSUES) {
|
||||
return healthcheck.needsToBeFixed;
|
||||
}
|
||||
|
||||
if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.ERRORS) {
|
||||
return healthcheck.needsToBeFixed && healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.ERROR;
|
||||
}
|
||||
|
||||
if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.WARNINGS) {
|
||||
return healthcheck.needsToBeFixed && healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.WARNING;
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
if (!healthchecksToRun.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_cliTools().logger.log(`\n${_chalk().default.dim(category.label)}`);
|
||||
|
||||
for (const healthcheckToRun of healthchecksToRun) {
|
||||
const spinner = (0, _ora().default)({
|
||||
prefixText: '',
|
||||
text: healthcheckToRun.label
|
||||
}).start();
|
||||
|
||||
try {
|
||||
await healthcheckToRun.runAutomaticFix({
|
||||
loader: spinner,
|
||||
environmentInfo
|
||||
});
|
||||
} catch (error) {// TODO: log the error in a meaningful way
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=runAutomaticFix.js.map
|
1
node_modules/@react-native-community/cli/build/commands/doctor/types.js
generated
vendored
Normal file
1
node_modules/@react-native-community/cli/build/commands/doctor/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
"use strict";
|
23
node_modules/@react-native-community/cli/build/commands/doctor/versionRanges.js
generated
vendored
Normal file
23
node_modules/@react-native-community/cli/build/commands/doctor/versionRanges.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _default = {
|
||||
// Common
|
||||
NODE_JS: '>= 8.3',
|
||||
YARN: '>= 1.10.x',
|
||||
NPM: '>= 4.x',
|
||||
WATCHMAN: '4.x',
|
||||
PYTHON: '>= 2.x < 3',
|
||||
JAVA: '>= 8',
|
||||
// Android
|
||||
ANDROID_SDK: '>= 26.x',
|
||||
ANDROID_NDK: '>= 19.x',
|
||||
// iOS
|
||||
XCODE: '>= 10.x'
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=versionRanges.js.map
|
49
node_modules/@react-native-community/cli/build/commands/index.js
generated
vendored
Normal file
49
node_modules/@react-native-community/cli/build/commands/index.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.detachedCommands = exports.projectCommands = void 0;
|
||||
|
||||
var _start = _interopRequireDefault(require("./start/start"));
|
||||
|
||||
var _bundle = _interopRequireDefault(require("./bundle/bundle"));
|
||||
|
||||
var _ramBundle = _interopRequireDefault(require("./bundle/ramBundle"));
|
||||
|
||||
var _link = _interopRequireDefault(require("./link/link"));
|
||||
|
||||
var _unlink = _interopRequireDefault(require("./link/unlink"));
|
||||
|
||||
var _install = _interopRequireDefault(require("./install/install"));
|
||||
|
||||
var _uninstall = _interopRequireDefault(require("./install/uninstall"));
|
||||
|
||||
var _upgrade = _interopRequireDefault(require("./upgrade/upgrade"));
|
||||
|
||||
var _info = _interopRequireDefault(require("./info/info"));
|
||||
|
||||
var _config = _interopRequireDefault(require("./config/config"));
|
||||
|
||||
var _init = _interopRequireDefault(require("./init"));
|
||||
|
||||
var _doctor = _interopRequireDefault(require("./doctor"));
|
||||
|
||||
function _cliHermes() {
|
||||
const data = _interopRequireDefault(require("@react-native-community/cli-hermes"));
|
||||
|
||||
_cliHermes = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const projectCommands = [_start.default, _bundle.default, _ramBundle.default, _link.default, _unlink.default, _install.default, _uninstall.default, _upgrade.default, _info.default, _config.default, _doctor.default, _cliHermes().default];
|
||||
exports.projectCommands = projectCommands;
|
||||
const detachedCommands = [_init.default, _doctor.default];
|
||||
exports.detachedCommands = detachedCommands;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
52
node_modules/@react-native-community/cli/build/commands/info/info.js
generated
vendored
Normal file
52
node_modules/@react-native-community/cli/build/commands/info/info.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _envinfo = _interopRequireDefault(require("../../tools/envinfo"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _releaseChecker = _interopRequireDefault(require("../../tools/releaseChecker"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// @ts-ignore untyped
|
||||
const info = async function getInfo(_argv, ctx) {
|
||||
try {
|
||||
_cliTools().logger.info('Fetching system and libraries information...');
|
||||
|
||||
const output = await (0, _envinfo.default)(false);
|
||||
|
||||
_cliTools().logger.log(output);
|
||||
} catch (err) {
|
||||
_cliTools().logger.error(`Unable to print environment info.\n${err}`);
|
||||
} finally {
|
||||
await (0, _releaseChecker.default)(ctx.root);
|
||||
}
|
||||
};
|
||||
|
||||
var _default = {
|
||||
name: 'info',
|
||||
description: 'Get relevant version info about OS, toolchain and libraries',
|
||||
func: info
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=info.js.map
|
30
node_modules/@react-native-community/cli/build/commands/init/banner.js
generated
vendored
Normal file
30
node_modules/@react-native-community/cli/build/commands/init/banner.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const reactLogoArray = [' ', ' ###### ###### ', ' ### #### #### ### ', ' ## ### ### ## ', ' ## #### ## ', ' ## #### ## ', ' ## ## ## ## ', ' ## ### ### ## ', ' ## ######################## ## ', ' ###### ### ### ###### ', ' ### ## ## ## ## ### ', ' ### ## ### #### ### ## ### ', ' ## #### ######## #### ## ', ' ## ### ########## ### ## ', ' ## #### ######## #### ## ', ' ### ## ### #### ### ## ### ', ' ### ## ## ## ## ### ', ' ###### ### ### ###### ', ' ## ######################## ## ', ' ## ### ### ## ', ' ## ## ## ## ', ' ## #### ## ', ' ## #### ## ', ' ## ### ### ## ', ' ### #### #### ### ', ' ###### ###### ', ' '];
|
||||
const welcomeMessage = ' Welcome to React Native! ';
|
||||
const learnOnceMessage = ' Learn once, write anywhere ';
|
||||
var _default = `${_chalk().default.blue(reactLogoArray.join('\n'))}
|
||||
|
||||
${_chalk().default.blue.bold(welcomeMessage)}
|
||||
${_chalk().default.dim(learnOnceMessage)}
|
||||
`;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=banner.js.map
|
118
node_modules/@react-native-community/cli/build/commands/init/editTemplate.js
generated
vendored
Normal file
118
node_modules/@react-native-community/cli/build/commands/init/editTemplate.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.changePlaceholderInTemplate = changePlaceholderInTemplate;
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _walk = _interopRequireDefault(require("../../tools/walk"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
TODO: This is a default placeholder for title in react-native template.
|
||||
We should get rid of this once custom templates adapt `placeholderTitle` in their configurations.
|
||||
*/
|
||||
const DEFAULT_TITLE_PLACEHOLDER = 'Hello App Display Name';
|
||||
|
||||
function replaceNameInUTF8File(filePath, projectName, templateName) {
|
||||
_cliTools().logger.debug(`Replacing in ${filePath}`);
|
||||
|
||||
const fileContent = _fs().default.readFileSync(filePath, 'utf8');
|
||||
|
||||
const replacedFileContent = fileContent.replace(new RegExp(templateName, 'g'), projectName).replace(new RegExp(templateName.toLowerCase(), 'g'), projectName.toLowerCase());
|
||||
|
||||
if (fileContent !== replacedFileContent) {
|
||||
_fs().default.writeFileSync(filePath, replacedFileContent, 'utf8');
|
||||
}
|
||||
}
|
||||
|
||||
function renameFile(filePath, oldName, newName) {
|
||||
const newFileName = _path().default.join(_path().default.dirname(filePath), _path().default.basename(filePath).replace(new RegExp(oldName, 'g'), newName));
|
||||
|
||||
_cliTools().logger.debug(`Renaming ${filePath} -> file:${newFileName}`);
|
||||
|
||||
_fs().default.renameSync(filePath, newFileName);
|
||||
}
|
||||
|
||||
function shouldRenameFile(filePath, nameToReplace) {
|
||||
return _path().default.basename(filePath).includes(nameToReplace);
|
||||
}
|
||||
|
||||
function shouldIgnoreFile(filePath) {
|
||||
return filePath.match(/node_modules|yarn.lock|package-lock.json/g);
|
||||
}
|
||||
|
||||
const UNDERSCORED_DOTFILES = ['buckconfig', 'eslintrc.js', 'flowconfig', 'gitattributes', 'gitignore', 'prettierrc.js', 'watchmanconfig'];
|
||||
|
||||
function processDotfiles(filePath) {
|
||||
const dotfile = UNDERSCORED_DOTFILES.find(e => filePath.includes(`_${e}`));
|
||||
|
||||
if (dotfile === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
renameFile(filePath, `_${dotfile}`, `.${dotfile}`);
|
||||
}
|
||||
|
||||
function changePlaceholderInTemplate({
|
||||
projectName,
|
||||
placeholderName,
|
||||
placeholderTitle = DEFAULT_TITLE_PLACEHOLDER,
|
||||
projectTitle = projectName
|
||||
}) {
|
||||
_cliTools().logger.debug(`Changing ${placeholderName} for ${projectName} in template`);
|
||||
|
||||
(0, _walk.default)(process.cwd()).reverse().forEach(filePath => {
|
||||
if (shouldIgnoreFile(filePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_fs().default.statSync(filePath).isDirectory()) {
|
||||
replaceNameInUTF8File(filePath, projectName, placeholderName);
|
||||
replaceNameInUTF8File(filePath, projectTitle, placeholderTitle);
|
||||
}
|
||||
|
||||
if (shouldRenameFile(filePath, placeholderName)) {
|
||||
renameFile(filePath, placeholderName, projectName);
|
||||
}
|
||||
|
||||
if (shouldRenameFile(filePath, placeholderName.toLowerCase())) {
|
||||
renameFile(filePath, placeholderName.toLowerCase(), projectName.toLowerCase());
|
||||
}
|
||||
|
||||
processDotfiles(filePath);
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=editTemplate.js.map
|
17
node_modules/@react-native-community/cli/build/commands/init/errors/DirectoryAlreadyExistsError.js
generated
vendored
Normal file
17
node_modules/@react-native-community/cli/build/commands/init/errors/DirectoryAlreadyExistsError.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class DirectoryAlreadyExistsError extends Error {
|
||||
constructor(directory) {
|
||||
super(`Cannot initialize new project because directory "${directory}" already exists.`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = DirectoryAlreadyExistsError;
|
||||
|
||||
//# sourceMappingURL=DirectoryAlreadyExistsError.js.map
|
17
node_modules/@react-native-community/cli/build/commands/init/errors/HelloWorldError.js
generated
vendored
Normal file
17
node_modules/@react-native-community/cli/build/commands/init/errors/HelloWorldError.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class HelloWorldError extends Error {
|
||||
constructor() {
|
||||
super('Project name shouldn\'t contain "HelloWorld" name in it, because it is CLI\'s default placeholder name.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = HelloWorldError;
|
||||
|
||||
//# sourceMappingURL=HelloWorldError.js.map
|
17
node_modules/@react-native-community/cli/build/commands/init/errors/InvalidNameError.js
generated
vendored
Normal file
17
node_modules/@react-native-community/cli/build/commands/init/errors/InvalidNameError.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class InvalidNameError extends Error {
|
||||
constructor(name) {
|
||||
super(`"${name}" is not a valid name for a project. Please use a valid identifier name (alphanumeric).`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = InvalidNameError;
|
||||
|
||||
//# sourceMappingURL=InvalidNameError.js.map
|
17
node_modules/@react-native-community/cli/build/commands/init/errors/ReservedNameError.js
generated
vendored
Normal file
17
node_modules/@react-native-community/cli/build/commands/init/errors/ReservedNameError.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class ReservedNameError extends Error {
|
||||
constructor() {
|
||||
super('Not a valid name for a project. Please do not use the reserved word "React".');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = ReservedNameError;
|
||||
|
||||
//# sourceMappingURL=ReservedNameError.js.map
|
39
node_modules/@react-native-community/cli/build/commands/init/index.js
generated
vendored
Normal file
39
node_modules/@react-native-community/cli/build/commands/init/index.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _init = _interopRequireDefault(require("./init"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = {
|
||||
func: _init.default,
|
||||
detached: true,
|
||||
name: 'init <projectName>',
|
||||
description: 'Initialize a new React Native project named <projectName> in a directory of the same name.',
|
||||
options: [{
|
||||
name: '--version [string]',
|
||||
description: 'Shortcut for `--template react-native@version`'
|
||||
}, {
|
||||
name: '--template [string]',
|
||||
description: 'Uses a custom template. Valid arguments are: npm package, absolute directory prefixed with `file://`, Git repository or a tarball'
|
||||
}, {
|
||||
name: '--npm',
|
||||
description: 'Forces using npm for initialization'
|
||||
}, {
|
||||
name: '--directory [string]',
|
||||
description: 'Uses a custom directory instead of `<projectName>`.'
|
||||
}, {
|
||||
name: '--title [string]',
|
||||
description: 'Uses a custom app title name for application'
|
||||
}, {
|
||||
name: '--skip-install',
|
||||
description: 'Skips dependencies installation step'
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
257
node_modules/@react-native-community/cli/build/commands/init/init.js
generated
vendored
Normal file
257
node_modules/@react-native-community/cli/build/commands/init/init.js
generated
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _os() {
|
||||
const data = _interopRequireDefault(require("os"));
|
||||
|
||||
_os = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fsExtra() {
|
||||
const data = _interopRequireDefault(require("fs-extra"));
|
||||
|
||||
_fsExtra = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _minimist() {
|
||||
const data = _interopRequireDefault(require("minimist"));
|
||||
|
||||
_minimist = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mkdirp() {
|
||||
const data = _interopRequireDefault(require("mkdirp"));
|
||||
|
||||
_mkdirp = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _validate = require("./validate");
|
||||
|
||||
var _DirectoryAlreadyExistsError = _interopRequireDefault(require("./errors/DirectoryAlreadyExistsError"));
|
||||
|
||||
var _printRunInstructions = _interopRequireDefault(require("./printRunInstructions"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _template = require("./template");
|
||||
|
||||
var _editTemplate = require("./editTemplate");
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
var _installPods = _interopRequireDefault(require("../../tools/installPods"));
|
||||
|
||||
var _templateName = require("./templateName");
|
||||
|
||||
var _banner = _interopRequireDefault(require("./banner"));
|
||||
|
||||
var _loader = require("../../tools/loader");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const DEFAULT_VERSION = 'latest';
|
||||
|
||||
function doesDirectoryExist(dir) {
|
||||
return _fsExtra().default.existsSync(dir);
|
||||
}
|
||||
|
||||
async function setProjectDirectory(directory) {
|
||||
if (doesDirectoryExist(directory)) {
|
||||
throw new _DirectoryAlreadyExistsError.default(directory);
|
||||
}
|
||||
|
||||
try {
|
||||
_mkdirp().default.sync(directory);
|
||||
|
||||
process.chdir(directory);
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Error occurred while trying to create project directory.', error);
|
||||
}
|
||||
|
||||
return process.cwd();
|
||||
}
|
||||
|
||||
function adjustNameIfUrl(name, cwd) {
|
||||
// We use package manager to infer the name of the template module for us.
|
||||
// That's why we get it from temporary package.json, where the name is the
|
||||
// first and only dependency (hence 0).
|
||||
if (name.match(/https?:/)) {
|
||||
name = Object.keys(JSON.parse(_fsExtra().default.readFileSync(_path().default.join(cwd, './package.json'), 'utf8')).dependencies)[0];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
async function createFromTemplate({
|
||||
projectName,
|
||||
templateName,
|
||||
npm,
|
||||
directory,
|
||||
projectTitle,
|
||||
skipInstall
|
||||
}) {
|
||||
_cliTools().logger.debug('Initializing new project');
|
||||
|
||||
_cliTools().logger.log(_banner.default);
|
||||
|
||||
const projectDirectory = await setProjectDirectory(directory);
|
||||
const Loader = (0, _loader.getLoader)();
|
||||
const loader = new Loader({
|
||||
text: 'Downloading template'
|
||||
});
|
||||
|
||||
const templateSourceDir = _fsExtra().default.mkdtempSync(_path().default.join(_os().default.tmpdir(), 'rncli-init-template-'));
|
||||
|
||||
try {
|
||||
loader.start();
|
||||
let {
|
||||
uri,
|
||||
name
|
||||
} = await (0, _templateName.processTemplateName)(templateName);
|
||||
await (0, _template.installTemplatePackage)(uri, templateSourceDir, npm);
|
||||
loader.succeed();
|
||||
loader.start('Copying template');
|
||||
name = adjustNameIfUrl(name, templateSourceDir);
|
||||
const templateConfig = (0, _template.getTemplateConfig)(name, templateSourceDir);
|
||||
await (0, _template.copyTemplate)(name, templateConfig.templateDir, templateSourceDir);
|
||||
loader.succeed();
|
||||
loader.start('Processing template');
|
||||
(0, _editTemplate.changePlaceholderInTemplate)({
|
||||
projectName,
|
||||
projectTitle,
|
||||
placeholderName: templateConfig.placeholderName,
|
||||
placeholderTitle: templateConfig.titlePlaceholder
|
||||
});
|
||||
loader.succeed();
|
||||
const {
|
||||
postInitScript
|
||||
} = templateConfig;
|
||||
|
||||
if (postInitScript) {
|
||||
// Leaving trailing space because there may be stdout from the script
|
||||
loader.start('Executing post init script ');
|
||||
await (0, _template.executePostInitScript)(name, postInitScript, templateSourceDir);
|
||||
loader.succeed();
|
||||
}
|
||||
|
||||
if (!skipInstall) {
|
||||
await installDependencies({
|
||||
projectName,
|
||||
npm,
|
||||
loader,
|
||||
root: projectDirectory
|
||||
});
|
||||
} else {
|
||||
loader.succeed('Dependencies installation skipped');
|
||||
}
|
||||
} catch (e) {
|
||||
loader.fail();
|
||||
throw new Error(e);
|
||||
} finally {
|
||||
_fsExtra().default.removeSync(templateSourceDir);
|
||||
}
|
||||
}
|
||||
|
||||
async function installDependencies({
|
||||
projectName,
|
||||
npm,
|
||||
loader,
|
||||
root
|
||||
}) {
|
||||
loader.start('Installing dependencies');
|
||||
await PackageManager.installAll({
|
||||
preferYarn: !npm,
|
||||
silent: true,
|
||||
root
|
||||
});
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
await (0, _installPods.default)({
|
||||
projectName,
|
||||
loader
|
||||
});
|
||||
}
|
||||
|
||||
loader.succeed();
|
||||
}
|
||||
|
||||
async function createProject(projectName, directory, version, options) {
|
||||
const templateName = options.template || `react-native@${version}`;
|
||||
return createFromTemplate({
|
||||
projectName,
|
||||
templateName,
|
||||
npm: options.npm,
|
||||
directory,
|
||||
projectTitle: options.title,
|
||||
skipInstall: options.skipInstall
|
||||
});
|
||||
}
|
||||
|
||||
var initialize = async function initialize([projectName], options) {
|
||||
const root = process.cwd();
|
||||
(0, _validate.validateProjectName)(projectName);
|
||||
/**
|
||||
* Commander is stripping `version` from options automatically.
|
||||
* We have to use `minimist` to take that directly from `process.argv`
|
||||
*/
|
||||
|
||||
const version = (0, _minimist().default)(process.argv).version || DEFAULT_VERSION;
|
||||
|
||||
const directoryName = _path().default.relative(root, options.directory || projectName);
|
||||
|
||||
try {
|
||||
await createProject(projectName, directoryName, version, options);
|
||||
|
||||
const projectFolder = _path().default.join(root, directoryName);
|
||||
|
||||
(0, _printRunInstructions.default)(projectFolder, projectName);
|
||||
} catch (e) {
|
||||
_cliTools().logger.error(e.message);
|
||||
}
|
||||
};
|
||||
|
||||
exports.default = initialize;
|
||||
|
||||
//# sourceMappingURL=init.js.map
|
164
node_modules/@react-native-community/cli/build/commands/init/initCompat.js
generated
vendored
Normal file
164
node_modules/@react-native-community/cli/build/commands/init/initCompat.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _minimist() {
|
||||
const data = _interopRequireDefault(require("minimist"));
|
||||
|
||||
_minimist = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _process() {
|
||||
const data = _interopRequireDefault(require("process"));
|
||||
|
||||
_process = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _printRunInstructions = _interopRequireDefault(require("./printRunInstructions"));
|
||||
|
||||
var _templates = require("../../tools/generator/templates");
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _installPods = _interopRequireDefault(require("../../tools/installPods"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates the template for a React Native project given the provided
|
||||
* parameters:
|
||||
* @param projectDir Templates will be copied here.
|
||||
* @param argsOrName Project name or full list of custom arguments
|
||||
* for the generator.
|
||||
* @param options Command line options passed from the react-native-cli directly.
|
||||
* E.g. `{ version: '0.43.0', template: 'navigation' }`
|
||||
*/
|
||||
async function initCompat(projectDir, argsOrName) {
|
||||
const args = Array.isArray(argsOrName) ? argsOrName // argsOrName was e.g. ['AwesomeApp', '--verbose']
|
||||
: [argsOrName].concat(_process().default.argv.slice(4)); // argsOrName was e.g. 'AwesomeApp'
|
||||
// args array is e.g. ['AwesomeApp', '--verbose', '--template', 'navigation']
|
||||
|
||||
if (!args || args.length === 0) {
|
||||
_cliTools().logger.error('react-native init requires a project name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const newProjectName = args[0];
|
||||
const options = (0, _minimist().default)(args);
|
||||
|
||||
_cliTools().logger.info(`Setting up new React Native app in ${projectDir}`);
|
||||
|
||||
await generateProject(projectDir, newProjectName, options);
|
||||
}
|
||||
/**
|
||||
* Generates a new React Native project based on the template.
|
||||
* @param Absolute path at which the project folder should be created.
|
||||
* @param options Command line arguments parsed by minimist.
|
||||
*/
|
||||
|
||||
|
||||
async function generateProject(destinationRoot, newProjectName, options) {
|
||||
const pkgJson = require('react-native/package.json');
|
||||
|
||||
const reactVersion = pkgJson.peerDependencies.react;
|
||||
await (0, _templates.createProjectFromTemplate)(destinationRoot, newProjectName, options.template);
|
||||
|
||||
_cliTools().logger.info('Adding required dependencies');
|
||||
|
||||
await PackageManager.install([`react@${reactVersion}`], {
|
||||
root: destinationRoot
|
||||
});
|
||||
|
||||
_cliTools().logger.info('Adding required dev dependencies');
|
||||
|
||||
await PackageManager.installDev(['@babel/core', '@babel/runtime', '@react-native-community/eslint-config', 'eslint', 'jest', 'babel-jest', 'metro-react-native-babel-preset', `react-test-renderer@${reactVersion}`], {
|
||||
root: destinationRoot
|
||||
});
|
||||
addJestToPackageJson(destinationRoot);
|
||||
|
||||
if (_process().default.platform === 'darwin') {
|
||||
_cliTools().logger.info('Installing required CocoaPods dependencies');
|
||||
|
||||
await (0, _installPods.default)({
|
||||
projectName: newProjectName
|
||||
});
|
||||
}
|
||||
|
||||
(0, _printRunInstructions.default)(destinationRoot, newProjectName);
|
||||
}
|
||||
/**
|
||||
* Add Jest-related stuff to package.json, which was created by the react-native-cli.
|
||||
*/
|
||||
|
||||
|
||||
function addJestToPackageJson(destinationRoot) {
|
||||
const packageJSONPath = _path().default.join(destinationRoot, 'package.json');
|
||||
|
||||
const packageJSON = JSON.parse(_fs().default.readFileSync(packageJSONPath).toString());
|
||||
packageJSON.scripts.test = 'jest';
|
||||
packageJSON.scripts.lint = 'eslint .';
|
||||
packageJSON.jest = {
|
||||
preset: 'react-native'
|
||||
};
|
||||
|
||||
_fs().default.writeFileSync(packageJSONPath, `${JSON.stringify(packageJSON, null, 2)}\n`);
|
||||
}
|
||||
|
||||
var _default = initCompat;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=initCompat.js.map
|
86
node_modules/@react-native-community/cli/build/commands/init/printRunInstructions.js
generated
vendored
Normal file
86
node_modules/@react-native-community/cli/build/commands/init/printRunInstructions.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
function printRunInstructions(projectDir, projectName) {
|
||||
const iosProjectDir = _path().default.resolve(projectDir, 'ios');
|
||||
|
||||
const iosPodsFile = _path().default.resolve(iosProjectDir, `${projectName}.xcworkspace`);
|
||||
|
||||
const isUsingPods = _fs().default.existsSync(iosPodsFile);
|
||||
|
||||
const relativeXcodeProjectPath = _path().default.relative('..', isUsingPods ? iosPodsFile : _path().default.resolve(iosProjectDir, `${projectName}.xcodeproj`));
|
||||
|
||||
_cliTools().logger.log(`
|
||||
${_chalk().default.cyan(`Run instructions for ${_chalk().default.bold('iOS')}`)}:
|
||||
• cd "${projectDir}" && npx react-native run-ios
|
||||
${_chalk().default.dim('- or -')}
|
||||
• Open ${relativeXcodeProjectPath} in Xcode or run "xed -b ios"
|
||||
• Hit the Run button
|
||||
|
||||
${_chalk().default.green(`Run instructions for ${_chalk().default.bold('Android')}`)}:
|
||||
• Have an Android emulator running (quickest way to get started), or a device connected.
|
||||
• cd "${projectDir}" && npx react-native run-android
|
||||
|
||||
${_chalk().default.magenta(`Run instructions for ${_chalk().default.bold('Windows')} and ${_chalk().default.bold('macOS')}`)}:
|
||||
• See ${_chalk().default.underline('https://aka.ms/ReactNative')} for the latest up-to-date instructions.
|
||||
`);
|
||||
}
|
||||
|
||||
var _default = printRunInstructions;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=printRunInstructions.js.map
|
123
node_modules/@react-native-community/cli/build/commands/init/template.js
generated
vendored
Normal file
123
node_modules/@react-native-community/cli/build/commands/init/template.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.installTemplatePackage = installTemplatePackage;
|
||||
exports.getTemplateConfig = getTemplateConfig;
|
||||
exports.copyTemplate = copyTemplate;
|
||||
exports.executePostInitScript = executePostInitScript;
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
var _copyFiles = _interopRequireDefault(require("../../tools/copyFiles"));
|
||||
|
||||
var _replacePathSepForRegex = _interopRequireDefault(require("../../tools/replacePathSepForRegex"));
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
async function installTemplatePackage(templateName, root, npm) {
|
||||
_cliTools().logger.debug(`Installing template from ${templateName}`);
|
||||
|
||||
await PackageManager.init({
|
||||
preferYarn: !npm,
|
||||
silent: true,
|
||||
root
|
||||
});
|
||||
return PackageManager.install([templateName], {
|
||||
preferYarn: !npm,
|
||||
silent: true,
|
||||
root
|
||||
});
|
||||
}
|
||||
|
||||
function getTemplateConfig(templateName, templateSourceDir) {
|
||||
const configFilePath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, 'template.config.js');
|
||||
|
||||
_cliTools().logger.debug(`Getting config from ${configFilePath}`);
|
||||
|
||||
if (!_fs().default.existsSync(configFilePath)) {
|
||||
throw new (_cliTools().CLIError)(`Couldn't find the "${configFilePath} file inside "${templateName}" template. Please make sure the template is valid.
|
||||
Read more: ${_chalk().default.underline.dim('https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template')}`);
|
||||
}
|
||||
|
||||
return require(configFilePath);
|
||||
}
|
||||
|
||||
async function copyTemplate(templateName, templateDir, templateSourceDir) {
|
||||
const templatePath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, templateDir);
|
||||
|
||||
_cliTools().logger.debug(`Copying template from ${templatePath}`);
|
||||
|
||||
let regexStr = _path().default.resolve(templatePath, 'node_modules');
|
||||
|
||||
await (0, _copyFiles.default)(templatePath, process.cwd(), {
|
||||
exclude: [new RegExp((0, _replacePathSepForRegex.default)(regexStr))]
|
||||
});
|
||||
}
|
||||
|
||||
function executePostInitScript(templateName, postInitScript, templateSourceDir) {
|
||||
const scriptPath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, postInitScript);
|
||||
|
||||
_cliTools().logger.debug(`Executing post init script located ${scriptPath}`);
|
||||
|
||||
return (0, _execa().default)(scriptPath, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=template.js.map
|
140
node_modules/@react-native-community/cli/build/commands/init/templateName.js
generated
vendored
Normal file
140
node_modules/@react-native-community/cli/build/commands/init/templateName.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.processTemplateName = processTemplateName;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _url() {
|
||||
const data = require("url");
|
||||
|
||||
_url = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const FILE_PROTOCOL = /file:/;
|
||||
const TARBALL = /\.tgz$/;
|
||||
const VERSION_POSTFIX = /(.*)(-\d+\.\d+\.\d+)/;
|
||||
const VERSIONED_PACKAGE = /(@?.+)(@)(.+)/;
|
||||
|
||||
function handleFileProtocol(filePath) {
|
||||
let uri = new (_url().URL)(filePath).pathname;
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// On Windows, the pathname has an extra / at the start, so remove that
|
||||
uri = uri.substring(1);
|
||||
}
|
||||
|
||||
if (!_fs().default.existsSync(uri)) {
|
||||
throw new (_cliTools().CLIError)(`Failed to retrieve template name. The specified template directory path "${uri}" does not exist or is invalid.`);
|
||||
}
|
||||
|
||||
const packageJsonPath = _path().default.join(uri, 'package.json');
|
||||
|
||||
let packageJson;
|
||||
|
||||
try {
|
||||
packageJson = JSON.parse(_fs().default.readFileSync(packageJsonPath, {
|
||||
encoding: 'utf8'
|
||||
}));
|
||||
} catch (_unused) {
|
||||
throw new (_cliTools().CLIError)('Failed to retrieve template name. We expect the template directory to include "package.json" file, but it was not found.');
|
||||
}
|
||||
|
||||
if (!packageJson || !packageJson.name) {
|
||||
throw new (_cliTools().CLIError)(`Failed to retrieve template name. We expect the "package.json" of the template to include the "name" property, but we found "${packageJson ? packageJson.name : 'undefined'}" which is invalid.`);
|
||||
}
|
||||
|
||||
return {
|
||||
uri,
|
||||
name: packageJson.name
|
||||
};
|
||||
}
|
||||
|
||||
function handleTarball(filePath) {
|
||||
if (!_fs().default.existsSync(filePath)) {
|
||||
throw new (_cliTools().CLIError)(`Failed to retrieve tarball name. The specified tarball path "${filePath}" does not exist or is invalid.`);
|
||||
}
|
||||
|
||||
const nameWithVersion = _path().default.parse(_path().default.basename(filePath)).name;
|
||||
|
||||
const tarballVersionMatch = nameWithVersion.match(VERSION_POSTFIX);
|
||||
|
||||
if (!tarballVersionMatch) {
|
||||
throw new (_cliTools().CLIError)(`Failed to retrieve tarball name. We expect the tarball to include package name and version, e.g.: "template-name-1.2.3-rc.0.tgz", but received: "${nameWithVersion}".`);
|
||||
}
|
||||
|
||||
return {
|
||||
uri: filePath,
|
||||
name: tarballVersionMatch[1]
|
||||
};
|
||||
}
|
||||
|
||||
function handleVersionedPackage(versionedPackage) {
|
||||
const versionedPackageMatch = versionedPackage.match(VERSIONED_PACKAGE);
|
||||
|
||||
if (!versionedPackageMatch) {
|
||||
throw new (_cliTools().CLIError)(`Failed to retrieve package name. We expect the package to include name and version, e.g.: "template-name@1.2.3-rc.0", but received: "${versionedPackage}".`);
|
||||
}
|
||||
|
||||
return {
|
||||
uri: versionedPackage,
|
||||
name: versionedPackageMatch[1]
|
||||
};
|
||||
}
|
||||
|
||||
function processTemplateName(templateName) {
|
||||
if (templateName.match(TARBALL)) {
|
||||
return handleTarball(templateName);
|
||||
}
|
||||
|
||||
if (templateName.match(FILE_PROTOCOL)) {
|
||||
return handleFileProtocol(templateName);
|
||||
}
|
||||
|
||||
if (templateName.match(VERSIONED_PACKAGE)) {
|
||||
return handleVersionedPackage(templateName);
|
||||
}
|
||||
|
||||
return {
|
||||
uri: templateName,
|
||||
name: templateName
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=templateName.js.map
|
37
node_modules/@react-native-community/cli/build/commands/init/validate.js
generated
vendored
Normal file
37
node_modules/@react-native-community/cli/build/commands/init/validate.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validateProjectName = validateProjectName;
|
||||
|
||||
var _InvalidNameError = _interopRequireDefault(require("./errors/InvalidNameError"));
|
||||
|
||||
var _ReservedNameError = _interopRequireDefault(require("./errors/ReservedNameError"));
|
||||
|
||||
var _HelloWorldError = _interopRequireDefault(require("./errors/HelloWorldError"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const NAME_REGEX = /^[$A-Z_][0-9A-Z_$]*$/i; // ref: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
|
||||
|
||||
const javaKeywords = ['abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default', 'goto', 'package', 'synchronized', 'boolean', 'do', 'if', 'private', 'this', 'break', 'double', 'implements', 'protected', 'throw', 'byte', 'else', 'import', 'public', 'throws', 'case', 'enum', 'instanceof', 'return', 'transient', 'catch', 'extends', 'int', 'short', 'try', 'char', 'final', 'interface', 'static', 'void', 'class', 'finally', 'long', 'strictfp', 'volatile', 'const', 'float', 'native', 'super', 'while'];
|
||||
const reservedNames = ['react', 'react-native', ...javaKeywords];
|
||||
|
||||
function validateProjectName(name) {
|
||||
if (!String(name).match(NAME_REGEX)) {
|
||||
throw new _InvalidNameError.default(name);
|
||||
}
|
||||
|
||||
const lowerCaseName = name.toLowerCase();
|
||||
|
||||
if (reservedNames.includes(lowerCaseName)) {
|
||||
throw new _ReservedNameError.default();
|
||||
}
|
||||
|
||||
if (name.match(/helloworld/gi)) {
|
||||
throw new _HelloWorldError.default();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=validate.js.map
|
64
node_modules/@react-native-community/cli/build/commands/install/install.js
generated
vendored
Normal file
64
node_modules/@react-native-community/cli/build/commands/install/install.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
var _link = _interopRequireDefault(require("../link/link"));
|
||||
|
||||
var _config = _interopRequireDefault(require("../../tools/config"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
async function install(args, ctx) {
|
||||
const name = args[0];
|
||||
|
||||
_cliTools().logger.info(`Installing "${name}"...`);
|
||||
|
||||
await PackageManager.install([name], {
|
||||
root: ctx.root
|
||||
}); // Reload configuration to see newly installed dependency
|
||||
|
||||
const newConfig = (0, _config.default)();
|
||||
|
||||
_cliTools().logger.info(`Linking "${name}"...`);
|
||||
|
||||
await _link.default.func([name], newConfig, {
|
||||
platforms: undefined
|
||||
});
|
||||
|
||||
_cliTools().logger.success(`Successfully installed and linked "${name}"`);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
func: install,
|
||||
description: 'install and link native dependencies',
|
||||
name: 'install <packageName>'
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=install.js.map
|
58
node_modules/@react-native-community/cli/build/commands/install/uninstall.js
generated
vendored
Normal file
58
node_modules/@react-native-community/cli/build/commands/install/uninstall.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
var _unlink = _interopRequireDefault(require("../link/unlink"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
async function uninstall(args, ctx) {
|
||||
const name = args[0];
|
||||
|
||||
_cliTools().logger.info(`Unlinking "${name}"...`);
|
||||
|
||||
await _unlink.default.func([name], ctx, {});
|
||||
|
||||
_cliTools().logger.info(`Uninstalling "${name}"...`);
|
||||
|
||||
await PackageManager.uninstall([name], {
|
||||
root: ctx.root
|
||||
});
|
||||
|
||||
_cliTools().logger.success(`Successfully uninstalled and unlinked "${name}"`);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
func: uninstall,
|
||||
description: 'uninstall and unlink native dependencies',
|
||||
name: 'uninstall <packageName>'
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=uninstall.js.map
|
16
node_modules/@react-native-community/cli/build/commands/link/getPlatformName.js
generated
vendored
Normal file
16
node_modules/@react-native-community/cli/build/commands/link/getPlatformName.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getPlatformName;
|
||||
const names = {
|
||||
ios: 'iOS',
|
||||
android: 'Android'
|
||||
};
|
||||
|
||||
function getPlatformName(name) {
|
||||
return names[name] || name;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=getPlatformName.js.map
|
140
node_modules/@react-native-community/cli/build/commands/link/link.js
generated
vendored
Normal file
140
node_modules/@react-native-community/cli/build/commands/link/link.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.func = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _lodash() {
|
||||
const data = require("lodash");
|
||||
|
||||
_lodash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _getPlatformName = _interopRequireDefault(require("./getPlatformName"));
|
||||
|
||||
var _linkDependency = _interopRequireDefault(require("./linkDependency"));
|
||||
|
||||
var _linkAssets = _interopRequireDefault(require("./linkAssets"));
|
||||
|
||||
var _linkAll = _interopRequireDefault(require("./linkAll"));
|
||||
|
||||
var _makeHook = _interopRequireDefault(require("./makeHook"));
|
||||
|
||||
var _printDeprecationWarning = _interopRequireDefault(require("./printDeprecationWarning"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Updates project and links all dependencies to it.
|
||||
*
|
||||
* @param args If optional argument [packageName] is provided,
|
||||
* only that package is processed.
|
||||
*/
|
||||
async function link([rawPackageName], ctx, opts) {
|
||||
let platforms = ctx.platforms;
|
||||
let project = ctx.project;
|
||||
|
||||
if (opts.platforms) {
|
||||
// @ts-ignore
|
||||
platforms = (0, _lodash().pick)(platforms, opts.platforms);
|
||||
|
||||
_cliTools().logger.debug('Skipping selected platforms');
|
||||
}
|
||||
|
||||
_cliTools().logger.debug('Available platforms: ' + `${Object.keys(platforms).map(_getPlatformName.default).join(', ')}`);
|
||||
|
||||
if (rawPackageName === undefined) {
|
||||
_cliTools().logger.debug('No package name provided, will link all possible assets.');
|
||||
|
||||
return (0, _linkAll.default)(ctx, {
|
||||
linkDeps: opts.all,
|
||||
linkAssets: true
|
||||
});
|
||||
}
|
||||
|
||||
(0, _printDeprecationWarning.default)('react-native link [packageName]'); // Trim the version / tag out of the package name (eg. package@latest)
|
||||
|
||||
const packageName = rawPackageName.replace(/^(.+?)(@.+?)$/gi, '$1');
|
||||
|
||||
if (!Object.keys(ctx.dependencies).includes(packageName)) {
|
||||
throw new (_cliTools().CLIError)(`
|
||||
Unknown dependency. Make sure that the package you are trying to link is
|
||||
already installed in your "node_modules" and present in your "package.json" dependencies.
|
||||
`);
|
||||
}
|
||||
|
||||
const {
|
||||
[packageName]: dependency
|
||||
} = ctx.dependencies;
|
||||
|
||||
_cliTools().logger.debug(`Package to link: ${rawPackageName}`);
|
||||
|
||||
try {
|
||||
if (dependency.hooks.prelink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.prelink)();
|
||||
}
|
||||
|
||||
await (0, _linkDependency.default)(platforms, project, dependency);
|
||||
|
||||
if (dependency.hooks.postlink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.postlink)();
|
||||
}
|
||||
|
||||
await (0, _linkAssets.default)(platforms, project, dependency.assets);
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)(`Linking "${_chalk().default.bold(dependency.name)}" failed.`, error);
|
||||
}
|
||||
}
|
||||
|
||||
const func = link;
|
||||
exports.func = func;
|
||||
var _default = {
|
||||
func: link,
|
||||
description: 'links assets and optionally native modules',
|
||||
name: 'link [packageName]',
|
||||
options: [{
|
||||
name: '--platforms [list]',
|
||||
description: 'Scope linking to specified platforms',
|
||||
parse: val => val.toLowerCase().split(',')
|
||||
}, {
|
||||
name: '--all [boolean]',
|
||||
description: 'Link all native modules and assets',
|
||||
parse: val => val.toLowerCase().split(',')
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=link.js.map
|
106
node_modules/@react-native-community/cli/build/commands/link/linkAll.js
generated
vendored
Normal file
106
node_modules/@react-native-community/cli/build/commands/link/linkAll.js
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _lodash() {
|
||||
const data = require("lodash");
|
||||
|
||||
_lodash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require("path"));
|
||||
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _linkAssets = _interopRequireDefault(require("./linkAssets"));
|
||||
|
||||
var _linkDependency = _interopRequireDefault(require("./linkDependency"));
|
||||
|
||||
var _makeHook = _interopRequireDefault(require("./makeHook"));
|
||||
|
||||
var _printDeprecationWarning = _interopRequireDefault(require("./printDeprecationWarning"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
const dedupeAssets = assets => (0, _lodash().uniqBy)(assets, asset => path().basename(asset));
|
||||
|
||||
async function linkAll(config, options) {
|
||||
if (options.linkDeps) {
|
||||
(0, _printDeprecationWarning.default)('react-native link --all');
|
||||
|
||||
_cliTools().logger.debug('Linking all dependencies');
|
||||
|
||||
for (let key in config.dependencies) {
|
||||
const dependency = config.dependencies[key];
|
||||
|
||||
try {
|
||||
if (dependency.hooks.prelink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.prelink)();
|
||||
}
|
||||
|
||||
await (0, _linkDependency.default)(config.platforms, config.project, dependency);
|
||||
|
||||
if (dependency.hooks.postlink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.postlink)();
|
||||
}
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)(`Linking "${_chalk().default.bold(dependency.name)}" failed.`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.linkAssets) {
|
||||
_cliTools().logger.debug('Linking all assets');
|
||||
|
||||
const projectAssets = config.assets;
|
||||
const assets = dedupeAssets(Object.keys(config.dependencies).reduce((acc, dependency) => acc.concat(config.dependencies[dependency].assets), projectAssets));
|
||||
|
||||
try {
|
||||
(0, _linkAssets.default)(config.platforms, config.project, assets);
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Linking assets failed.', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _default = linkAll;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=linkAll.js.map
|
48
node_modules/@react-native-community/cli/build/commands/link/linkAssets.js
generated
vendored
Normal file
48
node_modules/@react-native-community/cli/build/commands/link/linkAssets.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = linkAssets;
|
||||
|
||||
function _lodash() {
|
||||
const data = require("lodash");
|
||||
|
||||
_lodash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function linkAssets(platforms, project, assets) {
|
||||
if ((0, _lodash().isEmpty)(assets)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(platforms || {}).forEach(platform => {
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
|
||||
if (!linkConfig || !linkConfig.copyAssets || !project[platform]) {
|
||||
return;
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Linking assets to ${platform} project`);
|
||||
|
||||
linkConfig.copyAssets(assets, project[platform]);
|
||||
});
|
||||
|
||||
_cliTools().logger.success('Assets have been successfully linked to your project');
|
||||
}
|
||||
|
||||
//# sourceMappingURL=linkAssets.js.map
|
69
node_modules/@react-native-community/cli/build/commands/link/linkDependency.js
generated
vendored
Normal file
69
node_modules/@react-native-community/cli/build/commands/link/linkDependency.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = linkDependency;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _pollParams = _interopRequireDefault(require("./pollParams"));
|
||||
|
||||
var _getPlatformName = _interopRequireDefault(require("./getPlatformName"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
async function linkDependency(platforms, project, dependency) {
|
||||
const params = await (0, _pollParams.default)(dependency.params);
|
||||
Object.keys(platforms || {}).forEach(platform => {
|
||||
const projectConfig = project[platform];
|
||||
const dependencyConfig = dependency.platforms[platform];
|
||||
|
||||
if (!projectConfig || !dependencyConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
name
|
||||
} = dependency;
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
|
||||
if (!linkConfig || !linkConfig.isInstalled || !linkConfig.register) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isInstalled = linkConfig.isInstalled(projectConfig, name, dependencyConfig);
|
||||
|
||||
if (isInstalled) {
|
||||
_cliTools().logger.info(`${(0, _getPlatformName.default)(platform)} module "${_chalk().default.bold(name)}" is already linked`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Linking "${_chalk().default.bold(name)}" ${(0, _getPlatformName.default)(platform)} dependency`);
|
||||
|
||||
linkConfig.register(name, dependencyConfig, params, projectConfig);
|
||||
|
||||
_cliTools().logger.info(`${(0, _getPlatformName.default)(platform)} module "${_chalk().default.bold(dependency.name)}" has been successfully linked`);
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=linkDependency.js.map
|
30
node_modules/@react-native-community/cli/build/commands/link/makeHook.js
generated
vendored
Normal file
30
node_modules/@react-native-community/cli/build/commands/link/makeHook.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = makeHook;
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function makeHook(command) {
|
||||
return () => {
|
||||
const args = command.split(' ');
|
||||
const cmd = args.shift();
|
||||
return (0, _execa().default)(cmd, args, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=makeHook.js.map
|
36
node_modules/@react-native-community/cli/build/commands/link/pollParams.js
generated
vendored
Normal file
36
node_modules/@react-native-community/cli/build/commands/link/pollParams.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _inquirer() {
|
||||
const data = require("inquirer");
|
||||
|
||||
_inquirer = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// @ts-ignore untyped
|
||||
var _default = questions => new Promise((resolve, reject) => {
|
||||
if (!questions) {
|
||||
resolve({});
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _inquirer().prompt)(questions).then(resolve, reject);
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=pollParams.js.map
|
34
node_modules/@react-native-community/cli/build/commands/link/printDeprecationWarning.js
generated
vendored
Normal file
34
node_modules/@react-native-community/cli/build/commands/link/printDeprecationWarning.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = printDeprecationWarning;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function printDeprecationWarning(command) {
|
||||
_cliTools().logger.warn(`Calling ${_chalk().default.bold(command)} is deprecated in favor of autolinking. It will be removed in the next major release.\nAutolinking documentation: ${_chalk().default.dim.underline('https://github.com/react-native-community/cli/blob/master/docs/autolinking.md')}`);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=printDeprecationWarning.js.map
|
157
node_modules/@react-native-community/cli/build/commands/link/unlink.js
generated
vendored
Normal file
157
node_modules/@react-native-community/cli/build/commands/link/unlink.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _lodash() {
|
||||
const data = require("lodash");
|
||||
|
||||
_lodash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _getPlatformName = _interopRequireDefault(require("./getPlatformName"));
|
||||
|
||||
var _makeHook = _interopRequireDefault(require("./makeHook"));
|
||||
|
||||
var _printDeprecationWarning = _interopRequireDefault(require("./printDeprecationWarning"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const unlinkDependency = (platforms, project, dependency, packageName, otherDependencies) => {
|
||||
(0, _printDeprecationWarning.default)('react-native unlink [packageName]');
|
||||
Object.keys(platforms || {}).forEach(platform => {
|
||||
const projectConfig = project[platform];
|
||||
const dependencyConfig = dependency.platforms[platform];
|
||||
|
||||
if (!projectConfig || !dependencyConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
|
||||
if (!linkConfig || !linkConfig.isInstalled || !linkConfig.unregister) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isInstalled = linkConfig.isInstalled(projectConfig, packageName, dependencyConfig);
|
||||
|
||||
if (!isInstalled) {
|
||||
_cliTools().logger.info(`${(0, _getPlatformName.default)(platform)} module "${packageName}" is not installed`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Unlinking "${packageName}" ${(0, _getPlatformName.default)(platform)} dependency`);
|
||||
|
||||
linkConfig.unregister(packageName, dependencyConfig, projectConfig, otherDependencies);
|
||||
|
||||
_cliTools().logger.info(`${(0, _getPlatformName.default)(platform)} module "${dependency.name}" has been successfully unlinked`);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Updates project and unlink specific dependency
|
||||
*
|
||||
* If optional argument [packageName] is provided, it's the only one
|
||||
* that's checked
|
||||
*/
|
||||
|
||||
|
||||
async function unlink(args, ctx, opts) {
|
||||
const packageName = args[0];
|
||||
let platforms = ctx.platforms;
|
||||
|
||||
if (opts.platforms) {
|
||||
// @ts-ignore
|
||||
platforms = (0, _lodash().pick)(platforms, opts.platforms);
|
||||
|
||||
_cliTools().logger.debug('Skipping selected platforms');
|
||||
}
|
||||
|
||||
_cliTools().logger.debug(`Available platforms: ${Object.keys(platforms).map(_getPlatformName.default).join(', ')}`);
|
||||
|
||||
const {
|
||||
[packageName]: dependency,
|
||||
...otherDependencies
|
||||
} = ctx.dependencies;
|
||||
|
||||
if (!dependency) {
|
||||
throw new (_cliTools().CLIError)(`
|
||||
Failed to unlink "${packageName}". It appears that the project is not linked yet.
|
||||
`);
|
||||
}
|
||||
|
||||
const dependencies = (0, _lodash().values)(otherDependencies);
|
||||
|
||||
try {
|
||||
if (dependency.hooks.preunlink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.preunlink)();
|
||||
}
|
||||
|
||||
unlinkDependency(platforms, ctx.project, dependency, packageName, dependencies);
|
||||
|
||||
if (dependency.hooks.postunlink) {
|
||||
await (0, _makeHook.default)(dependency.hooks.postunlink)();
|
||||
}
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)(`Something went wrong while unlinking. Reason ${error.message}`, error);
|
||||
} // @todo move all these to above try/catch
|
||||
// @todo it is possible we could be unlinking some project assets in case of duplicate
|
||||
|
||||
|
||||
const assets = (0, _lodash().difference)(dependency.assets, (0, _lodash().flatMap)(dependencies, d => d.assets));
|
||||
|
||||
if (assets.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(platforms || {}).forEach(platform => {
|
||||
const projectConfig = ctx.project[platform];
|
||||
const linkConfig = platforms[platform] && platforms[platform].linkConfig && platforms[platform].linkConfig();
|
||||
|
||||
if (!linkConfig || !linkConfig.unlinkAssets || !projectConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Unlinking assets from ${platform} project`);
|
||||
|
||||
linkConfig.unlinkAssets(assets, projectConfig);
|
||||
});
|
||||
|
||||
_cliTools().logger.info(`${packageName} assets has been successfully unlinked from your project`);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
func: unlink,
|
||||
description: 'unlink native dependency',
|
||||
name: 'unlink <packageName>',
|
||||
options: [{
|
||||
name: '--platforms [list]',
|
||||
description: 'Scope unlinking to specified platforms',
|
||||
parse: val => val.toLowerCase().split(',')
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=unlink.js.map
|
167
node_modules/@react-native-community/cli/build/commands/start/runServer.js
generated
vendored
Normal file
167
node_modules/@react-native-community/cli/build/commands/start/runServer.js
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _metro() {
|
||||
const data = _interopRequireDefault(require("metro"));
|
||||
|
||||
_metro = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _metroCore() {
|
||||
const data = require("metro-core");
|
||||
|
||||
_metroCore = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliServerApi() {
|
||||
const data = require("@react-native-community/cli-server-api");
|
||||
|
||||
_cliServerApi = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig"));
|
||||
|
||||
var _releaseChecker = _interopRequireDefault(require("../../tools/releaseChecker"));
|
||||
|
||||
var _watchMode = _interopRequireDefault(require("./watchMode"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// @ts-ignore untyped metro
|
||||
// @ts-ignore untyped metro
|
||||
async function runServer(_argv, ctx, args) {
|
||||
let reportEvent;
|
||||
const terminal = new (_metroCore().Terminal)(process.stdout);
|
||||
const ReporterImpl = getReporterImpl(args.customLogReporterPath);
|
||||
const terminalReporter = new ReporterImpl(terminal);
|
||||
const reporter = {
|
||||
update(event) {
|
||||
terminalReporter.update(event);
|
||||
|
||||
if (reportEvent) {
|
||||
reportEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
const metroConfig = await (0, _loadMetroConfig.default)(ctx, {
|
||||
config: args.config,
|
||||
maxWorkers: args.maxWorkers,
|
||||
port: args.port,
|
||||
resetCache: args.resetCache,
|
||||
watchFolders: args.watchFolders,
|
||||
projectRoot: args.projectRoot,
|
||||
sourceExts: args.sourceExts,
|
||||
reporter
|
||||
});
|
||||
|
||||
if (args.assetPlugins) {
|
||||
metroConfig.transformer.assetPlugins = args.assetPlugins.map(plugin => require.resolve(plugin));
|
||||
}
|
||||
|
||||
const {
|
||||
middleware,
|
||||
attachToServer
|
||||
} = (0, _cliServerApi().createDevServerMiddleware)({
|
||||
host: args.host,
|
||||
port: metroConfig.server.port,
|
||||
watchFolders: metroConfig.watchFolders
|
||||
});
|
||||
middleware.use(_cliServerApi().indexPageMiddleware);
|
||||
const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;
|
||||
|
||||
metroConfig.server.enhanceMiddleware = (metroMiddleware, server) => {
|
||||
if (customEnhanceMiddleware) {
|
||||
metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);
|
||||
}
|
||||
|
||||
return middleware.use(metroMiddleware);
|
||||
};
|
||||
|
||||
const serverInstance = await _metro().default.runServer(metroConfig, {
|
||||
host: args.host,
|
||||
secure: args.https,
|
||||
secureCert: args.cert,
|
||||
secureKey: args.key,
|
||||
hmrEnabled: true
|
||||
});
|
||||
const {
|
||||
messageSocket,
|
||||
eventsSocket
|
||||
} = attachToServer(serverInstance);
|
||||
reportEvent = eventsSocket.reportEvent;
|
||||
|
||||
if (args.interactive) {
|
||||
(0, _watchMode.default)(messageSocket);
|
||||
} // In Node 8, the default keep-alive for an HTTP connection is 5 seconds. In
|
||||
// early versions of Node 8, this was implemented in a buggy way which caused
|
||||
// some HTTP responses (like those containing large JS bundles) to be
|
||||
// terminated early.
|
||||
//
|
||||
// As a workaround, arbitrarily increase the keep-alive from 5 to 30 seconds,
|
||||
// which should be enough to send even the largest of JS bundles.
|
||||
//
|
||||
// For more info: https://github.com/nodejs/node/issues/13391
|
||||
//
|
||||
|
||||
|
||||
serverInstance.keepAliveTimeout = 30000;
|
||||
await (0, _releaseChecker.default)(ctx.root);
|
||||
}
|
||||
|
||||
function getReporterImpl(customLogReporterPath) {
|
||||
if (customLogReporterPath === undefined) {
|
||||
return require('metro/src/lib/TerminalReporter');
|
||||
}
|
||||
|
||||
try {
|
||||
// First we let require resolve it, so we can require packages in node_modules
|
||||
// as expected. eg: require('my-package/reporter');
|
||||
return require(customLogReporterPath);
|
||||
} catch (e) {
|
||||
if (e.code !== 'MODULE_NOT_FOUND') {
|
||||
throw e;
|
||||
} // If that doesn't work, then we next try relative to the cwd, eg:
|
||||
// require('./reporter');
|
||||
|
||||
|
||||
return require(_path().default.resolve(customLogReporterPath));
|
||||
}
|
||||
}
|
||||
|
||||
var _default = runServer;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=runServer.js.map
|
91
node_modules/@react-native-community/cli/build/commands/start/start.js
generated
vendored
Normal file
91
node_modules/@react-native-community/cli/build/commands/start/start.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _runServer = _interopRequireDefault(require("./runServer"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
var _default = {
|
||||
name: 'start',
|
||||
func: _runServer.default,
|
||||
description: 'starts the webserver',
|
||||
options: [{
|
||||
name: '--port [number]',
|
||||
parse: val => Number(val)
|
||||
}, {
|
||||
name: '--host [string]',
|
||||
default: ''
|
||||
}, {
|
||||
name: '--projectRoot [path]',
|
||||
description: 'Path to a custom project root',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}, {
|
||||
name: '--watchFolders [list]',
|
||||
description: 'Specify any additional folders to be added to the watch list',
|
||||
parse: val => val.split(',').map(folder => _path().default.resolve(folder))
|
||||
}, {
|
||||
name: '--assetPlugins [list]',
|
||||
description: 'Specify any additional asset plugins to be used by the packager by full filepath',
|
||||
parse: val => val.split(',')
|
||||
}, {
|
||||
name: '--sourceExts [list]',
|
||||
description: 'Specify any additional source extensions to be used by the packager',
|
||||
parse: val => val.split(',')
|
||||
}, {
|
||||
name: '--max-workers [number]',
|
||||
description: 'Specifies the maximum number of workers the worker-pool ' + 'will spawn for transforming files. This defaults to the number of the ' + 'cores available on your machine.',
|
||||
parse: workers => Number(workers)
|
||||
}, {
|
||||
name: '--transformer [string]',
|
||||
description: 'Specify a custom transformer to be used'
|
||||
}, {
|
||||
name: '--reset-cache, --resetCache',
|
||||
description: 'Removes cached files'
|
||||
}, {
|
||||
name: '--custom-log-reporter-path, --customLogReporterPath [string]',
|
||||
description: 'Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter'
|
||||
}, {
|
||||
name: '--verbose',
|
||||
description: 'Enables logging'
|
||||
}, {
|
||||
name: '--https',
|
||||
description: 'Enables https connections to the server'
|
||||
}, {
|
||||
name: '--key [path]',
|
||||
description: 'Path to custom SSL key'
|
||||
}, {
|
||||
name: '--cert [path]',
|
||||
description: 'Path to custom SSL cert'
|
||||
}, {
|
||||
name: '--config [string]',
|
||||
description: 'Path to the CLI configuration file',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}, {
|
||||
name: '--no-interactive',
|
||||
description: 'Disables interactive mode'
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=start.js.map
|
89
node_modules/@react-native-community/cli/build/commands/start/watchMode.js
generated
vendored
Normal file
89
node_modules/@react-native-community/cli/build/commands/start/watchMode.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _readline() {
|
||||
const data = _interopRequireDefault(require("readline"));
|
||||
|
||||
_readline = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _hookStdout = _interopRequireDefault(require("../../tools/hookStdout"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function printWatchModeInstructions() {
|
||||
_cliTools().logger.log('\n\nTo reload the app press "r"\nTo open developer menu press "d"');
|
||||
}
|
||||
|
||||
function enableWatchMode(messageSocket) {
|
||||
// We need to set this to true to catch key presses individually.
|
||||
// As a result we have to implement our own method for exiting
|
||||
// and other commands (e.g. ctrl+c & ctrl+z)
|
||||
if (!process.stdin.setRawMode) {
|
||||
_cliTools().logger.debug('Watch mode is not supported in this environment');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_readline().default.emitKeypressEvents(process.stdin);
|
||||
|
||||
process.stdin.setRawMode(true); // We have no way of knowing when the dependency graph is done loading
|
||||
// except by hooking into stdout itself. We want to print instructions
|
||||
// right after its done loading.
|
||||
|
||||
const restore = (0, _hookStdout.default)(output => {
|
||||
if (output.includes('Learn once, write anywhere')) {
|
||||
printWatchModeInstructions();
|
||||
restore();
|
||||
}
|
||||
});
|
||||
process.stdin.on('keypress', (_key, data) => {
|
||||
const {
|
||||
ctrl,
|
||||
name
|
||||
} = data;
|
||||
|
||||
if (ctrl === true) {
|
||||
switch (name) {
|
||||
case 'c':
|
||||
process.exit();
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
process.emit('SIGTSTP');
|
||||
break;
|
||||
}
|
||||
} else if (name === 'r') {
|
||||
messageSocket.broadcast('reload', null);
|
||||
|
||||
_cliTools().logger.info('Reloading app...');
|
||||
} else if (name === 'd') {
|
||||
messageSocket.broadcast('devMenu', null);
|
||||
|
||||
_cliTools().logger.info('Opening developer menu...');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var _default = enableWatchMode;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=watchMode.js.map
|
396
node_modules/@react-native-community/cli/build/commands/upgrade/upgrade.js
generated
vendored
Normal file
396
node_modules/@react-native-community/cli/build/commands/upgrade/upgrade.js
generated
vendored
Normal file
@ -0,0 +1,396 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _semver() {
|
||||
const data = _interopRequireDefault(require("semver"));
|
||||
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
||||
|
||||
var _installPods = _interopRequireDefault(require("../../tools/installPods"));
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.0-rc.3
|
||||
const webDiffUrl = 'https://react-native-community.github.io/upgrade-helper';
|
||||
const rawDiffUrl = 'https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs';
|
||||
|
||||
const isConnected = output => {
|
||||
// there is no reliable way of checking for internet connectivity, so we should just
|
||||
// read the output from npm (to check for connectivity errors) which is faster and relatively more reliable.
|
||||
return !output.includes('the host is inaccessible');
|
||||
};
|
||||
|
||||
const checkForErrors = output => {
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isConnected(output)) {
|
||||
throw new (_cliTools().CLIError)('Upgrade failed. You do not seem to have an internet connection.');
|
||||
}
|
||||
|
||||
if (output.includes('npm ERR')) {
|
||||
throw new (_cliTools().CLIError)(`Upgrade failed with the following errors:\n${output}`);
|
||||
}
|
||||
|
||||
if (output.includes('npm WARN')) {
|
||||
_cliTools().logger.warn(output);
|
||||
}
|
||||
};
|
||||
|
||||
const getLatestRNVersion = async () => {
|
||||
_cliTools().logger.info('No version passed. Fetching latest...');
|
||||
|
||||
const {
|
||||
stdout,
|
||||
stderr
|
||||
} = await (0, _execa().default)('npm', ['info', 'react-native', 'version']);
|
||||
checkForErrors(stderr);
|
||||
return stdout;
|
||||
};
|
||||
|
||||
const getRNPeerDeps = async version => {
|
||||
const {
|
||||
stdout,
|
||||
stderr
|
||||
} = await (0, _execa().default)('npm', ['info', `react-native@${version}`, 'peerDependencies', '--json']);
|
||||
checkForErrors(stderr);
|
||||
return JSON.parse(stdout);
|
||||
};
|
||||
|
||||
const getPatch = async (currentVersion, newVersion, config) => {
|
||||
let patch;
|
||||
|
||||
_cliTools().logger.info(`Fetching diff between v${currentVersion} and v${newVersion}...`);
|
||||
|
||||
try {
|
||||
const {
|
||||
data
|
||||
} = await (0, _cliTools().fetch)(`${rawDiffUrl}/${currentVersion}..${newVersion}.diff`);
|
||||
patch = data;
|
||||
} catch (error) {
|
||||
_cliTools().logger.error(error.message);
|
||||
|
||||
_cliTools().logger.error(`Failed to fetch diff for react-native@${newVersion}. Maybe it's not released yet?`);
|
||||
|
||||
_cliTools().logger.info(`For available releases to diff see: ${_chalk().default.underline.dim('https://github.com/react-native-community/rn-diff-purge#diff-table-full-table-here')}`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
let patchWithRenamedProjects = patch;
|
||||
Object.keys(config.project).forEach(platform => {
|
||||
if (!config.project[platform]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform === 'ios') {
|
||||
patchWithRenamedProjects = patchWithRenamedProjects.replace(new RegExp('RnDiffApp', 'g'), config.project[platform].projectName.replace('.xcodeproj', ''));
|
||||
} else if (platform === 'android') {
|
||||
patchWithRenamedProjects = patchWithRenamedProjects.replace(new RegExp('com\\.rndiffapp', 'g'), config.project[platform].packageName).replace(new RegExp('com\\.rndiffapp'.split('.').join('/'), 'g'), config.project[platform].packageName.split('.').join('/'));
|
||||
} else {
|
||||
_cliTools().logger.warn(`Unsupported platform: "${platform}". \`upgrade\` only supports iOS and Android.`);
|
||||
}
|
||||
});
|
||||
return patchWithRenamedProjects;
|
||||
};
|
||||
|
||||
const getVersionToUpgradeTo = async (argv, currentVersion, projectDir) => {
|
||||
const argVersion = argv[0];
|
||||
|
||||
const semverCoercedVersion = _semver().default.coerce(argVersion);
|
||||
|
||||
const newVersion = argVersion ? _semver().default.valid(argVersion) || (semverCoercedVersion ? semverCoercedVersion.version : null) : await getLatestRNVersion();
|
||||
|
||||
if (!newVersion) {
|
||||
_cliTools().logger.error(`Provided version "${argv[0]}" is not allowed. Please pass a valid semver version`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_semver().default.gt(currentVersion, newVersion)) {
|
||||
_cliTools().logger.error(`Trying to upgrade from newer version "${currentVersion}" to older "${newVersion}"`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_semver().default.eq(currentVersion, newVersion)) {
|
||||
const {
|
||||
dependencies: {
|
||||
'react-native': version
|
||||
}
|
||||
} = require(_path().default.join(projectDir, 'package.json'));
|
||||
|
||||
if (_semver().default.satisfies(newVersion, version)) {
|
||||
_cliTools().logger.warn(`Specified version "${newVersion}" is already installed in node_modules and it satisfies "${version}" semver range. No need to upgrade`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_cliTools().logger.error(`Dependency mismatch. Specified version "${newVersion}" is already installed in node_modules and it doesn't satisfy "${version}" semver range of your "react-native" dependency. Please re-install your dependencies`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return newVersion;
|
||||
};
|
||||
|
||||
const installDeps = async (root, newVersion) => {
|
||||
_cliTools().logger.info(`Installing "react-native@${newVersion}" and its peer dependencies...`);
|
||||
|
||||
const peerDeps = await getRNPeerDeps(newVersion);
|
||||
const deps = [`react-native@${newVersion}`, ...Object.keys(peerDeps).map(module => `${module}@${peerDeps[module]}`)];
|
||||
await PackageManager.install(deps, {
|
||||
silent: true,
|
||||
root
|
||||
});
|
||||
await (0, _execa().default)('git', ['add', 'package.json']);
|
||||
|
||||
try {
|
||||
await (0, _execa().default)('git', ['add', 'yarn.lock']);
|
||||
} catch (error) {// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
await (0, _execa().default)('git', ['add', 'package-lock.json']);
|
||||
} catch (error) {// ignore
|
||||
}
|
||||
};
|
||||
|
||||
const installCocoaPodsDeps = async projectDir => {
|
||||
if (process.platform === 'darwin') {
|
||||
try {
|
||||
_cliTools().logger.info(`Installing CocoaPods dependencies ${_chalk().default.dim('(this may take a few minutes)')}`);
|
||||
|
||||
await (0, _installPods.default)({
|
||||
projectName: projectDir.split('/').pop() || ''
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.stderr) {
|
||||
_cliTools().logger.debug(`"pod install" or "pod repo update" failed. Error output:\n${error.stderr}`);
|
||||
}
|
||||
|
||||
_cliTools().logger.error('Installation of CocoaPods dependencies failed. Try to install them manually by running "pod install" in "ios" directory after finishing upgrade');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const applyPatch = async (currentVersion, newVersion, tmpPatchFile) => {
|
||||
const defaultExcludes = ['package.json'];
|
||||
let filesThatDontExist = [];
|
||||
let filesThatFailedToApply = [];
|
||||
const {
|
||||
stdout: relativePathFromRoot
|
||||
} = await (0, _execa().default)('git', ['rev-parse', '--show-prefix']);
|
||||
|
||||
try {
|
||||
try {
|
||||
const excludes = defaultExcludes.map(e => `--exclude=${_path().default.join(relativePathFromRoot, e)}`);
|
||||
await (0, _execa().default)('git', ['apply', // According to git documentation, `--binary` flag is turned on by
|
||||
// default. However it's necessary when running `git apply --check` to
|
||||
// actually accept binary files, maybe a bug in git?
|
||||
'--binary', '--check', tmpPatchFile, ...excludes, '-p2', '--3way', `--directory=${relativePathFromRoot}`]);
|
||||
|
||||
_cliTools().logger.info('Applying diff...');
|
||||
} catch (error) {
|
||||
const errorLines = error.stderr.split('\n');
|
||||
filesThatDontExist = [...errorLines.filter(x => x.includes('does not exist in index')).map(x => x.replace(/^error: (.*): does not exist in index$/, '$1'))].filter(Boolean);
|
||||
filesThatFailedToApply = errorLines.filter(x => x.includes('patch does not apply')).map(x => x.replace(/^error: (.*): patch does not apply$/, '$1')).filter(Boolean);
|
||||
|
||||
_cliTools().logger.info('Applying diff...');
|
||||
|
||||
_cliTools().logger.warn(`Excluding files that exist in the template, but not in your project:\n${filesThatDontExist.map(file => ` - ${_chalk().default.bold(file)}`).join('\n')}`);
|
||||
|
||||
if (filesThatFailedToApply.length) {
|
||||
_cliTools().logger.error(`Excluding files that failed to apply the diff:\n${filesThatFailedToApply.map(file => ` - ${_chalk().default.bold(file)}`).join('\n')}\nPlease make sure to check the actual changes after the upgrade command is finished.\nYou can find them in our Upgrade Helper web app: ${_chalk().default.underline.dim(`${webDiffUrl}/?from=${currentVersion}&to=${newVersion}`)}`);
|
||||
}
|
||||
} finally {
|
||||
const excludes = [...defaultExcludes, ...filesThatDontExist, ...filesThatFailedToApply].map(e => `--exclude=${_path().default.join(relativePathFromRoot, e)}`);
|
||||
await (0, _execa().default)('git', ['apply', tmpPatchFile, ...excludes, '-p2', '--3way', `--directory=${relativePathFromRoot}`]);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.stderr) {
|
||||
_cliTools().logger.debug(`"git apply" failed. Error output:\n${error.stderr}`);
|
||||
}
|
||||
|
||||
_cliTools().logger.error('Automatically applying diff failed. We did our best to automatically upgrade as many files as possible');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
* Upgrade application to a new version of React Native.
|
||||
*/
|
||||
|
||||
|
||||
async function upgrade(argv, ctx) {
|
||||
const tmpPatchFile = 'tmp-upgrade-rn.patch';
|
||||
const projectDir = ctx.root;
|
||||
|
||||
const {
|
||||
version: currentVersion
|
||||
} = require(_path().default.join(projectDir, 'node_modules/react-native/package.json'));
|
||||
|
||||
const newVersion = await getVersionToUpgradeTo(argv, currentVersion, projectDir);
|
||||
|
||||
if (!newVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
const patch = await getPatch(currentVersion, newVersion, ctx);
|
||||
|
||||
if (patch === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (patch === '') {
|
||||
_cliTools().logger.info('Diff has no changes to apply, proceeding further');
|
||||
|
||||
await installDeps(projectDir, newVersion);
|
||||
await installCocoaPodsDeps(projectDir);
|
||||
|
||||
_cliTools().logger.success(`Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let patchSuccess;
|
||||
|
||||
try {
|
||||
_fs().default.writeFileSync(tmpPatchFile, patch);
|
||||
|
||||
patchSuccess = await applyPatch(currentVersion, newVersion, tmpPatchFile);
|
||||
} catch (error) {
|
||||
throw new Error(error.stderr || error);
|
||||
} finally {
|
||||
try {
|
||||
_fs().default.unlinkSync(tmpPatchFile);
|
||||
} catch (e) {// ignore
|
||||
}
|
||||
|
||||
const {
|
||||
stdout
|
||||
} = await (0, _execa().default)('git', ['status', '-s']);
|
||||
|
||||
if (!patchSuccess) {
|
||||
if (stdout) {
|
||||
_cliTools().logger.warn('Continuing after failure. Some of the files are upgraded but you will need to deal with conflicts manually');
|
||||
|
||||
await installDeps(projectDir, newVersion);
|
||||
|
||||
_cliTools().logger.info('Running "git status" to check what changed...');
|
||||
|
||||
await (0, _execa().default)('git', ['status'], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} else {
|
||||
_cliTools().logger.error('Patch failed to apply for unknown reason. Please fall back to manual way of upgrading');
|
||||
}
|
||||
} else {
|
||||
await installDeps(projectDir, newVersion);
|
||||
await installCocoaPodsDeps(projectDir);
|
||||
|
||||
_cliTools().logger.info('Running "git status" to check what changed...');
|
||||
|
||||
await (0, _execa().default)('git', ['status'], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
|
||||
if (!patchSuccess) {
|
||||
if (stdout) {
|
||||
_cliTools().logger.warn('Please run "git diff" to review the conflicts and resolve them');
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
_cliTools().logger.warn('After resolving conflicts don\'t forget to run "pod install" inside "ios" directory');
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`You may find these resources helpful:
|
||||
• Release notes: ${_chalk().default.underline.dim(`https://github.com/facebook/react-native/releases/tag/v${newVersion}`)}
|
||||
• Manual Upgrade Helper: ${_chalk().default.underline.dim(`${webDiffUrl}/?from=${currentVersion}&to=${newVersion}`)}
|
||||
• Git diff: ${_chalk().default.underline.dim(`${rawDiffUrl}/${currentVersion}..${newVersion}.diff`)}`);
|
||||
|
||||
throw new (_cliTools().CLIError)('Upgrade failed. Please see the messages above for details');
|
||||
}
|
||||
}
|
||||
|
||||
_cliTools().logger.success(`Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes`);
|
||||
}
|
||||
|
||||
const upgradeCommand = {
|
||||
name: 'upgrade [version]',
|
||||
description: "Upgrade your app's template files to the specified or latest npm version using `rn-diff-purge` project. Only valid semver versions are allowed.",
|
||||
func: upgrade
|
||||
};
|
||||
var _default = upgradeCommand;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=upgrade.js.map
|
Reference in New Issue
Block a user