Skip to content

Commit 1e1d9d8

Browse files
committed
init
1 parent 65ab1dd commit 1e1d9d8

17 files changed

+1816
-2
lines changed

.config/.eslintrc.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
env: {
3+
commonjs: true,
4+
es6: true,
5+
node: true,
6+
},
7+
parserOptions: {
8+
ecmaVersion: 2018,
9+
},
10+
extends: 'eslint:recommended',
11+
rules: {
12+
'comma-dangle': ['error', 'always-multiline'],
13+
'indent': ['error', 4],
14+
'no-trailing-spaces': 'error',
15+
'quotes': ['error', 'single'],
16+
'semi': 'off',
17+
'array-bracket-spacing': ['error', 'never'],
18+
},
19+
};

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
3+
!.eslintrc.js
4+
!.config/.eslintrc.js

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.config/.eslintrc.js

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# project
2+
RnDiffApp
3+
4+
# macOS
5+
.DS_Store

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
sudo: false
3+
4+
script:
5+
- ls

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pavlos Vinieratos <[email protected]>

README.md

+196-2
Large diffs are not rendered by default.

README_MAINTAINERS.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# New version generation instructions
2+
3+
To generate `0.57.2 -> 0.57.3`:
4+
5+
```sh
6+
./new-version.sh 0.57.3
7+
```
8+
9+
Note: Always go one by one.
10+
11+
Verify the commit is ok, with the `package.json` file updated and any other file changes.
12+
13+
If all is well, press `y` to push the branch.
14+
15+
Afterwards, commit the new line on `README.md` and push to master.

Test.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
| From->To | R | E | A | C | T | | N | A | T | I | V | E |
2+
| ----------- | -------- | -------- | ------------- | -------- | ------------- | ------------- | -------- | -------- | -------- | -------- | -------- | --- |
3+
| 0.59.1 | X | - | - | - | - | - | - | - | - | - | - | - |
4+
| 0.59.0 | ->0.59.1 | X | - | - | - | - | - | - | - | - | - | - |
5+
| 0.59.0-rc.2 | ->0.59.1 | ->0.59.0 | X | - | - | - | - | - | - | - | - | - |
6+
| 0.58.5 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | X | ->0.59.0-rc.1 | ->0.59.0-rc.0 | - | - | - | - | - | - |
7+
| 0.59.0-rc.1 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | - | X | - | - | - | - | - | - | - |
8+
| 0.59.0-rc.0 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | - | ->0.59.0-rc.1 | X | - | - | - | - | - | - |
9+
| 0.58.4 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | X | - | - | - | - | - |
10+
| 0.58.3 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | ->0.58.4 | X | - | - | - | - |
11+
| 0.58.2 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | ->0.58.4 | ->0.58.3 | X | - | - | - |
12+
| 0.58.1 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | ->0.58.4 | ->0.58.3 | ->0.58.2 | X | - | - |
13+
| 0.58.0 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | ->0.58.4 | ->0.58.3 | ->0.58.2 | ->0.58.1 | X | - |
14+
| 0.57.8 | ->0.59.1 | ->0.59.0 | ->0.59.0-rc.2 | ->0.58.5 | ->0.59.0-rc.1 | ->0.59.0-rc.0 | ->0.58.4 | ->0.58.3 | ->0.58.2 | ->0.58.1 | ->0.58.0 | X |

