Skip to content

s #3

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

Open
wants to merge 28 commits into
base: feature/sync
Choose a base branch
from
Open

s #3

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
96d7162
Merge tag 'v3.2.12' into develop
junedomingo Jan 28, 2023
481e0af
Merge branch 'master' into develop
junedomingo Jan 31, 2023
5cee684
Merge branch 'master' into develop
junedomingo Feb 8, 2023
c21b301
Merge branch 'dependabot/npm_and_yarn/prettier-2.8.4' into develop
junedomingo Feb 21, 2023
a3a679b
Merge branch 'dependabot/npm_and_yarn/jest-29.4.3' into develop
junedomingo Feb 21, 2023
2d47d50
Merge branch 'dependabot/npm_and_yarn/esbuild-0.17.10' into develop
junedomingo Feb 21, 2023
639412d
Merge branch 'master' into develop
junedomingo Feb 21, 2023
782ee58
Merge tag 'v3.2.13' into develop
junedomingo Jun 12, 2023
49cb355
Merge tag 'v3.2.14' into develop
junedomingo Jan 20, 2024
664158e
Update paths.js
DhavalsShah Sep 10, 2024
876b8e7
Update lock
junedomingo Feb 18, 2025
7b1cf8b
Just use iosInfoPlist path
junedomingo Feb 18, 2025
c9049ca
Update self.moduleName in AppDelefate.swift
junedomingo Feb 18, 2025
f5ed847
Update version to 3.2.15
junedomingo Feb 18, 2025
317288d
Merge branch 'release/3.2.15'
junedomingo Feb 18, 2025
2ab895c
Merge tag 'v3.2.15' into develop
junedomingo Feb 18, 2025
e5bac50
Add new rn project with 0.77.1 version
junedomingo Feb 18, 2025
c44fab5
Update test
junedomingo Feb 18, 2025
3329b35
Update snapshot
junedomingo Feb 18, 2025
d85c944
Update snapshot
junedomingo Feb 18, 2025
a952437
Update snap
junedomingo Feb 18, 2025
07e6a44
Add addSnapshotSerializer
junedomingo Feb 18, 2025
6ead123
Update snap
junedomingo Feb 18, 2025
6c8c9db
Add .gitattributes
junedomingo Feb 18, 2025
6ec381d
Update node version
junedomingo Feb 18, 2025
8c69d33
Merge pull request #294 from DhavalsShah/patch-1
junedomingo Feb 19, 2025
325290b
Update snapshot
junedomingo Feb 19, 2025
52b1b63
Update version to 3.2.16
junedomingo Feb 19, 2025
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.js text eol=lf
*.snap text eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [16.x]
node-version: ['20.18']

