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,117 @@
/**
* 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 const valid: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
export declare const validKotlin: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
export declare const validApp: {
'build.gradle': any;
app: {
'build.gradle': any;
};
src: {
'AndroidManifest.xml': any;
};
};
export declare const userConfigManifest: {
src: {
main: {
'AndroidManifest.xml': any;
com: {
some: {
example: {
'Main.java': any;
'ReactPackage.java': any;
};
};
};
};
debug: {
'AndroidManifest.xml': any;
};
};
};
export declare const corrupted: {
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {};
};
};
};
};
};
export declare const noPackage: {
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
'Main.java': any;
};
};
};
};
};
};
export declare const findPackagesClassNameKotlinValid: string[];
export declare const findPackagesClassNameKotlinNotValid: string[];
export declare const findPackagesClassNameJavaValid: string[];
export declare const findPackagesClassNameJavaNotValid: string[];
export declare const fewActivities: {
src: {
'AndroidManifest.xml': any;
};
};
export declare const className: {
src: {
'AndroidManifest.xml': any;
};
};
export declare const customFlavor: {
src: {
e2e: {
'AndroidManifest.xml': any;
};
main: {
'AndroidManifest.xml': any;
};
};
};
//# sourceMappingURL=android.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../../src/config/__fixtures__/android.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;CAAwD,CAAC;AAE3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAAsD,CAAC;AAE/E,eAAO,MAAM,QAAQ;;;;;;;;CAAqC,CAAC;AAE3D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAqB9B,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;CAWrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;CAarB,CAAC;AAEF,eAAO,MAAM,gCAAgC,UAsE5C,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAuB/C,CAAC;AAEF,eAAO,MAAM,8BAA8B,UA6C1C,CAAC;AAEF,eAAO,MAAM,iCAAiC,UAqB7C,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAIzB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;CASxB,CAAC"}

View File

@@ -0,0 +1,75 @@
export declare const flat: {
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
export declare const nested: {
android: {
app: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
};
export declare const withExamples: {
Examples: {
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
//# sourceMappingURL=projects.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../../src/config/__fixtures__/projects.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAEhB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;CAIlB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGxB,CAAC"}

View File

@@ -0,0 +1,2 @@
export declare function extractComponentDescriptors(contents: string): string | null;
//# sourceMappingURL=extractComponentDescriptors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractComponentDescriptors.d.ts","sourceRoot":"","sources":["../../src/config/extractComponentDescriptors.ts"],"names":[],"mappings":"AAKA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,iBAM3D"}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractComponentDescriptors = extractComponentDescriptors;
// TODO: avoid the regex and improve reliability by reading this data from codegen schema.json.
// Need to find a way to run "generateNewArchitectureFiles" gradle task after each library's "generateCodegenSchemaFromJavaScript" task.
const CODEGEN_NATIVE_COMPONENT_REGEX = /codegenNativeComponent(<.*>)?\s*\(\s*["'`](\w+)["'`](,?[\s\S]+interfaceOnly:\s*(\w+))?/m;
function extractComponentDescriptors(contents) {
const match = contents.match(CODEGEN_NATIVE_COMPONENT_REGEX);
if (!((match === null || match === void 0 ? void 0 : match[4]) === 'true') && (match === null || match === void 0 ? void 0 : match[2])) {
return `${match[2]}ComponentDescriptor`;
}
return null;
}
//# sourceMappingURL=extractComponentDescriptors.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["CODEGEN_NATIVE_COMPONENT_REGEX","extractComponentDescriptors","contents","match"],"sources":["../../src/config/extractComponentDescriptors.ts"],"sourcesContent":["// TODO: avoid the regex and improve reliability by reading this data from codegen schema.json.\n// Need to find a way to run \"generateNewArchitectureFiles\" gradle task after each library's \"generateCodegenSchemaFromJavaScript\" task.\nconst CODEGEN_NATIVE_COMPONENT_REGEX =\n /codegenNativeComponent(<.*>)?\\s*\\(\\s*[\"'`](\\w+)[\"'`](,?[\\s\\S]+interfaceOnly:\\s*(\\w+))?/m;\n\nexport function extractComponentDescriptors(contents: string) {\n const match = contents.match(CODEGEN_NATIVE_COMPONENT_REGEX);\n if (!(match?.[4] === 'true') && match?.[2]) {\n return `${match[2]}ComponentDescriptor`;\n }\n return null;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA,MAAMA,8BAA8B,GAClC,yFAAyF;AAEpF,SAASC,2BAA2B,CAACC,QAAgB,EAAE;EAC5D,MAAMC,KAAK,GAAGD,QAAQ,CAACC,KAAK,CAACH,8BAA8B,CAAC;EAC5D,IAAI,EAAE,CAAAG,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,CAAC,CAAC,MAAK,MAAM,CAAC,KAAIA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,CAAC,CAAC,GAAE;IAC1C,OAAQ,GAAEA,KAAK,CAAC,CAAC,CAAE,qBAAoB;EACzC;EACA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,9 @@
/**
* 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 default function findAndroidDir(root: string): "android" | null;
//# sourceMappingURL=findAndroidDir.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findAndroidDir.d.ts","sourceRoot":"","sources":["../../src/config/findAndroidDir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,MAAM,oBAMlD"}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findAndroidDir;
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 }; }
/**
* 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 findAndroidDir(root) {
if (_fs().default.existsSync(_path().default.join(root, 'android'))) {
return 'android';
}
return null;
}
//# sourceMappingURL=findAndroidDir.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findAndroidDir","root","fs","existsSync","path","join"],"sources":["../../src/config/findAndroidDir.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 fs from 'fs';\nimport path from 'path';\n\nexport default function findAndroidDir(root: string) {\n if (fs.existsSync(path.join(root, 'android'))) {\n return 'android';\n }\n\n return null;\n}\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AATxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAKe,SAASA,cAAc,CAACC,IAAY,EAAE;EACnD,IAAIC,aAAE,CAACC,UAAU,CAACC,eAAI,CAACC,IAAI,CAACJ,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE;IAC7C,OAAO,SAAS;EAClB;EAEA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,2 @@
export declare function findBuildGradle(sourceDir: string, isLibrary: boolean): string | null;
//# sourceMappingURL=findBuildGradle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findBuildGradle.d.ts","sourceRoot":"","sources":["../../src/config/findBuildGradle.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,iBAiBpE"}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findBuildGradle = findBuildGradle;
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 }; }
function findBuildGradle(sourceDir, isLibrary) {
const buildGradlePath = _path().default.join(sourceDir, isLibrary ? 'build.gradle' : 'app/build.gradle');
const buildGradleKtsPath = _path().default.join(sourceDir, isLibrary ? 'build.gradle.kts' : 'app/build.gradle.kts');
if (_fs().default.existsSync(buildGradlePath)) {
return buildGradlePath;
} else if (_fs().default.existsSync(buildGradleKtsPath)) {
return buildGradleKtsPath;
} else {
return null;
}
}
//# sourceMappingURL=findBuildGradle.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findBuildGradle","sourceDir","isLibrary","buildGradlePath","path","join","buildGradleKtsPath","fs","existsSync"],"sources":["../../src/config/findBuildGradle.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function findBuildGradle(sourceDir: string, isLibrary: boolean) {\n const buildGradlePath = path.join(\n sourceDir,\n isLibrary ? 'build.gradle' : 'app/build.gradle',\n );\n const buildGradleKtsPath = path.join(\n sourceDir,\n isLibrary ? 'build.gradle.kts' : 'app/build.gradle.kts',\n );\n\n if (fs.existsSync(buildGradlePath)) {\n return buildGradlePath;\n } else if (fs.existsSync(buildGradleKtsPath)) {\n return buildGradleKtsPath;\n } else {\n return null;\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAEjB,SAASA,eAAe,CAACC,SAAiB,EAAEC,SAAkB,EAAE;EACrE,MAAMC,eAAe,GAAGC,eAAI,CAACC,IAAI,CAC/BJ,SAAS,EACTC,SAAS,GAAG,cAAc,GAAG,kBAAkB,CAChD;EACD,MAAMI,kBAAkB,GAAGF,eAAI,CAACC,IAAI,CAClCJ,SAAS,EACTC,SAAS,GAAG,kBAAkB,GAAG,sBAAsB,CACxD;EAED,IAAIK,aAAE,CAACC,UAAU,CAACL,eAAe,CAAC,EAAE;IAClC,OAAOA,eAAe;EACxB,CAAC,MAAM,IAAII,aAAE,CAACC,UAAU,CAACF,kBAAkB,CAAC,EAAE;IAC5C,OAAOA,kBAAkB;EAC3B,CAAC,MAAM;IACL,OAAO,IAAI;EACb;AACF"}

View File

@@ -0,0 +1,2 @@
export declare function findComponentDescriptors(packageRoot: string): string[];
//# sourceMappingURL=findComponentDescriptors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findComponentDescriptors.d.ts","sourceRoot":"","sources":["../../src/config/findComponentDescriptors.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,YAgB3D"}

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findComponentDescriptors = findComponentDescriptors;
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 _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = function () {
return data;
};
return data;
}
var _extractComponentDescriptors = require("./extractComponentDescriptors");
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function findComponentDescriptors(packageRoot) {
const files = _fastGlob().default.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {
cwd: (0, _cliTools().unixifyPaths)(packageRoot),
onlyFiles: true,
ignore: ['**/node_modules/**']
});
const codegenComponent = files.map(filePath => _fs().default.readFileSync(_path().default.join(packageRoot, filePath), 'utf8')).map(_extractComponentDescriptors.extractComponentDescriptors).filter(Boolean);
// Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.
// TODO: consider using "codegenConfig" to avoid this.
return Array.from(new Set(codegenComponent));
}
//# sourceMappingURL=findComponentDescriptors.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findComponentDescriptors","packageRoot","files","glob","sync","cwd","unixifyPaths","onlyFiles","ignore","codegenComponent","map","filePath","fs","readFileSync","path","join","extractComponentDescriptors","filter","Boolean","Array","from","Set"],"sources":["../../src/config/findComponentDescriptors.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport glob from 'fast-glob';\nimport {extractComponentDescriptors} from './extractComponentDescriptors';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport function findComponentDescriptors(packageRoot: string) {\n const files = glob.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {\n cwd: unixifyPaths(packageRoot),\n onlyFiles: true,\n ignore: ['**/node_modules/**'],\n });\n const codegenComponent = files\n .map((filePath) =>\n fs.readFileSync(path.join(packageRoot, filePath), 'utf8'),\n )\n .map(extractComponentDescriptors)\n .filter(Boolean);\n\n // Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.\n // TODO: consider using \"codegenConfig\" to avoid this.\n return Array.from(new Set(codegenComponent as string[]));\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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+D;AAExD,SAASA,wBAAwB,CAACC,WAAmB,EAAE;EAC5D,MAAMC,KAAK,GAAGC,mBAAI,CAACC,IAAI,CAAC,6BAA6B,EAAE;IACrDC,GAAG,EAAE,IAAAC,wBAAY,EAACL,WAAW,CAAC;IAC9BM,SAAS,EAAE,IAAI;IACfC,MAAM,EAAE,CAAC,oBAAoB;EAC/B,CAAC,CAAC;EACF,MAAMC,gBAAgB,GAAGP,KAAK,CAC3BQ,GAAG,CAAEC,QAAQ,IACZC,aAAE,CAACC,YAAY,CAACC,eAAI,CAACC,IAAI,CAACd,WAAW,EAAEU,QAAQ,CAAC,EAAE,MAAM,CAAC,CAC1D,CACAD,GAAG,CAACM,wDAA2B,CAAC,CAChCC,MAAM,CAACC,OAAO,CAAC;;EAElB;EACA;EACA,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAIC,GAAG,CAACZ,gBAAgB,CAAa,CAAC;AAC1D"}

View File

@@ -0,0 +1,2 @@
export declare function findLibraryName(root: string, sourceDir: string): any;
//# sourceMappingURL=findLibraryName.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findLibraryName.d.ts","sourceRoot":"","sources":["../../src/config/findLibraryName.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OA8B9D"}

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findLibraryName = findLibraryName;
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 }; }
function findLibraryName(root, sourceDir) {
const packageJsonPath = _path().default.join(root, 'package.json');
const buildGradlePath = _path().default.join(sourceDir, 'build.gradle');
const buildGradleKtsPath = _path().default.join(sourceDir, 'build.gradle.kts');
// We first check if there is a codegenConfig.name inside the package.json file.
if (_fs().default.existsSync(packageJsonPath)) {
var _packageJson$codegenC;
const packageJson = JSON.parse(_fs().default.readFileSync(packageJsonPath, 'utf8'));
if ((_packageJson$codegenC = packageJson.codegenConfig) === null || _packageJson$codegenC === void 0 ? void 0 : _packageJson$codegenC.name) {
return packageJson.codegenConfig.name;
}
}
// If not, we check if the library specified it in the build.gradle file.
let buildGradleContents = '';
if (_fs().default.existsSync(buildGradlePath)) {
buildGradleContents = _fs().default.readFileSync(buildGradlePath, 'utf-8');
} else if (_fs().default.existsSync(buildGradleKtsPath)) {
buildGradleContents = _fs().default.readFileSync(buildGradleKtsPath, 'utf-8');
} else {
return undefined;
}
const match = buildGradleContents.match(/libraryName = ["'](.+)["']/);
if (match) {
return match[1];
} else {
return undefined;
}
}
//# sourceMappingURL=findLibraryName.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findLibraryName","root","sourceDir","packageJsonPath","path","join","buildGradlePath","buildGradleKtsPath","fs","existsSync","packageJson","JSON","parse","readFileSync","codegenConfig","name","buildGradleContents","undefined","match"],"sources":["../../src/config/findLibraryName.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function findLibraryName(root: string, sourceDir: string) {\n const packageJsonPath = path.join(root, 'package.json');\n const buildGradlePath = path.join(sourceDir, 'build.gradle');\n const buildGradleKtsPath = path.join(sourceDir, 'build.gradle.kts');\n\n // We first check if there is a codegenConfig.name inside the package.json file.\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n if (packageJson.codegenConfig?.name) {\n return packageJson.codegenConfig.name;\n }\n }\n\n // If not, we check if the library specified it in the build.gradle file.\n let buildGradleContents = '';\n if (fs.existsSync(buildGradlePath)) {\n buildGradleContents = fs.readFileSync(buildGradlePath, 'utf-8');\n } else if (fs.existsSync(buildGradleKtsPath)) {\n buildGradleContents = fs.readFileSync(buildGradleKtsPath, 'utf-8');\n } else {\n return undefined;\n }\n\n const match = buildGradleContents.match(/libraryName = [\"'](.+)[\"']/);\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAEjB,SAASA,eAAe,CAACC,IAAY,EAAEC,SAAiB,EAAE;EAC/D,MAAMC,eAAe,GAAGC,eAAI,CAACC,IAAI,CAACJ,IAAI,EAAE,cAAc,CAAC;EACvD,MAAMK,eAAe,GAAGF,eAAI,CAACC,IAAI,CAACH,SAAS,EAAE,cAAc,CAAC;EAC5D,MAAMK,kBAAkB,GAAGH,eAAI,CAACC,IAAI,CAACH,SAAS,EAAE,kBAAkB,CAAC;;EAEnE;EACA,IAAIM,aAAE,CAACC,UAAU,CAACN,eAAe,CAAC,EAAE;IAAA;IAClC,MAAMO,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACJ,aAAE,CAACK,YAAY,CAACV,eAAe,EAAE,MAAM,CAAC,CAAC;IACxE,6BAAIO,WAAW,CAACI,aAAa,0DAAzB,sBAA2BC,IAAI,EAAE;MACnC,OAAOL,WAAW,CAACI,aAAa,CAACC,IAAI;IACvC;EACF;;EAEA;EACA,IAAIC,mBAAmB,GAAG,EAAE;EAC5B,IAAIR,aAAE,CAACC,UAAU,CAACH,eAAe,CAAC,EAAE;IAClCU,mBAAmB,GAAGR,aAAE,CAACK,YAAY,CAACP,eAAe,EAAE,OAAO,CAAC;EACjE,CAAC,MAAM,IAAIE,aAAE,CAACC,UAAU,CAACF,kBAAkB,CAAC,EAAE;IAC5CS,mBAAmB,GAAGR,aAAE,CAACK,YAAY,CAACN,kBAAkB,EAAE,OAAO,CAAC;EACpE,CAAC,MAAM;IACL,OAAOU,SAAS;EAClB;EAEA,MAAMC,KAAK,GAAGF,mBAAmB,CAACE,KAAK,CAAC,4BAA4B,CAAC;EAErE,IAAIA,KAAK,EAAE;IACT,OAAOA,KAAK,CAAC,CAAC,CAAC;EACjB,CAAC,MAAM;IACL,OAAOD,SAAS;EAClB;AACF"}

View File

@@ -0,0 +1,9 @@
/**
* 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 default function findManifest(folder: string): string | null;
//# sourceMappingURL=findManifest.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findManifest.d.ts","sourceRoot":"","sources":["../../src/config/findManifest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAM,EAAE,MAAM,iBA0BlD"}

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findManifest;
function _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = 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;
}
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 findManifest(folder) {
let manifestPaths = _fastGlob().default.sync('**/AndroidManifest.xml', {
cwd: (0, _cliTools().unixifyPaths)(folder),
ignore: ['node_modules/**', '**/build/**', '**/debug/**', 'Examples/**', 'examples/**', '**/Pods/**', '**/sdks/hermes/android/**', '**/src/androidTest/**', '**/src/test/**']
});
if (manifestPaths.length > 1) {
// if we have more than one manifest, pick the one in the main folder if present
const mainManifest = manifestPaths.filter(manifestPath => manifestPath.includes('src/main/'));
if (mainManifest.length === 1) {
manifestPaths = mainManifest;
}
}
return manifestPaths[0] ? _path().default.join(folder, manifestPaths[0]) : null;
}
//# sourceMappingURL=findManifest.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findManifest","folder","manifestPaths","glob","sync","cwd","unixifyPaths","ignore","length","mainManifest","filter","manifestPath","includes","path","join"],"sources":["../../src/config/findManifest.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 glob from 'fast-glob';\nimport path from 'path';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport default function findManifest(folder: string) {\n let manifestPaths = glob.sync('**/AndroidManifest.xml', {\n cwd: unixifyPaths(folder),\n ignore: [\n 'node_modules/**',\n '**/build/**',\n '**/debug/**',\n 'Examples/**',\n 'examples/**',\n '**/Pods/**',\n '**/sdks/hermes/android/**',\n '**/src/androidTest/**',\n '**/src/test/**',\n ],\n });\n if (manifestPaths.length > 1) {\n // if we have more than one manifest, pick the one in the main folder if present\n const mainManifest = manifestPaths.filter((manifestPath) =>\n manifestPath.includes('src/main/'),\n );\n if (mainManifest.length === 1) {\n manifestPaths = mainManifest;\n }\n }\n\n return manifestPaths[0] ? path.join(folder, manifestPaths[0]) : null;\n}\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+D;AAV/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAMe,SAASA,YAAY,CAACC,MAAc,EAAE;EACnD,IAAIC,aAAa,GAAGC,mBAAI,CAACC,IAAI,CAAC,wBAAwB,EAAE;IACtDC,GAAG,EAAE,IAAAC,wBAAY,EAACL,MAAM,CAAC;IACzBM,MAAM,EAAE,CACN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB;EAEpB,CAAC,CAAC;EACF,IAAIL,aAAa,CAACM,MAAM,GAAG,CAAC,EAAE;IAC5B;IACA,MAAMC,YAAY,GAAGP,aAAa,CAACQ,MAAM,CAAEC,YAAY,IACrDA,YAAY,CAACC,QAAQ,CAAC,WAAW,CAAC,CACnC;IACD,IAAIH,YAAY,CAACD,MAAM,KAAK,CAAC,EAAE;MAC7BN,aAAa,GAAGO,YAAY;IAC9B;EACF;EAEA,OAAOP,aAAa,CAAC,CAAC,CAAC,GAAGW,eAAI,CAACC,IAAI,CAACb,MAAM,EAAEC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;AACtE"}

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 default function getPackageClassName(folder: string): string | null;
export declare function matchClassName(file: string): RegExpMatchArray | null;
//# sourceMappingURL=findPackageClassName.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findPackageClassName.d.ts","sourceRoot":"","sources":["../../src/config/findPackageClassName.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,MAAM,iBAUzD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,2BAa1C"}

