react-native-update-cli 1.20.0 → 1.20.6

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.
@@ -0,0 +1,216 @@
1
+ // From https://github.com/openstf/adbkit-apkreader
2
+ const BinaryXmlParser = require('./binary')
3
+
4
+ const INTENT_MAIN = 'android.intent.action.MAIN'
5
+ const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER'
6
+
7
+ class ManifestParser {
8
+ constructor (buffer, options = {}) {
9
+ this.buffer = buffer
10
+ this.xmlParser = new BinaryXmlParser(this.buffer, options)
11
+ }
12
+
13
+ collapseAttributes (element) {
14
+ const collapsed = Object.create(null)
15
+ for (let attr of Array.from(element.attributes)) {
16
+ collapsed[attr.name] = attr.typedValue.value
17
+ }
18
+ return collapsed
19
+ }
20
+
21
+ parseIntents (element, target) {
22
+ target.intentFilters = []
23
+ target.metaData = []
24
+
25
+ return element.childNodes.forEach(element => {
26
+ switch (element.nodeName) {
27
+ case 'intent-filter': {
28
+ const intentFilter = this.collapseAttributes(element)
29
+
30
+ intentFilter.actions = []
31
+ intentFilter.categories = []
32
+ intentFilter.data = []
33
+
34
+ element.childNodes.forEach(element => {
35
+ switch (element.nodeName) {
36
+ case 'action':
37
+ intentFilter.actions.push(this.collapseAttributes(element))
38
+ break
39
+ case 'category':
40
+ intentFilter.categories.push(this.collapseAttributes(element))
41
+ break
42
+ case 'data':
43
+ intentFilter.data.push(this.collapseAttributes(element))
44
+ break
45
+ }
46
+ })
47
+
48
+ target.intentFilters.push(intentFilter)
49
+ break
50
+ }
51
+ case 'meta-data':
52
+ target.metaData.push(this.collapseAttributes(element))
53
+ break
54
+ }
55
+ })
56
+ }
57
+
58
+ parseApplication (element) {
59
+ const app = this.collapseAttributes(element)
60
+
61
+ app.activities = []
62
+ app.activityAliases = []
63
+ app.launcherActivities = []
64
+ app.services = []
65
+ app.receivers = []
66
+ app.providers = []
67
+ app.usesLibraries = []
68
+ app.metaData = []
69
+
70
+ element.childNodes.forEach(element => {
71
+ switch (element.nodeName) {
72
+ case 'activity': {
73
+ const activity = this.collapseAttributes(element)
74
+ this.parseIntents(element, activity)
75
+ app.activities.push(activity)
76
+ if (this.isLauncherActivity(activity)) {
77
+ app.launcherActivities.push(activity)
78
+ }
79
+ break
80
+ }
81
+ case 'activity-alias': {
82
+ const activityAlias = this.collapseAttributes(element)
83
+ this.parseIntents(element, activityAlias)
84
+ app.activityAliases.push(activityAlias)
85
+ if (this.isLauncherActivity(activityAlias)) {
86
+ app.launcherActivities.push(activityAlias)
87
+ }
88
+ break
89
+ }
90
+ case 'service': {
91
+ const service = this.collapseAttributes(element)
92
+ this.parseIntents(element, service)
93
+ app.services.push(service)
94
+ break
95
+ }
96
+ case 'receiver': {
97
+ const receiver = this.collapseAttributes(element)
98
+ this.parseIntents(element, receiver)
99
+ app.receivers.push(receiver)
100
+ break
101
+ }
102
+ case 'provider': {
103
+ const provider = this.collapseAttributes(element)
104
+
105
+ provider.grantUriPermissions = []
106
+ provider.metaData = []
107
+ provider.pathPermissions = []
108
+
109
+ element.childNodes.forEach(element => {
110
+ switch (element.nodeName) {
111
+ case 'grant-uri-permission':
112
+ provider.grantUriPermissions.push(this.collapseAttributes(element))
113
+ break
114
+ case 'meta-data':
115
+ provider.metaData.push(this.collapseAttributes(element))
116
+ break
117
+ case 'path-permission':
118
+ provider.pathPermissions.push(this.collapseAttributes(element))
119
+ break
120
+ }
121
+ })
122
+
123
+ app.providers.push(provider)
124
+ break
125
+ }
126
+ case 'uses-library':
127
+ app.usesLibraries.push(this.collapseAttributes(element))
128
+ break
129
+ case 'meta-data':
130
+ app.metaData.push(this.collapseAttributes(element))
131
+ break
132
+ }
133
+ })
134
+
135
+ return app
136
+ }
137
+
138
+ isLauncherActivity (activity) {
139
+ return activity.intentFilters.some(function (filter) {
140
+ const hasMain = filter.actions.some(action => action.name === INTENT_MAIN)
141
+ if (!hasMain) {
142
+ return false
143
+ }
144
+ return filter.categories.some(category => category.name === CATEGORY_LAUNCHER)
145
+ })
146
+ }
147
+
148
+ parse () {
149
+ const document = this.xmlParser.parse()
150
+ const manifest = this.collapseAttributes(document)
151
+
152
+ manifest.usesPermissions = []
153
+ manifest.usesPermissionsSDK23 = []
154
+ manifest.permissions = []
155
+ manifest.permissionTrees = []
156
+ manifest.permissionGroups = []
157
+ manifest.instrumentation = null
158
+ manifest.usesSdk = null
159
+ manifest.usesConfiguration = null
160
+ manifest.usesFeatures = []
161
+ manifest.supportsScreens = null
162
+ manifest.compatibleScreens = []
163
+ manifest.supportsGlTextures = []
164
+ manifest.application = Object.create(null)
165
+
166
+ document.childNodes.forEach(element => {
167
+ switch (element.nodeName) {
168
+ case 'uses-permission':
169
+ manifest.usesPermissions.push(this.collapseAttributes(element))
170
+ break
171
+ case 'uses-permission-sdk-23':
172
+ manifest.usesPermissionsSDK23.push(this.collapseAttributes(element))
173
+ break
174
+ case 'permission':
175
+ manifest.permissions.push(this.collapseAttributes(element))
176
+ break
177
+ case 'permission-tree':
178
+ manifest.permissionTrees.push(this.collapseAttributes(element))
179
+ break
180
+ case 'permission-group':
181
+ manifest.permissionGroups.push(this.collapseAttributes(element))
182
+ break
183
+ case 'instrumentation':
184
+ manifest.instrumentation = this.collapseAttributes(element)
185
+ break
186
+ case 'uses-sdk':
187
+ manifest.usesSdk = this.collapseAttributes(element)
188
+ break
189
+ case 'uses-configuration':
190
+ manifest.usesConfiguration = this.collapseAttributes(element)
191
+ break
192
+ case 'uses-feature':
193
+ manifest.usesFeatures.push(this.collapseAttributes(element))
194
+ break
195
+ case 'supports-screens':
196
+ manifest.supportsScreens = this.collapseAttributes(element)
197
+ break
198
+ case 'compatible-screens':
199
+ element.childNodes.forEach(screen => {
200
+ return manifest.compatibleScreens.push(this.collapseAttributes(screen))
201
+ })
202
+ break
203
+ case 'supports-gl-texture':
204
+ manifest.supportsGlTextures.push(this.collapseAttributes(element))
205
+ break
206
+ case 'application':
207
+ manifest.application = this.parseApplication(element)
208
+ break
209
+ }
210
+ })
211
+
212
+ return manifest
213
+ }
214
+ }
215
+
216
+ module.exports = ManifestParser
@@ -0,0 +1,48 @@
1
+ const Unzip = require('isomorphic-unzip')
2
+ const { isBrowser, decodeNullUnicode } = require('./utils')
3
+
4
+ class Zip {
5
+ constructor (file) {
6
+ if (isBrowser()) {
7
+ if (!(file instanceof window.Blob || typeof file.size !== 'undefined')) {
8
+ throw new Error('Param error: [file] must be an instance of Blob or File in browser.')
9
+ }
10
+ this.file = file
11
+ } else {
12
+ if (typeof file !== 'string') {
13
+ throw new Error('Param error: [file] must be file path in Node.')
14
+ }
15
+ this.file = require('path').resolve(file)
16
+ }
17
+ this.unzip = new Unzip(this.file)
18
+ }
19
+
20
+ /**
21
+ * get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
22
+ * @param {Array} regexps // regexps for matching files
23
+ * @param {String} type // return type, can be buffer or blob, default buffer
24
+ */
25
+ getEntries (regexps, type = 'buffer') {
26
+ regexps = regexps.map(regex => decodeNullUnicode(regex))
27
+ return new Promise((resolve, reject) => {
28
+ this.unzip.getBuffer(regexps, { type }, (err, buffers) => {
29
+ err ? reject(err) : resolve(buffers)
30
+ })
31
+ })
32
+ }
33
+ /**
34
+ * get entry by regex, return an instance of Buffer or Blob
35
+ * @param {Regex} regex // regex for matching file
36
+ * @param {String} type // return type, can be buffer or blob, default buffer
37
+ */
38
+ getEntry (regex, type = 'buffer') {
39
+ regex = decodeNullUnicode(regex)
40
+ return new Promise((resolve, reject) => {
41
+ this.unzip.getBuffer([regex], { type }, (err, buffers) => {
42
+ err ? reject(err) : resolve(buffers[regex])
43
+ })
44
+ })
45
+ }
46
+ }
47
+
48
+ module.exports = Zip
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
4
  import pkg from '../../package.json';
5
- import AppInfoParser from 'app-info-parser';
5
+ import AppInfoParser from './app-info-parser';
6
6
 
7
7
  import read from 'read';
8
8