Skip to content

Commit

Permalink
chore: update expo, ts and emotion (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhw authored Jul 20, 2023
1 parent a316465 commit 757f33d
Show file tree
Hide file tree
Showing 40 changed files with 1,237 additions and 951 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.yarn
dist/
53 changes: 53 additions & 0 deletions check-matching-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import glob from 'glob';
import pkg from './package.json';

const packageGlobs = pkg.workspaces.packages;
console.log('packageGlobs', packageGlobs);

const packages = packageGlobs
.map((packageName) => {
return glob.sync(`./${packageName}/package.json`);
})
.flat();

console.log('checking the following locations ', packages);

type DepsComparison = Record<string, Record<string, string>>;

const depsLookup = packages.reduce((dependenciesMap, packagePath) => {
const json = require(packagePath);

const deps: [string, string][] = Object.entries(json.dependencies ?? {});

const devDeps: [string, string][] = Object.entries(json.devDependencies ?? {});

const currentDependencies = deps.concat(devDeps);

return currentDependencies.reduce((depsMapSoFar, [currentDependency, version]) => {
if (!depsMapSoFar[currentDependency]) {
depsMapSoFar[currentDependency] = {
[json.name]: version,
};
} else {
depsMapSoFar[currentDependency][json.name] = version;
}

return depsMapSoFar;
}, dependenciesMap);
}, {} as DepsComparison);

console.log('checking for mismatched versions of dependencies');

let sum = 0;

Object.entries(depsLookup).forEach(([dependency, versionsMap]) => {
const versionValues = Object.values(versionsMap);

if (versionValues.length > 1 && versionValues.some((v) => v !== versionValues[0])) {
console.log({ dependency, versionsMap });

sum++;
}
});

console.log(`found ${sum} mismatched versions`);
32 changes: 16 additions & 16 deletions examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"private": true,
"main": "index.js",
"scripts": {
Expand All @@ -17,36 +17,36 @@
"web": "expo start --web"
},
"dependencies": {
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/datetimepicker": "6.7.3",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-native-community/datetimepicker": "7.2.0",
"@react-native-community/slider": "4.4.2",
"@storybook/addon-actions": "^6.5.14",
"@storybook/addon-essentials": "^6.5.14",
"@storybook/addon-knobs": "^6.4.0",
"@storybook/addon-links": "^6.5.14",
"@storybook/addon-ondevice-actions": "^6.5.5-alpha.0",
"@storybook/addon-ondevice-backgrounds": "^6.5.5-alpha.0",
"@storybook/addon-ondevice-controls": "^6.5.5-alpha.0",
"@storybook/addon-ondevice-knobs": "^6.5.5-alpha.0",
"@storybook/addon-ondevice-notes": "^6.5.5-alpha.0",
"@storybook/addon-ondevice-actions": "^6.5.5-alpha.1",
"@storybook/addon-ondevice-backgrounds": "^6.5.5-alpha.1",
"@storybook/addon-ondevice-controls": "^6.5.5-alpha.1",
"@storybook/addon-ondevice-knobs": "^6.5.5-alpha.1",
"@storybook/addon-ondevice-notes": "^6.5.5-alpha.1",
"@storybook/addons": "^6.5.14",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/docs-tools": "^6.5.14",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.14",
"@storybook/react-native": "^6.5.5-alpha.0",
"@storybook/react-native-server": "^6.5.5-alpha.0",
"expo": "^48.0.4",
"@storybook/react-native": "^6.5.5-alpha.1",
"@storybook/react-native-server": "^6.5.5-alpha.1",
"expo": "^49.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.8",
"react-native-safe-area-context": "4.5.0",
"react-native-web": "~0.18.10"
"react-native": "0.72.3",
"react-native-safe-area-context": "4.6.3",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@types/react": "~18.0.27",
"@types/react": "~18.2.14",
"babel-plugin-react-docgen-typescript": "^1.5.1",
"typescript": "^4.8.4"
"typescript": "^5.1.3"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"npmClient": "yarn",
"useWorkspaces": true,
"registry": "https://registry.npmjs.org",
"version": "6.5.5-alpha.0"
"version": "6.5.5-alpha.1"
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@
"publish:alpha": "yarn lerna publish from-git --dist-tag alpha",
"publish:latest": "yarn lerna publish from-git --dist-tag latest",
"publish:next": "yarn lerna publish from-git --dist-tag next",
"test": "lerna run test"
"test": "lerna run test",
"check-mismatched-deps": "ts-node ./check-matching-deps.ts"
},
"devDependencies": {
"lerna": "^6.6.1",
"cross-env": "^7.0.3",
"eslint": "8.24.0",
"@react-native/eslint-config": "^0.72.1"
"@react-native/eslint-config": "^0.72.1",
"typescript": "^5.1.3"
},
"resolutions": {
"telejson": "^7.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/ondevice-actions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-actions",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"description": "Action Logger addon for react-native storybook",
"keywords": [
"storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/ondevice-backgrounds/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-backgrounds",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"description": "A react-native storybook addon to show different backgrounds for your preview",
"keywords": [
"addon",
Expand Down
5 changes: 3 additions & 2 deletions packages/ondevice-controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-controls",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"description": "Display storybook controls on your device.",
"keywords": [
"addon",
Expand Down Expand Up @@ -30,10 +30,11 @@
"copyimages": "cross-env-shell cp -r src/components/color-picker/resources dist/components/color-picker/resources"
},
"dependencies": {
"@emotion/native": "^10.0.14",
"@emotion/native": "^11.11.0",
"@storybook/addons": "^6.5.14",
"@storybook/client-logger": "^6.5.14",
"@storybook/core-events": "^6.5.14",
"@storybook/react-native-theming": "^6.5.5-alpha.1",
"core-js": "^3.0.1",
"deep-equal": "^1.0.1",
"prop-types": "^15.7.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/ondevice-controls/src/emotion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '@emotion/react';

import { Theme as StorybookTheme } from '@storybook/react-native-theming';

declare module '@emotion/react' {
export interface Theme extends StorybookTheme {}
}
6 changes: 3 additions & 3 deletions packages/ondevice-controls/src/types/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const TouchableContainer = styled.View(({ theme }) => ({
backgroundColor: theme.inputs.swatch.backgroundColor,
}));

const Touchable = styled.TouchableOpacity(({ theme, color }) => ({
const Touchable = styled.TouchableOpacity<{ color: string }>(({ theme, color }) => ({
width: '100%',
height: '100%',
borderRadius: theme.inputs.swatch.innerBorderRadius,
Expand All @@ -47,7 +47,7 @@ const WebInput = styled('input' as any)(({ theme }) => ({
backgroundColor: theme.inputs.swatch.backgroundColor,
}));

const ButtonTouchable = styled.TouchableOpacity(({ theme, primary }) => {
const ButtonTouchable = styled.TouchableOpacity<{ primary?: boolean }>(({ theme, primary }) => {
const buttonTheme = primary ? theme.button.primary : theme.button.secondary;
return {
backgroundColor: buttonTheme.backgroundColor,
Expand All @@ -61,7 +61,7 @@ const ButtonTouchable = styled.TouchableOpacity(({ theme, primary }) => {
};
});

const ButtonText = styled.Text(({ theme, primary }) => {
const ButtonText = styled.Text<{ primary?: boolean }>(({ theme, primary }) => {
const buttonTheme = primary ? theme.button.primary : theme.button.secondary;
return {
color: buttonTheme.textColor,
Expand Down
2 changes: 1 addition & 1 deletion packages/ondevice-controls/src/types/Number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { View } from 'react-native';
import { inputStyle } from './common';
import { useResyncValue } from './useResyncValue';

const Input = styled.TextInput(({ theme, showError }) => {
const Input = styled.TextInput<{ showError: boolean }>(({ theme, showError }) => {
const style = inputStyle(theme);
return {
...style,
Expand Down
4 changes: 3 additions & 1 deletion packages/ondevice-controls/src/types/common.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Theme } from '@storybook/react-native-theming';
import { Platform } from 'react-native';

export function inputStyle(theme: any, isTextInput = true) {
// TODO fix this any
export function inputStyle(theme: Theme, isTextInput = true): any {
return {
backgroundColor: theme.inputs.text.backgroundColor,
borderWidth: theme.inputs.text.borderWidth,
Expand Down
75 changes: 0 additions & 75 deletions packages/ondevice-controls/src/typings.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ondevice-controls/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "dist/",
"paths": {
"@emotion/native": ["src/typings.d.ts"]
"@emotion/react": ["src/emotion.d.ts"]
},
"rootDir": "./src"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/ondevice-knobs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-knobs",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"description": "Display storybook story knobs on your deviced.",
"keywords": [
"addon",
Expand Down Expand Up @@ -30,7 +30,7 @@
"dev": "tsc --watch"
},
"dependencies": {
"@emotion/native": "^10.0.14",
"@emotion/native": "^11.11.0",
"@storybook/addons": "^6.5.14",
"@storybook/core-events": "^6.5.14",
"core-js": "^3.0.1",
Expand All @@ -41,7 +41,7 @@
"tinycolor2": "^1.4.1"
},
"devDependencies": {
"@storybook/addon-knobs": "^6"
"@storybook/addon-knobs": "^6.4.0"
},
"peerDependencies": {
"@react-native-community/datetimepicker": "*",
Expand Down
6 changes: 3 additions & 3 deletions packages/ondevice-notes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-ondevice-notes",
"version": "6.5.5-alpha.0",
"version": "6.5.5-alpha.1",
"description": "Write notes for your react-native Storybook stories.",
"keywords": [
"addon",
Expand Down Expand Up @@ -29,14 +29,14 @@
"dev": "tsc --watch"
},
"dependencies": {
"@emotion/core": "^10.0.20",
"@emotion/react": "^11.11.1",
"@storybook/addons": "^6.5.14",
"@storybook/api": "^6.5.14",
"@storybook/client-api": "^6.5.14",
"@storybook/client-logger": "^6.5.14",
"@storybook/core-events": "^6.5.14",
"@storybook/react-native-theming": "^6.5.5-alpha.1",
"core-js": "^3.0.1",
"emotion-theming": "^10.0.19",
"prop-types": "^15.7.2",
"simple-markdown": "^0.7.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/ondevice-notes/src/components/Markdown/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* mostly based on code from https://github.com/CharlesMangwa/react-native-simple-markdown
*/
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import { useMemo } from 'react';
import { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native/types';

Expand All @@ -10,7 +10,7 @@ interface Styles {
}

export const useThemedStyles = (): Styles => {
const theme = useTheme<any>();
const theme = useTheme();

const styles: Styles = useMemo(
() => ({
Expand Down
7 changes: 7 additions & 0 deletions packages/ondevice-notes/src/emotion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '@emotion/react';

import { Theme as StorybookTheme } from '@storybook/react-native-theming';

declare module '@emotion/react' {
export interface Theme extends StorybookTheme {}
}
Loading

0 comments on commit 757f33d

Please sign in to comment.