feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 react-native-community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,7 @@
# React Native CLI
Command line tools to interact with React Native projects.
This package contains source code for `@react-native-community/cli`, the actual CLI that comes bundled with React Native. You don't need to install it separately in your project.
See the [list of available commands](../../docs/commands.md).

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
import './tools/gracefulifyFs';
//# sourceMappingURL=bin.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,uBAAuB,CAAC"}

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env node
"use strict";
require("./tools/gracefulifyFs");
function _semver() {
const data = _interopRequireDefault(require("semver"));
_semver = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _cliDoctor() {
const data = require("@react-native-community/cli-doctor");
_cliDoctor = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
if (_semver().default.satisfies(process.version, _cliDoctor().versionRanges.NODE_JS)) {
const {
run
} = require('./');
run();
} else {
console.error(`${_chalk().default.red(`React Native needs Node.js ${_cliDoctor().versionRanges.NODE_JS}. You're currently on version ${process.version}. Please upgrade Node.js to a supported version and try again.`)}`);
}
//# sourceMappingURL=bin.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["semver","satisfies","process","version","versionRanges","NODE_JS","run","require","console","error","chalk","red"],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport './tools/gracefulifyFs';\nimport semver from 'semver';\nimport chalk from 'chalk';\nimport {versionRanges} from '@react-native-community/cli-doctor';\n\nif (semver.satisfies(process.version, versionRanges.NODE_JS)) {\n const {run} = require('./');\n run();\n} else {\n console.error(\n `${chalk.red(\n `React Native needs Node.js ${versionRanges.NODE_JS}. You're currently on version ${process.version}. Please upgrade Node.js to a supported version and try again.`,\n )}`,\n );\n}\n"],"mappings":"AAAA;AAAmB;;AAEnB;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAiE;AAEjE,IAAIA,iBAAM,CAACC,SAAS,CAACC,OAAO,CAACC,OAAO,EAAEC,0BAAa,CAACC,OAAO,CAAC,EAAE;EAC5D,MAAM;IAACC;EAAG,CAAC,GAAGC,OAAO,CAAC,IAAI,CAAC;EAC3BD,GAAG,EAAE;AACP,CAAC,MAAM;EACLE,OAAO,CAACC,KAAK,CACV,GAAEC,gBAAK,CAACC,GAAG,CACT,8BAA6BP,0BAAa,CAACC,OAAQ,iCAAgCH,OAAO,CAACC,OAAQ,gEAA+D,CACnK,EAAC,CACJ;AACH"}

View File

@@ -0,0 +1,4 @@
import { Command, DetachedCommand } from '@react-native-community/cli-types';
export declare const projectCommands: Command[];
export declare const detachedCommands: DetachedCommand[];
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,mCAAmC,CAAC;AAQ3E,eAAO,MAAM,eAAe,WAMd,CAAC;AAEf,eAAO,MAAM,gBAAgB,mBAGP,CAAC"}

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.projectCommands = exports.detachedCommands = void 0;
function _cliClean() {
const data = require("@react-native-community/cli-clean");
_cliClean = function () {
return data;
};
return data;
}
function _cliDoctor() {
const data = require("@react-native-community/cli-doctor");
_cliDoctor = function () {
return data;
};
return data;
}
function _cliConfig() {
const data = require("@react-native-community/cli-config");
_cliConfig = function () {
return data;
};
return data;
}
function _cliHermes() {
const data = _interopRequireDefault(require("@react-native-community/cli-hermes"));
_cliHermes = function () {
return data;
};
return data;
}
var _upgrade = _interopRequireDefault(require("./upgrade/upgrade"));
var _init = _interopRequireDefault(require("./init"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const projectCommands = [..._cliConfig().commands, _cliClean().commands.clean, _cliDoctor().commands.info, _upgrade.default, _cliHermes().default];
exports.projectCommands = projectCommands;
const detachedCommands = [_init.default, _cliDoctor().commands.doctor];
exports.detachedCommands = detachedCommands;
//# sourceMappingURL=index.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["projectCommands","configCommands","cleanCommands","clean","doctorCommands","info","upgrade","profileHermes","detachedCommands","init","doctor"],"sources":["../../src/commands/index.ts"],"sourcesContent":["import {Command, DetachedCommand} from '@react-native-community/cli-types';\nimport {commands as cleanCommands} from '@react-native-community/cli-clean';\nimport {commands as doctorCommands} from '@react-native-community/cli-doctor';\nimport {commands as configCommands} from '@react-native-community/cli-config';\nimport profileHermes from '@react-native-community/cli-hermes';\nimport upgrade from './upgrade/upgrade';\nimport init from './init';\n\nexport const projectCommands = [\n ...configCommands,\n cleanCommands.clean,\n doctorCommands.info,\n upgrade,\n profileHermes,\n] as Command[];\n\nexport const detachedCommands = [\n init,\n doctorCommands.doctor,\n] as DetachedCommand[];\n"],"mappings":";;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AAA0B;AAEnB,MAAMA,eAAe,GAAG,CAC7B,GAAGC,qBAAc,EACjBC,oBAAa,CAACC,KAAK,EACnBC,qBAAc,CAACC,IAAI,EACnBC,gBAAO,EACPC,oBAAa,CACD;AAAC;AAER,MAAMC,gBAAgB,GAAG,CAC9BC,aAAI,EACJL,qBAAc,CAACM,MAAM,CACD;AAAC"}

View File

@@ -0,0 +1,3 @@
declare const _default: string;
export default _default;
//# sourceMappingURL=banner.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../src/commands/init/banner.ts"],"names":[],"mappings":";AAqCA,wBAIE"}

View File

@@ -0,0 +1,25 @@
"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.cyan(reactLogoArray.join('\n'))}
${_chalk().default.cyanBright.bold(welcomeMessage)}
${_chalk().default.dim(learnOnceMessage)}
`;
exports.default = _default;
//# sourceMappingURL=banner.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["reactLogoArray","welcomeMessage","learnOnceMessage","chalk","cyan","join","cyanBright","bold","dim"],"sources":["../../../src/commands/init/banner.ts"],"sourcesContent":["import chalk from 'chalk';\n\nconst reactLogoArray = [\n ' ',\n ' ###### ###### ',\n ' ### #### #### ### ',\n ' ## ### ### ## ',\n ' ## #### ## ',\n ' ## #### ## ',\n ' ## ## ## ## ',\n ' ## ### ### ## ',\n ' ## ######################## ## ',\n ' ###### ### ### ###### ',\n ' ### ## ## ## ## ### ',\n ' ### ## ### #### ### ## ### ',\n ' ## #### ######## #### ## ',\n ' ## ### ########## ### ## ',\n ' ## #### ######## #### ## ',\n ' ### ## ### #### ### ## ### ',\n ' ### ## ## ## ## ### ',\n ' ###### ### ### ###### ',\n ' ## ######################## ## ',\n ' ## ### ### ## ',\n ' ## ## ## ## ',\n ' ## #### ## ',\n ' ## #### ## ',\n ' ## ### ### ## ',\n ' ### #### #### ### ',\n ' ###### ###### ',\n ' ',\n];\n\nconst welcomeMessage =\n ' Welcome to React Native! ';\nconst learnOnceMessage =\n ' Learn once, write anywhere ';\n\nexport default `${chalk.cyan(reactLogoArray.join('\\n'))}\n\n${chalk.cyanBright.bold(welcomeMessage)}\n${chalk.dim(learnOnceMessage)}\n`;\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA0B;AAE1B,MAAMA,cAAc,GAAG,CACrB,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,EAC5D,4DAA4D,CAC7D;AAED,MAAMC,cAAc,GAClB,4DAA4D;AAC9D,MAAMC,gBAAgB,GACpB,4DAA4D;AAAC,eAE/C,GAAEC,gBAAK,CAACC,IAAI,CAACJ,cAAc,CAACK,IAAI,CAAC,IAAI,CAAC,CAAE;AACxD;AACA,EAAEF,gBAAK,CAACG,UAAU,CAACC,IAAI,CAACN,cAAc,CAAE;AACxC,EAAEE,gBAAK,CAACK,GAAG,CAACN,gBAAgB,CAAE;AAC9B,CAAC;AAAA"}

View File

@@ -0,0 +1,13 @@
interface PlaceholderConfig {
projectName: string;
placeholderName: string;
placeholderTitle?: string;
projectTitle?: string;
packageName?: string;
}
export declare function validatePackageName(packageName: string): void;
export declare function replaceNameInUTF8File(filePath: string, projectName: string, templateName: string): Promise<void>;
export declare function replacePlaceholderWithPackageName({ projectName, placeholderName, placeholderTitle, packageName, }: Omit<Required<PlaceholderConfig>, 'projectTitle'>): Promise<void>;
export declare function changePlaceholderInTemplate({ projectName, placeholderName, placeholderTitle, projectTitle, packageName, }: PlaceholderConfig): Promise<void>;
export {};
//# sourceMappingURL=editTemplate.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"editTemplate.d.ts","sourceRoot":"","sources":["../../../src/commands/init/editTemplate.ts"],"names":[],"mappings":"AASA,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAQD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,QAYtD;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,iBAcrB;AAwFD,wBAAsB,iCAAiC,CAAC,EACtD,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,GACZ,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC,iBA+EnD;AAED,wBAAsB,2BAA2B,CAAC,EAChD,WAAW,EACX,eAAe,EACf,gBAA4C,EAC5C,YAA0B,EAC1B,WAAW,GACZ,EAAE,iBAAiB,iBAoCnB"}

View File

@@ -0,0 +1,192 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.changePlaceholderInTemplate = changePlaceholderInTemplate;
exports.replaceNameInUTF8File = replaceNameInUTF8File;
exports.replacePlaceholderWithPackageName = replacePlaceholderWithPackageName;
exports.validatePackageName = validatePackageName;
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 _fsExtra() {
const data = _interopRequireDefault(require("fs-extra"));
_fsExtra = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// We need `graceful-fs` behavior around async file renames on Win32.
// `gracefulify` does not support patching `fs.promises`. Use `fs-extra`, which
// exposes its own promise-based interface over `graceful-fs`.
/**
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 validatePackageName(packageName) {
const packageNameParts = packageName.split('.');
const packageNameRegex = /^([a-zA-Z]([a-zA-Z0-9_])*\.)+[a-zA-Z]([a-zA-Z0-9_])*$/u;
if (packageNameParts.length < 2) {
throw `The package name ${packageName} is invalid. It should contain at least two segments, e.g. com.app`;
}
if (!packageNameRegex.test(packageName)) {
throw `The ${packageName} package name is not valid. It can contain only alphanumeric characters and dots.`;
}
}
async function replaceNameInUTF8File(filePath, projectName, templateName) {
_cliTools().logger.debug(`Replacing in ${filePath}`);
const fileContent = await _fsExtra().default.readFile(filePath, 'utf8');
const replacedFileContent = fileContent.replace(new RegExp(templateName, 'g'), projectName).replace(new RegExp(templateName.toLowerCase(), 'g'), projectName.toLowerCase());
if (fileContent !== replacedFileContent) {
await _fsExtra().default.writeFile(filePath, replacedFileContent, 'utf8');
}
}
async 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}`);
await _fsExtra().default.rename(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);
}
function isIosFile(filePath) {
return filePath.includes('ios');
}
const UNDERSCORED_DOTFILES = ['buckconfig', 'eslintrc.js', 'flowconfig', 'gitattributes', 'gitignore', 'prettierrc.js', 'watchmanconfig', 'editorconfig', 'bundle', 'ruby-version', 'node-version', 'xcode.env'];
async function processDotfiles(filePath) {
const dotfile = UNDERSCORED_DOTFILES.find(e => filePath.includes(`_${e}`));
if (dotfile === undefined) {
return;
}
await renameFile(filePath, `_${dotfile}`, `.${dotfile}`);
}
async function createAndroidPackagePaths(filePath, packageName) {
const pathParts = filePath.split('/').slice(-2);
if (pathParts[0] === 'java' && pathParts[1] === 'com') {
const pathToFolders = filePath.split('/').slice(0, -2).join('/');
const segmentsList = packageName.split('.');
if (segmentsList.length > 1) {
const initialDir = process.cwd();
process.chdir(filePath.split('/').slice(0, -1).join('/'));
try {
await _fsExtra().default.rename(`${filePath}/${segmentsList.join('.')}`, `${pathToFolders}/${segmentsList[segmentsList.length - 1]}`);
await _fsExtra().default.rmdir(filePath);
for (const segment of segmentsList) {
_fsExtra().default.mkdirSync(segment);
process.chdir(segment);
}
await _fsExtra().default.rename(`${pathToFolders}/${segmentsList[segmentsList.length - 1]}`, process.cwd());
} catch {
throw 'Failed to create correct paths for Android.';
}
process.chdir(initialDir);
}
}
}
async function replacePlaceholderWithPackageName({
projectName,
placeholderName,
placeholderTitle,
packageName
}) {
validatePackageName(packageName);
const cleanPackageName = packageName.replace(/[^\p{L}\p{N}.]+/gu, '');
for (const filePath of (0, _walk.default)(process.cwd()).reverse()) {
if (shouldIgnoreFile(filePath)) {
continue;
}
const iosFile = isIosFile(filePath);
if (!(await _fsExtra().default.stat(filePath)).isDirectory()) {
let newName = iosFile ? projectName : cleanPackageName;
//replace bundleID for iOS
await replaceNameInUTF8File(filePath, `PRODUCT_BUNDLE_IDENTIFIER = "${cleanPackageName}"`, 'PRODUCT_BUNDLE_IDENTIFIER = "(.*)"');
if (filePath.includes('app.json')) {
await replaceNameInUTF8File(filePath, projectName, placeholderName);
} else {
const fileExtension = _path().default.extname(filePath);
if (fileExtension === '.java') {
await replaceNameInUTF8File(filePath, `return "${projectName}"`, `return "${placeholderName}"`);
} else if (fileExtension === '.kt') {
await replaceNameInUTF8File(filePath, `= "${projectName}"`, `= "${placeholderName}"`);
}
await replaceNameInUTF8File(filePath, `<string name="app_name">${projectName}</string>`, `<string name="app_name">${placeholderTitle}</string>`);
await replaceNameInUTF8File(filePath, newName, `com.${placeholderName}`);
await replaceNameInUTF8File(filePath, newName, placeholderName);
await replaceNameInUTF8File(filePath, newName, placeholderTitle);
}
}
let fileName = cleanPackageName;
if (shouldRenameFile(filePath, placeholderName)) {
if (iosFile) {
fileName = projectName;
}
await renameFile(filePath, placeholderName, fileName);
} else if (shouldRenameFile(filePath, placeholderName.toLowerCase())) {
await renameFile(filePath, placeholderName.toLowerCase(), fileName.toLowerCase());
}
try {
await createAndroidPackagePaths(filePath, cleanPackageName);
} catch (error) {
throw new (_cliTools().CLIError)('Failed to create correct paths for Android.');
}
await processDotfiles(filePath);
}
}
async function changePlaceholderInTemplate({
projectName,
placeholderName,
placeholderTitle = DEFAULT_TITLE_PLACEHOLDER,
projectTitle = projectName,
packageName
}) {
_cliTools().logger.debug(`Changing ${placeholderName} for ${projectName} in template`);
if (packageName) {
try {
await replacePlaceholderWithPackageName({
projectName,
placeholderName,
placeholderTitle,
packageName
});
} catch (error) {
throw new (_cliTools().CLIError)(error.message);
}
} else {
for (const filePath of (0, _walk.default)(process.cwd()).reverse()) {
if (shouldIgnoreFile(filePath)) {
continue;
}
if (!(await _fsExtra().default.stat(filePath)).isDirectory()) {
await replaceNameInUTF8File(filePath, projectName, placeholderName);
await replaceNameInUTF8File(filePath, projectTitle, placeholderTitle);
}
if (shouldRenameFile(filePath, placeholderName)) {
await renameFile(filePath, placeholderName, projectName);
} else if (shouldRenameFile(filePath, placeholderName.toLowerCase())) {
await renameFile(filePath, placeholderName.toLowerCase(), projectName.toLowerCase());
}
await processDotfiles(filePath);
}
}
}
//# sourceMappingURL=editTemplate.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import { CLIError } from '@react-native-community/cli-tools';
export default class DirectoryAlreadyExistsError extends CLIError {
constructor(directory: string);
}
//# sourceMappingURL=DirectoryAlreadyExistsError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DirectoryAlreadyExistsError.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/errors/DirectoryAlreadyExistsError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,QAAQ;gBACnD,SAAS,EAAE,MAAM;CAK9B"}

View File

@@ -0,0 +1,21 @@
"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;
}
class DirectoryAlreadyExistsError extends _cliTools().CLIError {
constructor(directory) {
super(`Cannot initialize new project because directory "${directory}" already exists. Please remove or rename the directory and try again.`);
}
}
exports.default = DirectoryAlreadyExistsError;
//# sourceMappingURL=DirectoryAlreadyExistsError.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["DirectoryAlreadyExistsError","CLIError","constructor","directory"],"sources":["../../../../src/commands/init/errors/DirectoryAlreadyExistsError.ts"],"sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\n\nexport default class DirectoryAlreadyExistsError extends CLIError {\n constructor(directory: string) {\n super(\n `Cannot initialize new project because directory \"${directory}\" already exists. Please remove or rename the directory and try again.`,\n );\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEe,MAAMA,2BAA2B,SAASC,oBAAQ,CAAC;EAChEC,WAAW,CAACC,SAAiB,EAAE;IAC7B,KAAK,CACF,oDAAmDA,SAAU,wEAAuE,CACtI;EACH;AACF;AAAC"}

View File

@@ -0,0 +1,5 @@
import { CLIError } from '@react-native-community/cli-tools';
export default class HelloWorldError extends CLIError {
constructor();
}
//# sourceMappingURL=HelloWorldError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"HelloWorldError.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/errors/HelloWorldError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,QAAQ;;CAMpD"}

View File

@@ -0,0 +1,21 @@
"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;
}
class HelloWorldError extends _cliTools().CLIError {
constructor() {
super('Project name shouldn\'t contain "HelloWorld" name in it, because it is CLI\'s default placeholder name.');
}
}
exports.default = HelloWorldError;
//# sourceMappingURL=HelloWorldError.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["HelloWorldError","CLIError","constructor"],"sources":["../../../../src/commands/init/errors/HelloWorldError.ts"],"sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\n\nexport default class HelloWorldError extends CLIError {\n constructor() {\n super(\n 'Project name shouldn\\'t contain \"HelloWorld\" name in it, because it is CLI\\'s default placeholder name.',\n );\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEe,MAAMA,eAAe,SAASC,oBAAQ,CAAC;EACpDC,WAAW,GAAG;IACZ,KAAK,CACH,yGAAyG,CAC1G;EACH;AACF;AAAC"}

View File

@@ -0,0 +1,5 @@
import { CLIError } from '@react-native-community/cli-tools';
export default class InvalidNameError extends CLIError {
constructor(name: string);
}
//# sourceMappingURL=InvalidNameError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InvalidNameError.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/errors/InvalidNameError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,QAAQ;gBACxC,IAAI,EAAE,MAAM;CAKzB"}

View File

@@ -0,0 +1,21 @@
"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;
}
class InvalidNameError extends _cliTools().CLIError {
constructor(name) {
super(`"${name}" is not a valid name for a project. Please use a valid identifier name (alphanumeric).`);
}
}
exports.default = InvalidNameError;
//# sourceMappingURL=InvalidNameError.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["InvalidNameError","CLIError","constructor","name"],"sources":["../../../../src/commands/init/errors/InvalidNameError.ts"],"sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\n\nexport default class InvalidNameError extends CLIError {\n constructor(name: string) {\n super(\n `\"${name}\" is not a valid name for a project. Please use a valid identifier name (alphanumeric).`,\n );\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEe,MAAMA,gBAAgB,SAASC,oBAAQ,CAAC;EACrDC,WAAW,CAACC,IAAY,EAAE;IACxB,KAAK,CACF,IAAGA,IAAK,yFAAwF,CAClG;EACH;AACF;AAAC"}

