@reuvenorg/react-native-boilerplate-ultimate
Version:
A powerful CLI tool for creating React Native projects with modular architecture. Generate, manage, and scaffold React Native applications with pre-built modules and best practices.
50 lines • 1.81 kB
JavaScript
import { FileProcessor } from './base-processor.js';
export class JsonProcessor extends FileProcessor {
canProcess(filePath) {
return filePath.endsWith('.json') && !this.shouldSkipFile(filePath);
}
async process(filePath, context) {
const content = await this.readFile(filePath);
try {
const json = JSON.parse(content);
this.transformJson(json, context);
await this.writeFile(filePath, JSON.stringify(json, null, 2));
}
catch (error) {
console.warn(`Warning: Could not parse JSON file ${filePath}, treating as text`);
const transformed = this.transformText(content, context);
await this.writeFile(filePath, transformed);
}
}
transformJson(obj, context) {
if (typeof obj === 'string') {
return;
}
if (Array.isArray(obj)) {
for (let i = 0; i < obj.length; i++) {
if (typeof obj[i] === 'string') {
obj[i] = this.transformText(obj[i], context);
}
else {
this.transformJson(obj[i], context);
}
}
}
else if (typeof obj === 'object' && obj !== null) {
for (const [key, value] of Object.entries(obj)) {
if (typeof value === 'string') {
obj[key] = this.transformText(value, context);
}
else {
this.transformJson(value, context);
}
}
}
}
transformText(text, context) {
return text
.replace(/ExApp/g, context.projectName)
.replace(/com\.anonymous\.exapp/g, context.bundleId);
}
}
//# sourceMappingURL=json-processor.js.map