steps:
- uses: actions/checkout@v3
Expand Down
7,312 changes: 1,083 additions & 6,229 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-rename",
"version": "3.2.14",
"version": "3.2.16",
"description": "Rename react-native app with just one command",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -70,4 +70,4 @@
"shelljs": "^0.8.5",
"update-check": "^1.5.4"
}
}
}
9 changes: 7 additions & 2 deletions src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const androidValuesStrings = 'android/app/src/main/res/values/strings.xml
export const androidJava = 'android/app/src/*/java';
export const iosXcodeproj = 'ios/*.xcodeproj';
export const iosPbxProject = 'ios/*.xcodeproj/project.pbxproj';
export const iosAppDelegate = 'ios/*/AppDelegate.h';
export const iosInfoPlist = 'ios/*/Info.plist';
export const appJson = 'app.json';
export const packageJson = 'package.json';
export const buildPaths = [
Expand Down Expand Up @@ -59,6 +59,11 @@ export const getIosUpdateFilesContentOptions = ({
from: [new RegExp(`@"${currentName}"`, 'g')],
to: `@"${newName}"`,
},
{
files: 'ios/*/AppDelegate.swift',
from: [new RegExp(`self.moduleName = "${currentName}"`, 'g')],
to: `self.moduleName = "${newName}"`,
},
{
files: [
'ios/*.xcodeproj/project.pbxproj',
Expand Down Expand Up @@ -191,7 +196,7 @@ export const getAndroidUpdateFilesContentOptions = ({
{
files: 'android/settings.gradle',
from: [/rootProject.name = "(.*)"/g, /rootProject.name = '(.*)'/g],
to: `rootProject.name = '${newName}'`,
to: `rootProject.name = "${newName}"`,
},
{
files: [`android/app/src/main/java/${newBundleIDAsPath}/MainActivity.java`],
Expand Down
16 changes: 4 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
getIosFoldersAndFilesPaths,
getIosUpdateFilesContentOptions,
getOtherUpdateFilesContentOptions,
iosAppDelegate,
iosInfoPlist,
iosXcodeproj,
packageJson,
} from './paths';
Expand All @@ -48,9 +48,7 @@ const normalizePath = process.platform === 'win32' ? require('normalize-path') :
const androidValuesStringsFullPath = path.join(APP_PATH, androidValuesStrings);

export const validateCreation = () => {
const iosInfoPlistFullPath = globbySync(
normalizePath(path.join(APP_PATH, iosAppDelegate))
)[0].replace('AppDelegate.h', 'Info.plist');
const iosInfoPlistFullPath = globbySync(normalizePath(path.join(APP_PATH, iosInfoPlist)))[0];
const fileExists =
fs.existsSync(iosInfoPlistFullPath) && fs.existsSync(androidValuesStringsFullPath);

Expand Down Expand Up @@ -171,10 +169,7 @@ const getElementFromXml = ({ filepath, selector }) => {
};

export const getIosCurrentName = () => {
const filepath = globbySync(normalizePath(path.join(APP_PATH, iosAppDelegate)))[0].replace(
'AppDelegate.h',
'Info.plist'
);
const filepath = globbySync(normalizePath(path.join(APP_PATH, iosInfoPlist)))[0];
const selector = 'dict > key:contains("CFBundleDisplayName") + string';
const element = getElementFromXml({ filepath, selector });

Expand Down Expand Up @@ -356,10 +351,7 @@ const updateElementInXml = async ({ filepath, selector, text }) => {

export const updateIosNameInInfoPlist = async newName => {
await updateElementInXml({
filepath: globbySync(normalizePath(path.join(APP_PATH, iosAppDelegate)))[0].replace(
'AppDelegate.h',
'Info.plist'
),
filepath: globbySync(normalizePath(path.join(APP_PATH, iosInfoPlist)))[0],
selector: 'dict > key:contains("CFBundleDisplayName") + string',
text: newName,
});
Expand Down
3,082 changes: 898 additions & 2,184 deletions tests/__snapshots__/rename.test.js.snap

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions tests/rename.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,44 @@ const resetGit = cwd => {
});
};

describe('rn-versions/0.70.6', () => {
const cwd = path.join(__dirname, 'rn-versions/0.70.6');
expect.addSnapshotSerializer({
test: val => typeof val === 'string',
print: val => val.replace(/\r\n/g, '\n').replace(/\\/g, '/'),
});

describe('rn-versions/0.77.1', () => {
const cwd = path.join(__dirname, 'rn-versions/0.77.1');

afterEach(() => {
resetGit(cwd);
});

test('Change app name', () => {
run(cwd, `"Demo App"`);
run(cwd, `"Travel App"`);

const result = getDiff(cwd);

expect(result).toMatchSnapshot();
});

test('Change app name and bundle id for both ios and android', () => {
run(cwd, `"Demo App" -b com.example.demoapp`);
run(cwd, `"Travel App" -b com.example.travelapp`);

const result = getDiff(cwd);

expect(result).toMatchSnapshot();
});

test('Change app name and bundle id for android only', () => {
run(cwd, `"Demo App" --androidBundleID com.example.demoapp`);
run(cwd, `"Travel App" --androidBundleID com.example.travelapp`);

const result = getDiff(cwd);

expect(result).toMatchSnapshot();
});

test('Change app name and bundle id for ios only', () => {
run(cwd, `"Demo App" --iosBundleID com.example.demoapp`);
run(cwd, `"Travel App" --iosBundleID com.example.travelapp`);

const result = getDiff(cwd);

Expand Down
2 changes: 2 additions & 0 deletions tests/rn-versions/0.77.1/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
4 changes: 4 additions & 0 deletions tests/rn-versions/0.77.1/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
74 changes: 74 additions & 0 deletions tests/rn-versions/0.77.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
**/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
7 changes: 7 additions & 0 deletions tests/rn-versions/0.77.1/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};
1 change: 1 addition & 0 deletions tests/rn-versions/0.77.1/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
118 changes: 118 additions & 0 deletions tests/rn-versions/0.77.1/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

type SectionProps = PropsWithChildren<{
title: string;
}>;

function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
}

function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});

export default App;
10 changes: 10 additions & 0 deletions tests/rn-versions/0.77.1/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
gem 'concurrent-ruby', '< 1.3.4'
Loading