View File

@@ -0,0 +1,5 @@
import { CLIError } from '@react-native-community/cli-tools';
export default class ReservedNameError extends CLIError {
constructor(name: string);
}
//# sourceMappingURL=ReservedNameError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ReservedNameError.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/errors/ReservedNameError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,QAAQ;gBACzC,IAAI,EAAE,MAAM;CAKzB"}

View File

@@ -0,0 +1,21 @@
"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;
}
class ReservedNameError extends _cliTools().CLIError {
constructor(name) {
super(`Not a valid name for a project. Please do not use the reserved word "${name}".`);
}
}
exports.default = ReservedNameError;
//# sourceMappingURL=ReservedNameError.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["ReservedNameError","CLIError","constructor","name"],"sources":["../../../../src/commands/init/errors/ReservedNameError.ts"],"sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\n\nexport default class ReservedNameError extends CLIError {\n constructor(name: string) {\n super(\n `Not a valid name for a project. Please do not use the reserved word \"${name}\".`,\n );\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEe,MAAMA,iBAAiB,SAASC,oBAAQ,CAAC;EACtDC,WAAW,CAACC,IAAY,EAAE;IACxB,KAAK,CACF,wEAAuEA,IAAK,IAAG,CACjF;EACH;AACF;AAAC"}

View File

@@ -0,0 +1,5 @@
import { CLIError } from '@react-native-community/cli-tools';
export default class TemplateAndVersionError extends CLIError {
constructor(template: string);
}
//# sourceMappingURL=TemplateAndVersionError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TemplateAndVersionError.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/errors/TemplateAndVersionError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,QAAQ;gBAC/C,QAAQ,EAAE,MAAM;CAS7B"}

View File

@@ -0,0 +1,25 @@
"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;
}
class TemplateAndVersionError extends _cliTools().CLIError {
constructor(template) {
super(`Passing both "version" and "template" is not supported. The template you select determines the version of react-native used. Please use only one of these options, for example:
--template ${template}@x.y.z
where x.y.z is the release of the template that contains the desired "react-native" version. Check the version tab of https://www.npmjs.com/package/${template} for available versions`);
}
}
exports.default = TemplateAndVersionError;
//# sourceMappingURL=TemplateAndVersionError.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["TemplateAndVersionError","CLIError","constructor","template"],"sources":["../../../../src/commands/init/errors/TemplateAndVersionError.ts"],"sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\n\nexport default class TemplateAndVersionError extends CLIError {\n constructor(template: string) {\n super(\n `Passing both \"version\" and \"template\" is not supported. The template you select determines the version of react-native used. Please use only one of these options, for example:\n \n --template ${template}@x.y.z\n \n where x.y.z is the release of the template that contains the desired \"react-native\" version. Check the version tab of https://www.npmjs.com/package/${template} for available versions`,\n );\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEe,MAAMA,uBAAuB,SAASC,oBAAQ,CAAC;EAC5DC,WAAW,CAACC,QAAgB,EAAE;IAC5B,KAAK,CACF;AACP;AACA,mBAAmBA,QAAS;AAC5B;AACA,4JAA4JA,QAAS,yBAAwB,CACxL;EACH;AACF;AAAC"}

View File

