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,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"}