@startupjs/cli 0.56.0-alpha.5 → 0.56.0-alpha.57
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 +20 -12
- package/commands/build.js +13 -0
- package/commands/index.js +7 -0
- package/commands/pm/init-pm.js +30 -0
- package/commands/pm/pr.js +12 -0
- package/commands/pm/task.js +12 -0
- package/commands/pm/utils.js +8 -0
- package/commands/postinstall.js +17 -0
- package/commands/start-production.js +21 -0
- package/index.js +23 -678
- package/package.json +9 -17
- package/corepack.sh +0 -52
- package/link/index.js +0 -9
- package/link/log.js +0 -33
- package/link/path.js +0 -61
- package/link/postLinkAndroid.js +0 -15
- package/link/postLinkIOS.js +0 -8
- package/link/pushNotificationsLinker/AndroidLinker.js +0 -144
- package/link/pushNotificationsLinker/IosLinker.js +0 -137
- package/link/pushNotificationsLinker/constants.js +0 -114
- package/link/pushNotificationsLinker/index.js +0 -37
- package/link/stylesLinker.js +0 -47
package/package.json
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs/cli",
|
|
3
|
-
"version": "0.56.0-alpha.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.56.0-alpha.57",
|
|
4
|
+
"description": "The command-line tool for StartupJS apps.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"publishConfig": {
|
|
8
9
|
"access": "public"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
12
|
+
"@startupjs/patches": "^0.56.0-alpha.13",
|
|
11
13
|
"@startupjs/pm": "^0.56.0-alpha.0",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"execa": "^
|
|
16
|
-
"glob": "^7.1.6",
|
|
17
|
-
"just-wait": "^1.0.11",
|
|
18
|
-
"lodash": "^4.17.20",
|
|
19
|
-
"nodemon": "2.0.22",
|
|
20
|
-
"rimraf": "^3.0.2",
|
|
21
|
-
"source-map-support": "^0.5.19",
|
|
22
|
-
"wait-on": "^5.2.1",
|
|
23
|
-
"webpack": "^5.60.0",
|
|
24
|
-
"webpack-cli": "^4.9.1",
|
|
25
|
-
"webpack-dev-server": "^4.4.0"
|
|
14
|
+
"chalk": "^5.3.0",
|
|
15
|
+
"commander": "^12.0.0",
|
|
16
|
+
"create-startupjs": "^0.56.0-alpha.57",
|
|
17
|
+
"execa": "^8.0.1"
|
|
26
18
|
},
|
|
27
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "25684cfb85781ecd2f262347baea88ce420272fe"
|
|
28
20
|
}
|
package/corepack.sh
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Fail script on first failed command
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
# function to compare version numbers
|
|
7
|
-
function version_greater_or_equal() {
|
|
8
|
-
[ "$1" == "`echo -e "$1\n$2" | sort -V | tail -n1`" ]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function main () {
|
|
12
|
-
# check if 'corepack' exists
|
|
13
|
-
if ! command -v corepack &> /dev/null
|
|
14
|
-
then
|
|
15
|
-
echo "corepack could not be found"
|
|
16
|
-
|
|
17
|
-
read -p "Do you want to install it? (Y/n) " answer
|
|
18
|
-
case ${answer:0:1} in
|
|
19
|
-
y|Y )
|
|
20
|
-
npm i -g corepack@latest
|
|
21
|
-
;;
|
|
22
|
-
* )
|
|
23
|
-
echo "Aborting the script as per your request."
|
|
24
|
-
exit 1
|
|
25
|
-
;;
|
|
26
|
-
esac
|
|
27
|
-
fi
|
|
28
|
-
|
|
29
|
-
# check if the version is >=0.20.0
|
|
30
|
-
version=$(corepack --version)
|
|
31
|
-
required_version="0.20.0"
|
|
32
|
-
|
|
33
|
-
if version_greater_or_equal $required_version $version; then
|
|
34
|
-
echo "corepack version is less than ${required_version}"
|
|
35
|
-
|
|
36
|
-
read -p "Would you like to update it now? (Y/n) " answer
|
|
37
|
-
case ${answer:0:1} in
|
|
38
|
-
y|Y )
|
|
39
|
-
npm i -g corepack@latest
|
|
40
|
-
;;
|
|
41
|
-
* )
|
|
42
|
-
echo "Aborting the script as per your request."
|
|
43
|
-
exit 1
|
|
44
|
-
;;
|
|
45
|
-
esac
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
# do 'corepack enable'
|
|
49
|
-
corepack enable
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
main "$@"; exit
|
package/link/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const { infon } = require('./log')
|
|
2
|
-
const postLinkAndroid = require('./postLinkAndroid')
|
|
3
|
-
const postLinkIOS = require('./postLinkIOS')
|
|
4
|
-
|
|
5
|
-
module.exports = function link () {
|
|
6
|
-
postLinkAndroid()
|
|
7
|
-
postLinkIOS()
|
|
8
|
-
infon('startupjs link is completed. Thank you for using startupjs!\n\n')
|
|
9
|
-
}
|
package/link/log.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const colors = {
|
|
2
|
-
HEADER: '\x1b[95m',
|
|
3
|
-
OKBLUE: '\x1b[94m',
|
|
4
|
-
OKGREEN: '\x1b[92m',
|
|
5
|
-
WARNING: '\x1b[93m',
|
|
6
|
-
FAIL: '\x1b[91m',
|
|
7
|
-
ENDC: '\x1b[0m',
|
|
8
|
-
BOLD: '\x1b[1m',
|
|
9
|
-
UNDERLINE: '\x1b[4m'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const log = (text) => process.stdout.write(text)
|
|
13
|
-
const logn = (text) => process.stdout.write(text ? text + '\n' : '\n')
|
|
14
|
-
const warn = (text) => process.stdout.write(`${colors.WARNING}${text}${colors.ENDC}`)
|
|
15
|
-
const warnn = (text) => warn(text ? text + '\n' : '\n')
|
|
16
|
-
const error = (text) => process.stdout.write(`${colors.FAIL}${text}${colors.ENDC}`)
|
|
17
|
-
const errorn = (text) => error(text ? text + '\n' : '\n')
|
|
18
|
-
const info = (text) => process.stdout.write(`${colors.OKGREEN}${text}${colors.ENDC}`)
|
|
19
|
-
const infon = (text) => info(text ? text + '\n' : '\n')
|
|
20
|
-
const debug = (text) => process.stdout.write(`${colors.OKBLUE}${text}${colors.ENDC}`)
|
|
21
|
-
const debugn = (text) => debug(text ? text + '\n' : '\n')
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
log,
|
|
25
|
-
logn,
|
|
26
|
-
warn,
|
|
27
|
-
warnn,
|
|
28
|
-
info,
|
|
29
|
-
infon,
|
|
30
|
-
debug,
|
|
31
|
-
debugn,
|
|
32
|
-
errorn
|
|
33
|
-
}
|
package/link/path.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const glob = require('glob')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const ignoreFolders = { ignore: ['node_modules/**', '**/build/**'] }
|
|
4
|
-
const styles = glob.sync('**/values/styles.xml', ignoreFolders)
|
|
5
|
-
const appJsonPath = glob.sync('**/app.json', ignoreFolders)[0]
|
|
6
|
-
if (!appJsonPath) {
|
|
7
|
-
throw new Error('Can\'t find app.json')
|
|
8
|
-
}
|
|
9
|
-
// TODO: some people get undefined when trying to find mainApplicationJava
|
|
10
|
-
// const mainApplicationJava = glob.sync(
|
|
11
|
-
// '**/MainApplication.java',
|
|
12
|
-
// ignoreFolders
|
|
13
|
-
// )[0]
|
|
14
|
-
|
|
15
|
-
// Android files
|
|
16
|
-
const mainActivityJava = glob.sync('**/MainActivity.java', ignoreFolders)[0]
|
|
17
|
-
|
|
18
|
-
const mainBuildGradleAndroid = glob.sync(
|
|
19
|
-
'**/android/build.gradle',
|
|
20
|
-
ignoreFolders
|
|
21
|
-
)[0]
|
|
22
|
-
const appBuildGradleAndroid = glob.sync(
|
|
23
|
-
'**/android/app/build.gradle',
|
|
24
|
-
ignoreFolders
|
|
25
|
-
)[0]
|
|
26
|
-
const androidManifestXML = glob.sync(
|
|
27
|
-
'**/main/AndroidManifest.xml',
|
|
28
|
-
ignoreFolders
|
|
29
|
-
)[0]
|
|
30
|
-
const APP_NAME = require(path.resolve(process.cwd(), appJsonPath)).name
|
|
31
|
-
const networkSecurityConfigFolder = 'android/app/src/main/res/xml'
|
|
32
|
-
const networkSecurityConfigRout = networkSecurityConfigFolder + '/network_security_config.xml'
|
|
33
|
-
const detoxTestFolder = `android/app/src/androidTest/java/com/${APP_NAME}`
|
|
34
|
-
const detoxTestRoute = detoxTestFolder + '/DetoxTest.java'
|
|
35
|
-
|
|
36
|
-
// iOS files
|
|
37
|
-
const appDelegateH = glob.sync('**/AppDelegate.h', ignoreFolders)[0]
|
|
38
|
-
const appDelegateM = glob.sync('**/AppDelegate.m', ignoreFolders)[0]
|
|
39
|
-
const podFilePath = glob.sync('**/Podfile', ignoreFolders)[0]
|
|
40
|
-
|
|
41
|
-
// exports
|
|
42
|
-
|
|
43
|
-
exports.mainActivityJava = mainActivityJava
|
|
44
|
-
// exports.mainApplicationJava = mainApplicationJava
|
|
45
|
-
// exports.rootGradle = mainApplicationJava
|
|
46
|
-
// .replace(/android\/app\/.*\.java/, 'android/build.gradle')
|
|
47
|
-
exports.styles = styles
|
|
48
|
-
|
|
49
|
-
exports.appDelegateH = appDelegateH
|
|
50
|
-
exports.appDelegateM = appDelegateM
|
|
51
|
-
exports.podFilePath = podFilePath
|
|
52
|
-
|
|
53
|
-
exports.networkSecurityConfigFolder = networkSecurityConfigFolder
|
|
54
|
-
exports.networkSecurityConfigRout = networkSecurityConfigRout
|
|
55
|
-
exports.detoxTestFolder = detoxTestFolder
|
|
56
|
-
exports.detoxTestRoute = detoxTestRoute
|
|
57
|
-
exports.mainBuildGradleAndroid = mainBuildGradleAndroid
|
|
58
|
-
exports.appBuildGradleAndroid = appBuildGradleAndroid
|
|
59
|
-
exports.androidManifestXML = androidManifestXML
|
|
60
|
-
|
|
61
|
-
exports.APP_NAME = APP_NAME
|
package/link/postLinkAndroid.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { infon, logn } = require('./log')
|
|
2
|
-
const StylesLinker = require('./stylesLinker')
|
|
3
|
-
const { pushNotificationsLinkerAndroid } = require('./pushNotificationsLinker')
|
|
4
|
-
// uncomment when the android in Detox will be implemented
|
|
5
|
-
// const DetoxLinker = require('./DetoxLinker')
|
|
6
|
-
|
|
7
|
-
module.exports = () => {
|
|
8
|
-
infon('\nRunning Android postlink script\n')
|
|
9
|
-
|
|
10
|
-
new StylesLinker().link()
|
|
11
|
-
|
|
12
|
-
logn()
|
|
13
|
-
pushNotificationsLinkerAndroid()
|
|
14
|
-
logn('\n')
|
|
15
|
-
}
|
package/link/postLinkIOS.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const { mainBuildGradleAndroid, appBuildGradleAndroid, androidManifestXML } = require('../path')
|
|
3
|
-
const { errorn, warnn, logn, infon, debugn } = require('../log')
|
|
4
|
-
const { permisionsString, aplicationBodyString, androidBuildGradleDeps, appGradleBuildHeader, appGradleBuildDeps } = require('./constants')
|
|
5
|
-
|
|
6
|
-
class AndroidLinker {
|
|
7
|
-
constructor () {
|
|
8
|
-
this.mainBuildGradleAndroid = mainBuildGradleAndroid
|
|
9
|
-
this.appBuildGradleAndroid = appBuildGradleAndroid
|
|
10
|
-
this.androidManifestXML = androidManifestXML
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
link () {
|
|
14
|
-
if (!this.checkRouts()) return
|
|
15
|
-
|
|
16
|
-
logn(' Linking AndroidManifest.xml')
|
|
17
|
-
this.linkAndroidManifestXML()
|
|
18
|
-
|
|
19
|
-
logn(' Linking build.gradle')
|
|
20
|
-
this.linkMainBuildGradle()
|
|
21
|
-
|
|
22
|
-
logn(' Linking app/build.gradle')
|
|
23
|
-
this.linkAppBuildGradleAndroid()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
linkMainBuildGradle () {
|
|
27
|
-
try {
|
|
28
|
-
let content = fs.readFileSync(this.mainBuildGradleAndroid, 'utf8')
|
|
29
|
-
content = this._linkMainBuildGradle(content)
|
|
30
|
-
fs.writeFileSync(this.mainBuildGradleAndroid, content)
|
|
31
|
-
infon(' build.gradle linked successfully!')
|
|
32
|
-
} catch (e) {
|
|
33
|
-
errorn('build.gradle was not linked. ' + e.message)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_linkMainBuildGradle (content) {
|
|
38
|
-
if (this._isLinkMainBuildGradle(content)) {
|
|
39
|
-
warnn(' build.gradle already linked')
|
|
40
|
-
return content
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const mainGradleDepsRegExp = /(dependencies \{)/
|
|
44
|
-
|
|
45
|
-
debugn(' Linking oneSignal files in build.gradle')
|
|
46
|
-
return content.replace(mainGradleDepsRegExp, `$1${androidBuildGradleDeps}`)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
linkAppBuildGradleAndroid () {
|
|
50
|
-
try {
|
|
51
|
-
let content = fs.readFileSync(this.appBuildGradleAndroid, 'utf8')
|
|
52
|
-
content = this._linkAppBuildGradleAndroid(content)
|
|
53
|
-
fs.writeFileSync(this.appBuildGradleAndroid, content)
|
|
54
|
-
infon(' app/build.gradle linked successfully!')
|
|
55
|
-
} catch (e) {
|
|
56
|
-
errorn('app/build.gradle was not linked. ' + e.message)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_linkAppBuildGradleAndroid (content) {
|
|
61
|
-
if (this._isLinkAppBuildGradleAndroid(content)) {
|
|
62
|
-
warnn(' app/build.gradle already linked')
|
|
63
|
-
return content
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const depsRegExp = /(dependencies.*{)/
|
|
67
|
-
|
|
68
|
-
debugn(' Linking files in app/build.gradle')
|
|
69
|
-
return appGradleBuildHeader + content.replace(depsRegExp, `$1${appGradleBuildDeps}`)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
linkAndroidManifestXML () {
|
|
73
|
-
try {
|
|
74
|
-
let content = fs.readFileSync(this.androidManifestXML, 'utf8')
|
|
75
|
-
content = this._linkAndroidManifestXML(content)
|
|
76
|
-
fs.writeFileSync(this.androidManifestXML, content)
|
|
77
|
-
infon(' AndroidManifestXML linked successfully!')
|
|
78
|
-
} catch (e) {
|
|
79
|
-
errorn('AndroidManifestXML was not linked. ' + e.message)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
_linkAndroidManifestXML (content) {
|
|
84
|
-
if (this._isLinkAndroidManifestXML(content)) {
|
|
85
|
-
warnn(' AndroidManifestXML already linked')
|
|
86
|
-
return content
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let changedContent = content
|
|
90
|
-
|
|
91
|
-
const manifestApplicationEndRegExp = /(<uses-permission android:name="android\.permission\.INTERNET" \/>)/
|
|
92
|
-
changedContent = changedContent.replace(manifestApplicationEndRegExp,
|
|
93
|
-
'$1' + permisionsString
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
const manifestApplicationRegExp = /(<application[\s\S]*?>)/
|
|
97
|
-
changedContent = changedContent.replace(manifestApplicationRegExp,
|
|
98
|
-
'$1' + aplicationBodyString
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
debugn(' Linking files in AndroidManifestXML')
|
|
102
|
-
return changedContent
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_isLinkMainBuildGradle (content) {
|
|
106
|
-
return /classpath\('com.google.gms:google-services/.test(content)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
_isLinkAppBuildGradleAndroid (content) {
|
|
110
|
-
return /apply plugin: 'com\.google\.gms\.google-services'/.test(content) ||
|
|
111
|
-
/implementation platform\('com\.google\.firebase:firebase-bom/.test(content) ||
|
|
112
|
-
/implementation 'com\.google\.firebase:firebase-analytics'/.test(content)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_isLinkAndroidManifestXML (content) {
|
|
116
|
-
return /android\.permission\.VIBRATE"/.test(content) ||
|
|
117
|
-
/android\.permission\.RECEIVE_BOOT_COMPLETED"/.test(content) ||
|
|
118
|
-
/RNPushNotificationListenerService/.test(content)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
checkRouts () {
|
|
122
|
-
if (!this.mainBuildGradleAndroid) {
|
|
123
|
-
errorn(
|
|
124
|
-
'build.gradle not found! Does the file exist in the correct folder?'
|
|
125
|
-
)
|
|
126
|
-
return false
|
|
127
|
-
}
|
|
128
|
-
if (!this.appBuildGradleAndroid) {
|
|
129
|
-
errorn(
|
|
130
|
-
'app/build.gradle not found! Does the file exist in the correct folder?'
|
|
131
|
-
)
|
|
132
|
-
return false
|
|
133
|
-
}
|
|
134
|
-
if (!this.androidManifestXML) {
|
|
135
|
-
errorn(
|
|
136
|
-
'main/AndroidManifest.xml not found! Does the file exist in the correct folder?'
|
|
137
|
-
)
|
|
138
|
-
return false
|
|
139
|
-
}
|
|
140
|
-
return true
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = AndroidLinker
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const { appDelegateH, appDelegateM, podFilePath } = require('../path')
|
|
3
|
-
const { errorn, warnn, logn, infon, debugn } = require('../log')
|
|
4
|
-
const { appDelegateHHeader, appDelegateHDeps, appDelegateMHeader, implementationBody, appDelegateMDeps, podFile } = require('./constants')
|
|
5
|
-
|
|
6
|
-
class IosLinker {
|
|
7
|
-
constructor () {
|
|
8
|
-
this.AppDelegateH = appDelegateH
|
|
9
|
-
this.AppDelegateM = appDelegateM
|
|
10
|
-
this.podfile = podFilePath
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
link () {
|
|
14
|
-
if (!this.checkRouts()) return
|
|
15
|
-
|
|
16
|
-
logn(' Linking AppDelegate.h')
|
|
17
|
-
this.linkAppDelegateH()
|
|
18
|
-
|
|
19
|
-
logn(' Linking AppDelegate.m')
|
|
20
|
-
this.linkAppDelegateM()
|
|
21
|
-
|
|
22
|
-
logn(' Linking Podfile')
|
|
23
|
-
this.linkPodfile()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
linkAppDelegateH () {
|
|
27
|
-
try {
|
|
28
|
-
let content = fs.readFileSync(this.AppDelegateH, 'utf8')
|
|
29
|
-
content = this._linkAppDelegateH(content)
|
|
30
|
-
fs.writeFileSync(this.AppDelegateH, content)
|
|
31
|
-
infon(' AppDelegate.h linked successfully!')
|
|
32
|
-
} catch (e) {
|
|
33
|
-
errorn('AppDelegate.h was not linked. ' + e.message)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
linkAppDelegateM () {
|
|
38
|
-
try {
|
|
39
|
-
let content = fs.readFileSync(this.AppDelegateM, 'utf8')
|
|
40
|
-
content = this._linkAppDelegateM(content)
|
|
41
|
-
fs.writeFileSync(this.AppDelegateM, content)
|
|
42
|
-
infon(' AppDelegate.m linked successfully!')
|
|
43
|
-
} catch (e) {
|
|
44
|
-
errorn('AppDelegate.m was not linked. ' + e.message)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
linkPodfile () {
|
|
49
|
-
try {
|
|
50
|
-
let content = fs.readFileSync(this.podfile, 'utf8')
|
|
51
|
-
content = this._linkPodfile(content)
|
|
52
|
-
fs.writeFileSync(this.podfile, content)
|
|
53
|
-
infon(' Podfile linked successfully!')
|
|
54
|
-
} catch (e) {
|
|
55
|
-
errorn('Podfile was not linked. ' + e.message)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
_linkAppDelegateH (content) {
|
|
60
|
-
if (this._isLinkAppDelegateH(content)) {
|
|
61
|
-
warnn(' AppDelegate.h already linked')
|
|
62
|
-
return content
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const appDelegateHDepsRegExp = /@interface AppDelegate.*>/
|
|
66
|
-
|
|
67
|
-
debugn(' Linking push-notifications files in AppDelegate.h')
|
|
68
|
-
return appDelegateHHeader + content.replace(appDelegateHDepsRegExp, appDelegateHDeps)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_linkAppDelegateM (content) {
|
|
72
|
-
if (this._isLinkAppDelegateM(content)) {
|
|
73
|
-
warnn(' AppDelegate.m already linked')
|
|
74
|
-
return content
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const headerRegExp = /(#import <React\/RCTRootView\.h>)/
|
|
78
|
-
const implementationBodyEndRegExp = /(return YES;\s\S*?})/
|
|
79
|
-
|
|
80
|
-
debugn(' Linking push-notifications files in AppDelegate.m')
|
|
81
|
-
return content.replace(headerRegExp, `$1${appDelegateMHeader}`)
|
|
82
|
-
.replace(implementationBodyEndRegExp, `${implementationBody}$1${appDelegateMDeps}`)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_linkPodfile (content) {
|
|
86
|
-
if (this._isLinkPodfile(content)) {
|
|
87
|
-
warnn(' Podfile already linked')
|
|
88
|
-
return content
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const podfilePodsRegExp = /(platform :ios, '10.0')/
|
|
92
|
-
|
|
93
|
-
debugn(' Linking push-notifications files in Podfile')
|
|
94
|
-
return content.replace(podfilePodsRegExp, `$1${podFile}`)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
_isLinkAppDelegateH (content) {
|
|
98
|
-
return /#import <UserNotifications\/UNUserNotificationCenter\.h>/.test(content) ||
|
|
99
|
-
/UNUserNotificationCenterDelegate/.test(content)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
_isLinkAppDelegateM (content) {
|
|
103
|
-
return /#import <UserNotifications\/UserNotifications\.h>/.test(content) ||
|
|
104
|
-
/#import <RNCPushNotificationIOS\.h>/.test(content) ||
|
|
105
|
-
/UNUserNotificationCenter \*center = \[UNUserNotificationCenter currentNotificationCenter\]/.test(content) ||
|
|
106
|
-
/RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken/.test(content) ||
|
|
107
|
-
/RNCPushNotificationIOS didReceiveNotificationResponse/.test(content)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
_isLinkPodfile (content) {
|
|
111
|
-
return /pod 'Firebase\/Messaging'/.test(content)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
checkRouts () {
|
|
115
|
-
if (!this.AppDelegateH) {
|
|
116
|
-
errorn(
|
|
117
|
-
'AppDelegate.h not found! Does the file exist in the correct folder?'
|
|
118
|
-
)
|
|
119
|
-
return false
|
|
120
|
-
}
|
|
121
|
-
if (!this.AppDelegateM) {
|
|
122
|
-
errorn(
|
|
123
|
-
'AppDelegate.m not found! Does the file exist in the correct folder?'
|
|
124
|
-
)
|
|
125
|
-
return false
|
|
126
|
-
}
|
|
127
|
-
if (!this.podfile) {
|
|
128
|
-
errorn(
|
|
129
|
-
'PodFile not found! Does the file exist in the correct folder?'
|
|
130
|
-
)
|
|
131
|
-
return false
|
|
132
|
-
}
|
|
133
|
-
return true
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
module.exports = IosLinker
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// Android
|
|
2
|
-
|
|
3
|
-
// AnroidManifest.xml
|
|
4
|
-
const permisionsString = `
|
|
5
|
-
<uses-permission android:name="android.permission.VIBRATE" />
|
|
6
|
-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>`
|
|
7
|
-
|
|
8
|
-
const aplicationBodyString = `
|
|
9
|
-
<!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
|
|
10
|
-
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
|
|
11
|
-
android:value="false"/>
|
|
12
|
-
|
|
13
|
-
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
|
|
14
|
-
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
|
|
15
|
-
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
|
|
16
|
-
<intent-filter>
|
|
17
|
-
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
18
|
-
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
|
19
|
-
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
|
|
20
|
-
</intent-filter>
|
|
21
|
-
</receiver>
|
|
22
|
-
|
|
23
|
-
<service
|
|
24
|
-
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
|
|
25
|
-
android:exported="false" >
|
|
26
|
-
<intent-filter>
|
|
27
|
-
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
28
|
-
</intent-filter>
|
|
29
|
-
</service>`
|
|
30
|
-
|
|
31
|
-
// build.gradle
|
|
32
|
-
const androidBuildGradleDeps = `
|
|
33
|
-
classpath('com.google.gms:google-services:4.3.3')`
|
|
34
|
-
|
|
35
|
-
// app/build.gradle
|
|
36
|
-
const appGradleBuildHeader = `
|
|
37
|
-
apply plugin: 'com.google.gms.google-services'
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
const appGradleBuildDeps = `
|
|
41
|
-
implementation platform('com.google.firebase:firebase-bom:27.1.0')
|
|
42
|
-
implementation 'com.google.firebase:firebase-analytics:17.3.0'
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
// iOS
|
|
46
|
-
|
|
47
|
-
// AppDelegate.h
|
|
48
|
-
|
|
49
|
-
const appDelegateHHeader = '#import <UserNotifications/UNUserNotificationCenter.h>\n'
|
|
50
|
-
|
|
51
|
-
const appDelegateHDeps = '@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n'
|
|
52
|
-
|
|
53
|
-
// AppDelegate.m
|
|
54
|
-
|
|
55
|
-
const appDelegateMHeader = `
|
|
56
|
-
#import <UserNotifications/UserNotifications.h>
|
|
57
|
-
#import <RNCPushNotificationIOS.h>
|
|
58
|
-
@import Firebase;
|
|
59
|
-
`
|
|
60
|
-
|
|
61
|
-
const implementationBody = `
|
|
62
|
-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
63
|
-
center.delegate = self;
|
|
64
|
-
[FIRApp configure];
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
const appDelegateMDeps = `
|
|
68
|
-
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
|
|
69
|
-
{
|
|
70
|
-
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Required for the register event.
|
|
74
|
-
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
75
|
-
{
|
|
76
|
-
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
77
|
-
}
|
|
78
|
-
// Required for the notification event. You must call the completion handler after handling the remote notification.
|
|
79
|
-
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
|
|
80
|
-
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
|
81
|
-
{
|
|
82
|
-
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
|
|
83
|
-
}
|
|
84
|
-
// Required for the registrationError event.
|
|
85
|
-
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
86
|
-
{
|
|
87
|
-
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
|
|
88
|
-
}
|
|
89
|
-
// Required for localNotification event
|
|
90
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
91
|
-
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
92
|
-
withCompletionHandler:(void (^)(void))completionHandler
|
|
93
|
-
{
|
|
94
|
-
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
|
|
95
|
-
}
|
|
96
|
-
`
|
|
97
|
-
|
|
98
|
-
const podFile = `\n
|
|
99
|
-
pod 'Firebase/Messaging'
|
|
100
|
-
`
|
|
101
|
-
|
|
102
|
-
module.exports = {
|
|
103
|
-
permisionsString,
|
|
104
|
-
aplicationBodyString,
|
|
105
|
-
androidBuildGradleDeps,
|
|
106
|
-
appGradleBuildHeader,
|
|
107
|
-
appGradleBuildDeps,
|
|
108
|
-
appDelegateHHeader,
|
|
109
|
-
appDelegateHDeps,
|
|
110
|
-
implementationBody,
|
|
111
|
-
appDelegateMHeader,
|
|
112
|
-
appDelegateMDeps,
|
|
113
|
-
podFile
|
|
114
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const AdroidLinker = require('./AndroidLinker')
|
|
2
|
-
const IOSLinker = require('./IOSLinker')
|
|
3
|
-
const { infon } = require('../log')
|
|
4
|
-
|
|
5
|
-
function pushNotificationsLinkerAndroid () {
|
|
6
|
-
if (!isPushNotificationsPackage()) {
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
infon(' Linking Android Push-notifications')
|
|
10
|
-
|
|
11
|
-
infon('\nRunning Android postlink script\n')
|
|
12
|
-
new AdroidLinker().link()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function pushNotificationsLinkerIos () {
|
|
16
|
-
if (!isPushNotificationsPackage()) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
infon(' Linking iOS Push-notifications')
|
|
20
|
-
|
|
21
|
-
infon('\nRunning iOS OneSignal postlink script\n')
|
|
22
|
-
new IOSLinker().link()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function isPushNotificationsPackage () {
|
|
26
|
-
try {
|
|
27
|
-
const path = require.resolve('@startupjs/push-notifications')
|
|
28
|
-
return !!path
|
|
29
|
-
} catch (err) {
|
|
30
|
-
return false
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
pushNotificationsLinkerAndroid,
|
|
36
|
-
pushNotificationsLinkerIos
|
|
37
|
-
}
|