@react-native-community/cli
Advanced tools
Comparing version 13.2.0 to 13.3.0
@@ -67,3 +67,11 @@ "use strict"; | ||
} | ||
var _createGitRepository = _interopRequireDefault(require("./createGitRepository")); | ||
var _git = require("./git"); | ||
function _semver() { | ||
const data = _interopRequireDefault(require("semver")); | ||
_semver = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _executeCommand = require("../../tools/executeCommand"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -73,2 +81,24 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 DEFAULT_VERSION = 'latest'; | ||
// Here we are defining explicit version of Yarn to be used in the new project because in some cases providing `3.x` don't work. | ||
const YARN_VERSION = '3.6.4'; | ||
const bumpYarnVersion = async (silent, root) => { | ||
try { | ||
let yarnVersion = _semver().default.parse((0, _yarn.getYarnVersionIfAvailable)()); | ||
if (yarnVersion) { | ||
await (0, _executeCommand.executeCommand)('yarn', ['set', 'version', YARN_VERSION], { | ||
root, | ||
silent | ||
}); | ||
// React Native doesn't support PnP, so we need to set nodeLinker to node-modules. Read more here: https://github.com/react-native-community/cli/issues/27#issuecomment-1772626767 | ||
await (0, _executeCommand.executeCommand)('yarn', ['config', 'set', 'nodeLinker', 'node-modules'], { | ||
root, | ||
silent | ||
}); | ||
} | ||
} catch (e) { | ||
_cliTools().logger.debug(e); | ||
} | ||
}; | ||
function doesDirectoryExist(dir) { | ||
@@ -78,9 +108,3 @@ return _fsExtra().default.existsSync(dir); | ||
async function setProjectDirectory(directory) { | ||
if (doesDirectoryExist(directory)) { | ||
throw new _DirectoryAlreadyExistsError.default(directory); | ||
} | ||
try { | ||
_fsExtra().default.mkdirSync(directory, { | ||
recursive: true | ||
}); | ||
process.chdir(directory); | ||
@@ -106,2 +130,3 @@ } catch (error) { | ||
projectName, | ||
shouldBumpYarnVersion, | ||
templateUri, | ||
@@ -159,2 +184,6 @@ npm, | ||
}); | ||
if (packageManager === 'yarn' && shouldBumpYarnVersion) { | ||
await bumpYarnVersion(false, projectDirectory); | ||
} | ||
loader.succeed(); | ||
const { | ||
@@ -252,6 +281,7 @@ postInitScript | ||
} | ||
async function createProject(projectName, directory, version, options) { | ||
async function createProject(projectName, directory, version, shouldBumpYarnVersion, options) { | ||
const templateUri = createTemplateUri(options, version); | ||
return createFromTemplate({ | ||
projectName, | ||
shouldBumpYarnVersion, | ||
templateUri, | ||
@@ -293,2 +323,3 @@ npm: options.npm, | ||
const directoryName = _path().default.relative(root, options.directory || projectName); | ||
const projectFolder = _path().default.join(root, directoryName); | ||
if (options.pm && !checkPackageManagerAvailability(options.pm)) { | ||
@@ -298,8 +329,27 @@ _cliTools().logger.error('Seems like the package manager you want to use is not installed. Please install it or choose another package manager.'); | ||
} | ||
if (doesDirectoryExist(projectFolder)) { | ||
throw new _DirectoryAlreadyExistsError.default(directoryName); | ||
} else { | ||
_fsExtra().default.mkdirSync(projectFolder, { | ||
recursive: true | ||
}); | ||
} | ||
let shouldBumpYarnVersion = true; | ||
let shouldCreateGitRepository = false; | ||
const isGitAvailable = await (0, _git.checkGitInstallation)(); | ||
if (isGitAvailable) { | ||
const isFolderGitRepo = await (0, _git.checkIfFolderIsGitRepo)(projectFolder); | ||
if (isFolderGitRepo) { | ||
shouldBumpYarnVersion = false; | ||
} else { | ||
shouldCreateGitRepository = true; // Initialize git repo after creating project | ||
} | ||
} else { | ||
_cliTools().logger.warn('Git is not installed on your system. This might cause some features to work incorrectly.'); | ||
} | ||
const { | ||
didInstallPods | ||
} = await createProject(projectName, directoryName, version, options); | ||
const projectFolder = _path().default.join(root, directoryName); | ||
if (!options.skipGitInit) { | ||
await (0, _createGitRepository.default)(projectFolder); | ||
} = await createProject(projectName, directoryName, version, shouldBumpYarnVersion, options); | ||
if (shouldCreateGitRepository && !options.skipGitInit) { | ||
await (0, _git.createGitRepository)(projectFolder); | ||
} | ||
@@ -306,0 +356,0 @@ (0, _printRunInstructions.default)(projectFolder, projectName, { |
@@ -49,2 +49,3 @@ "use strict"; | ||
var _yarn = require("../../tools/yarn"); | ||
var _executeCommand = require("../../tools/executeCommand"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -60,10 +61,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; } | ||
}); | ||
// React Native doesn't support PnP, so we need to set nodeLinker to node-modules. Read more here: https://github.com/react-native-community/cli/issues/27#issuecomment-1772626767 | ||
if (packageManager === 'yarn' && (0, _yarn.getYarnVersionIfAvailable)() !== null) { | ||
(0, PackageManager.executeCommand)('yarn', ['config', 'set', 'nodeLinker', 'node-modules'], { | ||
const options = { | ||
root, | ||
silent: true | ||
}); | ||
}; | ||
// React Native doesn't support PnP, so we need to set nodeLinker to node-modules. Read more here: https://github.com/react-native-community/cli/issues/27#issuecomment-1772626767 | ||
(0, _executeCommand.executeCommand)('yarn', ['config', 'set', 'nodeLinker', 'node-modules'], options); | ||
(0, _executeCommand.executeCommand)('yarn', ['config', 'set', 'nmHoistingLimits', 'workspaces'], options); | ||
} | ||
@@ -70,0 +72,0 @@ return PackageManager.install([templateName], { |
@@ -1,2 +0,1 @@ | ||
import execa from 'execa'; | ||
export type PackageManager = keyof typeof packageManagers; | ||
@@ -31,15 +30,11 @@ type Options = { | ||
}; | ||
export declare function executeCommand(command: string, args: Array<string>, options: { | ||
root: string; | ||
silent?: boolean; | ||
}): execa.ExecaChildProcess<string>; | ||
export declare function shouldUseYarn(options: Options): string | null | undefined; | ||
export declare function shouldUseBun(options: Options): string | null | undefined; | ||
export declare function shouldUseNpm(options: Options): string | null | undefined; | ||
export declare function init(options: Options): execa.ExecaChildProcess<string>; | ||
export declare function install(packageNames: Array<string>, options: Options): execa.ExecaChildProcess<string>; | ||
export declare function installDev(packageNames: Array<string>, options: Options): execa.ExecaChildProcess<string>; | ||
export declare function uninstall(packageNames: Array<string>, options: Options): execa.ExecaChildProcess<string>; | ||
export declare function installAll(options: Options): execa.ExecaChildProcess<string>; | ||
export declare function init(options: Options): import("execa").ExecaChildProcess<string>; | ||
export declare function install(packageNames: Array<string>, options: Options): import("execa").ExecaChildProcess<string>; | ||
export declare function installDev(packageNames: Array<string>, options: Options): import("execa").ExecaChildProcess<string>; | ||
export declare function uninstall(packageNames: Array<string>, options: Options): import("execa").ExecaChildProcess<string>; | ||
export declare function installAll(options: Options): import("execa").ExecaChildProcess<string>; | ||
export {}; | ||
//# sourceMappingURL=packageManager.d.ts.map |
@@ -6,3 +6,2 @@ "use strict"; | ||
}); | ||
exports.executeCommand = executeCommand; | ||
exports.init = init; | ||
@@ -16,20 +15,6 @@ exports.install = install; | ||
exports.uninstall = uninstall; | ||
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 _yarn = require("./yarn"); | ||
var _bun = require("./bun"); | ||
var _npm = require("./npm"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _executeCommand = require("./executeCommand"); | ||
const packageManagers = { | ||
@@ -76,10 +61,4 @@ yarn: { | ||
const args = [executable, ...flags, ...packageNames]; | ||
return executeCommand(pm, args, options); | ||
return (0, _executeCommand.executeCommand)(pm, args, options); | ||
} | ||
function executeCommand(command, args, options) { | ||
return (0, _execa().default)(command, args, { | ||
stdio: options.silent && !_cliTools().logger.isVerbose() ? 'pipe' : 'inherit', | ||
cwd: options.root | ||
}); | ||
} | ||
function shouldUseYarn(options) { | ||
@@ -86,0 +65,0 @@ if (options.packageManager === 'yarn') { |
{ | ||
"name": "@react-native-community/cli", | ||
"version": "13.2.0", | ||
"version": "13.3.0", | ||
"description": "React Native CLI", | ||
@@ -27,11 +27,11 @@ "license": "MIT", | ||
"dependencies": { | ||
"@react-native-community/cli-clean": "13.2.0", | ||
"@react-native-community/cli-config": "13.2.0", | ||
"@react-native-community/cli-debugger-ui": "13.2.0", | ||
"@react-native-community/cli-doctor": "13.2.0", | ||
"@react-native-community/cli-hermes": "13.2.0", | ||
"@react-native-community/cli-plugin-metro": "13.2.0", | ||
"@react-native-community/cli-server-api": "13.2.0", | ||
"@react-native-community/cli-tools": "13.2.0", | ||
"@react-native-community/cli-types": "13.2.0", | ||
"@react-native-community/cli-clean": "13.3.0", | ||
"@react-native-community/cli-config": "13.3.0", | ||
"@react-native-community/cli-debugger-ui": "13.3.0", | ||
"@react-native-community/cli-doctor": "13.3.0", | ||
"@react-native-community/cli-hermes": "13.3.0", | ||
"@react-native-community/cli-plugin-metro": "13.3.0", | ||
"@react-native-community/cli-server-api": "13.3.0", | ||
"@react-native-community/cli-tools": "13.3.0", | ||
"@react-native-community/cli-types": "13.3.0", | ||
"chalk": "^4.1.2", | ||
@@ -62,3 +62,3 @@ "commander": "^9.4.1", | ||
}, | ||
"gitHead": "acdcb2bbd7b1fa6a50e771e04b36604834330da4" | ||
"gitHead": "148f4d7220fba7a55e1f0b7def417c6c96ea6d9c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
188578
108
2015
+ Added@react-native-community/cli-clean@13.3.0(transitive)
+ Added@react-native-community/cli-config@13.3.0(transitive)
+ Added@react-native-community/cli-debugger-ui@13.3.0(transitive)
+ Added@react-native-community/cli-doctor@13.3.0(transitive)
+ Added@react-native-community/cli-hermes@13.3.0(transitive)
+ Added@react-native-community/cli-platform-android@13.3.0(transitive)
+ Added@react-native-community/cli-platform-apple@13.3.0(transitive)
+ Added@react-native-community/cli-platform-ios@13.3.0(transitive)
+ Added@react-native-community/cli-plugin-metro@13.3.0(transitive)
+ Added@react-native-community/cli-server-api@13.3.0(transitive)
+ Added@react-native-community/cli-tools@13.3.0(transitive)
+ Added@react-native-community/cli-types@13.3.0(transitive)
- Removed@react-native-community/cli-clean@13.2.0(transitive)
- Removed@react-native-community/cli-config@13.2.0(transitive)
- Removed@react-native-community/cli-debugger-ui@13.2.0(transitive)
- Removed@react-native-community/cli-doctor@13.2.0(transitive)
- Removed@react-native-community/cli-hermes@13.2.0(transitive)
- Removed@react-native-community/cli-platform-android@13.2.0(transitive)
- Removed@react-native-community/cli-platform-apple@13.2.0(transitive)
- Removed@react-native-community/cli-platform-ios@13.2.0(transitive)
- Removed@react-native-community/cli-plugin-metro@13.2.0(transitive)
- Removed@react-native-community/cli-server-api@13.2.0(transitive)
- Removed@react-native-community/cli-tools@13.2.0(transitive)
- Removed@react-native-community/cli-types@13.2.0(transitive)