Skip to content

Commit

Permalink
Leave Yarn workspaces and reorganize repo structure (callstack#397)
Browse files Browse the repository at this point in the history
* remove yarn lockfile

* correct the link in the podspec file

* remove npm ignore config

* remove git attributes config file

* Make src the package directory

* Use local node modules for example project

* Remove workspaces entry from main package JSON

* Use npm instead of yarn separately for each package

* Recreate the example project with react-native from scratch

* Install React Native Windows in example app

* Use npm for example app

* Install local Slider package in example app

* Fix dependencies conflict by removing peer dependencies

* Use copyfiles to replace symlink with existing files

* Install and link Slider in iOS example

* Bring back original Example app JS implementation

* Install missing babel-preset-expo

* Remove unused configuration files

* Fix linting errors according to new linter version

* Bring back React & React Native to dev deps

* Configure flow and ESLint for tests and linting

* Use rimraf for cross-platform package scripts

* Adjust CI config to new repo structure

* Fix Jest and build paths in CI config

* Use native build to check against example app compilation

* Correct paths in native example builds

* Do not exclude archs and keep the node_modules slider

* Link Slider project into windows example app

* Remove legacy CppWinRT project from Windows Slider

* Add basic scripts for installing modules and running example

* Update README and script according to new repo structure
  • Loading branch information
BartoszKlonowski authored Jul 13, 2022
1 parent 2fb1b15 commit 559edef
Show file tree
Hide file tree
Showing 152 changed files with 24,320 additions and 10,342 deletions.
90 changes: 56 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: 2.1

orbs:
rn: react-native-community/react-native@6.1.0
rn: react-native-community/react-native@7.1.0
windows: circleci/[email protected]
android: circleci/[email protected]
macos: circleci/[email protected]

jobs:
checkout_code:
Expand All @@ -18,23 +20,30 @@ jobs:
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Install node modules for package
command: cd package && npm install
- run:
name: Install node modules for example app
command: cd example && npm install
- run:
name: Lint JS Code (ESLint)
command: yarn run validate:eslint
command: cd package && npx eslint src
- run:
name: Flow
command: yarn run validate:flow
name: Lint Example app JS code (ESLint)
command: cd example && npx eslint .

test:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Install node modules for package
command: cd package && npm install
- run:
name: Run unit tests with Jest
command: yarn run test:jest
command: cd package && npx jest src

build_example_windows:
executor:
Expand All @@ -44,13 +53,13 @@ jobs:
- checkout
- run:
name: Install examples
command: cd src; yarn install; cd ../example; yarn install --force --frozen-lockfile
command: cd package; npm install; cd ../example; npm install
- run:
name: "Restore NuGet packages for Components"
command: nuget restore .\example\windows\SliderTestWindows.sln
command: nuget restore .\example\windows\example.sln
- run:
name: "Restore .NET dependencies"
command: msbuild -t:restore .\example\windows\SliderTestWindows.sln
command: msbuild -t:restore .\example\windows\example.sln
- run:
name: Build example Windows
command: cd example; npx react-native run-windows --no-packager --no-launch --arch x64 --logging --no-deploy
Expand All @@ -61,24 +70,48 @@ jobs:
- checkout
- run:
name: Install deps
command: cd src && yarn install && cd ../example && yarn install --force --frozen-lockfile
command: cd package && npm install && cd ../example && npm install
- run:
name: Install Pods
command: cd example && npx pod-install
- run:
name: Build the iOS example project
command: cd example/ios && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace example.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 11' -scheme example -parallelizeTargets -configuration Debug -derivedDataPath build -UseModernBuildSystem=YES

# To be uncommented as a part of https://github.com/react-native-community/react-native-slider/issues/34
# publish:
# executor: rn/linux_js
# steps:
# - attach_workspace:
# at: .
# - rn/yarn_install
# - run:
# name: Publish to NPM
# command: yarn ci:publish
android-debug:
executor:
name: android/android-machine
resource-class: large
tag: 2021.10.1
working_directory: ~/project
steps:
- checkout:
path: ~/project
- run:
command: cd package && npm install
- run:
command: cd example && npm install
- run:
name: Assemble debug build
command: cd example/android && ./gradlew clean build

ios-debug:
macos:
xcode: 13.3.1
working_directory: /Users/distiller/project
steps:
- checkout:
path: ~/project
- run:
command: cd package && npm install
- run:
command: cd example && npm install
- run:
command: cd example/ios && pod install
- run:
name: Compile iOS app
command: |
cd example/ios && xcodebuild -workspace example.xcworkspace -configuration Debug -scheme example CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=NO
workflows:
slider-full-ci:
Expand All @@ -93,20 +126,9 @@ workflows:
- build_example_windows:
requires:
- verify
- rn/android_build:
name: build_android_debug
project_path: "example/android"
build_type: debug
- android-debug:
requires:
- verify
- build_example_ios:
- ios-debug:
requires:
- verify
# - publish:
# requires:
# - analyse
# - rn/android_test
# - rn/ios_build_and_test
# filters:
# branches:
# only: master
10 changes: 0 additions & 10 deletions .eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,14 @@ To use this library you need to ensure you are using the correct version of Reac

## Contributing

This project uses [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to handle its internal dependencies.
* Make sure to use `yarn` to install dependencies when implementing changes to this library.
The main package implementation is done in the `package/` directory.
So when implementing changes there, make sure your code passes ESLint and the tests. Run the following to verify:
```sh
yarn install
cd package/
npm run lint
npm run test
```
* Make sure your code passes Flow, ESLint and the tests. Run the following to verify:
```sh
yarn validate:flow
yarn validate:eslint --fix
yarn test:jest
```
or
```sh
yarn test
```
to run them all.

* Remember to cover your changes with tests if possible.

When [creating an issue](https://github.com/callstack/react-native-slider/issues/new/choose) please remember to specify the platform which the issue occurs on.
Expand All @@ -135,17 +127,14 @@ While developing, you can run the example app to test your changes.

### Setup

- Clone the repository
- Run `yarn` in the root directory to install dependencies, and again in `src` to create the dist build.
- (on iOS) Run `npx pod-install` from the `example` directory
- (on Windows) You need to manually link the Slider module to your project.

### Start the app
- Clone the repository
- Run `npm install` in the root directory to install dependencies.
- Run `npm run example-<platform>`, where platform can be: `ios`, `android`, `windows`

- Run `yarn run:android` to run on Android
- Run `yarn run:ios` to run on iOS
- Run `yarn run:web` to run on web
- Run `yarn run:windows` to run on Windows.
You can also do this manually by:
- Installing node modules for example app
- Installing pods for iOS app
- Running example app like always: `npx react-native run-<platform>`


## Maintainers
Expand Down
6 changes: 0 additions & 6 deletions babel.config.js

This file was deleted.

6 changes: 6 additions & 0 deletions example/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
2 changes: 2 additions & 0 deletions example/.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 example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
66 changes: 66 additions & 0 deletions example/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
emoji=true

exact_by_default=true

format.bracket_spacing=false

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.176.3
63 changes: 63 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof

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

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# 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
/ios/Pods/
/vendor/bundle/
7 changes: 7 additions & 0 deletions example/.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 example/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.5
1 change: 1 addition & 0 deletions example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions example/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.5'

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
Loading

0 comments on commit 559edef

Please sign in to comment.