@@ -0,0 +1,4 @@
export declare const checkGitInstallation: () => Promise<boolean>;
export declare const checkIfFolderIsGitRepo: (folder: string) => Promise<boolean>;
export declare const createGitRepository: (folder: string) => Promise<void>;
//# sourceMappingURL=git.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/commands/init/git.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,QAAa,QAAQ,OAAO,CAO5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,MAAM,KACb,QAAQ,OAAO,CAUjB,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAkB,MAAM,kBAyCvD,CAAC"}

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createGitRepository = exports.checkIfFolderIsGitRepo = exports.checkGitInstallation = void 0;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _execa() {
const data = _interopRequireDefault(require("execa"));
_execa = 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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const checkGitInstallation = async () => {
try {
await (0, _execa().default)('git', ['--version'], {
stdio: 'ignore'
});
return true;
} catch {
return false;
}
};
exports.checkGitInstallation = checkGitInstallation;
const checkIfFolderIsGitRepo = async folder => {
try {
await (0, _execa().default)('git', ['rev-parse', '--is-inside-work-tree'], {
stdio: 'ignore',
cwd: folder
});
return true;
} catch {
return false;
}
};
exports.checkIfFolderIsGitRepo = checkIfFolderIsGitRepo;
const createGitRepository = async folder => {
const loader = (0, _cliTools().getLoader)();
loader.start('Initializing Git repository');
let version;
try {
version = JSON.parse(_fs().default.readFileSync(_path().default.join('node_modules/react-native/package.json'), 'utf8')).version;
} catch {}
try {
await (0, _execa().default)('git', ['init'], {
cwd: folder
});
await (0, _execa().default)('git', ['branch', '-M', 'main'], {
cwd: folder
});
await (0, _execa().default)('git', ['add', '.'], {
cwd: folder
});
await (0, _execa().default)('git', ['commit', '-m', `Initial commit\n\n${version ? 'Generated by react-native@' + version : ''}`], {
cwd: folder
});
loader.succeed();
} catch (e) {
loader.stop();
_cliTools().logger.debug('Could not create an empty Git repository, error: ', e);
}
};
exports.createGitRepository = createGitRepository;
//# sourceMappingURL=git.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["checkGitInstallation","execa","stdio","checkIfFolderIsGitRepo","folder","cwd","createGitRepository","loader","getLoader","start","version","JSON","parse","fs","readFileSync","path","join","succeed","e","stop","logger","debug"],"sources":["../../../src/commands/init/git.ts"],"sourcesContent":["import {getLoader, logger} from '@react-native-community/cli-tools';\nimport execa from 'execa';\nimport fs from 'fs';\nimport path from 'path';\n\nexport const checkGitInstallation = async (): Promise<boolean> => {\n try {\n await execa('git', ['--version'], {stdio: 'ignore'});\n return true;\n } catch {\n return false;\n }\n};\n\nexport const checkIfFolderIsGitRepo = async (\n folder: string,\n): Promise<boolean> => {\n try {\n await execa('git', ['rev-parse', '--is-inside-work-tree'], {\n stdio: 'ignore',\n cwd: folder,\n });\n return true;\n } catch {\n return false;\n }\n};\n\nexport const createGitRepository = async (folder: string) => {\n const loader = getLoader();\n\n loader.start('Initializing Git repository');\n\n let version;\n\n try {\n version = JSON.parse(\n fs.readFileSync(\n path.join('node_modules/react-native/package.json'),\n 'utf8',\n ),\n ).version;\n } catch {}\n\n try {\n await execa('git', ['init'], {cwd: folder});\n await execa('git', ['branch', '-M', 'main'], {cwd: folder});\n await execa('git', ['add', '.'], {cwd: folder});\n await execa(\n 'git',\n [\n 'commit',\n '-m',\n `Initial commit\\n\\n${\n version ? 'Generated by react-native@' + version : ''\n }`,\n ],\n {\n cwd: folder,\n },\n );\n loader.succeed();\n } catch (e) {\n loader.stop();\n logger.debug(\n 'Could not create an empty Git repository, error: ',\n e as string,\n );\n }\n};\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAEjB,MAAMA,oBAAoB,GAAG,YAA8B;EAChE,IAAI;IACF,MAAM,IAAAC,gBAAK,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE;MAACC,KAAK,EAAE;IAAQ,CAAC,CAAC;IACpD,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF,CAAC;AAAC;AAEK,MAAMC,sBAAsB,GAAG,MACpCC,MAAc,IACO;EACrB,IAAI;IACF,MAAM,IAAAH,gBAAK,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC,EAAE;MACzDC,KAAK,EAAE,QAAQ;MACfG,GAAG,EAAED;IACP,CAAC,CAAC;IACF,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF,CAAC;AAAC;AAEK,MAAME,mBAAmB,GAAG,MAAOF,MAAc,IAAK;EAC3D,MAAMG,MAAM,GAAG,IAAAC,qBAAS,GAAE;EAE1BD,MAAM,CAACE,KAAK,CAAC,6BAA6B,CAAC;EAE3C,IAAIC,OAAO;EAEX,IAAI;IACFA,OAAO,GAAGC,IAAI,CAACC,KAAK,CAClBC,aAAE,CAACC,YAAY,CACbC,eAAI,CAACC,IAAI,CAAC,wCAAwC,CAAC,EACnD,MAAM,CACP,CACF,CAACN,OAAO;EACX,CAAC,CAAC,MAAM,CAAC;EAET,IAAI;IACF,MAAM,IAAAT,gBAAK,EAAC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE;MAACI,GAAG,EAAED;IAAM,CAAC,CAAC;IAC3C,MAAM,IAAAH,gBAAK,EAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;MAACI,GAAG,EAAED;IAAM,CAAC,CAAC;IAC3D,MAAM,IAAAH,gBAAK,EAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;MAACI,GAAG,EAAED;IAAM,CAAC,CAAC;IAC/C,MAAM,IAAAH,gBAAK,EACT,KAAK,EACL,CACE,QAAQ,EACR,IAAI,EACH,qBACCS,OAAO,GAAG,4BAA4B,GAAGA,OAAO,GAAG,EACpD,EAAC,CACH,EACD;MACEL,GAAG,EAAED;IACP,CAAC,CACF;IACDG,MAAM,CAACU,OAAO,EAAE;EAClB,CAAC,CAAC,OAAOC,CAAC,EAAE;IACVX,MAAM,CAACY,IAAI,EAAE;IACbC,kBAAM,CAACC,KAAK,CACV,mDAAmD,EACnDH,CAAC,CACF;EACH;AACF,CAAC;AAAC"}

View File

@@ -0,0 +1,32 @@
declare const _default: {
func: ([projectName]: string[], options: {
template?: string | undefined;
npm?: boolean | undefined;
pm?: "yarn" | "npm" | "bun" | undefined;
directory?: string | undefined;
displayName?: string | undefined;
title?: string | undefined;
skipInstall?: boolean | undefined;
version?: string | undefined;
packageName?: string | undefined;
installPods?: string | boolean | undefined;
platformName?: string | undefined;
skipGitInit?: boolean | undefined;
replaceDirectory?: string | boolean | undefined;
yarnConfigOptions?: Record<string, string> | undefined;
}) => Promise<void>;
detached: boolean;
name: string;
description: string;
options: ({
name: string;
description: string;
parse?: undefined;
} | {
name: string;
description: string;
parse: (val: string) => Record<string, string>;
})[];
};
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkEmB,MAAM,KAAG,OAAO,MAAM,EAAE,MAAM,CAAC;;;AAhElD,wBA0EE"}

View File

@@ -0,0 +1,63 @@
"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: 'New app will be initialized in the directory of the same name. Android and iOS projects will use this name for publishing setup.',
options: [{
name: '--version <string>',
description: 'Shortcut for `--template react-native@version`'
}, {
name: '--template <string>',
description: 'Uses a custom template. Valid arguments are the ones supported by `yarn add [package]` or `npm install [package]`, if you are using `--npm` option'
}, {
name: '--npm',
description: 'Forces using npm for initialization'
}, {
name: '--pm <string>',
description: 'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `yarn`'
}, {
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'
}, {
name: '--install-pods [boolean]',
description: 'Determine if CocoaPods should be installed when initializing a project'
}, {
name: '--package-name <string>',
description: 'Inits a project with a custom package name (Android) and bundle ID (iOS), e.g. com.example.app'
}, {
name: '--platform-name <string>',
description: 'Name of out of tree platform to be used for ex. react-native-macos. This flag is optional as it should be passed automatically by out of tree platform. It needs to match the name of the platform declared in package.json'
}, {
name: '--skip-git-init',
description: 'Skip git repository initialization'
}, {
name: '--replace-directory [boolean]',
description: 'Replaces the directory if it already exists.'
}, {
name: '--yarn-config-options <string>',
description: 'Passes extra options that will be added to `.yarnrc.yml` file, format: key=value,key2=value2.',
parse: val => {
return Object.fromEntries(val.split(',').map(option => {
const [key, value] = option.split('=');
return [key, value];
}));
}
}]
};
exports.default = _default;
//# sourceMappingURL=index.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["func","init","detached","name","description","options","parse","val","Object","fromEntries","split","map","option","key","value"],"sources":["../../../src/commands/init/index.ts"],"sourcesContent":["import init from './init';\n\nexport default {\n func: init,\n detached: true,\n name: 'init [projectName]',\n description:\n 'New app will be initialized in the directory of the same name. Android and iOS projects will use this name for publishing setup.',\n options: [\n {\n name: '--version <string>',\n description: 'Shortcut for `--template react-native@version`',\n },\n {\n name: '--template <string>',\n description:\n 'Uses a custom template. Valid arguments are the ones supported by `yarn add [package]` or `npm install [package]`, if you are using `--npm` option',\n },\n {\n name: '--npm',\n description: 'Forces using npm for initialization',\n },\n {\n name: '--pm <string>',\n description:\n 'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `yarn`',\n },\n {\n name: '--directory <string>',\n description: 'Uses a custom directory instead of `<projectName>`.',\n },\n {\n name: '--title <string>',\n description: 'Uses a custom app title name for application',\n },\n {\n name: '--skip-install',\n description: 'Skips dependencies installation step',\n },\n {\n name: '--install-pods [boolean]',\n description:\n 'Determine if CocoaPods should be installed when initializing a project',\n },\n {\n name: '--package-name <string>',\n description:\n 'Inits a project with a custom package name (Android) and bundle ID (iOS), e.g. com.example.app',\n },\n {\n name: '--platform-name <string>',\n description:\n 'Name of out of tree platform to be used for ex. react-native-macos. This flag is optional as it should be passed automatically by out of tree platform. It needs to match the name of the platform declared in package.json',\n },\n {\n name: '--skip-git-init',\n description: 'Skip git repository initialization',\n },\n {\n name: '--replace-directory [boolean]',\n description: 'Replaces the directory if it already exists.',\n },\n {\n name: '--yarn-config-options <string>',\n description:\n 'Passes extra options that will be added to `.yarnrc.yml` file, format: key=value,key2=value2.',\n parse: (val: string): Record<string, string> => {\n return Object.fromEntries(\n val.split(',').map((option) => {\n const [key, value] = option.split('=');\n return [key, value];\n }),\n );\n },\n },\n ],\n};\n"],"mappings":";;;;;;AAAA;AAA0B;AAAA,eAEX;EACbA,IAAI,EAAEC,aAAI;EACVC,QAAQ,EAAE,IAAI;EACdC,IAAI,EAAE,oBAAoB;EAC1BC,WAAW,EACT,kIAAkI;EACpIC,OAAO,EAAE,CACP;IACEF,IAAI,EAAE,oBAAoB;IAC1BC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,qBAAqB;IAC3BC,WAAW,EACT;EACJ,CAAC,EACD;IACED,IAAI,EAAE,OAAO;IACbC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,eAAe;IACrBC,WAAW,EACT;EACJ,CAAC,EACD;IACED,IAAI,EAAE,sBAAsB;IAC5BC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,kBAAkB;IACxBC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,gBAAgB;IACtBC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,0BAA0B;IAChCC,WAAW,EACT;EACJ,CAAC,EACD;IACED,IAAI,EAAE,yBAAyB;IAC/BC,WAAW,EACT;EACJ,CAAC,EACD;IACED,IAAI,EAAE,0BAA0B;IAChCC,WAAW,EACT;EACJ,CAAC,EACD;IACED,IAAI,EAAE,iBAAiB;IACvBC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,+BAA+B;IACrCC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,gCAAgC;IACtCC,WAAW,EACT,+FAA+F;IACjGE,KAAK,EAAGC,GAAW,IAA6B;MAC9C,OAAOC,MAAM,CAACC,WAAW,CACvBF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAEC,MAAM,IAAK;QAC7B,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAGF,MAAM,CAACF,KAAK,CAAC,GAAG,CAAC;QACtC,OAAO,CAACG,GAAG,EAAEC,KAAK,CAAC;MACrB,CAAC,CAAC,CACH;IACH;EACF,CAAC;AAEL,CAAC;AAAA"}

View File

