Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android custom files #293

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { cleanString, encodeXmlEntities } from './utils';
import fs from 'fs';
import path from 'path';

export const androidManifestXml = 'android/app/src/main/AndroidManifest.xml';
export const androidValuesStrings = 'android/app/src/main/res/values/strings.xml';
Expand Down Expand Up @@ -237,13 +239,61 @@ export const getAndroidUpdateFilesContentOptions = ({
];
};

const getAllProjectFiles = options => {
const files = fs.readdirSync(
path.join(process.cwd(), `android/app/src/main/java/${options.newBundleIDAsPath}`)
);
let result = [];
const dirFiles = [];

for (const file of files) {
if (
fs
.lstatSync(
path.join(process.cwd(), `android/app/src/main/java/${options.newBundleIDAsPath}/${file}`)
)
.isDirectory()
) {
result.push(
...getAllProjectFiles({
currentBundleID: [options.currentBundleID, file].join('.'),
newBundleID: [options.newBundleID, file].join('.'),
currentBundleIDAsPath: [options.currentBundleIDAsPath, file].join('/'),
newBundleIDAsPath: [options.newBundleIDAsPath, file].join('/'),
})
);
} else {
dirFiles.push(`android/app/src/main/java/${options.newBundleIDAsPath}/${file}`);
}
}

result = [
{
files: dirFiles,
from: new RegExp(`${options.currentBundleID}`, 'g'),
to: options.newBundleID,
},
...result,
];

return result;
};

export const getAndroidUpdateBundleIDOptions = ({
currentBundleID,
newBundleID,
currentBundleIDAsPath,
newBundleIDAsPath,
}) => {
const result = getAllProjectFiles({
currentBundleID,
newBundleID,
currentBundleIDAsPath,
newBundleIDAsPath,
});

return [
...result,
{
files: [
'android/app/_BUCK',
Expand Down
Loading