View File

@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getPackageClassName;
exports.matchClassName = matchClassName;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = 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;
}
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 getPackageClassName(folder) {
const files = _fastGlob().default.sync('**/+(*.java|*.kt)', {
cwd: (0, _cliTools().unixifyPaths)(folder)
});
const packages = files.map(filePath => _fs().default.readFileSync(_path().default.join(folder, filePath), 'utf8')).map(matchClassName).filter(match => match);
// @ts-ignore
return packages.length ? packages[0][1] : null;
}
function matchClassName(file) {
const nativeModuleMatch = file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/);
// We first check for implementation of ReactPackage to find native
// modules and then for subclasses of TurboReactPackage to find turbo modules.
if (nativeModuleMatch) {
return nativeModuleMatch;
} else {
return file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+extends\s+|:)[\s\w():,]*[^{]*TurboReactPackage/);
}
}
//# sourceMappingURL=findPackageClassName.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getPackageClassName","folder","files","glob","sync","cwd","unixifyPaths","packages","map","filePath","fs","readFileSync","path","join","matchClassName","filter","match","length","file","nativeModuleMatch"],"sources":["../../src/config/findPackageClassName.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 fs from 'fs';\nimport glob from 'fast-glob';\nimport path from 'path';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport default function getPackageClassName(folder: string) {\n const files = glob.sync('**/+(*.java|*.kt)', {cwd: unixifyPaths(folder)});\n\n const packages = files\n .map((filePath) => fs.readFileSync(path.join(folder, filePath), 'utf8'))\n .map(matchClassName)\n .filter((match) => match);\n\n // @ts-ignore\n return packages.length ? packages[0][1] : null;\n}\n\nexport function matchClassName(file: string) {\n const nativeModuleMatch = file.match(\n /class\\s+(\\w+[^(\\s]*)[\\s\\w():]*(\\s+implements\\s+|:)[\\s\\w():,]*[^{]*ReactPackage/,\n );\n // We first check for implementation of ReactPackage to find native\n // modules and then for subclasses of TurboReactPackage to find turbo modules.\n if (nativeModuleMatch) {\n return nativeModuleMatch;\n } else {\n return file.match(\n /class\\s+(\\w+[^(\\s]*)[\\s\\w():]*(\\s+extends\\s+|:)[\\s\\w():,]*[^{]*TurboReactPackage/,\n );\n }\n}\n"],"mappings":";;;;;;;AAQA;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;AAA+D;AAX/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAOe,SAASA,mBAAmB,CAACC,MAAc,EAAE;EAC1D,MAAMC,KAAK,GAAGC,mBAAI,CAACC,IAAI,CAAC,mBAAmB,EAAE;IAACC,GAAG,EAAE,IAAAC,wBAAY,EAACL,MAAM;EAAC,CAAC,CAAC;EAEzE,MAAMM,QAAQ,GAAGL,KAAK,CACnBM,GAAG,CAAEC,QAAQ,IAAKC,aAAE,CAACC,YAAY,CAACC,eAAI,CAACC,IAAI,CAACZ,MAAM,EAAEQ,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CACvED,GAAG,CAACM,cAAc,CAAC,CACnBC,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAAC;;EAE3B;EACA,OAAOT,QAAQ,CAACU,MAAM,GAAGV,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;AAChD;AAEO,SAASO,cAAc,CAACI,IAAY,EAAE;EAC3C,MAAMC,iBAAiB,GAAGD,IAAI,CAACF,KAAK,CAClC,gFAAgF,CACjF;EACD;EACA;EACA,IAAIG,iBAAiB,EAAE;IACrB,OAAOA,iBAAiB;EAC1B,CAAC,MAAM;IACL,OAAOD,IAAI,CAACF,KAAK,CACf,kFAAkF,CACnF;EACH;AACF"}