@@ -0,0 +1,20 @@
import * as PackageManager from '../../tools/packageManager';
type Options = {
template?: string;
npm?: boolean;
pm?: PackageManager.PackageManager;
directory?: string;
displayName?: string;
title?: string;
skipInstall?: boolean;
version?: string;
packageName?: string;
installPods?: string | boolean;
platformName?: string;
skipGitInit?: boolean;
replaceDirectory?: string | boolean;
yarnConfigOptions?: Record<string, string>;
};
declare const _default: ([projectName]: Array<string>, options: Options) => Promise<void>;
export default _default;
//# sourceMappingURL=init.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAkB7D,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC;wCAsYe,MAAM,MAAM,CAAC,WACnB,OAAO;AAFlB,wBAkEG"}

View File

@@ -0,0 +1,390 @@
"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 = _interopRequireWildcard(require("fs-extra"));
_fsExtra = function () {
return data;
};
return data;
}
var _validate = require("./validate");
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
var _printRunInstructions = _interopRequireDefault(require("./printRunInstructions"));
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _cliPlatformApple() {
const data = require("@react-native-community/cli-platform-apple");
_cliPlatformApple = function () {
return data;
};
return data;
}
var _template = require("./template");
var _editTemplate = require("./editTemplate");
var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
var _banner = _interopRequireDefault(require("./banner"));
var _TemplateAndVersionError = _interopRequireDefault(require("./errors/TemplateAndVersionError"));
var _bun = require("../../tools/bun");
var _npm = require("../../tools/npm");
var _yarn = require("../../tools/yarn");
function _crypto() {
const data = require("crypto");
_crypto = function () {
return data;
};
return data;
}
var _git = require("./git");
function _semver() {
const data = _interopRequireDefault(require("semver"));
_semver = function () {
return data;
};
return data;
}
var _executeCommand = require("../../tools/executeCommand");
var _DirectoryAlreadyExistsError = _interopRequireDefault(require("./errors/DirectoryAlreadyExistsError"));
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); }
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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 YARN_LEGACY_VERSION = '1.22.22';
const bumpYarnVersion = async (silent, root) => {
try {
let yarnVersion = _semver().default.parse((0, _yarn.getYarnVersionIfAvailable)());
if (yarnVersion) {
// `yarn set` is unsupported until 1.22, however it's a alias (yarnpkg/yarn/pull/7862) calling `policies set-version`.
const setVersionArgs = yarnVersion.major > 1 ? ['set', 'version', YARN_VERSION] : ['policies', 'set-version', YARN_LEGACY_VERSION];
await (0, _executeCommand.executeCommand)('yarn', setVersionArgs, {
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) {
return _fsExtra().default.existsSync(dir);
}
function getConflictsForDirectory(directory) {
return (0, _fsExtra().readdirSync)(directory);
}
async function setProjectDirectory(directory, replaceDirectory) {
const directoryExists = doesDirectoryExist(directory);
if (replaceDirectory === 'false' && directoryExists) {
throw new _DirectoryAlreadyExistsError.default(directory);
}
let deleteDirectory = false;
if (replaceDirectory === 'true' && directoryExists) {
deleteDirectory = true;
} else if (directoryExists) {
const conflicts = getConflictsForDirectory(directory);
if (conflicts.length > 0) {
let warnMessage = `The directory ${_chalk().default.bold(directory)} contains files that will be overwritten:\n`;
for (const conflict of conflicts) {
warnMessage += ` ${conflict}\n`;
}
_cliTools().logger.warn(warnMessage);
const {
replace
} = await (0, _cliTools().prompt)({
type: 'confirm',
name: 'replace',
message: 'Do you want to replace existing files?'
});
deleteDirectory = replace;
if (!replace) {
throw new _DirectoryAlreadyExistsError.default(directory);
}
}
}
try {
if (deleteDirectory) {
_fsExtra().default.removeSync(directory);
}
_fsExtra().default.mkdirSync(directory, {
recursive: true
});
process.chdir(directory);
} catch (error) {
throw new (_cliTools().CLIError)('Error occurred while trying to create project directory.', error);
}
return process.cwd();
}
function getTemplateName(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).
const name = Object.keys(JSON.parse(_fsExtra().default.readFileSync(_path().default.join(cwd, './package.json'), 'utf8')).dependencies)[0];
return name;
}
//set cache to empty string to prevent installing cocoapods on freshly created project
function setEmptyHashForCachedDependencies(projectName) {
_cliTools().cacheManager.set(projectName, 'dependencies', (0, _crypto().createHash)('md5').update('').digest('hex'));
}
async function createFromTemplate({
projectName,
shouldBumpYarnVersion,
templateUri,
npm,
pm,
directory,
projectTitle,
skipInstall,
packageName,
installCocoaPods,
replaceDirectory,
yarnConfigOptions
}) {
_cliTools().logger.debug('Initializing new project');
// Only print out the banner if we're not in a CI
if (!process.env.CI) {
_cliTools().logger.log(_banner.default);
}
let didInstallPods = String(installCocoaPods) === 'true';
let packageManager = pm;
if (pm) {
packageManager = pm;
} else {
const userAgentPM = userAgentPackageManager();
// if possible, use the package manager from the user agent. Otherwise fallback to default (yarn)
packageManager = userAgentPM || 'yarn';
}
if (npm) {
_cliTools().logger.warn('Flag --npm is deprecated and will be removed soon. In the future, please use --pm npm instead.');
packageManager = 'npm';
}
// if the project with the name already has cache, remove the cache to avoid problems with pods installation
_cliTools().cacheManager.removeProjectCache(projectName);
const projectDirectory = await setProjectDirectory(directory, String(replaceDirectory));
const loader = (0, _cliTools().getLoader)({
text: 'Downloading template'
});
const templateSourceDir = _fsExtra().default.mkdtempSync(_path().default.join(_os().default.tmpdir(), 'rncli-init-template-'));
try {
loader.start();
await (0, _template.installTemplatePackage)(templateUri, templateSourceDir, packageManager, yarnConfigOptions);
loader.succeed();
loader.start('Copying template');
const templateName = getTemplateName(templateSourceDir);
const templateConfig = (0, _template.getTemplateConfig)(templateName, templateSourceDir);
await (0, _template.copyTemplate)(templateName, templateConfig.templateDir, templateSourceDir);
loader.succeed();
loader.start('Processing template');
await (0, _editTemplate.changePlaceholderInTemplate)({
projectName,
projectTitle,
placeholderName: templateConfig.placeholderName,
placeholderTitle: templateConfig.titlePlaceholder,
packageName
});
if (packageManager === 'yarn' && shouldBumpYarnVersion) {
await bumpYarnVersion(false, projectDirectory);
}
loader.succeed();
const {
postInitScript
} = templateConfig;
if (postInitScript) {
loader.info('Executing post init script ');
await (0, _template.executePostInitScript)(templateName, postInitScript, templateSourceDir);
}
if (!skipInstall) {
await installDependencies({
packageManager,
loader,
root: projectDirectory
});
if (process.platform === 'darwin') {
const installPodsValue = String(installCocoaPods);
if (installPodsValue === 'true') {
didInstallPods = true;
await (0, _cliPlatformApple().installPods)(loader);
loader.succeed();
setEmptyHashForCachedDependencies(projectName);
} else if (installPodsValue === 'undefined') {
const {
installCocoapods
} = await (0, _cliTools().prompt)({
type: 'confirm',
name: 'installCocoapods',
message: `Do you want to install CocoaPods now? ${_chalk().default.reset.dim('Only needed if you run your project in Xcode directly')}`
});
didInstallPods = installCocoapods;
if (installCocoapods) {
await (0, _cliPlatformApple().installPods)(loader);
loader.succeed();
setEmptyHashForCachedDependencies(projectName);
}
}
}
} else {
didInstallPods = false;
loader.succeed('Dependencies installation skipped');
}
} catch (e) {
if (e instanceof Error) {
_cliTools().logger.error('Installing pods failed. This doesn\'t affect project initialization and you can safely proceed. \nHowever, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.\n');
}
loader.fail();
didInstallPods = false;
} finally {
_fsExtra().default.removeSync(templateSourceDir);
}
if (process.platform === 'darwin') {
_cliTools().logger.log('\n');
_cliTools().logger.info(`💡 To enable automatic CocoaPods installation when building for iOS you can create react-native.config.js with automaticPodsInstallation field. \n${_chalk().default.reset.dim(`For more details, see ${_chalk().default.underline('https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation')}`)}
`);
}
return {
didInstallPods
};
}
async function installDependencies({
packageManager,
loader,
root
}) {
loader.start('Installing dependencies');
await PackageManager.installAll({
packageManager,
silent: true,
root
});
loader.succeed();
}
function checkPackageManagerAvailability(packageManager) {
if (packageManager === 'bun') {
return (0, _bun.getBunVersionIfAvailable)();
} else if (packageManager === 'npm') {
return (0, _npm.getNpmVersionIfAvailable)();
} else if (packageManager === 'yarn') {
return (0, _yarn.getYarnVersionIfAvailable)();
}
return false;
}
function createTemplateUri(options, version) {
const isTypescriptTemplate = options.template === 'react-native-template-typescript';
// This allows to correctly retrieve template uri for out of tree platforms.
const platform = options.platformName || 'react-native';
if (isTypescriptTemplate) {
_cliTools().logger.warn("Ignoring custom template: 'react-native-template-typescript'. Starting from React Native v0.71 TypeScript is used by default.");
return platform;
}
return options.template || `${platform}@${version}`;
}
async function createProject(projectName, directory, version, shouldBumpYarnVersion, options) {
const templateUri = createTemplateUri(options, version);
return createFromTemplate({
projectName,
shouldBumpYarnVersion,
templateUri,
npm: options.npm,
pm: options.pm,
directory,
projectTitle: options.title,
skipInstall: options.skipInstall,
packageName: options.packageName,
installCocoaPods: options.installPods,
version,
replaceDirectory: options.replaceDirectory,
yarnConfigOptions: options.yarnConfigOptions
});
}
function userAgentPackageManager() {
const userAgent = process.env.npm_config_user_agent;
if (userAgent && userAgent.startsWith('bun')) {
return 'bun';
}
return null;
}
var initialize = async function initialize([projectName], options) {
if (!projectName) {
const {
projName
} = await (0, _cliTools().prompt)({
type: 'text',
name: 'projName',
message: 'How would you like to name the app?'
});
projectName = projName;
}
(0, _validate.validateProjectName)(projectName);
if (!!options.template && !!options.version) {
throw new _TemplateAndVersionError.default(options.template);
}
const root = process.cwd();
const version = options.version || DEFAULT_VERSION;
const directoryName = _path().default.relative(root, options.directory || projectName);
const projectFolder = _path().default.join(root, directoryName);
if (options.pm && !checkPackageManagerAvailability(options.pm)) {
_cliTools().logger.error('Seems like the package manager you want to use is not installed. Please install it or choose another package manager.');
return;
}
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, shouldBumpYarnVersion, options);
if (shouldCreateGitRepository && !options.skipGitInit) {
await (0, _git.createGitRepository)(projectFolder);
}
(0, _printRunInstructions.default)(projectFolder, projectName, {
showPodsInstructions: !didInstallPods
});
};
exports.default = initialize;
//# sourceMappingURL=init.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
/**
* 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
*/
interface Options {
showPodsInstructions?: boolean;
}
declare function printRunInstructions(projectDir: string, projectName: string, options?: Options): void;
export default printRunInstructions;
//# sourceMappingURL=printRunInstructions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"printRunInstructions.d.ts","sourceRoot":"","sources":["../../../src/commands/init/printRunInstructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,UAAU,OAAO;IACf,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,iBAAS,oBAAoB,CAC3B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,OAER,QAiEF;AAED,eAAe,oBAAoB,CAAC"}

View File

@@ -0,0 +1,99 @@
"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 _process() {
const data = _interopRequireDefault(require("process"));
_process = 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, options = {
showPodsInstructions: false
}) {
let iosInstructions = '';
let desktopInstructions = '';
if (_process().default.platform === 'darwin') {
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`));
iosInstructions = `
${_chalk().default.cyan(`Run instructions for ${_chalk().default.bold('iOS')}`)}:
• cd "${projectDir}${options.showPodsInstructions ? '/ios' : ''}"
${options.showPodsInstructions ? `
• Install Cocoapods
• bundle install # you need to run this only once in your project.
• bundle exec pod install
• cd ..
` : ''}
• npx react-native run-ios
${_chalk().default.dim('- or -')}
• Open ${relativeXcodeProjectPath} in Xcode or run "xed -b ios"
• Hit the Run button
`;
desktopInstructions = `
${_chalk().default.magenta(`Run instructions for ${_chalk().default.bold('macOS')}`)}:
• See ${_chalk().default.underline('https://aka.ms/ReactNativeGuideMacOS')} for the latest up-to-date instructions.
`;
}
if (_process().default.platform === 'win32') {
desktopInstructions = `
${_chalk().default.cyan(`Run instructions for ${_chalk().default.bold('Windows')}`)}:
• See ${_chalk().default.underline('https://aka.ms/ReactNativeGuideWindows')} for the latest up-to-date instructions.
`;
}
const androidInstructions = `
${_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
`;
_cliTools().logger.log(`
${androidInstructions}${iosInstructions}${desktopInstructions}
`);
}
var _default = printRunInstructions;
exports.default = _default;
//# sourceMappingURL=printRunInstructions.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["printRunInstructions","projectDir","projectName","options","showPodsInstructions","iosInstructions","desktopInstructions","process","platform","iosProjectDir","path","resolve","iosPodsFile","isUsingPods","fs","existsSync","relativeXcodeProjectPath","relative","chalk","cyan","bold","dim","magenta","underline","androidInstructions","green","logger","log"],"sources":["../../../src/commands/init/printRunInstructions.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n */\n\nimport path from 'path';\nimport fs from 'fs';\nimport process from 'process';\nimport chalk from 'chalk';\nimport {logger} from '@react-native-community/cli-tools';\n\ninterface Options {\n showPodsInstructions?: boolean;\n}\n\nfunction printRunInstructions(\n projectDir: string,\n projectName: string,\n options: Options = {\n showPodsInstructions: false,\n },\n) {\n let iosInstructions = '';\n let desktopInstructions = '';\n\n if (process.platform === 'darwin') {\n const iosProjectDir = path.resolve(projectDir, 'ios');\n const iosPodsFile = path.resolve(\n iosProjectDir,\n `${projectName}.xcworkspace`,\n );\n const isUsingPods = fs.existsSync(iosPodsFile);\n\n const relativeXcodeProjectPath = path.relative(\n '..',\n isUsingPods\n ? iosPodsFile\n : path.resolve(iosProjectDir, `${projectName}.xcodeproj`),\n );\n\n iosInstructions = `\n ${chalk.cyan(`Run instructions for ${chalk.bold('iOS')}`)}:\n • cd \"${projectDir}${options.showPodsInstructions ? '/ios' : ''}\"\n ${\n options.showPodsInstructions\n ? `\n • Install Cocoapods\n • bundle install # you need to run this only once in your project.\n • bundle exec pod install\n • cd ..\n `\n : ''\n }\n • npx react-native run-ios\n ${chalk.dim('- or -')}\n • Open ${relativeXcodeProjectPath} in Xcode or run \"xed -b ios\"\n • Hit the Run button\n `;\n\n desktopInstructions = `\n ${chalk.magenta(`Run instructions for ${chalk.bold('macOS')}`)}:\n • See ${chalk.underline(\n 'https://aka.ms/ReactNativeGuideMacOS',\n )} for the latest up-to-date instructions.\n `;\n }\n\n if (process.platform === 'win32') {\n desktopInstructions = `\n ${chalk.cyan(`Run instructions for ${chalk.bold('Windows')}`)}:\n • See ${chalk.underline(\n 'https://aka.ms/ReactNativeGuideWindows',\n )} for the latest up-to-date instructions.\n `;\n }\n\n const androidInstructions = `\n ${chalk.green(`Run instructions for ${chalk.bold('Android')}`)}:\n • Have an Android emulator running (quickest way to get started), or a device connected.\n • cd \"${projectDir}\" && npx react-native run-android\n `;\n\n logger.log(`\n ${androidInstructions}${iosInstructions}${desktopInstructions}\n `);\n}\n\nexport default printRunInstructions;\n"],"mappings":";;;;;;AASA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAyD;AAbzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,oBAAoB,CAC3BC,UAAkB,EAClBC,WAAmB,EACnBC,OAAgB,GAAG;EACjBC,oBAAoB,EAAE;AACxB,CAAC,EACD;EACA,IAAIC,eAAe,GAAG,EAAE;EACxB,IAAIC,mBAAmB,GAAG,EAAE;EAE5B,IAAIC,kBAAO,CAACC,QAAQ,KAAK,QAAQ,EAAE;IACjC,MAAMC,aAAa,GAAGC,eAAI,CAACC,OAAO,CAACV,UAAU,EAAE,KAAK,CAAC;IACrD,MAAMW,WAAW,GAAGF,eAAI,CAACC,OAAO,CAC9BF,aAAa,EACZ,GAAEP,WAAY,cAAa,CAC7B;IACD,MAAMW,WAAW,GAAGC,aAAE,CAACC,UAAU,CAACH,WAAW,CAAC;IAE9C,MAAMI,wBAAwB,GAAGN,eAAI,CAACO,QAAQ,CAC5C,IAAI,EACJJ,WAAW,GACPD,WAAW,GACXF,eAAI,CAACC,OAAO,CAACF,aAAa,EAAG,GAAEP,WAAY,YAAW,CAAC,CAC5D;IAEDG,eAAe,GAAI;AACvB,IAAIa,gBAAK,CAACC,IAAI,CAAE,wBAAuBD,gBAAK,CAACE,IAAI,CAAC,KAAK,CAAE,EAAC,CAAE;AAC5D,YAAYnB,UAAW,GAAEE,OAAO,CAACC,oBAAoB,GAAG,MAAM,GAAG,EAAG;AACpE,MACMD,OAAO,CAACC,oBAAoB,GACvB;AACX;AACA;AACA;AACA;AACA,KAAK,GACK,EACL;AACL;AACA,MAAMc,gBAAK,CAACG,GAAG,CAAC,QAAQ,CAAE;AAC1B,aAAaL,wBAAyB;AACtC;AACA,KAAK;IAEDV,mBAAmB,GAAI;AAC3B,IAAIY,gBAAK,CAACI,OAAO,CAAE,wBAAuBJ,gBAAK,CAACE,IAAI,CAAC,OAAO,CAAE,EAAC,CAAE;AACjE,YAAYF,gBAAK,CAACK,SAAS,CACrB,sCAAsC,CACtC;AACN,KAAK;EACH;EAEA,IAAIhB,kBAAO,CAACC,QAAQ,KAAK,OAAO,EAAE;IAChCF,mBAAmB,GAAI;AAC3B,IAAIY,gBAAK,CAACC,IAAI,CAAE,wBAAuBD,gBAAK,CAACE,IAAI,CAAC,SAAS,CAAE,EAAC,CAAE;AAChE,YAAYF,gBAAK,CAACK,SAAS,CACrB,wCAAwC,CACxC;AACN,KAAK;EACH;EAEA,MAAMC,mBAAmB,GAAI;AAC/B,IAAIN,gBAAK,CAACO,KAAK,CAAE,wBAAuBP,gBAAK,CAACE,IAAI,CAAC,SAAS,CAAE,EAAC,CAAE;AACjE;AACA,YAAYnB,UAAW;AACvB,GAAG;EAEDyB,kBAAM,CAACC,GAAG,CAAE;AACd,IAAIH,mBAAoB,GAAEnB,eAAgB,GAAEC,mBAAoB;AAChE,GAAG,CAAC;AACJ;AAAC,eAEcN,oBAAoB;AAAA"}

View File

@@ -0,0 +1,13 @@
import execa from 'execa';
import * as PackageManager from '../../tools/packageManager';
export type TemplateConfig = {
placeholderName: string;
templateDir: string;
postInitScript?: string;
titlePlaceholder?: string;
};
export declare function installTemplatePackage(templateName: string, root: string, packageManager: PackageManager.PackageManager, yarnConfigOptions?: Record<string, string>): Promise<execa.ExecaReturnValue<string>>;
export declare function getTemplateConfig(templateName: string, templateSourceDir: string): TemplateConfig;
export declare function copyTemplate(templateName: string, templateDir: string, templateSourceDir: string): Promise<void>;
export declare function executePostInitScript(templateName: string, postInitScript: string, templateSourceDir: string): execa.ExecaChildProcess<string>;
//# sourceMappingURL=template.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/commands/init/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAQ7D,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,2CA0C3C;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,GACxB,cAAc,CAkBhB;AAED,wBAAsB,YAAY,CAChC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,MAAM,iBAc1B;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,mCAY1B"}

View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.copyTemplate = copyTemplate;
exports.executePostInitScript = executePostInitScript;
exports.getTemplateConfig = getTemplateConfig;
exports.installTemplatePackage = installTemplatePackage;
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;
}
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); }
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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
async function installTemplatePackage(templateName, root, packageManager, yarnConfigOptions) {
_cliTools().logger.debug(`Installing template from ${templateName}`);
await PackageManager.init({
packageManager,
silent: true,
root
});
if (packageManager === 'yarn' && (0, _yarn.getYarnVersionIfAvailable)() !== null) {
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);
for (let key in yarnConfigOptions) {
if (yarnConfigOptions.hasOwnProperty(key)) {
let value = yarnConfigOptions[key];
(0, _executeCommand.executeCommand)('yarn', ['config', 'set', key, value], options);
}
}
}
return PackageManager.install([templateName], {
packageManager,
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/main/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.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare function validateProjectName(name: string): void;
//# sourceMappingURL=validate.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/init/validate.ts"],"names":[],"mappings":"AA8DA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,QAa/C"}

View File

@@ -0,0 +1,29 @@
"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(lowerCaseName);
}
if (name.match(/helloworld/gi)) {
throw new _HelloWorldError.default();
}
}
//# sourceMappingURL=validate.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NAME_REGEX","javaKeywords","reservedNames","validateProjectName","name","String","match","InvalidNameError","lowerCaseName","toLowerCase","includes","ReservedNameError","HelloWorldError"],"sources":["../../../src/commands/init/validate.ts"],"sourcesContent":["import InvalidNameError from './errors/InvalidNameError';\nimport ReservedNameError from './errors/ReservedNameError';\nimport HelloWorldError from './errors/HelloWorldError';\n\nconst NAME_REGEX = /^[$A-Z_][0-9A-Z_$]*$/i;\n\n// ref: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html\nconst javaKeywords = [\n 'abstract',\n 'continue',\n 'for',\n 'new',\n 'switch',\n 'assert',\n 'default',\n 'goto',\n 'package',\n 'synchronized',\n 'boolean',\n 'do',\n 'if',\n 'private',\n 'this',\n 'break',\n 'double',\n 'implements',\n 'protected',\n 'throw',\n 'byte',\n 'else',\n 'import',\n 'public',\n 'throws',\n 'case',\n 'enum',\n 'instanceof',\n 'return',\n 'transient',\n 'catch',\n 'extends',\n 'int',\n 'short',\n 'try',\n 'char',\n 'final',\n 'interface',\n 'static',\n 'void',\n 'class',\n 'finally',\n 'long',\n 'strictfp',\n 'volatile',\n 'const',\n 'float',\n 'native',\n 'super',\n 'while',\n];\n\nconst reservedNames = ['react', 'react-native', ...javaKeywords];\n\nexport function validateProjectName(name: string) {\n if (!String(name).match(NAME_REGEX)) {\n throw new InvalidNameError(name);\n }\n\n const lowerCaseName = name.toLowerCase();\n if (reservedNames.includes(lowerCaseName)) {\n throw new ReservedNameError(lowerCaseName);\n }\n\n if (name.match(/helloworld/gi)) {\n throw new HelloWorldError();\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAuD;AAEvD,MAAMA,UAAU,GAAG,uBAAuB;;AAE1C;AACA,MAAMC,YAAY,GAAG,CACnB,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,cAAc,EACd,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,KAAK,EACL,OAAO,EACP,KAAK,EACL,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,CACR;AAED,MAAMC,aAAa,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,GAAGD,YAAY,CAAC;AAEzD,SAASE,mBAAmB,CAACC,IAAY,EAAE;EAChD,IAAI,CAACC,MAAM,CAACD,IAAI,CAAC,CAACE,KAAK,CAACN,UAAU,CAAC,EAAE;IACnC,MAAM,IAAIO,yBAAgB,CAACH,IAAI,CAAC;EAClC;EAEA,MAAMI,aAAa,GAAGJ,IAAI,CAACK,WAAW,EAAE;EACxC,IAAIP,aAAa,CAACQ,QAAQ,CAACF,aAAa,CAAC,EAAE;IACzC,MAAM,IAAIG,0BAAiB,CAACH,aAAa,CAAC;EAC5C;EAEA,IAAIJ,IAAI,CAACE,KAAK,CAAC,cAAc,CAAC,EAAE;IAC9B,MAAM,IAAIM,wBAAe,EAAE;EAC7B;AACF"}

