onesignal-expo-plugin 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  <h1 align="center">Welcome to onesignal-expo-plugin 👋</h1>
2
2
  <p>
3
- <img alt="Version" src="https://img.shields.io/badge/version-1.0.1-blue.svg?cacheSeconds=2592000" />
3
+ <a href="https://www.npmjs.com/package/onesignal-expo-plugin" target="_blank">
4
+ <img alt="Version" src="https://img.shields.io/npm/v/onesignal-expo-plugin.svg">
5
+ </a>
4
6
  <a href="https://github.com/OneSignal/onesignal-expo-plugin#readme" target="_blank">
5
7
  <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
6
8
  </a>
@@ -41,7 +43,7 @@ yarn add react-native-onesignal
41
43
 
42
44
  ## Configuration in app.json / app.config.js
43
45
  ### Plugin
44
- Add the plugin to the [plugin array](https://docs.expo.dev/versions/latest/config/app/):
46
+ Add the plugin to the **front** of the [plugin array](https://docs.expo.dev/versions/latest/config/app/). It should be added automatically if you ran `expo install`. Just make sure it is the first plugin in the array and to configure any desired plugin props:
45
47
 
46
48
  **app.json**
47
49
  ```json
@@ -174,5 +176,5 @@ Give a ⭐️ if this project helped you!
174
176
 
175
177
  ## 📝 License
176
178
 
177
- Copyright © 2021 [OneSignal](https://github.com/OneSignal).<br />
179
+ Copyright © 2022 [OneSignal](https://github.com/OneSignal).<br />
178
180
  This project is [MIT](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/LICENSE) licensed.
@@ -5,25 +5,9 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.withOneSignalAndroid = void 0;
8
- const config_plugins_1 = require("@expo/config-plugins");
9
- const androidConstants_1 = require("../support/androidConstants");
10
8
  const OneSignalLog_1 = require("../support/OneSignalLog");
11
- const withGradleBuildConfig = (config) => {
12
- return (0, config_plugins_1.withAppBuildGradle)(config, (newConfig) => {
13
- let { contents } = newConfig.modResults;
14
- // make sure we haven't previously added dependencies
15
- if (!contents.includes(androidConstants_1.ONESIGNAL_GRADLE)) {
16
- contents = `${androidConstants_1.ONESIGNAL_GRADLE}\n${contents}`;
17
- }
18
- else {
19
- OneSignalLog_1.OneSignalLog.log("OneSignal dependencies already added to build.gradle. Skipping...");
20
- }
21
- newConfig.modResults.contents = contents;
22
- return newConfig;
23
- });
24
- };
25
9
  const withOneSignalAndroid = (config, props) => {
26
- withGradleBuildConfig(config, props);
10
+ OneSignalLog_1.OneSignalLog.log("No specific actions required for OneSignal on Android...");
27
11
  return config;
28
12
  };
29
13
  exports.withOneSignalAndroid = withOneSignalAndroid;
@@ -103,7 +103,13 @@ const withOneSignalNSE = (config, onesignalProps) => {
103
103
  mode: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.mode,
104
104
  iPhoneDeploymentTarget: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.iPhoneDeploymentTarget
105
105
  };
106
- xcodeProjectAddNse(props.modRequest.projectName || "", options, "node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/");
106
+ // support for monorepos where node_modules can be up to 5 parents
107
+ // above the project directory.
108
+ let dir = "node_modules";
109
+ for (let x = 0; x < 5 && !FileManager_1.FileManager.dirExists(dir); x++) {
110
+ dir = "../" + dir;
111
+ }
112
+ xcodeProjectAddNse(props.modRequest.projectName || "", options, dir + "/onesignal-expo-plugin/build/support/serviceExtensionFiles/");
107
113
  return props;
108
114
  });
109
115
  };
@@ -54,5 +54,8 @@ class FileManager {
54
54
  const fileContents = await FileManager.readFile(path1);
55
55
  await FileManager.writeFile(path2, fileContents);
56
56
  }
57
+ static dirExists(path) {
58
+ return fs.existsSync(path);
59
+ }
57
60
  }
58
61
  exports.FileManager = FileManager;
@@ -3,32 +3,15 @@
3
3
  * @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
4
4
  */
5
5
 
6
- import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';
7
- import { ONESIGNAL_GRADLE } from '../support/androidConstants';
6
+ import { ConfigPlugin } from '@expo/config-plugins';
8
7
  import { OneSignalLog } from '../support/OneSignalLog';
9
8
  import { OneSignalPluginProps } from '../types/types';
10
9
 
11
- const withGradleBuildConfig: ConfigPlugin<OneSignalPluginProps> = (config) => {
12
- return withAppBuildGradle(config, (newConfig) => {
13
- let { contents } = newConfig.modResults;
14
-
15
- // make sure we haven't previously added dependencies
16
- if (!contents.includes(ONESIGNAL_GRADLE)) {
17
- contents = `${ONESIGNAL_GRADLE}\n${contents}`;
18
- } else {
19
- OneSignalLog.log("OneSignal dependencies already added to build.gradle. Skipping...");
20
- }
21
-
22
- newConfig.modResults.contents = contents;
23
- return newConfig;
24
- });
25
- };
26
-
27
10
  export const withOneSignalAndroid: ConfigPlugin<OneSignalPluginProps> = (
28
11
  config,
29
12
  props,
30
13
  ) => {
31
- withGradleBuildConfig(config, props);
14
+ OneSignalLog.log("No specific actions required for OneSignal on Android...");
32
15
 
33
16
  return config;
34
17
  };
@@ -105,10 +105,17 @@ const withOneSignalNSE: ConfigPlugin<OneSignalPluginProps> = (config, onesignalP
105
105
  iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget
106
106
  };
107
107
 
108
+ // support for monorepos where node_modules can be up to 5 parents
109
+ // above the project directory.
110
+ let dir = "node_modules"
111
+ for(let x=0; x < 5 && !FileManager.dirExists(dir); x++) {
112
+ dir = "../" + dir
113
+ }
114
+
108
115
  xcodeProjectAddNse(
109
116
  props.modRequest.projectName || "",
110
117
  options,
111
- "node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/"
118
+ dir + "/onesignal-expo-plugin/build/support/serviceExtensionFiles/"
112
119
  );
113
120
 
114
121
  return props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onesignal-expo-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.",
5
5
  "main": "./app.plugin.js",
6
6
  "scripts": {
@@ -35,4 +35,8 @@ export class FileManager {
35
35
  const fileContents = await FileManager.readFile(path1);
36
36
  await FileManager.writeFile(path2, fileContents);
37
37
  }
38
+
39
+ static dirExists(path: string): boolean {
40
+ return fs.existsSync(path)
41
+ }
38
42
  }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ONESIGNAL_GRADLE = void 0;
4
- exports.ONESIGNAL_GRADLE = `buildscript {
5
- repositories {
6
- gradlePluginPortal()
7
- }
8
- dependencies {
9
- classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
10
- }
11
- }
12
-
13
- apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'`;
@@ -1,11 +0,0 @@
1
- export const ONESIGNAL_GRADLE =
2
- `buildscript {
3
- repositories {
4
- gradlePluginPortal()
5
- }
6
- dependencies {
7
- classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
8
- }
9
- }
10
-
11
- apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'`;