View File

@@ -0,0 +1,13 @@
import { Config } from '@react-native-community/cli-types';
export declare function getAndroidProject(config: Config): import("@react-native-community/cli-types").AndroidProjectConfig;
/**
* Get the package name/namespace of the running React Native app
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
export declare function getPackageName(manifestPath: string | null, buildGradlePath: string | null): string;
export declare function parsePackageNameFromAndroidManifestFile(androidManifest: string): string | null;
export declare function parseNamespaceFromBuildGradleFile(buildGradle: string): string | null;
export declare function validatePackageName(packageName: string): boolean;
export declare function parseApplicationIdFromBuildGradleFile(buildGradlePath: string): string | null;
//# sourceMappingURL=getAndroidProject.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAndroidProject.d.ts","sourceRoot":"","sources":["../../src/config/getAndroidProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAKzD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,oEAW/C;AA4CD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,UAa/B;AAED,wBAAgB,uCAAuC,CACrD,eAAe,EAAE,MAAM,iBAQxB;AAED,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,MAAM,iBAQpE;AAGD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,WAEtD;AAGD,wBAAgB,qCAAqC,CAAC,eAAe,EAAE,MAAM,iBAgB5E"}

View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAndroidProject = getAndroidProject;
exports.getPackageName = getPackageName;
exports.parseApplicationIdFromBuildGradleFile = parseApplicationIdFromBuildGradleFile;
exports.parseNamespaceFromBuildGradleFile = parseNamespaceFromBuildGradleFile;
exports.parsePackageNameFromAndroidManifestFile = parsePackageNameFromAndroidManifestFile;
exports.validatePackageName = validatePackageName;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getAndroidProject(config) {
const androidProject = config.project.android;
if (!androidProject) {
throw new (_cliTools().CLIError)(`
Android project not found. Are you sure this is a React Native project?
If your Android files are located in a non-standard location (e.g. not inside 'android' folder), consider setting
\`project.android.sourceDir\` option to point to a new location.
`);
}
return androidProject;
}
/**
* Util function to discover the package name from either the Manifest file or the build.gradle file.
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
function discoverPackageName(manifestPath, buildGradlePath) {
if (manifestPath) {
const androidManifest = _fs().default.readFileSync(manifestPath, 'utf8');
const packageNameFromManifest = parsePackageNameFromAndroidManifestFile(androidManifest);
// We got the package from the AndroidManifest.xml
if (packageNameFromManifest) {
return packageNameFromManifest;
}
}
if (buildGradlePath) {
// We didn't get the package from the AndroidManifest.xml,
// so we'll try to get it from the build.gradle[.kts] file
// via the namespace field.
const buildGradle = _fs().default.readFileSync(buildGradlePath, 'utf8');
const namespace = parseNamespaceFromBuildGradleFile(buildGradle);
if (namespace) {
return namespace;
}
}
throw new (_cliTools().CLIError)(`Failed to build the app: No package name found.
We couldn't parse the namespace from neither your build.gradle[.kts] file at ${_chalk().default.underline.dim(`${buildGradlePath}`)}
nor your package in the AndroidManifest at ${_chalk().default.underline.dim(`${manifestPath}`)}
`);
}
/**
* Get the package name/namespace of the running React Native app
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
function getPackageName(manifestPath, buildGradlePath) {
let packageName = discoverPackageName(manifestPath, buildGradlePath);
if (!validatePackageName(packageName)) {
_cliTools().logger.warn(`Invalid application's package name "${_chalk().default.bgRed(packageName)}" in either 'AndroidManifest.xml' or 'build.gradle'. Read guidelines for setting the package name here: ${_chalk().default.underline.dim('https://developer.android.com/studio/build/application-id')}`);
}
return packageName;
}
function parsePackageNameFromAndroidManifestFile(androidManifest) {
const matchArray = androidManifest.match(/package="(.+?)"/);
if (matchArray && matchArray.length > 0) {
return matchArray[1];
} else {
return null;
}
}
function parseNamespaceFromBuildGradleFile(buildGradle) {
// search for namespace = inside the build.gradle file via regex
const matchArray = buildGradle.match(/namespace\s*[=]*\s*["'](.+?)["']/);
if (matchArray && matchArray.length > 0) {
return matchArray[1];
} else {
return null;
}
}
// Validates that the package name is correct
function validatePackageName(packageName) {
return /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/i.test(packageName);
}
// Search for applicationId at defaultConfig object
function parseApplicationIdFromBuildGradleFile(buildGradlePath) {
if (!buildGradlePath) {
return null;
}
const buildGradle = _fs().default.readFileSync(buildGradlePath, 'utf8');
const matchArray = buildGradle.match(/defaultConfig\s*{([\s\S]*?)}/);
if (matchArray && matchArray.length > 0) {
const appIdMatchArray = matchArray[1].match(/applicationId\s*[=]*\s*["'](.+?)["']/);
return (appIdMatchArray === null || appIdMatchArray === void 0 ? void 0 : appIdMatchArray[1]) ?? '';
} else {
return null;
}
}
//# sourceMappingURL=getAndroidProject.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
/**
* Reads the AndroidManifest.xml file and returns the name of the main activity.
*/
export default function getMainActivity(manifestPath: string): string | null;
//# sourceMappingURL=getMainActivity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMainActivity.d.ts","sourceRoot":"","sources":["../../src/config/getMainActivity.ts"],"names":[],"mappings":"AAmBA;;GAEG;AAEH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0E3E"}