View File

@@ -0,0 +1,12 @@
import type { Config } from '@react-native-community/cli-types';
/**
* Upgrade application to a new version of React Native.
*/
declare function upgrade(_: string[], { root: projectDir }: Config): Promise<void>;
declare const upgradeCommand: {
name: string;
description: string;
func: typeof upgrade;
};
export default upgradeCommand;
//# sourceMappingURL=upgrade.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../src/commands/upgrade/upgrade.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAG9D;;GAEG;AACH,iBAAe,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC,EAAE,MAAM,iBAqC7D;AAED,QAAA,MAAM,cAAc;;;;CAInB,CAAC;AAEF,eAAe,cAAc,CAAC"}

View File

@@ -0,0 +1,59 @@
"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;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Upgrade application to a new version of React Native.
*/
async function upgrade(_, {
root: projectDir
}) {
var _update$upgrade;
const url = new URL('https://react-native-community.github.io/upgrade-helper');
const update = await _cliTools().version.latest(projectDir);
if (!(update === null || update === void 0 ? void 0 : update.current)) {
_cliTools().logger.error(`Cannot figure out your version of React Native, use: ${_chalk().default.dim(url.toString())}`);
process.exit(1);
}
const from = update.current;
const to = (_update$upgrade = update.upgrade) === null || _update$upgrade === void 0 ? void 0 : _update$upgrade.stable;
if (to === from) {
_cliTools().logger.success(`You are on the most recent stable release of React Native: ${_chalk().default.white(from)} 🎉.`);
return;
}
url.searchParams.set('from', from);
if (to) {
url.searchParams.set('to', to);
}
_cliTools().logger.log(`
To upgrade React Native please follow the instructions here:
${_chalk().default.dim(url.toString())}
`);
}
const upgradeCommand = {
name: 'upgrade',
description: 'Generate a link to the upgrade helper to help you upgrade',
func: upgrade
};
var _default = upgradeCommand;
exports.default = _default;
//# sourceMappingURL=upgrade.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["upgrade","_","root","projectDir","url","URL","update","version","latest","current","logger","error","chalk","dim","toString","process","exit","from","to","stable","success","white","searchParams","set","log","upgradeCommand","name","description","func"],"sources":["../../../src/commands/upgrade/upgrade.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type {Config} from '@react-native-community/cli-types';\nimport {logger, version} from '@react-native-community/cli-tools';\n\n/**\n * Upgrade application to a new version of React Native.\n */\nasync function upgrade(_: string[], {root: projectDir}: Config) {\n const url = new URL(\n 'https://react-native-community.github.io/upgrade-helper',\n );\n\n const update = await version.latest(projectDir);\n if (!update?.current) {\n logger.error(\n `Cannot figure out your version of React Native, use: ${chalk.dim(\n url.toString(),\n )}`,\n );\n process.exit(1);\n }\n\n const from = update.current;\n const to = update.upgrade?.stable;\n\n if (to === from) {\n logger.success(\n `You are on the most recent stable release of React Native: ${chalk.white(\n from,\n )} 🎉.`,\n );\n return;\n }\n\n url.searchParams.set('from', from);\n if (to) {\n url.searchParams.set('to', to);\n }\n\n logger.log(`\nTo upgrade React Native please follow the instructions here:\n\n ${chalk.dim(url.toString())}\n`);\n}\n\nconst upgradeCommand = {\n name: 'upgrade',\n description: 'Generate a link to the upgrade helper to help you upgrade',\n func: upgrade,\n};\n\nexport default upgradeCommand;\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkE;AAElE;AACA;AACA;AACA,eAAeA,OAAO,CAACC,CAAW,EAAE;EAACC,IAAI,EAAEC;AAAkB,CAAC,EAAE;EAAA;EAC9D,MAAMC,GAAG,GAAG,IAAIC,GAAG,CACjB,yDAAyD,CAC1D;EAED,MAAMC,MAAM,GAAG,MAAMC,mBAAO,CAACC,MAAM,CAACL,UAAU,CAAC;EAC/C,IAAI,EAACG,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,OAAO,GAAE;IACpBC,kBAAM,CAACC,KAAK,CACT,wDAAuDC,gBAAK,CAACC,GAAG,CAC/DT,GAAG,CAACU,QAAQ,EAAE,CACd,EAAC,CACJ;IACDC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;EACjB;EAEA,MAAMC,IAAI,GAAGX,MAAM,CAACG,OAAO;EAC3B,MAAMS,EAAE,sBAAGZ,MAAM,CAACN,OAAO,oDAAd,gBAAgBmB,MAAM;EAEjC,IAAID,EAAE,KAAKD,IAAI,EAAE;IACfP,kBAAM,CAACU,OAAO,CACX,8DAA6DR,gBAAK,CAACS,KAAK,CACvEJ,IAAI,CACJ,MAAK,CACR;IACD;EACF;EAEAb,GAAG,CAACkB,YAAY,CAACC,GAAG,CAAC,MAAM,EAAEN,IAAI,CAAC;EAClC,IAAIC,EAAE,EAAE;IACNd,GAAG,CAACkB,YAAY,CAACC,GAAG,CAAC,IAAI,EAAEL,EAAE,CAAC;EAChC;EAEAR,kBAAM,CAACc,GAAG,CAAE;AACd;AACA;AACA,IAAIZ,gBAAK,CAACC,GAAG,CAACT,GAAG,CAACU,QAAQ,EAAE,CAAE;AAC9B,CAAC,CAAC;AACF;AAEA,MAAMW,cAAc,GAAG;EACrBC,IAAI,EAAE,SAAS;EACfC,WAAW,EAAE,2DAA2D;EACxEC,IAAI,EAAE5B;AACR,CAAC;AAAC,eAEayB,cAAc;AAAA"}

