expo 58.0.1 → 58.0.2

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.
@@ -11,8 +11,9 @@
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
13
 
14
- // No reader below is sensitive to a trailing `\r` today; the normalisation is here so
15
- // that one anchoring a pattern at line end does not quietly fail on a CRLF checkout.
14
+ const { APPLE_SOURCE_DIRS } = require('./classify');
15
+
16
+ // CRLF-safe.
16
17
  const sourceLines = (text) => text.replace(/\r\n/g, '\n').split('\n');
17
18
 
18
19
  // ---------------------------------------------------------------------------
@@ -121,10 +122,40 @@ function xcconfigLinkerFlags(text) {
121
122
  return null;
122
123
  }
123
124
 
125
+ /** Pod names a podspec depends on, ignoring `test_spec` blocks. Text-only. */
126
+ function podspecDependencies(text) {
127
+ const deps = [];
128
+ for (const { text: line } of podspecBodyLines(text)) {
129
+ const match = line.match(/\.dependency\s+['"]([^'"]+)['"]/);
130
+ if (match) deps.push(match[1]);
131
+ }
132
+ return deps;
133
+ }
134
+
124
135
  // ---------------------------------------------------------------------------
125
136
  // I/O
126
137
  // ---------------------------------------------------------------------------
127
138
 
139
+ function readText(file) {
140
+ try {
141
+ return fs.readFileSync(file, 'utf8');
142
+ } catch {
143
+ return null;
144
+ }
145
+ }
146
+
147
+ function podspecsIn(dir) {
148
+ try {
149
+ return fs
150
+ .readdirSync(dir)
151
+ .filter((name) => name.endsWith('.podspec'))
152
+ .sort()
153
+ .map((name) => path.join(dir, name));
154
+ } catch {
155
+ return [];
156
+ }
157
+ }
158
+
128
159
  /**
129
160
  * The podspecs describing `podName`: its own file when one carries its name, else
130
161
  * every podspec in the directories — a module may name its podspec anything.
@@ -134,17 +165,7 @@ function podspecFiles(podName, dirs) {
134
165
  const own = path.join(dir, `${podName}.podspec`);
135
166
  if (fs.existsSync(own)) return [own];
136
167
  }
137
- return dirs.flatMap((dir) => {
138
- try {
139
- return fs
140
- .readdirSync(dir)
141
- .filter((name) => name.endsWith('.podspec'))
142
- .sort()
143
- .map((name) => path.join(dir, name));
144
- } catch {
145
- return [];
146
- }
147
- });
168
+ return dirs.flatMap(podspecsIn);
148
169
  }
149
170
 
150
171
  /**
@@ -156,12 +177,8 @@ function podspecFiles(podName, dirs) {
156
177
  function readPodspecs(podName, dirs) {
157
178
  const texts = [];
158
179
  for (const file of podspecFiles(podName, dirs)) {
159
- let text = '';
160
- try {
161
- text = fs.readFileSync(file, 'utf8');
162
- } catch {
163
- continue;
164
- }
180
+ const text = readText(file);
181
+ if (text == null) continue;
165
182
  const declaration = linkageDeclaration(text);
166
183
  if (declaration != null) {
167
184
  return {
@@ -184,9 +201,29 @@ function readPodspecs(podName, dirs) {
184
201
  };
185
202
  }
186
203
 
204
+ /**
205
+ * Everything the plugin reads from a pod's podspecs, read once per pod. Linkage is
206
+ * looked for beside the pod and in the module's source directories and root;
207
+ * dependencies are read from every podspec in the pod's own directory, so a pod
208
+ * sharing it with siblings reports theirs too.
209
+ */
210
+ function readPodspecFacts({ podName, podspecDir, moduleRoot }) {
211
+ const dirs = [
212
+ podspecDir,
213
+ ...APPLE_SOURCE_DIRS.map((dir) => path.join(moduleRoot, dir)),
214
+ moduleRoot,
215
+ ].filter(Boolean);
216
+ const dependencies = new Set(
217
+ podspecsIn(podspecDir).flatMap((file) => podspecDependencies(readText(file) ?? ''))
218
+ );
219
+ return { ...readPodspecs(podName, dirs), dependencies: [...dependencies] };
220
+ }
221
+
187
222
  module.exports = {
188
223
  podspecBodyLines,
224
+ podspecDependencies,
189
225
  linkageDeclaration,
190
226
  xcconfigLinkerFlags,
191
227
  readPodspecs,
228
+ readPodspecFacts,
192
229
  };
package/template.tgz CHANGED
Binary file