Skip to content

Commit

Permalink
Getting monorepo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaycumber committed Jan 28, 2021
1 parent 2b6d8f5 commit 4bde6ca
Show file tree
Hide file tree
Showing 48 changed files with 13,834 additions and 1,171 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
42 changes: 22 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#
.DS_Store

# XDE
.expo/

# VSCode
.vscode/
jsconfig.json

# Xcode
#
build/
Expand All @@ -22,42 +29,37 @@ DerivedData
*.xcuserstate
project.xcworkspace

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

# Cocoapods
#
example/ios/Pods

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

# BUCK
buck-out/
\.buckd/
*.keystore
android/app/libs
android/keystores/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
# Expo
.expo/*

# Bundle artifacts
*.jsbundle
# generated by bob
lib/

# CocoaPods
/ios/Pods/

# Expo
.expo/*
web-build/
**/web-build
**/.expo
15 changes: 0 additions & 15 deletions App.tsx

This file was deleted.

Empty file removed Web.tsx
Empty file.
7 changes: 0 additions & 7 deletions app.json

This file was deleted.

8 changes: 2 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin']
};
module.exports = {
presets: ["module:metro-react-native-babel-preset"],
};
25 changes: 25 additions & 0 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "redrip-example",
"displayName": "BobMonorepo Example",
"expo": {
"name": "redrip-example",
"slug": "redrip-example",
"description": "Example app for redrip",
"privacy": "public",
"version": "1.0.0",
"platforms": [
"ios",
"android",
"web"
],
"ios": {
"supportsTablet": true
},
"assetBundlePatterns": [
"**/*"
],
"experiments": {
"turboModules": true
}
}
}
7 changes: 7 additions & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin']
};
};
8 changes: 8 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { registerRootComponent } from "expo";

import App from "./src/App";

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
92 changes: 92 additions & 0 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const escape = require("escape-string-regexp");
const fs = require("fs");
const blacklist = require("metro-config/src/defaults/blacklist");
const path = require("path");

const root = path.resolve(__dirname, "..");
const packages = path.resolve(root, "packages");

// List all packages under `packages/`
const workspaces = fs
.readdirSync(packages)
.map((p) => path.join(packages, p))
.filter(
(p) =>
fs.statSync(p).isDirectory() &&
fs.existsSync(path.join(p, "package.json"))
);

// Get the list of dependencies for all packages in the monorepo
const modules = ["@expo/vector-icons"]
.concat(
...workspaces.map((it) => {
const pak = JSON.parse(
fs.readFileSync(path.join(it, "package.json"), "utf8")
);

// We need to make sure that only one version is loaded for peerDependencies
// So we blacklist them at the root, and alias them to the versions in example's node_modules
return pak.peerDependencies ? Object.keys(pak.peerDependencies) : [];
})
)
.sort()
.filter(
(m, i, self) =>
// Remove duplicates and package names of the packages in the monorepo
self.lastIndexOf(m) === i && !m.startsWith("@redrip/")
);

module.exports = {
projectRoot: __dirname,

// We need to watch the root of the monorepo
// This lets Metro find the monorepo packages automatically using haste
// This also lets us import modules from monorepo root
watchFolders: [root],

resolver: {
// We need to blacklist the peerDependencies we've collected in packages' node_modules
blacklistRE: blacklist(
[].concat(
...workspaces.map((it) =>
modules.map(
(m) =>
new RegExp(`^${escape(path.join(it, "node_modules", m))}\\/.*$`)
)
)
)
),

// When we import a package from the monorepo, metro won't be able to find their deps
// We need to specify them in `extraNodeModules` to tell metro where to find them
extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(root, "node_modules", name);
return acc;
}, {}),
},

server: {
enhanceMiddleware: (middleware) => {
return (req, res, next) => {
// When an asset is imported outside the project root, it has wrong path on Android
// So we fix the path to correct one
if (/\/packages\/.+\.png\?.+$/.test(req.url)) {
req.url = `/assets/../${req.url}`;
}

return middleware(req, res, next);
};
},
},

transformer: {
getTransformOptions: () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
40 changes: 40 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "redrip-example",
"description": "Example app for redrip",
"version": "0.0.1",
"private": true,
"main": "index",
"scripts": {
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"start": "expo start",
"test": "jest"
},
"dependencies": {
"@react-spring/native": "^9.0.0-rc.3",
"expo": "^40.0.0-beta.5",
"expo-splash-screen": "~0.8.1",
"expo-status-bar": "~1.0.3",
"framer-motion": "^3.2.1",
"lodash.set": "^4.3.2",
"react": "~16.13.1",
"react-dom": "^16.13.1",
"react-native": "0.63.4",
"react-native-gesture-handler": "~1.8.0",
"react-native-reanimated": "2.0.0-rc.0",
"react-native-unimodules": "~0.12.0",
"react-native-web": "~0.14.9",
"react-navigation-stack": "^2.8.4",
"react-spring": "^8.0.27"
},
"devDependencies": {
"@babel/core": "~7.12.10",
"@babel/runtime": "^7.9.6",
"@types/lodash.set": "^4.3.6",
"babel-loader": "^8.2.2",
"babel-plugin-module-resolver": "^4.0.0",
"babel-preset-expo": "8.3.0",
"expo-cli": "^4.0.13"
}
}
3 changes: 1 addition & 2 deletions Drip.Presence.tsx → example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { AnimatePresence } from 'framer-motion'
import React, { useReducer, useState } from 'react'
import { StyleSheet, Pressable } from 'react-native'
import * as Redrip from './src/components'
import { View } from 'redrip'

const { View } = Redrip

function Shape() {
return (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Drip.Color.tsx → example/src/Drip.Color.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useReducer, useState } from 'react'
import { Button, StyleSheet } from 'react-native'
import { View } from './src/components'
import { View } from 'redrip'

function AnimatedCircle() {
const colors = ['#41b87a', '#533592']
Expand Down
54 changes: 54 additions & 0 deletions example/src/Drip.Presence.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// import { AnimatePresence } from 'framer-motion'
import React, { useReducer, useState } from 'react'
import { StyleSheet, Pressable } from 'react-native'
// import * as Redrip from 'redrip'

// const { View } = Redrip

// function Shape() {
// return (
// <View
// from={{
// opacity: 0,
// scale: 0.9,
// }}
// animate={{
// opacity: 1,
// scale: 1,
// }}
// exit={{
// opacity: 0,
// scale: 0.9,
// }}
// style={styles.shape}
// />
// )
// }

export default function Presence() {
const [visible, toggle] = useReducer((s) => !s, true)

return (
<Pressable onPress={toggle} style={styles.container}>
{/* <AnimatePresence>{visible && <Shape />}</AnimatePresence> */}
</Pressable>
)
}

const styles = StyleSheet.create({
shape: {
justifyContent: 'center',
height: 250,
width: 250,
borderRadius: 25,
marginRight: 10,
backgroundColor: 'white',
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
backgroundColor: '#9c1aff',
},
})
2 changes: 1 addition & 1 deletion Drip.Repeat.tsx → example/src/Drip.Repeat.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { StyleSheet } from 'react-native'
import * as Redrip from './src/components'
import * as Redrip from 'redrip'

const { View } = Redrip

Expand Down
Loading

0 comments on commit 4bde6ca

Please sign in to comment.