View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getMainActivity;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _fastXmlParser() {
const data = require("fast-xml-parser");
_fastXmlParser = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const MAIN_ACTION = 'android.intent.action.MAIN';
const LAUNCHER = 'android.intent.category.LAUNCHER';
/**
* Reads the AndroidManifest.xml file and returns the name of the main activity.
*/
function getMainActivity(manifestPath) {
try {
const xmlParser = new (_fastXmlParser().XMLParser)({
ignoreAttributes: false
});
const manifestContent = _fs().default.readFileSync(manifestPath, {
encoding: 'utf8'
});
if (_fastXmlParser().XMLValidator.validate(manifestContent)) {
const {
manifest
} = xmlParser.parse(manifestContent);
const application = manifest.application || {};
const activity = application.activity || {};
let activities = [];
if (!Array.isArray(activity)) {
activities = [activity];
} else {
activities = activity;
}
const mainActivity = activities.find(act => {
let intentFilters = act['intent-filter'];
if (!intentFilters) {
return false;
}
if (!Array.isArray(intentFilters)) {
intentFilters = [intentFilters];
}
return intentFilters.find(intentFilter => {
const {
action,
category
} = intentFilter;
let actions;
let categories;
if (!Array.isArray(action)) {
actions = [action];
} else {
actions = action;
}
if (!Array.isArray(category)) {
categories = [category];
} else {
categories = category;
}
if (actions && categories) {
const parsedActions = actions.map(({
'@_android:name': name
}) => name);
const parsedCategories = categories.map(({
'@_android:name': name
}) => name);
return parsedActions.includes(MAIN_ACTION) && parsedCategories.includes(LAUNCHER);
}
return false;
});
});
return mainActivity ? mainActivity['@_android:name'] : null;
} else {
return null;
}
} catch {
return null;
}
}
//# sourceMappingURL=getMainActivity.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["MAIN_ACTION","LAUNCHER","getMainActivity","manifestPath","xmlParser","XMLParser","ignoreAttributes","manifestContent","fs","readFileSync","encoding","XMLValidator","validate","manifest","parse","application","activity","activities","Array","isArray","mainActivity","find","act","intentFilters","intentFilter","action","category","actions","categories","parsedActions","map","name","parsedCategories","includes"],"sources":["../../src/config/getMainActivity.ts"],"sourcesContent":["import fs from 'fs';\nimport {XMLParser, XMLValidator} from 'fast-xml-parser';\n\nconst MAIN_ACTION = 'android.intent.action.MAIN';\nconst LAUNCHER = 'android.intent.category.LAUNCHER';\n\ninterface Activity {\n [x: string]: any;\n}\n\ninterface AndroidNameProperty {\n '@_android:name': string;\n}\n\ninterface IntentFilter {\n action: AndroidNameProperty | AndroidNameProperty[];\n category: AndroidNameProperty | AndroidNameProperty[];\n}\n\n/**\n * Reads the AndroidManifest.xml file and returns the name of the main activity.\n */\n\nexport default function getMainActivity(manifestPath: string): string | null {\n try {\n const xmlParser = new XMLParser({ignoreAttributes: false});\n const manifestContent = fs.readFileSync(manifestPath, {encoding: 'utf8'});\n\n if (XMLValidator.validate(manifestContent)) {\n const {manifest} = xmlParser.parse(manifestContent);\n\n const application = manifest.application || {};\n const activity = application.activity || {};\n\n let activities: Activity[] = [];\n\n if (!Array.isArray(activity)) {\n activities = [activity];\n } else {\n activities = activity;\n }\n\n const mainActivity = activities.find((act: Activity) => {\n let intentFilters = act['intent-filter'];\n\n if (!intentFilters) {\n return false;\n }\n\n if (!Array.isArray(intentFilters)) {\n intentFilters = [intentFilters];\n }\n\n return intentFilters.find((intentFilter: IntentFilter) => {\n const {action, category} = intentFilter;\n\n let actions;\n let categories;\n\n if (!Array.isArray(action)) {\n actions = [action];\n } else {\n actions = action;\n }\n\n if (!Array.isArray(category)) {\n categories = [category];\n } else {\n categories = category;\n }\n\n if (actions && categories) {\n const parsedActions: string[] = actions.map(\n ({'@_android:name': name}) => name,\n );\n\n const parsedCategories: string[] = categories.map(\n ({'@_android:name': name}) => name,\n );\n\n return (\n parsedActions.includes(MAIN_ACTION) &&\n parsedCategories.includes(LAUNCHER)\n );\n }\n\n return false;\n });\n });\n\n return mainActivity ? mainActivity['@_android:name'] : null;\n } else {\n return null;\n }\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAExD,MAAMA,WAAW,GAAG,4BAA4B;AAChD,MAAMC,QAAQ,GAAG,kCAAkC;AAenD;AACA;AACA;;AAEe,SAASC,eAAe,CAACC,YAAoB,EAAiB;EAC3E,IAAI;IACF,MAAMC,SAAS,GAAG,KAAIC,0BAAS,EAAC;MAACC,gBAAgB,EAAE;IAAK,CAAC,CAAC;IAC1D,MAAMC,eAAe,GAAGC,aAAE,CAACC,YAAY,CAACN,YAAY,EAAE;MAACO,QAAQ,EAAE;IAAM,CAAC,CAAC;IAEzE,IAAIC,6BAAY,CAACC,QAAQ,CAACL,eAAe,CAAC,EAAE;MAC1C,MAAM;QAACM;MAAQ,CAAC,GAAGT,SAAS,CAACU,KAAK,CAACP,eAAe,CAAC;MAEnD,MAAMQ,WAAW,GAAGF,QAAQ,CAACE,WAAW,IAAI,CAAC,CAAC;MAC9C,MAAMC,QAAQ,GAAGD,WAAW,CAACC,QAAQ,IAAI,CAAC,CAAC;MAE3C,IAAIC,UAAsB,GAAG,EAAE;MAE/B,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,EAAE;QAC5BC,UAAU,GAAG,CAACD,QAAQ,CAAC;MACzB,CAAC,MAAM;QACLC,UAAU,GAAGD,QAAQ;MACvB;MAEA,MAAMI,YAAY,GAAGH,UAAU,CAACI,IAAI,CAAEC,GAAa,IAAK;QACtD,IAAIC,aAAa,GAAGD,GAAG,CAAC,eAAe,CAAC;QAExC,IAAI,CAACC,aAAa,EAAE;UAClB,OAAO,KAAK;QACd;QAEA,IAAI,CAACL,KAAK,CAACC,OAAO,CAACI,aAAa,CAAC,EAAE;UACjCA,aAAa,GAAG,CAACA,aAAa,CAAC;QACjC;QAEA,OAAOA,aAAa,CAACF,IAAI,CAAEG,YAA0B,IAAK;UACxD,MAAM;YAACC,MAAM;YAAEC;UAAQ,CAAC,GAAGF,YAAY;UAEvC,IAAIG,OAAO;UACX,IAAIC,UAAU;UAEd,IAAI,CAACV,KAAK,CAACC,OAAO,CAACM,MAAM,CAAC,EAAE;YAC1BE,OAAO,GAAG,CAACF,MAAM,CAAC;UACpB,CAAC,MAAM;YACLE,OAAO,GAAGF,MAAM;UAClB;UAEA,IAAI,CAACP,KAAK,CAACC,OAAO,CAACO,QAAQ,CAAC,EAAE;YAC5BE,UAAU,GAAG,CAACF,QAAQ,CAAC;UACzB,CAAC,MAAM;YACLE,UAAU,GAAGF,QAAQ;UACvB;UAEA,IAAIC,OAAO,IAAIC,UAAU,EAAE;YACzB,MAAMC,aAAuB,GAAGF,OAAO,CAACG,GAAG,CACzC,CAAC;cAAC,gBAAgB,EAAEC;YAAI,CAAC,KAAKA,IAAI,CACnC;YAED,MAAMC,gBAA0B,GAAGJ,UAAU,CAACE,GAAG,CAC/C,CAAC;cAAC,gBAAgB,EAAEC;YAAI,CAAC,KAAKA,IAAI,CACnC;YAED,OACEF,aAAa,CAACI,QAAQ,CAACjC,WAAW,CAAC,IACnCgC,gBAAgB,CAACC,QAAQ,CAAChC,QAAQ,CAAC;UAEvC;UAEA,OAAO,KAAK;QACd,CAAC,CAAC;MACJ,CAAC,CAAC;MAEF,OAAOmB,YAAY,GAAGA,YAAY,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAC7D,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF"}

View File

@@ -0,0 +1,19 @@
/**
* 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.
*
*/
import { AndroidProjectParams, AndroidProjectConfig, AndroidDependencyParams, AndroidDependencyConfig } from '@react-native-community/cli-types';
/**
* Gets android project config by analyzing given folder and taking some
* defaults specified by user into consideration
*/
export declare function projectConfig(root: string, userConfig?: AndroidProjectParams): AndroidProjectConfig | null;
/**
* Same as projectConfigAndroid except it returns
* different config that applies to packages only
*/
export declare function dependencyConfig(root: string, userConfig?: AndroidDependencyParams | null): AndroidDependencyConfig | null;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,mCAAmC,CAAC;AAW3C;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,oBAAyB,GACpC,oBAAoB,GAAG,IAAI,CAoD7B;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,uBAAuB,GAAG,IAAS,GAC9C,uBAAuB,GAAG,IAAI,CA2EhC"}

View File

@@ -0,0 +1,161 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.dependencyConfig = dependencyConfig;
exports.projectConfig = projectConfig;
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
var _findAndroidDir = _interopRequireDefault(require("./findAndroidDir"));
var _findManifest = _interopRequireDefault(require("./findManifest"));
var _findPackageClassName = _interopRequireDefault(require("./findPackageClassName"));
var _getAndroidProject = require("./getAndroidProject");
var _findLibraryName = require("./findLibraryName");
var _findComponentDescriptors = require("./findComponentDescriptors");
var _findBuildGradle = require("./findBuildGradle");
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
var _getMainActivity = _interopRequireDefault(require("./getMainActivity"));
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.
*
*/
/**
* Gets android project config by analyzing given folder and taking some
* defaults specified by user into consideration
*/
function projectConfig(root, userConfig = {}) {
const src = userConfig.sourceDir || (0, _findAndroidDir.default)(root);
if (!src) {
return null;
}
const sourceDir = _path().default.join(root, src);
const appName = getAppName(sourceDir, userConfig.appName);
const manifestPath = userConfig.manifestPath ? _path().default.join(sourceDir, userConfig.manifestPath) : (0, _findManifest.default)(_path().default.join(sourceDir, appName));
const buildGradlePath = (0, _findBuildGradle.findBuildGradle)(sourceDir, false);
if (!manifestPath && !buildGradlePath) {
return null;
}
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath, buildGradlePath);
if (!packageName) {
throw new (_cliTools().CLIError)(`Package name not found in neither ${manifestPath} nor ${buildGradlePath}`);
}
const applicationId = buildGradlePath ? getApplicationId(buildGradlePath, packageName) : packageName;
const mainActivity = (0, _getMainActivity.default)(manifestPath || '') ?? '';
// @todo remove for RN 0.75
if (userConfig.unstable_reactLegacyComponentNames) {
_cliTools().logger.warn('The "project.android.unstable_reactLegacyComponentNames" config option is not necessary anymore for React Native 0.74 and does nothing. Please remove it from the "react-native.config.js" file.');
}
return {
sourceDir,
appName,
packageName,
applicationId,
mainActivity,
dependencyConfiguration: userConfig.dependencyConfiguration,
watchModeCommandParams: userConfig.watchModeCommandParams,
// @todo remove for RN 0.75
unstable_reactLegacyComponentNames: undefined
};
}
function getApplicationId(buildGradlePath, packageName) {
let appId = packageName;
const applicationId = (0, _getAndroidProject.parseApplicationIdFromBuildGradleFile)(buildGradlePath);
if (applicationId) {
appId = applicationId;
}
return appId;
}
function getAppName(sourceDir, userConfigAppName) {
let appName = '';
if (typeof userConfigAppName === 'string' && _fs().default.existsSync(_path().default.join(sourceDir, userConfigAppName))) {
appName = userConfigAppName;
} else if (_fs().default.existsSync(_path().default.join(sourceDir, 'app'))) {
appName = 'app';
}
return appName;
}
/**
* Same as projectConfigAndroid except it returns
* different config that applies to packages only
*/
function dependencyConfig(root, userConfig = {}) {
if (userConfig === null) {
return null;
}
const src = userConfig.sourceDir || (0, _findAndroidDir.default)(root);
if (!src) {
return null;
}
const sourceDir = _path().default.join(root, src);
const manifestPath = userConfig.manifestPath ? _path().default.join(sourceDir, userConfig.manifestPath) : (0, _findManifest.default)(sourceDir);
const buildGradlePath = (0, _findBuildGradle.findBuildGradle)(sourceDir, true);
if (!manifestPath && !buildGradlePath) {
return null;
}
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath, buildGradlePath);
const packageClassName = (0, _findPackageClassName.default)(sourceDir);
/**
* This module has no package to export
*/
if (!packageClassName) {
return null;
}
const packageImportPath = userConfig.packageImportPath || `import ${packageName}.${packageClassName};`;
const packageInstance = userConfig.packageInstance || `new ${packageClassName}()`;
const buildTypes = userConfig.buildTypes || [];
const dependencyConfiguration = userConfig.dependencyConfiguration;
const libraryName = userConfig.libraryName || (0, _findLibraryName.findLibraryName)(root, sourceDir);
const componentDescriptors = userConfig.componentDescriptors || (0, _findComponentDescriptors.findComponentDescriptors)(root);
let cmakeListsPath = userConfig.cmakeListsPath ? _path().default.join(sourceDir, userConfig.cmakeListsPath) : _path().default.join(sourceDir, 'build/generated/source/codegen/jni/CMakeLists.txt');
const cxxModuleCMakeListsModuleName = userConfig.cxxModuleCMakeListsModuleName || null;
const cxxModuleHeaderName = userConfig.cxxModuleHeaderName || null;
let cxxModuleCMakeListsPath = userConfig.cxxModuleCMakeListsPath ? _path().default.join(sourceDir, userConfig.cxxModuleCMakeListsPath) : null;
if (process.platform === 'win32') {
cmakeListsPath = cmakeListsPath.replace(/\\/g, '/');
if (cxxModuleCMakeListsPath) {
cxxModuleCMakeListsPath = cxxModuleCMakeListsPath.replace(/\\/g, '/');
}
}
return {
sourceDir,
packageImportPath,
packageInstance,
buildTypes,
dependencyConfiguration,
libraryName,
componentDescriptors,
cmakeListsPath,
cxxModuleCMakeListsModuleName,
cxxModuleCMakeListsPath,
cxxModuleHeaderName
};
}
//# sourceMappingURL=index.ts.map

File diff suppressed because one or more lines are too long