From caf8245dbece3320020bcd672b2a7ef7dc0e3aa6 Mon Sep 17 00:00:00 2001 From: Ryan Iguchi Date: Fri, 22 Nov 2024 14:25:40 +0100 Subject: [PATCH 1/2] adding plugin --- app.plugin.js | 12 +----------- example/app.json | 3 ++- example/package-lock.json | 13 ++++++++++++- example/package.json | 3 ++- .../src/index.ts | 0 plugin/tsconfig.json | 9 +++++++++ tsconfig.json | 2 +- 7 files changed, 27 insertions(+), 15 deletions(-) rename config-plugin/withMotionActivityPermissions.ts => plugin/src/index.ts (100%) create mode 100644 plugin/tsconfig.json diff --git a/app.plugin.js b/app.plugin.js index c2c82a8..7066fa2 100644 --- a/app.plugin.js +++ b/app.plugin.js @@ -1,11 +1 @@ -const { createRunOncePlugin } = require("expo/config-plugins"); - -const withMotionActivityPermissions = - require("./config-plugin/withMotionActivityPermissions").default; -const pkg = require("./package.json"); - -module.exports = createRunOncePlugin( - withMotionActivityPermissions, - pkg.name, - pkg.version, -); +module.exports = require("./plugin/build"); diff --git a/example/app.json b/example/app.json index dd9133c..2213655 100644 --- a/example/app.json +++ b/example/app.json @@ -27,6 +27,7 @@ }, "web": { "favicon": "./assets/favicon.png" - } + }, + "plugins": ["../app.plugin.js"] } } diff --git a/example/package-lock.json b/example/package-lock.json index 054b7f1..d28bae8 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -10,7 +10,8 @@ "dependencies": { "expo": "~51.0.28", "react": "18.2.0", - "react-native": "0.74.5" + "react-native": "0.74.5", + "react-native-motion-activity-tracker": "^0.1.3" }, "devDependencies": { "@babel/core": "^7.20.0", @@ -12205,6 +12206,16 @@ } } }, + "node_modules/react-native-motion-activity-tracker": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/react-native-motion-activity-tracker/-/react-native-motion-activity-tracker-0.1.3.tgz", + "integrity": "sha512-3UasOiI1fNGUcYQEByQd4EJ18+QZGoIuSZLc5IPOuJnsAeXc73EiMHeUOl8dbsyxkrqzesP0GM/ZLZjp6z4E4g==", + "peerDependencies": { + "expo": "*", + "react": "*", + "react-native": "*" + } + }, "node_modules/react-native/node_modules/@jest/types": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", diff --git a/example/package.json b/example/package.json index 26fe9d4..86e3efd 100644 --- a/example/package.json +++ b/example/package.json @@ -11,7 +11,8 @@ "dependencies": { "expo": "~51.0.28", "react": "18.2.0", - "react-native": "0.74.5" + "react-native": "0.74.5", + "react-native-motion-activity-tracker": "^0.1.3" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/config-plugin/withMotionActivityPermissions.ts b/plugin/src/index.ts similarity index 100% rename from config-plugin/withMotionActivityPermissions.ts rename to plugin/src/index.ts diff --git a/plugin/tsconfig.json b/plugin/tsconfig.json new file mode 100644 index 0000000..354bddb --- /dev/null +++ b/plugin/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "expo-module-scripts/tsconfig.plugin", + "compilerOptions": { + "outDir": "build", + "rootDir": "src" + }, + "include": ["./src"], + "exclude": ["**/__mocks__/*", "**/__tests__/*"] +} diff --git a/tsconfig.json b/tsconfig.json index e267900..a24ec0f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,6 @@ "compilerOptions": { "outDir": "./build" }, - "include": ["./src", "./tests"], + "include": ["./src"], "exclude": ["**/__mocks__/*", "**/__tests__/*"] } From 2a061e0200024251b3a74185a5dad1318b80fe2c Mon Sep 17 00:00:00 2001 From: revan Date: Fri, 22 Nov 2024 14:34:24 +0100 Subject: [PATCH 2/2] fixed test for the plugin --- tests/withMotionActivityPermissions.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/withMotionActivityPermissions.test.ts b/tests/withMotionActivityPermissions.test.ts index e6bf495..12136b9 100644 --- a/tests/withMotionActivityPermissions.test.ts +++ b/tests/withMotionActivityPermissions.test.ts @@ -1,7 +1,7 @@ import { withInfoPlist, withAndroidManifest } from "@expo/config-plugins"; import type { ExpoConfig } from "@expo/config-types"; -import withMotionActivityPermissions from "../config-plugin/withMotionActivityPermissions"; +import withMotionActivityPermissions from "../plugin/src/index"; interface ExpoConfigWithModResults extends ExpoConfig { modResults?: {