USAGE.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Using rn-diff-purge
2+
3+
The git patches can be used as a replacement of `react-native-git-upgrade`. The procedure is
4+
straightforward and more trusted than using the upgrade command.
5+
6+
## Recommended method
7+
8+
#### 1 Check the diff
9+
Check the diff of your current version and the version you want to upgrade to.
10+
11+
#### 2 Manually do the changes
12+
Do the changes from the diff in your project.
13+
They are usually no more than 10 lines, so it's pretty quick and easy.
14+
If it's more than that, you could try the alternative method below.
15+
:warning: In any case, make sure you pay attention to the changes made. It's always imporant to know what an upgrade actually changed.
16+
17+
## Alternative method (using patch)
18+
19+
#### 1 Download the git patch
20+
21+
Download the patch for your version, for example:
22+
23+
```shell
24+
curl https://github.com/pvinis/rn-diff-purge/compare/version/0.29.0...version/0.30.0.diff > upgrade-rn.patch
25+
```
26+
27+
#### 2 Prepare the patch
28+
29+
The patch is made for the RnDiffApp located in the *RnDiffApp* folder of this repository.
30+
To use it in your own repository, some changes are needed.
31+
32+
Don't worry about the root folder *RnDiffApp*, it can be ignored with the option `-p 2`
33+
(see https://git-scm.com/docs/git-apply)
34+
35+
Then, some files include the name of the app in their path:
36+
37+
- All files in the `ios` directory (example: `ios/RnDiffApp/AppDelegate.m`)
38+
- Some files in the `android` directory (example:
39+
`android/app/src/main/java/com/rndiffapp/MainActivity.java`)
40+
41+
You have to edit the patch and replace all occurences of `ios/RnDiffApp` and `com/rndiffapp`
42+
by the name of your app.
43+
44+
#### 3 Set up the 3-way merge
45+
46+
By default in case of conflicts, the `git apply` command will fail and leave the files untouched.
47+
It could be interesting to fallback on a 3-way merge (option `--3way`) in order to resolve the
48+
conflicts with your favorite merge tool.
49+
50+
To do this, git needs to know the blob referenced in the patch
51+
(line `index 4c88077..e49e881 100644` for example). So you have to add rn-diff as a remote
52+
repository and fetch it (see this [SO question](http://stackoverflow.com/questions/33577383/git-apply-3way-error-repository-lacks-the-necessary-blob-to-fall-back-on-3-way)
53+
for details).
54+
55+
```shell
56+
git remote add rn-diff-purge https://github.com/pvinis/rn-diff-purge.git
57+
git fetch rn-diff-purge
58+
```
59+
60+
#### 4 Run the apply command
61+
```shell
62+
git apply upgrade-rn.patch --exclude=package.json -p 2 --3way
63+
```
64+
65+
66+
### Wrap up
67+
68+
```shell
69+
# Download the patch
70+
curl https://github.com/pvinis/rn-diff-purge/compare/version/0.29.0...version/0.30.0.diff > upgrade-rn.patch
71+
72+
# Replace RnDiffApp occurences
73+
appNameCamelCase=MyApp
74+
appNameLowerCase=myapp
75+
sed -i "" "s-ios/RnDiffApp-ios/${appNameCamelCase}-" upgrade-rn.patch
76+
sed -i "" "s-java/com/rndiffapp-java/com/${appNameLowerCase}-" upgrade-rn.patch
77+
78+
# Set up the 3-way merge
79+
git remote add rn-diff-purge https://github.com/pvinis/rn-diff-purge.git
80+
git fetch rn-diff-purge
81+
82+
# Run the apply command
83+
git apply upgrade-rn.patch --exclude=package.json -p 2 --3way
84+
```
85+
86+
### :warning: Known issues
87+
Sometimes there are new files that reference the project's name. Whenever there is a new file, make sure to check for this, and replace it with your project's name.

VERSIONS

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
0.58.1
2+
0.58.0
3+
0.32.0
4+
0.31.0
5+
0.23.1
6+
0.23.0

multiple-versions.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
5+
versions=(
6+
0.23.1
7+
0.24.0-rc
8+
0.24.0-rc1
9+
0.24.0-rc2
10+
0.24.0-rc3
11+
0.24.0-rc4
12+
0.24.0-rc5
13+
0.24.0
14+
0.24.1
15+
0.25.0-rc
16+
0.25.1
17+
0.26.0-rc
18+
0.26.0
19+
0.26.1
20+
0.26.2
21+
0.26.3
22+
0.27.0-rc
23+
0.27.0-rc1
24+
0.27.0-rc2
25+
0.27.0-rc3
26+
0.27.0
27+
0.27.1
28+
0.27.2
29+
0.28.0-rc.0
30+
0.28.0
31+
0.29.0-rc.0
32+
0.29.0-rc.1
33+
0.29.0-rc.2
34+
0.29.0-rc.3
35+
0.29.0
36+
0.29.1
37+
0.29.2
38+
0.30.0-rc.0
39+
0.30.0
40+
0.31.0-rc.0
41+
0.31.0-rc.1
42+
0.31.0
43+
0.32.0-rc.0
44+
0.32.0
45+
0.32.1
46+
0.33.0-rc.0
47+
0.33.0-rc.1
48+
0.33.0
49+
0.33.1
50+
0.34.0-rc.0
51+
0.34.0
52+
0.34.1
53+
0.35.0-rc.0
54+
0.35.0
55+
0.36.0-rc.0
56+
0.36.0-rc.1
57+
0.36.0
58+
0.36.1
59+
)
60+
61+
for v in "${versions[@]}"
62+
do
63+
echo $v
64+
./new-version.sh $v
65+
done

new-version.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env node
2+
3+
const table = require('markdown-table')
4+
const R = require('ramda')
5+
const semver = require('semver')
6+
const fs = require('fs')
7+
const replace = require('replace-in-file')
8+
const execa = require('execa')
9+
const shell = require('shelljs')
10+
11+
12+
13+
const AppBaseBranch = 'app-base'
14+
const AppName = 'RnDiffApp'
15+
16+
17+
18+
const main = async () => {
19+
const newVersion = '0.33.0'
20+
await generateNewVersionBranch(newVersion)
21+
}
22+
23+
24+
const generateReadme = () => {
25+
const versions = [
26+
'0.59.1',
27+
'0.59.0',
28+
'0.59.0-rc.2',
29+
'0.58.5',
30+
'0.59.0-rc.1',
31+
'0.59.0-rc.0',
32+
'0.58.4',
33+
'0.58.3',
34+
'0.58.2',
35+
'0.58.1',
36+
'0.58.0',
37+
'0.57.8',
38+
]
39+
40+
// words or phrases of length 12
41+
const comments = [
42+
'react native',
43+
'this is cool',
44+
'purge time!!',
45+
'i love diffs',
46+
'diffs == fun',
47+
'rn core team',
48+
]
49+
50+
const diffTable = [
51+
['From->To', ...comments[Math.floor(Math.random() * comments.length)] .toUpperCase() .split('')],
52+
...R.map(fromVersion => {
53+
const length = versions.length
54+
return [
55+
fromVersion,
56+
...R.pipe(
57+
R.map(idx => {
58+
const toVersion = versions[idx]
59+
if (semver.eq(fromVersion, toVersion)) {
60+
return 'X'
61+
}
62+
if (semver.gt(fromVersion, toVersion)) {
63+
return '-'
64+
}
65+
return `->${toVersion}`
66+
}),
67+
)(R.range(0, length)),
68+
]
69+
}, versions),
70+
]
71+
72+
console.log(table(diffTable))
73+
fs.writeFileSync('Test.md', table(diffTable))
74+
}
75+
76+
77+
78+
// # get previous version
79+
// prevTag=$(git tag --points-at HEAD)
80+
// prevVersion=$(basename "$prevTag")
81+
82+
83+
// # save the stats
84+
// diffStat=$(git --no-pager diff HEAD~1 --shortstat)
85+
86+
87+
// # update readme
88+
// diffUrl="[${prevVersion}...${newVersion}](https://github.com/pvinis/rn-diff-purge/compare/version/${prevVersion}...version/${newVersion})"
89+
// patchUrl="[${prevVersion}...${newVersion}](https://github.com/pvinis/rn-diff-purge/compare/version/${prevVersion}...version/${newVersion}.diff)"
90+
// rnDiffUrl="[${prevVersion}...${newVersion}](https://github.com/facebook/react-native/compare/v${prevVersion}...v${newVersion})"
91+
92+
// # insert a row in the version table
93+
// # shellcheck disable=SC1004
94+
// sed -i '' 's/----|----|----|----|----/----|----|----|----|----\
95+
// NEWLINE/g' README.md
96+
// # edit the new line with the version info
97+
// sed -i "" "s@NEWLINE@${newVersion}|${diffUrl}|${patchUrl}|${diffStat}|${rnDiffUrl}@" README.md
98+
99+
// (async () => {
100+
// await main()
101+
// })()

new-version.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
5+
ErrorVersionExists=2
6+
7+
AppName=RnDiffApp
8+
AppBaseBranch=app-base
9+
VersionsFile=VERSIONS
10+
11+
newVersion=$1
12+
13+
14+
function guardExisting () {
15+
if grep -q "$newVersion" "$VersionsFile"; then
16+
echo "Version $newVersion already exists!"
17+
exit "$ErrorVersionExists"
18+
fi
19+
}
20+
21+
function prepare () {
22+
yarn install
23+
}
24+
25+
function generateNewVersionBranch () {
26+
27+
# go to the base app branch
28+
git checkout "$AppBaseBranch"
29+
30+
# clear any existing stuff
31+
rm -rf "$AppName"
32+
33+
# make a new branch
34+
git checkout -b version/"$newVersion"
35+
36+
# generate app
37+
react-native init "$AppName" --version "$newVersion"
38+
39+
# commit
40+
git add "$AppName"
41+
git commit -m "Version $newVersion"
42+
43+
# go back to master
44+
git checkout new-new-master
45+
}
46+
47+
function addVersionToList () {
48+
echo "$newVersion" >> "$VersionsFile"
49+
# take each line ->dedup-> sort them -> reverse them -> save them
50+
cat "$VersionsFile" | uniq | xargs yarn --silent semver | tac > tmpfile
51+
mv tmpfile "$VersionsFile"
52+
}
53+
54+
55+
guardExisting
56+
57+
prepare
58+
generateNewVersionBranch
59+
addVersionToList

0 commit comments

Comments
 (0)