View File

@@ -0,0 +1,5 @@
import loadConfig from '@react-native-community/cli-config';
declare function run(platformName?: string): Promise<void>;
declare const bin: string;
export { run, bin, loadConfig };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAyI5D,iBAAe,GAAG,CAAC,YAAY,CAAC,EAAE,MAAM,iBAMvC;AAoFD,QAAA,MAAM,GAAG,QAA2B,CAAC;AAErC,OAAO,EAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAC,CAAC"}

View File

@@ -0,0 +1,209 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bin = void 0;
Object.defineProperty(exports, "loadConfig", {
enumerable: true,
get: function () {
return _cliConfig().default;
}
});
exports.run = run;
function _cliConfig() {
const data = _interopRequireDefault(require("@react-native-community/cli-config"));
_cliConfig = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _child_process() {
const data = _interopRequireDefault(require("child_process"));
_child_process = function () {
return data;
};
return data;
}
function _commander() {
const data = require("commander");
_commander = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
var _commands = require("./commands");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const pkgJson = require('../package.json');
const program = new (_commander().Command)().usage('[command] [options]').version(pkgJson.version, '-v', 'Output the current version').enablePositionalOptions();
const handleError = err => {
_cliTools().logger.enable();
if (program.opts().verbose) {
_cliTools().logger.error(err.message);
} else {
// Some error messages (esp. custom ones) might have `.` at the end already.
const message = err.message.replace(/\.$/, '');
_cliTools().logger.error(`${message}.`);
}
if (err.stack) {
_cliTools().logger.log(err.stack);
}
if (!program.opts().verbose && _cliTools().logger.hasDebugMessages()) {
_cliTools().logger.info(_chalk().default.dim(`Run CLI with ${_chalk().default.reset('--verbose')} ${_chalk().default.dim('flag for more details.')}`));
}
process.exit(1);
};
function printExamples(examples) {
let output = [];
if (examples && examples.length > 0) {
const formattedUsage = examples.map(example => ` ${example.desc}: \n ${_chalk().default.cyan(example.cmd)}`).join('\n\n');
output = output.concat([_chalk().default.bold('\nExample usage:'), formattedUsage]);
}
return output.join('\n').concat('\n');
}
/**
* Custom type assertion needed for the `makeCommand` conditional
* types to be properly resolved.
*/
function isDetachedCommand(command) {
return command.detached === true;
}
function isAttachedCommand(command) {
return !isDetachedCommand(command);
}
/**
* Attaches a new command onto global `commander` instance.
*
* Note that this function takes additional argument of `Config` type in case
* passed `command` needs it for its execution.
*/
function attachCommand(command, config) {
// commander@9.x will internally push commands into an array structure!
// Commands with duplicate names (e.g. from config) must be reduced before
// calling this function.
// https://unpkg.com/browse/commander@9.4.1/lib/command.js#L1308
if (program.commands.find(cmd => cmd.name() === command.name)) {
throw new Error('Invariant Violation: Attempted to override an already registered ' + `command: '${command.name}'. This is not supported by the underlying ` + 'library and will cause bugs. Ensure a command with this `name` is ' + 'only registered once.');
}
const cmd = program.command(command.name).option('--verbose', 'Increase logging verbosity').action(async function handleAction(...args) {
const passedOptions = this.opts();
const argv = Array.from(args).slice(0, -1);
try {
if (isDetachedCommand(command)) {
await command.func(argv, passedOptions, config);
} else if (isAttachedCommand(command)) {
await command.func(argv, config, passedOptions);
} else {
throw new Error('A command must be either attached or detached');
}
} catch (error) {
handleError(error);
}
});
if (command.description) {
cmd.description(command.description);
}
cmd.addHelpText('after', printExamples(command.examples));
for (const opt of command.options || []) {
cmd.option(opt.name, opt.description ?? '', opt.parse || (val => val), typeof opt.default === 'function' ? opt.default(config) : opt.default);
}
}
// Platform name is optional argument passed by out of tree platforms.
async function run(platformName) {
try {
await setupAndRun(platformName);
} catch (e) {
handleError(e);
}
}
const isCommandPassed = commandName => {
return process.argv.filter(arg => arg === commandName).length > 0;
};
async function setupAndRun(platformName) {
// Commander is not available yet
// when we run `config`, we don't want to output anything to the console. We
// expect it to return valid JSON
if (isCommandPassed('config')) {
_cliTools().logger.disable();
}
_cliTools().logger.setVerbose(process.argv.includes('--verbose'));
// We only have a setup script for UNIX envs currently
if (process.platform !== 'win32') {
const scriptName = 'setup_env.sh';
const absolutePath = _path().default.join(__dirname, '..', scriptName);
try {
_child_process().default.execFileSync(absolutePath, {
stdio: 'pipe'
});
} catch (error) {
_cliTools().logger.warn(`Failed to run environment setup script "${scriptName}"\n\n${_chalk().default.red(error)}`);
_cliTools().logger.info(`React Native CLI will continue to run if your local environment matches what React Native expects. If it does fail, check out "${absolutePath}" and adjust your environment to match it.`);
}
}
let config;
try {
config = (0, _cliConfig().default)();
_cliTools().logger.enable();
const commands = {};
// Reduce overridden commands before registering
for (const command of [..._commands.projectCommands, ...config.commands]) {
commands[command.name] = command;
}
for (const command of Object.values(commands)) {
attachCommand(command, config);
}
} catch (error) {
/**
* When there is no `package.json` found, the CLI will enter `detached` mode and a subset
* of commands will be available. That's why we don't throw on such kind of error.
*/
if (error.message.includes("We couldn't find a package.json")) {
_cliTools().logger.debug(error.message);
_cliTools().logger.debug('Failed to load configuration of your project. Only a subset of commands will be available.');
} else {
throw new (_cliTools().CLIError)('Failed to load configuration of your project.', error);
}
} finally {
for (const command of _commands.detachedCommands) {
attachCommand(command, config);
}
}
const argv = [...process.argv];
// If out of tree platform specifices custom platform name, we need to pass it to argv array for the init command.
if (isCommandPassed('init') && platformName) {
argv.push('--platform-name', platformName);
}
program.parse(argv);
}
const bin = require.resolve('./bin');
exports.bin = bin;
//# sourceMappingURL=index.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
export declare function getBunVersionIfAvailable(): string | null;
export declare function isProjectUsingBun(cwd: string): string | undefined;
//# sourceMappingURL=bun.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../src/tools/bun.ts"],"names":[],"mappings":"AAKA,wBAAgB,wBAAwB,kBAsBvC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,sBAE5C"}

View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getBunVersionIfAvailable = getBunVersionIfAvailable;
exports.isProjectUsingBun = isProjectUsingBun;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _child_process() {
const data = require("child_process");
_child_process = function () {
return data;
};
return data;
}
function _findUp() {
const data = _interopRequireDefault(require("find-up"));
_findUp = function () {
return data;
};
return data;
}
function _semver() {
const data = _interopRequireDefault(require("semver"));
_semver = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getBunVersionIfAvailable() {
let bunVersion;
try {
bunVersion = ((0, _child_process().execSync)('bun --version', {
stdio: [0, 'pipe', 'ignore']
}).toString() || '').trim();
} catch (error) {
return null;
}
try {
if (_semver().default.gte(bunVersion, '1.0.0')) {
return bunVersion;
}
return null;
} catch (error) {
_cliTools().logger.error(`Cannot parse bun version: ${bunVersion}`);
return null;
}
}
function isProjectUsingBun(cwd) {
return _findUp().default.sync('bun.lockb', {
cwd
});
}
//# sourceMappingURL=bun.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getBunVersionIfAvailable","bunVersion","execSync","stdio","toString","trim","error","semver","gte","logger","isProjectUsingBun","cwd","findUp","sync"],"sources":["../../src/tools/bun.ts"],"sourcesContent":["import {logger} from '@react-native-community/cli-tools';\nimport {execSync} from 'child_process';\nimport findUp from 'find-up';\nimport semver from 'semver';\n\nexport function getBunVersionIfAvailable() {\n let bunVersion;\n\n try {\n bunVersion = (\n execSync('bun --version', {\n stdio: [0, 'pipe', 'ignore'],\n }).toString() || ''\n ).trim();\n } catch (error) {\n return null;\n }\n\n try {\n if (semver.gte(bunVersion, '1.0.0')) {\n return bunVersion;\n }\n return null;\n } catch (error) {\n logger.error(`Cannot parse bun version: ${bunVersion}`);\n return null;\n }\n}\n\nexport function isProjectUsingBun(cwd: string) {\n return findUp.sync('bun.lockb', {cwd});\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA4B;AAErB,SAASA,wBAAwB,GAAG;EACzC,IAAIC,UAAU;EAEd,IAAI;IACFA,UAAU,GAAG,CACX,IAAAC,yBAAQ,EAAC,eAAe,EAAE;MACxBC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ;IAC7B,CAAC,CAAC,CAACC,QAAQ,EAAE,IAAI,EAAE,EACnBC,IAAI,EAAE;EACV,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;EAEA,IAAI;IACF,IAAIC,iBAAM,CAACC,GAAG,CAACP,UAAU,EAAE,OAAO,CAAC,EAAE;MACnC,OAAOA,UAAU;IACnB;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOK,KAAK,EAAE;IACdG,kBAAM,CAACH,KAAK,CAAE,6BAA4BL,UAAW,EAAC,CAAC;IACvD,OAAO,IAAI;EACb;AACF;AAEO,SAASS,iBAAiB,CAACC,GAAW,EAAE;EAC7C,OAAOC,iBAAM,CAACC,IAAI,CAAC,WAAW,EAAE;IAACF;EAAG,CAAC,CAAC;AACxC"}

View File

@@ -0,0 +1,15 @@
/**
* 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.
*/
type Options = {
exclude?: Array<RegExp>;
};
/**
* Copy files (binary included) recursively.
*/
declare function copyFiles(srcPath: string, destPath: string, options?: Options): Promise<void[]>;
export default copyFiles;
//# sourceMappingURL=copyFiles.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"copyFiles.d.ts","sourceRoot":"","sources":["../../src/tools/copyFiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,KAAK,OAAO,GAAG;IACb,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,iBAAe,SAAS,CACtB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAY,mBAetB;AAsDD,eAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,97 @@
"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 _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
var _walk = _interopRequireDefault(require("./walk"));
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.
*/
/**
* Copy files (binary included) recursively.
*/
async function copyFiles(srcPath, destPath, options = {}) {
return Promise.all((0, _walk.default)(srcPath).map(async absoluteSrcFilePath => {
const exclude = options.exclude;
if (exclude && exclude.some(p => p.test(absoluteSrcFilePath))) {
return;
}
const relativeFilePath = _path().default.relative(srcPath, absoluteSrcFilePath);
await copyFile(absoluteSrcFilePath, _path().default.resolve(destPath, relativeFilePath));
}));
}
/**
* Copy a file to given destination.
*/
function copyFile(srcPath, destPath) {
if (_fs().default.lstatSync(srcPath).isDirectory()) {
if (!_fs().default.existsSync(destPath)) {
_fs().default.mkdirSync(destPath);
}
// Not recursive
return;
}
return new Promise((resolve, reject) => {
copyBinaryFile(srcPath, destPath, err => {
if (err) {
reject(err);
}
resolve(destPath);
});
});
}
/**
* Same as 'cp' on Unix. Don't do any replacements.
*/
function copyBinaryFile(srcPath, destPath, cb) {
let cbCalled = false;
const {
mode
} = _fs().default.statSync(srcPath);
const readStream = _fs().default.createReadStream(srcPath);
const writeStream = _fs().default.createWriteStream(destPath, {
mode
});
readStream.on('error', err => {
done(err);
});
writeStream.on('error', err => {
done(err);
});
readStream.on('close', () => {
done();
});
readStream.pipe(writeStream);
function done(err) {
if (!cbCalled) {
cb(err);
cbCalled = true;
}
}
}
var _default = copyFiles;
exports.default = _default;
//# sourceMappingURL=copyFiles.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["copyFiles","srcPath","destPath","options","Promise","all","walk","map","absoluteSrcFilePath","exclude","some","p","test","relativeFilePath","path","relative","copyFile","resolve","fs","lstatSync","isDirectory","existsSync","mkdirSync","reject","copyBinaryFile","err","cb","cbCalled","mode","statSync","readStream","createReadStream","writeStream","createWriteStream","on","done","pipe"],"sources":["../../src/tools/copyFiles.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport walk from './walk';\n\ntype Options = {\n exclude?: Array<RegExp>;\n};\n\n/**\n * Copy files (binary included) recursively.\n */\nasync function copyFiles(\n srcPath: string,\n destPath: string,\n options: Options = {},\n) {\n return Promise.all(\n walk(srcPath).map(async (absoluteSrcFilePath: string) => {\n const exclude = options.exclude;\n if (exclude && exclude.some((p) => p.test(absoluteSrcFilePath))) {\n return;\n }\n const relativeFilePath = path.relative(srcPath, absoluteSrcFilePath);\n await copyFile(\n absoluteSrcFilePath,\n path.resolve(destPath, relativeFilePath),\n );\n }),\n );\n}\n\n/**\n * Copy a file to given destination.\n */\nfunction copyFile(srcPath: string, destPath: string) {\n if (fs.lstatSync(srcPath).isDirectory()) {\n if (!fs.existsSync(destPath)) {\n fs.mkdirSync(destPath);\n }\n // Not recursive\n return;\n }\n\n return new Promise((resolve, reject) => {\n copyBinaryFile(srcPath, destPath, (err) => {\n if (err) {\n reject(err);\n }\n resolve(destPath);\n });\n });\n}\n\n/**\n * Same as 'cp' on Unix. Don't do any replacements.\n */\nfunction copyBinaryFile(\n srcPath: string,\n destPath: string,\n cb: (err?: Error) => void,\n) {\n let cbCalled = false;\n const {mode} = fs.statSync(srcPath);\n const readStream = fs.createReadStream(srcPath);\n const writeStream = fs.createWriteStream(destPath, {mode});\n readStream.on('error', (err) => {\n done(err);\n });\n writeStream.on('error', (err) => {\n done(err);\n });\n readStream.on('close', () => {\n done();\n });\n readStream.pipe(writeStream);\n function done(err?: Error) {\n if (!cbCalled) {\n cb(err);\n cbCalled = true;\n }\n }\n}\n\nexport default copyFiles;\n"],"mappings":";;;;;;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AAA0B;AAT1B;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA,eAAeA,SAAS,CACtBC,OAAe,EACfC,QAAgB,EAChBC,OAAgB,GAAG,CAAC,CAAC,EACrB;EACA,OAAOC,OAAO,CAACC,GAAG,CAChB,IAAAC,aAAI,EAACL,OAAO,CAAC,CAACM,GAAG,CAAC,MAAOC,mBAA2B,IAAK;IACvD,MAAMC,OAAO,GAAGN,OAAO,CAACM,OAAO;IAC/B,IAAIA,OAAO,IAAIA,OAAO,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,CAACJ,mBAAmB,CAAC,CAAC,EAAE;MAC/D;IACF;IACA,MAAMK,gBAAgB,GAAGC,eAAI,CAACC,QAAQ,CAACd,OAAO,EAAEO,mBAAmB,CAAC;IACpE,MAAMQ,QAAQ,CACZR,mBAAmB,EACnBM,eAAI,CAACG,OAAO,CAACf,QAAQ,EAAEW,gBAAgB,CAAC,CACzC;EACH,CAAC,CAAC,CACH;AACH;;AAEA;AACA;AACA;AACA,SAASG,QAAQ,CAACf,OAAe,EAAEC,QAAgB,EAAE;EACnD,IAAIgB,aAAE,CAACC,SAAS,CAAClB,OAAO,CAAC,CAACmB,WAAW,EAAE,EAAE;IACvC,IAAI,CAACF,aAAE,CAACG,UAAU,CAACnB,QAAQ,CAAC,EAAE;MAC5BgB,aAAE,CAACI,SAAS,CAACpB,QAAQ,CAAC;IACxB;IACA;IACA;EACF;EAEA,OAAO,IAAIE,OAAO,CAAC,CAACa,OAAO,EAAEM,MAAM,KAAK;IACtCC,cAAc,CAACvB,OAAO,EAAEC,QAAQ,EAAGuB,GAAG,IAAK;MACzC,IAAIA,GAAG,EAAE;QACPF,MAAM,CAACE,GAAG,CAAC;MACb;MACAR,OAAO,CAACf,QAAQ,CAAC;IACnB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA,SAASsB,cAAc,CACrBvB,OAAe,EACfC,QAAgB,EAChBwB,EAAyB,EACzB;EACA,IAAIC,QAAQ,GAAG,KAAK;EACpB,MAAM;IAACC;EAAI,CAAC,GAAGV,aAAE,CAACW,QAAQ,CAAC5B,OAAO,CAAC;EACnC,MAAM6B,UAAU,GAAGZ,aAAE,CAACa,gBAAgB,CAAC9B,OAAO,CAAC;EAC/C,MAAM+B,WAAW,GAAGd,aAAE,CAACe,iBAAiB,CAAC/B,QAAQ,EAAE;IAAC0B;EAAI,CAAC,CAAC;EAC1DE,UAAU,CAACI,EAAE,CAAC,OAAO,EAAGT,GAAG,IAAK;IAC9BU,IAAI,CAACV,GAAG,CAAC;EACX,CAAC,CAAC;EACFO,WAAW,CAACE,EAAE,CAAC,OAAO,EAAGT,GAAG,IAAK;IAC/BU,IAAI,CAACV,GAAG,CAAC;EACX,CAAC,CAAC;EACFK,UAAU,CAACI,EAAE,CAAC,OAAO,EAAE,MAAM;IAC3BC,IAAI,EAAE;EACR,CAAC,CAAC;EACFL,UAAU,CAACM,IAAI,CAACJ,WAAW,CAAC;EAC5B,SAASG,IAAI,CAACV,GAAW,EAAE;IACzB,IAAI,CAACE,QAAQ,EAAE;MACbD,EAAE,CAACD,GAAG,CAAC;MACPE,QAAQ,GAAG,IAAI;IACjB;EACF;AACF;AAAC,eAEc3B,SAAS;AAAA"}

View File

@@ -0,0 +1,6 @@
import execa from 'execa';
export declare function executeCommand(command: string, args: Array<string>, options: {
root: string;
silent?: boolean;
}): execa.ExecaChildProcess<string>;
//# sourceMappingURL=executeCommand.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"executeCommand.d.ts","sourceRoot":"","sources":["../../src/tools/executeCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,mCAMF"}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.executeCommand = executeCommand;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _execa() {
const data = _interopRequireDefault(require("execa"));
_execa = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function executeCommand(command, args, options) {
return (0, _execa().default)(command, args, {
stdio: options.silent && !_cliTools().logger.isVerbose() ? 'pipe' : 'inherit',
cwd: options.root
});
}
//# sourceMappingURL=executeCommand.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["executeCommand","command","args","options","execa","stdio","silent","logger","isVerbose","cwd","root"],"sources":["../../src/tools/executeCommand.ts"],"sourcesContent":["import {logger} from '@react-native-community/cli-tools';\nimport execa from 'execa';\n\nexport function executeCommand(\n command: string,\n args: Array<string>,\n options: {\n root: string;\n silent?: boolean;\n },\n) {\n return execa(command, args, {\n stdio: options.silent && !logger.isVerbose() ? 'pipe' : 'inherit',\n cwd: options.root,\n });\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA0B;AAEnB,SAASA,cAAc,CAC5BC,OAAe,EACfC,IAAmB,EACnBC,OAGC,EACD;EACA,OAAO,IAAAC,gBAAK,EAACH,OAAO,EAAEC,IAAI,EAAE;IAC1BG,KAAK,EAAEF,OAAO,CAACG,MAAM,IAAI,CAACC,kBAAM,CAACC,SAAS,EAAE,GAAG,MAAM,GAAG,SAAS;IACjEC,GAAG,EAAEN,OAAO,CAACO;EACf,CAAC,CAAC;AACJ"}

View File

@@ -0,0 +1,3 @@
import gracefulFs from 'graceful-fs';
export default gracefulFs;
//# sourceMappingURL=gracefulifyFs.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"gracefulifyFs.d.ts","sourceRoot":"","sources":["../../src/tools/gracefulifyFs.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,eAAe,UAAU,CAAC"}

View File

@@ -0,0 +1,26 @@
"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 _gracefulFs() {
const data = _interopRequireDefault(require("graceful-fs"));
_gracefulFs = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_gracefulFs().default.gracefulify(_fs().default);
var _default = _gracefulFs().default;
exports.default = _default;
//# sourceMappingURL=gracefulifyFs.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["gracefulFs","gracefulify","realFs"],"sources":["../../src/tools/gracefulifyFs.ts"],"sourcesContent":["import realFs from 'fs';\nimport gracefulFs from 'graceful-fs';\n\ngracefulFs.gracefulify(realFs);\n\nexport default gracefulFs;\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAqC;AAErCA,qBAAU,CAACC,WAAW,CAACC,aAAM,CAAC;AAAC,eAEhBF,qBAAU;AAAA"}

View File

@@ -0,0 +1,10 @@
/**
* 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.
*
*/
export declare function getNpmVersionIfAvailable(): string | null;
export declare function isProjectUsingNpm(cwd: string): string | undefined;
//# sourceMappingURL=npm.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/tools/npm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,wBAAgB,wBAAwB,kBAcvC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,sBAE5C"}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getNpmVersionIfAvailable = getNpmVersionIfAvailable;
exports.isProjectUsingNpm = isProjectUsingNpm;
function _child_process() {
const data = require("child_process");
_child_process = function () {
return data;
};
return data;
}
function _findUp() {
const data = _interopRequireDefault(require("find-up"));
_findUp = 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 getNpmVersionIfAvailable() {
let npmVersion;
try {
// execSync returns a Buffer -> convert to string
npmVersion = ((0, _child_process().execSync)('npm --version', {
stdio: [0, 'pipe', 'ignore']
}).toString() || '').trim();
return npmVersion;
} catch (error) {
return null;
}
}
function isProjectUsingNpm(cwd) {
return _findUp().default.sync('package-lock.json', {
cwd
});
}
//# sourceMappingURL=npm.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getNpmVersionIfAvailable","npmVersion","execSync","stdio","toString","trim","error","isProjectUsingNpm","cwd","findUp","sync"],"sources":["../../src/tools/npm.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {execSync} from 'child_process';\nimport findUp from 'find-up';\n\nexport function getNpmVersionIfAvailable() {\n let npmVersion;\n try {\n // execSync returns a Buffer -> convert to string\n npmVersion = (\n execSync('npm --version', {\n stdio: [0, 'pipe', 'ignore'],\n }).toString() || ''\n ).trim();\n\n return npmVersion;\n } catch (error) {\n return null;\n }\n}\n\nexport function isProjectUsingNpm(cwd: string) {\n return findUp.sync('package-lock.json', {cwd});\n}\n"],"mappings":";;;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA6B;AAT7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,SAASA,wBAAwB,GAAG;EACzC,IAAIC,UAAU;EACd,IAAI;IACF;IACAA,UAAU,GAAG,CACX,IAAAC,yBAAQ,EAAC,eAAe,EAAE;MACxBC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ;IAC7B,CAAC,CAAC,CAACC,QAAQ,EAAE,IAAI,EAAE,EACnBC,IAAI,EAAE;IAER,OAAOJ,UAAU;EACnB,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF;AAEO,SAASC,iBAAiB,CAACC,GAAW,EAAE;EAC7C,OAAOC,iBAAM,CAACC,IAAI,CAAC,mBAAmB,EAAE;IAACF;EAAG,CAAC,CAAC;AAChD"}

View File

@@ -0,0 +1,39 @@
export type PackageManager = keyof typeof packageManagers;
type Options = {
packageManager: PackageManager;
silent?: boolean;
root: string;
};
declare const packageManagers: {
yarn: {
init: string[];
install: string[];
installDev: string[];
uninstall: string[];
installAll: string[];
};
npm: {
init: string[];
install: string[];
installDev: string[];
uninstall: string[];
installAll: string[];
};
bun: {
init: string[];
install: string[];
installDev: string[];
uninstall: string[];
installAll: 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): 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

View File

@@ -0,0 +1 @@
{"version":3,"file":"packageManager.d.ts","sourceRoot":"","sources":["../../src/tools/packageManager.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,eAAe,CAAC;AAE1D,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AA+BF,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,6BAK7C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,6BAM5C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,6BAM5C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,6CAEpC;AAED,wBAAgB,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,6CAEpE;AAED,wBAAgB,UAAU,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,6CAEvE;AAED,wBAAgB,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,6CAEtE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,6CAE1C"}

View File

@@ -0,0 +1,95 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.init = init;
exports.install = install;
exports.installAll = installAll;
exports.installDev = installDev;
exports.shouldUseBun = shouldUseBun;
exports.shouldUseNpm = shouldUseNpm;
exports.shouldUseYarn = shouldUseYarn;
exports.uninstall = uninstall;
var _yarn = require("./yarn");
var _bun = require("./bun");
var _npm = require("./npm");
var _executeCommand = require("./executeCommand");
const packageManagers = {
yarn: {
init: ['init', '-y'],
install: ['add'],
installDev: ['add', '-D'],
uninstall: ['remove'],
installAll: ['install']
},
npm: {
init: ['init', '-y'],
install: ['install', '--save', '--save-exact'],
installDev: ['install', '--save-dev', '--save-exact'],
uninstall: ['uninstall', '--save'],
installAll: ['install']
},
bun: {
init: ['init', '-y'],
install: ['add', '--exact'],
installDev: ['add', '--dev', '--exact'],
uninstall: ['remove'],
installAll: ['install']
}
};
function configurePackageManager(packageNames, action, options) {
let yarnAvailable = shouldUseYarn(options);
let bunAvailable = shouldUseBun(options);
let pm = 'npm';
if (options.packageManager === 'bun') {
if (bunAvailable) {
pm = 'bun';
} else if (yarnAvailable) {
pm = 'yarn';
} else {
pm = 'npm';
}
}
if (options.packageManager === 'yarn' && yarnAvailable) {
pm = 'yarn';
}
const [executable, ...flags] = packageManagers[pm][action];
const args = [executable, ...flags, ...packageNames];
return (0, _executeCommand.executeCommand)(pm, args, options);
}
function shouldUseYarn(options) {
if (options.packageManager === 'yarn') {
return (0, _yarn.getYarnVersionIfAvailable)();
}
return (0, _yarn.isProjectUsingYarn)(options.root) && (0, _yarn.getYarnVersionIfAvailable)();
}
function shouldUseBun(options) {
if (options.packageManager === 'bun') {
return (0, _bun.getBunVersionIfAvailable)();
}
return (0, _bun.isProjectUsingBun)(options.root) && (0, _bun.getBunVersionIfAvailable)();
}
function shouldUseNpm(options) {
if (options.packageManager === 'npm') {
return (0, _npm.getNpmVersionIfAvailable)();
}
return (0, _npm.isProjectUsingNpm)(options.root) && (0, _npm.getNpmVersionIfAvailable)();
}
function init(options) {
return configurePackageManager([], 'init', options);
}
function install(packageNames, options) {
return configurePackageManager(packageNames, 'install', options);
}
function installDev(packageNames, options) {
return configurePackageManager(packageNames, 'installDev', options);
}
function uninstall(packageNames, options) {
return configurePackageManager(packageNames, 'uninstall', options);
}
function installAll(options) {
return configurePackageManager([], 'installAll', options);
}
//# sourceMappingURL=packageManager.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export default function replacePathSepForRegex(string: string): string;
//# sourceMappingURL=replacePathSepForRegex.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"replacePathSepForRegex.d.ts","sourceRoot":"","sources":["../../src/tools/replacePathSepForRegex.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAM,EAAE,MAAM,UAQ5D"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = replacePathSepForRegex;
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function replacePathSepForRegex(string) {
if (_path().default.sep === '\\') {
return string.replace(/(\/|(.)?\\(?![[\]{}()*+?.^$|\\]))/g, (_match, _, p2) => p2 && p2 !== '\\' ? p2 + '\\\\' : '\\\\');
}
return string;
}
//# sourceMappingURL=replacePathSepForRegex.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["replacePathSepForRegex","string","path","sep","replace","_match","_","p2"],"sources":["../../src/tools/replacePathSepForRegex.ts"],"sourcesContent":["import path from 'path';\n\nexport default function replacePathSepForRegex(string: string) {\n if (path.sep === '\\\\') {\n return string.replace(\n /(\\/|(.)?\\\\(?![[\\]{}()*+?.^$|\\\\]))/g,\n (_match, _, p2) => (p2 && p2 !== '\\\\' ? p2 + '\\\\\\\\' : '\\\\\\\\'),\n );\n }\n return string;\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAET,SAASA,sBAAsB,CAACC,MAAc,EAAE;EAC7D,IAAIC,eAAI,CAACC,GAAG,KAAK,IAAI,EAAE;IACrB,OAAOF,MAAM,CAACG,OAAO,CACnB,oCAAoC,EACpC,CAACC,MAAM,EAAEC,CAAC,EAAEC,EAAE,KAAMA,EAAE,IAAIA,EAAE,KAAK,IAAI,GAAGA,EAAE,GAAG,MAAM,GAAG,MAAO,CAC9D;EACH;EACA,OAAON,MAAM;AACf"}

View File

@@ -0,0 +1,10 @@
/**
* 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.
*
*/
declare function walk(current: string): string[];
export default walk;
//# sourceMappingURL=walk.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/tools/walk.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,iBAAS,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAUvC;AAED,eAAe,IAAI,CAAC"}

Some files were not shown because too many files have changed in this diff Show More