Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

Commit 501ebc2

Browse files
committed
add androidtest,fastlane folder and update ios identifier
1 parent 8653c71 commit 501ebc2

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/config/bundleIdentifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function bundleIdentifiers({ currentAppName, newName, currentBundleID, ne
1515
{
1616
regex: `"${currentBundleID}"`,
1717
replacement: `"${newBundleID}"`,
18-
paths: ['android/app/BUCK', 'android/app/_BUCK', 'android/app/build.gradle'],
18+
paths: ['android/app/BUCK', 'android/app/_BUCK', 'android/app/build.gradle', 'android/fastlane/Appfile'],
1919
},
2020
{
2121
regex: currentBundleID,

src/config/filesToModifyContent.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// nS - No Space
22
// lC - Lowercase
33

4-
export function filesToModifyContent(currentAppName, newName, bundleID) {
4+
export function filesToModifyContent(currentAppName, newName, bundleID, existingBundleId) {
55
const nS_CurrentAppName = currentAppName.replace(/\s/g, '');
66
const nS_NewName = newName.replace(/\s/g, '');
77

8-
return [
8+
const result = [
99
{
1010
regex: `<string name="app_name">${currentAppName}</string>`,
1111
replacement: `<string name="app_name">${newName}</string>`,
@@ -26,6 +26,7 @@ export function filesToModifyContent(currentAppName, newName, bundleID) {
2626
'android/settings.gradle',
2727
`ios/${nS_NewName}Tests/${nS_NewName}Tests.m`,
2828
'ios/build/info.plist',
29+
'ios/fastlane/Fastfile',
2930
'ios/Podfile',
3031
'app.json',
3132
],
@@ -40,11 +41,6 @@ export function filesToModifyContent(currentAppName, newName, bundleID) {
4041
replacement: newName,
4142
paths: [`ios/${nS_NewName}/Info.plist`],
4243
},
43-
{
44-
regex: /\$\(PRODUCT_BUNDLE_IDENTIFIER\)/,
45-
replacement: bundleID,
46-
paths: [`ios/${nS_NewName}/Info.plist`],
47-
},
4844
{
4945
regex: `"name": "${nS_CurrentAppName}"`,
5046
replacement: `"name": "${nS_NewName}"`,
@@ -56,4 +52,14 @@ export function filesToModifyContent(currentAppName, newName, bundleID) {
5652
paths: ['app.json'],
5753
},
5854
];
55+
56+
if (bundleID && existingBundleId) {
57+
result.push({
58+
regex: existingBundleId,
59+
replacement: bundleID,
60+
paths: [`ios/${nS_NewName}.xcodeproj/project.pbxproj`, 'ios/fastlane/Appfile'],
61+
});
62+
}
63+
64+
return result;
5965
}

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { filesToModifyContent } from './config/filesToModifyContent';
1515
import { bundleIdentifiers } from './config/bundleIdentifiers';
1616
import { loadAppConfig, loadAndroidManifest, __dirname, iosRequiredPaths } from './utils';
1717

18-
const androidEnvs = ['main', 'debug'];
18+
const androidEnvs = ['main', 'debug', 'androidTest'];
1919
const projectName = pjson.name;
2020
const projectVersion = pjson.version;
2121
const replaceOptions = {
@@ -65,7 +65,10 @@ loadAppConfig()
6565
const bundleID = program.bundleID ? program.bundleID.toLowerCase() : null;
6666
let newBundlePath;
6767
const listOfFoldersAndFiles = foldersAndFiles(currentAppName, newName);
68-
const listOfFilesToModifyContent = filesToModifyContent(currentAppName, newName, bundleID);
68+
const existingBundleId = shell.exec(
69+
'cd ios && echo $(xcodebuild -showBuildSettings | grep PRODUCT_BUNDLE_IDENTIFIER) | sed "s/ //g" | sed "s/PRODUCT_BUNDLE_IDENTIFIER//g" | sed "s/=//g"'
70+
).stdout;
71+
const listOfFilesToModifyContent = filesToModifyContent(currentAppName, newName, bundleID, existingBundleId);
6972

7073
if (bundleID) {
7174
newBundlePath = bundleID.replace(/\./g, '/');

0 commit comments

Comments
 (0)