peachsim 0.1.2430 → 0.1.2431
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/cli/commands/preview.ts +2 -1
- package/cli/outbound-endpoints.ts +10 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +15765 -5973
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +14638 -4888
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +15464 -5754
- package/dist-lib/host/fetch-proxy-handler.cjs +3204 -54
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +3541 -391
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +3437 -287
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +172 -79
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +16782 -6989
- package/dist-lib/swift-compile.cjs +2 -2
- package/dist-lib/swift-compile.mjs +2 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +74 -6
- package/dist-lib/vite.cjs +3331 -181
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/expo-native-workspace.ts +23 -63
- package/src/pbx-table.ts +200 -0
- package/src/pod-sources.ts +628 -0
- package/src/podfile-cocoapods.ts +40 -3
- package/src/pods-analysis.ts +488 -0
- package/src/pods-build-settings.ts +1015 -0
- package/src/pods-files.ts +478 -0
- package/src/pods-install.ts +475 -0
- package/src/pods-integration.ts +778 -0
- package/src/pods-post-install.ts +1811 -0
- package/src/pods-project.ts +2416 -0
- package/src/pods-scripts.ts +409 -0
- package/src/pods-targets.ts +757 -0
- package/src/pods-xcconfig.ts +198 -0
- package/src/podspec-cocoapods.ts +29 -3
- package/src/podspec-ruby-stdlib.ts +111 -10
- package/src/podspec-ruby.ts +52 -8
- package/src/swift-catalog-png.ts +75 -0
- package/src/swift-host.ts +4 -3
- package/src/swift-root-lock.ts +0 -10
- package/src/swift-source-pods.ts +29 -73
- package/src/turbo-source.ts +16 -37
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
// what `pod install` leaves in an app's ios directory, made without CocoaPods or Ruby: the Podfile
|
|
2
|
+
// is evaluated and resolved on Peach's Ruby interpreter, pod sources come from Peach's cache, and
|
|
3
|
+
// the Pods project, support files, header links, integrated app project, workspace, Local Podspecs
|
|
4
|
+
// and lockfiles are written as CocoaPods 1.17 writes them. the lockfile writer follows
|
|
5
|
+
// cocoapods-core's YAMLHelper (MIT).
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import path from 'node:path'
|
|
8
|
+
import { isDict, list, parseOpenStepPlist, str, type PlistDict } from './openstep-plist'
|
|
9
|
+
import { PbxTable, serializePbxproj } from './pbx-table'
|
|
10
|
+
import { cleanInstalledPod, podSourceRoot } from './pod-sources'
|
|
11
|
+
import { evaluatePodfile, resolvePodfile } from './podfile-cocoapods'
|
|
12
|
+
import { analyzePods } from './pods-analysis'
|
|
13
|
+
import { PodsBuildSettings } from './pods-build-settings'
|
|
14
|
+
import {
|
|
15
|
+
projectObjects,
|
|
16
|
+
rubyProject,
|
|
17
|
+
runInstallHooks,
|
|
18
|
+
type ProjectTable,
|
|
19
|
+
} from './pods-post-install'
|
|
20
|
+
import { finalizePodsProject, generatePodsProject } from './pods-project'
|
|
21
|
+
import { createPodTargets, Sandbox } from './pods-targets'
|
|
22
|
+
import { rubyFailures } from './podspec-cocoapods'
|
|
23
|
+
import { RHash, RString, RSymbol, type Interpreter, type Value } from './podspec-ruby'
|
|
24
|
+
import { toJson } from './podspec-ruby-stdlib'
|
|
25
|
+
|
|
26
|
+
const COCOAPODS_VERSION = '1.17.0'
|
|
27
|
+
|
|
28
|
+
const INSTALL_INPUTS = String.raw`
|
|
29
|
+
lambda do |podfile, sandbox, resolver|
|
|
30
|
+
roots = resolver.specifications.map(&:root).uniq
|
|
31
|
+
{
|
|
32
|
+
'definitions' => podfile.target_definition_list.reject(&:abstract?).map do |td|
|
|
33
|
+
{ 'name' => td.name.to_s, 'project' => td.user_project_path&.to_s, 'configurations' => (td.build_configurations || {}).map { |name, type| [name.to_s, type.to_s] }.to_h }
|
|
34
|
+
end,
|
|
35
|
+
'workspace' => podfile.workspace_path&.to_s,
|
|
36
|
+
'downloads' => roots.reject { |spec| sandbox.local?(spec.name) }.map { |spec| [spec.name, spec.to_pretty_json] },
|
|
37
|
+
'stored' => sandbox.stored_podspecs.map { |name, spec| [name, spec.to_pretty_json] },
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
// Lockfile.generate
|
|
43
|
+
const LOCKFILE = String.raw`
|
|
44
|
+
lambda do |podfile, sandbox, resolver|
|
|
45
|
+
specs = resolver.specifications
|
|
46
|
+
pods = specs.each_with_object({}) { |spec, result| (result[spec.to_s] ||= []).concat(spec.all_dependencies.map(&:to_s)) }
|
|
47
|
+
trunk = specs.map(&:root).uniq.reject { |spec| sandbox.specification(spec.name) }.map(&:name)
|
|
48
|
+
{
|
|
49
|
+
'PODS' => pods.map { |name, deps| deps.empty? ? name : { name => deps.uniq } },
|
|
50
|
+
'DEPENDENCIES' => podfile.dependencies.map(&:to_s),
|
|
51
|
+
'SPEC REPOS' => trunk.empty? ? {} : { 'trunk' => trunk },
|
|
52
|
+
'EXTERNAL SOURCES' => podfile.dependencies.select(&:external?).each_with_object({}) { |dep, result| result[dep.root_name] = dep.external_source },
|
|
53
|
+
'SPEC CHECKSUMS' => specs.select(&:defined_in_file).each_with_object({}) { |spec, result| result[spec.root.name] = spec.checksum },
|
|
54
|
+
'PODFILE CHECKSUM' => podfile.checksum,
|
|
55
|
+
'COCOAPODS' => '${COCOAPODS_VERSION}',
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
`
|
|
59
|
+
|
|
60
|
+
const LOCKFILE_KEYS = [
|
|
61
|
+
'PODS',
|
|
62
|
+
'DEPENDENCIES',
|
|
63
|
+
'SPEC REPOS',
|
|
64
|
+
'EXTERNAL SOURCES',
|
|
65
|
+
'CHECKOUT OPTIONS',
|
|
66
|
+
'SPEC CHECKSUMS',
|
|
67
|
+
'PODFILE CHECKSUM',
|
|
68
|
+
'COCOAPODS',
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
interface InstallInputs {
|
|
72
|
+
definitions: {
|
|
73
|
+
name: string
|
|
74
|
+
project: string | null
|
|
75
|
+
configurations: Record<string, string>
|
|
76
|
+
}[]
|
|
77
|
+
workspace: string | null
|
|
78
|
+
downloads: [string, string][]
|
|
79
|
+
stored: [string, string][]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
83
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
84
|
+
const isPairs = (value: unknown): value is [string, string][] =>
|
|
85
|
+
Array.isArray(value) &&
|
|
86
|
+
value.every(
|
|
87
|
+
(pair) =>
|
|
88
|
+
Array.isArray(pair) && typeof pair[0] === 'string' && typeof pair[1] === 'string',
|
|
89
|
+
)
|
|
90
|
+
const isInstallInputs = (value: unknown): value is InstallInputs =>
|
|
91
|
+
isRecord(value) &&
|
|
92
|
+
Array.isArray(value.definitions) &&
|
|
93
|
+
value.definitions.every(
|
|
94
|
+
(definition) =>
|
|
95
|
+
isRecord(definition) &&
|
|
96
|
+
typeof definition.name === 'string' &&
|
|
97
|
+
(definition.project === null || typeof definition.project === 'string') &&
|
|
98
|
+
isRecord(definition.configurations),
|
|
99
|
+
) &&
|
|
100
|
+
(value.workspace === null || typeof value.workspace === 'string') &&
|
|
101
|
+
isPairs(value.downloads) &&
|
|
102
|
+
isPairs(value.stored)
|
|
103
|
+
|
|
104
|
+
function readProject(xcodeproj: string): ProjectTable {
|
|
105
|
+
const parsed = parseOpenStepPlist(
|
|
106
|
+
fs.readFileSync(path.join(xcodeproj, 'project.pbxproj'), 'utf8'),
|
|
107
|
+
)
|
|
108
|
+
if (
|
|
109
|
+
!isDict(parsed) ||
|
|
110
|
+
!isDict(parsed.objects) ||
|
|
111
|
+
typeof parsed.rootObject !== 'string' ||
|
|
112
|
+
typeof parsed.objectVersion !== 'string'
|
|
113
|
+
)
|
|
114
|
+
throw new Error(`${xcodeproj} holds no Xcode project`)
|
|
115
|
+
const objects: Record<string, PlistDict> = {}
|
|
116
|
+
for (const [id, object] of Object.entries(parsed.objects))
|
|
117
|
+
if (isDict(object)) objects[id] = object
|
|
118
|
+
return {
|
|
119
|
+
path: xcodeproj,
|
|
120
|
+
objects,
|
|
121
|
+
rootObject: parsed.rootObject,
|
|
122
|
+
objectVersion: parsed.objectVersion,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// TargetInspector: the user targets, configurations and Swift version of the Podfile's target
|
|
127
|
+
function inspectUserProject(
|
|
128
|
+
iosRoot: string,
|
|
129
|
+
definition: InstallInputs['definitions'][number],
|
|
130
|
+
) {
|
|
131
|
+
let xcodeproj: string
|
|
132
|
+
if (definition.project) xcodeproj = path.resolve(iosRoot, definition.project)
|
|
133
|
+
else {
|
|
134
|
+
const found = fs.readdirSync(iosRoot).filter((name) => name.endsWith('.xcodeproj'))
|
|
135
|
+
if (found.length !== 1)
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Could not automatically select an Xcode project in ${iosRoot}. Specify one in your Podfile like so:\n\n project 'path/to/Project.xcodeproj'`,
|
|
138
|
+
)
|
|
139
|
+
xcodeproj = path.join(iosRoot, found[0]!)
|
|
140
|
+
}
|
|
141
|
+
const project = readProject(xcodeproj)
|
|
142
|
+
const table = new PbxTable(project.objects, project.rootObject)
|
|
143
|
+
const nativeTargets = list(table.get(project.rootObject).targets).filter(
|
|
144
|
+
(id) => table.get(id).isa === 'PBXNativeTarget',
|
|
145
|
+
)
|
|
146
|
+
const targetIds = nativeTargets.filter(
|
|
147
|
+
(id) => table.string(id, 'name') === definition.name,
|
|
148
|
+
)
|
|
149
|
+
if (targetIds.length === 0)
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Unable to find a target named \`${definition.name}\` in project \`${path.basename(xcodeproj)}\`, did find ${nativeTargets.map((id) => `\`${table.string(id, 'name')}\``).join(', ')}.`,
|
|
152
|
+
)
|
|
153
|
+
const projectSettings = new Map(
|
|
154
|
+
table
|
|
155
|
+
.configurations(project.rootObject)
|
|
156
|
+
.map((id) => [table.string(id, 'name'), table.buildSettings(id)]),
|
|
157
|
+
)
|
|
158
|
+
const buildConfigurations: Record<string, 'debug' | 'release'> = {}
|
|
159
|
+
const swiftVersions = new Set<string>()
|
|
160
|
+
for (const target of targetIds)
|
|
161
|
+
for (const config of table.configurations(target)) {
|
|
162
|
+
const name = table.string(config, 'name') ?? ''
|
|
163
|
+
buildConfigurations[name] = name === 'Debug' ? 'debug' : 'release'
|
|
164
|
+
const version =
|
|
165
|
+
str(table.buildSettings(config).SWIFT_VERSION) ??
|
|
166
|
+
str(projectSettings.get(name)?.SWIFT_VERSION)
|
|
167
|
+
if (version) swiftVersions.add(version)
|
|
168
|
+
}
|
|
169
|
+
for (const [name, type] of Object.entries(definition.configurations))
|
|
170
|
+
buildConfigurations[name] = type === 'debug' ? 'debug' : 'release'
|
|
171
|
+
if (swiftVersions.size > 1)
|
|
172
|
+
throw new Error(
|
|
173
|
+
`There may only be up to 1 unique SWIFT_VERSION per target. Found target(s) with multiple Swift versions: ${definition.name}`,
|
|
174
|
+
)
|
|
175
|
+
return {
|
|
176
|
+
project,
|
|
177
|
+
targetIds,
|
|
178
|
+
buildConfigurations,
|
|
179
|
+
swiftVersion: [...swiftVersions][0] ?? null,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const byBytes = (a: string, b: string) => Buffer.compare(Buffer.from(a), Buffer.from(b))
|
|
184
|
+
|
|
185
|
+
// YAMLHelper#process_string
|
|
186
|
+
const RESOLVED_TAG =
|
|
187
|
+
/^(?:null|Null|NULL|~|true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO|on|On|ON|off|Off|OFF|[0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}(?:[Tt]|[ \t]+)[0-9]{1,2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]*)?(?:[ \t]*(?:Z|[-+][0-9]{1,2}(?::[0-9]{2})?))?|[-+]?[0-9]+|00[0-7]+|0x[0-9a-fA-F]+|[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))?$/
|
|
188
|
+
const INDICATOR_START = /^[-?:,[\]{}#&*!|>'"%@`]/
|
|
189
|
+
const PLAIN_SCALAR = /^[A-Za-z0-9_][A-Za-z0-9_/ ()~<>=.:`,-]*$/
|
|
190
|
+
const INSPECT_ESCAPES: Record<string, string> = {
|
|
191
|
+
'"': '\\"',
|
|
192
|
+
'\\': '\\\\',
|
|
193
|
+
'\n': '\\n',
|
|
194
|
+
'\t': '\\t',
|
|
195
|
+
'\r': '\\r',
|
|
196
|
+
'\u001b': '\\e',
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// String#inspect
|
|
200
|
+
const inspect = (text: string) =>
|
|
201
|
+
`"${text.replace(/["\\\n\t\r\u001b]|#(?=[{$@])|[\u0000-\u001f\u007f]/g, (c) =>
|
|
202
|
+
c === '#'
|
|
203
|
+
? '\\#'
|
|
204
|
+
: (INSPECT_ESCAPES[c] ??
|
|
205
|
+
`\\u${c.charCodeAt(0).toString(16).toUpperCase().padStart(4, '0')}`),
|
|
206
|
+
)}"`
|
|
207
|
+
|
|
208
|
+
function yamlString(text: string): string {
|
|
209
|
+
if (RESOLVED_TAG.test(text)) return `'${text}'`
|
|
210
|
+
if (/^\s*$/.test(text) || INDICATOR_START.test(text) || text.endsWith(':'))
|
|
211
|
+
return inspect(text)
|
|
212
|
+
return PLAIN_SCALAR.test(text) ? text : inspect(text)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// YAMLHelper#sorting_string
|
|
216
|
+
function sortingString(interp: Interpreter, value: Value): string {
|
|
217
|
+
if (value === null) return ''
|
|
218
|
+
if (value instanceof RString) return value.s.toLowerCase()
|
|
219
|
+
if (value instanceof RSymbol) return value.name.toLowerCase()
|
|
220
|
+
if (Array.isArray(value)) return sortingString(interp, value[0] ?? null)
|
|
221
|
+
if (value instanceof RHash)
|
|
222
|
+
return value
|
|
223
|
+
.entries()
|
|
224
|
+
.map(([key]) => interp.toS(key).toLowerCase())
|
|
225
|
+
.sort(byBytes)[0]!
|
|
226
|
+
throw new Error(`Cannot sort ${interp.toS(value)}`)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const sortedValues = (interp: Interpreter, values: Value[]) =>
|
|
230
|
+
values
|
|
231
|
+
.map((value, index) => ({ value, key: sortingString(interp, value), index }))
|
|
232
|
+
.sort((a, b) => byBytes(a.key, b.key) || a.index - b.index)
|
|
233
|
+
.map(({ value }) => value)
|
|
234
|
+
|
|
235
|
+
const size = (value: Value) =>
|
|
236
|
+
Array.isArray(value)
|
|
237
|
+
? value.length
|
|
238
|
+
: value instanceof RHash
|
|
239
|
+
? value.entries().length
|
|
240
|
+
: 0
|
|
241
|
+
|
|
242
|
+
// YAMLHelper#process_according_to_class
|
|
243
|
+
function yaml(
|
|
244
|
+
interp: Interpreter,
|
|
245
|
+
value: Value,
|
|
246
|
+
hint: string[] | null = null,
|
|
247
|
+
separator = '\n',
|
|
248
|
+
): string {
|
|
249
|
+
if (Array.isArray(value)) {
|
|
250
|
+
if (value.length === 0) return '[]'
|
|
251
|
+
const items = sortedValues(interp, value).map((item) => {
|
|
252
|
+
const processed = yaml(interp, item)
|
|
253
|
+
if (size(item) <= 1) return processed
|
|
254
|
+
const [head, ...rest] = processed.split('\n')
|
|
255
|
+
return [head, ...rest.map((line) => ` ${line}`)].join('\n')
|
|
256
|
+
})
|
|
257
|
+
return `- ${items.join('\n- ').trim()}`
|
|
258
|
+
}
|
|
259
|
+
if (value instanceof RHash) {
|
|
260
|
+
const entries = value.entries()
|
|
261
|
+
if (entries.length === 0) return '{}'
|
|
262
|
+
const keys = entries.map(([key]) => key)
|
|
263
|
+
const named = (key: Value) => (key instanceof RString ? key.s : null)
|
|
264
|
+
const hinted = (hint ?? []).flatMap((name) =>
|
|
265
|
+
keys.filter((key) => named(key) === name),
|
|
266
|
+
)
|
|
267
|
+
const ordered = [
|
|
268
|
+
...hinted,
|
|
269
|
+
...sortedValues(
|
|
270
|
+
interp,
|
|
271
|
+
keys.filter((key) => !hinted.includes(key)),
|
|
272
|
+
),
|
|
273
|
+
]
|
|
274
|
+
return ordered
|
|
275
|
+
.map((key) => {
|
|
276
|
+
const item = value.get(key) ?? null
|
|
277
|
+
const processed = yaml(interp, item)
|
|
278
|
+
const processedKey = yaml(interp, key)
|
|
279
|
+
return Array.isArray(item) || item instanceof RHash
|
|
280
|
+
? `${processedKey}:\n${processed.replace(/^/gm, ' ')}`
|
|
281
|
+
: `${processedKey}: ${processed}`
|
|
282
|
+
})
|
|
283
|
+
.join(separator)
|
|
284
|
+
}
|
|
285
|
+
if (value instanceof RString) return yamlString(value.s).trim()
|
|
286
|
+
if (value instanceof RSymbol) return `:${value.name}`
|
|
287
|
+
throw new Error(
|
|
288
|
+
`the lockfile holds ${interp.toS(value)}, which YAMLHelper does not write`,
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Lockfile#to_yaml of `lock`, dropping empty sections as Lockfile#to_hash does. */
|
|
293
|
+
function lockfileYaml(interp: Interpreter, lock: Value): string {
|
|
294
|
+
if (!(lock instanceof RHash)) throw new Error('Lockfile.generate returned no hash')
|
|
295
|
+
const kept = RHash.from(
|
|
296
|
+
lock.entries().filter(([, value]) => size(value) > 0 || value instanceof RString),
|
|
297
|
+
)
|
|
298
|
+
return `${yaml(interp, kept, LOCKFILE_KEYS, '\n\n')}\n`
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Xcodeproj::Workspace#to_s for a new workspace, and the FileRefs it appends to an existing one
|
|
302
|
+
const fileRef = (location: string) =>
|
|
303
|
+
` <FileRef\n location = "group:${location}">\n </FileRef>\n`
|
|
304
|
+
|
|
305
|
+
function writeWorkspace(workspace: string, projects: string[]) {
|
|
306
|
+
const dataFile = path.join(workspace, 'contents.xcworkspacedata')
|
|
307
|
+
const locations = projects.map((project) =>
|
|
308
|
+
path.relative(path.dirname(workspace), project),
|
|
309
|
+
)
|
|
310
|
+
if (!fs.existsSync(dataFile)) {
|
|
311
|
+
fs.mkdirSync(workspace, { recursive: true })
|
|
312
|
+
fs.writeFileSync(
|
|
313
|
+
dataFile,
|
|
314
|
+
`<?xml version="1.0" encoding="UTF-8"?>\n<Workspace\n version = "1.0">\n${locations.map(fileRef).join('')}</Workspace>\n`,
|
|
315
|
+
)
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
const existing = fs.readFileSync(dataFile, 'utf8')
|
|
319
|
+
const missing = locations.filter(
|
|
320
|
+
(location) => !existing.includes(`"group:${location}"`),
|
|
321
|
+
)
|
|
322
|
+
if (missing.length === 0) return
|
|
323
|
+
const end = existing.lastIndexOf('</Workspace>')
|
|
324
|
+
if (end < 0) throw new Error(`${dataFile} is no Xcode workspace`)
|
|
325
|
+
fs.writeFileSync(
|
|
326
|
+
dataFile,
|
|
327
|
+
`${existing.slice(0, end)}${missing.map(fileRef).join('')}${existing.slice(end)}`,
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** installs the pods of `app`'s ios/Podfile as `pod install` does, with `env` as the Podfile's ENV. */
|
|
332
|
+
export async function installPods(
|
|
333
|
+
app: string,
|
|
334
|
+
env: Record<string, string | undefined>,
|
|
335
|
+
): Promise<{ timings: Record<string, number> }> {
|
|
336
|
+
const timings: Record<string, number> = {}
|
|
337
|
+
let started = performance.now()
|
|
338
|
+
const lap = (label: string) => {
|
|
339
|
+
const now = performance.now()
|
|
340
|
+
timings[label] = Math.round(now - started)
|
|
341
|
+
started = now
|
|
342
|
+
}
|
|
343
|
+
const resolved = await resolvePodfile(evaluatePodfile(app, env))
|
|
344
|
+
const { interp, file, podfile, sandbox: rubySandbox, resolver } = resolved
|
|
345
|
+
const iosRoot = path.dirname(file)
|
|
346
|
+
const call = (source: string, label: string) =>
|
|
347
|
+
rubyFailures(file, () =>
|
|
348
|
+
interp.callMethod(
|
|
349
|
+
interp.evalString(source, label),
|
|
350
|
+
'call',
|
|
351
|
+
[podfile, rubySandbox, resolver],
|
|
352
|
+
null,
|
|
353
|
+
null,
|
|
354
|
+
null,
|
|
355
|
+
null,
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
const inputs = toJson(interp, call(INSTALL_INPUTS, 'peach/install-inputs'))
|
|
359
|
+
if (!isInstallInputs(inputs))
|
|
360
|
+
throw new Error(`${file}: the Podfile's install inputs are malformed`)
|
|
361
|
+
const lock = lockfileYaml(interp, call(LOCKFILE, 'cocoapods-core/lockfile'))
|
|
362
|
+
lap('resolve')
|
|
363
|
+
|
|
364
|
+
const podsRoot = path.join(iosRoot, 'Pods')
|
|
365
|
+
fs.rmSync(podsRoot, { recursive: true, force: true })
|
|
366
|
+
const downloaded = new Map<string, Record<string, unknown>>()
|
|
367
|
+
await Promise.all(
|
|
368
|
+
inputs.downloads.map(async ([name, json]) => {
|
|
369
|
+
const spec: unknown = JSON.parse(json)
|
|
370
|
+
if (!isRecord(spec)) throw new Error(`${name}: the specification is no JSON object`)
|
|
371
|
+
downloaded.set(name, spec)
|
|
372
|
+
fs.cpSync(await podSourceRoot(spec), path.join(podsRoot, name), {
|
|
373
|
+
recursive: true,
|
|
374
|
+
mode: fs.constants.COPYFILE_FICLONE,
|
|
375
|
+
verbatimSymlinks: true,
|
|
376
|
+
})
|
|
377
|
+
}),
|
|
378
|
+
)
|
|
379
|
+
const specifications = path.join(podsRoot, 'Local Podspecs')
|
|
380
|
+
fs.mkdirSync(specifications, { recursive: true })
|
|
381
|
+
for (const [name, json] of inputs.stored)
|
|
382
|
+
fs.writeFileSync(path.join(specifications, `${name}.podspec.json`), json)
|
|
383
|
+
lap('download')
|
|
384
|
+
|
|
385
|
+
const [definition, ...others] = inputs.definitions
|
|
386
|
+
if (!definition || others.length > 0)
|
|
387
|
+
throw new Error(
|
|
388
|
+
`${file}: Peach installs the pods of one application target, not ${inputs.definitions.map((d) => d.name).join(', ') || 'none'}`,
|
|
389
|
+
)
|
|
390
|
+
const user = inspectUserProject(iosRoot, definition)
|
|
391
|
+
const userProject = rubyProject(interp, user.project, 'Xcodeproj::Project')
|
|
392
|
+
const analysis = analyzePods(resolved, {
|
|
393
|
+
buildConfigurations: user.buildConfigurations,
|
|
394
|
+
project: userProject,
|
|
395
|
+
targetIds: user.targetIds,
|
|
396
|
+
swiftVersion: user.swiftVersion,
|
|
397
|
+
})
|
|
398
|
+
for (const [name, spec] of downloaded)
|
|
399
|
+
cleanInstalledPod(
|
|
400
|
+
spec,
|
|
401
|
+
path.join(podsRoot, name),
|
|
402
|
+
analysis.pods
|
|
403
|
+
.filter((pod) => pod.specs[0]?.name.split('/')[0] === name)
|
|
404
|
+
.map((pod) => ({
|
|
405
|
+
platform: pod.platform.name,
|
|
406
|
+
specs: pod.specs.map((s) => s.name),
|
|
407
|
+
})),
|
|
408
|
+
)
|
|
409
|
+
const sandbox = new Sandbox(podsRoot, (name) => path.join(podsRoot, name))
|
|
410
|
+
const targets = createPodTargets(
|
|
411
|
+
{ pods: analysis.pods, aggregates: analysis.aggregates },
|
|
412
|
+
sandbox,
|
|
413
|
+
iosRoot,
|
|
414
|
+
file,
|
|
415
|
+
)
|
|
416
|
+
const settings = new PodsBuildSettings(analysis.aggregates[0]!.setArcCompatibilityFlag)
|
|
417
|
+
const generated = generatePodsProject(targets, settings, {
|
|
418
|
+
podfilePath: file,
|
|
419
|
+
objectVersion: Number(user.project.objectVersion),
|
|
420
|
+
})
|
|
421
|
+
lap('generate')
|
|
422
|
+
|
|
423
|
+
const podsProject = rubyProject(
|
|
424
|
+
interp,
|
|
425
|
+
{
|
|
426
|
+
path: sandbox.projectPath,
|
|
427
|
+
objects: generated.table.objects,
|
|
428
|
+
rootObject: generated.table.rootObject,
|
|
429
|
+
objectVersion: generated.objectVersion,
|
|
430
|
+
},
|
|
431
|
+
'Pod::Project',
|
|
432
|
+
)
|
|
433
|
+
runInstallHooks(interp, file, {
|
|
434
|
+
installer: analysis.installer,
|
|
435
|
+
podsProject,
|
|
436
|
+
userProject,
|
|
437
|
+
results: generated.results,
|
|
438
|
+
targets,
|
|
439
|
+
settings,
|
|
440
|
+
aggregates: analysis.aggregates,
|
|
441
|
+
})
|
|
442
|
+
const pods = new PbxTable(
|
|
443
|
+
projectObjects(interp, podsProject),
|
|
444
|
+
generated.table.rootObject,
|
|
445
|
+
)
|
|
446
|
+
finalizePodsProject(pods, generated.objectVersion)
|
|
447
|
+
lap('hooks')
|
|
448
|
+
|
|
449
|
+
fs.mkdirSync(sandbox.projectPath, { recursive: true })
|
|
450
|
+
fs.writeFileSync(
|
|
451
|
+
path.join(sandbox.projectPath, 'project.pbxproj'),
|
|
452
|
+
serializePbxproj(pods.objects, pods.rootObject, generated.objectVersion),
|
|
453
|
+
)
|
|
454
|
+
fs.writeFileSync(
|
|
455
|
+
path.join(user.project.path, 'project.pbxproj'),
|
|
456
|
+
serializePbxproj(
|
|
457
|
+
projectObjects(interp, userProject),
|
|
458
|
+
user.project.rootObject,
|
|
459
|
+
user.project.objectVersion,
|
|
460
|
+
),
|
|
461
|
+
)
|
|
462
|
+
writeWorkspace(
|
|
463
|
+
inputs.workspace
|
|
464
|
+
? path.resolve(iosRoot, inputs.workspace)
|
|
465
|
+
: path.join(
|
|
466
|
+
iosRoot,
|
|
467
|
+
`${path.basename(user.project.path, '.xcodeproj')}.xcworkspace`,
|
|
468
|
+
),
|
|
469
|
+
[user.project.path, sandbox.projectPath],
|
|
470
|
+
)
|
|
471
|
+
fs.writeFileSync(path.join(iosRoot, 'Podfile.lock'), lock)
|
|
472
|
+
fs.writeFileSync(path.join(podsRoot, 'Manifest.lock'), lock)
|
|
473
|
+
lap('write')
|
|
474
|
+
return { timings }
|
|
475
|
+
}
|