@limrun/api 0.28.8 → 0.28.10
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/CHANGELOG.md +13 -0
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/folder-sync.d.mts.map +1 -1
- package/folder-sync.d.ts.map +1 -1
- package/folder-sync.js +2 -1
- package/folder-sync.js.map +1 -1
- package/folder-sync.mjs +2 -1
- package/folder-sync.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/internal/direct-instance-errors.d.mts +2 -0
- package/internal/direct-instance-errors.d.mts.map +1 -0
- package/internal/direct-instance-errors.d.ts +2 -0
- package/internal/direct-instance-errors.d.ts.map +1 -0
- package/internal/direct-instance-errors.js +12 -0
- package/internal/direct-instance-errors.js.map +1 -0
- package/internal/direct-instance-errors.mjs +9 -0
- package/internal/direct-instance-errors.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/xcode-instances-helpers.d.mts +42 -1
- package/resources/xcode-instances-helpers.d.mts.map +1 -1
- package/resources/xcode-instances-helpers.d.ts +42 -1
- package/resources/xcode-instances-helpers.d.ts.map +1 -1
- package/resources/xcode-instances-helpers.js +29 -11
- package/resources/xcode-instances-helpers.js.map +1 -1
- package/resources/xcode-instances-helpers.mjs +29 -11
- package/resources/xcode-instances-helpers.mjs.map +1 -1
- package/src/client.ts +12 -0
- package/src/folder-sync.ts +2 -1
- package/src/index.ts +6 -0
- package/src/internal/direct-instance-errors.ts +14 -0
- package/src/resources/index.ts +6 -0
- package/src/resources/xcode-instances-helpers.ts +89 -13
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '../folder-sync';
|
|
13
13
|
import { createIgnoreFn } from '../folder-sync-ignore';
|
|
14
14
|
import { nodeProxyTransport } from '../internal/proxy-transport';
|
|
15
|
+
import { directInstanceHttpError } from '../internal/direct-instance-errors';
|
|
15
16
|
|
|
16
17
|
export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
17
18
|
|
|
@@ -89,6 +90,52 @@ export type XcodeBuildOptions = {
|
|
|
89
90
|
reactNative?: ReactNativeBuildConfig;
|
|
90
91
|
};
|
|
91
92
|
|
|
93
|
+
export type SimulatorInstallState =
|
|
94
|
+
| 'notInstalled'
|
|
95
|
+
| 'installedOnAttachedSimulator'
|
|
96
|
+
| 'installedOnOtherSimulator';
|
|
97
|
+
|
|
98
|
+
export type SimulatorDeviceInfo = {
|
|
99
|
+
arch: string;
|
|
100
|
+
model: string;
|
|
101
|
+
name: string;
|
|
102
|
+
osVersion: string;
|
|
103
|
+
platform: string;
|
|
104
|
+
screenHeight: number;
|
|
105
|
+
screenWidth: number;
|
|
106
|
+
udid: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type SimulatorAttachment = {
|
|
110
|
+
apiUrl: string;
|
|
111
|
+
iosInstanceId?: string;
|
|
112
|
+
target?: SimulatorDeviceInfo;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type SimulatorBuildStatus = {
|
|
116
|
+
buildId: string;
|
|
117
|
+
sdk: string;
|
|
118
|
+
bundleId?: string;
|
|
119
|
+
installState: SimulatorInstallState;
|
|
120
|
+
syncDurationMs?: number;
|
|
121
|
+
installDurationMs?: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type SimulatorStatus = {
|
|
125
|
+
attached: boolean;
|
|
126
|
+
simulator?: SimulatorAttachment;
|
|
127
|
+
latestBuild?: SimulatorBuildStatus;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type SimulatorAttachResult = {
|
|
131
|
+
attached: boolean;
|
|
132
|
+
alreadyAttached: boolean;
|
|
133
|
+
installedLastBuild: boolean;
|
|
134
|
+
simulator?: SimulatorAttachment;
|
|
135
|
+
latestBuild?: SimulatorBuildStatus;
|
|
136
|
+
installError?: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
92
139
|
export type XcodeClient = {
|
|
93
140
|
/**
|
|
94
141
|
* Sync source code to the xcode instance. In watch mode, keeps syncing on changes.
|
|
@@ -110,7 +157,14 @@ export type XcodeClient = {
|
|
|
110
157
|
* Attach a simulator to this xcode instance.
|
|
111
158
|
* After attaching, builds will auto-install on the simulator.
|
|
112
159
|
*/
|
|
113
|
-
attachSimulator: (
|
|
160
|
+
attachSimulator: (
|
|
161
|
+
simulator: IosInstance | { apiUrl: string; token: string },
|
|
162
|
+
) => Promise<SimulatorAttachResult>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Return the currently attached simulator and latest installable build state.
|
|
166
|
+
*/
|
|
167
|
+
getSimulator: () => Promise<SimulatorStatus>;
|
|
114
168
|
};
|
|
115
169
|
|
|
116
170
|
export type XcodeCreateClientParams =
|
|
@@ -156,11 +210,7 @@ async function fetchSandboxInfo(apiUrl: string, token: string): Promise<{ homeDi
|
|
|
156
210
|
Authorization: `Bearer ${token}`,
|
|
157
211
|
},
|
|
158
212
|
});
|
|
159
|
-
const
|
|
160
|
-
if (!res.ok) {
|
|
161
|
-
throw new Error(`GET /info failed: ${res.status} ${text}`);
|
|
162
|
-
}
|
|
163
|
-
const body = JSON.parse(text) as { homeDir?: string };
|
|
213
|
+
const body = await readJsonResponse<{ homeDir?: string }>(res, 'GET /info');
|
|
164
214
|
if (!body.homeDir) {
|
|
165
215
|
throw new Error('GET /info response is missing homeDir');
|
|
166
216
|
}
|
|
@@ -169,6 +219,17 @@ async function fetchSandboxInfo(apiUrl: string, token: string): Promise<{ homeDi
|
|
|
169
219
|
};
|
|
170
220
|
}
|
|
171
221
|
|
|
222
|
+
async function readJsonResponse<T>(res: Response, operation: string): Promise<T> {
|
|
223
|
+
const text = await res.text();
|
|
224
|
+
if (!res.ok) {
|
|
225
|
+
throw directInstanceHttpError(operation, res.status, text, res.headers);
|
|
226
|
+
}
|
|
227
|
+
if (!text.trim()) {
|
|
228
|
+
throw new Error(`${operation} returned an empty response`);
|
|
229
|
+
}
|
|
230
|
+
return JSON.parse(text) as T;
|
|
231
|
+
}
|
|
232
|
+
|
|
172
233
|
export class XcodeInstances extends GeneratedXcodeInstances {
|
|
173
234
|
async createClient(params: XcodeCreateClientParams): Promise<XcodeClient> {
|
|
174
235
|
let apiUrl: string;
|
|
@@ -186,7 +247,11 @@ export class XcodeInstances extends GeneratedXcodeInstances {
|
|
|
186
247
|
|
|
187
248
|
const log = createLogger(params.logLevel ?? 'info');
|
|
188
249
|
const client = this._client;
|
|
189
|
-
|
|
250
|
+
let sandboxInfoPromise: Promise<{ homeDir: string }> | undefined;
|
|
251
|
+
const getSandboxInfo = () => {
|
|
252
|
+
sandboxInfoPromise ??= fetchSandboxInfo(apiUrl, token);
|
|
253
|
+
return sandboxInfoPromise;
|
|
254
|
+
};
|
|
190
255
|
|
|
191
256
|
return {
|
|
192
257
|
async sync(localCodePath: string, opts?: SyncOptions): Promise<SyncResult> {
|
|
@@ -195,10 +260,12 @@ export class XcodeInstances extends GeneratedXcodeInstances {
|
|
|
195
260
|
const hash = crypto.createHash('sha1').update(resolvedPath).digest('hex').slice(0, 8);
|
|
196
261
|
const cacheKey = `limsync-cache-${folderName}-${hash}`;
|
|
197
262
|
const basisCacheDir = opts?.basisCacheDir ?? path.join(os.tmpdir(), cacheKey);
|
|
263
|
+
const sandboxInfo =
|
|
264
|
+
opts?.additionalFiles && opts.additionalFiles.length > 0 ? await getSandboxInfo() : undefined;
|
|
198
265
|
const additionalFiles = opts?.additionalFiles?.map((file) => ({
|
|
199
266
|
localPath: file.localPath,
|
|
200
267
|
remotePath:
|
|
201
|
-
file.remotePath.startsWith('~/') ?
|
|
268
|
+
sandboxInfo && file.remotePath.startsWith('~/') ?
|
|
202
269
|
`${sandboxInfo.homeDir}/${file.remotePath.slice(2)}`
|
|
203
270
|
: file.remotePath,
|
|
204
271
|
}));
|
|
@@ -292,7 +359,19 @@ export class XcodeInstances extends GeneratedXcodeInstances {
|
|
|
292
359
|
return exec(request, { apiUrl, token, log });
|
|
293
360
|
},
|
|
294
361
|
|
|
295
|
-
async
|
|
362
|
+
async getSimulator(): Promise<SimulatorStatus> {
|
|
363
|
+
const res = await nodeProxyTransport.fetch(`${apiUrl}/simulator`, {
|
|
364
|
+
method: 'GET',
|
|
365
|
+
headers: {
|
|
366
|
+
Authorization: `Bearer ${token}`,
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
return readJsonResponse<SimulatorStatus>(res, 'GET /simulator');
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
async attachSimulator(
|
|
373
|
+
simulator: IosInstance | { apiUrl: string; token: string },
|
|
374
|
+
): Promise<SimulatorAttachResult> {
|
|
296
375
|
let simApiUrl: string;
|
|
297
376
|
let simToken: string;
|
|
298
377
|
if ('status' in simulator) {
|
|
@@ -314,10 +393,7 @@ export class XcodeInstances extends GeneratedXcodeInstances {
|
|
|
314
393
|
},
|
|
315
394
|
body: JSON.stringify({ apiUrl: simApiUrl, token: simToken }),
|
|
316
395
|
});
|
|
317
|
-
|
|
318
|
-
const text = await res.text();
|
|
319
|
-
throw new Error(`POST /simulator failed: ${res.status} ${text}`);
|
|
320
|
-
}
|
|
396
|
+
return readJsonResponse<SimulatorAttachResult>(res, 'POST /simulator');
|
|
321
397
|
},
|
|
322
398
|
};
|
|
323
399
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.28.
|
|
1
|
+
export const VERSION = '0.28.10'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.28.
|
|
1
|
+
export declare const VERSION = "0.28.10";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.28.
|
|
1
|
+
export declare const VERSION = "0.28.10";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
package/version.js
CHANGED
package/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,SAAS,CAAC,CAAC,2BAA2B"}
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.28.
|
|
1
|
+
export const VERSION = '0.28.10'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,2BAA2B"}
|